<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
    <channel>
        <title>toshiki-notebook</title>
        <link>https://note.toshiki.dev</link>
        <description>Toshiki's web notebook served via Vitepress!</description>
        <lastBuildDate>Tue, 12 Mar 2024 18:19:55 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/jpmonette/feed</generator>
        <language>en-US</language>
        <image>
            <title>toshiki-notebook</title>
            <url>https://note.toshiki.dev/logo-308px.png</url>
            <link>https://note.toshiki.dev</link>
        </image>
        <copyright>Copyright (c) 2023-present, Anda Toshiki at Toshiki Dev</copyright>
        <item>
            <title><![CDATA[Welcome to Chemistry ]]></title>
            <link>https://note.toshiki.devacademic/chemistry/</link>
            <guid>https://note.toshiki.devacademic/chemistry/</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="welcome-to-chemistry" tabindex="-1">Welcome to Chemistry <a class="header-anchor" href="#welcome-to-chemistry" aria-label="Permalink to &quot;Welcome to Chemistry&quot;">&ZeroWidthSpace;</a></h1>
]]></description>
            <content:encoded><![CDATA[<h1 id="welcome-to-chemistry" tabindex="-1">Welcome to Chemistry <a class="header-anchor" href="#welcome-to-chemistry" aria-label="Permalink to &quot;Welcome to Chemistry&quot;">&ZeroWidthSpace;</a></h1>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[12-5: Reaction Mechanism]]></title>
            <link>https://note.toshiki.devacademic/chemistry/notes/12-5</link>
            <guid>https://note.toshiki.devacademic/chemistry/notes/12-5</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="_12-5-reaction-mechanism" tabindex="-1">12-5: Reaction Mechanism <a class="header-anchor" href="#_12-5-reaction-mechanism" aria-label="Permalink to &quot;12-5: Reaction Mechanism&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="_12-5-1-learning-objectives" tabindex="-1">12-5-1: Learning Objectives <a class="header-anchor" href="#_12-5-1-learning-objectives" aria-label="Permalink to &quot;12-5-1: Learning Objectives&quot;">&ZeroWidthSpace;</a></h2>
<div class="tip custom-block"><p class="custom-block-title">Learning Objectives</p>
<p>One of the major reasons for studying chemical kinetics is to use measurements of the macroscopic properties of a system, such as the rate of change in the concentration of reactants or products with time, to discover the sequence of events that occur at the molecular level during a reaction. This molecular description is the mechanism of the reaction; it describes how individual atoms, ions, or molecules interact to form particular products. The stepwise changes are collectively called the reaction mechanism.</p>
</div>
<p>In an internal combustion engine, for example, isooctane reacts with oxygen to give carbon dioxide and water:</p>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mn>2</mn><msub><mi mathvariant="normal">C</mi><mn>8</mn></msub><msub><mi mathvariant="normal">H</mi><mn>18</mn></msub><mo stretchy="false">(</mo><mi mathvariant="normal">l</mi><mo stretchy="false">)</mo><mo>+</mo><mn>25</mn><msub><mi mathvariant="normal">O</mi><mn>2</mn></msub><mo stretchy="false">(</mo><mrow><mtext> </mtext><mi mathvariant="normal">g</mi></mrow><mo stretchy="false">)</mo><mo>⟶</mo><mn>16</mn><msub><mrow><mi mathvariant="normal">C</mi><mi mathvariant="normal">O</mi></mrow><mn>2</mn></msub><mo stretchy="false">(</mo><mrow><mtext> </mtext><mi mathvariant="normal">g</mi></mrow><mo stretchy="false">)</mo><mo>+</mo><mn>18</mn><msub><mi mathvariant="normal">H</mi><mn>2</mn></msub><mi mathvariant="normal">O</mi><mo stretchy="false">(</mo><mi mathvariant="normal">g</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">2 \mathrm{C}_{8} \mathrm{H}_{18}(\mathrm{l})+25 \mathrm{O}_{2}(\mathrm{~g}) \longrightarrow 16 \mathrm{CO}_{2}(\mathrm{~g})+18 \mathrm{H}_{2} \mathrm{O}(\mathrm{g})
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">2</span><span class="mord"><span class="mord mathrm">C</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">8</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">H</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">18</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mopen">(</span><span class="mord mathrm">l</span><span class="mclose">)</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">25</span><span class="mord"><span class="mord mathrm">O</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mopen">(</span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm" style="margin-right:0.01389em;">g</span></span><span class="mclose">)</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">⟶</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">16</span><span class="mord"><span class="mord"><span class="mord mathrm">CO</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mopen">(</span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm" style="margin-right:0.01389em;">g</span></span><span class="mclose">)</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">18</span><span class="mord"><span class="mord mathrm">H</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord mathrm">O</span><span class="mopen">(</span><span class="mord mathrm" style="margin-right:0.01389em;">g</span><span class="mclose">)</span></span></span></span></span></p>
<p>For this reaction to occur in a single step, 25 dioxygen molecules and 2 isooctane molecules would have to collide simultaneously and be converted to 34 molecules of product, which is very unlikely. It is more likely that a complex series of reactions takes place in a stepwise fashion. Each individual reaction, which is called an elementary reaction, involves one, two, or (rarely) three atoms, molecules, or ions. The overall sequence of elementary reactions is the mechanism of the reaction. The sum of the individual steps, or elementary reactions, in the mechanism must give the balanced chemical equation for the overall reaction.</p>
<p>The overall sequence of elementary reactions is the mechanism of the reaction.</p>
<h2 id="_12-5-2-molecularity-and-the-rate-determining-step" tabindex="-1">12-5-2: Molecularity and the Rate-Determining Step <a class="header-anchor" href="#_12-5-2-molecularity-and-the-rate-determining-step" aria-label="Permalink to &quot;12-5-2: Molecularity and the Rate-Determining Step&quot;">&ZeroWidthSpace;</a></h2>
<p>To demonstrate how the analysis of elementary reactions helps us determine the overall reaction mechanism, we will examine the much simpler reaction of carbon monoxide with nitrogen dioxide.</p>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mn>2</mn><mi mathvariant="normal">C</mi><mi mathvariant="normal">O</mi><mo>+</mo><mn>2</mn><mi mathvariant="normal">N</mi><msub><mi mathvariant="normal">O</mi><mn>2</mn></msub><mo>→</mo><mn>2</mn><mi mathvariant="normal">C</mi><msub><mi mathvariant="normal">O</mi><mn>2</mn></msub><mo>+</mo><msub><mi mathvariant="normal">N</mi><mn>2</mn></msub><msub><mi mathvariant="normal">O</mi><mn>4</mn></msub></mrow><annotation encoding="application/x-tex">\mathrm{2CO + 2NO_2 \rightarrow 2CO_2 + N_2O_4}
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathrm">2CO</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathrm">2N</span><span class="mord"><span class="mord mathrm">O</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathrm mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">→</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord mathrm">2C</span><span class="mord"><span class="mord mathrm">O</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathrm mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathrm">N</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathrm mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">O</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathrm mtight">4</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span></span></span></p>
<p>From the balanced chemical equation, one might expect the reaction to occur via a collision of one molecule of <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mrow><mi mathvariant="normal">N</mi><mi mathvariant="normal">O</mi></mrow><mn>2</mn></msub></mrow><annotation encoding="application/x-tex">\mathrm{NO}_{2}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord"><span class="mord mathrm">NO</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> with a molecule of <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">C</mi><mi mathvariant="normal">O</mi></mrow><annotation encoding="application/x-tex">\mathrm{CO}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord"><span class="mord mathrm">CO</span></span></span></span></span> that results in the transfer of an oxygen atom from nitrogen to carbon. The experimentally determined rate law for the reaction, however, is as follows:</p>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mtext> rate </mtext><mo>=</mo><mi>k</mi><msup><mrow><mo fence="true">[</mo><msub><mrow><mi mathvariant="normal">N</mi><mi mathvariant="normal">O</mi></mrow><mn>2</mn></msub><mo fence="true">]</mo></mrow><mn>2</mn></msup></mrow><annotation encoding="application/x-tex">\text { rate }=k\left[\mathrm{NO}_{2}\right]^{2}
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6151em;"></span><span class="mord text"><span class="mord"> rate </span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.204em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="minner"><span class="mopen delimcenter" style="top:0em;">[</span><span class="mord"><span class="mord"><span class="mord mathrm">NO</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">]</span></span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.954em;"><span style="top:-3.2029em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span></span></span></span></p>
<p>The fact that the reaction is second order in <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true">[</mo><msub><mrow><mi mathvariant="normal">N</mi><mi mathvariant="normal">O</mi></mrow><mn>2</mn></msub><mo fence="true">]</mo></mrow><annotation encoding="application/x-tex">\left[\mathrm{NO}_{2}\right]</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">[</span><span class="mord"><span class="mord"><span class="mord mathrm">NO</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">]</span></span></span></span></span> and independent of <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">[</mo><mrow><mi mathvariant="normal">C</mi><mi mathvariant="normal">O</mi></mrow><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">[\mathrm{CO}]</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">[</span><span class="mord"><span class="mord mathrm">CO</span></span><span class="mclose">]</span></span></span></span> tells us that it does not occur by the simple collision model outlined previously. If it did, its predicted rate law would be</p>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mtext> rate </mtext><mo>=</mo><mi>k</mi><mrow><mo fence="true">[</mo><msub><mrow><mi mathvariant="normal">N</mi><mi mathvariant="normal">O</mi></mrow><mn>2</mn></msub><mo fence="true">]</mo></mrow><mo stretchy="false">[</mo><mrow><mi mathvariant="normal">C</mi><mi mathvariant="normal">O</mi></mrow><mo stretchy="false">]</mo><mi mathvariant="normal">.</mi></mrow><annotation encoding="application/x-tex">\text { rate }=k\left[\mathrm{NO}_{2}\right][\mathrm{CO}] .
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6151em;"></span><span class="mord text"><span class="mord"> rate </span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">[</span><span class="mord"><span class="mord"><span class="mord mathrm">NO</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">]</span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mopen">[</span><span class="mord"><span class="mord mathrm">CO</span></span><span class="mclose">]</span><span class="mord">.</span></span></span></span></span></p>
<p>The following two-step mechanism is consistent with the rate law if step 1 is much slower than step 2:</p>
<h3 id="_15-2-1-two-step-mechanism" tabindex="-1">15-2-1: Two-Step Mechanism <a class="header-anchor" href="#_15-2-1-two-step-mechanism" aria-label="Permalink to &quot;15-2-1: Two-Step Mechanism&quot;">&ZeroWidthSpace;</a></h3>
<table>
<thead>
<tr>
<th>Steps</th>
<th>Reaction</th>
<th>Reaction Type</th>
</tr>
</thead>
<tbody>
<tr>
<td>step 1</td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mrow><mi mathvariant="normal">N</mi><mi mathvariant="normal">O</mi></mrow><mn>2</mn></msub><mo>+</mo><msub><mrow><mi mathvariant="normal">N</mi><mi mathvariant="normal">O</mi></mrow><mn>2</mn></msub><mo><mover><mo><mo>⟶</mo></mo><mtext> slow </mtext></mover></mo><msub><mrow><mi mathvariant="normal">N</mi><mi mathvariant="normal">O</mi></mrow><mn>3</mn></msub><mo>+</mo><mrow><mi mathvariant="normal">N</mi><mi mathvariant="normal">O</mi></mrow></mrow><annotation encoding="application/x-tex">\mathrm{NO}_{2}+\mathrm{NO}_{2} \stackrel{\text { slow }}{\longrightarrow} \mathrm{NO}_{3}+\mathrm{NO}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord"><span class="mord mathrm">NO</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1.4471em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord"><span class="mord mathrm">NO</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel"><span class="mop op-limits"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.2971em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span><span class="mop">⟶</span></span></span><span style="top:-3.711em;margin-left:0em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord text mtight"><span class="mord mtight"> slow </span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.011em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord"><span class="mord mathrm">NO</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">3</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord"><span class="mord mathrm">NO</span></span></span></span></span></td>
<td>elementary reaction</td>
</tr>
<tr>
<td>step 2</td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><munder accentunder="true"><mrow><msub><mrow><mi mathvariant="normal">N</mi><mi mathvariant="normal">O</mi></mrow><mn>3</mn></msub><mo>+</mo><mrow><mi mathvariant="normal">C</mi><mi mathvariant="normal">O</mi></mrow><mo>→</mo><msub><mrow><mi mathvariant="normal">N</mi><mi mathvariant="normal">O</mi></mrow><mn>2</mn></msub><mo>+</mo><msub><mrow><mi mathvariant="normal">C</mi><mi mathvariant="normal">O</mi></mrow><mn>2</mn></msub></mrow><mo stretchy="true">‾</mo></munder></mrow><annotation encoding="application/x-tex">\underline{\mathrm{NO}_{3}+\mathrm{CO} \rightarrow \mathrm{NO}_{2}+\mathrm{CO}_{2}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0333em;vertical-align:-0.35em;"></span><span class="mord underline"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6833em;"><span style="top:-2.69em;"><span class="pstrut" style="height:3em;"></span><span class="underline-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord mathrm">NO</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">3</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathrm">CO</span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">→</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mord"><span class="mord mathrm">NO</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord"><span class="mord mathrm">CO</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.35em;"><span></span></span></span></span></span></span></span></span></td>
<td>elementary reaction</td>
</tr>
<tr>
<td>sum</td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mrow><mi mathvariant="normal">N</mi><mi mathvariant="normal">O</mi></mrow><mn>2</mn></msub><mo>+</mo><mrow><mi mathvariant="normal">C</mi><mi mathvariant="normal">O</mi></mrow><mo>→</mo><mrow><mi mathvariant="normal">N</mi><mi mathvariant="normal">O</mi></mrow><mo>+</mo><msub><mrow><mi mathvariant="normal">C</mi><mi mathvariant="normal">O</mi></mrow><mn>2</mn></msub></mrow><annotation encoding="application/x-tex">\mathrm{NO}_{2}+\mathrm{CO} \rightarrow \mathrm{NO}+\mathrm{CO}_{2}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord"><span class="mord mathrm">NO</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord"><span class="mord mathrm">CO</span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">→</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.7667em;vertical-align:-0.0833em;"></span><span class="mord"><span class="mord mathrm">NO</span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord"><span class="mord mathrm">CO</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span></td>
<td>overall reaction</td>
</tr>
</tbody>
</table>
<p>According to this mechanism, the overall reaction occurs in two steps, or elementary reactions. Summing steps 1 and 2 and canceling on both sides of the equation gives the overall balanced chemical equation for the reaction. The <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">N</mi><msub><mi mathvariant="normal">O</mi><mn>3</mn></msub></mrow><annotation encoding="application/x-tex">\mathrm{NO_3}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathrm">N</span><span class="mord"><span class="mord mathrm">O</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathrm mtight">3</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span></span> molecule is intermediate in the reaction, a species that does not appear in the balanced chemical equation for the overall reaction. It is formed as a product of the first step but is consumed in the second step.</p>
<p>The sum of the elementary reactions in a reaction mechanism must give the overall balanced chemical equation of the reaction.</p>
<h2 id="_12-5-3-using-molecularity-to-describe-a-rate-law" tabindex="-1">12-5-3: Using Molecularity to Describe a Rate Law <a class="header-anchor" href="#_12-5-3-using-molecularity-to-describe-a-rate-law" aria-label="Permalink to &quot;12-5-3: Using Molecularity to Describe a Rate Law&quot;">&ZeroWidthSpace;</a></h2>
<p>The molecularity of an elementary reaction is the number of molecules that collide during that step in the mechanism. If there is only a single reactant molecule in an elementary reaction, that step is designated as unimolecular; if there are two reactant molecules, it is bimolecular; and if there are three reactant molecules (a relatively rare situation), it is termolecular. Elementary reactions that involve the simultaneous collision of more than three molecules are highly improbable and have never been observed experimentally. (To understand why, try to make three or more marbles or pool balls collide with one another simultaneously!)</p>
<div class="warning custom-block"><p class="custom-block-title">About the image</p>
<p>The Basis for Writing Rate Laws of Elementary Reactions. This diagram illustrates how the number of possible collisions per unit time between two reactant species, A and B, depends on the number of A and B particles present. The number of collisions between A and B particles increases as the product of the number of particles, not as the sum. This is why the rate law for an elementary reaction depends on the product of the concentrations of the species that collide in that step. (CC BY-NC-SA; anonymous)</p>
</div>
<p>Writing the rate law for an elementary reaction is straightforward because we know how many molecules must collide simultaneously for the elementary reaction to occur; hence the order of the elementary reaction is the same as its molecularity (Table 14.6.1). In contrast, the rate law for the reaction cannot be determined from the balanced chemical equation for the overall reaction. The general rate law for a unimolecular elementary reaction ( <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">A</mi><mo>→</mo></mrow><annotation encoding="application/x-tex">\mathrm{A} \rightarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathrm">A</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">→</span></span></span></span> products) is</p>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mtext> rate </mtext><mo>=</mo><mi>k</mi><mo stretchy="false">[</mo><mi>A</mi><mo stretchy="false">]</mo><mi mathvariant="normal">.</mi></mrow><annotation encoding="application/x-tex">\text { rate }=k[A] .
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6151em;"></span><span class="mord text"><span class="mord"> rate </span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="mopen">[</span><span class="mord mathnormal">A</span><span class="mclose">]</span><span class="mord">.</span></span></span></span></span></p>
<p>For bimolecular reactions, the reaction rate depends on the number of collisions per unit time, which is proportional to the product of the concentrations of the reactants, as shown in Figure 14.6.1 For a bimolecular elementary reaction of the form <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">A</mi><mo>+</mo><mi mathvariant="normal">B</mi><mo>→</mo></mrow><annotation encoding="application/x-tex">\mathrm{A}+\mathrm{B} \rightarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7667em;vertical-align:-0.0833em;"></span><span class="mord mathrm">A</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathrm">B</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">→</span></span></span></span> products, the general rate law is</p>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mtext> rate </mtext><mo>=</mo><mi>k</mi><mo stretchy="false">[</mo><mi>A</mi><mo stretchy="false">]</mo><mo stretchy="false">[</mo><mi>B</mi><mo stretchy="false">]</mo><mi mathvariant="normal">.</mi></mrow><annotation encoding="application/x-tex">\text { rate }=k[A][B] .
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6151em;"></span><span class="mord text"><span class="mord"> rate </span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="mopen">[</span><span class="mord mathnormal">A</span><span class="mclose">]</span><span class="mopen">[</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span><span class="mclose">]</span><span class="mord">.</span></span></span></span></span></p>
<table>
<thead>
<tr>
<th>Elementary Reaction</th>
<th>Molecularity</th>
<th>Rate</th>
<th>Reaction Order</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">A</mi><mo>→</mo><mtext> products </mtext></mrow><annotation encoding="application/x-tex">\mathrm{A} \rightarrow \text { products }</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathrm">A</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">→</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord text"><span class="mord"> products </span></span></span></span></span></td>
<td>Unimolecular</td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext> rate </mtext><mo>=</mo><mi>k</mi><mo stretchy="false">[</mo><mrow><mtext> </mtext><mi mathvariant="normal">A</mi></mrow><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">\text { rate }=k[\mathrm{~A}]</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6151em;"></span><span class="mord text"><span class="mord"> rate </span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="mopen">[</span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">A</span></span><span class="mclose">]</span></span></span></span></td>
<td>first</td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>2</mn><mrow><mtext> </mtext><mi mathvariant="normal">A</mi></mrow><mo>→</mo><mtext> products </mtext></mrow><annotation encoding="application/x-tex">2\mathrm{~A} \rightarrow \text { products }</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">2</span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">A</span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">→</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord text"><span class="mord"> products </span></span></span></span></span></td>
<td>Bimolecular</td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext> rate </mtext><mo>=</mo><mi>k</mi><mo stretchy="false">[</mo><mrow><mtext> </mtext><mi mathvariant="normal">A</mi></mrow><msup><mo stretchy="false">]</mo><mn>2</mn></msup></mrow><annotation encoding="application/x-tex">\text { rate }=k[\mathrm{~A}]^2</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6151em;"></span><span class="mord text"><span class="mord"> rate </span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.0641em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="mopen">[</span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">A</span></span><span class="mclose"><span class="mclose">]</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span></span></td>
<td>second</td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">A</mi><mo>+</mo><mi mathvariant="normal">B</mi><mo>→</mo><mtext> products </mtext></mrow><annotation encoding="application/x-tex">\mathrm{A}+\mathrm{B} \rightarrow \text { products }</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7667em;vertical-align:-0.0833em;"></span><span class="mord mathrm">A</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathrm">B</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">→</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord text"><span class="mord"> products </span></span></span></span></span></td>
<td>Bimolecular</td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext> rate </mtext><mo>=</mo><mi>k</mi><mo stretchy="false">[</mo><mrow><mtext> </mtext><mi mathvariant="normal">A</mi></mrow><mo stretchy="false">]</mo><mo stretchy="false">[</mo><mi mathvariant="normal">B</mi><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">\text { rate }=k[\mathrm{~A}][\mathrm{B}]</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6151em;"></span><span class="mord text"><span class="mord"> rate </span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="mopen">[</span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">A</span></span><span class="mclose">]</span><span class="mopen">[</span><span class="mord mathrm">B</span><span class="mclose">]</span></span></span></span></td>
<td>second</td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>2</mn><mrow><mtext> </mtext><mi mathvariant="normal">A</mi></mrow><mo>+</mo><mi mathvariant="normal">B</mi><mo>→</mo><mtext> products </mtext></mrow><annotation encoding="application/x-tex">2 \mathrm{~A}+\mathrm{B} \rightarrow \text { products }</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7667em;vertical-align:-0.0833em;"></span><span class="mord">2</span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">A</span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathrm">B</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">→</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord text"><span class="mord"> products </span></span></span></span></span></td>
<td>Termolecular</td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext> rate </mtext><mo>=</mo><mi>k</mi><mo stretchy="false">[</mo><mrow><mtext> </mtext><mi mathvariant="normal">A</mi></mrow><msup><mo stretchy="false">]</mo><mn>2</mn></msup><mo stretchy="false">[</mo><mrow><mtext> </mtext><mi mathvariant="normal">B</mi></mrow><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">\text { rate }=k[\mathrm{~A}]^2[\mathrm{~B}]</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6151em;"></span><span class="mord text"><span class="mord"> rate </span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.0641em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="mopen">[</span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">A</span></span><span class="mclose"><span class="mclose">]</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mopen">[</span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">B</span></span><span class="mclose">]</span></span></span></span></td>
<td>third</td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">A</mi><mo>+</mo><mi mathvariant="normal">B</mi><mo>+</mo><mi mathvariant="normal">C</mi><mo>→</mo><mtext> products </mtext></mrow><annotation encoding="application/x-tex">\mathrm{A}+\mathrm{B}+\mathrm{C} \rightarrow \text { products }</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7667em;vertical-align:-0.0833em;"></span><span class="mord mathrm">A</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.7667em;vertical-align:-0.0833em;"></span><span class="mord mathrm">B</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathrm">C</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">→</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord text"><span class="mord"> products </span></span></span></span></span></td>
<td>Termolecular</td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext> rate </mtext><mo>=</mo><mi>k</mi><mo stretchy="false">[</mo><mrow><mtext> </mtext><mi mathvariant="normal">A</mi></mrow><mo stretchy="false">]</mo><mo stretchy="false">[</mo><mi mathvariant="normal">B</mi><mo stretchy="false">]</mo><mo stretchy="false">[</mo><mi mathvariant="normal">C</mi><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">\text { rate }=k[\mathrm{~A}][\mathrm{B}][\mathrm{C}]</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6151em;"></span><span class="mord text"><span class="mord"> rate </span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="mopen">[</span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">A</span></span><span class="mclose">]</span><span class="mopen">[</span><span class="mord mathrm">B</span><span class="mclose">]</span><span class="mopen">[</span><span class="mord mathrm">C</span><span class="mclose">]</span></span></span></span></td>
<td>third</td>
</tr>
</tbody>
</table>
<blockquote>
<p>For elementary reactions, the order of the elementary reaction is the same as its molecularity. In contrast, the rate law cannot be determined from the balanced chemical equation for the overall reaction (unless it is a single step mechanism and is therefore also an elementary step).</p>
</blockquote>
<h2 id="_12-5-4-identifying-the-rate-determining-step" tabindex="-1">12-5-4: Identifying the Rate-Determining Step <a class="header-anchor" href="#_12-5-4-identifying-the-rate-determining-step" aria-label="Permalink to &quot;12-5-4: Identifying the Rate-Determining Step&quot;">&ZeroWidthSpace;</a></h2>
<p>Note the important difference between writing rate laws for elementary reactions and the balanced chemical equation of the overall reaction. Because the balanced chemical equation does not necessarily reveal the individual elementary reactions by which the reaction occurs, we cannot obtain the rate law for a reaction from the overall balanced chemical equation alone. In fact, it is the rate law for the slowest overall reaction, which is the same as the rate law for the slowest step in the reaction mechanism, the ratedetermining step, that must give the experimentally determined rate law for the overall reaction.This statement is true if one step is substantially slower than all the others, typically by a factor of 10 or more. If two or more slow steps have comparable rates, the experimentally determined rate laws can become complex. Our discussion is limited to reactions in which one step can be identified as being substantially slower than any other. The reason for this is that any process that occurs through a sequence of steps can take place no faster than the slowest step in the sequence. In an automotive assembly line, for example, a component cannot be used faster than it is produced. Similarly, blood pressure is regulated by the flow of blood through the smallest passages, the capillaries. Because movement through capillaries constitutes the rate-determining step in blood flow, blood pressure can be regulated by medications that cause the capillaries to contract or dilate. A chemical reaction that occurs via a series of elementary reactions can take place no faster than the slowest step in the series of reactions.</p>
<p>Look at the rate laws for each elementary reaction in the example as well as for the overall reaction.</p>
<p>Rate laws for each elementary reaction in our example as well as for the overall reaction</p>
<table>
<thead>
<tr>
<th>Steps</th>
<th>Reaction</th>
<th>Rate</th>
</tr>
</thead>
<tbody>
<tr>
<td>step 1</td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mrow><mi mathvariant="normal">N</mi><mi mathvariant="normal">O</mi></mrow><mn>2</mn></msub><mo>+</mo><msub><mrow><mi mathvariant="normal">N</mi><mi mathvariant="normal">O</mi></mrow><mn>2</mn></msub><mo><mover><mo><mo>→</mo></mo><msub><mi mathvariant="normal">k</mi><mn>1</mn></msub></mover></mo><msub><mrow><mi mathvariant="normal">N</mi><mi mathvariant="normal">O</mi></mrow><mn>3</mn></msub><mo>+</mo><mrow><mi mathvariant="normal">N</mi><mi mathvariant="normal">O</mi></mrow></mrow><annotation encoding="application/x-tex">\mathrm{NO}_2+\mathrm{NO}_2 \stackrel{\mathrm{k}_1}{\rightarrow} \mathrm{NO}_3+\mathrm{NO}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord"><span class="mord mathrm">NO</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1.3141em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord"><span class="mord mathrm">NO</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel"><span class="mop op-limits"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:1.1641em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span><span class="mop">→</span></span></span><span style="top:-3.578em;margin-left:0em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight"><span class="mord mathrm mtight">k</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3173em;"><span style="top:-2.357em;margin-left:0em;margin-right:0.0714em;"><span class="pstrut" style="height:2.5em;"></span><span class="sizing reset-size3 size1 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.143em;"><span></span></span></span></span></span></span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord"><span class="mord mathrm">NO</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">3</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord"><span class="mord mathrm">NO</span></span></span></span></span></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext> rate </mtext><mo>=</mo><msub><mi>k</mi><mn>1</mn></msub><msup><mrow><mo fence="true">[</mo><msub><mrow><mi mathvariant="normal">N</mi><mi mathvariant="normal">O</mi></mrow><mn>2</mn></msub><mo fence="true">]</mo></mrow><mn>2</mn></msup><mo stretchy="false">(</mo><mtext> predicted) </mtext></mrow><annotation encoding="application/x-tex">\text { rate }=k_1\left[\mathrm{NO}_2\right]^2(\text { predicted) }</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6151em;"></span><span class="mord text"><span class="mord"> rate </span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.204em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0315em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="minner"><span class="mopen delimcenter" style="top:0em;">[</span><span class="mord"><span class="mord"><span class="mord mathrm">NO</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">]</span></span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.954em;"><span style="top:-3.2029em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mopen">(</span><span class="mord text"><span class="mord"> predicted) </span></span></span></span></span></td>
</tr>
<tr>
<td>step 2</td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><munder accentunder="true"><mrow><msub><mrow><mi mathvariant="normal">N</mi><mi mathvariant="normal">O</mi></mrow><mn>3</mn></msub><mo>+</mo><mrow><mi mathvariant="normal">C</mi><mi mathvariant="normal">O</mi></mrow><mo><mover><mo><mo>→</mo></mo><msub><mi>k</mi><mn>2</mn></msub></mover></mo><msub><mrow><mi mathvariant="normal">N</mi><mi mathvariant="normal">O</mi></mrow><mn>2</mn></msub><mo>+</mo><msub><mrow><mi mathvariant="normal">C</mi><mi mathvariant="normal">O</mi></mrow><mn>2</mn></msub></mrow><mo stretchy="true">‾</mo></munder></mrow><annotation encoding="application/x-tex">\underline{\mathrm{NO}_3+\mathrm{CO} \stackrel{k_2}{\rightarrow} \mathrm{NO}_2+\mathrm{CO}_2}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.5141em;vertical-align:-0.35em;"></span><span class="mord underline"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1641em;"><span style="top:-2.8541em;"><span class="pstrut" style="height:3.1641em;"></span><span class="underline-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.1641em;"><span class="pstrut" style="height:3.1641em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord mathrm">NO</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">3</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathrm">CO</span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel"><span class="mop op-limits"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:1.1641em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span><span class="mop">→</span></span></span><span style="top:-3.578em;margin-left:0em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.03148em;">k</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3173em;"><span style="top:-2.357em;margin-left:-0.0315em;margin-right:0.0714em;"><span class="pstrut" style="height:2.5em;"></span><span class="sizing reset-size3 size1 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.143em;"><span></span></span></span></span></span></span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mord"><span class="mord mathrm">NO</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord"><span class="mord mathrm">CO</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.35em;"><span></span></span></span></span></span></span></span></span></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext> rate </mtext><mo>=</mo><msub><mi>k</mi><mn>2</mn></msub><mrow><mo fence="true">[</mo><msub><mrow><mi mathvariant="normal">N</mi><mi mathvariant="normal">O</mi></mrow><mn>3</mn></msub><mo fence="true">]</mo></mrow><mo stretchy="false">[</mo><mrow><mi mathvariant="normal">C</mi><mi mathvariant="normal">O</mi></mrow><mo stretchy="false">]</mo><mo stretchy="false">(</mo><mtext> predicted </mtext><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">\text { rate }=k_2\left[\mathrm{NO}_3\right][\mathrm{CO}](\text { predicted })</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6151em;"></span><span class="mord text"><span class="mord"> rate </span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0315em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">[</span><span class="mord"><span class="mord"><span class="mord mathrm">NO</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">3</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">]</span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mopen">[</span><span class="mord"><span class="mord mathrm">CO</span></span><span class="mclose">]</span><span class="mopen">(</span><span class="mord text"><span class="mord"> predicted </span></span><span class="mclose">)</span></span></span></span></td>
</tr>
<tr>
<td>step 3</td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mrow><mi mathvariant="normal">N</mi><mi mathvariant="normal">O</mi></mrow><mn>2</mn></msub><mo>+</mo><mrow><mi mathvariant="normal">C</mi><mi mathvariant="normal">O</mi></mrow><mo><mover><mo><mo>→</mo></mo><mi>k</mi></mover></mo><mrow><mi mathvariant="normal">N</mi><mi mathvariant="normal">O</mi></mrow><mo>+</mo><msub><mrow><mi mathvariant="normal">C</mi><mi mathvariant="normal">O</mi></mrow><mn>2</mn></msub></mrow><annotation encoding="application/x-tex">\mathrm{NO}_2+\mathrm{CO} \stackrel{k}{\rightarrow} \mathrm{NO}+\mathrm{CO}_2</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord"><span class="mord mathrm">NO</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1.153em;"></span><span class="mord"><span class="mord mathrm">CO</span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel"><span class="mop op-limits"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:1.153em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span><span class="mop">→</span></span></span><span style="top:-3.5669em;margin-left:0em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.03148em;">k</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.7667em;vertical-align:-0.0833em;"></span><span class="mord"><span class="mord mathrm">NO</span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord"><span class="mord mathrm">CO</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext> rate </mtext><mo>=</mo><mi>k</mi><msup><mrow><mo fence="true">[</mo><msub><mrow><mi mathvariant="normal">N</mi><mi mathvariant="normal">O</mi></mrow><mn>2</mn></msub><mo fence="true">]</mo></mrow><mn>2</mn></msup><mo stretchy="false">(</mo><mtext> observed) </mtext></mrow><annotation encoding="application/x-tex">\text { rate }=k\left[\mathrm{NO}_2\right]^2(\text { observed) }</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6151em;"></span><span class="mord text"><span class="mord"> rate </span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.204em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="minner"><span class="mopen delimcenter" style="top:0em;">[</span><span class="mord"><span class="mord"><span class="mord mathrm">NO</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">]</span></span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.954em;"><span style="top:-3.2029em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mopen">(</span><span class="mord text"><span class="mord"> observed) </span></span></span></span></span></td>
</tr>
</tbody>
</table>
<p>The experimentally determined rate law for the reaction of <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mrow><mi mathvariant="normal">N</mi><mi mathvariant="normal">O</mi></mrow><mn>2</mn></msub></mrow><annotation encoding="application/x-tex">\mathrm{NO}_{2}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord"><span class="mord mathrm">NO</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> with <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>C</mi><mi>O</mi></mrow><annotation encoding="application/x-tex">C O</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.02778em;">CO</span></span></span></span> is the same as the predicted rate law for step 1 . This tells us that the first elementary reaction is the rate-determining step, so <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>k</mi></mrow><annotation encoding="application/x-tex">k</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal" style="margin-right:0.03148em;">k</span></span></span></span> for the overall reaction must equal <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>k</mi><mn>1</mn></msub></mrow><annotation encoding="application/x-tex">k_{1}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8444em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0315em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">1</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span>. That is, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mrow><mi mathvariant="normal">N</mi><mi mathvariant="normal">O</mi></mrow><mn>3</mn></msub></mrow><annotation encoding="application/x-tex">\mathrm{NO}_{3}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord"><span class="mord mathrm">NO</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">3</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> is formed slowly in step 1, but once it is formed, it reacts very rapidly with CO in step 2.</p>
<p>Sometimes chemists are able to propose two or more mechanisms that are consistent with the available data. If a proposed mechanism predicts the wrong experimental rate law, however, the mechanism must be incorrect.</p>
<h3 id="_12-5-4-1-example-a-reaction-with-an-intermediate" tabindex="-1">12-5-4-1: Example-A Reaction with an Intermediate <a class="header-anchor" href="#_12-5-4-1-example-a-reaction-with-an-intermediate" aria-label="Permalink to &quot;12-5-4-1: Example-A Reaction with an Intermediate&quot;">&ZeroWidthSpace;</a></h3>
<p>In an alternative mechanism for the reaction of <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mrow><mi mathvariant="normal">N</mi><mi mathvariant="normal">O</mi></mrow><mn>2</mn></msub></mrow><annotation encoding="application/x-tex">\mathrm{NO}_{2}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord"><span class="mord mathrm">NO</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> with <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">C</mi><mi mathvariant="normal">O</mi></mrow><annotation encoding="application/x-tex">\mathrm{CO}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord"><span class="mord mathrm">CO</span></span></span></span></span> with <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi mathvariant="normal">N</mi><mn>2</mn></msub><msub><mi mathvariant="normal">O</mi><mn>4</mn></msub></mrow><annotation encoding="application/x-tex">\mathrm{N}_{2} \mathrm{O}_{4}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathrm">N</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">O</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">4</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> appearing as an intermediate.</p>
<p>alternative mechanism for the reaction of <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mrow><mi mathvariant="normal">N</mi><mi mathvariant="normal">O</mi></mrow><mn>2</mn></msub></mrow><annotation encoding="application/x-tex">\mathrm{NO}_{2}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord"><span class="mord mathrm">NO</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> with <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">C</mi><mi mathvariant="normal">O</mi></mrow><annotation encoding="application/x-tex">\mathrm{CO}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord"><span class="mord mathrm">CO</span></span></span></span></span> with <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi mathvariant="normal">N</mi><mn>2</mn></msub><msub><mi mathvariant="normal">O</mi><mn>4</mn></msub></mrow><annotation encoding="application/x-tex">\mathrm{N}_{2} \mathrm{O}_{4}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathrm">N</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">O</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">4</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> appearing as an intermediate.</p>
<p>Write the rate law for each elementary reaction. Is this mechanism consistent with the experimentally determined rate law (rate <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>=</mo><mrow><mi mathvariant="normal">k</mi><mo stretchy="false">[</mo><msub><mrow><mi mathvariant="normal">N</mi><mi mathvariant="normal">O</mi></mrow><mn>2</mn></msub><msup><mo stretchy="false">]</mo><mn>2</mn></msup><mi mathvariant="normal">t</mi></mrow></mrow><annotation encoding="application/x-tex">=\mathrm{k[{NO}_{2}]^{2}t}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.0641em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord mathrm">k</span><span class="mopen">[</span><span class="mord"><span class="mord"><span class="mord mathrm">NO</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathrm mtight">2</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose"><span class="mclose">]</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathrm mtight">2</span></span></span></span></span></span></span></span></span><span class="mord mathrm">t</span></span></span></span></span>)</p>
<p>Given: elementary reactions Asked for: rate law for each elementary reaction and overall rate law</p>
<h4 id="strategy" tabindex="-1">Strategy <a class="header-anchor" href="#strategy" aria-label="Permalink to &quot;Strategy&quot;">&ZeroWidthSpace;</a></h4>
<ul>
<li>
<p>Determine the rate law for each elementary reaction in the reaction.</p>
</li>
<li>
<p>Determine which rate law corresponds to the experimentally determined rate law for the reaction. This rate law is the one for the rate-determining step.</p>
</li>
</ul>
<h4 id="solution" tabindex="-1">Solution <a class="header-anchor" href="#solution" aria-label="Permalink to &quot;Solution&quot;">&ZeroWidthSpace;</a></h4>
<details class="details custom-block"><summary>View solution</summary>
<p>A The rate law for step 1 is rate <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>=</mo><msub><mi>k</mi><mn>1</mn></msub><msup><mrow><mo fence="true">[</mo><msub><mrow><mi mathvariant="normal">N</mi><mi mathvariant="normal">O</mi></mrow><mn>2</mn></msub><mo fence="true">]</mo></mrow><mn>2</mn></msup></mrow><annotation encoding="application/x-tex">=k_{1}\left[\mathrm{NO}_{2}\right]^{2}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.204em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0315em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">1</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="minner"><span class="mopen delimcenter" style="top:0em;">[</span><span class="mord"><span class="mord"><span class="mord mathrm">NO</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">]</span></span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.954em;"><span style="top:-3.2029em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span></span></span>; for step 2 , it is rate <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>=</mo><msub><mi>k</mi><mn>2</mn></msub><mrow><mo fence="true">[</mo><msub><mrow><mtext> </mtext><mi mathvariant="normal">N</mi></mrow><mn>2</mn></msub><msub><mi mathvariant="normal">O</mi><mn>4</mn></msub><mo fence="true">]</mo></mrow><mo stretchy="false">[</mo><mrow><mi mathvariant="normal">C</mi><mi mathvariant="normal">O</mi></mrow><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">=k_{2}\left[\mathrm{~N}_{2} \mathrm{O}_{4}\right][\mathrm{CO}]</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0315em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">[</span><span class="mord"><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">N</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">O</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">4</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">]</span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mopen">[</span><span class="mord"><span class="mord mathrm">CO</span></span><span class="mclose">]</span></span></span></span>.</p>
<p>B If step 1 is slow (and therefore the rate-determining step), then the overall rate law for the reaction will be the same: rate <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>=</mo></mrow><annotation encoding="application/x-tex">=</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">=</span></span></span></span> <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>k</mi><mn>1</mn></msub><msup><mrow><mo fence="true">[</mo><msub><mrow><mi mathvariant="normal">N</mi><mi mathvariant="normal">O</mi></mrow><mn>2</mn></msub><mo fence="true">]</mo></mrow><mn>2</mn></msup></mrow><annotation encoding="application/x-tex">k_{1}\left[\mathrm{NO}_{2}\right]^{2}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.204em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0315em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">1</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="minner"><span class="mopen delimcenter" style="top:0em;">[</span><span class="mord"><span class="mord"><span class="mord mathrm">NO</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">]</span></span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.954em;"><span style="top:-3.2029em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span></span></span>. This is the same as the experimentally determined rate law. Hence this mechanism, with <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi mathvariant="normal">N</mi><mn>2</mn></msub><msub><mi mathvariant="normal">O</mi><mn>4</mn></msub></mrow><annotation encoding="application/x-tex">\mathrm{N}_{2} \mathrm{O}_{4}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathrm">N</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">O</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">4</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> as an intermediate, and the one described previously, with <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mrow><mi mathvariant="normal">N</mi><mi mathvariant="normal">O</mi></mrow><mn>3</mn></msub></mrow><annotation encoding="application/x-tex">\mathrm{NO}_{3}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord"><span class="mord mathrm">NO</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">3</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> as an intermediate, are kinetically indistinguishable. In this case, further experiments are needed to distinguish between them. For example, the researcher could try to detect the proposed intermediates, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mrow><mi mathvariant="normal">N</mi><mi mathvariant="normal">O</mi></mrow><mn>3</mn></msub></mrow><annotation encoding="application/x-tex">\mathrm{NO}_{3}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord"><span class="mord mathrm">NO</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">3</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> and <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi mathvariant="normal">N</mi><mn>2</mn></msub><msub><mi mathvariant="normal">O</mi><mn>4</mn></msub></mrow><annotation encoding="application/x-tex">\mathrm{N}_{2} \mathrm{O}_{4}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathrm">N</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">O</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">4</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span>, directly.</p>
</details>
]]></description>
            <content:encoded><![CDATA[<h1 id="_12-5-reaction-mechanism" tabindex="-1">12-5: Reaction Mechanism <a class="header-anchor" href="#_12-5-reaction-mechanism" aria-label="Permalink to &quot;12-5: Reaction Mechanism&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="_12-5-1-learning-objectives" tabindex="-1">12-5-1: Learning Objectives <a class="header-anchor" href="#_12-5-1-learning-objectives" aria-label="Permalink to &quot;12-5-1: Learning Objectives&quot;">&ZeroWidthSpace;</a></h2>
<div class="tip custom-block"><p class="custom-block-title">Learning Objectives</p>
<p>One of the major reasons for studying chemical kinetics is to use measurements of the macroscopic properties of a system, such as the rate of change in the concentration of reactants or products with time, to discover the sequence of events that occur at the molecular level during a reaction. This molecular description is the mechanism of the reaction; it describes how individual atoms, ions, or molecules interact to form particular products. The stepwise changes are collectively called the reaction mechanism.</p>
</div>
<p>In an internal combustion engine, for example, isooctane reacts with oxygen to give carbon dioxide and water:</p>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mn>2</mn><msub><mi mathvariant="normal">C</mi><mn>8</mn></msub><msub><mi mathvariant="normal">H</mi><mn>18</mn></msub><mo stretchy="false">(</mo><mi mathvariant="normal">l</mi><mo stretchy="false">)</mo><mo>+</mo><mn>25</mn><msub><mi mathvariant="normal">O</mi><mn>2</mn></msub><mo stretchy="false">(</mo><mrow><mtext> </mtext><mi mathvariant="normal">g</mi></mrow><mo stretchy="false">)</mo><mo>⟶</mo><mn>16</mn><msub><mrow><mi mathvariant="normal">C</mi><mi mathvariant="normal">O</mi></mrow><mn>2</mn></msub><mo stretchy="false">(</mo><mrow><mtext> </mtext><mi mathvariant="normal">g</mi></mrow><mo stretchy="false">)</mo><mo>+</mo><mn>18</mn><msub><mi mathvariant="normal">H</mi><mn>2</mn></msub><mi mathvariant="normal">O</mi><mo stretchy="false">(</mo><mi mathvariant="normal">g</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">2 \mathrm{C}_{8} \mathrm{H}_{18}(\mathrm{l})+25 \mathrm{O}_{2}(\mathrm{~g}) \longrightarrow 16 \mathrm{CO}_{2}(\mathrm{~g})+18 \mathrm{H}_{2} \mathrm{O}(\mathrm{g})
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">2</span><span class="mord"><span class="mord mathrm">C</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">8</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">H</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">18</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mopen">(</span><span class="mord mathrm">l</span><span class="mclose">)</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">25</span><span class="mord"><span class="mord mathrm">O</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mopen">(</span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm" style="margin-right:0.01389em;">g</span></span><span class="mclose">)</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">⟶</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">16</span><span class="mord"><span class="mord"><span class="mord mathrm">CO</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mopen">(</span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm" style="margin-right:0.01389em;">g</span></span><span class="mclose">)</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">18</span><span class="mord"><span class="mord mathrm">H</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord mathrm">O</span><span class="mopen">(</span><span class="mord mathrm" style="margin-right:0.01389em;">g</span><span class="mclose">)</span></span></span></span></span></p>
<p>For this reaction to occur in a single step, 25 dioxygen molecules and 2 isooctane molecules would have to collide simultaneously and be converted to 34 molecules of product, which is very unlikely. It is more likely that a complex series of reactions takes place in a stepwise fashion. Each individual reaction, which is called an elementary reaction, involves one, two, or (rarely) three atoms, molecules, or ions. The overall sequence of elementary reactions is the mechanism of the reaction. The sum of the individual steps, or elementary reactions, in the mechanism must give the balanced chemical equation for the overall reaction.</p>
<p>The overall sequence of elementary reactions is the mechanism of the reaction.</p>
<h2 id="_12-5-2-molecularity-and-the-rate-determining-step" tabindex="-1">12-5-2: Molecularity and the Rate-Determining Step <a class="header-anchor" href="#_12-5-2-molecularity-and-the-rate-determining-step" aria-label="Permalink to &quot;12-5-2: Molecularity and the Rate-Determining Step&quot;">&ZeroWidthSpace;</a></h2>
<p>To demonstrate how the analysis of elementary reactions helps us determine the overall reaction mechanism, we will examine the much simpler reaction of carbon monoxide with nitrogen dioxide.</p>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mn>2</mn><mi mathvariant="normal">C</mi><mi mathvariant="normal">O</mi><mo>+</mo><mn>2</mn><mi mathvariant="normal">N</mi><msub><mi mathvariant="normal">O</mi><mn>2</mn></msub><mo>→</mo><mn>2</mn><mi mathvariant="normal">C</mi><msub><mi mathvariant="normal">O</mi><mn>2</mn></msub><mo>+</mo><msub><mi mathvariant="normal">N</mi><mn>2</mn></msub><msub><mi mathvariant="normal">O</mi><mn>4</mn></msub></mrow><annotation encoding="application/x-tex">\mathrm{2CO + 2NO_2 \rightarrow 2CO_2 + N_2O_4}
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathrm">2CO</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathrm">2N</span><span class="mord"><span class="mord mathrm">O</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathrm mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">→</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord mathrm">2C</span><span class="mord"><span class="mord mathrm">O</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathrm mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathrm">N</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathrm mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">O</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathrm mtight">4</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span></span></span></p>
<p>From the balanced chemical equation, one might expect the reaction to occur via a collision of one molecule of <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mrow><mi mathvariant="normal">N</mi><mi mathvariant="normal">O</mi></mrow><mn>2</mn></msub></mrow><annotation encoding="application/x-tex">\mathrm{NO}_{2}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord"><span class="mord mathrm">NO</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> with a molecule of <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">C</mi><mi mathvariant="normal">O</mi></mrow><annotation encoding="application/x-tex">\mathrm{CO}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord"><span class="mord mathrm">CO</span></span></span></span></span> that results in the transfer of an oxygen atom from nitrogen to carbon. The experimentally determined rate law for the reaction, however, is as follows:</p>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mtext> rate </mtext><mo>=</mo><mi>k</mi><msup><mrow><mo fence="true">[</mo><msub><mrow><mi mathvariant="normal">N</mi><mi mathvariant="normal">O</mi></mrow><mn>2</mn></msub><mo fence="true">]</mo></mrow><mn>2</mn></msup></mrow><annotation encoding="application/x-tex">\text { rate }=k\left[\mathrm{NO}_{2}\right]^{2}
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6151em;"></span><span class="mord text"><span class="mord"> rate </span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.204em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="minner"><span class="mopen delimcenter" style="top:0em;">[</span><span class="mord"><span class="mord"><span class="mord mathrm">NO</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">]</span></span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.954em;"><span style="top:-3.2029em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span></span></span></span></p>
<p>The fact that the reaction is second order in <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true">[</mo><msub><mrow><mi mathvariant="normal">N</mi><mi mathvariant="normal">O</mi></mrow><mn>2</mn></msub><mo fence="true">]</mo></mrow><annotation encoding="application/x-tex">\left[\mathrm{NO}_{2}\right]</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">[</span><span class="mord"><span class="mord"><span class="mord mathrm">NO</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">]</span></span></span></span></span> and independent of <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">[</mo><mrow><mi mathvariant="normal">C</mi><mi mathvariant="normal">O</mi></mrow><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">[\mathrm{CO}]</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">[</span><span class="mord"><span class="mord mathrm">CO</span></span><span class="mclose">]</span></span></span></span> tells us that it does not occur by the simple collision model outlined previously. If it did, its predicted rate law would be</p>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mtext> rate </mtext><mo>=</mo><mi>k</mi><mrow><mo fence="true">[</mo><msub><mrow><mi mathvariant="normal">N</mi><mi mathvariant="normal">O</mi></mrow><mn>2</mn></msub><mo fence="true">]</mo></mrow><mo stretchy="false">[</mo><mrow><mi mathvariant="normal">C</mi><mi mathvariant="normal">O</mi></mrow><mo stretchy="false">]</mo><mi mathvariant="normal">.</mi></mrow><annotation encoding="application/x-tex">\text { rate }=k\left[\mathrm{NO}_{2}\right][\mathrm{CO}] .
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6151em;"></span><span class="mord text"><span class="mord"> rate </span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">[</span><span class="mord"><span class="mord"><span class="mord mathrm">NO</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">]</span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mopen">[</span><span class="mord"><span class="mord mathrm">CO</span></span><span class="mclose">]</span><span class="mord">.</span></span></span></span></span></p>
<p>The following two-step mechanism is consistent with the rate law if step 1 is much slower than step 2:</p>
<h3 id="_15-2-1-two-step-mechanism" tabindex="-1">15-2-1: Two-Step Mechanism <a class="header-anchor" href="#_15-2-1-two-step-mechanism" aria-label="Permalink to &quot;15-2-1: Two-Step Mechanism&quot;">&ZeroWidthSpace;</a></h3>
<table>
<thead>
<tr>
<th>Steps</th>
<th>Reaction</th>
<th>Reaction Type</th>
</tr>
</thead>
<tbody>
<tr>
<td>step 1</td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mrow><mi mathvariant="normal">N</mi><mi mathvariant="normal">O</mi></mrow><mn>2</mn></msub><mo>+</mo><msub><mrow><mi mathvariant="normal">N</mi><mi mathvariant="normal">O</mi></mrow><mn>2</mn></msub><mo><mover><mo><mo>⟶</mo></mo><mtext> slow </mtext></mover></mo><msub><mrow><mi mathvariant="normal">N</mi><mi mathvariant="normal">O</mi></mrow><mn>3</mn></msub><mo>+</mo><mrow><mi mathvariant="normal">N</mi><mi mathvariant="normal">O</mi></mrow></mrow><annotation encoding="application/x-tex">\mathrm{NO}_{2}+\mathrm{NO}_{2} \stackrel{\text { slow }}{\longrightarrow} \mathrm{NO}_{3}+\mathrm{NO}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord"><span class="mord mathrm">NO</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1.4471em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord"><span class="mord mathrm">NO</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel"><span class="mop op-limits"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.2971em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span><span class="mop">⟶</span></span></span><span style="top:-3.711em;margin-left:0em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord text mtight"><span class="mord mtight"> slow </span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.011em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord"><span class="mord mathrm">NO</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">3</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord"><span class="mord mathrm">NO</span></span></span></span></span></td>
<td>elementary reaction</td>
</tr>
<tr>
<td>step 2</td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><munder accentunder="true"><mrow><msub><mrow><mi mathvariant="normal">N</mi><mi mathvariant="normal">O</mi></mrow><mn>3</mn></msub><mo>+</mo><mrow><mi mathvariant="normal">C</mi><mi mathvariant="normal">O</mi></mrow><mo>→</mo><msub><mrow><mi mathvariant="normal">N</mi><mi mathvariant="normal">O</mi></mrow><mn>2</mn></msub><mo>+</mo><msub><mrow><mi mathvariant="normal">C</mi><mi mathvariant="normal">O</mi></mrow><mn>2</mn></msub></mrow><mo stretchy="true">‾</mo></munder></mrow><annotation encoding="application/x-tex">\underline{\mathrm{NO}_{3}+\mathrm{CO} \rightarrow \mathrm{NO}_{2}+\mathrm{CO}_{2}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0333em;vertical-align:-0.35em;"></span><span class="mord underline"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6833em;"><span style="top:-2.69em;"><span class="pstrut" style="height:3em;"></span><span class="underline-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord mathrm">NO</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">3</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathrm">CO</span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">→</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mord"><span class="mord mathrm">NO</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord"><span class="mord mathrm">CO</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.35em;"><span></span></span></span></span></span></span></span></span></td>
<td>elementary reaction</td>
</tr>
<tr>
<td>sum</td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mrow><mi mathvariant="normal">N</mi><mi mathvariant="normal">O</mi></mrow><mn>2</mn></msub><mo>+</mo><mrow><mi mathvariant="normal">C</mi><mi mathvariant="normal">O</mi></mrow><mo>→</mo><mrow><mi mathvariant="normal">N</mi><mi mathvariant="normal">O</mi></mrow><mo>+</mo><msub><mrow><mi mathvariant="normal">C</mi><mi mathvariant="normal">O</mi></mrow><mn>2</mn></msub></mrow><annotation encoding="application/x-tex">\mathrm{NO}_{2}+\mathrm{CO} \rightarrow \mathrm{NO}+\mathrm{CO}_{2}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord"><span class="mord mathrm">NO</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord"><span class="mord mathrm">CO</span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">→</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.7667em;vertical-align:-0.0833em;"></span><span class="mord"><span class="mord mathrm">NO</span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord"><span class="mord mathrm">CO</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span></td>
<td>overall reaction</td>
</tr>
</tbody>
</table>
<p>According to this mechanism, the overall reaction occurs in two steps, or elementary reactions. Summing steps 1 and 2 and canceling on both sides of the equation gives the overall balanced chemical equation for the reaction. The <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">N</mi><msub><mi mathvariant="normal">O</mi><mn>3</mn></msub></mrow><annotation encoding="application/x-tex">\mathrm{NO_3}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathrm">N</span><span class="mord"><span class="mord mathrm">O</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathrm mtight">3</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span></span> molecule is intermediate in the reaction, a species that does not appear in the balanced chemical equation for the overall reaction. It is formed as a product of the first step but is consumed in the second step.</p>
<p>The sum of the elementary reactions in a reaction mechanism must give the overall balanced chemical equation of the reaction.</p>
<h2 id="_12-5-3-using-molecularity-to-describe-a-rate-law" tabindex="-1">12-5-3: Using Molecularity to Describe a Rate Law <a class="header-anchor" href="#_12-5-3-using-molecularity-to-describe-a-rate-law" aria-label="Permalink to &quot;12-5-3: Using Molecularity to Describe a Rate Law&quot;">&ZeroWidthSpace;</a></h2>
<p>The molecularity of an elementary reaction is the number of molecules that collide during that step in the mechanism. If there is only a single reactant molecule in an elementary reaction, that step is designated as unimolecular; if there are two reactant molecules, it is bimolecular; and if there are three reactant molecules (a relatively rare situation), it is termolecular. Elementary reactions that involve the simultaneous collision of more than three molecules are highly improbable and have never been observed experimentally. (To understand why, try to make three or more marbles or pool balls collide with one another simultaneously!)</p>
<div class="warning custom-block"><p class="custom-block-title">About the image</p>
<p>The Basis for Writing Rate Laws of Elementary Reactions. This diagram illustrates how the number of possible collisions per unit time between two reactant species, A and B, depends on the number of A and B particles present. The number of collisions between A and B particles increases as the product of the number of particles, not as the sum. This is why the rate law for an elementary reaction depends on the product of the concentrations of the species that collide in that step. (CC BY-NC-SA; anonymous)</p>
</div>
<p>Writing the rate law for an elementary reaction is straightforward because we know how many molecules must collide simultaneously for the elementary reaction to occur; hence the order of the elementary reaction is the same as its molecularity (Table 14.6.1). In contrast, the rate law for the reaction cannot be determined from the balanced chemical equation for the overall reaction. The general rate law for a unimolecular elementary reaction ( <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">A</mi><mo>→</mo></mrow><annotation encoding="application/x-tex">\mathrm{A} \rightarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathrm">A</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">→</span></span></span></span> products) is</p>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mtext> rate </mtext><mo>=</mo><mi>k</mi><mo stretchy="false">[</mo><mi>A</mi><mo stretchy="false">]</mo><mi mathvariant="normal">.</mi></mrow><annotation encoding="application/x-tex">\text { rate }=k[A] .
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6151em;"></span><span class="mord text"><span class="mord"> rate </span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="mopen">[</span><span class="mord mathnormal">A</span><span class="mclose">]</span><span class="mord">.</span></span></span></span></span></p>
<p>For bimolecular reactions, the reaction rate depends on the number of collisions per unit time, which is proportional to the product of the concentrations of the reactants, as shown in Figure 14.6.1 For a bimolecular elementary reaction of the form <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">A</mi><mo>+</mo><mi mathvariant="normal">B</mi><mo>→</mo></mrow><annotation encoding="application/x-tex">\mathrm{A}+\mathrm{B} \rightarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7667em;vertical-align:-0.0833em;"></span><span class="mord mathrm">A</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathrm">B</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">→</span></span></span></span> products, the general rate law is</p>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mtext> rate </mtext><mo>=</mo><mi>k</mi><mo stretchy="false">[</mo><mi>A</mi><mo stretchy="false">]</mo><mo stretchy="false">[</mo><mi>B</mi><mo stretchy="false">]</mo><mi mathvariant="normal">.</mi></mrow><annotation encoding="application/x-tex">\text { rate }=k[A][B] .
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6151em;"></span><span class="mord text"><span class="mord"> rate </span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="mopen">[</span><span class="mord mathnormal">A</span><span class="mclose">]</span><span class="mopen">[</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span><span class="mclose">]</span><span class="mord">.</span></span></span></span></span></p>
<table>
<thead>
<tr>
<th>Elementary Reaction</th>
<th>Molecularity</th>
<th>Rate</th>
<th>Reaction Order</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">A</mi><mo>→</mo><mtext> products </mtext></mrow><annotation encoding="application/x-tex">\mathrm{A} \rightarrow \text { products }</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathrm">A</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">→</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord text"><span class="mord"> products </span></span></span></span></span></td>
<td>Unimolecular</td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext> rate </mtext><mo>=</mo><mi>k</mi><mo stretchy="false">[</mo><mrow><mtext> </mtext><mi mathvariant="normal">A</mi></mrow><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">\text { rate }=k[\mathrm{~A}]</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6151em;"></span><span class="mord text"><span class="mord"> rate </span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="mopen">[</span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">A</span></span><span class="mclose">]</span></span></span></span></td>
<td>first</td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>2</mn><mrow><mtext> </mtext><mi mathvariant="normal">A</mi></mrow><mo>→</mo><mtext> products </mtext></mrow><annotation encoding="application/x-tex">2\mathrm{~A} \rightarrow \text { products }</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">2</span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">A</span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">→</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord text"><span class="mord"> products </span></span></span></span></span></td>
<td>Bimolecular</td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext> rate </mtext><mo>=</mo><mi>k</mi><mo stretchy="false">[</mo><mrow><mtext> </mtext><mi mathvariant="normal">A</mi></mrow><msup><mo stretchy="false">]</mo><mn>2</mn></msup></mrow><annotation encoding="application/x-tex">\text { rate }=k[\mathrm{~A}]^2</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6151em;"></span><span class="mord text"><span class="mord"> rate </span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.0641em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="mopen">[</span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">A</span></span><span class="mclose"><span class="mclose">]</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span></span></td>
<td>second</td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">A</mi><mo>+</mo><mi mathvariant="normal">B</mi><mo>→</mo><mtext> products </mtext></mrow><annotation encoding="application/x-tex">\mathrm{A}+\mathrm{B} \rightarrow \text { products }</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7667em;vertical-align:-0.0833em;"></span><span class="mord mathrm">A</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathrm">B</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">→</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord text"><span class="mord"> products </span></span></span></span></span></td>
<td>Bimolecular</td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext> rate </mtext><mo>=</mo><mi>k</mi><mo stretchy="false">[</mo><mrow><mtext> </mtext><mi mathvariant="normal">A</mi></mrow><mo stretchy="false">]</mo><mo stretchy="false">[</mo><mi mathvariant="normal">B</mi><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">\text { rate }=k[\mathrm{~A}][\mathrm{B}]</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6151em;"></span><span class="mord text"><span class="mord"> rate </span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="mopen">[</span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">A</span></span><span class="mclose">]</span><span class="mopen">[</span><span class="mord mathrm">B</span><span class="mclose">]</span></span></span></span></td>
<td>second</td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>2</mn><mrow><mtext> </mtext><mi mathvariant="normal">A</mi></mrow><mo>+</mo><mi mathvariant="normal">B</mi><mo>→</mo><mtext> products </mtext></mrow><annotation encoding="application/x-tex">2 \mathrm{~A}+\mathrm{B} \rightarrow \text { products }</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7667em;vertical-align:-0.0833em;"></span><span class="mord">2</span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">A</span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathrm">B</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">→</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord text"><span class="mord"> products </span></span></span></span></span></td>
<td>Termolecular</td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext> rate </mtext><mo>=</mo><mi>k</mi><mo stretchy="false">[</mo><mrow><mtext> </mtext><mi mathvariant="normal">A</mi></mrow><msup><mo stretchy="false">]</mo><mn>2</mn></msup><mo stretchy="false">[</mo><mrow><mtext> </mtext><mi mathvariant="normal">B</mi></mrow><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">\text { rate }=k[\mathrm{~A}]^2[\mathrm{~B}]</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6151em;"></span><span class="mord text"><span class="mord"> rate </span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.0641em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="mopen">[</span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">A</span></span><span class="mclose"><span class="mclose">]</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mopen">[</span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">B</span></span><span class="mclose">]</span></span></span></span></td>
<td>third</td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">A</mi><mo>+</mo><mi mathvariant="normal">B</mi><mo>+</mo><mi mathvariant="normal">C</mi><mo>→</mo><mtext> products </mtext></mrow><annotation encoding="application/x-tex">\mathrm{A}+\mathrm{B}+\mathrm{C} \rightarrow \text { products }</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7667em;vertical-align:-0.0833em;"></span><span class="mord mathrm">A</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.7667em;vertical-align:-0.0833em;"></span><span class="mord mathrm">B</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathrm">C</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">→</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord text"><span class="mord"> products </span></span></span></span></span></td>
<td>Termolecular</td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext> rate </mtext><mo>=</mo><mi>k</mi><mo stretchy="false">[</mo><mrow><mtext> </mtext><mi mathvariant="normal">A</mi></mrow><mo stretchy="false">]</mo><mo stretchy="false">[</mo><mi mathvariant="normal">B</mi><mo stretchy="false">]</mo><mo stretchy="false">[</mo><mi mathvariant="normal">C</mi><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">\text { rate }=k[\mathrm{~A}][\mathrm{B}][\mathrm{C}]</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6151em;"></span><span class="mord text"><span class="mord"> rate </span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="mopen">[</span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">A</span></span><span class="mclose">]</span><span class="mopen">[</span><span class="mord mathrm">B</span><span class="mclose">]</span><span class="mopen">[</span><span class="mord mathrm">C</span><span class="mclose">]</span></span></span></span></td>
<td>third</td>
</tr>
</tbody>
</table>
<blockquote>
<p>For elementary reactions, the order of the elementary reaction is the same as its molecularity. In contrast, the rate law cannot be determined from the balanced chemical equation for the overall reaction (unless it is a single step mechanism and is therefore also an elementary step).</p>
</blockquote>
<h2 id="_12-5-4-identifying-the-rate-determining-step" tabindex="-1">12-5-4: Identifying the Rate-Determining Step <a class="header-anchor" href="#_12-5-4-identifying-the-rate-determining-step" aria-label="Permalink to &quot;12-5-4: Identifying the Rate-Determining Step&quot;">&ZeroWidthSpace;</a></h2>
<p>Note the important difference between writing rate laws for elementary reactions and the balanced chemical equation of the overall reaction. Because the balanced chemical equation does not necessarily reveal the individual elementary reactions by which the reaction occurs, we cannot obtain the rate law for a reaction from the overall balanced chemical equation alone. In fact, it is the rate law for the slowest overall reaction, which is the same as the rate law for the slowest step in the reaction mechanism, the ratedetermining step, that must give the experimentally determined rate law for the overall reaction.This statement is true if one step is substantially slower than all the others, typically by a factor of 10 or more. If two or more slow steps have comparable rates, the experimentally determined rate laws can become complex. Our discussion is limited to reactions in which one step can be identified as being substantially slower than any other. The reason for this is that any process that occurs through a sequence of steps can take place no faster than the slowest step in the sequence. In an automotive assembly line, for example, a component cannot be used faster than it is produced. Similarly, blood pressure is regulated by the flow of blood through the smallest passages, the capillaries. Because movement through capillaries constitutes the rate-determining step in blood flow, blood pressure can be regulated by medications that cause the capillaries to contract or dilate. A chemical reaction that occurs via a series of elementary reactions can take place no faster than the slowest step in the series of reactions.</p>
<p>Look at the rate laws for each elementary reaction in the example as well as for the overall reaction.</p>
<p>Rate laws for each elementary reaction in our example as well as for the overall reaction</p>
<table>
<thead>
<tr>
<th>Steps</th>
<th>Reaction</th>
<th>Rate</th>
</tr>
</thead>
<tbody>
<tr>
<td>step 1</td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mrow><mi mathvariant="normal">N</mi><mi mathvariant="normal">O</mi></mrow><mn>2</mn></msub><mo>+</mo><msub><mrow><mi mathvariant="normal">N</mi><mi mathvariant="normal">O</mi></mrow><mn>2</mn></msub><mo><mover><mo><mo>→</mo></mo><msub><mi mathvariant="normal">k</mi><mn>1</mn></msub></mover></mo><msub><mrow><mi mathvariant="normal">N</mi><mi mathvariant="normal">O</mi></mrow><mn>3</mn></msub><mo>+</mo><mrow><mi mathvariant="normal">N</mi><mi mathvariant="normal">O</mi></mrow></mrow><annotation encoding="application/x-tex">\mathrm{NO}_2+\mathrm{NO}_2 \stackrel{\mathrm{k}_1}{\rightarrow} \mathrm{NO}_3+\mathrm{NO}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord"><span class="mord mathrm">NO</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1.3141em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord"><span class="mord mathrm">NO</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel"><span class="mop op-limits"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:1.1641em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span><span class="mop">→</span></span></span><span style="top:-3.578em;margin-left:0em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight"><span class="mord mathrm mtight">k</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3173em;"><span style="top:-2.357em;margin-left:0em;margin-right:0.0714em;"><span class="pstrut" style="height:2.5em;"></span><span class="sizing reset-size3 size1 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.143em;"><span></span></span></span></span></span></span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord"><span class="mord mathrm">NO</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">3</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord"><span class="mord mathrm">NO</span></span></span></span></span></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext> rate </mtext><mo>=</mo><msub><mi>k</mi><mn>1</mn></msub><msup><mrow><mo fence="true">[</mo><msub><mrow><mi mathvariant="normal">N</mi><mi mathvariant="normal">O</mi></mrow><mn>2</mn></msub><mo fence="true">]</mo></mrow><mn>2</mn></msup><mo stretchy="false">(</mo><mtext> predicted) </mtext></mrow><annotation encoding="application/x-tex">\text { rate }=k_1\left[\mathrm{NO}_2\right]^2(\text { predicted) }</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6151em;"></span><span class="mord text"><span class="mord"> rate </span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.204em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0315em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="minner"><span class="mopen delimcenter" style="top:0em;">[</span><span class="mord"><span class="mord"><span class="mord mathrm">NO</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">]</span></span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.954em;"><span style="top:-3.2029em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mopen">(</span><span class="mord text"><span class="mord"> predicted) </span></span></span></span></span></td>
</tr>
<tr>
<td>step 2</td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><munder accentunder="true"><mrow><msub><mrow><mi mathvariant="normal">N</mi><mi mathvariant="normal">O</mi></mrow><mn>3</mn></msub><mo>+</mo><mrow><mi mathvariant="normal">C</mi><mi mathvariant="normal">O</mi></mrow><mo><mover><mo><mo>→</mo></mo><msub><mi>k</mi><mn>2</mn></msub></mover></mo><msub><mrow><mi mathvariant="normal">N</mi><mi mathvariant="normal">O</mi></mrow><mn>2</mn></msub><mo>+</mo><msub><mrow><mi mathvariant="normal">C</mi><mi mathvariant="normal">O</mi></mrow><mn>2</mn></msub></mrow><mo stretchy="true">‾</mo></munder></mrow><annotation encoding="application/x-tex">\underline{\mathrm{NO}_3+\mathrm{CO} \stackrel{k_2}{\rightarrow} \mathrm{NO}_2+\mathrm{CO}_2}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.5141em;vertical-align:-0.35em;"></span><span class="mord underline"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1641em;"><span style="top:-2.8541em;"><span class="pstrut" style="height:3.1641em;"></span><span class="underline-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.1641em;"><span class="pstrut" style="height:3.1641em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord mathrm">NO</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">3</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathrm">CO</span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel"><span class="mop op-limits"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:1.1641em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span><span class="mop">→</span></span></span><span style="top:-3.578em;margin-left:0em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.03148em;">k</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3173em;"><span style="top:-2.357em;margin-left:-0.0315em;margin-right:0.0714em;"><span class="pstrut" style="height:2.5em;"></span><span class="sizing reset-size3 size1 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.143em;"><span></span></span></span></span></span></span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mord"><span class="mord mathrm">NO</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord"><span class="mord mathrm">CO</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.35em;"><span></span></span></span></span></span></span></span></span></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext> rate </mtext><mo>=</mo><msub><mi>k</mi><mn>2</mn></msub><mrow><mo fence="true">[</mo><msub><mrow><mi mathvariant="normal">N</mi><mi mathvariant="normal">O</mi></mrow><mn>3</mn></msub><mo fence="true">]</mo></mrow><mo stretchy="false">[</mo><mrow><mi mathvariant="normal">C</mi><mi mathvariant="normal">O</mi></mrow><mo stretchy="false">]</mo><mo stretchy="false">(</mo><mtext> predicted </mtext><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">\text { rate }=k_2\left[\mathrm{NO}_3\right][\mathrm{CO}](\text { predicted })</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6151em;"></span><span class="mord text"><span class="mord"> rate </span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0315em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">[</span><span class="mord"><span class="mord"><span class="mord mathrm">NO</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">3</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">]</span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mopen">[</span><span class="mord"><span class="mord mathrm">CO</span></span><span class="mclose">]</span><span class="mopen">(</span><span class="mord text"><span class="mord"> predicted </span></span><span class="mclose">)</span></span></span></span></td>
</tr>
<tr>
<td>step 3</td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mrow><mi mathvariant="normal">N</mi><mi mathvariant="normal">O</mi></mrow><mn>2</mn></msub><mo>+</mo><mrow><mi mathvariant="normal">C</mi><mi mathvariant="normal">O</mi></mrow><mo><mover><mo><mo>→</mo></mo><mi>k</mi></mover></mo><mrow><mi mathvariant="normal">N</mi><mi mathvariant="normal">O</mi></mrow><mo>+</mo><msub><mrow><mi mathvariant="normal">C</mi><mi mathvariant="normal">O</mi></mrow><mn>2</mn></msub></mrow><annotation encoding="application/x-tex">\mathrm{NO}_2+\mathrm{CO} \stackrel{k}{\rightarrow} \mathrm{NO}+\mathrm{CO}_2</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord"><span class="mord mathrm">NO</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1.153em;"></span><span class="mord"><span class="mord mathrm">CO</span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel"><span class="mop op-limits"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:1.153em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span><span class="mop">→</span></span></span><span style="top:-3.5669em;margin-left:0em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.03148em;">k</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.7667em;vertical-align:-0.0833em;"></span><span class="mord"><span class="mord mathrm">NO</span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord"><span class="mord mathrm">CO</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext> rate </mtext><mo>=</mo><mi>k</mi><msup><mrow><mo fence="true">[</mo><msub><mrow><mi mathvariant="normal">N</mi><mi mathvariant="normal">O</mi></mrow><mn>2</mn></msub><mo fence="true">]</mo></mrow><mn>2</mn></msup><mo stretchy="false">(</mo><mtext> observed) </mtext></mrow><annotation encoding="application/x-tex">\text { rate }=k\left[\mathrm{NO}_2\right]^2(\text { observed) }</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6151em;"></span><span class="mord text"><span class="mord"> rate </span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.204em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="minner"><span class="mopen delimcenter" style="top:0em;">[</span><span class="mord"><span class="mord"><span class="mord mathrm">NO</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">]</span></span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.954em;"><span style="top:-3.2029em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mopen">(</span><span class="mord text"><span class="mord"> observed) </span></span></span></span></span></td>
</tr>
</tbody>
</table>
<p>The experimentally determined rate law for the reaction of <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mrow><mi mathvariant="normal">N</mi><mi mathvariant="normal">O</mi></mrow><mn>2</mn></msub></mrow><annotation encoding="application/x-tex">\mathrm{NO}_{2}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord"><span class="mord mathrm">NO</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> with <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>C</mi><mi>O</mi></mrow><annotation encoding="application/x-tex">C O</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.02778em;">CO</span></span></span></span> is the same as the predicted rate law for step 1 . This tells us that the first elementary reaction is the rate-determining step, so <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>k</mi></mrow><annotation encoding="application/x-tex">k</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal" style="margin-right:0.03148em;">k</span></span></span></span> for the overall reaction must equal <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>k</mi><mn>1</mn></msub></mrow><annotation encoding="application/x-tex">k_{1}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8444em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0315em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">1</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span>. That is, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mrow><mi mathvariant="normal">N</mi><mi mathvariant="normal">O</mi></mrow><mn>3</mn></msub></mrow><annotation encoding="application/x-tex">\mathrm{NO}_{3}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord"><span class="mord mathrm">NO</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">3</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> is formed slowly in step 1, but once it is formed, it reacts very rapidly with CO in step 2.</p>
<p>Sometimes chemists are able to propose two or more mechanisms that are consistent with the available data. If a proposed mechanism predicts the wrong experimental rate law, however, the mechanism must be incorrect.</p>
<h3 id="_12-5-4-1-example-a-reaction-with-an-intermediate" tabindex="-1">12-5-4-1: Example-A Reaction with an Intermediate <a class="header-anchor" href="#_12-5-4-1-example-a-reaction-with-an-intermediate" aria-label="Permalink to &quot;12-5-4-1: Example-A Reaction with an Intermediate&quot;">&ZeroWidthSpace;</a></h3>
<p>In an alternative mechanism for the reaction of <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mrow><mi mathvariant="normal">N</mi><mi mathvariant="normal">O</mi></mrow><mn>2</mn></msub></mrow><annotation encoding="application/x-tex">\mathrm{NO}_{2}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord"><span class="mord mathrm">NO</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> with <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">C</mi><mi mathvariant="normal">O</mi></mrow><annotation encoding="application/x-tex">\mathrm{CO}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord"><span class="mord mathrm">CO</span></span></span></span></span> with <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi mathvariant="normal">N</mi><mn>2</mn></msub><msub><mi mathvariant="normal">O</mi><mn>4</mn></msub></mrow><annotation encoding="application/x-tex">\mathrm{N}_{2} \mathrm{O}_{4}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathrm">N</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">O</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">4</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> appearing as an intermediate.</p>
<p>alternative mechanism for the reaction of <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mrow><mi mathvariant="normal">N</mi><mi mathvariant="normal">O</mi></mrow><mn>2</mn></msub></mrow><annotation encoding="application/x-tex">\mathrm{NO}_{2}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord"><span class="mord mathrm">NO</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> with <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">C</mi><mi mathvariant="normal">O</mi></mrow><annotation encoding="application/x-tex">\mathrm{CO}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord"><span class="mord mathrm">CO</span></span></span></span></span> with <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi mathvariant="normal">N</mi><mn>2</mn></msub><msub><mi mathvariant="normal">O</mi><mn>4</mn></msub></mrow><annotation encoding="application/x-tex">\mathrm{N}_{2} \mathrm{O}_{4}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathrm">N</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">O</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">4</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> appearing as an intermediate.</p>
<p>Write the rate law for each elementary reaction. Is this mechanism consistent with the experimentally determined rate law (rate <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>=</mo><mrow><mi mathvariant="normal">k</mi><mo stretchy="false">[</mo><msub><mrow><mi mathvariant="normal">N</mi><mi mathvariant="normal">O</mi></mrow><mn>2</mn></msub><msup><mo stretchy="false">]</mo><mn>2</mn></msup><mi mathvariant="normal">t</mi></mrow></mrow><annotation encoding="application/x-tex">=\mathrm{k[{NO}_{2}]^{2}t}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.0641em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord mathrm">k</span><span class="mopen">[</span><span class="mord"><span class="mord"><span class="mord mathrm">NO</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathrm mtight">2</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose"><span class="mclose">]</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathrm mtight">2</span></span></span></span></span></span></span></span></span><span class="mord mathrm">t</span></span></span></span></span>)</p>
<p>Given: elementary reactions Asked for: rate law for each elementary reaction and overall rate law</p>
<h4 id="strategy" tabindex="-1">Strategy <a class="header-anchor" href="#strategy" aria-label="Permalink to &quot;Strategy&quot;">&ZeroWidthSpace;</a></h4>
<ul>
<li>
<p>Determine the rate law for each elementary reaction in the reaction.</p>
</li>
<li>
<p>Determine which rate law corresponds to the experimentally determined rate law for the reaction. This rate law is the one for the rate-determining step.</p>
</li>
</ul>
<h4 id="solution" tabindex="-1">Solution <a class="header-anchor" href="#solution" aria-label="Permalink to &quot;Solution&quot;">&ZeroWidthSpace;</a></h4>
<details class="details custom-block"><summary>View solution</summary>
<p>A The rate law for step 1 is rate <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>=</mo><msub><mi>k</mi><mn>1</mn></msub><msup><mrow><mo fence="true">[</mo><msub><mrow><mi mathvariant="normal">N</mi><mi mathvariant="normal">O</mi></mrow><mn>2</mn></msub><mo fence="true">]</mo></mrow><mn>2</mn></msup></mrow><annotation encoding="application/x-tex">=k_{1}\left[\mathrm{NO}_{2}\right]^{2}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.204em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0315em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">1</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="minner"><span class="mopen delimcenter" style="top:0em;">[</span><span class="mord"><span class="mord"><span class="mord mathrm">NO</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">]</span></span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.954em;"><span style="top:-3.2029em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span></span></span>; for step 2 , it is rate <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>=</mo><msub><mi>k</mi><mn>2</mn></msub><mrow><mo fence="true">[</mo><msub><mrow><mtext> </mtext><mi mathvariant="normal">N</mi></mrow><mn>2</mn></msub><msub><mi mathvariant="normal">O</mi><mn>4</mn></msub><mo fence="true">]</mo></mrow><mo stretchy="false">[</mo><mrow><mi mathvariant="normal">C</mi><mi mathvariant="normal">O</mi></mrow><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">=k_{2}\left[\mathrm{~N}_{2} \mathrm{O}_{4}\right][\mathrm{CO}]</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0315em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">[</span><span class="mord"><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">N</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">O</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">4</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">]</span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mopen">[</span><span class="mord"><span class="mord mathrm">CO</span></span><span class="mclose">]</span></span></span></span>.</p>
<p>B If step 1 is slow (and therefore the rate-determining step), then the overall rate law for the reaction will be the same: rate <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>=</mo></mrow><annotation encoding="application/x-tex">=</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">=</span></span></span></span> <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>k</mi><mn>1</mn></msub><msup><mrow><mo fence="true">[</mo><msub><mrow><mi mathvariant="normal">N</mi><mi mathvariant="normal">O</mi></mrow><mn>2</mn></msub><mo fence="true">]</mo></mrow><mn>2</mn></msup></mrow><annotation encoding="application/x-tex">k_{1}\left[\mathrm{NO}_{2}\right]^{2}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.204em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0315em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">1</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="minner"><span class="mopen delimcenter" style="top:0em;">[</span><span class="mord"><span class="mord"><span class="mord mathrm">NO</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">]</span></span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.954em;"><span style="top:-3.2029em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span></span></span>. This is the same as the experimentally determined rate law. Hence this mechanism, with <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi mathvariant="normal">N</mi><mn>2</mn></msub><msub><mi mathvariant="normal">O</mi><mn>4</mn></msub></mrow><annotation encoding="application/x-tex">\mathrm{N}_{2} \mathrm{O}_{4}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathrm">N</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">O</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">4</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> as an intermediate, and the one described previously, with <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mrow><mi mathvariant="normal">N</mi><mi mathvariant="normal">O</mi></mrow><mn>3</mn></msub></mrow><annotation encoding="application/x-tex">\mathrm{NO}_{3}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord"><span class="mord mathrm">NO</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">3</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> as an intermediate, are kinetically indistinguishable. In this case, further experiments are needed to distinguish between them. For example, the researcher could try to detect the proposed intermediates, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mrow><mi mathvariant="normal">N</mi><mi mathvariant="normal">O</mi></mrow><mn>3</mn></msub></mrow><annotation encoding="application/x-tex">\mathrm{NO}_{3}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord"><span class="mord mathrm">NO</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">3</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> and <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi mathvariant="normal">N</mi><mn>2</mn></msub><msub><mi mathvariant="normal">O</mi><mn>4</mn></msub></mrow><annotation encoding="application/x-tex">\mathrm{N}_{2} \mathrm{O}_{4}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathrm">N</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">O</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">4</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span>, directly.</p>
</details>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Presentation problem: 02-20 ]]></title>
            <link>https://note.toshiki.devacademic/chemistry/problems/02-20</link>
            <guid>https://note.toshiki.devacademic/chemistry/problems/02-20</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="presentation-problem-02-20" tabindex="-1">Presentation problem: 02-20 <a class="header-anchor" href="#presentation-problem-02-20" aria-label="Permalink to &quot;Presentation problem: 02-20&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="question" tabindex="-1">Question <a class="header-anchor" href="#question" aria-label="Permalink to &quot;Question&quot;">&ZeroWidthSpace;</a></h2>
<p>At <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>500</mn><mrow><mtext> </mtext><mi mathvariant="normal">K</mi></mrow></mrow><annotation encoding="application/x-tex">500 \mathrm{~K}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">500</span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">K</span></span></span></span></span> in the presence of a copper surface, ethanol decomposes according to the equation</p>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><msub><mi mathvariant="normal">C</mi><mn>2</mn></msub><msub><mi mathvariant="normal">H</mi><mn>5</mn></msub><mrow><mi mathvariant="normal">O</mi><mi mathvariant="normal">H</mi></mrow><mo stretchy="false">(</mo><mi mathvariant="normal">g</mi><mo stretchy="false">)</mo><mo>⟶</mo><msub><mrow><mi mathvariant="normal">C</mi><mi mathvariant="normal">H</mi></mrow><mn>3</mn></msub><mrow><mi mathvariant="normal">C</mi><mi mathvariant="normal">H</mi><mi mathvariant="normal">O</mi></mrow><mo stretchy="false">(</mo><mi>g</mi><mo stretchy="false">)</mo><mo>+</mo><msub><mi mathvariant="normal">H</mi><mn>2</mn></msub><mo stretchy="false">(</mo><mi>g</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">\mathrm{C}_2 \mathrm{H}_5 \mathrm{OH}(\mathrm{g}) \longrightarrow \mathrm{CH}_3 \mathrm{CHO}(g)+\mathrm{H}_2(g)
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord mathrm">C</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">H</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">5</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">OH</span></span><span class="mopen">(</span><span class="mord mathrm" style="margin-right:0.01389em;">g</span><span class="mclose">)</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">⟶</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord"><span class="mord mathrm">CH</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">3</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">CHO</span></span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.03588em;">g</span><span class="mclose">)</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord mathrm">H</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.03588em;">g</span><span class="mclose">)</span></span></span></span></span></p>
<p>The pressure of <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi mathvariant="normal">C</mi><mn>2</mn></msub><msub><mi mathvariant="normal">H</mi><mn>5</mn></msub><mrow><mi mathvariant="normal">O</mi><mi mathvariant="normal">H</mi></mrow></mrow><annotation encoding="application/x-tex">\mathrm{C}_2 \mathrm{H}_5 \mathrm{OH}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathrm">C</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">H</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">5</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">OH</span></span></span></span></span> was measured as a function of time and the following data were obtained:</p>
<table>
<thead>
<tr>
<th>Time (s)</th>
<th><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>P</mi><mrow><msub><mi mathvariant="normal">C</mi><mn>2</mn></msub><msub><mi mathvariant="normal">H</mi><mn>5</mn></msub><mrow><mi mathvariant="normal">O</mi><mi mathvariant="normal">H</mi></mrow></mrow></msub><mtext> (torr) </mtext></mrow><annotation encoding="application/x-tex">P_{\mathrm{C}_2 \mathrm{H}_5 \mathrm{OH}} \text { (torr) }</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0001em;vertical-align:-0.2501em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.13889em;">P</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-left:-0.1389em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight"><span class="mord mathrm mtight">C</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3173em;"><span style="top:-2.357em;margin-left:0em;margin-right:0.0714em;"><span class="pstrut" style="height:2.5em;"></span><span class="sizing reset-size3 size1 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.143em;"><span></span></span></span></span></span></span><span class="mord mtight"><span class="mord mathrm mtight">H</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3173em;"><span style="top:-2.357em;margin-left:0em;margin-right:0.0714em;"><span class="pstrut" style="height:2.5em;"></span><span class="sizing reset-size3 size1 mtight"><span class="mord mtight">5</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.143em;"><span></span></span></span></span></span></span><span class="mord mtight"><span class="mord mathrm mtight">OH</span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2501em;"><span></span></span></span></span></span></span><span class="mord text"><span class="mord"> (torr) </span></span></span></span></span></th>
</tr>
</thead>
<tbody>
<tr>
<td>0</td>
<td>250.</td>
</tr>
<tr>
<td>100.</td>
<td>237</td>
</tr>
<tr>
<td>200.</td>
<td>224</td>
</tr>
<tr>
<td>300.</td>
<td>211</td>
</tr>
<tr>
<td>400.</td>
<td>198</td>
</tr>
<tr>
<td>500.</td>
<td>185</td>
</tr>
</tbody>
</table>
<p><strong>Since the pressure of a gas is directly proportional to the concentration of gas</strong>, we can express the rate law for a gaseous reaction in terms of partial pressures. Using the above data, deduce the rate law, the integrated rate law, and the value of the rate constant, all in terms of pressure units in atm and time in seconds. Predict the pressure of <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi mathvariant="normal">C</mi><mn>2</mn></msub><msub><mi mathvariant="normal">H</mi><mn>5</mn></msub><mrow><mi mathvariant="normal">O</mi><mi mathvariant="normal">H</mi></mrow></mrow><annotation encoding="application/x-tex">\mathrm{C}_2 \mathrm{H}_5 \mathrm{OH}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathrm">C</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">H</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">5</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">OH</span></span></span></span></span> after <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>900.</mn><mi mathvariant="normal">s</mi></mrow><annotation encoding="application/x-tex">900 . \mathrm{s}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">900.</span><span class="mord mathrm">s</span></span></span></span> from the start of the reaction. (Hint: To determine the order of the reaction with respect to <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi mathvariant="normal">C</mi><mn>2</mn></msub><msub><mi mathvariant="normal">H</mi><mn>5</mn></msub><mrow><mi mathvariant="normal">O</mi><mi mathvariant="normal">H</mi></mrow></mrow><annotation encoding="application/x-tex">\mathrm{C}_2 \mathrm{H}_5 \mathrm{OH}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathrm">C</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">H</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">5</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">OH</span></span></span></span></span>, compare how the pressure of <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi mathvariant="normal">C</mi><mn>2</mn></msub><msub><mi mathvariant="normal">H</mi><mn>5</mn></msub><mrow><mi mathvariant="normal">O</mi><mi mathvariant="normal">H</mi></mrow></mrow><annotation encoding="application/x-tex">\mathrm{C}_2 \mathrm{H}_5 \mathrm{OH}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathrm">C</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">H</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">5</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">OH</span></span></span></span></span> decreases with each time listing.)</p>
<h2 id="solution" tabindex="-1">Solution <a class="header-anchor" href="#solution" aria-label="Permalink to &quot;Solution&quot;">&ZeroWidthSpace;</a></h2>
<p><figure><img src="https://r2.toshiki.dev/image/chemistry/solution1.png" alt="solution graph" title="" /><figcaption align="center"><small>◎ </small></figcaption></figure></p>
<p>Due to the fact that the graph of <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">p</mi><mrow><mo fence="true">[</mo><msub><mi mathvariant="normal">O</mi><mn>2</mn></msub><mo fence="true">]</mo></mrow></mrow><annotation encoding="application/x-tex">\mathrm{p}\left[\mathrm{O}_2\right]</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathrm">p</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">[</span><span class="mord"><span class="mord mathrm">O</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">]</span></span></span></span></span> over time is showing <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msup><mi mathvariant="normal">R</mi><mn>2</mn></msup></mrow><annotation encoding="application/x-tex">\mathrm{R}^2</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8141em;"></span><span class="mord"><span class="mord mathrm">R</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span></span> value of 1 we know we have a zero-order reaction. Therefore:</p>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mtable rowspacing="0.25em" columnalign="right left" columnspacing="0em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mi mathvariant="normal">k</mi><mo>=</mo><mfrac><mrow><msub><mi mathvariant="normal">p</mi><mn>0</mn></msub><mrow><mo fence="true">[</mo><msub><mi mathvariant="normal">C</mi><mn>2</mn></msub><msub><mi mathvariant="normal">H</mi><mn>5</mn></msub><mrow><mi mathvariant="normal">O</mi><mi mathvariant="normal">H</mi></mrow><mo fence="true">]</mo></mrow><mo>−</mo><mi mathvariant="normal">p</mi><mrow><mo fence="true">[</mo><msub><mi mathvariant="normal">C</mi><mn>2</mn></msub><msub><mi mathvariant="normal">H</mi><mn>5</mn></msub><mrow><mi mathvariant="normal">O</mi><mi mathvariant="normal">H</mi></mrow><mo fence="true">]</mo></mrow></mrow><mi mathvariant="normal">t</mi></mfrac><mo>=</mo><mfrac><mrow><mn>250</mn><mtext> torr </mtext><mo>−</mo><mn>185</mn><mtext> torr </mtext></mrow><mrow><mn>500</mn><mrow><mtext> </mtext><mi mathvariant="normal">s</mi></mrow></mrow></mfrac><mo>=</mo><mn>0.13</mn><msup><mtext> torr s </mtext><mrow><mo>−</mo><mn>1</mn></mrow></msup></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mi mathvariant="normal">k</mi><mo>=</mo><mn>0.13</mn><mtext> torr s </mtext><msup><mi mathvariant="normal">s</mi><mrow><mo>−</mo><mn>1</mn></mrow></msup><mo>×</mo><mfrac><mrow><mn>1</mn><mrow><mtext> </mtext><mi mathvariant="normal">a</mi><mi mathvariant="normal">t</mi><mi mathvariant="normal">m</mi></mrow></mrow><mrow><mn>760</mn><mtext> torr </mtext></mrow></mfrac><mo>=</mo><mn>1.71</mn><mo>×</mo><mn>1</mn><msup><mn>0</mn><mrow><mo>−</mo><mn>4</mn></mrow></msup><mrow><mtext> </mtext><mi mathvariant="normal">a</mi><mi mathvariant="normal">t</mi><mi mathvariant="normal">m</mi></mrow><msup><mrow><mtext> </mtext><mi mathvariant="normal">s</mi></mrow><mrow><mo>−</mo><mn>1</mn></mrow></msup></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mtext> rate </mtext><mo>=</mo><mi mathvariant="bold">k</mi></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mi mathvariant="normal">p</mi><mrow><mo fence="true">(</mo><msub><mi mathvariant="normal">C</mi><mn>2</mn></msub><msub><mi mathvariant="normal">H</mi><mn>5</mn></msub><mrow><mi mathvariant="normal">O</mi><mi mathvariant="normal">H</mi></mrow><mo fence="true">)</mo></mrow><mo>=</mo><mo>−</mo><mrow><mi mathvariant="normal">k</mi><mi mathvariant="normal">t</mi></mrow><mo>+</mo><msub><mi mathvariant="normal">p</mi><mn>0</mn></msub><mrow><mo fence="true">(</mo><msub><mi mathvariant="normal">C</mi><mn>2</mn></msub><msub><mi mathvariant="normal">H</mi><mn>5</mn></msub><mrow><mi mathvariant="normal">O</mi><mi mathvariant="normal">H</mi></mrow><mo fence="true">)</mo></mrow></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mi mathvariant="normal">p</mi><mrow><mo fence="true">(</mo><msub><mi mathvariant="normal">C</mi><mn>2</mn></msub><msub><mi mathvariant="normal">H</mi><mn>5</mn></msub><mrow><mi mathvariant="normal">O</mi><mi mathvariant="normal">H</mi></mrow><mo fence="true">)</mo></mrow><mo>=</mo><mo>−</mo><mrow><mo fence="true">(</mo><mn>1.71</mn><mo>×</mo><mn>1</mn><msup><mn>0</mn><mrow><mo>−</mo><mn>4</mn></mrow></msup><mrow><mtext> </mtext><mi mathvariant="normal">a</mi><mi mathvariant="normal">t</mi><mi mathvariant="normal">m</mi></mrow><msup><mrow><mtext> </mtext><mi mathvariant="normal">s</mi></mrow><mrow><mo>−</mo><mn>1</mn></mrow></msup><mo fence="true">)</mo></mrow><mo>×</mo><mn>900</mn><mrow><mtext> </mtext><mi mathvariant="normal">s</mi></mrow><mo>+</mo><mn>0.33</mn><mrow><mtext> </mtext><mi mathvariant="normal">a</mi><mi mathvariant="normal">t</mi><mi mathvariant="normal">m</mi></mrow></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mi mathvariant="normal">p</mi><mrow><mo fence="true">(</mo><msub><mi mathvariant="normal">C</mi><mn>2</mn></msub><msub><mi mathvariant="normal">H</mi><mn>5</mn></msub><mrow><mi mathvariant="normal">O</mi><mi mathvariant="normal">H</mi></mrow><mo fence="true">)</mo></mrow><mo>=</mo><mn>0.176</mn><mrow><mtext> </mtext><mi mathvariant="normal">a</mi><mi mathvariant="normal">t</mi><mi mathvariant="normal">m</mi></mrow><msup><mrow><mtext> </mtext><mi mathvariant="normal">s</mi></mrow><mrow><mo>−</mo><mn>1</mn></mrow></msup></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{aligned}
&amp; \mathrm{k}=\frac{\mathrm{p}_0\left[\mathrm{C}_2 \mathrm{H}_5 \mathrm{OH}\right]-\mathrm{p}\left[\mathrm{C}_2 \mathrm{H}_5 \mathrm{OH}\right]}{\mathrm{t}}=\frac{250 \text { torr }-185 \text { torr }}{500 \mathrm{~s}}=0.13 \text { torr s }^{-1} \\
&amp; \mathrm{k}=0.13 \text { torr s } \mathrm{s}^{-1} \times \frac{1 \mathrm{~atm}}{760 \text { torr }}=1.71 \times 10^{-4} \mathrm{~atm} \mathrm{~s}^{-1} \\
&amp; \text { rate }=\mathbf{k} \\
&amp; \mathrm{p}\left(\mathrm{C}_2 \mathrm{H}_5 \mathrm{OH}\right)=-\mathrm{kt}+\mathrm{p}_0\left(\mathrm{C}_2 \mathrm{H}_5 \mathrm{OH}\right) \\
&amp; \mathrm{p}\left(\mathrm{C}_2 \mathrm{H}_5 \mathrm{OH}\right)=-\left(1.71 \times 10^{-4} \mathrm{~atm} \mathrm{~s}^{-1}\right) \times 900 \mathrm{~s}+0.33 \mathrm{~atm} \\
&amp; \mathrm{p}\left(\mathrm{C}_2 \mathrm{H}_5 \mathrm{OH}\right)=0.176 \mathrm{~atm} \mathrm{~s}^{-1} \\
&amp;
\end{aligned}
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:12.2687em;vertical-align:-5.8843em;"></span><span class="mord"><span class="mtable"><span class="col-align-r"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:6.3843em;"><span style="top:-8.3843em;"><span class="pstrut" style="height:3.427em;"></span><span class="mord"></span></span><span style="top:-6.0769em;"><span class="pstrut" style="height:3.427em;"></span><span class="mord"></span></span><span style="top:-4.2509em;"><span class="pstrut" style="height:3.427em;"></span><span class="mord"></span></span><span style="top:-2.7509em;"><span class="pstrut" style="height:3.427em;"></span><span class="mord"></span></span><span style="top:-1.2268em;"><span class="pstrut" style="height:3.427em;"></span><span class="mord"></span></span><span style="top:0.2973em;"><span class="pstrut" style="height:3.427em;"></span><span class="mord"></span></span><span style="top:1.7973em;"><span class="pstrut" style="height:3.427em;"></span><span class="mord"></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:5.8843em;"><span></span></span></span></span></span><span class="col-align-l"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:6.3843em;"><span style="top:-8.3843em;"><span class="pstrut" style="height:3.427em;"></span><span class="mord"><span class="mord"></span><span class="mord mathrm">k</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.427em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathrm">t</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"><span class="mord mathrm">p</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">0</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">[</span><span class="mord"><span class="mord mathrm">C</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">H</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">5</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">OH</span></span><span class="mclose delimcenter" style="top:0em;">]</span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathrm">p</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">[</span><span class="mord"><span class="mord mathrm">C</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">H</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">5</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">OH</span></span><span class="mclose delimcenter" style="top:0em;">]</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.3214em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">500</span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">s</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">250</span><span class="mord text"><span class="mord"> torr </span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord">185</span><span class="mord text"><span class="mord"> torr </span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord">0.13</span><span class="mord"><span class="mord text"><span class="mord"> torr s </span></span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">−</span><span class="mord mtight">1</span></span></span></span></span></span></span></span></span></span></span><span style="top:-6.0769em;"><span class="pstrut" style="height:3.427em;"></span><span class="mord"><span class="mord"></span><span class="mord mathrm">k</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord">0.13</span><span class="mord text"><span class="mord"> torr s </span></span><span class="mord"><span class="mord mathrm">s</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">−</span><span class="mord mtight">1</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">×</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.3214em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">760</span><span class="mord text"><span class="mord"> torr </span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">1</span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">atm</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord">1.71</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">×</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord">1</span><span class="mord"><span class="mord">0</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">−</span><span class="mord mtight">4</span></span></span></span></span></span></span></span></span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">atm</span></span><span class="mord"><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">s</span></span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">−</span><span class="mord mtight">1</span></span></span></span></span></span></span></span></span></span></span><span style="top:-4.2509em;"><span class="pstrut" style="height:3.427em;"></span><span class="mord"><span class="mord"></span><span class="mord text"><span class="mord"> rate </span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord mathbf">k</span></span></span><span style="top:-2.7509em;"><span class="pstrut" style="height:3.427em;"></span><span class="mord"><span class="mord"></span><span class="mord mathrm">p</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord"><span class="mord mathrm">C</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">H</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">5</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">OH</span></span><span class="mclose delimcenter" style="top:0em;">)</span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord">−</span><span class="mord"><span class="mord mathrm">kt</span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathrm">p</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">0</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord"><span class="mord mathrm">C</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">H</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">5</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">OH</span></span><span class="mclose delimcenter" style="top:0em;">)</span></span></span></span><span style="top:-1.2268em;"><span class="pstrut" style="height:3.427em;"></span><span class="mord"><span class="mord"></span><span class="mord mathrm">p</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord"><span class="mord mathrm">C</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">H</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">5</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">OH</span></span><span class="mclose delimcenter" style="top:0em;">)</span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord">−</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size1">(</span></span><span class="mord">1.71</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">×</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord">1</span><span class="mord"><span class="mord">0</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">−</span><span class="mord mtight">4</span></span></span></span></span></span></span></span></span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">atm</span></span><span class="mord"><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">s</span></span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">−</span><span class="mord mtight">1</span></span></span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size1">)</span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">×</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord">900</span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">s</span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord">0.33</span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">atm</span></span></span></span><span style="top:0.2973em;"><span class="pstrut" style="height:3.427em;"></span><span class="mord"><span class="mord"></span><span class="mord mathrm">p</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord"><span class="mord mathrm">C</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">H</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">5</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">OH</span></span><span class="mclose delimcenter" style="top:0em;">)</span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord">0.176</span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">atm</span></span><span class="mord"><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">s</span></span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">−</span><span class="mord mtight">1</span></span></span></span></span></span></span></span></span></span></span><span style="top:1.7973em;"><span class="pstrut" style="height:3.427em;"></span><span class="mord"><span class="mord"></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:5.8843em;"><span></span></span></span></span></span></span></span></span></span></span></span></p>
]]></description>
            <content:encoded><![CDATA[<h1 id="presentation-problem-02-20" tabindex="-1">Presentation problem: 02-20 <a class="header-anchor" href="#presentation-problem-02-20" aria-label="Permalink to &quot;Presentation problem: 02-20&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="question" tabindex="-1">Question <a class="header-anchor" href="#question" aria-label="Permalink to &quot;Question&quot;">&ZeroWidthSpace;</a></h2>
<p>At <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>500</mn><mrow><mtext> </mtext><mi mathvariant="normal">K</mi></mrow></mrow><annotation encoding="application/x-tex">500 \mathrm{~K}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">500</span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">K</span></span></span></span></span> in the presence of a copper surface, ethanol decomposes according to the equation</p>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><msub><mi mathvariant="normal">C</mi><mn>2</mn></msub><msub><mi mathvariant="normal">H</mi><mn>5</mn></msub><mrow><mi mathvariant="normal">O</mi><mi mathvariant="normal">H</mi></mrow><mo stretchy="false">(</mo><mi mathvariant="normal">g</mi><mo stretchy="false">)</mo><mo>⟶</mo><msub><mrow><mi mathvariant="normal">C</mi><mi mathvariant="normal">H</mi></mrow><mn>3</mn></msub><mrow><mi mathvariant="normal">C</mi><mi mathvariant="normal">H</mi><mi mathvariant="normal">O</mi></mrow><mo stretchy="false">(</mo><mi>g</mi><mo stretchy="false">)</mo><mo>+</mo><msub><mi mathvariant="normal">H</mi><mn>2</mn></msub><mo stretchy="false">(</mo><mi>g</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">\mathrm{C}_2 \mathrm{H}_5 \mathrm{OH}(\mathrm{g}) \longrightarrow \mathrm{CH}_3 \mathrm{CHO}(g)+\mathrm{H}_2(g)
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord mathrm">C</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">H</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">5</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">OH</span></span><span class="mopen">(</span><span class="mord mathrm" style="margin-right:0.01389em;">g</span><span class="mclose">)</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">⟶</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord"><span class="mord mathrm">CH</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">3</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">CHO</span></span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.03588em;">g</span><span class="mclose">)</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord mathrm">H</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.03588em;">g</span><span class="mclose">)</span></span></span></span></span></p>
<p>The pressure of <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi mathvariant="normal">C</mi><mn>2</mn></msub><msub><mi mathvariant="normal">H</mi><mn>5</mn></msub><mrow><mi mathvariant="normal">O</mi><mi mathvariant="normal">H</mi></mrow></mrow><annotation encoding="application/x-tex">\mathrm{C}_2 \mathrm{H}_5 \mathrm{OH}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathrm">C</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">H</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">5</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">OH</span></span></span></span></span> was measured as a function of time and the following data were obtained:</p>
<table>
<thead>
<tr>
<th>Time (s)</th>
<th><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>P</mi><mrow><msub><mi mathvariant="normal">C</mi><mn>2</mn></msub><msub><mi mathvariant="normal">H</mi><mn>5</mn></msub><mrow><mi mathvariant="normal">O</mi><mi mathvariant="normal">H</mi></mrow></mrow></msub><mtext> (torr) </mtext></mrow><annotation encoding="application/x-tex">P_{\mathrm{C}_2 \mathrm{H}_5 \mathrm{OH}} \text { (torr) }</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0001em;vertical-align:-0.2501em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.13889em;">P</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-left:-0.1389em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight"><span class="mord mathrm mtight">C</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3173em;"><span style="top:-2.357em;margin-left:0em;margin-right:0.0714em;"><span class="pstrut" style="height:2.5em;"></span><span class="sizing reset-size3 size1 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.143em;"><span></span></span></span></span></span></span><span class="mord mtight"><span class="mord mathrm mtight">H</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3173em;"><span style="top:-2.357em;margin-left:0em;margin-right:0.0714em;"><span class="pstrut" style="height:2.5em;"></span><span class="sizing reset-size3 size1 mtight"><span class="mord mtight">5</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.143em;"><span></span></span></span></span></span></span><span class="mord mtight"><span class="mord mathrm mtight">OH</span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2501em;"><span></span></span></span></span></span></span><span class="mord text"><span class="mord"> (torr) </span></span></span></span></span></th>
</tr>
</thead>
<tbody>
<tr>
<td>0</td>
<td>250.</td>
</tr>
<tr>
<td>100.</td>
<td>237</td>
</tr>
<tr>
<td>200.</td>
<td>224</td>
</tr>
<tr>
<td>300.</td>
<td>211</td>
</tr>
<tr>
<td>400.</td>
<td>198</td>
</tr>
<tr>
<td>500.</td>
<td>185</td>
</tr>
</tbody>
</table>
<p><strong>Since the pressure of a gas is directly proportional to the concentration of gas</strong>, we can express the rate law for a gaseous reaction in terms of partial pressures. Using the above data, deduce the rate law, the integrated rate law, and the value of the rate constant, all in terms of pressure units in atm and time in seconds. Predict the pressure of <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi mathvariant="normal">C</mi><mn>2</mn></msub><msub><mi mathvariant="normal">H</mi><mn>5</mn></msub><mrow><mi mathvariant="normal">O</mi><mi mathvariant="normal">H</mi></mrow></mrow><annotation encoding="application/x-tex">\mathrm{C}_2 \mathrm{H}_5 \mathrm{OH}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathrm">C</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">H</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">5</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">OH</span></span></span></span></span> after <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>900.</mn><mi mathvariant="normal">s</mi></mrow><annotation encoding="application/x-tex">900 . \mathrm{s}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">900.</span><span class="mord mathrm">s</span></span></span></span> from the start of the reaction. (Hint: To determine the order of the reaction with respect to <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi mathvariant="normal">C</mi><mn>2</mn></msub><msub><mi mathvariant="normal">H</mi><mn>5</mn></msub><mrow><mi mathvariant="normal">O</mi><mi mathvariant="normal">H</mi></mrow></mrow><annotation encoding="application/x-tex">\mathrm{C}_2 \mathrm{H}_5 \mathrm{OH}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathrm">C</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">H</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">5</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">OH</span></span></span></span></span>, compare how the pressure of <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi mathvariant="normal">C</mi><mn>2</mn></msub><msub><mi mathvariant="normal">H</mi><mn>5</mn></msub><mrow><mi mathvariant="normal">O</mi><mi mathvariant="normal">H</mi></mrow></mrow><annotation encoding="application/x-tex">\mathrm{C}_2 \mathrm{H}_5 \mathrm{OH}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathrm">C</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">H</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">5</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">OH</span></span></span></span></span> decreases with each time listing.)</p>
<h2 id="solution" tabindex="-1">Solution <a class="header-anchor" href="#solution" aria-label="Permalink to &quot;Solution&quot;">&ZeroWidthSpace;</a></h2>
<p><figure><img src="https://r2.toshiki.dev/image/chemistry/solution1.png" alt="solution graph" title="" /><figcaption align="center"><small>◎ </small></figcaption></figure></p>
<p>Due to the fact that the graph of <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">p</mi><mrow><mo fence="true">[</mo><msub><mi mathvariant="normal">O</mi><mn>2</mn></msub><mo fence="true">]</mo></mrow></mrow><annotation encoding="application/x-tex">\mathrm{p}\left[\mathrm{O}_2\right]</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathrm">p</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">[</span><span class="mord"><span class="mord mathrm">O</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">]</span></span></span></span></span> over time is showing <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msup><mi mathvariant="normal">R</mi><mn>2</mn></msup></mrow><annotation encoding="application/x-tex">\mathrm{R}^2</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8141em;"></span><span class="mord"><span class="mord mathrm">R</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span></span> value of 1 we know we have a zero-order reaction. Therefore:</p>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mtable rowspacing="0.25em" columnalign="right left" columnspacing="0em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mi mathvariant="normal">k</mi><mo>=</mo><mfrac><mrow><msub><mi mathvariant="normal">p</mi><mn>0</mn></msub><mrow><mo fence="true">[</mo><msub><mi mathvariant="normal">C</mi><mn>2</mn></msub><msub><mi mathvariant="normal">H</mi><mn>5</mn></msub><mrow><mi mathvariant="normal">O</mi><mi mathvariant="normal">H</mi></mrow><mo fence="true">]</mo></mrow><mo>−</mo><mi mathvariant="normal">p</mi><mrow><mo fence="true">[</mo><msub><mi mathvariant="normal">C</mi><mn>2</mn></msub><msub><mi mathvariant="normal">H</mi><mn>5</mn></msub><mrow><mi mathvariant="normal">O</mi><mi mathvariant="normal">H</mi></mrow><mo fence="true">]</mo></mrow></mrow><mi mathvariant="normal">t</mi></mfrac><mo>=</mo><mfrac><mrow><mn>250</mn><mtext> torr </mtext><mo>−</mo><mn>185</mn><mtext> torr </mtext></mrow><mrow><mn>500</mn><mrow><mtext> </mtext><mi mathvariant="normal">s</mi></mrow></mrow></mfrac><mo>=</mo><mn>0.13</mn><msup><mtext> torr s </mtext><mrow><mo>−</mo><mn>1</mn></mrow></msup></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mi mathvariant="normal">k</mi><mo>=</mo><mn>0.13</mn><mtext> torr s </mtext><msup><mi mathvariant="normal">s</mi><mrow><mo>−</mo><mn>1</mn></mrow></msup><mo>×</mo><mfrac><mrow><mn>1</mn><mrow><mtext> </mtext><mi mathvariant="normal">a</mi><mi mathvariant="normal">t</mi><mi mathvariant="normal">m</mi></mrow></mrow><mrow><mn>760</mn><mtext> torr </mtext></mrow></mfrac><mo>=</mo><mn>1.71</mn><mo>×</mo><mn>1</mn><msup><mn>0</mn><mrow><mo>−</mo><mn>4</mn></mrow></msup><mrow><mtext> </mtext><mi mathvariant="normal">a</mi><mi mathvariant="normal">t</mi><mi mathvariant="normal">m</mi></mrow><msup><mrow><mtext> </mtext><mi mathvariant="normal">s</mi></mrow><mrow><mo>−</mo><mn>1</mn></mrow></msup></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mtext> rate </mtext><mo>=</mo><mi mathvariant="bold">k</mi></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mi mathvariant="normal">p</mi><mrow><mo fence="true">(</mo><msub><mi mathvariant="normal">C</mi><mn>2</mn></msub><msub><mi mathvariant="normal">H</mi><mn>5</mn></msub><mrow><mi mathvariant="normal">O</mi><mi mathvariant="normal">H</mi></mrow><mo fence="true">)</mo></mrow><mo>=</mo><mo>−</mo><mrow><mi mathvariant="normal">k</mi><mi mathvariant="normal">t</mi></mrow><mo>+</mo><msub><mi mathvariant="normal">p</mi><mn>0</mn></msub><mrow><mo fence="true">(</mo><msub><mi mathvariant="normal">C</mi><mn>2</mn></msub><msub><mi mathvariant="normal">H</mi><mn>5</mn></msub><mrow><mi mathvariant="normal">O</mi><mi mathvariant="normal">H</mi></mrow><mo fence="true">)</mo></mrow></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mi mathvariant="normal">p</mi><mrow><mo fence="true">(</mo><msub><mi mathvariant="normal">C</mi><mn>2</mn></msub><msub><mi mathvariant="normal">H</mi><mn>5</mn></msub><mrow><mi mathvariant="normal">O</mi><mi mathvariant="normal">H</mi></mrow><mo fence="true">)</mo></mrow><mo>=</mo><mo>−</mo><mrow><mo fence="true">(</mo><mn>1.71</mn><mo>×</mo><mn>1</mn><msup><mn>0</mn><mrow><mo>−</mo><mn>4</mn></mrow></msup><mrow><mtext> </mtext><mi mathvariant="normal">a</mi><mi mathvariant="normal">t</mi><mi mathvariant="normal">m</mi></mrow><msup><mrow><mtext> </mtext><mi mathvariant="normal">s</mi></mrow><mrow><mo>−</mo><mn>1</mn></mrow></msup><mo fence="true">)</mo></mrow><mo>×</mo><mn>900</mn><mrow><mtext> </mtext><mi mathvariant="normal">s</mi></mrow><mo>+</mo><mn>0.33</mn><mrow><mtext> </mtext><mi mathvariant="normal">a</mi><mi mathvariant="normal">t</mi><mi mathvariant="normal">m</mi></mrow></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mi mathvariant="normal">p</mi><mrow><mo fence="true">(</mo><msub><mi mathvariant="normal">C</mi><mn>2</mn></msub><msub><mi mathvariant="normal">H</mi><mn>5</mn></msub><mrow><mi mathvariant="normal">O</mi><mi mathvariant="normal">H</mi></mrow><mo fence="true">)</mo></mrow><mo>=</mo><mn>0.176</mn><mrow><mtext> </mtext><mi mathvariant="normal">a</mi><mi mathvariant="normal">t</mi><mi mathvariant="normal">m</mi></mrow><msup><mrow><mtext> </mtext><mi mathvariant="normal">s</mi></mrow><mrow><mo>−</mo><mn>1</mn></mrow></msup></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{aligned}
&amp; \mathrm{k}=\frac{\mathrm{p}_0\left[\mathrm{C}_2 \mathrm{H}_5 \mathrm{OH}\right]-\mathrm{p}\left[\mathrm{C}_2 \mathrm{H}_5 \mathrm{OH}\right]}{\mathrm{t}}=\frac{250 \text { torr }-185 \text { torr }}{500 \mathrm{~s}}=0.13 \text { torr s }^{-1} \\
&amp; \mathrm{k}=0.13 \text { torr s } \mathrm{s}^{-1} \times \frac{1 \mathrm{~atm}}{760 \text { torr }}=1.71 \times 10^{-4} \mathrm{~atm} \mathrm{~s}^{-1} \\
&amp; \text { rate }=\mathbf{k} \\
&amp; \mathrm{p}\left(\mathrm{C}_2 \mathrm{H}_5 \mathrm{OH}\right)=-\mathrm{kt}+\mathrm{p}_0\left(\mathrm{C}_2 \mathrm{H}_5 \mathrm{OH}\right) \\
&amp; \mathrm{p}\left(\mathrm{C}_2 \mathrm{H}_5 \mathrm{OH}\right)=-\left(1.71 \times 10^{-4} \mathrm{~atm} \mathrm{~s}^{-1}\right) \times 900 \mathrm{~s}+0.33 \mathrm{~atm} \\
&amp; \mathrm{p}\left(\mathrm{C}_2 \mathrm{H}_5 \mathrm{OH}\right)=0.176 \mathrm{~atm} \mathrm{~s}^{-1} \\
&amp;
\end{aligned}
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:12.2687em;vertical-align:-5.8843em;"></span><span class="mord"><span class="mtable"><span class="col-align-r"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:6.3843em;"><span style="top:-8.3843em;"><span class="pstrut" style="height:3.427em;"></span><span class="mord"></span></span><span style="top:-6.0769em;"><span class="pstrut" style="height:3.427em;"></span><span class="mord"></span></span><span style="top:-4.2509em;"><span class="pstrut" style="height:3.427em;"></span><span class="mord"></span></span><span style="top:-2.7509em;"><span class="pstrut" style="height:3.427em;"></span><span class="mord"></span></span><span style="top:-1.2268em;"><span class="pstrut" style="height:3.427em;"></span><span class="mord"></span></span><span style="top:0.2973em;"><span class="pstrut" style="height:3.427em;"></span><span class="mord"></span></span><span style="top:1.7973em;"><span class="pstrut" style="height:3.427em;"></span><span class="mord"></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:5.8843em;"><span></span></span></span></span></span><span class="col-align-l"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:6.3843em;"><span style="top:-8.3843em;"><span class="pstrut" style="height:3.427em;"></span><span class="mord"><span class="mord"></span><span class="mord mathrm">k</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.427em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathrm">t</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"><span class="mord mathrm">p</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">0</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">[</span><span class="mord"><span class="mord mathrm">C</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">H</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">5</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">OH</span></span><span class="mclose delimcenter" style="top:0em;">]</span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathrm">p</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">[</span><span class="mord"><span class="mord mathrm">C</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">H</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">5</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">OH</span></span><span class="mclose delimcenter" style="top:0em;">]</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.3214em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">500</span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">s</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">250</span><span class="mord text"><span class="mord"> torr </span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord">185</span><span class="mord text"><span class="mord"> torr </span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord">0.13</span><span class="mord"><span class="mord text"><span class="mord"> torr s </span></span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">−</span><span class="mord mtight">1</span></span></span></span></span></span></span></span></span></span></span><span style="top:-6.0769em;"><span class="pstrut" style="height:3.427em;"></span><span class="mord"><span class="mord"></span><span class="mord mathrm">k</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord">0.13</span><span class="mord text"><span class="mord"> torr s </span></span><span class="mord"><span class="mord mathrm">s</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">−</span><span class="mord mtight">1</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">×</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.3214em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">760</span><span class="mord text"><span class="mord"> torr </span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">1</span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">atm</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord">1.71</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">×</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord">1</span><span class="mord"><span class="mord">0</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">−</span><span class="mord mtight">4</span></span></span></span></span></span></span></span></span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">atm</span></span><span class="mord"><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">s</span></span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">−</span><span class="mord mtight">1</span></span></span></span></span></span></span></span></span></span></span><span style="top:-4.2509em;"><span class="pstrut" style="height:3.427em;"></span><span class="mord"><span class="mord"></span><span class="mord text"><span class="mord"> rate </span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord mathbf">k</span></span></span><span style="top:-2.7509em;"><span class="pstrut" style="height:3.427em;"></span><span class="mord"><span class="mord"></span><span class="mord mathrm">p</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord"><span class="mord mathrm">C</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">H</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">5</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">OH</span></span><span class="mclose delimcenter" style="top:0em;">)</span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord">−</span><span class="mord"><span class="mord mathrm">kt</span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathrm">p</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">0</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord"><span class="mord mathrm">C</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">H</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">5</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">OH</span></span><span class="mclose delimcenter" style="top:0em;">)</span></span></span></span><span style="top:-1.2268em;"><span class="pstrut" style="height:3.427em;"></span><span class="mord"><span class="mord"></span><span class="mord mathrm">p</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord"><span class="mord mathrm">C</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">H</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">5</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">OH</span></span><span class="mclose delimcenter" style="top:0em;">)</span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord">−</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size1">(</span></span><span class="mord">1.71</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">×</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord">1</span><span class="mord"><span class="mord">0</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">−</span><span class="mord mtight">4</span></span></span></span></span></span></span></span></span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">atm</span></span><span class="mord"><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">s</span></span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">−</span><span class="mord mtight">1</span></span></span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size1">)</span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">×</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord">900</span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">s</span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord">0.33</span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">atm</span></span></span></span><span style="top:0.2973em;"><span class="pstrut" style="height:3.427em;"></span><span class="mord"><span class="mord"></span><span class="mord mathrm">p</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord"><span class="mord mathrm">C</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">H</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">5</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">OH</span></span><span class="mclose delimcenter" style="top:0em;">)</span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord">0.176</span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">atm</span></span><span class="mord"><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">s</span></span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">−</span><span class="mord mtight">1</span></span></span></span></span></span></span></span></span></span></span><span style="top:1.7973em;"><span class="pstrut" style="height:3.427em;"></span><span class="mord"><span class="mord"></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:5.8843em;"><span></span></span></span></span></span></span></span></span></span></span></span></p>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Problem: 03-02-1 ]]></title>
            <link>https://note.toshiki.devacademic/chemistry/problems/03-02-1</link>
            <guid>https://note.toshiki.devacademic/chemistry/problems/03-02-1</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="problem-03-02-1" tabindex="-1">Problem: 03-02-1 <a class="header-anchor" href="#problem-03-02-1" aria-label="Permalink to &quot;Problem: 03-02-1&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="question" tabindex="-1">Question <a class="header-anchor" href="#question" aria-label="Permalink to &quot;Question&quot;">&ZeroWidthSpace;</a></h2>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mn>2</mn><msub><mrow><mtext> </mtext><mi mathvariant="normal">N</mi></mrow><mn>2</mn></msub><msub><mi mathvariant="normal">O</mi><mn>5</mn></msub><mo stretchy="false">(</mo><mi>g</mi><mo stretchy="false">)</mo><mo>→</mo><mn>4</mn><msub><mrow><mi mathvariant="normal">N</mi><mi mathvariant="normal">O</mi></mrow><mn>2</mn></msub><mo stretchy="false">(</mo><mi>g</mi><mo stretchy="false">)</mo><mo>+</mo><msub><mi mathvariant="normal">O</mi><mn>2</mn></msub><mo stretchy="false">(</mo><mi>g</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">2 \mathrm{~N}_2 \mathrm{O}_5(g) \rightarrow 4 \mathrm{NO}_2(g)+\mathrm{O}_2(g)
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">2</span><span class="mord"><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">N</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">O</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">5</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.03588em;">g</span><span class="mclose">)</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">→</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">4</span><span class="mord"><span class="mord"><span class="mord mathrm">NO</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.03588em;">g</span><span class="mclose">)</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord mathrm">O</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.03588em;">g</span><span class="mclose">)</span></span></span></span></span></p>
<p>The decomposition of <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi mathvariant="normal">N</mi><mn>2</mn></msub><msub><mi mathvariant="normal">O</mi><mn>5</mn></msub><mo stretchy="false">(</mo><mi>g</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">\mathrm{N}_2 \mathrm{O}_5(g)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord mathrm">N</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">O</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">5</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.03588em;">g</span><span class="mclose">)</span></span></span></span> is represented by the equation above. A sample of <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi mathvariant="normal">N</mi><mn>2</mn></msub><msub><mi mathvariant="normal">O</mi><mn>5</mn></msub><mo stretchy="false">(</mo><mi>g</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">\mathrm{N}_2 \mathrm{O}_5(g)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord mathrm">N</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">O</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">5</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.03588em;">g</span><span class="mclose">)</span></span></span></span> is monitored as it decomposes, and the concentration of <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi mathvariant="normal">N</mi><mn>2</mn></msub><msub><mi mathvariant="normal">O</mi><mn>5</mn></msub></mrow><annotation encoding="application/x-tex">\mathrm{N}_2 \mathrm{O}_5</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathrm">N</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">O</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">5</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> as a function of time is recorded. The results are shown in the table below.</p>
<table>
<thead>
<tr>
<th>Time (s)</th>
<th><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">[</mo><msub><mi mathvariant="normal">N</mi><mn>2</mn></msub><msub><mi mathvariant="normal">O</mi><mn>5</mn></msub><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">\mathrm{[N_2O_5]}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord"><span class="mopen">[</span><span class="mord"><span class="mord mathrm">N</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathrm mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">O</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathrm mtight">5</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose">]</span></span></span></span></span></th>
</tr>
</thead>
<tbody>
<tr>
<td>0</td>
<td>1.000</td>
</tr>
<tr>
<td>25.0</td>
<td>0.801</td>
</tr>
<tr>
<td>50.0</td>
<td>0.642</td>
</tr>
<tr>
<td>75.0</td>
<td>0.515</td>
</tr>
</tbody>
</table>
<p>Calculate the average rate of the reaction between <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>50.0</mn></mrow><annotation encoding="application/x-tex">50.0</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">50.0</span></span></span></span> and <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>75.0</mn></mrow><annotation encoding="application/x-tex">75.0</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">75.0</span></span></span></span> seconds.</p>
<h2 id="solution" tabindex="-1">Solution <a class="header-anchor" href="#solution" aria-label="Permalink to &quot;Solution&quot;">&ZeroWidthSpace;</a></h2>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mi>a</mi><mrow><mtext> </mtext><mi mathvariant="normal">A</mi></mrow><mo>+</mo><mi>b</mi><mrow><mtext> </mtext><mi mathvariant="normal">B</mi></mrow><mo>→</mo><mi>c</mi><mi mathvariant="normal">C</mi><mo>+</mo><mi>d</mi><mi mathvariant="normal">D</mi></mrow><annotation encoding="application/x-tex">a \mathrm{~A}+b \mathrm{~B} \rightarrow c \mathrm{C}+d \mathrm{D}
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7667em;vertical-align:-0.0833em;"></span><span class="mord mathnormal">a</span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">A</span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">b</span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">B</span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">→</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.7667em;vertical-align:-0.0833em;"></span><span class="mord mathnormal">c</span><span class="mord mathrm">C</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">d</span><span class="mord mathrm">D</span></span></span></span></span></p>
<p>the rate of reaction is defined as</p>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mstyle mathcolor="cyan"><mtext> rate </mtext><mo>=</mo><mo>−</mo><mfrac><mn>1</mn><mi>a</mi></mfrac><mfrac><mrow><mi mathvariant="normal">Δ</mi><mo stretchy="false">[</mo><mi mathvariant="normal">A</mi><mo stretchy="false">]</mo></mrow><mrow><mi mathvariant="normal">Δ</mi><mi>t</mi></mrow></mfrac><mo>=</mo><mo>−</mo><mfrac><mn>1</mn><mi>b</mi></mfrac><mfrac><mrow><mi mathvariant="normal">Δ</mi><mo stretchy="false">[</mo><mi mathvariant="normal">B</mi><mo stretchy="false">]</mo></mrow><mrow><mi mathvariant="normal">Δ</mi><mi>t</mi></mrow></mfrac><mo>=</mo><mo>+</mo><mfrac><mn>1</mn><mi>c</mi></mfrac><mfrac><mrow><mi mathvariant="normal">Δ</mi><mo stretchy="false">[</mo><mi mathvariant="normal">C</mi><mo stretchy="false">]</mo></mrow><mrow><mi mathvariant="normal">Δ</mi><mi>t</mi></mrow></mfrac><mo>=</mo><mo>+</mo><mfrac><mn>1</mn><mi>d</mi></mfrac><mfrac><mrow><mi mathvariant="normal">Δ</mi><mo stretchy="false">[</mo><mi mathvariant="normal">D</mi><mo stretchy="false">]</mo></mrow><mrow><mi mathvariant="normal">Δ</mi><mi>t</mi></mrow></mfrac></mstyle></mrow><annotation encoding="application/x-tex">\color{cyan}\text { rate }=-\frac{1}{a} \frac{\Delta[\mathrm{A}]}{\Delta t}=-\frac{1}{b} \frac{\Delta[\mathrm{B}]}{\Delta t}=+\frac{1}{c} \frac{\Delta[\mathrm{C}]}{\Delta t}=+\frac{1}{d} \frac{\Delta[\mathrm{D}]}{\Delta t}
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6151em;"></span><span class="mord text" style="color:cyan;"><span class="mord" style="color:cyan;"> rate </span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel" style="color:cyan;">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:2.113em;vertical-align:-0.686em;"></span><span class="mord" style="color:cyan;">−</span><span class="mord" style="color:cyan;"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.3214em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord" style="color:cyan;"><span class="mord mathnormal" style="color:cyan;">a</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="color:cyan;border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord" style="color:cyan;"><span class="mord" style="color:cyan;">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mord" style="color:cyan;"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.427em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord" style="color:cyan;"><span class="mord" style="color:cyan;">Δ</span><span class="mord mathnormal" style="color:cyan;">t</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="color:cyan;border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord" style="color:cyan;"><span class="mord" style="color:cyan;">Δ</span><span class="mopen" style="color:cyan;">[</span><span class="mord mathrm" style="color:cyan;">A</span><span class="mclose" style="color:cyan;">]</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel" style="color:cyan;">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:2.113em;vertical-align:-0.686em;"></span><span class="mord" style="color:cyan;">−</span><span class="mord" style="color:cyan;"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.3214em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord" style="color:cyan;"><span class="mord mathnormal" style="color:cyan;">b</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="color:cyan;border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord" style="color:cyan;"><span class="mord" style="color:cyan;">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mord" style="color:cyan;"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.427em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord" style="color:cyan;"><span class="mord" style="color:cyan;">Δ</span><span class="mord mathnormal" style="color:cyan;">t</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="color:cyan;border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord" style="color:cyan;"><span class="mord" style="color:cyan;">Δ</span><span class="mopen" style="color:cyan;">[</span><span class="mord mathrm" style="color:cyan;">B</span><span class="mclose" style="color:cyan;">]</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel" style="color:cyan;">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:2.113em;vertical-align:-0.686em;"></span><span class="mord" style="color:cyan;">+</span><span class="mord" style="color:cyan;"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.3214em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord" style="color:cyan;"><span class="mord mathnormal" style="color:cyan;">c</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="color:cyan;border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord" style="color:cyan;"><span class="mord" style="color:cyan;">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mord" style="color:cyan;"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.427em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord" style="color:cyan;"><span class="mord" style="color:cyan;">Δ</span><span class="mord mathnormal" style="color:cyan;">t</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="color:cyan;border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord" style="color:cyan;"><span class="mord" style="color:cyan;">Δ</span><span class="mopen" style="color:cyan;">[</span><span class="mord mathrm" style="color:cyan;">C</span><span class="mclose" style="color:cyan;">]</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel" style="color:cyan;">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:2.113em;vertical-align:-0.686em;"></span><span class="mord" style="color:cyan;">+</span><span class="mord" style="color:cyan;"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.3214em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord" style="color:cyan;"><span class="mord mathnormal" style="color:cyan;">d</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="color:cyan;border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord" style="color:cyan;"><span class="mord" style="color:cyan;">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mord" style="color:cyan;"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.427em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord" style="color:cyan;"><span class="mord" style="color:cyan;">Δ</span><span class="mord mathnormal" style="color:cyan;">t</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="color:cyan;border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord" style="color:cyan;"><span class="mord" style="color:cyan;">Δ</span><span class="mopen" style="color:cyan;">[</span><span class="mord mathrm" style="color:cyan;">D</span><span class="mclose" style="color:cyan;">]</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span></span></p>
<p>Notice that the rate of change in concentration of each species is divided by its coefficient from the balanced chemical equation ( <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi></mrow><annotation encoding="application/x-tex">a</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">a</span></span></span></span>, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>b</mi><mo separator="true">,</mo><mi>c</mi></mrow><annotation encoding="application/x-tex">b, c</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">b</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">c</span></span></span></span>, or <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>d</mi></mrow><annotation encoding="application/x-tex">d</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">d</span></span></span></span> ). This ensures that the calculated reaction rate is the same no matter which reactant or product is monitored for changes in concentration.
In this case, the monitored species was <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi mathvariant="normal">N</mi><mn>2</mn></msub><msub><mi mathvariant="normal">O</mi><mn>5</mn></msub></mrow><annotation encoding="application/x-tex">\mathrm{N}_2 \mathrm{O}_5</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathrm">N</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">O</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">5</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span>. With that in mind, let's write the reaction rate in terms of the rate of change in concentration of <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi mathvariant="normal">N</mi><mn>2</mn></msub><msub><mi mathvariant="normal">O</mi><mn>5</mn></msub></mrow><annotation encoding="application/x-tex">\mathrm{N}_2 \mathrm{O}_5</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathrm">N</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">O</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">5</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> :</p>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mtext> rate </mtext><mo>=</mo><mo>−</mo><mfrac><mn>1</mn><mn>2</mn></mfrac><mfrac><mrow><mi mathvariant="normal">Δ</mi><mrow><mo fence="true">[</mo><msub><mi mathvariant="normal">N</mi><mn>2</mn></msub><msub><mi mathvariant="normal">O</mi><mn>5</mn></msub><mo fence="true">]</mo></mrow></mrow><mrow><mi mathvariant="normal">Δ</mi><mi>t</mi></mrow></mfrac></mrow><annotation encoding="application/x-tex">\text { rate }=-\frac{1}{2} \frac{\Delta\left[\mathrm{N}_2 \mathrm{O}_5\right]}{\Delta t}
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6151em;"></span><span class="mord text"><span class="mord"> rate </span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:2.113em;vertical-align:-0.686em;"></span><span class="mord">−</span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.3214em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">2</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.427em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">Δ</span><span class="mord mathnormal">t</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">Δ</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">[</span><span class="mord"><span class="mord mathrm">N</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">O</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">5</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">]</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span></span></p>
<p>Since the coefficient for <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi mathvariant="normal">N</mi><mn>2</mn></msub><msub><mi mathvariant="normal">O</mi><mn>5</mn></msub></mrow><annotation encoding="application/x-tex">\mathrm{N}_2 \mathrm{O}_5</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathrm">N</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">O</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">5</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> in the balanced equation is 2 , we divided the rate of change in concentration of <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi mathvariant="normal">N</mi><mn>2</mn></msub><msub><mi mathvariant="normal">O</mi><mn>5</mn></msub></mrow><annotation encoding="application/x-tex">\mathrm{N}_2 \mathrm{O}_5</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathrm">N</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">O</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">5</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> by 2 .
Additionally, since <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi mathvariant="normal">N</mi><mn>2</mn></msub><msub><mi mathvariant="normal">O</mi><mn>5</mn></msub></mrow><annotation encoding="application/x-tex">\mathrm{N}_2 \mathrm{O}_5</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathrm">N</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">O</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">5</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> is being consumed in the reaction, we included a negative sign in front of the expression.</p>
<p>Now, let's plug in the information from the table to calculate the average reaction rate between <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>50.0</mn></mrow><annotation encoding="application/x-tex">50.0</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">50.0</span></span></span></span> and <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>75.0</mn></mrow><annotation encoding="application/x-tex">75.0</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">75.0</span></span></span></span> seconds:</p>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mtable rowspacing="0.25em" columnalign="right left" columnspacing="0em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mtext> rate </mtext></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mo>=</mo><mo>−</mo><mfrac><mn>1</mn><mn>2</mn></mfrac><mfrac><mrow><mo stretchy="false">(</mo><mn>0.515</mn><mi>M</mi><mo>−</mo><mn>0.642</mn><mi>M</mi><mo stretchy="false">)</mo></mrow><mrow><mo stretchy="false">(</mo><mn>75.0</mn><mrow><mtext> </mtext><mi mathvariant="normal">s</mi></mrow><mo>−</mo><mn>50.0</mn><mrow><mtext> </mtext><mi mathvariant="normal">s</mi></mrow><mo stretchy="false">)</mo></mrow></mfrac></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mo>=</mo><mn>2.54</mn><mo>×</mo><mn>1</mn><msup><mn>0</mn><mrow><mo>−</mo><mn>3</mn></mrow></msup><mi>M</mi><msup><mrow><mtext> </mtext><mi mathvariant="normal">s</mi></mrow><mrow><mo>−</mo><mn>1</mn></mrow></msup></mrow></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{aligned}
\text { rate } &amp; =-\frac{1}{2} \frac{(0.515 M-0.642 M)}{(75.0 \mathrm{~s}-50.0 \mathrm{~s})} \\
&amp; =2.54 \times 10^{-3} M \mathrm{~s}^{-1}
\end{aligned}
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:4.1871em;vertical-align:-1.8436em;"></span><span class="mord"><span class="mtable"><span class="col-align-r"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:2.3436em;"><span style="top:-4.3436em;"><span class="pstrut" style="height:3.427em;"></span><span class="mord"><span class="mord text"><span class="mord"> rate </span></span></span></span><span style="top:-2.2434em;"><span class="pstrut" style="height:3.427em;"></span><span class="mord"></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.8436em;"><span></span></span></span></span></span><span class="col-align-l"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:2.3436em;"><span style="top:-4.3436em;"><span class="pstrut" style="height:3.427em;"></span><span class="mord"><span class="mord"></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord">−</span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.3214em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">2</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.427em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mopen">(</span><span class="mord">75.0</span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">s</span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord">50.0</span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">s</span></span><span class="mclose">)</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mopen">(</span><span class="mord">0.515</span><span class="mord mathnormal" style="margin-right:0.10903em;">M</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord">0.642</span><span class="mord mathnormal" style="margin-right:0.10903em;">M</span><span class="mclose">)</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.936em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span><span style="top:-2.2434em;"><span class="pstrut" style="height:3.427em;"></span><span class="mord"><span class="mord"></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord">2.54</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">×</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord">1</span><span class="mord"><span class="mord">0</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">−</span><span class="mord mtight">3</span></span></span></span></span></span></span></span></span><span class="mord mathnormal" style="margin-right:0.10903em;">M</span><span class="mord"><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">s</span></span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">−</span><span class="mord mtight">1</span></span></span></span></span></span></span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.8436em;"><span></span></span></span></span></span></span></span></span></span></span></span></p>
<p>So, the average rate of the reaction between <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>50.0</mn></mrow><annotation encoding="application/x-tex">50.0</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">50.0</span></span></span></span> and <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>75.0</mn></mrow><annotation encoding="application/x-tex">75.0</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">75.0</span></span></span></span> seconds is <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn mathvariant="bold">2.54</mn><mo>×</mo><mn mathvariant="bold">1</mn><msup><mn mathvariant="bold">0</mn><mrow><mo>−</mo><mn mathvariant="bold">3</mn></mrow></msup><mi mathvariant="normal">M</mi><msup><mi mathvariant="normal">s</mi><mrow><mo>−</mo><mn mathvariant="bold">1</mn></mrow></msup></mrow><annotation encoding="application/x-tex">\bold{2.54 \times 10^{-3} \mathrm{M} \mathrm{s}^{-1}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8974em;vertical-align:-0.0833em;"></span><span class="mord"><span class="mord mathbf">2.54</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">×</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathbf">1</span><span class="mord"><span class="mord mathbf">0</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">−</span><span class="mord mathbf mtight">3</span></span></span></span></span></span></span></span></span><span class="mord mathrm">M</span><span class="mord"><span class="mord mathrm">s</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">−</span><span class="mord mathbf mtight">1</span></span></span></span></span></span></span></span></span></span></span></span></span>.</p>
]]></description>
            <content:encoded><![CDATA[<h1 id="problem-03-02-1" tabindex="-1">Problem: 03-02-1 <a class="header-anchor" href="#problem-03-02-1" aria-label="Permalink to &quot;Problem: 03-02-1&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="question" tabindex="-1">Question <a class="header-anchor" href="#question" aria-label="Permalink to &quot;Question&quot;">&ZeroWidthSpace;</a></h2>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mn>2</mn><msub><mrow><mtext> </mtext><mi mathvariant="normal">N</mi></mrow><mn>2</mn></msub><msub><mi mathvariant="normal">O</mi><mn>5</mn></msub><mo stretchy="false">(</mo><mi>g</mi><mo stretchy="false">)</mo><mo>→</mo><mn>4</mn><msub><mrow><mi mathvariant="normal">N</mi><mi mathvariant="normal">O</mi></mrow><mn>2</mn></msub><mo stretchy="false">(</mo><mi>g</mi><mo stretchy="false">)</mo><mo>+</mo><msub><mi mathvariant="normal">O</mi><mn>2</mn></msub><mo stretchy="false">(</mo><mi>g</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">2 \mathrm{~N}_2 \mathrm{O}_5(g) \rightarrow 4 \mathrm{NO}_2(g)+\mathrm{O}_2(g)
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">2</span><span class="mord"><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">N</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">O</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">5</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.03588em;">g</span><span class="mclose">)</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">→</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">4</span><span class="mord"><span class="mord"><span class="mord mathrm">NO</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.03588em;">g</span><span class="mclose">)</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord mathrm">O</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.03588em;">g</span><span class="mclose">)</span></span></span></span></span></p>
<p>The decomposition of <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi mathvariant="normal">N</mi><mn>2</mn></msub><msub><mi mathvariant="normal">O</mi><mn>5</mn></msub><mo stretchy="false">(</mo><mi>g</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">\mathrm{N}_2 \mathrm{O}_5(g)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord mathrm">N</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">O</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">5</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.03588em;">g</span><span class="mclose">)</span></span></span></span> is represented by the equation above. A sample of <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi mathvariant="normal">N</mi><mn>2</mn></msub><msub><mi mathvariant="normal">O</mi><mn>5</mn></msub><mo stretchy="false">(</mo><mi>g</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">\mathrm{N}_2 \mathrm{O}_5(g)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord mathrm">N</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">O</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">5</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.03588em;">g</span><span class="mclose">)</span></span></span></span> is monitored as it decomposes, and the concentration of <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi mathvariant="normal">N</mi><mn>2</mn></msub><msub><mi mathvariant="normal">O</mi><mn>5</mn></msub></mrow><annotation encoding="application/x-tex">\mathrm{N}_2 \mathrm{O}_5</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathrm">N</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">O</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">5</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> as a function of time is recorded. The results are shown in the table below.</p>
<table>
<thead>
<tr>
<th>Time (s)</th>
<th><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">[</mo><msub><mi mathvariant="normal">N</mi><mn>2</mn></msub><msub><mi mathvariant="normal">O</mi><mn>5</mn></msub><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">\mathrm{[N_2O_5]}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord"><span class="mopen">[</span><span class="mord"><span class="mord mathrm">N</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathrm mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">O</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathrm mtight">5</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose">]</span></span></span></span></span></th>
</tr>
</thead>
<tbody>
<tr>
<td>0</td>
<td>1.000</td>
</tr>
<tr>
<td>25.0</td>
<td>0.801</td>
</tr>
<tr>
<td>50.0</td>
<td>0.642</td>
</tr>
<tr>
<td>75.0</td>
<td>0.515</td>
</tr>
</tbody>
</table>
<p>Calculate the average rate of the reaction between <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>50.0</mn></mrow><annotation encoding="application/x-tex">50.0</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">50.0</span></span></span></span> and <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>75.0</mn></mrow><annotation encoding="application/x-tex">75.0</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">75.0</span></span></span></span> seconds.</p>
<h2 id="solution" tabindex="-1">Solution <a class="header-anchor" href="#solution" aria-label="Permalink to &quot;Solution&quot;">&ZeroWidthSpace;</a></h2>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mi>a</mi><mrow><mtext> </mtext><mi mathvariant="normal">A</mi></mrow><mo>+</mo><mi>b</mi><mrow><mtext> </mtext><mi mathvariant="normal">B</mi></mrow><mo>→</mo><mi>c</mi><mi mathvariant="normal">C</mi><mo>+</mo><mi>d</mi><mi mathvariant="normal">D</mi></mrow><annotation encoding="application/x-tex">a \mathrm{~A}+b \mathrm{~B} \rightarrow c \mathrm{C}+d \mathrm{D}
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7667em;vertical-align:-0.0833em;"></span><span class="mord mathnormal">a</span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">A</span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">b</span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">B</span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">→</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.7667em;vertical-align:-0.0833em;"></span><span class="mord mathnormal">c</span><span class="mord mathrm">C</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">d</span><span class="mord mathrm">D</span></span></span></span></span></p>
<p>the rate of reaction is defined as</p>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mstyle mathcolor="cyan"><mtext> rate </mtext><mo>=</mo><mo>−</mo><mfrac><mn>1</mn><mi>a</mi></mfrac><mfrac><mrow><mi mathvariant="normal">Δ</mi><mo stretchy="false">[</mo><mi mathvariant="normal">A</mi><mo stretchy="false">]</mo></mrow><mrow><mi mathvariant="normal">Δ</mi><mi>t</mi></mrow></mfrac><mo>=</mo><mo>−</mo><mfrac><mn>1</mn><mi>b</mi></mfrac><mfrac><mrow><mi mathvariant="normal">Δ</mi><mo stretchy="false">[</mo><mi mathvariant="normal">B</mi><mo stretchy="false">]</mo></mrow><mrow><mi mathvariant="normal">Δ</mi><mi>t</mi></mrow></mfrac><mo>=</mo><mo>+</mo><mfrac><mn>1</mn><mi>c</mi></mfrac><mfrac><mrow><mi mathvariant="normal">Δ</mi><mo stretchy="false">[</mo><mi mathvariant="normal">C</mi><mo stretchy="false">]</mo></mrow><mrow><mi mathvariant="normal">Δ</mi><mi>t</mi></mrow></mfrac><mo>=</mo><mo>+</mo><mfrac><mn>1</mn><mi>d</mi></mfrac><mfrac><mrow><mi mathvariant="normal">Δ</mi><mo stretchy="false">[</mo><mi mathvariant="normal">D</mi><mo stretchy="false">]</mo></mrow><mrow><mi mathvariant="normal">Δ</mi><mi>t</mi></mrow></mfrac></mstyle></mrow><annotation encoding="application/x-tex">\color{cyan}\text { rate }=-\frac{1}{a} \frac{\Delta[\mathrm{A}]}{\Delta t}=-\frac{1}{b} \frac{\Delta[\mathrm{B}]}{\Delta t}=+\frac{1}{c} \frac{\Delta[\mathrm{C}]}{\Delta t}=+\frac{1}{d} \frac{\Delta[\mathrm{D}]}{\Delta t}
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6151em;"></span><span class="mord text" style="color:cyan;"><span class="mord" style="color:cyan;"> rate </span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel" style="color:cyan;">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:2.113em;vertical-align:-0.686em;"></span><span class="mord" style="color:cyan;">−</span><span class="mord" style="color:cyan;"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.3214em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord" style="color:cyan;"><span class="mord mathnormal" style="color:cyan;">a</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="color:cyan;border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord" style="color:cyan;"><span class="mord" style="color:cyan;">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mord" style="color:cyan;"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.427em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord" style="color:cyan;"><span class="mord" style="color:cyan;">Δ</span><span class="mord mathnormal" style="color:cyan;">t</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="color:cyan;border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord" style="color:cyan;"><span class="mord" style="color:cyan;">Δ</span><span class="mopen" style="color:cyan;">[</span><span class="mord mathrm" style="color:cyan;">A</span><span class="mclose" style="color:cyan;">]</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel" style="color:cyan;">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:2.113em;vertical-align:-0.686em;"></span><span class="mord" style="color:cyan;">−</span><span class="mord" style="color:cyan;"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.3214em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord" style="color:cyan;"><span class="mord mathnormal" style="color:cyan;">b</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="color:cyan;border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord" style="color:cyan;"><span class="mord" style="color:cyan;">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mord" style="color:cyan;"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.427em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord" style="color:cyan;"><span class="mord" style="color:cyan;">Δ</span><span class="mord mathnormal" style="color:cyan;">t</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="color:cyan;border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord" style="color:cyan;"><span class="mord" style="color:cyan;">Δ</span><span class="mopen" style="color:cyan;">[</span><span class="mord mathrm" style="color:cyan;">B</span><span class="mclose" style="color:cyan;">]</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel" style="color:cyan;">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:2.113em;vertical-align:-0.686em;"></span><span class="mord" style="color:cyan;">+</span><span class="mord" style="color:cyan;"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.3214em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord" style="color:cyan;"><span class="mord mathnormal" style="color:cyan;">c</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="color:cyan;border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord" style="color:cyan;"><span class="mord" style="color:cyan;">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mord" style="color:cyan;"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.427em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord" style="color:cyan;"><span class="mord" style="color:cyan;">Δ</span><span class="mord mathnormal" style="color:cyan;">t</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="color:cyan;border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord" style="color:cyan;"><span class="mord" style="color:cyan;">Δ</span><span class="mopen" style="color:cyan;">[</span><span class="mord mathrm" style="color:cyan;">C</span><span class="mclose" style="color:cyan;">]</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel" style="color:cyan;">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:2.113em;vertical-align:-0.686em;"></span><span class="mord" style="color:cyan;">+</span><span class="mord" style="color:cyan;"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.3214em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord" style="color:cyan;"><span class="mord mathnormal" style="color:cyan;">d</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="color:cyan;border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord" style="color:cyan;"><span class="mord" style="color:cyan;">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mord" style="color:cyan;"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.427em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord" style="color:cyan;"><span class="mord" style="color:cyan;">Δ</span><span class="mord mathnormal" style="color:cyan;">t</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="color:cyan;border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord" style="color:cyan;"><span class="mord" style="color:cyan;">Δ</span><span class="mopen" style="color:cyan;">[</span><span class="mord mathrm" style="color:cyan;">D</span><span class="mclose" style="color:cyan;">]</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span></span></p>
<p>Notice that the rate of change in concentration of each species is divided by its coefficient from the balanced chemical equation ( <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi></mrow><annotation encoding="application/x-tex">a</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">a</span></span></span></span>, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>b</mi><mo separator="true">,</mo><mi>c</mi></mrow><annotation encoding="application/x-tex">b, c</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">b</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">c</span></span></span></span>, or <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>d</mi></mrow><annotation encoding="application/x-tex">d</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">d</span></span></span></span> ). This ensures that the calculated reaction rate is the same no matter which reactant or product is monitored for changes in concentration.
In this case, the monitored species was <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi mathvariant="normal">N</mi><mn>2</mn></msub><msub><mi mathvariant="normal">O</mi><mn>5</mn></msub></mrow><annotation encoding="application/x-tex">\mathrm{N}_2 \mathrm{O}_5</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathrm">N</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">O</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">5</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span>. With that in mind, let's write the reaction rate in terms of the rate of change in concentration of <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi mathvariant="normal">N</mi><mn>2</mn></msub><msub><mi mathvariant="normal">O</mi><mn>5</mn></msub></mrow><annotation encoding="application/x-tex">\mathrm{N}_2 \mathrm{O}_5</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathrm">N</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">O</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">5</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> :</p>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mtext> rate </mtext><mo>=</mo><mo>−</mo><mfrac><mn>1</mn><mn>2</mn></mfrac><mfrac><mrow><mi mathvariant="normal">Δ</mi><mrow><mo fence="true">[</mo><msub><mi mathvariant="normal">N</mi><mn>2</mn></msub><msub><mi mathvariant="normal">O</mi><mn>5</mn></msub><mo fence="true">]</mo></mrow></mrow><mrow><mi mathvariant="normal">Δ</mi><mi>t</mi></mrow></mfrac></mrow><annotation encoding="application/x-tex">\text { rate }=-\frac{1}{2} \frac{\Delta\left[\mathrm{N}_2 \mathrm{O}_5\right]}{\Delta t}
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6151em;"></span><span class="mord text"><span class="mord"> rate </span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:2.113em;vertical-align:-0.686em;"></span><span class="mord">−</span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.3214em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">2</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.427em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">Δ</span><span class="mord mathnormal">t</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">Δ</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">[</span><span class="mord"><span class="mord mathrm">N</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">O</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">5</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">]</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span></span></p>
<p>Since the coefficient for <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi mathvariant="normal">N</mi><mn>2</mn></msub><msub><mi mathvariant="normal">O</mi><mn>5</mn></msub></mrow><annotation encoding="application/x-tex">\mathrm{N}_2 \mathrm{O}_5</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathrm">N</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">O</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">5</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> in the balanced equation is 2 , we divided the rate of change in concentration of <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi mathvariant="normal">N</mi><mn>2</mn></msub><msub><mi mathvariant="normal">O</mi><mn>5</mn></msub></mrow><annotation encoding="application/x-tex">\mathrm{N}_2 \mathrm{O}_5</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathrm">N</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">O</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">5</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> by 2 .
Additionally, since <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi mathvariant="normal">N</mi><mn>2</mn></msub><msub><mi mathvariant="normal">O</mi><mn>5</mn></msub></mrow><annotation encoding="application/x-tex">\mathrm{N}_2 \mathrm{O}_5</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathrm">N</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathrm">O</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">5</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> is being consumed in the reaction, we included a negative sign in front of the expression.</p>
<p>Now, let's plug in the information from the table to calculate the average reaction rate between <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>50.0</mn></mrow><annotation encoding="application/x-tex">50.0</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">50.0</span></span></span></span> and <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>75.0</mn></mrow><annotation encoding="application/x-tex">75.0</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">75.0</span></span></span></span> seconds:</p>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mtable rowspacing="0.25em" columnalign="right left" columnspacing="0em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mtext> rate </mtext></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mo>=</mo><mo>−</mo><mfrac><mn>1</mn><mn>2</mn></mfrac><mfrac><mrow><mo stretchy="false">(</mo><mn>0.515</mn><mi>M</mi><mo>−</mo><mn>0.642</mn><mi>M</mi><mo stretchy="false">)</mo></mrow><mrow><mo stretchy="false">(</mo><mn>75.0</mn><mrow><mtext> </mtext><mi mathvariant="normal">s</mi></mrow><mo>−</mo><mn>50.0</mn><mrow><mtext> </mtext><mi mathvariant="normal">s</mi></mrow><mo stretchy="false">)</mo></mrow></mfrac></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mo>=</mo><mn>2.54</mn><mo>×</mo><mn>1</mn><msup><mn>0</mn><mrow><mo>−</mo><mn>3</mn></mrow></msup><mi>M</mi><msup><mrow><mtext> </mtext><mi mathvariant="normal">s</mi></mrow><mrow><mo>−</mo><mn>1</mn></mrow></msup></mrow></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{aligned}
\text { rate } &amp; =-\frac{1}{2} \frac{(0.515 M-0.642 M)}{(75.0 \mathrm{~s}-50.0 \mathrm{~s})} \\
&amp; =2.54 \times 10^{-3} M \mathrm{~s}^{-1}
\end{aligned}
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:4.1871em;vertical-align:-1.8436em;"></span><span class="mord"><span class="mtable"><span class="col-align-r"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:2.3436em;"><span style="top:-4.3436em;"><span class="pstrut" style="height:3.427em;"></span><span class="mord"><span class="mord text"><span class="mord"> rate </span></span></span></span><span style="top:-2.2434em;"><span class="pstrut" style="height:3.427em;"></span><span class="mord"></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.8436em;"><span></span></span></span></span></span><span class="col-align-l"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:2.3436em;"><span style="top:-4.3436em;"><span class="pstrut" style="height:3.427em;"></span><span class="mord"><span class="mord"></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord">−</span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.3214em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">2</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.427em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mopen">(</span><span class="mord">75.0</span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">s</span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord">50.0</span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">s</span></span><span class="mclose">)</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mopen">(</span><span class="mord">0.515</span><span class="mord mathnormal" style="margin-right:0.10903em;">M</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord">0.642</span><span class="mord mathnormal" style="margin-right:0.10903em;">M</span><span class="mclose">)</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.936em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span><span style="top:-2.2434em;"><span class="pstrut" style="height:3.427em;"></span><span class="mord"><span class="mord"></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord">2.54</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">×</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord">1</span><span class="mord"><span class="mord">0</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">−</span><span class="mord mtight">3</span></span></span></span></span></span></span></span></span><span class="mord mathnormal" style="margin-right:0.10903em;">M</span><span class="mord"><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">s</span></span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">−</span><span class="mord mtight">1</span></span></span></span></span></span></span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.8436em;"><span></span></span></span></span></span></span></span></span></span></span></span></p>
<p>So, the average rate of the reaction between <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>50.0</mn></mrow><annotation encoding="application/x-tex">50.0</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">50.0</span></span></span></span> and <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>75.0</mn></mrow><annotation encoding="application/x-tex">75.0</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">75.0</span></span></span></span> seconds is <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn mathvariant="bold">2.54</mn><mo>×</mo><mn mathvariant="bold">1</mn><msup><mn mathvariant="bold">0</mn><mrow><mo>−</mo><mn mathvariant="bold">3</mn></mrow></msup><mi mathvariant="normal">M</mi><msup><mi mathvariant="normal">s</mi><mrow><mo>−</mo><mn mathvariant="bold">1</mn></mrow></msup></mrow><annotation encoding="application/x-tex">\bold{2.54 \times 10^{-3} \mathrm{M} \mathrm{s}^{-1}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8974em;vertical-align:-0.0833em;"></span><span class="mord"><span class="mord mathbf">2.54</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">×</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathbf">1</span><span class="mord"><span class="mord mathbf">0</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">−</span><span class="mord mathbf mtight">3</span></span></span></span></span></span></span></span></span><span class="mord mathrm">M</span><span class="mord"><span class="mord mathrm">s</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">−</span><span class="mord mathbf mtight">1</span></span></span></span></span></span></span></span></span></span></span></span></span>.</p>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Problem: 03-02-2 ]]></title>
            <link>https://note.toshiki.devacademic/chemistry/problems/03-02-2</link>
            <guid>https://note.toshiki.devacademic/chemistry/problems/03-02-2</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="problem-03-02-2" tabindex="-1">Problem: 03-02-2 <a class="header-anchor" href="#problem-03-02-2" aria-label="Permalink to &quot;Problem: 03-02-2&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="question" tabindex="-1">Question <a class="header-anchor" href="#question" aria-label="Permalink to &quot;Question&quot;">&ZeroWidthSpace;</a></h2>
<p>The rate law for a particular reaction is rate <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>=</mo><mi>k</mi><mo stretchy="false">[</mo><mrow><mi mathvariant="normal">X</mi><mi mathvariant="normal">Y</mi></mrow><msup><mo stretchy="false">]</mo><mn>2</mn></msup></mrow><annotation encoding="application/x-tex">=k[\mathrm{XY}]^2</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.0641em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="mopen">[</span><span class="mord"><span class="mord mathrm" style="margin-right:0.025em;">XY</span></span><span class="mclose"><span class="mclose">]</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span></span>. In an experiment, the initial rate of the reaction is determined to be <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>0.16</mn><mrow><mtext> </mtext><mi mathvariant="normal">m</mi><mi mathvariant="normal">o</mi><mi mathvariant="normal">l</mi></mrow><mi mathvariant="normal">/</mi><mo stretchy="false">(</mo><mi mathvariant="normal">L</mi><mo>⋅</mo><mi mathvariant="normal">s</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">0.16 \mathrm{~mol} /(\mathrm{L} \cdot \mathrm{s})</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">0.16</span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">mol</span></span><span class="mord">/</span><span class="mopen">(</span><span class="mord mathrm">L</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">⋅</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathrm">s</span><span class="mclose">)</span></span></span></span> when the initial concentration of <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">X</mi><mi mathvariant="normal">Y</mi></mrow><annotation encoding="application/x-tex">\mathrm{XY}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord"><span class="mord mathrm" style="margin-right:0.025em;">XY</span></span></span></span></span> is <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>0.40</mn><mrow><mtext> </mtext><mi mathvariant="normal">m</mi><mi mathvariant="normal">o</mi><mi mathvariant="normal">l</mi></mrow><mi mathvariant="normal">/</mi><mi mathvariant="normal">L</mi></mrow><annotation encoding="application/x-tex">0.40 \mathrm{~mol} / \mathrm{L}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">0.40</span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">mol</span></span><span class="mord">/</span><span class="mord mathrm">L</span></span></span></span>.</p>
<ul>
<li>What is the value of the rate constant, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>k</mi></mrow><annotation encoding="application/x-tex">k</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal" style="margin-right:0.03148em;">k</span></span></span></span>, for the reaction?
<ul class="contains-task-list">
<li class="task-list-item"><input class="task-list-item-checkbox" disabled="" type="checkbox"> <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>0.10</mn><mrow><mtext> </mtext><mi mathvariant="normal">L</mi></mrow><mi mathvariant="normal">/</mi><mo stretchy="false">(</mo><mrow><mi mathvariant="normal">m</mi><mi mathvariant="normal">o</mi><mi mathvariant="normal">l</mi></mrow><mo>⋅</mo><mi mathvariant="normal">s</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">0.10 \mathrm{~L} /(\mathrm{mol} \cdot \mathrm{s})</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">0.10</span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">L</span></span><span class="mord">/</span><span class="mopen">(</span><span class="mord"><span class="mord mathrm">mol</span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">⋅</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathrm">s</span><span class="mclose">)</span></span></span></span></li>
<li class="task-list-item"><input class="task-list-item-checkbox" disabled="" type="checkbox"> <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>0.40</mn><mrow><mtext> </mtext><mi mathvariant="normal">L</mi></mrow><mi mathvariant="normal">/</mi><mo stretchy="false">(</mo><mrow><mi mathvariant="normal">m</mi><mi mathvariant="normal">o</mi><mi mathvariant="normal">l</mi></mrow><mo>⋅</mo><mi mathvariant="normal">s</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">0.40 \mathrm{~L} /(\mathrm{mol} \cdot \mathrm{s})</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">0.40</span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">L</span></span><span class="mord">/</span><span class="mopen">(</span><span class="mord"><span class="mord mathrm">mol</span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">⋅</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathrm">s</span><span class="mclose">)</span></span></span></span></li>
<li class="task-list-item"><input class="task-list-item-checkbox" checked="" disabled="" type="checkbox"> <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>1.0</mn><mrow><mtext> </mtext><mi mathvariant="normal">L</mi></mrow><mi mathvariant="normal">/</mi><mo stretchy="false">(</mo><mrow><mi mathvariant="normal">m</mi><mi mathvariant="normal">o</mi><mi mathvariant="normal">l</mi></mrow><mo>⋅</mo><mi mathvariant="normal">s</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">1.0 \mathrm{~L} /(\mathrm{mol} \cdot \mathrm{s})</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">1.0</span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">L</span></span><span class="mord">/</span><span class="mopen">(</span><span class="mord"><span class="mord mathrm">mol</span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">⋅</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathrm">s</span><span class="mclose">)</span></span></span></span></li>
<li class="task-list-item"><input class="task-list-item-checkbox" disabled="" type="checkbox"> <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>2.5</mn><mrow><mtext> </mtext><mi mathvariant="normal">L</mi></mrow><mi mathvariant="normal">/</mi><mo stretchy="false">(</mo><mrow><mi mathvariant="normal">m</mi><mi mathvariant="normal">o</mi><mi mathvariant="normal">l</mi></mrow><mo>⋅</mo><mi mathvariant="normal">s</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">2.5 \mathrm{~L} /(\mathrm{mol} \cdot \mathrm{s})</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">2.5</span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">L</span></span><span class="mord">/</span><span class="mopen">(</span><span class="mord"><span class="mord mathrm">mol</span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">⋅</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathrm">s</span><span class="mclose">)</span></span></span></span></li>
</ul>
</li>
</ul>
<h2 id="solution" tabindex="-1">Solution <a class="header-anchor" href="#solution" aria-label="Permalink to &quot;Solution&quot;">&ZeroWidthSpace;</a></h2>
<p>lo tind the value of the rate constant for the reaction, let's first solve the rate law for <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>k</mi></mrow><annotation encoding="application/x-tex">k</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal" style="margin-right:0.03148em;">k</span></span></span></span> :</p>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mi>k</mi><mo>=</mo><mfrac><mtext> rate </mtext><mrow><mo stretchy="false">[</mo><mrow><mi mathvariant="normal">X</mi><mi mathvariant="normal">Y</mi></mrow><msup><mo stretchy="false">]</mo><mn>2</mn></msup></mrow></mfrac></mrow><annotation encoding="application/x-tex">k=\frac{\text { rate }}{[\mathrm{XY}]^2}
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:2.2281em;vertical-align:-0.936em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.2921em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mopen">[</span><span class="mord"><span class="mord mathrm" style="margin-right:0.025em;">XY</span></span><span class="mclose"><span class="mclose">]</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7401em;"><span style="top:-2.989em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord text"><span class="mord"> rate </span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.936em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span></span></p>
<p>Next, let's plug in the initial rate and concentration given in the text:</p>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mtable rowspacing="0.25em" columnalign="right left" columnspacing="0em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mi>k</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mo>=</mo><mfrac><mrow><mn>0.16</mn><mrow><mtext> </mtext><mi mathvariant="normal">m</mi><mi mathvariant="normal">o</mi><mi mathvariant="normal">l</mi></mrow><mi mathvariant="normal">/</mi><mo stretchy="false">(</mo><mi mathvariant="normal">L</mi><mo>⋅</mo><mi mathvariant="normal">s</mi><mo stretchy="false">)</mo></mrow><mrow><mo stretchy="false">(</mo><mn>0.40</mn><mrow><mtext> </mtext><mi mathvariant="normal">m</mi><mi mathvariant="normal">o</mi><mi mathvariant="normal">l</mi></mrow><mi mathvariant="normal">/</mi><mi mathvariant="normal">L</mi><msup><mo stretchy="false">)</mo><mn>2</mn></msup></mrow></mfrac></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mo>=</mo><mfrac><mrow><mn>0.16</mn><mrow><mtext> </mtext><mi mathvariant="normal">m</mi><mi mathvariant="normal">o</mi><mi mathvariant="normal">l</mi></mrow><mi mathvariant="normal">/</mi><mo stretchy="false">(</mo><mi mathvariant="normal">L</mi><mo>⋅</mo><mi mathvariant="normal">s</mi><mo stretchy="false">)</mo></mrow><mrow><mn>0.16</mn><msup><mrow><mtext> </mtext><mi mathvariant="normal">m</mi><mi mathvariant="normal">o</mi><mi mathvariant="normal">l</mi></mrow><mn>2</mn></msup><mi mathvariant="normal">/</mi><msup><mi mathvariant="normal">L</mi><mn>2</mn></msup></mrow></mfrac></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mo>=</mo><mn>1.0</mn><mrow><mtext> </mtext><mi mathvariant="normal">L</mi></mrow><mi mathvariant="normal">/</mi><mo stretchy="false">(</mo><mrow><mi mathvariant="normal">m</mi><mi mathvariant="normal">o</mi><mi mathvariant="normal">l</mi></mrow><mo>⋅</mo><mi mathvariant="normal">s</mi><mo stretchy="false">)</mo></mrow></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{aligned}
k &amp; =\frac{0.16 \mathrm{~mol} /(\mathrm{L} \cdot \mathrm{s})}{(0.40 \mathrm{~mol} / \mathrm{L})^2} \\
&amp; =\frac{0.16 \mathrm{~mol} /(\mathrm{L} \cdot \mathrm{s})}{0.16 \mathrm{~mol}^2 / \mathrm{L}^2} \\
&amp; =1.0 \mathrm{~L} /(\mathrm{mol} \cdot \mathrm{s})
\end{aligned}
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:6.9284em;vertical-align:-3.2142em;"></span><span class="mord"><span class="mtable"><span class="col-align-r"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:3.7142em;"><span style="top:-5.7142em;"><span class="pstrut" style="height:3.427em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03148em;">k</span></span></span><span style="top:-3.0512em;"><span class="pstrut" style="height:3.427em;"></span><span class="mord"></span></span><span style="top:-0.8728em;"><span class="pstrut" style="height:3.427em;"></span><span class="mord"></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:3.2142em;"><span></span></span></span></span></span><span class="col-align-l"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:3.7142em;"><span style="top:-5.7142em;"><span class="pstrut" style="height:3.427em;"></span><span class="mord"><span class="mord"></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.427em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mopen">(</span><span class="mord">0.40</span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">mol</span></span><span class="mord">/</span><span class="mord mathrm">L</span><span class="mclose"><span class="mclose">)</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7401em;"><span style="top:-2.989em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">0.16</span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">mol</span></span><span class="mord">/</span><span class="mopen">(</span><span class="mord mathrm">L</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">⋅</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathrm">s</span><span class="mclose">)</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.936em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span><span style="top:-3.0512em;"><span class="pstrut" style="height:3.427em;"></span><span class="mord"><span class="mord"></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.427em;"><span style="top:-2.2116em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">0.16</span><span class="mord"><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">mol</span></span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8984em;"><span style="top:-3.1473em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mord">/</span><span class="mord"><span class="mord mathrm">L</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7401em;"><span style="top:-2.989em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">0.16</span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">mol</span></span><span class="mord">/</span><span class="mopen">(</span><span class="mord mathrm">L</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">⋅</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathrm">s</span><span class="mclose">)</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.0384em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span><span style="top:-0.8728em;"><span class="pstrut" style="height:3.427em;"></span><span class="mord"><span class="mord"></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord">1.0</span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">L</span></span><span class="mord">/</span><span class="mopen">(</span><span class="mord"><span class="mord mathrm">mol</span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">⋅</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathrm">s</span><span class="mclose">)</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:3.2142em;"><span></span></span></span></span></span></span></span></span></span></span></span></p>
<p>So, the value of the rate constant for the reaction is
<span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>1.0</mn><mrow><mtext> </mtext><mi mathvariant="normal">L</mi></mrow><mi mathvariant="normal">/</mi><mo stretchy="false">(</mo><mrow><mi mathvariant="normal">m</mi><mi mathvariant="normal">o</mi><mi mathvariant="normal">l</mi></mrow><mo>⋅</mo><mi mathvariant="normal">s</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">1.0 \mathrm{~L} /(\mathrm{mol} \cdot \mathrm{s})</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">1.0</span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">L</span></span><span class="mord">/</span><span class="mopen">(</span><span class="mord"><span class="mord mathrm">mol</span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">⋅</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathrm">s</span><span class="mclose">)</span></span></span></span></p>
]]></description>
            <content:encoded><![CDATA[<h1 id="problem-03-02-2" tabindex="-1">Problem: 03-02-2 <a class="header-anchor" href="#problem-03-02-2" aria-label="Permalink to &quot;Problem: 03-02-2&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="question" tabindex="-1">Question <a class="header-anchor" href="#question" aria-label="Permalink to &quot;Question&quot;">&ZeroWidthSpace;</a></h2>
<p>The rate law for a particular reaction is rate <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>=</mo><mi>k</mi><mo stretchy="false">[</mo><mrow><mi mathvariant="normal">X</mi><mi mathvariant="normal">Y</mi></mrow><msup><mo stretchy="false">]</mo><mn>2</mn></msup></mrow><annotation encoding="application/x-tex">=k[\mathrm{XY}]^2</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.0641em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="mopen">[</span><span class="mord"><span class="mord mathrm" style="margin-right:0.025em;">XY</span></span><span class="mclose"><span class="mclose">]</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span></span>. In an experiment, the initial rate of the reaction is determined to be <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>0.16</mn><mrow><mtext> </mtext><mi mathvariant="normal">m</mi><mi mathvariant="normal">o</mi><mi mathvariant="normal">l</mi></mrow><mi mathvariant="normal">/</mi><mo stretchy="false">(</mo><mi mathvariant="normal">L</mi><mo>⋅</mo><mi mathvariant="normal">s</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">0.16 \mathrm{~mol} /(\mathrm{L} \cdot \mathrm{s})</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">0.16</span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">mol</span></span><span class="mord">/</span><span class="mopen">(</span><span class="mord mathrm">L</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">⋅</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathrm">s</span><span class="mclose">)</span></span></span></span> when the initial concentration of <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">X</mi><mi mathvariant="normal">Y</mi></mrow><annotation encoding="application/x-tex">\mathrm{XY}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord"><span class="mord mathrm" style="margin-right:0.025em;">XY</span></span></span></span></span> is <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>0.40</mn><mrow><mtext> </mtext><mi mathvariant="normal">m</mi><mi mathvariant="normal">o</mi><mi mathvariant="normal">l</mi></mrow><mi mathvariant="normal">/</mi><mi mathvariant="normal">L</mi></mrow><annotation encoding="application/x-tex">0.40 \mathrm{~mol} / \mathrm{L}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">0.40</span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">mol</span></span><span class="mord">/</span><span class="mord mathrm">L</span></span></span></span>.</p>
<ul>
<li>What is the value of the rate constant, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>k</mi></mrow><annotation encoding="application/x-tex">k</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal" style="margin-right:0.03148em;">k</span></span></span></span>, for the reaction?
<ul class="contains-task-list">
<li class="task-list-item"><input class="task-list-item-checkbox" disabled="" type="checkbox"> <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>0.10</mn><mrow><mtext> </mtext><mi mathvariant="normal">L</mi></mrow><mi mathvariant="normal">/</mi><mo stretchy="false">(</mo><mrow><mi mathvariant="normal">m</mi><mi mathvariant="normal">o</mi><mi mathvariant="normal">l</mi></mrow><mo>⋅</mo><mi mathvariant="normal">s</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">0.10 \mathrm{~L} /(\mathrm{mol} \cdot \mathrm{s})</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">0.10</span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">L</span></span><span class="mord">/</span><span class="mopen">(</span><span class="mord"><span class="mord mathrm">mol</span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">⋅</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathrm">s</span><span class="mclose">)</span></span></span></span></li>
<li class="task-list-item"><input class="task-list-item-checkbox" disabled="" type="checkbox"> <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>0.40</mn><mrow><mtext> </mtext><mi mathvariant="normal">L</mi></mrow><mi mathvariant="normal">/</mi><mo stretchy="false">(</mo><mrow><mi mathvariant="normal">m</mi><mi mathvariant="normal">o</mi><mi mathvariant="normal">l</mi></mrow><mo>⋅</mo><mi mathvariant="normal">s</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">0.40 \mathrm{~L} /(\mathrm{mol} \cdot \mathrm{s})</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">0.40</span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">L</span></span><span class="mord">/</span><span class="mopen">(</span><span class="mord"><span class="mord mathrm">mol</span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">⋅</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathrm">s</span><span class="mclose">)</span></span></span></span></li>
<li class="task-list-item"><input class="task-list-item-checkbox" checked="" disabled="" type="checkbox"> <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>1.0</mn><mrow><mtext> </mtext><mi mathvariant="normal">L</mi></mrow><mi mathvariant="normal">/</mi><mo stretchy="false">(</mo><mrow><mi mathvariant="normal">m</mi><mi mathvariant="normal">o</mi><mi mathvariant="normal">l</mi></mrow><mo>⋅</mo><mi mathvariant="normal">s</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">1.0 \mathrm{~L} /(\mathrm{mol} \cdot \mathrm{s})</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">1.0</span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">L</span></span><span class="mord">/</span><span class="mopen">(</span><span class="mord"><span class="mord mathrm">mol</span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">⋅</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathrm">s</span><span class="mclose">)</span></span></span></span></li>
<li class="task-list-item"><input class="task-list-item-checkbox" disabled="" type="checkbox"> <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>2.5</mn><mrow><mtext> </mtext><mi mathvariant="normal">L</mi></mrow><mi mathvariant="normal">/</mi><mo stretchy="false">(</mo><mrow><mi mathvariant="normal">m</mi><mi mathvariant="normal">o</mi><mi mathvariant="normal">l</mi></mrow><mo>⋅</mo><mi mathvariant="normal">s</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">2.5 \mathrm{~L} /(\mathrm{mol} \cdot \mathrm{s})</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">2.5</span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">L</span></span><span class="mord">/</span><span class="mopen">(</span><span class="mord"><span class="mord mathrm">mol</span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">⋅</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathrm">s</span><span class="mclose">)</span></span></span></span></li>
</ul>
</li>
</ul>
<h2 id="solution" tabindex="-1">Solution <a class="header-anchor" href="#solution" aria-label="Permalink to &quot;Solution&quot;">&ZeroWidthSpace;</a></h2>
<p>lo tind the value of the rate constant for the reaction, let's first solve the rate law for <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>k</mi></mrow><annotation encoding="application/x-tex">k</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal" style="margin-right:0.03148em;">k</span></span></span></span> :</p>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mi>k</mi><mo>=</mo><mfrac><mtext> rate </mtext><mrow><mo stretchy="false">[</mo><mrow><mi mathvariant="normal">X</mi><mi mathvariant="normal">Y</mi></mrow><msup><mo stretchy="false">]</mo><mn>2</mn></msup></mrow></mfrac></mrow><annotation encoding="application/x-tex">k=\frac{\text { rate }}{[\mathrm{XY}]^2}
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:2.2281em;vertical-align:-0.936em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.2921em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mopen">[</span><span class="mord"><span class="mord mathrm" style="margin-right:0.025em;">XY</span></span><span class="mclose"><span class="mclose">]</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7401em;"><span style="top:-2.989em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord text"><span class="mord"> rate </span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.936em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span></span></p>
<p>Next, let's plug in the initial rate and concentration given in the text:</p>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mtable rowspacing="0.25em" columnalign="right left" columnspacing="0em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mi>k</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mo>=</mo><mfrac><mrow><mn>0.16</mn><mrow><mtext> </mtext><mi mathvariant="normal">m</mi><mi mathvariant="normal">o</mi><mi mathvariant="normal">l</mi></mrow><mi mathvariant="normal">/</mi><mo stretchy="false">(</mo><mi mathvariant="normal">L</mi><mo>⋅</mo><mi mathvariant="normal">s</mi><mo stretchy="false">)</mo></mrow><mrow><mo stretchy="false">(</mo><mn>0.40</mn><mrow><mtext> </mtext><mi mathvariant="normal">m</mi><mi mathvariant="normal">o</mi><mi mathvariant="normal">l</mi></mrow><mi mathvariant="normal">/</mi><mi mathvariant="normal">L</mi><msup><mo stretchy="false">)</mo><mn>2</mn></msup></mrow></mfrac></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mo>=</mo><mfrac><mrow><mn>0.16</mn><mrow><mtext> </mtext><mi mathvariant="normal">m</mi><mi mathvariant="normal">o</mi><mi mathvariant="normal">l</mi></mrow><mi mathvariant="normal">/</mi><mo stretchy="false">(</mo><mi mathvariant="normal">L</mi><mo>⋅</mo><mi mathvariant="normal">s</mi><mo stretchy="false">)</mo></mrow><mrow><mn>0.16</mn><msup><mrow><mtext> </mtext><mi mathvariant="normal">m</mi><mi mathvariant="normal">o</mi><mi mathvariant="normal">l</mi></mrow><mn>2</mn></msup><mi mathvariant="normal">/</mi><msup><mi mathvariant="normal">L</mi><mn>2</mn></msup></mrow></mfrac></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mo>=</mo><mn>1.0</mn><mrow><mtext> </mtext><mi mathvariant="normal">L</mi></mrow><mi mathvariant="normal">/</mi><mo stretchy="false">(</mo><mrow><mi mathvariant="normal">m</mi><mi mathvariant="normal">o</mi><mi mathvariant="normal">l</mi></mrow><mo>⋅</mo><mi mathvariant="normal">s</mi><mo stretchy="false">)</mo></mrow></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{aligned}
k &amp; =\frac{0.16 \mathrm{~mol} /(\mathrm{L} \cdot \mathrm{s})}{(0.40 \mathrm{~mol} / \mathrm{L})^2} \\
&amp; =\frac{0.16 \mathrm{~mol} /(\mathrm{L} \cdot \mathrm{s})}{0.16 \mathrm{~mol}^2 / \mathrm{L}^2} \\
&amp; =1.0 \mathrm{~L} /(\mathrm{mol} \cdot \mathrm{s})
\end{aligned}
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:6.9284em;vertical-align:-3.2142em;"></span><span class="mord"><span class="mtable"><span class="col-align-r"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:3.7142em;"><span style="top:-5.7142em;"><span class="pstrut" style="height:3.427em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03148em;">k</span></span></span><span style="top:-3.0512em;"><span class="pstrut" style="height:3.427em;"></span><span class="mord"></span></span><span style="top:-0.8728em;"><span class="pstrut" style="height:3.427em;"></span><span class="mord"></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:3.2142em;"><span></span></span></span></span></span><span class="col-align-l"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:3.7142em;"><span style="top:-5.7142em;"><span class="pstrut" style="height:3.427em;"></span><span class="mord"><span class="mord"></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.427em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mopen">(</span><span class="mord">0.40</span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">mol</span></span><span class="mord">/</span><span class="mord mathrm">L</span><span class="mclose"><span class="mclose">)</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7401em;"><span style="top:-2.989em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">0.16</span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">mol</span></span><span class="mord">/</span><span class="mopen">(</span><span class="mord mathrm">L</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">⋅</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathrm">s</span><span class="mclose">)</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.936em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span><span style="top:-3.0512em;"><span class="pstrut" style="height:3.427em;"></span><span class="mord"><span class="mord"></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.427em;"><span style="top:-2.2116em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">0.16</span><span class="mord"><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">mol</span></span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8984em;"><span style="top:-3.1473em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mord">/</span><span class="mord"><span class="mord mathrm">L</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7401em;"><span style="top:-2.989em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">0.16</span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">mol</span></span><span class="mord">/</span><span class="mopen">(</span><span class="mord mathrm">L</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">⋅</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathrm">s</span><span class="mclose">)</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.0384em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span><span style="top:-0.8728em;"><span class="pstrut" style="height:3.427em;"></span><span class="mord"><span class="mord"></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord">1.0</span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">L</span></span><span class="mord">/</span><span class="mopen">(</span><span class="mord"><span class="mord mathrm">mol</span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">⋅</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathrm">s</span><span class="mclose">)</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:3.2142em;"><span></span></span></span></span></span></span></span></span></span></span></span></p>
<p>So, the value of the rate constant for the reaction is
<span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>1.0</mn><mrow><mtext> </mtext><mi mathvariant="normal">L</mi></mrow><mi mathvariant="normal">/</mi><mo stretchy="false">(</mo><mrow><mi mathvariant="normal">m</mi><mi mathvariant="normal">o</mi><mi mathvariant="normal">l</mi></mrow><mo>⋅</mo><mi mathvariant="normal">s</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">1.0 \mathrm{~L} /(\mathrm{mol} \cdot \mathrm{s})</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">1.0</span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">L</span></span><span class="mord">/</span><span class="mopen">(</span><span class="mord"><span class="mord mathrm">mol</span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">⋅</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathrm">s</span><span class="mclose">)</span></span></span></span></p>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Problem 03-02-3 ]]></title>
            <link>https://note.toshiki.devacademic/chemistry/problems/03-02-3</link>
            <guid>https://note.toshiki.devacademic/chemistry/problems/03-02-3</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="problem-03-02-3" tabindex="-1">Problem 03-02-3 <a class="header-anchor" href="#problem-03-02-3" aria-label="Permalink to &quot;Problem 03-02-3&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="question" tabindex="-1">Question <a class="header-anchor" href="#question" aria-label="Permalink to &quot;Question&quot;">&ZeroWidthSpace;</a></h2>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mn>2</mn><mi mathvariant="normal">X</mi><mo stretchy="false">(</mo><mi>g</mi><mo stretchy="false">)</mo><mo>+</mo><mn>2</mn><mi mathvariant="normal">Y</mi><mo stretchy="false">(</mo><mi>g</mi><mo stretchy="false">)</mo><mo>→</mo><mi mathvariant="normal">Q</mi><mo stretchy="false">(</mo><mi>g</mi><mo stretchy="false">)</mo><mo>+</mo><mn>2</mn><mi mathvariant="normal">R</mi><mo stretchy="false">(</mo><mi>g</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">2 \mathrm{X}(g)+2 \mathrm{Y}(g) \rightarrow \mathrm{Q}(g)+2 \mathrm{R}(g)
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">2</span><span class="mord mathrm">X</span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.03588em;">g</span><span class="mclose">)</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">2</span><span class="mord mathrm" style="margin-right:0.025em;">Y</span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.03588em;">g</span><span class="mclose">)</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">→</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathrm">Q</span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.03588em;">g</span><span class="mclose">)</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">2</span><span class="mord mathrm">R</span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.03588em;">g</span><span class="mclose">)</span></span></span></span></span></p>
<p>The reaction represented above is found to be second order with respect to <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">X</mi></mrow><annotation encoding="application/x-tex">\mathrm{X}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathrm">X</span></span></span></span> and first order with respect to <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Y</mi></mrow><annotation encoding="application/x-tex">\mathrm{Y}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathrm" style="margin-right:0.025em;">Y</span></span></span></span>.</p>
<p>What happens to the rate of the reaction when <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">[</mo><mi mathvariant="normal">X</mi><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">[\mathrm{X}]</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">[</span><span class="mord mathrm">X</span><span class="mclose">]</span></span></span></span> is halved and <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">[</mo><mi mathvariant="normal">Y</mi><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">[\mathrm{Y}]</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">[</span><span class="mord mathrm" style="margin-right:0.025em;">Y</span><span class="mclose">]</span></span></span></span> is doubled?</p>
<ul class="contains-task-list">
<li class="task-list-item"><input class="task-list-item-checkbox" disabled="" type="checkbox"> It increases by a factor of 4.</li>
<li class="task-list-item"><input class="task-list-item-checkbox" checked="" disabled="" type="checkbox"> It decreases by a factor of 2.</li>
<li class="task-list-item"><input class="task-list-item-checkbox" disabled="" type="checkbox"> It decreases by a factor of 4.</li>
<li class="task-list-item"><input class="task-list-item-checkbox" disabled="" type="checkbox"> It does not change.</li>
</ul>
<h2 id="solution" tabindex="-1">Solution <a class="header-anchor" href="#solution" aria-label="Permalink to &quot;Solution&quot;">&ZeroWidthSpace;</a></h2>
<p>To solve this problem, let's first write out the rate law for the reaction. According to the text, the reaction is second order with respect to <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">X</mi></mrow><annotation encoding="application/x-tex">\mathrm{X}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathrm">X</span></span></span></span> and first order with respect to <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Y</mi></mrow><annotation encoding="application/x-tex">\mathrm{Y}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathrm" style="margin-right:0.025em;">Y</span></span></span></span>, so the rate law is rate <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>=</mo><mi>k</mi><mo stretchy="false">[</mo><mi mathvariant="normal">X</mi><msup><mo stretchy="false">]</mo><mn>2</mn></msup><mo stretchy="false">[</mo><mi mathvariant="normal">Y</mi><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">=k[\mathrm{X}]^2[\mathrm{Y}]</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.0641em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="mopen">[</span><span class="mord mathrm">X</span><span class="mclose"><span class="mclose">]</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mopen">[</span><span class="mord mathrm" style="margin-right:0.025em;">Y</span><span class="mclose">]</span></span></span></span></p>
<p>Now, let's think about how the rate changes when <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">[</mo><mi mathvariant="normal">X</mi><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">[\mathrm{X}]</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">[</span><span class="mord mathrm">X</span><span class="mclose">]</span></span></span></span> is halved and <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">[</mo><mi mathvariant="normal">Y</mi><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">[\mathrm{Y}]</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">[</span><span class="mord mathrm" style="margin-right:0.025em;">Y</span><span class="mclose">]</span></span></span></span> is doubled. Since <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">[</mo><mi mathvariant="normal">X</mi><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">[\mathrm{X}]</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">[</span><span class="mord mathrm">X</span><span class="mclose">]</span></span></span></span> is raised to the second power in the rate law, halving <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">[</mo><mi mathvariant="normal">X</mi><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">[\mathrm{X}]</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">[</span><span class="mord mathrm">X</span><span class="mclose">]</span></span></span></span> decreases the reaction rate by a factor of 4 . Similarly, since <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">[</mo><mi mathvariant="normal">Y</mi><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">[\mathrm{Y}]</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">[</span><span class="mord mathrm" style="margin-right:0.025em;">Y</span><span class="mclose">]</span></span></span></span> is raised to the first power, doubling <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">[</mo><mi mathvariant="normal">Y</mi><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">[\mathrm{Y}]</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">[</span><span class="mord mathrm" style="margin-right:0.025em;">Y</span><span class="mclose">]</span></span></span></span> increases the reaction rate by a factor of 2 . Combined, these changes result in the reaction rate decreasing by a factor of 2 overall.
So, when <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">[</mo><mi mathvariant="normal">X</mi><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">[\mathrm{X}]</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">[</span><span class="mord mathrm">X</span><span class="mclose">]</span></span></span></span> is halved and <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">[</mo><mi mathvariant="normal">Y</mi><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">[\mathrm{Y}]</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">[</span><span class="mord mathrm" style="margin-right:0.025em;">Y</span><span class="mclose">]</span></span></span></span> is doubled, the rate of the reaction decreases by a factor of 2 .</p>
]]></description>
            <content:encoded><![CDATA[<h1 id="problem-03-02-3" tabindex="-1">Problem 03-02-3 <a class="header-anchor" href="#problem-03-02-3" aria-label="Permalink to &quot;Problem 03-02-3&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="question" tabindex="-1">Question <a class="header-anchor" href="#question" aria-label="Permalink to &quot;Question&quot;">&ZeroWidthSpace;</a></h2>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mn>2</mn><mi mathvariant="normal">X</mi><mo stretchy="false">(</mo><mi>g</mi><mo stretchy="false">)</mo><mo>+</mo><mn>2</mn><mi mathvariant="normal">Y</mi><mo stretchy="false">(</mo><mi>g</mi><mo stretchy="false">)</mo><mo>→</mo><mi mathvariant="normal">Q</mi><mo stretchy="false">(</mo><mi>g</mi><mo stretchy="false">)</mo><mo>+</mo><mn>2</mn><mi mathvariant="normal">R</mi><mo stretchy="false">(</mo><mi>g</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">2 \mathrm{X}(g)+2 \mathrm{Y}(g) \rightarrow \mathrm{Q}(g)+2 \mathrm{R}(g)
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">2</span><span class="mord mathrm">X</span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.03588em;">g</span><span class="mclose">)</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">2</span><span class="mord mathrm" style="margin-right:0.025em;">Y</span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.03588em;">g</span><span class="mclose">)</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">→</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathrm">Q</span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.03588em;">g</span><span class="mclose">)</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">2</span><span class="mord mathrm">R</span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.03588em;">g</span><span class="mclose">)</span></span></span></span></span></p>
<p>The reaction represented above is found to be second order with respect to <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">X</mi></mrow><annotation encoding="application/x-tex">\mathrm{X}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathrm">X</span></span></span></span> and first order with respect to <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Y</mi></mrow><annotation encoding="application/x-tex">\mathrm{Y}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathrm" style="margin-right:0.025em;">Y</span></span></span></span>.</p>
<p>What happens to the rate of the reaction when <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">[</mo><mi mathvariant="normal">X</mi><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">[\mathrm{X}]</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">[</span><span class="mord mathrm">X</span><span class="mclose">]</span></span></span></span> is halved and <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">[</mo><mi mathvariant="normal">Y</mi><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">[\mathrm{Y}]</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">[</span><span class="mord mathrm" style="margin-right:0.025em;">Y</span><span class="mclose">]</span></span></span></span> is doubled?</p>
<ul class="contains-task-list">
<li class="task-list-item"><input class="task-list-item-checkbox" disabled="" type="checkbox"> It increases by a factor of 4.</li>
<li class="task-list-item"><input class="task-list-item-checkbox" checked="" disabled="" type="checkbox"> It decreases by a factor of 2.</li>
<li class="task-list-item"><input class="task-list-item-checkbox" disabled="" type="checkbox"> It decreases by a factor of 4.</li>
<li class="task-list-item"><input class="task-list-item-checkbox" disabled="" type="checkbox"> It does not change.</li>
</ul>
<h2 id="solution" tabindex="-1">Solution <a class="header-anchor" href="#solution" aria-label="Permalink to &quot;Solution&quot;">&ZeroWidthSpace;</a></h2>
<p>To solve this problem, let's first write out the rate law for the reaction. According to the text, the reaction is second order with respect to <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">X</mi></mrow><annotation encoding="application/x-tex">\mathrm{X}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathrm">X</span></span></span></span> and first order with respect to <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Y</mi></mrow><annotation encoding="application/x-tex">\mathrm{Y}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathrm" style="margin-right:0.025em;">Y</span></span></span></span>, so the rate law is rate <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>=</mo><mi>k</mi><mo stretchy="false">[</mo><mi mathvariant="normal">X</mi><msup><mo stretchy="false">]</mo><mn>2</mn></msup><mo stretchy="false">[</mo><mi mathvariant="normal">Y</mi><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">=k[\mathrm{X}]^2[\mathrm{Y}]</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.0641em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="mopen">[</span><span class="mord mathrm">X</span><span class="mclose"><span class="mclose">]</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mopen">[</span><span class="mord mathrm" style="margin-right:0.025em;">Y</span><span class="mclose">]</span></span></span></span></p>
<p>Now, let's think about how the rate changes when <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">[</mo><mi mathvariant="normal">X</mi><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">[\mathrm{X}]</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">[</span><span class="mord mathrm">X</span><span class="mclose">]</span></span></span></span> is halved and <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">[</mo><mi mathvariant="normal">Y</mi><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">[\mathrm{Y}]</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">[</span><span class="mord mathrm" style="margin-right:0.025em;">Y</span><span class="mclose">]</span></span></span></span> is doubled. Since <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">[</mo><mi mathvariant="normal">X</mi><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">[\mathrm{X}]</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">[</span><span class="mord mathrm">X</span><span class="mclose">]</span></span></span></span> is raised to the second power in the rate law, halving <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">[</mo><mi mathvariant="normal">X</mi><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">[\mathrm{X}]</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">[</span><span class="mord mathrm">X</span><span class="mclose">]</span></span></span></span> decreases the reaction rate by a factor of 4 . Similarly, since <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">[</mo><mi mathvariant="normal">Y</mi><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">[\mathrm{Y}]</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">[</span><span class="mord mathrm" style="margin-right:0.025em;">Y</span><span class="mclose">]</span></span></span></span> is raised to the first power, doubling <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">[</mo><mi mathvariant="normal">Y</mi><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">[\mathrm{Y}]</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">[</span><span class="mord mathrm" style="margin-right:0.025em;">Y</span><span class="mclose">]</span></span></span></span> increases the reaction rate by a factor of 2 . Combined, these changes result in the reaction rate decreasing by a factor of 2 overall.
So, when <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">[</mo><mi mathvariant="normal">X</mi><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">[\mathrm{X}]</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">[</span><span class="mord mathrm">X</span><span class="mclose">]</span></span></span></span> is halved and <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">[</mo><mi mathvariant="normal">Y</mi><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">[\mathrm{Y}]</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">[</span><span class="mord mathrm" style="margin-right:0.025em;">Y</span><span class="mclose">]</span></span></span></span> is doubled, the rate of the reaction decreases by a factor of 2 .</p>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CIS105: Computer Applications &amp; Information Systems Lec. 1. ]]></title>
            <link>https://note.toshiki.devacademic/cis105/cis105-l1-lecture-note</link>
            <guid>https://note.toshiki.devacademic/cis105/cis105-l1-lecture-note</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="cis105-computer-applications-information-systems-lec-1" tabindex="-1">CIS105: Computer Applications &amp; Information Systems Lec. 1. <a class="header-anchor" href="#cis105-computer-applications-information-systems-lec-1" aria-label="Permalink to &quot;CIS105: Computer Applications &amp; Information Systems Lec. 1.&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="chapter-1-everything-changes" tabindex="-1">Chapter 1: Everything Changes <a class="header-anchor" href="#chapter-1-everything-changes" aria-label="Permalink to &quot;Chapter 1: Everything Changes&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="_1-1-the-historic-timelines" tabindex="-1">1.1: The Historic Timelines <a class="header-anchor" href="#_1-1-the-historic-timelines" aria-label="Permalink to &quot;1.1: The Historic Timelines&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>
<p>1903: Wright bros, invented the airplane.</p>
</li>
<li>
<p>1969: Armstrong walks on the moon.</p>
</li>
<li>
<p>2004: SpaceX Falcon 9 lands upright.</p>
</li>
<li>
<p>2015: Electreic plane crosses English Channel</p>
</li>
<li>
<p>20xx: Google Live goes online.</p>
</li>
<li>
<p>Boeing 777, commercial airline airplanes normally cost approximately <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">$</mi><mn>200</mn><mo separator="true">,</mo><mn>000</mn><mo separator="true">,</mo><mn>000</mn><mo separator="true">,</mo><mn>000</mn></mrow><annotation encoding="application/x-tex">\$ 200,000,000,000</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9444em;vertical-align:-0.1944em;"></span><span class="mord">$200</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord">000</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord">000</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord">000</span></span></span></span> for a singular aircraft.</p>
</li>
</ul>
<h3 id="_1-2-analytical-engne" tabindex="-1">1.2: Analytical Engne <a class="header-anchor" href="#_1-2-analytical-engne" aria-label="Permalink to &quot;1.2: Analytical Engne&quot;">&ZeroWidthSpace;</a></h3>
<p>A mechanical computing device, was a special-purpose machine designed to tabulate logarithms and trigonometric functions by evaluating finite differences to create approximating polynomials.</p>
<h3 id="_1-3-ada-lovelace" tabindex="-1">1.3: Ada Lovelace <a class="header-anchor" href="#_1-3-ada-lovelace" aria-label="Permalink to &quot;1.3: Ada Lovelace&quot;">&ZeroWidthSpace;</a></h3>
<p>It tok the powerful insights of a mathematicial named Ada Lovelace to realize the true potentilal of the analytical engine. She was the first person to recognize that the machine could be used for more than pure calculations. She developed the first algorithm for the engine. It was the very first example of <strong>computer programming</strong>.</p>
<h3 id="_1-4-information-technology-is-for-people" tabindex="-1">1.4: Information Technology is for People <a class="header-anchor" href="#_1-4-information-technology-is-for-people" aria-label="Permalink to &quot;1.4: Information Technology is for People&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li><strong>Information technology (IT)</strong>: the study, design, development, implementation, support, and management of computer-baed information systems, particularly software hardware.
<ul>
<li><strong>People are the most important component in an information system</strong> because <strong>it is only a human who can conceive information from data</strong>. Computer system is only a machinery device and human is expected to operate towards aspects on <strong>how to perform</strong>, <strong>what to perform</strong>, <strong>what to outcome</strong>.</li>
</ul>
</li>
<li><strong>End-users (people)</strong> are what make computers start.</li>
<li><strong>Attitude</strong> will be the defining factor in your success when it comes to computer competency.</li>
<li><strong>Best practice</strong>: a management process, technique, or method that is most effective at arriving at desired outcome or better outcome than any other process, technique, or method.
<ul>
<li><strong>The best and effective way of practice is through persistent and consistent training and reviewing.</strong></li>
</ul>
</li>
</ul>
<h3 id="_1-5-moore-s-law" tabindex="-1">1.5: Moore's Law <a class="header-anchor" href="#_1-5-moore-s-law" aria-label="Permalink to &quot;1.5: Moore's Law&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li><strong>Gordon Moore</strong>: One of the founding fathers of the Intel.</li>
<li><strong>Computer power doubles every eighteen months</strong>.
<ul>
<li>This essentially means that, if a business purchases a computer today, in eighteen months there will be a computer available that is twice as fast.</li>
</ul>
</li>
<li>Being a Leader vs. Follower controversy</li>
</ul>
<h3 id="_1-6-the-cuff-smartwatch" tabindex="-1">1.6: The Cuff Smartwatch? <a class="header-anchor" href="#_1-6-the-cuff-smartwatch" aria-label="Permalink to &quot;1.6: The Cuff Smartwatch?&quot;">&ZeroWidthSpace;</a></h3>
<p>US rapper/producer/entrepreneur Will.i.Am announced his foray into the world of wearable tech in 2014, proclaiming to have created a device so life-changing and futuristic it'd blow our archaic mind.</p>
<ul>
<li><a href="https://en.wikipedia.org/wiki/Smartwatch" target="_blank" rel="noreferrer">Wikipedia smartwatch reference</a></li>
</ul>
<h3 id="_1-7-types-of-computer" tabindex="-1">1.7: Types of Computer <a class="header-anchor" href="#_1-7-types-of-computer" aria-label="Permalink to &quot;1.7: Types of Computer&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li><strong>Mainframe</strong>: Banks, Tech Companies</li>
<li><strong>Midrange</strong>: Small to Mid-sized business, not as powerful.</li>
<li><strong>Microcomputer</strong>: Laptops, <strong>Desktops</strong>, <strong>Tablet</strong> &amp; Handled.</li>
</ul>
<h3 id="_1-8-what-is-system-software" tabindex="-1">1.8: What is System Software? <a class="header-anchor" href="#_1-8-what-is-system-software" aria-label="Permalink to &quot;1.8: What is System Software?&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>
<p>System software vs. Operating system</p>
</li>
<li>
<p>System software vs. Application software</p>
</li>
<li>
<p>Operating system: Manages resources. Responsible for reading and writing data.</p>
</li>
<li>
<p>Graphical User Interface (GUI) &amp; Command line interface.</p>
<ul>
<li>
<p>The level of an operational system layers by interface visibility.</p>
<ul>
<li>
<div class="language-mermaid vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">mermaid</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">graph</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">LR</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #F69D50">a</span><span style="color: #F47067">[</span><span style="color: #96D0FF">GUI</span><span style="color: #F47067">]</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">--&gt;</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50">b</span><span style="color: #F47067">[</span><span style="color: #96D0FF">Application software</span><span style="color: #F47067">]</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #F69D50">b </span><span style="color: #F47067">--&gt;</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50">c</span><span style="color: #F47067">[</span><span style="color: #96D0FF">Operating system</span><span style="color: #F47067">]</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #F69D50">c </span><span style="color: #F47067">--&gt;</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50">d</span><span style="color: #F47067">[</span><span style="color: #96D0FF">System software</span><span style="color: #F47067">]</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #F69D50">d </span><span style="color: #F47067">--&gt;</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50">e</span><span style="color: #F47067">[</span><span style="color: #96D0FF">CLI</span><span style="color: #F47067">]</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">graph</span><span style="color: #24292E"> </span><span style="color: #6F42C1">LR</span><span style="color: #24292E">;</span></span>
<span class="line"><span style="color: #E36209">a</span><span style="color: #D73A49">[</span><span style="color: #032F62">GUI</span><span style="color: #D73A49">]</span><span style="color: #24292E"> </span><span style="color: #D73A49">--&gt;</span><span style="color: #24292E"> </span><span style="color: #E36209">b</span><span style="color: #D73A49">[</span><span style="color: #032F62">Application software</span><span style="color: #D73A49">]</span><span style="color: #24292E">;</span></span>
<span class="line"><span style="color: #E36209">b </span><span style="color: #D73A49">--&gt;</span><span style="color: #24292E"> </span><span style="color: #E36209">c</span><span style="color: #D73A49">[</span><span style="color: #032F62">Operating system</span><span style="color: #D73A49">]</span><span style="color: #24292E">;</span></span>
<span class="line"><span style="color: #E36209">c </span><span style="color: #D73A49">--&gt;</span><span style="color: #24292E"> </span><span style="color: #E36209">d</span><span style="color: #D73A49">[</span><span style="color: #032F62">System software</span><span style="color: #D73A49">]</span><span style="color: #24292E">;</span></span>
<span class="line"><span style="color: #E36209">d </span><span style="color: #D73A49">--&gt;</span><span style="color: #24292E"> </span><span style="color: #E36209">e</span><span style="color: #D73A49">[</span><span style="color: #032F62">CLI</span><span style="color: #D73A49">]</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br></div></div></li>
</ul>
</li>
</ul>
</li>
</ul>
<h3 id="_1-9-operating-systems-platforms" tabindex="-1">1.9: Operating Systems/Platforms <a class="header-anchor" href="#_1-9-operating-systems-platforms" aria-label="Permalink to &quot;1.9: Operating Systems/Platforms&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li><strong>A collection of computer programs that work together to manage hardware and software to ensure that they are working properly.</strong>
<ul>
<li>Memory allocation</li>
<li>Administer input and output of information</li>
<li>File management</li>
</ul>
</li>
<li><strong>Platform (OS)</strong>: Microsoft Windows, macOS, iOS, Linux, UNIX.</li>
</ul>
<h3 id="_2-0-processes-multitasking" tabindex="-1">2.0: Processes/Multitasking <a class="header-anchor" href="#_2-0-processes-multitasking" aria-label="Permalink to &quot;2.0: Processes/Multitasking&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li><strong>Process</strong>: Any task a computer performs.</li>
<li><strong>Multitasking</strong>: the execution of multiple processes over a certain period of time.</li>
</ul>
<h3 id="_2-1-memory-disk-management" tabindex="-1">2.1: Memory/Disk management <a class="header-anchor" href="#_2-1-memory-disk-management" aria-label="Permalink to &quot;2.1: Memory/Disk management&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>
<p><strong>Operating systems</strong>: Cache, random access memory (ram), registers, virtual memory.</p>
</li>
<li>
<p><strong>Primary storage vs. Secondary Storage</strong>: RAM, hard drive, file allocation table (FAT).</p>
<ul>
<li>The table of contents of a hard drive, or the file system directory structure of a system.</li>
</ul>
<blockquote>
<ul>
<li>
<p>Primary storage is accessed randomly which indicating the storage is only temporary without preserved.</p>
</li>
<li>
<p>Secondary storage is the permanent storage on a specific device while user information is stored on the machine within the physical drive storage.</p>
</li>
</ul>
</blockquote>
</li>
</ul>
<h3 id="_2-2-business-computing-software" tabindex="-1">2.2: Business Computing Software <a class="header-anchor" href="#_2-2-business-computing-software" aria-label="Permalink to &quot;2.2: Business Computing Software&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>
<p>Software suite: Spreadsheets, word processors, database, and presentation software (aka application suite or productivity suite).</p>
<ul>
<li>Sharing information between these applications is te mot important aspect of a software suite.</li>
</ul>
</li>
<li>
<p>Hot keys/shortcuts: <kbd>Ctrl</kbd>+ <kbd>C</kbd> &amp; <kbd>Ctrl</kbd> + <kbd>V</kbd> on Windows; <kbd>Command</kbd>+ <kbd>C</kbd> &amp; <kbd>Command</kbd> + <kbd>V</kbd> on Windows.</p>
</li>
<li>
<p><strong>Object linking and embedding (OLE) (Static)</strong></p>
<ul>
<li>
<p><strong>In static linking, the system linker copies the dependencies into the final executable.</strong> At the time of linking an external library, the linker finds all dependencies that are defined in that library. And it replaces them with the corresponding functions from the library to resolve dependencies in our code. Afterward, the linker generates the final executable file that we can execute on the underlying machine.</p>
<p>For example, let’s say our application calls the function <em>print()</em> from an external library named <em>Library.</em> The assembler generates the object file with all native symbols resolved to their memory addresses. The external reference <em>print()</em> cannot be resolved. The linker loads this library and finds the definition of <em>print()</em> in it. Then, it maps to <em>print()</em> to a memory location and thus resolves the dependency:</p>
<p><img src="https://www.baeldung.com/wp-content/uploads/sites/4/2022/10/Static-Linking.jpg" alt="Static Linking"></p>
<p><strong>So, a statically linked file contains our program’s code as well as the code of all the libraries it invokes</strong>. Since we copy complete libraries, we need space on both the disk and in the main memory because the resulting file may be very large.</p>
</li>
</ul>
</li>
<li>
<p><strong>Object linking (Dynamic)</strong></p>
<ul>
<li><strong>In dynamic linking, we copy the names of the external libraries into our final executable as unresolved symbols. We do the actual linking of these unresolved symbols only at runtime.</strong> How? When encountering an unresolved symbol, we query RAM for it. If the corresponding library isn’t loaded, the operating system loads it in the memory. So, <strong>the operating system performs dynamic linking for us by resolving each external symbol on the first muss.</strong> As a result, we load only a single copy of a library in memory and all processes use it.</li>
</ul>
</li>
</ul>
]]></description>
            <content:encoded><![CDATA[<h1 id="cis105-computer-applications-information-systems-lec-1" tabindex="-1">CIS105: Computer Applications &amp; Information Systems Lec. 1. <a class="header-anchor" href="#cis105-computer-applications-information-systems-lec-1" aria-label="Permalink to &quot;CIS105: Computer Applications &amp; Information Systems Lec. 1.&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="chapter-1-everything-changes" tabindex="-1">Chapter 1: Everything Changes <a class="header-anchor" href="#chapter-1-everything-changes" aria-label="Permalink to &quot;Chapter 1: Everything Changes&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="_1-1-the-historic-timelines" tabindex="-1">1.1: The Historic Timelines <a class="header-anchor" href="#_1-1-the-historic-timelines" aria-label="Permalink to &quot;1.1: The Historic Timelines&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>
<p>1903: Wright bros, invented the airplane.</p>
</li>
<li>
<p>1969: Armstrong walks on the moon.</p>
</li>
<li>
<p>2004: SpaceX Falcon 9 lands upright.</p>
</li>
<li>
<p>2015: Electreic plane crosses English Channel</p>
</li>
<li>
<p>20xx: Google Live goes online.</p>
</li>
<li>
<p>Boeing 777, commercial airline airplanes normally cost approximately <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">$</mi><mn>200</mn><mo separator="true">,</mo><mn>000</mn><mo separator="true">,</mo><mn>000</mn><mo separator="true">,</mo><mn>000</mn></mrow><annotation encoding="application/x-tex">\$ 200,000,000,000</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9444em;vertical-align:-0.1944em;"></span><span class="mord">$200</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord">000</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord">000</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord">000</span></span></span></span> for a singular aircraft.</p>
</li>
</ul>
<h3 id="_1-2-analytical-engne" tabindex="-1">1.2: Analytical Engne <a class="header-anchor" href="#_1-2-analytical-engne" aria-label="Permalink to &quot;1.2: Analytical Engne&quot;">&ZeroWidthSpace;</a></h3>
<p>A mechanical computing device, was a special-purpose machine designed to tabulate logarithms and trigonometric functions by evaluating finite differences to create approximating polynomials.</p>
<h3 id="_1-3-ada-lovelace" tabindex="-1">1.3: Ada Lovelace <a class="header-anchor" href="#_1-3-ada-lovelace" aria-label="Permalink to &quot;1.3: Ada Lovelace&quot;">&ZeroWidthSpace;</a></h3>
<p>It tok the powerful insights of a mathematicial named Ada Lovelace to realize the true potentilal of the analytical engine. She was the first person to recognize that the machine could be used for more than pure calculations. She developed the first algorithm for the engine. It was the very first example of <strong>computer programming</strong>.</p>
<h3 id="_1-4-information-technology-is-for-people" tabindex="-1">1.4: Information Technology is for People <a class="header-anchor" href="#_1-4-information-technology-is-for-people" aria-label="Permalink to &quot;1.4: Information Technology is for People&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li><strong>Information technology (IT)</strong>: the study, design, development, implementation, support, and management of computer-baed information systems, particularly software hardware.
<ul>
<li><strong>People are the most important component in an information system</strong> because <strong>it is only a human who can conceive information from data</strong>. Computer system is only a machinery device and human is expected to operate towards aspects on <strong>how to perform</strong>, <strong>what to perform</strong>, <strong>what to outcome</strong>.</li>
</ul>
</li>
<li><strong>End-users (people)</strong> are what make computers start.</li>
<li><strong>Attitude</strong> will be the defining factor in your success when it comes to computer competency.</li>
<li><strong>Best practice</strong>: a management process, technique, or method that is most effective at arriving at desired outcome or better outcome than any other process, technique, or method.
<ul>
<li><strong>The best and effective way of practice is through persistent and consistent training and reviewing.</strong></li>
</ul>
</li>
</ul>
<h3 id="_1-5-moore-s-law" tabindex="-1">1.5: Moore's Law <a class="header-anchor" href="#_1-5-moore-s-law" aria-label="Permalink to &quot;1.5: Moore's Law&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li><strong>Gordon Moore</strong>: One of the founding fathers of the Intel.</li>
<li><strong>Computer power doubles every eighteen months</strong>.
<ul>
<li>This essentially means that, if a business purchases a computer today, in eighteen months there will be a computer available that is twice as fast.</li>
</ul>
</li>
<li>Being a Leader vs. Follower controversy</li>
</ul>
<h3 id="_1-6-the-cuff-smartwatch" tabindex="-1">1.6: The Cuff Smartwatch? <a class="header-anchor" href="#_1-6-the-cuff-smartwatch" aria-label="Permalink to &quot;1.6: The Cuff Smartwatch?&quot;">&ZeroWidthSpace;</a></h3>
<p>US rapper/producer/entrepreneur Will.i.Am announced his foray into the world of wearable tech in 2014, proclaiming to have created a device so life-changing and futuristic it'd blow our archaic mind.</p>
<ul>
<li><a href="https://en.wikipedia.org/wiki/Smartwatch" target="_blank" rel="noreferrer">Wikipedia smartwatch reference</a></li>
</ul>
<h3 id="_1-7-types-of-computer" tabindex="-1">1.7: Types of Computer <a class="header-anchor" href="#_1-7-types-of-computer" aria-label="Permalink to &quot;1.7: Types of Computer&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li><strong>Mainframe</strong>: Banks, Tech Companies</li>
<li><strong>Midrange</strong>: Small to Mid-sized business, not as powerful.</li>
<li><strong>Microcomputer</strong>: Laptops, <strong>Desktops</strong>, <strong>Tablet</strong> &amp; Handled.</li>
</ul>
<h3 id="_1-8-what-is-system-software" tabindex="-1">1.8: What is System Software? <a class="header-anchor" href="#_1-8-what-is-system-software" aria-label="Permalink to &quot;1.8: What is System Software?&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>
<p>System software vs. Operating system</p>
</li>
<li>
<p>System software vs. Application software</p>
</li>
<li>
<p>Operating system: Manages resources. Responsible for reading and writing data.</p>
</li>
<li>
<p>Graphical User Interface (GUI) &amp; Command line interface.</p>
<ul>
<li>
<p>The level of an operational system layers by interface visibility.</p>
<ul>
<li>
<div class="language-mermaid vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">mermaid</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">graph</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">LR</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #F69D50">a</span><span style="color: #F47067">[</span><span style="color: #96D0FF">GUI</span><span style="color: #F47067">]</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">--&gt;</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50">b</span><span style="color: #F47067">[</span><span style="color: #96D0FF">Application software</span><span style="color: #F47067">]</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #F69D50">b </span><span style="color: #F47067">--&gt;</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50">c</span><span style="color: #F47067">[</span><span style="color: #96D0FF">Operating system</span><span style="color: #F47067">]</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #F69D50">c </span><span style="color: #F47067">--&gt;</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50">d</span><span style="color: #F47067">[</span><span style="color: #96D0FF">System software</span><span style="color: #F47067">]</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #F69D50">d </span><span style="color: #F47067">--&gt;</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50">e</span><span style="color: #F47067">[</span><span style="color: #96D0FF">CLI</span><span style="color: #F47067">]</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">graph</span><span style="color: #24292E"> </span><span style="color: #6F42C1">LR</span><span style="color: #24292E">;</span></span>
<span class="line"><span style="color: #E36209">a</span><span style="color: #D73A49">[</span><span style="color: #032F62">GUI</span><span style="color: #D73A49">]</span><span style="color: #24292E"> </span><span style="color: #D73A49">--&gt;</span><span style="color: #24292E"> </span><span style="color: #E36209">b</span><span style="color: #D73A49">[</span><span style="color: #032F62">Application software</span><span style="color: #D73A49">]</span><span style="color: #24292E">;</span></span>
<span class="line"><span style="color: #E36209">b </span><span style="color: #D73A49">--&gt;</span><span style="color: #24292E"> </span><span style="color: #E36209">c</span><span style="color: #D73A49">[</span><span style="color: #032F62">Operating system</span><span style="color: #D73A49">]</span><span style="color: #24292E">;</span></span>
<span class="line"><span style="color: #E36209">c </span><span style="color: #D73A49">--&gt;</span><span style="color: #24292E"> </span><span style="color: #E36209">d</span><span style="color: #D73A49">[</span><span style="color: #032F62">System software</span><span style="color: #D73A49">]</span><span style="color: #24292E">;</span></span>
<span class="line"><span style="color: #E36209">d </span><span style="color: #D73A49">--&gt;</span><span style="color: #24292E"> </span><span style="color: #E36209">e</span><span style="color: #D73A49">[</span><span style="color: #032F62">CLI</span><span style="color: #D73A49">]</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br></div></div></li>
</ul>
</li>
</ul>
</li>
</ul>
<h3 id="_1-9-operating-systems-platforms" tabindex="-1">1.9: Operating Systems/Platforms <a class="header-anchor" href="#_1-9-operating-systems-platforms" aria-label="Permalink to &quot;1.9: Operating Systems/Platforms&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li><strong>A collection of computer programs that work together to manage hardware and software to ensure that they are working properly.</strong>
<ul>
<li>Memory allocation</li>
<li>Administer input and output of information</li>
<li>File management</li>
</ul>
</li>
<li><strong>Platform (OS)</strong>: Microsoft Windows, macOS, iOS, Linux, UNIX.</li>
</ul>
<h3 id="_2-0-processes-multitasking" tabindex="-1">2.0: Processes/Multitasking <a class="header-anchor" href="#_2-0-processes-multitasking" aria-label="Permalink to &quot;2.0: Processes/Multitasking&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li><strong>Process</strong>: Any task a computer performs.</li>
<li><strong>Multitasking</strong>: the execution of multiple processes over a certain period of time.</li>
</ul>
<h3 id="_2-1-memory-disk-management" tabindex="-1">2.1: Memory/Disk management <a class="header-anchor" href="#_2-1-memory-disk-management" aria-label="Permalink to &quot;2.1: Memory/Disk management&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>
<p><strong>Operating systems</strong>: Cache, random access memory (ram), registers, virtual memory.</p>
</li>
<li>
<p><strong>Primary storage vs. Secondary Storage</strong>: RAM, hard drive, file allocation table (FAT).</p>
<ul>
<li>The table of contents of a hard drive, or the file system directory structure of a system.</li>
</ul>
<blockquote>
<ul>
<li>
<p>Primary storage is accessed randomly which indicating the storage is only temporary without preserved.</p>
</li>
<li>
<p>Secondary storage is the permanent storage on a specific device while user information is stored on the machine within the physical drive storage.</p>
</li>
</ul>
</blockquote>
</li>
</ul>
<h3 id="_2-2-business-computing-software" tabindex="-1">2.2: Business Computing Software <a class="header-anchor" href="#_2-2-business-computing-software" aria-label="Permalink to &quot;2.2: Business Computing Software&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>
<p>Software suite: Spreadsheets, word processors, database, and presentation software (aka application suite or productivity suite).</p>
<ul>
<li>Sharing information between these applications is te mot important aspect of a software suite.</li>
</ul>
</li>
<li>
<p>Hot keys/shortcuts: <kbd>Ctrl</kbd>+ <kbd>C</kbd> &amp; <kbd>Ctrl</kbd> + <kbd>V</kbd> on Windows; <kbd>Command</kbd>+ <kbd>C</kbd> &amp; <kbd>Command</kbd> + <kbd>V</kbd> on Windows.</p>
</li>
<li>
<p><strong>Object linking and embedding (OLE) (Static)</strong></p>
<ul>
<li>
<p><strong>In static linking, the system linker copies the dependencies into the final executable.</strong> At the time of linking an external library, the linker finds all dependencies that are defined in that library. And it replaces them with the corresponding functions from the library to resolve dependencies in our code. Afterward, the linker generates the final executable file that we can execute on the underlying machine.</p>
<p>For example, let’s say our application calls the function <em>print()</em> from an external library named <em>Library.</em> The assembler generates the object file with all native symbols resolved to their memory addresses. The external reference <em>print()</em> cannot be resolved. The linker loads this library and finds the definition of <em>print()</em> in it. Then, it maps to <em>print()</em> to a memory location and thus resolves the dependency:</p>
<p><img src="https://www.baeldung.com/wp-content/uploads/sites/4/2022/10/Static-Linking.jpg" alt="Static Linking"></p>
<p><strong>So, a statically linked file contains our program’s code as well as the code of all the libraries it invokes</strong>. Since we copy complete libraries, we need space on both the disk and in the main memory because the resulting file may be very large.</p>
</li>
</ul>
</li>
<li>
<p><strong>Object linking (Dynamic)</strong></p>
<ul>
<li><strong>In dynamic linking, we copy the names of the external libraries into our final executable as unresolved symbols. We do the actual linking of these unresolved symbols only at runtime.</strong> How? When encountering an unresolved symbol, we query RAM for it. If the corresponding library isn’t loaded, the operating system loads it in the memory. So, <strong>the operating system performs dynamic linking for us by resolving each external symbol on the first muss.</strong> As a result, we load only a single copy of a library in memory and all processes use it.</li>
</ul>
</li>
</ul>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CIS105: Computer Applications &amp; Information Systems Lect. 2 ]]></title>
            <link>https://note.toshiki.devacademic/cis105/cis105-l2-lecture-note</link>
            <guid>https://note.toshiki.devacademic/cis105/cis105-l2-lecture-note</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="cis105-computer-applications-information-systems-lect-2" tabindex="-1">CIS105: Computer Applications &amp; Information Systems Lect. 2 <a class="header-anchor" href="#cis105-computer-applications-information-systems-lect-2" aria-label="Permalink to &quot;CIS105: Computer Applications &amp; Information Systems Lect. 2&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="chapter-2-application-software" tabindex="-1">Chapter 2: Application Software <a class="header-anchor" href="#chapter-2-application-software" aria-label="Permalink to &quot;Chapter 2: Application Software&quot;">&ZeroWidthSpace;</a></h2>
<ul>
<li>An application program is a computer program designed to carry out a specific task other than one relating to the operation of the computer itself.</li>
</ul>
<h3 id="_2-1-word-processing-software" tabindex="-1">2.1: Word Processing Software <a class="header-anchor" href="#_2-1-word-processing-software" aria-label="Permalink to &quot;2.1: Word Processing Software&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>For creating, updating and editing documents</li>
<li>Can create a Table of Contents</li>
<li>Saved to secondary memory</li>
<li>Often underestimated</li>
<li><strong>Microsoft Word</strong>: Most popular word processor in the world</li>
<li><strong>Adobe Acrobat</strong>: Most portable document format (pdf)
<ul>
<li>Platform Neutral</li>
</ul>
</li>
<li>Corel WordPerfect: most dominant in early 80s (still used in some industries like law)
<ul>
<li>Created and Brigham Young university</li>
</ul>
</li>
</ul>
<h3 id="_2-2-spreadsheets" tabindex="-1">2.2: Spreadsheets <a class="header-anchor" href="#_2-2-spreadsheets" aria-label="Permalink to &quot;2.2: Spreadsheets&quot;">&ZeroWidthSpace;</a></h3>
<p><strong>Microsoft Excel</strong>: Most popular spreadsheet application (provides <strong>&quot;what-if&quot;</strong> analysis)</p>
<ul>
<li>Interface of information in a grid form</li>
<li>Separated by <strong>columns</strong> and <strong>rows</strong>
<ul>
<li>Intersection of both called a cell</li>
</ul>
</li>
<li>Often for financial calculations</li>
<li>Supports graphing</li>
<li>Replaced Lotus 1-2-3 as industry standard in 1993</li>
</ul>
<h3 id="_2-3-database-software" tabindex="-1">2.3: Database Software <a class="header-anchor" href="#_2-3-database-software" aria-label="Permalink to &quot;2.3: Database Software&quot;">&ZeroWidthSpace;</a></h3>
<p>Database: <strong>The heavy-lifting application</strong></p>
<ul>
<li>Well thought out collection of files</li>
<li>Consists of <strong>records</strong> (<strong>rows</strong>)</li>
<li>Separated by <strong>fields</strong> (<strong>columns</strong>)</li>
<li>Can be queried</li>
<li>Often called a Database Management System or simply referred as <strong>DBMS</strong></li>
<li>One-to-many relationship</li>
</ul>
<h3 id="_2-4-presentation-software" tabindex="-1">2.4: Presentation Software <a class="header-anchor" href="#_2-4-presentation-software" aria-label="Permalink to &quot;2.4: Presentation Software&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>Displays information</li>
<li>Often a slide show and on-screen</li>
<li>Easy to build</li>
<li>Popularized by Business Intelligence</li>
<li>Allows users to:
<ul>
<li>Edit, update, insert, and delete text</li>
<li>Include graphics, video, and hypertext</li>
</ul>
</li>
</ul>
<h3 id="_2-5-browser-software" tabindex="-1">2.5: Browser Software <a class="header-anchor" href="#_2-5-browser-software" aria-label="Permalink to &quot;2.5: Browser Software&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>User interface <strong>software</strong> that allows the user to display web pages found on the World Wide Web</li>
<li>Browsers display <strong>hyperlinks</strong> that are clickable navigation elements</li>
<li>Microsoft Edge, Google Chroe, Mozilla Firefox, and Apple's Safari</li>
<li>The first browser was called <strong>WorldWideWeb</strong> (no spaces)</li>
<li><strong>Sir Tim Berners-Lee</strong> was the inventor of the first web browser</li>
</ul>
<h3 id="_2-6-networks" tabindex="-1">2.6: Networks <a class="header-anchor" href="#_2-6-networks" aria-label="Permalink to &quot;2.6: Networks&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>A computer network is <strong>two or more computers connected together</strong> for resource sharing and communication.</li>
<li>Resources: Computer files, folder, software</li>
<li><strong>Peripheral hardware</strong>: Printers, scanners, webcam, etc.</li>
</ul>
<p>The advantages of a computer network over a stand-alone computer are so significant that business cannot compete effectively in the marketplace without a network of some kind, even if the business is a sole proprietorship.</p>
]]></description>
            <content:encoded><![CDATA[<h1 id="cis105-computer-applications-information-systems-lect-2" tabindex="-1">CIS105: Computer Applications &amp; Information Systems Lect. 2 <a class="header-anchor" href="#cis105-computer-applications-information-systems-lect-2" aria-label="Permalink to &quot;CIS105: Computer Applications &amp; Information Systems Lect. 2&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="chapter-2-application-software" tabindex="-1">Chapter 2: Application Software <a class="header-anchor" href="#chapter-2-application-software" aria-label="Permalink to &quot;Chapter 2: Application Software&quot;">&ZeroWidthSpace;</a></h2>
<ul>
<li>An application program is a computer program designed to carry out a specific task other than one relating to the operation of the computer itself.</li>
</ul>
<h3 id="_2-1-word-processing-software" tabindex="-1">2.1: Word Processing Software <a class="header-anchor" href="#_2-1-word-processing-software" aria-label="Permalink to &quot;2.1: Word Processing Software&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>For creating, updating and editing documents</li>
<li>Can create a Table of Contents</li>
<li>Saved to secondary memory</li>
<li>Often underestimated</li>
<li><strong>Microsoft Word</strong>: Most popular word processor in the world</li>
<li><strong>Adobe Acrobat</strong>: Most portable document format (pdf)
<ul>
<li>Platform Neutral</li>
</ul>
</li>
<li>Corel WordPerfect: most dominant in early 80s (still used in some industries like law)
<ul>
<li>Created and Brigham Young university</li>
</ul>
</li>
</ul>
<h3 id="_2-2-spreadsheets" tabindex="-1">2.2: Spreadsheets <a class="header-anchor" href="#_2-2-spreadsheets" aria-label="Permalink to &quot;2.2: Spreadsheets&quot;">&ZeroWidthSpace;</a></h3>
<p><strong>Microsoft Excel</strong>: Most popular spreadsheet application (provides <strong>&quot;what-if&quot;</strong> analysis)</p>
<ul>
<li>Interface of information in a grid form</li>
<li>Separated by <strong>columns</strong> and <strong>rows</strong>
<ul>
<li>Intersection of both called a cell</li>
</ul>
</li>
<li>Often for financial calculations</li>
<li>Supports graphing</li>
<li>Replaced Lotus 1-2-3 as industry standard in 1993</li>
</ul>
<h3 id="_2-3-database-software" tabindex="-1">2.3: Database Software <a class="header-anchor" href="#_2-3-database-software" aria-label="Permalink to &quot;2.3: Database Software&quot;">&ZeroWidthSpace;</a></h3>
<p>Database: <strong>The heavy-lifting application</strong></p>
<ul>
<li>Well thought out collection of files</li>
<li>Consists of <strong>records</strong> (<strong>rows</strong>)</li>
<li>Separated by <strong>fields</strong> (<strong>columns</strong>)</li>
<li>Can be queried</li>
<li>Often called a Database Management System or simply referred as <strong>DBMS</strong></li>
<li>One-to-many relationship</li>
</ul>
<h3 id="_2-4-presentation-software" tabindex="-1">2.4: Presentation Software <a class="header-anchor" href="#_2-4-presentation-software" aria-label="Permalink to &quot;2.4: Presentation Software&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>Displays information</li>
<li>Often a slide show and on-screen</li>
<li>Easy to build</li>
<li>Popularized by Business Intelligence</li>
<li>Allows users to:
<ul>
<li>Edit, update, insert, and delete text</li>
<li>Include graphics, video, and hypertext</li>
</ul>
</li>
</ul>
<h3 id="_2-5-browser-software" tabindex="-1">2.5: Browser Software <a class="header-anchor" href="#_2-5-browser-software" aria-label="Permalink to &quot;2.5: Browser Software&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>User interface <strong>software</strong> that allows the user to display web pages found on the World Wide Web</li>
<li>Browsers display <strong>hyperlinks</strong> that are clickable navigation elements</li>
<li>Microsoft Edge, Google Chroe, Mozilla Firefox, and Apple's Safari</li>
<li>The first browser was called <strong>WorldWideWeb</strong> (no spaces)</li>
<li><strong>Sir Tim Berners-Lee</strong> was the inventor of the first web browser</li>
</ul>
<h3 id="_2-6-networks" tabindex="-1">2.6: Networks <a class="header-anchor" href="#_2-6-networks" aria-label="Permalink to &quot;2.6: Networks&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>A computer network is <strong>two or more computers connected together</strong> for resource sharing and communication.</li>
<li>Resources: Computer files, folder, software</li>
<li><strong>Peripheral hardware</strong>: Printers, scanners, webcam, etc.</li>
</ul>
<p>The advantages of a computer network over a stand-alone computer are so significant that business cannot compete effectively in the marketplace without a network of some kind, even if the business is a sole proprietorship.</p>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CIS105: Computer Applications &amp; Information Systems Lect. 3 ]]></title>
            <link>https://note.toshiki.devacademic/cis105/cis105-l3-lecture-note</link>
            <guid>https://note.toshiki.devacademic/cis105/cis105-l3-lecture-note</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="cis105-computer-applications-information-systems-lect-3" tabindex="-1">CIS105: Computer Applications &amp; Information Systems Lect. 3 <a class="header-anchor" href="#cis105-computer-applications-information-systems-lect-3" aria-label="Permalink to &quot;CIS105: Computer Applications &amp; Information Systems Lect. 3&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="chapter-3-computer-hardware" tabindex="-1">Chapter 3: Computer Hardware <a class="header-anchor" href="#chapter-3-computer-hardware" aria-label="Permalink to &quot;Chapter 3: Computer Hardware&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="_3-1-technical-terminologies" tabindex="-1">3.1: Technical Terminologies <a class="header-anchor" href="#_3-1-technical-terminologies" aria-label="Permalink to &quot;3.1: Technical Terminologies&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li><strong>System Unit</strong>: Main body of the computer that contains a motherboard.</li>
<li><strong>Motherboard</strong> (AKA Circuit Board): Main component of a system unit; a compleex array of electronics that connect and help different components of the computer communicate with each other.
<ul>
<li>PC: Motherboards, Mac; Logic Boards</li>
</ul>
</li>
<li><strong>Chassis</strong> (AKA Case or Box): Case to enclose the main components of a computer</li>
<li><strong>Microprocessor</strong>: The brains of the computer
<ul>
<li><strong>Central processing unit (CPU)</strong>: Interprets program instructions and processes data by performing arithmetic and logical operations.</li>
</ul>
</li>
</ul>
<h3 id="_3-2-central-processing-unit-cpu" tabindex="-1">3.2: Central Processing Unit (CPU) <a class="header-anchor" href="#_3-2-central-processing-unit-cpu" aria-label="Permalink to &quot;3.2: Central Processing Unit (CPU)&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>Speed is directly, but not solely, related to the CPU</li>
<li>Measured in Clock Rate
<ul>
<li>The number of cycles per second, that a computer can perform its most basic task</li>
</ul>
</li>
<li>RSIC (Reduced Instruction Set Computer): Many chips encased into one chip</li>
<li>Bus Lines; Pathways that transfer data and power between components inside of a computer.</li>
</ul>
<table>
<thead>
<tr>
<th>Architecture Diagram of CPU</th>
<th>Actual CPU Image</th>
</tr>
</thead>
<tbody>
<tr>
<td><img src="https://computersciencewiki.org/images/1/1a/Cpu_diagram.png" alt="Architecture of the central processing unit (CPU) - Computer ..."></td>
<td><img src="https://i.insider.com/60402d8eb46d720018b04c1f?width=700" alt="What Is a CPU? a Guide to Your Computer's 'Brain'"></td>
</tr>
</tbody>
</table>
<h3 id="_3-3-power-supply-unit-psu" tabindex="-1">3.3 Power Supply Unit (PSU) <a class="header-anchor" href="#_3-3-power-supply-unit-psu" aria-label="Permalink to &quot;3.3 Power Supply Unit (PSU)&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>Supplies electricity</li>
<li>Converts 100-120 volts or 220-240 volts of <strong>alternating current (AC)</strong> to a lower voltage direct current (DC) that can be used by the internal components of the system unit</li>
<li>Different currents used in different parts of the world.</li>
</ul>
<h3 id="_3-4-primary-and-secondary-storage" tabindex="-1">3.4: Primary and Secondary Storage <a class="header-anchor" href="#_3-4-primary-and-secondary-storage" aria-label="Permalink to &quot;3.4: Primary and Secondary Storage&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li><strong>Primary</strong>: The workbench
<ul>
<li>Random Access Memory (RAM): Primary storage</li>
</ul>
</li>
<li><strong>Secondary</strong>: The storage for all your tools and supplies
<ul>
<li>Hard Drive: Secondary storage</li>
</ul>
</li>
<li>ROM Chips (Read-Only Memory): Preprogrammed chips that serve specialized internal tasks. No human intervention
<ul>
<li>AKA Firmware</li>
</ul>
</li>
</ul>
<h4 id="_3-4-1-secondary-storage-contd" tabindex="-1">3.4.1: Secondary Storage Contd. <a class="header-anchor" href="#_3-4-1-secondary-storage-contd" aria-label="Permalink to &quot;3.4.1: Secondary Storage Contd.&quot;">&ZeroWidthSpace;</a></h4>
<ul>
<li>Internal vs. External Storage</li>
<li>Hard Drivers vs. Solid State Drivers (SSDs)</li>
<li>Impractical for a computer to be stand-alone</li>
<li>Important to consider business needs
<ul>
<li>Bad IT can make or break a business</li>
</ul>
</li>
</ul>
<h3 id="_3-5-binary-number-system" tabindex="-1">3.5: Binary Number System <a class="header-anchor" href="#_3-5-binary-number-system" aria-label="Permalink to &quot;3.5: Binary Number System&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>
<p>Computer only understands one language: Machine code or machine language</p>
</li>
<li>
<p>1 or 0 (on or off)</p>
</li>
<li>
<p>1s or 0s are referred to as bits (short for binary digits)</p>
</li>
<li>
<p>8 bits become a byte</p>
<ul>
<li>Byte 8 bits</li>
<li>Kilob</li>
</ul>
</li>
<li>
<p>American Standard Code for Information Interchange (ASCII): The coding scheme that most microcomputer use to represent bytes.</p>
<ul>
<li>
<table>
<thead>
<tr>
<th>Name</th>
<th>Equal To</th>
<th>Size (In Bytes)</th>
</tr>
</thead>
<tbody>
<tr>
<td>Bit</td>
<td>1 Bit</td>
<td>1/8</td>
</tr>
<tr>
<td>Nibble</td>
<td>4 Bits</td>
<td>1/2 (rare)</td>
</tr>
<tr>
<td>Byte</td>
<td>8 Bits</td>
<td>1</td>
</tr>
<tr>
<td>Kilobyte</td>
<td>1024 Bytes</td>
<td>1024</td>
</tr>
<tr>
<td>Megabyte</td>
<td>1, 024 Kilobytes</td>
<td>1, 048, 576</td>
</tr>
<tr>
<td>Gigabyte</td>
<td>1, 024 Megabytes</td>
<td>1, 073, 741, 824</td>
</tr>
<tr>
<td>Terrabyte</td>
<td>1, 024 Gigabytes</td>
<td>1, 099, 511, 627, 776</td>
</tr>
<tr>
<td>Petabyte</td>
<td>1, 024 Terabytes</td>
<td>1, 125, 899, 906, 842, 624</td>
</tr>
<tr>
<td>Exabyte</td>
<td>1, 024 Petabytes</td>
<td>1, 152, 921, 504, 606, 846, 976</td>
</tr>
<tr>
<td>Zettabyte</td>
<td>1, 024 Exabytes</td>
<td>1, 180, 591, 620, 717, 411, 303, 424</td>
</tr>
<tr>
<td>Yottabyte</td>
<td>1, 024 Zettabytes</td>
<td>1, 208, 925, 819, 614, 629, 174, 706, 176</td>
</tr>
</tbody>
</table>
</li>
</ul>
</li>
</ul>
<h3 id="_3-6-peripheral-devices" tabindex="-1">3.6: Peripheral Devices <a class="header-anchor" href="#_3-6-peripheral-devices" aria-label="Permalink to &quot;3.6: Peripheral Devices&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>Input v. Output</li>
<li>Input device: keywords, mice, touchpad, stylus, speakers, microphone, digital camera, etc/</li>
<li>Optical Character Recognition (OCR): Converting printed text to digital text</li>
<li>Radio Frequency Identification (RFID): An input mechanism that can be used to label a product for identification and have the product's information transmitted through radio waves.</li>
</ul>
<h3 id="_3-7-output-devices-contd" tabindex="-1">3.7: Output Devices Contd. <a class="header-anchor" href="#_3-7-output-devices-contd" aria-label="Permalink to &quot;3.7: Output Devices Contd.&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>Monitor: A series of transistors that translate machine code into text and images./</li>
<li>Pixels: A single dot on a graphic or text image</li>
<li>Resolution: The number of pixels inside a defined dimension on a monitor, commonly referred to as <strong>dots per inch (dpi).</strong>
<ul>
<li>Resolution is the most important feature of a monitor.</li>
</ul>
</li>
</ul>
]]></description>
            <content:encoded><![CDATA[<h1 id="cis105-computer-applications-information-systems-lect-3" tabindex="-1">CIS105: Computer Applications &amp; Information Systems Lect. 3 <a class="header-anchor" href="#cis105-computer-applications-information-systems-lect-3" aria-label="Permalink to &quot;CIS105: Computer Applications &amp; Information Systems Lect. 3&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="chapter-3-computer-hardware" tabindex="-1">Chapter 3: Computer Hardware <a class="header-anchor" href="#chapter-3-computer-hardware" aria-label="Permalink to &quot;Chapter 3: Computer Hardware&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="_3-1-technical-terminologies" tabindex="-1">3.1: Technical Terminologies <a class="header-anchor" href="#_3-1-technical-terminologies" aria-label="Permalink to &quot;3.1: Technical Terminologies&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li><strong>System Unit</strong>: Main body of the computer that contains a motherboard.</li>
<li><strong>Motherboard</strong> (AKA Circuit Board): Main component of a system unit; a compleex array of electronics that connect and help different components of the computer communicate with each other.
<ul>
<li>PC: Motherboards, Mac; Logic Boards</li>
</ul>
</li>
<li><strong>Chassis</strong> (AKA Case or Box): Case to enclose the main components of a computer</li>
<li><strong>Microprocessor</strong>: The brains of the computer
<ul>
<li><strong>Central processing unit (CPU)</strong>: Interprets program instructions and processes data by performing arithmetic and logical operations.</li>
</ul>
</li>
</ul>
<h3 id="_3-2-central-processing-unit-cpu" tabindex="-1">3.2: Central Processing Unit (CPU) <a class="header-anchor" href="#_3-2-central-processing-unit-cpu" aria-label="Permalink to &quot;3.2: Central Processing Unit (CPU)&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>Speed is directly, but not solely, related to the CPU</li>
<li>Measured in Clock Rate
<ul>
<li>The number of cycles per second, that a computer can perform its most basic task</li>
</ul>
</li>
<li>RSIC (Reduced Instruction Set Computer): Many chips encased into one chip</li>
<li>Bus Lines; Pathways that transfer data and power between components inside of a computer.</li>
</ul>
<table>
<thead>
<tr>
<th>Architecture Diagram of CPU</th>
<th>Actual CPU Image</th>
</tr>
</thead>
<tbody>
<tr>
<td><img src="https://computersciencewiki.org/images/1/1a/Cpu_diagram.png" alt="Architecture of the central processing unit (CPU) - Computer ..."></td>
<td><img src="https://i.insider.com/60402d8eb46d720018b04c1f?width=700" alt="What Is a CPU? a Guide to Your Computer's 'Brain'"></td>
</tr>
</tbody>
</table>
<h3 id="_3-3-power-supply-unit-psu" tabindex="-1">3.3 Power Supply Unit (PSU) <a class="header-anchor" href="#_3-3-power-supply-unit-psu" aria-label="Permalink to &quot;3.3 Power Supply Unit (PSU)&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>Supplies electricity</li>
<li>Converts 100-120 volts or 220-240 volts of <strong>alternating current (AC)</strong> to a lower voltage direct current (DC) that can be used by the internal components of the system unit</li>
<li>Different currents used in different parts of the world.</li>
</ul>
<h3 id="_3-4-primary-and-secondary-storage" tabindex="-1">3.4: Primary and Secondary Storage <a class="header-anchor" href="#_3-4-primary-and-secondary-storage" aria-label="Permalink to &quot;3.4: Primary and Secondary Storage&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li><strong>Primary</strong>: The workbench
<ul>
<li>Random Access Memory (RAM): Primary storage</li>
</ul>
</li>
<li><strong>Secondary</strong>: The storage for all your tools and supplies
<ul>
<li>Hard Drive: Secondary storage</li>
</ul>
</li>
<li>ROM Chips (Read-Only Memory): Preprogrammed chips that serve specialized internal tasks. No human intervention
<ul>
<li>AKA Firmware</li>
</ul>
</li>
</ul>
<h4 id="_3-4-1-secondary-storage-contd" tabindex="-1">3.4.1: Secondary Storage Contd. <a class="header-anchor" href="#_3-4-1-secondary-storage-contd" aria-label="Permalink to &quot;3.4.1: Secondary Storage Contd.&quot;">&ZeroWidthSpace;</a></h4>
<ul>
<li>Internal vs. External Storage</li>
<li>Hard Drivers vs. Solid State Drivers (SSDs)</li>
<li>Impractical for a computer to be stand-alone</li>
<li>Important to consider business needs
<ul>
<li>Bad IT can make or break a business</li>
</ul>
</li>
</ul>
<h3 id="_3-5-binary-number-system" tabindex="-1">3.5: Binary Number System <a class="header-anchor" href="#_3-5-binary-number-system" aria-label="Permalink to &quot;3.5: Binary Number System&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>
<p>Computer only understands one language: Machine code or machine language</p>
</li>
<li>
<p>1 or 0 (on or off)</p>
</li>
<li>
<p>1s or 0s are referred to as bits (short for binary digits)</p>
</li>
<li>
<p>8 bits become a byte</p>
<ul>
<li>Byte 8 bits</li>
<li>Kilob</li>
</ul>
</li>
<li>
<p>American Standard Code for Information Interchange (ASCII): The coding scheme that most microcomputer use to represent bytes.</p>
<ul>
<li>
<table>
<thead>
<tr>
<th>Name</th>
<th>Equal To</th>
<th>Size (In Bytes)</th>
</tr>
</thead>
<tbody>
<tr>
<td>Bit</td>
<td>1 Bit</td>
<td>1/8</td>
</tr>
<tr>
<td>Nibble</td>
<td>4 Bits</td>
<td>1/2 (rare)</td>
</tr>
<tr>
<td>Byte</td>
<td>8 Bits</td>
<td>1</td>
</tr>
<tr>
<td>Kilobyte</td>
<td>1024 Bytes</td>
<td>1024</td>
</tr>
<tr>
<td>Megabyte</td>
<td>1, 024 Kilobytes</td>
<td>1, 048, 576</td>
</tr>
<tr>
<td>Gigabyte</td>
<td>1, 024 Megabytes</td>
<td>1, 073, 741, 824</td>
</tr>
<tr>
<td>Terrabyte</td>
<td>1, 024 Gigabytes</td>
<td>1, 099, 511, 627, 776</td>
</tr>
<tr>
<td>Petabyte</td>
<td>1, 024 Terabytes</td>
<td>1, 125, 899, 906, 842, 624</td>
</tr>
<tr>
<td>Exabyte</td>
<td>1, 024 Petabytes</td>
<td>1, 152, 921, 504, 606, 846, 976</td>
</tr>
<tr>
<td>Zettabyte</td>
<td>1, 024 Exabytes</td>
<td>1, 180, 591, 620, 717, 411, 303, 424</td>
</tr>
<tr>
<td>Yottabyte</td>
<td>1, 024 Zettabytes</td>
<td>1, 208, 925, 819, 614, 629, 174, 706, 176</td>
</tr>
</tbody>
</table>
</li>
</ul>
</li>
</ul>
<h3 id="_3-6-peripheral-devices" tabindex="-1">3.6: Peripheral Devices <a class="header-anchor" href="#_3-6-peripheral-devices" aria-label="Permalink to &quot;3.6: Peripheral Devices&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>Input v. Output</li>
<li>Input device: keywords, mice, touchpad, stylus, speakers, microphone, digital camera, etc/</li>
<li>Optical Character Recognition (OCR): Converting printed text to digital text</li>
<li>Radio Frequency Identification (RFID): An input mechanism that can be used to label a product for identification and have the product's information transmitted through radio waves.</li>
</ul>
<h3 id="_3-7-output-devices-contd" tabindex="-1">3.7: Output Devices Contd. <a class="header-anchor" href="#_3-7-output-devices-contd" aria-label="Permalink to &quot;3.7: Output Devices Contd.&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>Monitor: A series of transistors that translate machine code into text and images./</li>
<li>Pixels: A single dot on a graphic or text image</li>
<li>Resolution: The number of pixels inside a defined dimension on a monitor, commonly referred to as <strong>dots per inch (dpi).</strong>
<ul>
<li>Resolution is the most important feature of a monitor.</li>
</ul>
</li>
</ul>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CIS105: Computer Applications &amp; Information Systems Lect. 4 ]]></title>
            <link>https://note.toshiki.devacademic/cis105/cis105-l4-lecture-note</link>
            <guid>https://note.toshiki.devacademic/cis105/cis105-l4-lecture-note</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="cis105-computer-applications-information-systems-lect-4" tabindex="-1">CIS105: Computer Applications &amp; Information Systems Lect. 4 <a class="header-anchor" href="#cis105-computer-applications-information-systems-lect-4" aria-label="Permalink to &quot;CIS105: Computer Applications &amp; Information Systems Lect. 4&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="chapter-4-formulas-and-functions" tabindex="-1">Chapter 4: Formulas and Functions <a class="header-anchor" href="#chapter-4-formulas-and-functions" aria-label="Permalink to &quot;Chapter 4: Formulas and Functions&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="_4-1-references-and-calculations" tabindex="-1">4.1: References and Calculations <a class="header-anchor" href="#_4-1-references-and-calculations" aria-label="Permalink to &quot;4.1: References and Calculations&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>Calculations
<ul>
<li><strong>Add (<code>+</code>), Subtract (<code>-</code>), Multiply (<code>*</code>), Divide (<code>/</code>)</strong></li>
<li>Add: <code>A1+A2</code></li>
<li>Subtract: <code>A1-A2</code></li>
<li>Multiply: <code>A1*A2</code></li>
<li>Divide: <code>A1/A2</code></li>
</ul>
</li>
<li><strong>Always end typing by pressing <kbd>Enter</kbd></strong></li>
<li>Al formulas start with an equals (<code>=</code>) sign</li>
</ul>
<h3 id="_4-2-references-and-calculations" tabindex="-1">4.2: References and Calculations <a class="header-anchor" href="#_4-2-references-and-calculations" aria-label="Permalink to &quot;4.2: References and Calculations&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>
<p>References: When we perform calculations in Excel, we often reference the value stored in other cells in our worksheet</p>
</li>
<li>
<p>Three ays to reference a cell:</p>
<ul>
<li>Relative reference - <code>A1</code></li>
<li>Mixed reference - <code>$A1</code> or <code>A$1</code></li>
<li>Absolute reference - <code>$A$1</code></li>
</ul>
</li>
<li>
<p><strong>Relative Reference</strong>: An address or pointer that changes when the target item is moved or the relationship to it has changed.</p>
<ul>
<li><strong>RELATIVE REFERENCE IS THE DEFALT REFERENCE IN EXCEL</strong>.</li>
<li>The reference changes when the formula is copied elsewhere.</li>
<li>Excel sees the location of the cells relative to the location of the formula.</li>
<li>Click <kbd>Fn</kbd> + <kbd>F4</kbd> as hotkeys to construct value as relative value</li>
</ul>
</li>
<li>
<p><strong>Absolute Reference</strong>: Will make either the row or column &quot;constant&quot; in other words, the ABSOLUTE cell location is LOCKED</p>
<ul>
<li>To create an absolute cell reference, put a dollar sign ``$` symbol in front of the part of the reference that you want to remain constant.</li>
</ul>
</li>
<li>
<table>
<thead>
<tr>
<th>Reference</th>
<th>Comments</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>A1</code></td>
<td>Both the column and row references are &quot;relative&quot; and will change when the reference is copied and pasted to other cell.</td>
</tr>
<tr>
<td><code>$A1</code></td>
<td>The column reference is &quot;<strong>absolute</strong>&quot; and will remain constant when copied and pasted to other cells. The row reference is &quot;relative&quot; and will change when copied and pasted to cells in other rows of the worksheet</td>
</tr>
<tr>
<td><code>A$1</code></td>
<td>The column reference is &quot;relative&quot; and will change when copied and pasted to cells in other columns in the worksheet. The row reference is &quot;<strong>absolute</strong>&quot; and will remain constant when copied and pasted to other cells.</td>
</tr>
<tr>
<td><code>$A$1</code></td>
<td>Both the column and row references are &quot;<strong>absolute</strong>&quot; and will remain constant when the reference is copied and pated to other cells.</td>
</tr>
</tbody>
</table>
</li>
</ul>
<h3 id="_4-3-summary-statistics-functions" tabindex="-1">4.3: Summary Statistics Functions <a class="header-anchor" href="#_4-3-summary-statistics-functions" aria-label="Permalink to &quot;4.3: Summary Statistics Functions&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>Formula vs. Function
<ul>
<li>Formula: Any calculation in excel</li>
<li>Function: A pre-defined calculation</li>
</ul>
</li>
<li>To perform calculations in Excel, we often reference the values stored in other cells in our worksheets. <strong>We reference the cell location, not the value in the cell</strong>.</li>
<li><code>COUNT(value1, [value2]), ...)</code>: Counts the number of cells in that contain numbers.</li>
<li><code>COUNTA(value1, [value2], ...)</code>: Counts the number of cells in a range of cells that are not blank.</li>
<li><code>AVERAGE(number1, [number2], ...)</code>: Calculates the simple average of a set of numbers.</li>
<li><code>MAX(number1, [number2], ...)</code>: Returns the largest value in a set of numbers.</li>
<li><code>MIN(number1, [number2], ...)</code>: Returns the smallest value in a set of numbers.</li>
</ul>
<h3 id="_4-4-financial-function" tabindex="-1">4.4: Financial Function <a class="header-anchor" href="#_4-4-financial-function" aria-label="Permalink to &quot;4.4: Financial Function&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li><code>RATE(nper, pmt, pv, [fv], [type], [guess])</code> : calculates the interest rate earned for an investment given the number of payments made as part of the investment, the payment amount, and the current value of the investment.</li>
<li><code>EFFECT(nominal _rate, pery)</code>: calculates the annual percentage rate for an interest rate given the
number of times per year that interest is charged.</li>
<li><code>NPER(rate, pmt, pv, [fv], [type])</code>: calculates the number of payments that will be made to pay off a loan given the interest rate, payment amount, and original loan amount.</li>
<li><code>PMT(rate, per, pv, [fv], [type])</code>: calculates the payment amount for a loan given the interest rate, number of payments to be made to pay off the loan, and the original loan amount.</li>
<li><code>PV(rate, per, pmt, [fv], (type))</code>: calculates the current value (accounting for compounding interest) of an investment given the interest rate, number of payments to be made, and the amount of the payment.</li>
<li><code>FV(rate, per, pmt, [pv], [type])</code>: calculates the future value of an investment given the interest rate, number of payments to be made, and the amount of the payment.</li>
</ul>
]]></description>
            <content:encoded><![CDATA[<h1 id="cis105-computer-applications-information-systems-lect-4" tabindex="-1">CIS105: Computer Applications &amp; Information Systems Lect. 4 <a class="header-anchor" href="#cis105-computer-applications-information-systems-lect-4" aria-label="Permalink to &quot;CIS105: Computer Applications &amp; Information Systems Lect. 4&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="chapter-4-formulas-and-functions" tabindex="-1">Chapter 4: Formulas and Functions <a class="header-anchor" href="#chapter-4-formulas-and-functions" aria-label="Permalink to &quot;Chapter 4: Formulas and Functions&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="_4-1-references-and-calculations" tabindex="-1">4.1: References and Calculations <a class="header-anchor" href="#_4-1-references-and-calculations" aria-label="Permalink to &quot;4.1: References and Calculations&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>Calculations
<ul>
<li><strong>Add (<code>+</code>), Subtract (<code>-</code>), Multiply (<code>*</code>), Divide (<code>/</code>)</strong></li>
<li>Add: <code>A1+A2</code></li>
<li>Subtract: <code>A1-A2</code></li>
<li>Multiply: <code>A1*A2</code></li>
<li>Divide: <code>A1/A2</code></li>
</ul>
</li>
<li><strong>Always end typing by pressing <kbd>Enter</kbd></strong></li>
<li>Al formulas start with an equals (<code>=</code>) sign</li>
</ul>
<h3 id="_4-2-references-and-calculations" tabindex="-1">4.2: References and Calculations <a class="header-anchor" href="#_4-2-references-and-calculations" aria-label="Permalink to &quot;4.2: References and Calculations&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>
<p>References: When we perform calculations in Excel, we often reference the value stored in other cells in our worksheet</p>
</li>
<li>
<p>Three ays to reference a cell:</p>
<ul>
<li>Relative reference - <code>A1</code></li>
<li>Mixed reference - <code>$A1</code> or <code>A$1</code></li>
<li>Absolute reference - <code>$A$1</code></li>
</ul>
</li>
<li>
<p><strong>Relative Reference</strong>: An address or pointer that changes when the target item is moved or the relationship to it has changed.</p>
<ul>
<li><strong>RELATIVE REFERENCE IS THE DEFALT REFERENCE IN EXCEL</strong>.</li>
<li>The reference changes when the formula is copied elsewhere.</li>
<li>Excel sees the location of the cells relative to the location of the formula.</li>
<li>Click <kbd>Fn</kbd> + <kbd>F4</kbd> as hotkeys to construct value as relative value</li>
</ul>
</li>
<li>
<p><strong>Absolute Reference</strong>: Will make either the row or column &quot;constant&quot; in other words, the ABSOLUTE cell location is LOCKED</p>
<ul>
<li>To create an absolute cell reference, put a dollar sign ``$` symbol in front of the part of the reference that you want to remain constant.</li>
</ul>
</li>
<li>
<table>
<thead>
<tr>
<th>Reference</th>
<th>Comments</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>A1</code></td>
<td>Both the column and row references are &quot;relative&quot; and will change when the reference is copied and pasted to other cell.</td>
</tr>
<tr>
<td><code>$A1</code></td>
<td>The column reference is &quot;<strong>absolute</strong>&quot; and will remain constant when copied and pasted to other cells. The row reference is &quot;relative&quot; and will change when copied and pasted to cells in other rows of the worksheet</td>
</tr>
<tr>
<td><code>A$1</code></td>
<td>The column reference is &quot;relative&quot; and will change when copied and pasted to cells in other columns in the worksheet. The row reference is &quot;<strong>absolute</strong>&quot; and will remain constant when copied and pasted to other cells.</td>
</tr>
<tr>
<td><code>$A$1</code></td>
<td>Both the column and row references are &quot;<strong>absolute</strong>&quot; and will remain constant when the reference is copied and pated to other cells.</td>
</tr>
</tbody>
</table>
</li>
</ul>
<h3 id="_4-3-summary-statistics-functions" tabindex="-1">4.3: Summary Statistics Functions <a class="header-anchor" href="#_4-3-summary-statistics-functions" aria-label="Permalink to &quot;4.3: Summary Statistics Functions&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>Formula vs. Function
<ul>
<li>Formula: Any calculation in excel</li>
<li>Function: A pre-defined calculation</li>
</ul>
</li>
<li>To perform calculations in Excel, we often reference the values stored in other cells in our worksheets. <strong>We reference the cell location, not the value in the cell</strong>.</li>
<li><code>COUNT(value1, [value2]), ...)</code>: Counts the number of cells in that contain numbers.</li>
<li><code>COUNTA(value1, [value2], ...)</code>: Counts the number of cells in a range of cells that are not blank.</li>
<li><code>AVERAGE(number1, [number2], ...)</code>: Calculates the simple average of a set of numbers.</li>
<li><code>MAX(number1, [number2], ...)</code>: Returns the largest value in a set of numbers.</li>
<li><code>MIN(number1, [number2], ...)</code>: Returns the smallest value in a set of numbers.</li>
</ul>
<h3 id="_4-4-financial-function" tabindex="-1">4.4: Financial Function <a class="header-anchor" href="#_4-4-financial-function" aria-label="Permalink to &quot;4.4: Financial Function&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li><code>RATE(nper, pmt, pv, [fv], [type], [guess])</code> : calculates the interest rate earned for an investment given the number of payments made as part of the investment, the payment amount, and the current value of the investment.</li>
<li><code>EFFECT(nominal _rate, pery)</code>: calculates the annual percentage rate for an interest rate given the
number of times per year that interest is charged.</li>
<li><code>NPER(rate, pmt, pv, [fv], [type])</code>: calculates the number of payments that will be made to pay off a loan given the interest rate, payment amount, and original loan amount.</li>
<li><code>PMT(rate, per, pv, [fv], [type])</code>: calculates the payment amount for a loan given the interest rate, number of payments to be made to pay off the loan, and the original loan amount.</li>
<li><code>PV(rate, per, pmt, [fv], (type))</code>: calculates the current value (accounting for compounding interest) of an investment given the interest rate, number of payments to be made, and the amount of the payment.</li>
<li><code>FV(rate, per, pmt, [pv], [type])</code>: calculates the future value of an investment given the interest rate, number of payments to be made, and the amount of the payment.</li>
</ul>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CIS105: Computer Applications &amp; Information Systems Lect. 5 ]]></title>
            <link>https://note.toshiki.devacademic/cis105/cis105-l5-lecture-note</link>
            <guid>https://note.toshiki.devacademic/cis105/cis105-l5-lecture-note</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="cis105-computer-applications-information-systems-lect-5" tabindex="-1">CIS105: Computer Applications &amp; Information Systems Lect. 5 <a class="header-anchor" href="#cis105-computer-applications-information-systems-lect-5" aria-label="Permalink to &quot;CIS105: Computer Applications &amp; Information Systems Lect. 5&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="chapter-5-operating-system" tabindex="-1">Chapter 5: Operating System <a class="header-anchor" href="#chapter-5-operating-system" aria-label="Permalink to &quot;Chapter 5: Operating System&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="_5-1-operating-system-fundamentals" tabindex="-1">5.1: Operating System Fundamentals <a class="header-anchor" href="#_5-1-operating-system-fundamentals" aria-label="Permalink to &quot;5.1: Operating System Fundamentals&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>1980: Bill Gates and Paul Allen leased IBM a Personal Computer (PC) called MS-DOS (Microsoft Disk Operating System) for a one-time fee of <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">$</mi><mn>50</mn><mo separator="true">,</mo><mn>000</mn></mrow><annotation encoding="application/x-tex">\$50,000</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9444em;vertical-align:-0.1944em;"></span><span class="mord">$50</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord">000</span></span></span></span>.
<ul>
<li>Gates Kept the copyright for MS-DOS</li>
</ul>
</li>
<li>1984: Steve Jobs and Steve Wozniak created Mac OS
<ul>
<li>Advertised on &quot;More user-friendly&quot;</li>
</ul>
</li>
</ul>
<h3 id="_5-2-understanding-operating-systems" tabindex="-1">5.2: Understanding Operating Systems <a class="header-anchor" href="#_5-2-understanding-operating-systems" aria-label="Permalink to &quot;5.2: Understanding Operating Systems&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>System software: Software that automatically runs to configure a computer (no human intervention)</li>
<li>Operating system (AKA Platform): A collection of computer programs that administer the hardware and software of a computer so that they work properly
<ul>
<li>Microsoft Windows, Mac OS, UNIX, Linux</li>
</ul>
</li>
<li><strong>Application software cannot run or be installed without a operating system</strong>.</li>
</ul>
<h3 id="_5-3-memory-management" tabindex="-1">5.3: Memory Management <a class="header-anchor" href="#_5-3-memory-management" aria-label="Permalink to &quot;5.3: Memory Management&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>
<p><strong>Operating system coordinate</strong>: Computers memory</p>
<ul>
<li><strong>Cache, Random Access Memory (RAM), registers, and virtual memory</strong></li>
<li><strong>Disk Storage</strong></li>
</ul>
</li>
<li>
<p><strong>CPU Cache</strong>: A small, very quick memory that stores copies of information and data from the most regularly-used parts of main memory</p>
<ul>
<li>Helps decrease the time it takes to access memory.</li>
</ul>
</li>
<li>
<p><strong>Random Access Memory (RAM)</strong>: Volatile memory</p>
</li>
<li>
<p>Disk Storage: Non-volatile memory</p>
<ul>
<li>
<blockquote>
<p><strong>volatile memory stores data when a computer is on but erases it as soon as the computer is switched off, whereas non-volatile memory remains in a computer even after the system shuts off</strong>.</p>
</blockquote>
</li>
</ul>
</li>
</ul>
<h3 id="_5-4-memory-management-contd" tabindex="-1">5.4: Memory Management Contd. <a class="header-anchor" href="#_5-4-memory-management-contd" aria-label="Permalink to &quot;5.4: Memory Management Contd.&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>Registers: Small memory locations used to quicken the implementation of computer programs
<ul>
<li>Customization towards the device including wallpaper setting which is referred the process of registering.</li>
</ul>
</li>
<li>Virtual Memory: Memory the OS uses to coordinate, track and efficiently allocate the use of CPU cache, registers, RAM and disk storage.
<ul>
<li>The messenger between volatile and non-volatile storage.</li>
</ul>
</li>
</ul>
<h3 id="_5-5-disk-management" tabindex="-1">5.5: Disk Management <a class="header-anchor" href="#_5-5-disk-management" aria-label="Permalink to &quot;5.5: Disk Management&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>OS is responsible for saving information as efficiently as possible
<ul>
<li>Creates a table of contents of FAT (File Allocation Table)</li>
</ul>
</li>
<li>Defragmentation: A program the reorganizes the hard drive
<ul>
<li>Note required for SSD</li>
</ul>
</li>
<li>Hard Disk Drive (HDD)
<ul>
<li>Pros: More affordable, good for standard business procedures</li>
<li>Cons: more prone to damage</li>
</ul>
</li>
<li>Solid State Drives (SSD)
<ul>
<li>Pros: N moving parts, more reliable</li>
<li>Cons: More expensive.</li>
</ul>
</li>
</ul>
<h3 id="_5-6-file-management" tabindex="-1">5.6: File Management <a class="header-anchor" href="#_5-6-file-management" aria-label="Permalink to &quot;5.6: File Management&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>File manager are made up of Hierarchy of Directories, more commonly referred to as folders
<ul>
<li>Can be compared to a physical storage</li>
</ul>
</li>
</ul>
<h3 id="_5-7-networks" tabindex="-1">5.7: Networks <a class="header-anchor" href="#_5-7-networks" aria-label="Permalink to &quot;5.7: Networks&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>Network: 2 or more computers connected together</li>
<li>Transmission control protocol and internet protocol (TCP/IP): A set of rules for transferring information from one computer to another
<ul>
<li>Transfers info by breaking up files into packates</li>
</ul>
</li>
<li>The internet is the world's largest network</li>
</ul>
<h3 id="_5-8-device-drivers" tabindex="-1">5.8: Device Drivers <a class="header-anchor" href="#_5-8-device-drivers" aria-label="Permalink to &quot;5.8: Device Drivers&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>Device Driver: Allows the OS to communicate with peripheral devices</li>
<li>Modern OS have plug-and-play capability</li>
<li>1996: USB developed and considered industry standard</li>
</ul>
<h3 id="_5-9-embedded-operating-systems" tabindex="-1">5.9: embedded Operating Systems <a class="header-anchor" href="#_5-9-embedded-operating-systems" aria-label="Permalink to &quot;5.9: embedded Operating Systems&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>Embedded Operating System: OS installed on devices and appliances that rely on computing
<ul>
<li>Ex; Cash registers, automatic teller machines (ATM), microwaves, and specialized handled devices</li>
<li>Embedded OS cannot be modified in most cases</li>
<li>Embedded OS used on most cell pones
<ul>
<li>Google, Android, and iPhone</li>
</ul>
</li>
</ul>
</li>
</ul>
<h3 id="_5-10-mac-or-pc" tabindex="-1">5.10: Mac or PC? <a class="header-anchor" href="#_5-10-mac-or-pc" aria-label="Permalink to &quot;5.10: Mac or PC?&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>The answer is baed on the needs of the business</li>
<li>Ask yourself: Which one are your end-users comfortable or have experiencing using? Which one gives you a clear competitive advantage?</li>
</ul>
<h3 id="_5-11-major-operating-systems" tabindex="-1">5.11: Major Operating Systems <a class="header-anchor" href="#_5-11-major-operating-systems" aria-label="Permalink to &quot;5.11: Major Operating Systems&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>Microsoft Windows: Windows 10
<ul>
<li>Windows 11 available for download</li>
</ul>
</li>
<li>Mac Operating System (AKA Mac OS)
<ul>
<li>Version 14: Sonoma</li>
</ul>
</li>
<li>Linux: An open-source OS that can be modified, used, and redistributed by anyone freely
<ul>
<li>Created by <strong>Linux Torvalds</strong></li>
</ul>
</li>
<li>UNIX: Popular for large processing applications like credit card transactions and approvals.</li>
</ul>
<h3 id="_5-12-open-source-os" tabindex="-1">5.12: Open-Source OS <a class="header-anchor" href="#_5-12-open-source-os" aria-label="Permalink to &quot;5.12: Open-Source OS&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>Proprietary software vs. open-source
<ul>
<li>Why doesn't everyone use open-source</li>
</ul>
</li>
<li>Diffusion: A product or software is widely accepted</li>
</ul>
]]></description>
            <content:encoded><![CDATA[<h1 id="cis105-computer-applications-information-systems-lect-5" tabindex="-1">CIS105: Computer Applications &amp; Information Systems Lect. 5 <a class="header-anchor" href="#cis105-computer-applications-information-systems-lect-5" aria-label="Permalink to &quot;CIS105: Computer Applications &amp; Information Systems Lect. 5&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="chapter-5-operating-system" tabindex="-1">Chapter 5: Operating System <a class="header-anchor" href="#chapter-5-operating-system" aria-label="Permalink to &quot;Chapter 5: Operating System&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="_5-1-operating-system-fundamentals" tabindex="-1">5.1: Operating System Fundamentals <a class="header-anchor" href="#_5-1-operating-system-fundamentals" aria-label="Permalink to &quot;5.1: Operating System Fundamentals&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>1980: Bill Gates and Paul Allen leased IBM a Personal Computer (PC) called MS-DOS (Microsoft Disk Operating System) for a one-time fee of <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">$</mi><mn>50</mn><mo separator="true">,</mo><mn>000</mn></mrow><annotation encoding="application/x-tex">\$50,000</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9444em;vertical-align:-0.1944em;"></span><span class="mord">$50</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord">000</span></span></span></span>.
<ul>
<li>Gates Kept the copyright for MS-DOS</li>
</ul>
</li>
<li>1984: Steve Jobs and Steve Wozniak created Mac OS
<ul>
<li>Advertised on &quot;More user-friendly&quot;</li>
</ul>
</li>
</ul>
<h3 id="_5-2-understanding-operating-systems" tabindex="-1">5.2: Understanding Operating Systems <a class="header-anchor" href="#_5-2-understanding-operating-systems" aria-label="Permalink to &quot;5.2: Understanding Operating Systems&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>System software: Software that automatically runs to configure a computer (no human intervention)</li>
<li>Operating system (AKA Platform): A collection of computer programs that administer the hardware and software of a computer so that they work properly
<ul>
<li>Microsoft Windows, Mac OS, UNIX, Linux</li>
</ul>
</li>
<li><strong>Application software cannot run or be installed without a operating system</strong>.</li>
</ul>
<h3 id="_5-3-memory-management" tabindex="-1">5.3: Memory Management <a class="header-anchor" href="#_5-3-memory-management" aria-label="Permalink to &quot;5.3: Memory Management&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>
<p><strong>Operating system coordinate</strong>: Computers memory</p>
<ul>
<li><strong>Cache, Random Access Memory (RAM), registers, and virtual memory</strong></li>
<li><strong>Disk Storage</strong></li>
</ul>
</li>
<li>
<p><strong>CPU Cache</strong>: A small, very quick memory that stores copies of information and data from the most regularly-used parts of main memory</p>
<ul>
<li>Helps decrease the time it takes to access memory.</li>
</ul>
</li>
<li>
<p><strong>Random Access Memory (RAM)</strong>: Volatile memory</p>
</li>
<li>
<p>Disk Storage: Non-volatile memory</p>
<ul>
<li>
<blockquote>
<p><strong>volatile memory stores data when a computer is on but erases it as soon as the computer is switched off, whereas non-volatile memory remains in a computer even after the system shuts off</strong>.</p>
</blockquote>
</li>
</ul>
</li>
</ul>
<h3 id="_5-4-memory-management-contd" tabindex="-1">5.4: Memory Management Contd. <a class="header-anchor" href="#_5-4-memory-management-contd" aria-label="Permalink to &quot;5.4: Memory Management Contd.&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>Registers: Small memory locations used to quicken the implementation of computer programs
<ul>
<li>Customization towards the device including wallpaper setting which is referred the process of registering.</li>
</ul>
</li>
<li>Virtual Memory: Memory the OS uses to coordinate, track and efficiently allocate the use of CPU cache, registers, RAM and disk storage.
<ul>
<li>The messenger between volatile and non-volatile storage.</li>
</ul>
</li>
</ul>
<h3 id="_5-5-disk-management" tabindex="-1">5.5: Disk Management <a class="header-anchor" href="#_5-5-disk-management" aria-label="Permalink to &quot;5.5: Disk Management&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>OS is responsible for saving information as efficiently as possible
<ul>
<li>Creates a table of contents of FAT (File Allocation Table)</li>
</ul>
</li>
<li>Defragmentation: A program the reorganizes the hard drive
<ul>
<li>Note required for SSD</li>
</ul>
</li>
<li>Hard Disk Drive (HDD)
<ul>
<li>Pros: More affordable, good for standard business procedures</li>
<li>Cons: more prone to damage</li>
</ul>
</li>
<li>Solid State Drives (SSD)
<ul>
<li>Pros: N moving parts, more reliable</li>
<li>Cons: More expensive.</li>
</ul>
</li>
</ul>
<h3 id="_5-6-file-management" tabindex="-1">5.6: File Management <a class="header-anchor" href="#_5-6-file-management" aria-label="Permalink to &quot;5.6: File Management&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>File manager are made up of Hierarchy of Directories, more commonly referred to as folders
<ul>
<li>Can be compared to a physical storage</li>
</ul>
</li>
</ul>
<h3 id="_5-7-networks" tabindex="-1">5.7: Networks <a class="header-anchor" href="#_5-7-networks" aria-label="Permalink to &quot;5.7: Networks&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>Network: 2 or more computers connected together</li>
<li>Transmission control protocol and internet protocol (TCP/IP): A set of rules for transferring information from one computer to another
<ul>
<li>Transfers info by breaking up files into packates</li>
</ul>
</li>
<li>The internet is the world's largest network</li>
</ul>
<h3 id="_5-8-device-drivers" tabindex="-1">5.8: Device Drivers <a class="header-anchor" href="#_5-8-device-drivers" aria-label="Permalink to &quot;5.8: Device Drivers&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>Device Driver: Allows the OS to communicate with peripheral devices</li>
<li>Modern OS have plug-and-play capability</li>
<li>1996: USB developed and considered industry standard</li>
</ul>
<h3 id="_5-9-embedded-operating-systems" tabindex="-1">5.9: embedded Operating Systems <a class="header-anchor" href="#_5-9-embedded-operating-systems" aria-label="Permalink to &quot;5.9: embedded Operating Systems&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>Embedded Operating System: OS installed on devices and appliances that rely on computing
<ul>
<li>Ex; Cash registers, automatic teller machines (ATM), microwaves, and specialized handled devices</li>
<li>Embedded OS cannot be modified in most cases</li>
<li>Embedded OS used on most cell pones
<ul>
<li>Google, Android, and iPhone</li>
</ul>
</li>
</ul>
</li>
</ul>
<h3 id="_5-10-mac-or-pc" tabindex="-1">5.10: Mac or PC? <a class="header-anchor" href="#_5-10-mac-or-pc" aria-label="Permalink to &quot;5.10: Mac or PC?&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>The answer is baed on the needs of the business</li>
<li>Ask yourself: Which one are your end-users comfortable or have experiencing using? Which one gives you a clear competitive advantage?</li>
</ul>
<h3 id="_5-11-major-operating-systems" tabindex="-1">5.11: Major Operating Systems <a class="header-anchor" href="#_5-11-major-operating-systems" aria-label="Permalink to &quot;5.11: Major Operating Systems&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>Microsoft Windows: Windows 10
<ul>
<li>Windows 11 available for download</li>
</ul>
</li>
<li>Mac Operating System (AKA Mac OS)
<ul>
<li>Version 14: Sonoma</li>
</ul>
</li>
<li>Linux: An open-source OS that can be modified, used, and redistributed by anyone freely
<ul>
<li>Created by <strong>Linux Torvalds</strong></li>
</ul>
</li>
<li>UNIX: Popular for large processing applications like credit card transactions and approvals.</li>
</ul>
<h3 id="_5-12-open-source-os" tabindex="-1">5.12: Open-Source OS <a class="header-anchor" href="#_5-12-open-source-os" aria-label="Permalink to &quot;5.12: Open-Source OS&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>Proprietary software vs. open-source
<ul>
<li>Why doesn't everyone use open-source</li>
</ul>
</li>
<li>Diffusion: A product or software is widely accepted</li>
</ul>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CIS105: Computer Applications &amp; Information Systems Lect. 6 Pt. 1 ]]></title>
            <link>https://note.toshiki.devacademic/cis105/cis105-l6-pt1-lecture-note</link>
            <guid>https://note.toshiki.devacademic/cis105/cis105-l6-pt1-lecture-note</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="cis105-computer-applications-information-systems-lect-6-pt-1" tabindex="-1">CIS105: Computer Applications &amp; Information Systems Lect. 6 Pt. 1 <a class="header-anchor" href="#cis105-computer-applications-information-systems-lect-6-pt-1" aria-label="Permalink to &quot;CIS105: Computer Applications &amp; Information Systems Lect. 6 Pt. 1&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="chapter-6-system-software" tabindex="-1">Chapter 6: System Software <a class="header-anchor" href="#chapter-6-system-software" aria-label="Permalink to &quot;Chapter 6: System Software&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="_6-1-system-software-overview" tabindex="-1">6.1: System Software Overview <a class="header-anchor" href="#_6-1-system-software-overview" aria-label="Permalink to &quot;6.1: System Software Overview&quot;">&ZeroWidthSpace;</a></h3>
<p>System Software:</p>
<ul>
<li>Enables the Operating System</li>
<li>Controls memory, input and output, and manages filing system</li>
<li>Runs essential processes automatically</li>
<li>Controls the physical hardware so that applications software can work</li>
<li>If your computer is running, your system software is working</li>
</ul>
<h3 id="_6-2-starting-the-computer" tabindex="-1">6.2: Starting the Computer <a class="header-anchor" href="#_6-2-starting-the-computer" aria-label="Permalink to &quot;6.2: Starting the Computer&quot;">&ZeroWidthSpace;</a></h3>
<p>What happens when you press the power button:</p>
<ul>
<li>System searches for Basic Input/Output System (BIOS)</li>
<li>Firmware, locates computer hardware</li>
<li>SS loads the platform (OS) into the computer’s memory: Booting</li>
<li>Powering up the computer for the first time: Cold Boot</li>
<li>Restarting a computer: Warm Boot</li>
<li>Computer will ask for login and load your profile</li>
<li>Preferences, themes, styles, and types of resources set up by the user</li>
<li>Registry loads settings made by the user</li>
<li>Screen savers, appearance, and personalizations</li>
</ul>
<h3 id="_6-3-administering-application-software" tabindex="-1">6.3: Administering Application Software <a class="header-anchor" href="#_6-3-administering-application-software" aria-label="Permalink to &quot;6.3: Administering Application Software&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>When a user clicks on an application, the application info moves from the hard drive to RAM (Random Access Memory)</li>
<li>SS and OS make sure application software works correctly</li>
</ul>
<h3 id="_6-4-memory-management" tabindex="-1">6.4: Memory Management <a class="header-anchor" href="#_6-4-memory-management" aria-label="Permalink to &quot;6.4: Memory Management&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>Computer memory allocation can be compared to a farmer allocating water for crops</li>
<li>Virtual memory: The technique of breaking large files down from the hard drive into smaller, more manageable files that fit in RAM</li>
<li>Smaller files called Pages</li>
<li>If the pages exceed RAM storage, OS will store temporary copies of pages to hard drive</li>
<li>Swap Files: When pages exceed RAM storage, OS swaps pages between hard drive and RAM
Ask yourself: Does your business need new computers or new computer parts?</li>
<li>New computer: $800-1500</li>
<li>Upgraded RAM: $50-$200</li>
<li>Upgraded Hard Drive:$40-$100</li>
</ul>
<h3 id="_6-5-interfacing-and-utilities" tabindex="-1">6.5: Interfacing and Utilities <a class="header-anchor" href="#_6-5-interfacing-and-utilities" aria-label="Permalink to &quot;6.5: Interfacing and Utilities&quot;">&ZeroWidthSpace;</a></h3>
<p>SS in the form of an OS must serve as a translator for both the computer and end user</p>
<ul>
<li>Monitor: displays and renders output an end user can understand</li>
<li>GUI</li>
<li>Icon: A small pictogram on the desktop that a user clicks with a mouse</li>
<li>Window: A GUI unto its own</li>
<li>Device Drivers: allow input and output devices to operate properly</li>
<li>The background displayed on the monitor is considered the desktop environment, or &quot;desktop&quot; for short</li>
<li>Active Window: the window that the user is currently using</li>
</ul>
<h3 id="_6-6-file-management-systems" tabindex="-1">6.6: File Management Systems <a class="header-anchor" href="#_6-6-file-management-systems" aria-label="Permalink to &quot;6.6: File Management Systems&quot;">&ZeroWidthSpace;</a></h3>
<p>Based on a hierarchy of folders that contain computer files. File management systems are searchable and provide information on files:</p>
<ul>
<li>File Name</li>
<li>File Creation Date</li>
<li>File Modification Date</li>
<li>Location of the file</li>
<li>Who created or modified a file</li>
<li>File size</li>
<li>In business, it is important to establish your file management system early</li>
</ul>
<h3 id="_6-7-system-software-utilities" tabindex="-1">6.7: System Software Utilities <a class="header-anchor" href="#_6-7-system-software-utilities" aria-label="Permalink to &quot;6.7: System Software Utilities&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>Tracks: concentric circular bands</li>
<li>Sectors: Tracks that are separated into wedges</li>
<li>Defragmentation: Organizes + and – charges to the innermost tracks of the disk to reduce the amount of time it takes the R/W arm to find the info</li>
</ul>
<h3 id="_6-8-antivirus-utilities" tabindex="-1">6.8: Antivirus Utilities <a class="header-anchor" href="#_6-8-antivirus-utilities" aria-label="Permalink to &quot;6.8: Antivirus Utilities&quot;">&ZeroWidthSpace;</a></h3>
<p>Antivirus Utilities: System software that identifies known viruses to block them from entering and infecting a computer system</p>
<ul>
<li>Utilizes a database of known viruses to cross reference against each incoming file</li>
<li>Subscription service: Norton Antivirus and McAfee VirusScan</li>
</ul>
<h3 id="_6-9-system-updates" tabindex="-1">6.9: System Updates <a class="header-anchor" href="#_6-9-system-updates" aria-label="Permalink to &quot;6.9: System Updates&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>To compensate for OS inadequacies, OS offer a system software utility called system update</li>
<li>Patches sent from Microsoft (or Mac) via the Internet to a user’s computer</li>
</ul>
]]></description>
            <content:encoded><![CDATA[<h1 id="cis105-computer-applications-information-systems-lect-6-pt-1" tabindex="-1">CIS105: Computer Applications &amp; Information Systems Lect. 6 Pt. 1 <a class="header-anchor" href="#cis105-computer-applications-information-systems-lect-6-pt-1" aria-label="Permalink to &quot;CIS105: Computer Applications &amp; Information Systems Lect. 6 Pt. 1&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="chapter-6-system-software" tabindex="-1">Chapter 6: System Software <a class="header-anchor" href="#chapter-6-system-software" aria-label="Permalink to &quot;Chapter 6: System Software&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="_6-1-system-software-overview" tabindex="-1">6.1: System Software Overview <a class="header-anchor" href="#_6-1-system-software-overview" aria-label="Permalink to &quot;6.1: System Software Overview&quot;">&ZeroWidthSpace;</a></h3>
<p>System Software:</p>
<ul>
<li>Enables the Operating System</li>
<li>Controls memory, input and output, and manages filing system</li>
<li>Runs essential processes automatically</li>
<li>Controls the physical hardware so that applications software can work</li>
<li>If your computer is running, your system software is working</li>
</ul>
<h3 id="_6-2-starting-the-computer" tabindex="-1">6.2: Starting the Computer <a class="header-anchor" href="#_6-2-starting-the-computer" aria-label="Permalink to &quot;6.2: Starting the Computer&quot;">&ZeroWidthSpace;</a></h3>
<p>What happens when you press the power button:</p>
<ul>
<li>System searches for Basic Input/Output System (BIOS)</li>
<li>Firmware, locates computer hardware</li>
<li>SS loads the platform (OS) into the computer’s memory: Booting</li>
<li>Powering up the computer for the first time: Cold Boot</li>
<li>Restarting a computer: Warm Boot</li>
<li>Computer will ask for login and load your profile</li>
<li>Preferences, themes, styles, and types of resources set up by the user</li>
<li>Registry loads settings made by the user</li>
<li>Screen savers, appearance, and personalizations</li>
</ul>
<h3 id="_6-3-administering-application-software" tabindex="-1">6.3: Administering Application Software <a class="header-anchor" href="#_6-3-administering-application-software" aria-label="Permalink to &quot;6.3: Administering Application Software&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>When a user clicks on an application, the application info moves from the hard drive to RAM (Random Access Memory)</li>
<li>SS and OS make sure application software works correctly</li>
</ul>
<h3 id="_6-4-memory-management" tabindex="-1">6.4: Memory Management <a class="header-anchor" href="#_6-4-memory-management" aria-label="Permalink to &quot;6.4: Memory Management&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>Computer memory allocation can be compared to a farmer allocating water for crops</li>
<li>Virtual memory: The technique of breaking large files down from the hard drive into smaller, more manageable files that fit in RAM</li>
<li>Smaller files called Pages</li>
<li>If the pages exceed RAM storage, OS will store temporary copies of pages to hard drive</li>
<li>Swap Files: When pages exceed RAM storage, OS swaps pages between hard drive and RAM
Ask yourself: Does your business need new computers or new computer parts?</li>
<li>New computer: $800-1500</li>
<li>Upgraded RAM: $50-$200</li>
<li>Upgraded Hard Drive:$40-$100</li>
</ul>
<h3 id="_6-5-interfacing-and-utilities" tabindex="-1">6.5: Interfacing and Utilities <a class="header-anchor" href="#_6-5-interfacing-and-utilities" aria-label="Permalink to &quot;6.5: Interfacing and Utilities&quot;">&ZeroWidthSpace;</a></h3>
<p>SS in the form of an OS must serve as a translator for both the computer and end user</p>
<ul>
<li>Monitor: displays and renders output an end user can understand</li>
<li>GUI</li>
<li>Icon: A small pictogram on the desktop that a user clicks with a mouse</li>
<li>Window: A GUI unto its own</li>
<li>Device Drivers: allow input and output devices to operate properly</li>
<li>The background displayed on the monitor is considered the desktop environment, or &quot;desktop&quot; for short</li>
<li>Active Window: the window that the user is currently using</li>
</ul>
<h3 id="_6-6-file-management-systems" tabindex="-1">6.6: File Management Systems <a class="header-anchor" href="#_6-6-file-management-systems" aria-label="Permalink to &quot;6.6: File Management Systems&quot;">&ZeroWidthSpace;</a></h3>
<p>Based on a hierarchy of folders that contain computer files. File management systems are searchable and provide information on files:</p>
<ul>
<li>File Name</li>
<li>File Creation Date</li>
<li>File Modification Date</li>
<li>Location of the file</li>
<li>Who created or modified a file</li>
<li>File size</li>
<li>In business, it is important to establish your file management system early</li>
</ul>
<h3 id="_6-7-system-software-utilities" tabindex="-1">6.7: System Software Utilities <a class="header-anchor" href="#_6-7-system-software-utilities" aria-label="Permalink to &quot;6.7: System Software Utilities&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>Tracks: concentric circular bands</li>
<li>Sectors: Tracks that are separated into wedges</li>
<li>Defragmentation: Organizes + and – charges to the innermost tracks of the disk to reduce the amount of time it takes the R/W arm to find the info</li>
</ul>
<h3 id="_6-8-antivirus-utilities" tabindex="-1">6.8: Antivirus Utilities <a class="header-anchor" href="#_6-8-antivirus-utilities" aria-label="Permalink to &quot;6.8: Antivirus Utilities&quot;">&ZeroWidthSpace;</a></h3>
<p>Antivirus Utilities: System software that identifies known viruses to block them from entering and infecting a computer system</p>
<ul>
<li>Utilizes a database of known viruses to cross reference against each incoming file</li>
<li>Subscription service: Norton Antivirus and McAfee VirusScan</li>
</ul>
<h3 id="_6-9-system-updates" tabindex="-1">6.9: System Updates <a class="header-anchor" href="#_6-9-system-updates" aria-label="Permalink to &quot;6.9: System Updates&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>To compensate for OS inadequacies, OS offer a system software utility called system update</li>
<li>Patches sent from Microsoft (or Mac) via the Internet to a user’s computer</li>
</ul>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CIS105: Computer Applications &amp; Information Systems Lect. 6 Pt. 2 ]]></title>
            <link>https://note.toshiki.devacademic/cis105/cis105-l6-pt2-lecture-note</link>
            <guid>https://note.toshiki.devacademic/cis105/cis105-l6-pt2-lecture-note</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="cis105-computer-applications-information-systems-lect-6-pt-2" tabindex="-1">CIS105: Computer Applications &amp; Information Systems Lect. 6 Pt. 2 <a class="header-anchor" href="#cis105-computer-applications-information-systems-lect-6-pt-2" aria-label="Permalink to &quot;CIS105: Computer Applications &amp; Information Systems Lect. 6 Pt. 2&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="chapter-6-logical-functions" tabindex="-1">Chapter 6: Logical Functions <a class="header-anchor" href="#chapter-6-logical-functions" aria-label="Permalink to &quot;Chapter 6: Logical Functions&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="_6-1-new-functions" tabindex="-1">6.1: New Functions <a class="header-anchor" href="#_6-1-new-functions" aria-label="Permalink to &quot;6.1: New Functions&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>
<p><code>AND</code>: Checks whether all arguments are <code>TRUE</code>, and returns <code>TRUE</code> if all arguments are <code>TRUE</code>.</p>
</li>
<li>
<p><code>OR</code>: Checks whether any of the arguments are <code>TRUE</code>, and returns <code>TRUE</code> or <code>FALSE</code>.</p>
</li>
<li>
<p><code>NOT</code>: Changes <code>TRUE</code> to <code>FALSE</code>, or <code>FALSE</code> to <code>TRUE</code>.</p>
</li>
<li>
<p><code>IF</code>: Checks whether a condition is met, and returns one value if <code>TRUE</code>, and another value if <code>FALSE</code>.</p>
<ul>
<li>Nested <code>IF</code>: Using multiple <code>IF</code> statements in one functions to account for multiple conditions.</li>
</ul>
</li>
<li>
<p><code>VLOOKUP</code>: Looks for a value in a table or a range veryically</p>
<ul>
<li><code>VLOOKUP</code> What you want to look up, where you want to look for it, the column number in the range containing the value to return, return an approximate or exact match: Indicates as <code>1/TRUE</code>, or <code>0/FALSE</code>.</li>
</ul>
</li>
<li>
<p><code>HLOOKUP</code>: Looks for a value in a table or a range horizontally.</p>
</li>
<li>
<p><code>COUNTIF</code>: Counts the number of cells within a range that meet the given condition.</p>
<ul>
<li><code>=COUNTIF(Where do you want to look? What do you want to look for?)</code></li>
</ul>
</li>
<li>
<p><code>SUMIF</code>: Adds the cells specified by a given condition or criteria.</p>
</li>
<li>
<p><code>AVERAGEIF</code>: s an Excel Statistical function, which calculates the average of a given range of cells by a specific criterion.</p>
</li>
</ul>
<h3 id="_6-2-comparison-operators" tabindex="-1">6.2: Comparison Operators <a class="header-anchor" href="#_6-2-comparison-operators" aria-label="Permalink to &quot;6.2: Comparison Operators&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li><code>&gt;</code>: More than</li>
<li><code>&lt;</code>: Less than</li>
<li><code>&gt;=</code>: More than or equal to</li>
<li><code>&lt;=</code>: Less that or equal to</li>
</ul>
<h3 id="_6-3-reminder" tabindex="-1">6.3: Reminder <a class="header-anchor" href="#_6-3-reminder" aria-label="Permalink to &quot;6.3: Reminder&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li><strong>Excel does not recognize tex</strong>
<ul>
<li>When searching for keywords, put keyword between <code>&quot;&quot;</code> delimiters.</li>
</ul>
</li>
</ul>
]]></description>
            <content:encoded><![CDATA[<h1 id="cis105-computer-applications-information-systems-lect-6-pt-2" tabindex="-1">CIS105: Computer Applications &amp; Information Systems Lect. 6 Pt. 2 <a class="header-anchor" href="#cis105-computer-applications-information-systems-lect-6-pt-2" aria-label="Permalink to &quot;CIS105: Computer Applications &amp; Information Systems Lect. 6 Pt. 2&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="chapter-6-logical-functions" tabindex="-1">Chapter 6: Logical Functions <a class="header-anchor" href="#chapter-6-logical-functions" aria-label="Permalink to &quot;Chapter 6: Logical Functions&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="_6-1-new-functions" tabindex="-1">6.1: New Functions <a class="header-anchor" href="#_6-1-new-functions" aria-label="Permalink to &quot;6.1: New Functions&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>
<p><code>AND</code>: Checks whether all arguments are <code>TRUE</code>, and returns <code>TRUE</code> if all arguments are <code>TRUE</code>.</p>
</li>
<li>
<p><code>OR</code>: Checks whether any of the arguments are <code>TRUE</code>, and returns <code>TRUE</code> or <code>FALSE</code>.</p>
</li>
<li>
<p><code>NOT</code>: Changes <code>TRUE</code> to <code>FALSE</code>, or <code>FALSE</code> to <code>TRUE</code>.</p>
</li>
<li>
<p><code>IF</code>: Checks whether a condition is met, and returns one value if <code>TRUE</code>, and another value if <code>FALSE</code>.</p>
<ul>
<li>Nested <code>IF</code>: Using multiple <code>IF</code> statements in one functions to account for multiple conditions.</li>
</ul>
</li>
<li>
<p><code>VLOOKUP</code>: Looks for a value in a table or a range veryically</p>
<ul>
<li><code>VLOOKUP</code> What you want to look up, where you want to look for it, the column number in the range containing the value to return, return an approximate or exact match: Indicates as <code>1/TRUE</code>, or <code>0/FALSE</code>.</li>
</ul>
</li>
<li>
<p><code>HLOOKUP</code>: Looks for a value in a table or a range horizontally.</p>
</li>
<li>
<p><code>COUNTIF</code>: Counts the number of cells within a range that meet the given condition.</p>
<ul>
<li><code>=COUNTIF(Where do you want to look? What do you want to look for?)</code></li>
</ul>
</li>
<li>
<p><code>SUMIF</code>: Adds the cells specified by a given condition or criteria.</p>
</li>
<li>
<p><code>AVERAGEIF</code>: s an Excel Statistical function, which calculates the average of a given range of cells by a specific criterion.</p>
</li>
</ul>
<h3 id="_6-2-comparison-operators" tabindex="-1">6.2: Comparison Operators <a class="header-anchor" href="#_6-2-comparison-operators" aria-label="Permalink to &quot;6.2: Comparison Operators&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li><code>&gt;</code>: More than</li>
<li><code>&lt;</code>: Less than</li>
<li><code>&gt;=</code>: More than or equal to</li>
<li><code>&lt;=</code>: Less that or equal to</li>
</ul>
<h3 id="_6-3-reminder" tabindex="-1">6.3: Reminder <a class="header-anchor" href="#_6-3-reminder" aria-label="Permalink to &quot;6.3: Reminder&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li><strong>Excel does not recognize tex</strong>
<ul>
<li>When searching for keywords, put keyword between <code>&quot;&quot;</code> delimiters.</li>
</ul>
</li>
</ul>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CIS105: Computer Applications &amp; Information Systems Lect. 7 ]]></title>
            <link>https://note.toshiki.devacademic/cis105/cis105-l7-lecture-note</link>
            <guid>https://note.toshiki.devacademic/cis105/cis105-l7-lecture-note</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="cis105-computer-applications-information-systems-lect-7" tabindex="-1">CIS105: Computer Applications &amp; Information Systems Lect. 7 <a class="header-anchor" href="#cis105-computer-applications-information-systems-lect-7" aria-label="Permalink to &quot;CIS105: Computer Applications &amp; Information Systems Lect. 7&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="chapter-7-green-business-computing" tabindex="-1">Chapter 7: Green Business Computing <a class="header-anchor" href="#chapter-7-green-business-computing" aria-label="Permalink to &quot;Chapter 7: Green Business Computing&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="_7-1-green-business-computing" tabindex="-1">7.1: Green Business Computing <a class="header-anchor" href="#_7-1-green-business-computing" aria-label="Permalink to &quot;7.1: Green Business Computing&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>Burning fossil fules creates carbon dioxide which builds up and slows the escape of heat into space, called the &quot;greenhouse effect&quot;.</li>
<li><strong>NASA</strong> predicts Earth's surface temperature will increase by 2.5 to 10.4 Fahrenheit by the year 2100. The concern is that human societies and natural ecosystems may not adapt quickly enough.</li>
<li>The National Center for Atmospheric Research (NCAR) in charge of creating and maintaining climate computer models that are used to predict weather admit they are flawed and unreliable.</li>
<li>Who's right, ASA or NCAR?</li>
</ul>
<h3 id="_7-2-climate-change" tabindex="-1">7.2: Climate Change <a class="header-anchor" href="#_7-2-climate-change" aria-label="Permalink to &quot;7.2: Climate Change&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>Whether global warming exists is a discussion that requires critical thoughtfullnesswith a minimum of passion.</li>
<li>It is virtually impossible to not come across terminologies like &quot;green&quot; or challenges, and potential sustainable solutions have gained traction and must be dealt with.</li>
<li>Regardless of differing views, climate change has gained diffusion and acceptance as an acknowledged problem that will drive business for many years to come. Environmental responsibility and global governance is simply the right things to do.</li>
</ul>
<h3 id="_7-3-it-challenges-and-opportunities" tabindex="-1">7.3: IT Challenges and Opportunities <a class="header-anchor" href="#_7-3-it-challenges-and-opportunities" aria-label="Permalink to &quot;7.3: IT Challenges and Opportunities&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>Chief technology officers (in charge of all business computing assets) meed to be concerned with overall energy costs associated with computing systems.</li>
<li>Electronic Product Environmental Assessment Tool (EPEAT)
<ul>
<li>Started by the Environmental Protection Agency in 2006.</li>
<li>Managed by the Green Electronics Council (GEC)</li>
<li>Easy to use online tool</li>
</ul>
</li>
</ul>
<h3 id="_7-4-epeat-criteria" tabindex="-1">7.4: EPEAT Criteria <a class="header-anchor" href="#_7-4-epeat-criteria" aria-label="Permalink to &quot;7.4: EPEAT Criteria&quot;">&ZeroWidthSpace;</a></h3>
<p>EPEAT evaluates electronic products relative to 51 environmental criteria, 23 required and 28 optional. Computer manufacturers that meet a certain criteria are awarded a gold, silver, or bronze star allowing the consumer to differentiate products.</p>
<ul>
<li>
<p><strong>Reduction or elimination of environmentally sensitive materials</strong>. Computers contain potentially harmful chemicals like cadmium, mercury, and chromium. EPEAT Encourages manufacturers to reduce or eliminate them altogether.</p>
</li>
<li>
<p><strong>Materials Selection</strong> informs the consumer of the percentage of recycled plastic and offers a declaration of percentage of renewable/bio-based plastic material content.</p>
</li>
<li>
<p><strong>Design for End of Life</strong> informs consumers about special handling needs for disposing of their product when it no longer useful.</p>
</li>
<li>
<p><strong>Product Longevity/Life Cycle Extension</strong> encourages manufacturers to make extended warranties available so their product lasts longer or available to be upgraded.</p>
</li>
<li>
<p><strong>End of Life Management</strong> asks manufacturers to take their product back at the end of the product’s life, at no cost to the consumer.</p>
</li>
<li>
<p><strong>Corporate Performance</strong> means a manufacturer demonstrates a sound corporate environmental policy throughout their business.</p>
</li>
<li>
<p><strong>Packaging</strong> criteria requires manufacturers to reduce or eliminate intentionally added toxins in packaging.</p>
</li>
<li>
<p><strong>Energy Conservation</strong> asks manufacturers to adopt the government’s Energy Star® specifications.</p>
</li>
</ul>
<p>EPEAT criteria seems difficult and expensive for a gold star, so why would manufacturers be willing to comply? Had you ever heard of EPEAT? Did you base your last computer purchase on EPEAT criteria? If you were aware of EPEAT, would you pay more just to be green? What if your business pays significantly more for EPEAT computers and your competitor doesn’t, did they get an edge?</p>
<h3 id="_7-5-energy-star®-specifications" tabindex="-1">7.5: <strong>Energy Star® Specifications</strong> <a class="header-anchor" href="#_7-5-energy-star®-specifications" aria-label="Permalink to &quot;7.5: **Energy Star® Specifications**&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>
<p>Started in 1772 as a voluntary labeling program to identify and promote energy efficient products.</p>
</li>
<li>
<p>Energy Star® claims that if every computer in the United States met Energy Star® requirements, the savings in energy costs alone will grow to about $2 billion each year and greenhouse gas emissions would be reduced by the the equivalent of that from 2 million cars.</p>
</li>
<li>
<p>In many instances, Energy Star® computers are more expensive to purchase but are far more efficient and cost effective in the long run</p>
</li>
</ul>
<h3 id="_7-6-the-green-pc" tabindex="-1">7.6: The Green PC <a class="header-anchor" href="#_7-6-the-green-pc" aria-label="Permalink to &quot;7.6: The Green PC&quot;">&ZeroWidthSpace;</a></h3>
<p>A Green PC is a personal computer that is environmentally friendly and includes the following:</p>
<ul>
<li>
<p>Energy-efficient power supplies</p>
</li>
<li>
<p>Includes processors that consume minimum amounts of electricity</p>
</li>
<li>
<p>Attempt to do away with or minimize environmentally harmful components</p>
</li>
<li>
<p>Makes use of aluminum or plastic parts from recycled materials</p>
</li>
</ul>
<p>The most important factor in a Green PC is energy efficiency</p>
<h3 id="_7-7-modes" tabindex="-1">7.7: <strong>Modes</strong> <a class="header-anchor" href="#_7-7-modes" aria-label="Permalink to &quot;7.7: **Modes**&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>
<p><strong>Active Use</strong>: The computer is on and being use</p>
</li>
<li>
<p><strong>Sleep Mode</strong>: Low power after a designated period of time</p>
</li>
<li>
<p><strong>Standby Mode</strong> (Off): Turns off after designated period of time</p>
</li>
</ul>
<h3 id="_7-8-green-business-computing-plan" tabindex="-1">7.8: Green Business Computing Plan <a class="header-anchor" href="#_7-8-green-business-computing-plan" aria-label="Permalink to &quot;7.8: Green Business Computing Plan&quot;">&ZeroWidthSpace;</a></h3>
<p>Based on the idea that businesses can be environmentally friendly, more profitable, and socially responsible.</p>
<ul>
<li>
<p>Organizational policies and procedures</p>
</li>
<li>
<p>Best Practice considerations</p>
</li>
<li>
<p>Long term, sustainable considerations</p>
</li>
<li>
<p>Reduction of power usage and paper consumption</p>
</li>
<li>
<p>Recycling policies and procedures</p>
</li>
<li>
<p>Used computer software and hardware disposal</p>
</li>
<li>
<p>EPEAT and Energy Star® compliance</p>
</li>
<li>
<p>Green PC purchasing recommendations</p>
</li>
</ul>
]]></description>
            <content:encoded><![CDATA[<h1 id="cis105-computer-applications-information-systems-lect-7" tabindex="-1">CIS105: Computer Applications &amp; Information Systems Lect. 7 <a class="header-anchor" href="#cis105-computer-applications-information-systems-lect-7" aria-label="Permalink to &quot;CIS105: Computer Applications &amp; Information Systems Lect. 7&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="chapter-7-green-business-computing" tabindex="-1">Chapter 7: Green Business Computing <a class="header-anchor" href="#chapter-7-green-business-computing" aria-label="Permalink to &quot;Chapter 7: Green Business Computing&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="_7-1-green-business-computing" tabindex="-1">7.1: Green Business Computing <a class="header-anchor" href="#_7-1-green-business-computing" aria-label="Permalink to &quot;7.1: Green Business Computing&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>Burning fossil fules creates carbon dioxide which builds up and slows the escape of heat into space, called the &quot;greenhouse effect&quot;.</li>
<li><strong>NASA</strong> predicts Earth's surface temperature will increase by 2.5 to 10.4 Fahrenheit by the year 2100. The concern is that human societies and natural ecosystems may not adapt quickly enough.</li>
<li>The National Center for Atmospheric Research (NCAR) in charge of creating and maintaining climate computer models that are used to predict weather admit they are flawed and unreliable.</li>
<li>Who's right, ASA or NCAR?</li>
</ul>
<h3 id="_7-2-climate-change" tabindex="-1">7.2: Climate Change <a class="header-anchor" href="#_7-2-climate-change" aria-label="Permalink to &quot;7.2: Climate Change&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>Whether global warming exists is a discussion that requires critical thoughtfullnesswith a minimum of passion.</li>
<li>It is virtually impossible to not come across terminologies like &quot;green&quot; or challenges, and potential sustainable solutions have gained traction and must be dealt with.</li>
<li>Regardless of differing views, climate change has gained diffusion and acceptance as an acknowledged problem that will drive business for many years to come. Environmental responsibility and global governance is simply the right things to do.</li>
</ul>
<h3 id="_7-3-it-challenges-and-opportunities" tabindex="-1">7.3: IT Challenges and Opportunities <a class="header-anchor" href="#_7-3-it-challenges-and-opportunities" aria-label="Permalink to &quot;7.3: IT Challenges and Opportunities&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>Chief technology officers (in charge of all business computing assets) meed to be concerned with overall energy costs associated with computing systems.</li>
<li>Electronic Product Environmental Assessment Tool (EPEAT)
<ul>
<li>Started by the Environmental Protection Agency in 2006.</li>
<li>Managed by the Green Electronics Council (GEC)</li>
<li>Easy to use online tool</li>
</ul>
</li>
</ul>
<h3 id="_7-4-epeat-criteria" tabindex="-1">7.4: EPEAT Criteria <a class="header-anchor" href="#_7-4-epeat-criteria" aria-label="Permalink to &quot;7.4: EPEAT Criteria&quot;">&ZeroWidthSpace;</a></h3>
<p>EPEAT evaluates electronic products relative to 51 environmental criteria, 23 required and 28 optional. Computer manufacturers that meet a certain criteria are awarded a gold, silver, or bronze star allowing the consumer to differentiate products.</p>
<ul>
<li>
<p><strong>Reduction or elimination of environmentally sensitive materials</strong>. Computers contain potentially harmful chemicals like cadmium, mercury, and chromium. EPEAT Encourages manufacturers to reduce or eliminate them altogether.</p>
</li>
<li>
<p><strong>Materials Selection</strong> informs the consumer of the percentage of recycled plastic and offers a declaration of percentage of renewable/bio-based plastic material content.</p>
</li>
<li>
<p><strong>Design for End of Life</strong> informs consumers about special handling needs for disposing of their product when it no longer useful.</p>
</li>
<li>
<p><strong>Product Longevity/Life Cycle Extension</strong> encourages manufacturers to make extended warranties available so their product lasts longer or available to be upgraded.</p>
</li>
<li>
<p><strong>End of Life Management</strong> asks manufacturers to take their product back at the end of the product’s life, at no cost to the consumer.</p>
</li>
<li>
<p><strong>Corporate Performance</strong> means a manufacturer demonstrates a sound corporate environmental policy throughout their business.</p>
</li>
<li>
<p><strong>Packaging</strong> criteria requires manufacturers to reduce or eliminate intentionally added toxins in packaging.</p>
</li>
<li>
<p><strong>Energy Conservation</strong> asks manufacturers to adopt the government’s Energy Star® specifications.</p>
</li>
</ul>
<p>EPEAT criteria seems difficult and expensive for a gold star, so why would manufacturers be willing to comply? Had you ever heard of EPEAT? Did you base your last computer purchase on EPEAT criteria? If you were aware of EPEAT, would you pay more just to be green? What if your business pays significantly more for EPEAT computers and your competitor doesn’t, did they get an edge?</p>
<h3 id="_7-5-energy-star®-specifications" tabindex="-1">7.5: <strong>Energy Star® Specifications</strong> <a class="header-anchor" href="#_7-5-energy-star®-specifications" aria-label="Permalink to &quot;7.5: **Energy Star® Specifications**&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>
<p>Started in 1772 as a voluntary labeling program to identify and promote energy efficient products.</p>
</li>
<li>
<p>Energy Star® claims that if every computer in the United States met Energy Star® requirements, the savings in energy costs alone will grow to about $2 billion each year and greenhouse gas emissions would be reduced by the the equivalent of that from 2 million cars.</p>
</li>
<li>
<p>In many instances, Energy Star® computers are more expensive to purchase but are far more efficient and cost effective in the long run</p>
</li>
</ul>
<h3 id="_7-6-the-green-pc" tabindex="-1">7.6: The Green PC <a class="header-anchor" href="#_7-6-the-green-pc" aria-label="Permalink to &quot;7.6: The Green PC&quot;">&ZeroWidthSpace;</a></h3>
<p>A Green PC is a personal computer that is environmentally friendly and includes the following:</p>
<ul>
<li>
<p>Energy-efficient power supplies</p>
</li>
<li>
<p>Includes processors that consume minimum amounts of electricity</p>
</li>
<li>
<p>Attempt to do away with or minimize environmentally harmful components</p>
</li>
<li>
<p>Makes use of aluminum or plastic parts from recycled materials</p>
</li>
</ul>
<p>The most important factor in a Green PC is energy efficiency</p>
<h3 id="_7-7-modes" tabindex="-1">7.7: <strong>Modes</strong> <a class="header-anchor" href="#_7-7-modes" aria-label="Permalink to &quot;7.7: **Modes**&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>
<p><strong>Active Use</strong>: The computer is on and being use</p>
</li>
<li>
<p><strong>Sleep Mode</strong>: Low power after a designated period of time</p>
</li>
<li>
<p><strong>Standby Mode</strong> (Off): Turns off after designated period of time</p>
</li>
</ul>
<h3 id="_7-8-green-business-computing-plan" tabindex="-1">7.8: Green Business Computing Plan <a class="header-anchor" href="#_7-8-green-business-computing-plan" aria-label="Permalink to &quot;7.8: Green Business Computing Plan&quot;">&ZeroWidthSpace;</a></h3>
<p>Based on the idea that businesses can be environmentally friendly, more profitable, and socially responsible.</p>
<ul>
<li>
<p>Organizational policies and procedures</p>
</li>
<li>
<p>Best Practice considerations</p>
</li>
<li>
<p>Long term, sustainable considerations</p>
</li>
<li>
<p>Reduction of power usage and paper consumption</p>
</li>
<li>
<p>Recycling policies and procedures</p>
</li>
<li>
<p>Used computer software and hardware disposal</p>
</li>
<li>
<p>EPEAT and Energy Star® compliance</p>
</li>
<li>
<p>Green PC purchasing recommendations</p>
</li>
</ul>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CIS105: Computer Applications &amp; Information Systems Lect. 8 ]]></title>
            <link>https://note.toshiki.devacademic/cis105/cis105-l8-lecture-note</link>
            <guid>https://note.toshiki.devacademic/cis105/cis105-l8-lecture-note</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="cis105-computer-applications-information-systems-lect-8" tabindex="-1">CIS105: Computer Applications &amp; Information Systems Lect. 8 <a class="header-anchor" href="#cis105-computer-applications-information-systems-lect-8" aria-label="Permalink to &quot;CIS105: Computer Applications &amp; Information Systems Lect. 8&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="chapter-8-computer-networks" tabindex="-1">Chapter 8: Computer Networks <a class="header-anchor" href="#chapter-8-computer-networks" aria-label="Permalink to &quot;Chapter 8: Computer Networks&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="_8-1-computer-networks" tabindex="-1">8.1: Computer Networks <a class="header-anchor" href="#_8-1-computer-networks" aria-label="Permalink to &quot;8.1: Computer Networks&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>Two or more computers connected together to share resources like:</li>
<li>Folders and files</li>
<li>Software</li>
<li>Hardware</li>
<li>Scanners, Printers, Webcams, etc.
Consider a network made up of three computers (Clients) connected to one computer called a Server. The server is connected to a printer and a scanner (peripheral devices) enabling all three clients to use them. Any device connected to a network is called a node.</li>
</ul>
<h3 id="_8-2-building-a-computer-network" tabindex="-1">8.2: Building a Computer Network <a class="header-anchor" href="#_8-2-building-a-computer-network" aria-label="Permalink to &quot;8.2: Building a Computer Network&quot;">&ZeroWidthSpace;</a></h3>
<p>All networks require four basic components</p>
<ol>
<li>Network Interface Controller Card (NIC): Plugged into the motherboard to interface and connect with other computers.</li>
<li>Protocol: TCP/IP controls how data and information is shared between computers.</li>
<li>Cables: Cables connect servers to clients which can sometimes be replaced through wireless connections.</li>
<li>Hub: Typically, the central location of a network (server) that serves to run the network smoothly</li>
</ol>
<h3 id="_8-3-network-protocols" tabindex="-1">8.3: Network Protocols <a class="header-anchor" href="#_8-3-network-protocols" aria-label="Permalink to &quot;8.3: Network Protocols&quot;">&ZeroWidthSpace;</a></h3>
<p>Provides a common language and rules for communication between computers. A protocol is a convention or standard that controls or allows communication and data transfer between two computers.</p>
<ul>
<li>Transmission Control Protocol / Internet Protocol (TCP/IP): When sending a file from one computer to another, the file is broken down into smaller files called “packets”. The packets arrive at the receiving computer and must be reassembled correctly to guarantee the receiving computer gets a file that will work (not corrupted).</li>
<li>User Datagram Packets: Break large files into packets, but unlike TCP/IP, allows a user to use the incoming file.</li>
</ul>
<h3 id="_8-4-network-operating-systems" tabindex="-1">8.4: Network Operating Systems <a class="header-anchor" href="#_8-4-network-operating-systems" aria-label="Permalink to &quot;8.4: Network Operating Systems&quot;">&ZeroWidthSpace;</a></h3>
<p>A Network Operating System (NOS) is similar to a stand-alone platform but responsible for much more:</p>
<ul>
<li>Automatic hardware detection. The NOS recognizes it when it becomes part of the network.</li>
<li>Supports multi-processing which allows several processes to occur at one time.</li>
<li>Recognizes who is using the network.</li>
<li>Provides security</li>
</ul>
<h3 id="_8-5-network-administrator" tabindex="-1">8.5: Network Administrator <a class="header-anchor" href="#_8-5-network-administrator" aria-label="Permalink to &quot;8.5: Network Administrator&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>Responsible for smooth network operations</li>
<li>Network performance</li>
<li>Implementation of new nodes and users</li>
<li>Strong business background</li>
</ul>
<h3 id="_8-6-network-topology" tabindex="-1">8.6: Network Topology <a class="header-anchor" href="#_8-6-network-topology" aria-label="Permalink to &quot;8.6: Network Topology&quot;">&ZeroWidthSpace;</a></h3>
<p>Refers to the mapping of a physical network and logical interconnections between nodes. Basically, the way a network is arranged and laid out.</p>
<ul>
<li>Bus Topology: Sometimes called a linear bus topology where the network’s nodes are connected to a common linear backbone with tw endpoints. If the backbone fails, the whole network fails.</li>
<li>Star Topology: One central server in which clients connect in a spoke- like fashion, or star. If the server fails, the network fails. (Most common topology)</li>
<li>Ring Topology: Data is transferred between computers in a circular manner.</li>
</ul>
<h3 id="_8-7-types-of-computer-networks" tabindex="-1">8.7: Types of Computer Networks <a class="header-anchor" href="#_8-7-types-of-computer-networks" aria-label="Permalink to &quot;8.7: Types of Computer Networks&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>Local Area Network (LAN): A small network typically confined by a single building. Often used by smaller businesses.</li>
<li>Campus Area Network (CAN): Connects two or more LANs which are located on universities or large businesses.</li>
<li>Metropolitan Area Network (MAN): A computer network that connects CANs and LANs into a larger network like a city.</li>
<li>Wide Area Network (WAN): Connects LANs, CANs, and MANs and can cover an entire country</li>
<li>Peer to Peer (P2P): Generally, connect computers to each other.</li>
<li>Internet: The world’s largest network interconnecting public, private, commercial, and governmental networks. Network Security Starts with a solid understanding of network threats. Network administrators must adopt policies which define rules for network access.</li>
<li>Passwords: A secret word or combination of keyboard characters typed in by the user to authenticate their identity to a network and gain appropriate access.</li>
<li>Strong Passwords: Same as passwords, but requires a user to use upper case characters, lower case characters, numbers, and special characters.</li>
<li>Passphrase: Same as a Strong Password, but a phrase that is memorable.</li>
</ul>
<h3 id="_8-8-network-security" tabindex="-1">8.8: Network Security <a class="header-anchor" href="#_8-8-network-security" aria-label="Permalink to &quot;8.8: Network Security&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>Web Browsing on a Network: Part of network security includes policies and procedures regarding employee’s web browsing. Should a business let employees browse on the Web?</li>
<li>Email / Instant Messaging: On a business network, consider that all email and instant message is recorded and saved, therefore, policies and procedures must be in place regarding appropriate usage.</li>
<li>Permissions: Network access is called “permissions”, which grants and denies access to a network depending on the user.</li>
<li>Firewall: Hardware and software on a proxy server that determines who is allowed on a network, and who is not.</li>
</ul>
<h3 id="_8-9-green-business-computing-plan" tabindex="-1">8.9: Green Business Computing Plan <a class="header-anchor" href="#_8-9-green-business-computing-plan" aria-label="Permalink to &quot;8.9: Green Business Computing Plan&quot;">&ZeroWidthSpace;</a></h3>
<p>Based on the idea that businesses can be environmentally friendly, more profitable, and socially responsible.</p>
<ul>
<li>Organizational policies and procedures</li>
<li>Best Practice considerations</li>
<li>Long term, sustainable considerations</li>
<li>Reduction of power usage and paper consumption</li>
<li>Recycling policies and procedures</li>
<li>Used computer software and hardware disposal</li>
<li>EPEAT and Energy Star® compliance</li>
<li>Green PC purchasing recommendations</li>
</ul>
]]></description>
            <content:encoded><![CDATA[<h1 id="cis105-computer-applications-information-systems-lect-8" tabindex="-1">CIS105: Computer Applications &amp; Information Systems Lect. 8 <a class="header-anchor" href="#cis105-computer-applications-information-systems-lect-8" aria-label="Permalink to &quot;CIS105: Computer Applications &amp; Information Systems Lect. 8&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="chapter-8-computer-networks" tabindex="-1">Chapter 8: Computer Networks <a class="header-anchor" href="#chapter-8-computer-networks" aria-label="Permalink to &quot;Chapter 8: Computer Networks&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="_8-1-computer-networks" tabindex="-1">8.1: Computer Networks <a class="header-anchor" href="#_8-1-computer-networks" aria-label="Permalink to &quot;8.1: Computer Networks&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>Two or more computers connected together to share resources like:</li>
<li>Folders and files</li>
<li>Software</li>
<li>Hardware</li>
<li>Scanners, Printers, Webcams, etc.
Consider a network made up of three computers (Clients) connected to one computer called a Server. The server is connected to a printer and a scanner (peripheral devices) enabling all three clients to use them. Any device connected to a network is called a node.</li>
</ul>
<h3 id="_8-2-building-a-computer-network" tabindex="-1">8.2: Building a Computer Network <a class="header-anchor" href="#_8-2-building-a-computer-network" aria-label="Permalink to &quot;8.2: Building a Computer Network&quot;">&ZeroWidthSpace;</a></h3>
<p>All networks require four basic components</p>
<ol>
<li>Network Interface Controller Card (NIC): Plugged into the motherboard to interface and connect with other computers.</li>
<li>Protocol: TCP/IP controls how data and information is shared between computers.</li>
<li>Cables: Cables connect servers to clients which can sometimes be replaced through wireless connections.</li>
<li>Hub: Typically, the central location of a network (server) that serves to run the network smoothly</li>
</ol>
<h3 id="_8-3-network-protocols" tabindex="-1">8.3: Network Protocols <a class="header-anchor" href="#_8-3-network-protocols" aria-label="Permalink to &quot;8.3: Network Protocols&quot;">&ZeroWidthSpace;</a></h3>
<p>Provides a common language and rules for communication between computers. A protocol is a convention or standard that controls or allows communication and data transfer between two computers.</p>
<ul>
<li>Transmission Control Protocol / Internet Protocol (TCP/IP): When sending a file from one computer to another, the file is broken down into smaller files called “packets”. The packets arrive at the receiving computer and must be reassembled correctly to guarantee the receiving computer gets a file that will work (not corrupted).</li>
<li>User Datagram Packets: Break large files into packets, but unlike TCP/IP, allows a user to use the incoming file.</li>
</ul>
<h3 id="_8-4-network-operating-systems" tabindex="-1">8.4: Network Operating Systems <a class="header-anchor" href="#_8-4-network-operating-systems" aria-label="Permalink to &quot;8.4: Network Operating Systems&quot;">&ZeroWidthSpace;</a></h3>
<p>A Network Operating System (NOS) is similar to a stand-alone platform but responsible for much more:</p>
<ul>
<li>Automatic hardware detection. The NOS recognizes it when it becomes part of the network.</li>
<li>Supports multi-processing which allows several processes to occur at one time.</li>
<li>Recognizes who is using the network.</li>
<li>Provides security</li>
</ul>
<h3 id="_8-5-network-administrator" tabindex="-1">8.5: Network Administrator <a class="header-anchor" href="#_8-5-network-administrator" aria-label="Permalink to &quot;8.5: Network Administrator&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>Responsible for smooth network operations</li>
<li>Network performance</li>
<li>Implementation of new nodes and users</li>
<li>Strong business background</li>
</ul>
<h3 id="_8-6-network-topology" tabindex="-1">8.6: Network Topology <a class="header-anchor" href="#_8-6-network-topology" aria-label="Permalink to &quot;8.6: Network Topology&quot;">&ZeroWidthSpace;</a></h3>
<p>Refers to the mapping of a physical network and logical interconnections between nodes. Basically, the way a network is arranged and laid out.</p>
<ul>
<li>Bus Topology: Sometimes called a linear bus topology where the network’s nodes are connected to a common linear backbone with tw endpoints. If the backbone fails, the whole network fails.</li>
<li>Star Topology: One central server in which clients connect in a spoke- like fashion, or star. If the server fails, the network fails. (Most common topology)</li>
<li>Ring Topology: Data is transferred between computers in a circular manner.</li>
</ul>
<h3 id="_8-7-types-of-computer-networks" tabindex="-1">8.7: Types of Computer Networks <a class="header-anchor" href="#_8-7-types-of-computer-networks" aria-label="Permalink to &quot;8.7: Types of Computer Networks&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>Local Area Network (LAN): A small network typically confined by a single building. Often used by smaller businesses.</li>
<li>Campus Area Network (CAN): Connects two or more LANs which are located on universities or large businesses.</li>
<li>Metropolitan Area Network (MAN): A computer network that connects CANs and LANs into a larger network like a city.</li>
<li>Wide Area Network (WAN): Connects LANs, CANs, and MANs and can cover an entire country</li>
<li>Peer to Peer (P2P): Generally, connect computers to each other.</li>
<li>Internet: The world’s largest network interconnecting public, private, commercial, and governmental networks. Network Security Starts with a solid understanding of network threats. Network administrators must adopt policies which define rules for network access.</li>
<li>Passwords: A secret word or combination of keyboard characters typed in by the user to authenticate their identity to a network and gain appropriate access.</li>
<li>Strong Passwords: Same as passwords, but requires a user to use upper case characters, lower case characters, numbers, and special characters.</li>
<li>Passphrase: Same as a Strong Password, but a phrase that is memorable.</li>
</ul>
<h3 id="_8-8-network-security" tabindex="-1">8.8: Network Security <a class="header-anchor" href="#_8-8-network-security" aria-label="Permalink to &quot;8.8: Network Security&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>Web Browsing on a Network: Part of network security includes policies and procedures regarding employee’s web browsing. Should a business let employees browse on the Web?</li>
<li>Email / Instant Messaging: On a business network, consider that all email and instant message is recorded and saved, therefore, policies and procedures must be in place regarding appropriate usage.</li>
<li>Permissions: Network access is called “permissions”, which grants and denies access to a network depending on the user.</li>
<li>Firewall: Hardware and software on a proxy server that determines who is allowed on a network, and who is not.</li>
</ul>
<h3 id="_8-9-green-business-computing-plan" tabindex="-1">8.9: Green Business Computing Plan <a class="header-anchor" href="#_8-9-green-business-computing-plan" aria-label="Permalink to &quot;8.9: Green Business Computing Plan&quot;">&ZeroWidthSpace;</a></h3>
<p>Based on the idea that businesses can be environmentally friendly, more profitable, and socially responsible.</p>
<ul>
<li>Organizational policies and procedures</li>
<li>Best Practice considerations</li>
<li>Long term, sustainable considerations</li>
<li>Reduction of power usage and paper consumption</li>
<li>Recycling policies and procedures</li>
<li>Used computer software and hardware disposal</li>
<li>EPEAT and Energy Star® compliance</li>
<li>Green PC purchasing recommendations</li>
</ul>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CIS105: Computer Applications &amp; Information Systems Lect. 9 ]]></title>
            <link>https://note.toshiki.devacademic/cis105/cis105-l9-lecture-note</link>
            <guid>https://note.toshiki.devacademic/cis105/cis105-l9-lecture-note</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="cis105-computer-applications-information-systems-lect-9" tabindex="-1">CIS105: Computer Applications &amp; Information Systems Lect. 9 <a class="header-anchor" href="#cis105-computer-applications-information-systems-lect-9" aria-label="Permalink to &quot;CIS105: Computer Applications &amp; Information Systems Lect. 9&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="chapter-9-internet" tabindex="-1">Chapter 9: Internet <a class="header-anchor" href="#chapter-9-internet" aria-label="Permalink to &quot;Chapter 9: Internet&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="_9-1-internet-history" tabindex="-1">9.1: Internet History <a class="header-anchor" href="#_9-1-internet-history" aria-label="Permalink to &quot;9.1: Internet History&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>1969: University of California Los Angeles (UCLA) created the Advanced Research Project Agency Network (ARPANET)</li>
<li>1989: Hypertext Transfer Protocol (HTTP) / World Wide Web (WWW)</li>
<li>1993: Hypertext Markup Langauge (HTML)</li>
</ul>
<h3 id="_9-2-internet-and-www-structure" tabindex="-1">9.2: Internet and WWW Structure <a class="header-anchor" href="#_9-2-internet-and-www-structure" aria-label="Permalink to &quot;9.2: Internet and WWW Structure&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>he internet is a network called the Client/Server Model</li>
<li>The browser application software interprets HTML and HTTP to create web pages</li>
<li>Everything on the internet lives somewhere physically; the trick is using computer addresses to send info from one place to another</li>
</ul>
<h3 id="_9-3-internet-addresses" tabindex="-1">9.3: Internet Addresses <a class="header-anchor" href="#_9-3-internet-addresses" aria-label="Permalink to &quot;9.3: Internet Addresses&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>Internet Protocol Address (IP): An address system used to identify and communicate through the network</li>
<li>Uniform Resource Locators (URLs)
<ul>
<li><code>https://asu.edu</code></li>
<li><code>https</code>: refers to standard protocol</li>
<li><code>www</code>: refers to the world wide web</li>
<li><code>Canvas.asu</code>: domain name</li>
<li><code>.edu</code>: a top-level domain code or extension</li>
</ul>
</li>
</ul>
<h3 id="_9-4-9-5-websites-browsers" tabindex="-1">9.4/9.5: Websites/Browsers <a class="header-anchor" href="#_9-4-9-5-websites-browsers" aria-label="Permalink to &quot;9.4/9.5: Websites/Browsers&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>Website: A collection of web pages on a server that exists on the web that can be requested by a client and displayed with a browser</li>
<li>Hyperlink: Clickable navigation element</li>
<li>Browser: An application software that provides an interface for the WWW</li>
<li>Aspects of a good website:
<ul>
<li>Content</li>
<li>Interactivity</li>
<li>Design</li>
</ul>
</li>
</ul>
<h3 id="_9-6-browser-features" tabindex="-1">9.6: Browser Features <a class="header-anchor" href="#_9-6-browser-features" aria-label="Permalink to &quot;9.6: Browser Features&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>Common Browser Features
<ul>
<li>Bookmarks: AKA favorites</li>
<li>Caching: Just like a CPU cache on the internet</li>
<li>Cookies: Text files used to track info about users</li>
<li>Graphics File (GIF, JPEG): Images and videos</li>
<li>Javascript: A programming language
<ul>
<li>Used to make websites dynamics; Ex: Countdown timer</li>
</ul>
</li>
</ul>
</li>
<li>Browser Considerations:
<ul>
<li>Security</li>
<li>Popup Blockers</li>
<li>Usability</li>
</ul>
</li>
</ul>
<h3 id="_9-7-internet-service-providers-isp" tabindex="-1">9.7: Internet Service Providers (ISP) <a class="header-anchor" href="#_9-7-internet-service-providers-isp" aria-label="Permalink to &quot;9.7: Internet Service Providers (ISP)&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>Connectivity: When one computer connects to another and shares info &amp; resources</li>
<li>Internet Service Providers (ISP)
<ul>
<li>Dial-up &amp; Digital Subscriber Line (DSL)</li>
<li>Broadband Internet Access</li>
<li>Web Hosting</li>
</ul>
</li>
</ul>
<h3 id="_9-8-search-engines" tabindex="-1">9.8: Search Engines <a class="header-anchor" href="#_9-8-search-engines" aria-label="Permalink to &quot;9.8: Search Engines&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>Search engine: A website that lets a user type in specific key words or phrases and then return a list of hyperlinks that best match the search criteria
<ul>
<li>Google, Bing, Yahoo</li>
<li>Directory searches</li>
<li>Metasearch Engines
<ul>
<li>Ex: Dogpile</li>
</ul>
</li>
</ul>
</li>
</ul>
<h3 id="_9-9-e-commerce" tabindex="-1">9.9: E-Commerce <a class="header-anchor" href="#_9-9-e-commerce" aria-label="Permalink to &quot;9.9: E-Commerce&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>Electronic Commerce (E-Commerce): The distribution, buying, selling, advertising, and marketing of goods and services over the web
<ul>
<li>Business-to-Business (B2B)</li>
<li>Business-to-Consumer (B2C)</li>
<li>Consumer-to-Consumer (C2C)</li>
</ul>
</li>
<li>The rules of business still apply to online environments</li>
</ul>
<h3 id="_9-10-security" tabindex="-1">9.10: Security <a class="header-anchor" href="#_9-10-security" aria-label="Permalink to &quot;9.10: Security&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>Malware: Software designed to damage a computer's system without the owner's knowledge
<ul>
<li>Virus</li>
<li>Worms</li>
<li>Trojan Horse</li>
<li>Spyware</li>
<li>Adware</li>
</ul>
</li>
</ul>
<h3 id="_9-11-9-12-email-email-security" tabindex="-1">9.11/9.12: Email/Email Security <a class="header-anchor" href="#_9-11-9-12-email-email-security" aria-label="Permalink to &quot;9.11/9.12: Email/Email Security&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>Email: &quot;A store and forward&quot; system of composing, sending, storing, and receiving message over electronic communication systems.</li>
<li>Never send an email you wouldn't be willing to say in public</li>
<li>Phishing: An email that looks official but is malicious in nature</li>
<li>Spam: Unwanted mail</li>
</ul>
]]></description>
            <content:encoded><![CDATA[<h1 id="cis105-computer-applications-information-systems-lect-9" tabindex="-1">CIS105: Computer Applications &amp; Information Systems Lect. 9 <a class="header-anchor" href="#cis105-computer-applications-information-systems-lect-9" aria-label="Permalink to &quot;CIS105: Computer Applications &amp; Information Systems Lect. 9&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="chapter-9-internet" tabindex="-1">Chapter 9: Internet <a class="header-anchor" href="#chapter-9-internet" aria-label="Permalink to &quot;Chapter 9: Internet&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="_9-1-internet-history" tabindex="-1">9.1: Internet History <a class="header-anchor" href="#_9-1-internet-history" aria-label="Permalink to &quot;9.1: Internet History&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>1969: University of California Los Angeles (UCLA) created the Advanced Research Project Agency Network (ARPANET)</li>
<li>1989: Hypertext Transfer Protocol (HTTP) / World Wide Web (WWW)</li>
<li>1993: Hypertext Markup Langauge (HTML)</li>
</ul>
<h3 id="_9-2-internet-and-www-structure" tabindex="-1">9.2: Internet and WWW Structure <a class="header-anchor" href="#_9-2-internet-and-www-structure" aria-label="Permalink to &quot;9.2: Internet and WWW Structure&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>he internet is a network called the Client/Server Model</li>
<li>The browser application software interprets HTML and HTTP to create web pages</li>
<li>Everything on the internet lives somewhere physically; the trick is using computer addresses to send info from one place to another</li>
</ul>
<h3 id="_9-3-internet-addresses" tabindex="-1">9.3: Internet Addresses <a class="header-anchor" href="#_9-3-internet-addresses" aria-label="Permalink to &quot;9.3: Internet Addresses&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>Internet Protocol Address (IP): An address system used to identify and communicate through the network</li>
<li>Uniform Resource Locators (URLs)
<ul>
<li><code>https://asu.edu</code></li>
<li><code>https</code>: refers to standard protocol</li>
<li><code>www</code>: refers to the world wide web</li>
<li><code>Canvas.asu</code>: domain name</li>
<li><code>.edu</code>: a top-level domain code or extension</li>
</ul>
</li>
</ul>
<h3 id="_9-4-9-5-websites-browsers" tabindex="-1">9.4/9.5: Websites/Browsers <a class="header-anchor" href="#_9-4-9-5-websites-browsers" aria-label="Permalink to &quot;9.4/9.5: Websites/Browsers&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>Website: A collection of web pages on a server that exists on the web that can be requested by a client and displayed with a browser</li>
<li>Hyperlink: Clickable navigation element</li>
<li>Browser: An application software that provides an interface for the WWW</li>
<li>Aspects of a good website:
<ul>
<li>Content</li>
<li>Interactivity</li>
<li>Design</li>
</ul>
</li>
</ul>
<h3 id="_9-6-browser-features" tabindex="-1">9.6: Browser Features <a class="header-anchor" href="#_9-6-browser-features" aria-label="Permalink to &quot;9.6: Browser Features&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>Common Browser Features
<ul>
<li>Bookmarks: AKA favorites</li>
<li>Caching: Just like a CPU cache on the internet</li>
<li>Cookies: Text files used to track info about users</li>
<li>Graphics File (GIF, JPEG): Images and videos</li>
<li>Javascript: A programming language
<ul>
<li>Used to make websites dynamics; Ex: Countdown timer</li>
</ul>
</li>
</ul>
</li>
<li>Browser Considerations:
<ul>
<li>Security</li>
<li>Popup Blockers</li>
<li>Usability</li>
</ul>
</li>
</ul>
<h3 id="_9-7-internet-service-providers-isp" tabindex="-1">9.7: Internet Service Providers (ISP) <a class="header-anchor" href="#_9-7-internet-service-providers-isp" aria-label="Permalink to &quot;9.7: Internet Service Providers (ISP)&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>Connectivity: When one computer connects to another and shares info &amp; resources</li>
<li>Internet Service Providers (ISP)
<ul>
<li>Dial-up &amp; Digital Subscriber Line (DSL)</li>
<li>Broadband Internet Access</li>
<li>Web Hosting</li>
</ul>
</li>
</ul>
<h3 id="_9-8-search-engines" tabindex="-1">9.8: Search Engines <a class="header-anchor" href="#_9-8-search-engines" aria-label="Permalink to &quot;9.8: Search Engines&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>Search engine: A website that lets a user type in specific key words or phrases and then return a list of hyperlinks that best match the search criteria
<ul>
<li>Google, Bing, Yahoo</li>
<li>Directory searches</li>
<li>Metasearch Engines
<ul>
<li>Ex: Dogpile</li>
</ul>
</li>
</ul>
</li>
</ul>
<h3 id="_9-9-e-commerce" tabindex="-1">9.9: E-Commerce <a class="header-anchor" href="#_9-9-e-commerce" aria-label="Permalink to &quot;9.9: E-Commerce&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>Electronic Commerce (E-Commerce): The distribution, buying, selling, advertising, and marketing of goods and services over the web
<ul>
<li>Business-to-Business (B2B)</li>
<li>Business-to-Consumer (B2C)</li>
<li>Consumer-to-Consumer (C2C)</li>
</ul>
</li>
<li>The rules of business still apply to online environments</li>
</ul>
<h3 id="_9-10-security" tabindex="-1">9.10: Security <a class="header-anchor" href="#_9-10-security" aria-label="Permalink to &quot;9.10: Security&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>Malware: Software designed to damage a computer's system without the owner's knowledge
<ul>
<li>Virus</li>
<li>Worms</li>
<li>Trojan Horse</li>
<li>Spyware</li>
<li>Adware</li>
</ul>
</li>
</ul>
<h3 id="_9-11-9-12-email-email-security" tabindex="-1">9.11/9.12: Email/Email Security <a class="header-anchor" href="#_9-11-9-12-email-email-security" aria-label="Permalink to &quot;9.11/9.12: Email/Email Security&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>Email: &quot;A store and forward&quot; system of composing, sending, storing, and receiving message over electronic communication systems.</li>
<li>Never send an email you wouldn't be willing to say in public</li>
<li>Phishing: An email that looks official but is malicious in nature</li>
<li>Spam: Unwanted mail</li>
</ul>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CIS105: Computer Appls&amp;Info Technology (2024 Spring) ]]></title>
            <link>https://note.toshiki.devacademic/cis105/</link>
            <guid>https://note.toshiki.devacademic/cis105/</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="cis105-computer-appls-info-technology-2024-spring" tabindex="-1">CIS105: Computer Appls&amp;Info Technology (2024 Spring) <a class="header-anchor" href="#cis105-computer-appls-info-technology-2024-spring" aria-label="Permalink to &quot;CIS105: Computer Appls&amp;Info Technology (2024 Spring)&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="courseload-overview" tabindex="-1">Courseload Overview <a class="header-anchor" href="#courseload-overview" aria-label="Permalink to &quot;Courseload Overview&quot;">&ZeroWidthSpace;</a></h2>
<table><tbody><tr><td><p><strong>REQUIRED</strong></p><p><strong>TEXTBOOKS:</strong></p></td><td><ul><li><span><a title="Required eBooks" href="https://canvas.asu.edu/courses/178246/pages/required-ebooks" data-course-type="wikiPages" data-published="true" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/pages/required-ebooks" data-api-returntype="Page"><strong>Applied Business Computing Concepts Textbook</strong></a></span></li><li><span><a title="Required eBooks" href="https://canvas.asu.edu/courses/178246/pages/required-ebooks" data-course-type="wikiPages" data-published="true" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/pages/required-ebooks" data-api-returntype="Page"><strong>Excel/SQL Textbook</strong></a></span></li></ul></td></tr><tr><td><p>Week 1</p></td><td><ul><li><span><strong>Lecture</strong> - Tue, Jan 9th&nbsp;</span></li><li><span><strong><a title="Textbook Information" href="https://canvas.asu.edu/courses/178246/pages/textbook-information" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/pages/textbook-information" data-api-returntype="Page">How to Access Textbook Instructions</a></strong></span></li></ul><hr><ul><li><span><strong>Lab</strong> - Thu, Jan 11th</span></li><li><span><strong><a href="https://asu.co1.qualtrics.com/jfe/form/SV_5nVqvnrTs3FmEHs?courseID=Fall2023-CIS105&amp;instructorEmail=mjmccart@asu.edu,pjmccar1@asu.edu,hgrimes1@asu.edu" target="_blank" rel="noreferrer noopener"><span>Excel Add-in Directions</span><span role="presentation"> <span>Links to an external site.</span></span></a></strong></span></li><li><span><a href="https://myeducator.freshdesk.com/support/solutions/articles/14000144410" target="_blank" rel="noreferrer noopener"><span><span><strong><span>Click here for MyEducator add-in installer for Windows</span></strong></span></span><span role="presentation"> <span>Links to an external site.</span></span></a></span></li><li><span><a href="https://myeducator.freshdesk.com/support/solutions/articles/14000110269-microsoft-excel-add-in-mac-instructions" target="_blank" rel="noreferrer noopener"><span><span><strong><span>Click here for MyEducator add-in installer for Mac iOS</span></strong></span></span><span role="presentation"> <span>Links to an external site.</span></span></a></span></li><li><span>Due Date(s): <strong>Sunday, Jan 14th, 2024 by midnight</strong></span></li></ul></td></tr><tr><td><p>Week 2</p><span><strong>&nbsp;</strong></span></td><td><ul><li><span><strong>Lecture</strong> - Tue, Jan 16th&nbsp;</span></li><li><span><strong><a title="Knowledge Check 1 | Information Systems" href="https://canvas.asu.edu/courses/178246/assignments/4864355" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864355" data-api-returntype="Assignment">Knowledge Check 1 | Information Systems</a></strong></span></li><li>Due Date(s): <strong>Sunday, January 21st, 2024 by midnight</strong></li></ul><hr><ul><li><span><strong>Lab</strong> - Thu, Jan 18th</span></li><li><span><strong><a title="0.4 Getting Started Excel/SQL Educator" href="https://canvas.asu.edu/courses/178246/assignments/4864307" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864307" data-api-returntype="Assignment">0.4 Getting Started Excel/SQL Educator</a></strong></span><strong></strong></li><li><a title="0.4 Getting Started Excel/SQL Educator" href="https://canvas.asu.edu/courses/178246/assignments/4864307" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864307" data-api-returntype="Assignment"></a>Due Date(s): <strong>Sunday, January 21st, 2024 by midnight</strong></li></ul></td></tr><tr><td><span><span><strong>&nbsp;</strong></span></span><p>Week 3</p></td><td><ul><li><span><strong>Lecture</strong> -&nbsp; Tue, Jan 23rd&nbsp;</span></li><li><span><strong><a title="Knowledge Check 2 | Application Software" href="https://canvas.asu.edu/courses/178246/assignments/4864362" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864362" data-api-returntype="Assignment">Knowledge Check 2 | Application Software</a></strong></span><br><strong></strong></li><li>Due Date(s): <strong>Sunday, January 28th, 2024 by midnight</strong></li></ul><hr><ul><li><span><strong>Lab</strong> - Thu, Jan 25th&nbsp;</span></li><li><span><strong><a title="1.3 Cells and Worksheets Practice" href="https://canvas.asu.edu/courses/178246/assignments/4864308" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864308" data-api-returntype="Assignment">1.3 Cells and Worksheets Practice</a></strong></span></li><li><span><strong><a title="1.5 Formatting Cells and Sheets Practice" href="https://canvas.asu.edu/courses/178246/assignments/4864309" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864309" data-api-returntype="Assignment">1.5 Formatting Cells and Sheets Practice</a></strong></span></li><li><span><strong><a title="1.7 Sorting and Filtering Practice" href="https://canvas.asu.edu/courses/178246/assignments/4864310" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864310" data-api-returntype="Assignment">1.7 Sorting and Filtering Practice</a></strong></span></li><li><span><strong><a title="1.7 Sorting and Filtering Practice" href="https://canvas.asu.edu/courses/178246/assignments/4864310" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864310" data-api-returntype="Assignment"></a><a title="1.8 Excel Basics Assessment" href="https://canvas.asu.edu/courses/178246/assignments/4864311" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864311" data-api-returntype="Assignment">1.8 Excel Basics Assessment</a></strong></span></li><li>Due Date(s): <strong>Sunday, January 28th, 2024 by midnight</strong></li></ul></td></tr><tr><td><p>Week 4</p><span><strong>&nbsp;</strong></span></td><td><ul><li><span><strong>Lecture</strong> - Tue, Jan 30th&nbsp;</span></li><li><span><strong><a title="Knowledge Check 3 | Inside the Computer" href="https://canvas.asu.edu/courses/178246/assignments/4864363" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864363" data-api-returntype="Assignment">Knowledge Check 3 | Inside the Computer</a></strong></span><br><strong></strong></li><li>Due Date(s): <strong>Sunday, February 4th, 2024 by midnight</strong></li></ul><hr><ul><li><span><strong>Lab</strong> - Thu, Feb 1st</span></li><li><span><strong><a title="2.2 References and Calculations Practice" href="https://canvas.asu.edu/courses/178246/assignments/4864329" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864329" data-api-returntype="Assignment">2.2 References and Calculations Practice</a></strong></span></li><li><span><strong><a title="2.4 Summary Statistics Practice" href="https://canvas.asu.edu/courses/178246/assignments/4864330" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864330" data-api-returntype="Assignment">2.4 Summary Statistics Practice</a></strong></span></li><li><span><strong><a title="2.6 Financial Functions Practice" href="https://canvas.asu.edu/courses/178246/assignments/4864331" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864331" data-api-returntype="Assignment">2.6 Financial Functions Practice</a></strong></span></li><li><span><strong><a title="2.8 Formula Auditing Practice" href="https://canvas.asu.edu/courses/178246/assignments/4864332" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864332" data-api-returntype="Assignment">2.8 Formula Auditing Practice</a></strong></span></li><li><span><strong><a title="2.9 Formulas and Functions Assessment" href="https://canvas.asu.edu/courses/178246/assignments/4864333" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864333" data-api-returntype="Assignment">2.9 Formulas and Functions Assessment</a></strong></span></li><li><span>Due Date(s): <strong>Sunday, February 4th, 2024 by midnight</strong></span></li></ul></td></tr><tr><td><p>Week 5</p><span><strong>&nbsp;</strong></span></td><td><ul><li><span><strong>Lecture</strong> - Tue, Feb 6th</span></li><li><span><strong><a title="Knowledge Check 4 | Operating Systems" href="https://canvas.asu.edu/courses/178246/assignments/4864364" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864364" data-api-returntype="Assignment">Knowledge Check 4 | Operating Systems</a></strong></span><br><strong></strong></li><li>Due Date(s): <strong>Sunday, February 11th, 2024 by midnight</strong></li></ul><hr><ul><li><span><span><strong>Lab</strong> - Thu, Feb 8th</span></span></li><li><span><strong><a title="3.2 Boolean Functions Practice" href="https://canvas.asu.edu/courses/178246/assignments/4864334" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864334" data-api-returntype="Assignment">3.2 Boolean Functions Practice</a></strong></span></li><li><span><strong><a title="3.4 If Functions Practice" href="https://canvas.asu.edu/courses/178246/assignments/4864335" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864335" data-api-returntype="Assignment">3.4 If Functions Practice</a></strong></span></li><li><span><strong><a title="3.6 Conditional Functions Practice" href="https://canvas.asu.edu/courses/178246/assignments/4864336" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864336" data-api-returntype="Assignment">3.6 Conditional Functions Practice</a></strong></span></li><li><span><strong><a title="3.8 Reference Functions Practice" href="https://canvas.asu.edu/courses/178246/assignments/4864337" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864337" data-api-returntype="Assignment">3.8 Reference Functions Practice</a></strong></span></li><li><span><strong><a title="3.9 Logic and Reference Functions Assessment (Alternative Lookups)" href="https://canvas.asu.edu/courses/178246/assignments/4864338" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864338" data-api-returntype="Assignment">3.9 Logic and Reference Functions Assessment (Alternative Lookups)</a></strong></span></li><li>Due Date(s): <strong>Sunday, February 11th, 2024 by midnight</strong></li></ul></td></tr><tr><td><p>Week 6</p><span><strong>&nbsp;</strong></span></td><td><ul><li><span><strong>Lecture</strong> - Tue, Feb 13th</span></li><li><span><strong><a title="Knowledge Check 5 | Business Storage" href="https://canvas.asu.edu/courses/178246/assignments/4864365" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864365" data-api-returntype="Assignment">Knowledge Check 5 | Business Storage</a></strong></span><strong></strong><br><strong></strong></li><li><span><a title="Knowledge Check 5 | Business Storage" href="https://canvas.asu.edu/courses/$CANVAS_OBJECT_REFERENCE$/assignments/g6668e44610cc0861111d60a906ef3d03" data-api-endpoint="https://asu.instructure.com/api/v1/courses/123091/assignments/3257939" data-api-returntype="Assignment"></a></span>Due Date(s): <strong>Sunday, February 18th, 2024 by midnight</strong></li><li><span><strong>ZOOM Exam One Review: TBA</strong></span><strong></strong></li></ul><hr><ul><li><span><span><span><strong>Lab</strong> - Thu, Feb 15th</span></span></span></li><li><span><strong><a title="4.2 Date and Time Functions Practice" href="https://canvas.asu.edu/courses/178246/assignments/4864339" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864339" data-api-returntype="Assignment">4.2 Date and Time Functions Practice</a></strong></span></li><li><span><strong><a title="4.4 Text Functions Practice" href="https://canvas.asu.edu/courses/178246/assignments/4864340" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864340" data-api-returntype="Assignment">4.4 Text Functions Practice</a></strong></span></li><li><span><strong><a title="4.5 Date, Time, and Text Functions Assessment" href="https://canvas.asu.edu/courses/178246/assignments/4864341" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864341" data-api-returntype="Assignment">4.5 Date, Time, and Text Functions Assessment</a></strong></span></li><li><span>Due Date(s): <strong>Sunday, February 18th, 2024 by midnight</strong></span></li></ul></td></tr><tr><td></td><td><p><strong><span>Exam 1: February 22nd - 23rd</span><a title="Exam 1" href="https://canvas.asu.edu/courses/178246/assignments/4864353" data-course-type="assignments" data-published="true" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864353" data-api-returntype="Assignment"></a></strong></p></td></tr><tr><td><span><span><strong>&nbsp;</strong></span></span><p>Week 7</p></td><td><ul><li><span><strong>Lecture</strong> - Tue, Feb 20th</span></li><li><span><strong><a title="Knowledge Check 6 | System Software" href="https://canvas.asu.edu/courses/178246/assignments/4864366" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864366" data-api-returntype="Assignment">Knowledge Check 6 | System Software</a></strong></span><strong></strong><br><strong></strong></li><li><span><a title="Knowledge Check 6 | System Software" href="https://canvas.asu.edu/courses/$CANVAS_OBJECT_REFERENCE$/assignments/gce1e6b22e2cff82aca758d0f04f327a0" data-api-endpoint="https://asu.instructure.com/api/v1/courses/123091/assignments/3257940" data-api-returntype="Assignment"></a></span><span>Due Date(s): <strong>Sunday, February 25th, 2024 by midnight</strong></span></li></ul><hr><ul><li><span><span><span><strong>Lab</strong> - Thu, Feb 22nd</span></span></span></li><li><span><strong><a title="5.3 Column Charts Practice" href="https://canvas.asu.edu/courses/178246/assignments/4864343" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864343" data-api-returntype="Assignment">5.3 Column Charts Practice</a></strong></span></li><li><span><strong><a title="5.5 Stacked Column Charts Practice" href="https://canvas.asu.edu/courses/178246/assignments/4864344" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864344" data-api-returntype="Assignment">5.5 Stacked Column Charts Practice</a></strong></span></li><li><span><strong><a title="5.7 Pie Charts Practice" href="https://canvas.asu.edu/courses/178246/assignments/4864345" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864345" data-api-returntype="Assignment">5.7 Pie Charts Practice</a></strong></span></li><li><span><strong><a title="5.9 Line Charts Practice" href="https://canvas.asu.edu/courses/178246/assignments/4864346" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864346" data-api-returntype="Assignment">5.9 Line Charts Practice</a></strong></span></li><li><span><strong><a title="5.10 Charting Assessment" href="https://canvas.asu.edu/courses/178246/assignments/4864342" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864342" data-api-returntype="Assignment">5.10 Charting Assessment</a></strong></span></li><li><span>Due Date(s): <strong>Sunday, February 25th, 2024 by midnight</strong></span></li></ul></td></tr><tr><td><p>Week 8</p><span><strong>&nbsp;</strong></span></td><td><ul><li><span><strong>Lecture</strong> - Tue, February 27th</span></li><li><span><strong><a title="Knowledge Check 7 | Green Business Computing" href="https://canvas.asu.edu/courses/178246/assignments/4864367" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864367" data-api-returntype="Assignment">Knowledge Check 7 | Green Business Computing</a></strong></span></li><li><span><strong><a title="Knowledge Check 8 | Computer Networks" href="https://canvas.asu.edu/courses/178246/assignments/4864368" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864368" data-api-returntype="Assignment">Knowledge Check 8 | Computer Networks</a></strong></span></li><li><span>Due Date(s): <strong>Sunday, March 3rd, 2024 by midnight</strong></span><strong></strong></li></ul><hr><ul><li><span><span><span><span><strong>Lab</strong> - Thu, Feb 29th</span></span></span></span></li><li><span><strong><a title="6.2 Building Spreadsheet Models Practice" href="https://canvas.asu.edu/courses/178246/assignments/4864347" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864347" data-api-returntype="Assignment">6.2 Building Spreadsheet Models Practice</a></strong></span></li><li><span><strong><a title="6.4 What-if Analysis Practice" href="https://canvas.asu.edu/courses/178246/assignments/4864348" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864348" data-api-returntype="Assignment">6.4 What-if Analysis Practice</a></strong></span></li><li><span><strong><a title="6.5 Basic Modeling Assessment" href="https://canvas.asu.edu/courses/178246/assignments/4864349" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864349" data-api-returntype="Assignment">6.5 Basic Modeling Assessment</a></strong></span></li><li><span>Due Date(s): <strong>Sunday, March 3rd, 2024 by midnight</strong></span></li></ul></td></tr><tr><td><p>Mar 4th - 10th</p></td><td><p><span><strong>SPRING BREAK</strong></span></p></td></tr><tr><td><p>Week 9</p><span><strong>&nbsp;</strong></span></td><td><ul><li><span><strong>Lecture</strong> - Tue, Mar 12th</span><strong></strong></li><li><strong><span><a title="Knowledge Check 9 | Internet" href="https://canvas.asu.edu/courses/178246/assignments/4864369" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864369" data-api-returntype="Assignment">Knowledge Check 9 | Internet</a></span></strong></li><li><span><a title="Knowledge Check 8 | Computer Networks" href="https://canvas.asu.edu/courses/$CANVAS_OBJECT_REFERENCE$/assignments/g02f84ca4314a168cb45b1b2078471269" data-api-endpoint="https://asu.instructure.com/api/v1/courses/123091/assignments/3257942" data-api-returntype="Assignment"></a></span><span>Due Date(s): <strong>Sunday, March 17th, 2024 by midnight</strong></span></li></ul><hr><ul><li><span><span><span><span><span><span><strong>Lab</strong> - Thu, Mar 14th</span></span></span></span></span></span></li><li><a title="9.2 PivotTable Practice" href="https://canvas.asu.edu/courses/178246/assignments/4864350" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864350" data-api-returntype="Assignment"><strong><span>9.2 PivotTable Practice</span></strong></a></li><li><a title="9.3 PivotTable Assessment" href="https://canvas.asu.edu/courses/178246/assignments/4864351" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864351" data-api-returntype="Assignment"><strong><span>9.3 PivotTable Assessment</span></strong></a></li><li><span>Due Date(s): <strong>Sunday, March 17th, 2024 by midnight</strong></span></li></ul></td></tr><tr><td><p>Week 10</p><span><strong>&nbsp;</strong></span></td><td><ul><li><span><strong>Lecture</strong> - Tue, Mar 19th</span><strong></strong></li><li><strong><span><a title="Knowledge Check 10 | Business Websites" href="https://canvas.asu.edu/courses/178246/assignments/4864356" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864356" data-api-returntype="Assignment">Knowledge Check 10 | Business Websites</a></span></strong><strong></strong></li><li><span><a title="Knowledge Check 9 | Internet" href="https://canvas.asu.edu/courses/$CANVAS_OBJECT_REFERENCE$/assignments/g698110836c1822c002df3e2bb2c97f21" data-api-endpoint="https://asu.instructure.com/api/v1/courses/123091/assignments/3257943" data-api-returntype="Assignment"></a></span><span>Due Date(s): <strong>Sunday, March 24th, 2024 by midnight</strong></span></li></ul><hr><ul><li><span><span><span><span><span><span><span><span><strong>Lab</strong> - Thu, Mar 21st</span></span></span></span></span></span></span></span><span><span><span><span><span><span><span><span><span><strong><br></strong></span></span></span></span></span></span></span></span></span></li><li><strong><span><a title="11.4 Practice Designing Database Tables" href="https://canvas.asu.edu/courses/178246/assignments/4864312" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864312" data-api-returntype="Assignment">11.4 Practice Designing Database Tables</a></span></strong></li><li><strong><span><a title="11.6 Practice Working with Airtable" href="https://canvas.asu.edu/courses/178246/assignments/4864313" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864313" data-api-returntype="Assignment">11.6 Practice Working with Airtable</a></span></strong></li><li><strong><span><a title="11.7 Design and Build a Database Assessment" href="https://canvas.asu.edu/courses/178246/assignments/4864314" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864314" data-api-returntype="Assignment">11.7 Design and Build a Database Assessment</a></span></strong></li><li><span>Due Date(s): <strong>Sunday, March 24th, 2024 by midnight</strong></span></li></ul></td></tr><tr><td><p>Week 11</p><span><strong>&nbsp;</strong></span></td><td><ul><li><span><strong>Lecture</strong> -&nbsp; Tue, Mar 26th</span><strong><span><br></span></strong></li><li><strong><span><a title="Knowledge Check 11 | Computer Security" href="https://canvas.asu.edu/courses/178246/assignments/4864357" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864357" data-api-returntype="Assignment">Knowledge Check 11 | Computer Security</a></span></strong></li><li><span>Due Date(s): <strong>Sunday, March 31st, 2024 by midnight</strong></span></li><li><span><strong>ZOOM Midterm Review(s) TBA</strong></span></li></ul><hr><ul><li><span><span><span><span><span><span><span><span><span><strong>Lab</strong> - Thu, Mar 28th</span></span></span></span></span></span></span></span></span></li><li><strong><span><a title="12.4 Select Clause Practice" href="https://canvas.asu.edu/courses/178246/assignments/4864316" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864316" data-api-returntype="Assignment">12.4 Select Clause Practice</a></span></strong></li><li><strong><span><a title="12.5 Distinct Keyword Practice" href="https://canvas.asu.edu/courses/178246/assignments/4864317" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864317" data-api-returntype="Assignment">12.5 Distinct Keyword Practice</a></span></strong></li><li><strong><span><a title="12.7 Order By Clause Practice" href="https://canvas.asu.edu/courses/178246/assignments/4864318" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864318" data-api-returntype="Assignment">12.7 Order By Clause Practice</a></span></strong></li><li><strong><span><a title="12.9 Limit Clause Practice" href="https://canvas.asu.edu/courses/178246/assignments/4864319" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864319" data-api-returntype="Assignment">12.9 Limit Clause Practice</a></span></strong></li><li><strong><span><a title="12.10 Introduction to SQL Assessment - Simpsons" href="https://canvas.asu.edu/courses/178246/assignments/4864315" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864315" data-api-returntype="Assignment">12.10 Introduction to SQL Assessment - Simpsons</a></span></strong></li><li><span>Due Date(s): <strong>Sunday, April 7th, 2024 by midnight</strong></span></li></ul></td></tr><tr><td><strong><span><span><span><span>&nbsp;</span></span></span></span></strong></td><td><span><span><strong>Exam 2</strong></span></span></td></tr><tr><td><p>Week 12</p><span><strong>&nbsp;</strong></span></td><td><ul><li><span><strong>Lecture</strong> - Tue, Apr 2nd</span></li><li><strong><span><a title="Knowledge Check 12 | Information Systems in Business" href="https://canvas.asu.edu/courses/178246/assignments/4864358" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864358" data-api-returntype="Assignment">Knowledge Check 12 | Information Systems in Business</a></span></strong><br><strong></strong></li><li><span>Due Date(s): <strong>Sunday, April 7th, 2024 by midnight</strong></span></li></ul><hr><ul><li><span><span><span><span><span><span><span><span><span><span><strong>Lab</strong> - Thu, Apr 4</span></span></span></span></span></span></span></span></span></span></li><li><strong><span><a title="13.3 Simple Where Clause Practice" href="https://canvas.asu.edu/courses/178246/assignments/4864322" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864322" data-api-returntype="Assignment">13.3 Simple Where Clause Practice</a></span></strong></li><li><strong><span><a title="13.5 Where Clause with Null Practice" href="https://canvas.asu.edu/courses/178246/assignments/4864323" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864323" data-api-returntype="Assignment">13.5 Where Clause with Null Practice</a></span></strong></li><li><strong><span><a title="13.8 Compound Where Clause Practice" href="https://canvas.asu.edu/courses/178246/assignments/4864324" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864324" data-api-returntype="Assignment">13.8 Compound Where Clause Practice</a></span></strong></li><li><strong><span><a title="13.10 Where Clause with Wildcards Practice" href="https://canvas.asu.edu/courses/178246/assignments/4864320" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864320" data-api-returntype="Assignment">13.10 Where Clause with Wildcards Practice</a></span></strong></li><li><strong><span><a title="13.11 Queries with Restrictions Assessment" href="https://canvas.asu.edu/courses/178246/assignments/4864321" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864321" data-api-returntype="Assignment">13.11 Queries with Restrictions Assessment</a></span></strong></li><li><span>Due Date(s): <strong>Sunday, April 14th, 2024 by midnight</strong></span></li></ul></td></tr><tr><td><p>Week 13</p><span><strong>&nbsp;</strong></span></td><td><ul><li><span><strong>Lecture</strong> - Tue, Apr 9th</span></li><li><span><strong><a title="Knowledge Check 13 | Business System Reporting" href="https://canvas.asu.edu/courses/178246/assignments/4864359" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864359" data-api-returntype="Assignment">Knowledge Check 13 | Business System Reporting</a></strong></span></li><li><strong><span><a title="Knowledge Check 14 | Information Technology Careers" href="https://canvas.asu.edu/courses/178246/assignments/4864360" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864360" data-api-returntype="Assignment">Knowledge Check 14 | Information Technology Careers</a></span></strong><br><strong></strong></li><li><span>Due Date(s): <strong>Sunday, April 21st, 2024 by midnight</strong></span></li></ul><hr><ul><li><span><span><span><span><span><span><span><span><span><span><span><span><strong>Lab</strong> - Thu, Apr 11th</span></span></span></span></span></span></span></span></span></span></span></span></li><li><strong><span><a title="14.2 Joining Two Tables Practice" href="https://canvas.asu.edu/courses/178246/assignments/4864325" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864325" data-api-returntype="Assignment">14.2 Joining Two Tables Practice</a></span></strong></li><li><strong><span><a title="14.4 Joining Three or More Tables Practice" href="https://canvas.asu.edu/courses/178246/assignments/4864326" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864326" data-api-returntype="Assignment">14.4 Joining Three or More Tables Practice</a></span></strong></li><li><strong><span><a title="14.6 Queries with Join and Where Practice" href="https://canvas.asu.edu/courses/178246/assignments/4864327" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864327" data-api-returntype="Assignment">14.6 Queries with Join and Where Practice</a></span></strong></li><li><strong><span><a title="14.7 Join Queries Assessment" href="https://canvas.asu.edu/courses/178246/assignments/4864328" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864328" data-api-returntype="Assignment">14.7 Join Queries Assessment</a></span></strong></li><li><span>Due Date(s): <strong>Sunday, April 21st, 2024 by midnight</strong></span></li></ul></td></tr><tr><td><span><strong>&nbsp;</strong></span></td><td><ul><li><span><strong>Lecture</strong> - Tue, Apr 16th</span><strong></strong></li><li><strong><span><a title="Knowledge Check 15 | Database" href="https://canvas.asu.edu/courses/178246/assignments/4864361" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864361" data-api-returntype="Assignment">Knowledge Check 15 | Database</a></span></strong><br><strong></strong></li><li><span>Due Date(s): <strong>Sunday, April 28th, 2024 by midnight</strong></span></li></ul></td></tr><tr><td><span><strong>&nbsp;</strong></span></td><td><ul><li><span><strong>Lecture - Thur, Apr 18th</strong></span></li><li><span><strong>Final Exam Review</strong></span></li></ul></td></tr><tr><td><strong><span><span>&nbsp;</span></span></strong></td><td><strong>Final Exam</strong></td></tr></tbody></table>
]]></description>
            <content:encoded><![CDATA[<h1 id="cis105-computer-appls-info-technology-2024-spring" tabindex="-1">CIS105: Computer Appls&amp;Info Technology (2024 Spring) <a class="header-anchor" href="#cis105-computer-appls-info-technology-2024-spring" aria-label="Permalink to &quot;CIS105: Computer Appls&amp;Info Technology (2024 Spring)&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="courseload-overview" tabindex="-1">Courseload Overview <a class="header-anchor" href="#courseload-overview" aria-label="Permalink to &quot;Courseload Overview&quot;">&ZeroWidthSpace;</a></h2>
<table><tbody><tr><td><p><strong>REQUIRED</strong></p><p><strong>TEXTBOOKS:</strong></p></td><td><ul><li><span><a title="Required eBooks" href="https://canvas.asu.edu/courses/178246/pages/required-ebooks" data-course-type="wikiPages" data-published="true" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/pages/required-ebooks" data-api-returntype="Page"><strong>Applied Business Computing Concepts Textbook</strong></a></span></li><li><span><a title="Required eBooks" href="https://canvas.asu.edu/courses/178246/pages/required-ebooks" data-course-type="wikiPages" data-published="true" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/pages/required-ebooks" data-api-returntype="Page"><strong>Excel/SQL Textbook</strong></a></span></li></ul></td></tr><tr><td><p>Week 1</p></td><td><ul><li><span><strong>Lecture</strong> - Tue, Jan 9th&nbsp;</span></li><li><span><strong><a title="Textbook Information" href="https://canvas.asu.edu/courses/178246/pages/textbook-information" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/pages/textbook-information" data-api-returntype="Page">How to Access Textbook Instructions</a></strong></span></li></ul><hr><ul><li><span><strong>Lab</strong> - Thu, Jan 11th</span></li><li><span><strong><a href="https://asu.co1.qualtrics.com/jfe/form/SV_5nVqvnrTs3FmEHs?courseID=Fall2023-CIS105&amp;instructorEmail=mjmccart@asu.edu,pjmccar1@asu.edu,hgrimes1@asu.edu" target="_blank" rel="noreferrer noopener"><span>Excel Add-in Directions</span><span role="presentation"> <span>Links to an external site.</span></span></a></strong></span></li><li><span><a href="https://myeducator.freshdesk.com/support/solutions/articles/14000144410" target="_blank" rel="noreferrer noopener"><span><span><strong><span>Click here for MyEducator add-in installer for Windows</span></strong></span></span><span role="presentation"> <span>Links to an external site.</span></span></a></span></li><li><span><a href="https://myeducator.freshdesk.com/support/solutions/articles/14000110269-microsoft-excel-add-in-mac-instructions" target="_blank" rel="noreferrer noopener"><span><span><strong><span>Click here for MyEducator add-in installer for Mac iOS</span></strong></span></span><span role="presentation"> <span>Links to an external site.</span></span></a></span></li><li><span>Due Date(s): <strong>Sunday, Jan 14th, 2024 by midnight</strong></span></li></ul></td></tr><tr><td><p>Week 2</p><span><strong>&nbsp;</strong></span></td><td><ul><li><span><strong>Lecture</strong> - Tue, Jan 16th&nbsp;</span></li><li><span><strong><a title="Knowledge Check 1 | Information Systems" href="https://canvas.asu.edu/courses/178246/assignments/4864355" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864355" data-api-returntype="Assignment">Knowledge Check 1 | Information Systems</a></strong></span></li><li>Due Date(s): <strong>Sunday, January 21st, 2024 by midnight</strong></li></ul><hr><ul><li><span><strong>Lab</strong> - Thu, Jan 18th</span></li><li><span><strong><a title="0.4 Getting Started Excel/SQL Educator" href="https://canvas.asu.edu/courses/178246/assignments/4864307" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864307" data-api-returntype="Assignment">0.4 Getting Started Excel/SQL Educator</a></strong></span><strong></strong></li><li><a title="0.4 Getting Started Excel/SQL Educator" href="https://canvas.asu.edu/courses/178246/assignments/4864307" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864307" data-api-returntype="Assignment"></a>Due Date(s): <strong>Sunday, January 21st, 2024 by midnight</strong></li></ul></td></tr><tr><td><span><span><strong>&nbsp;</strong></span></span><p>Week 3</p></td><td><ul><li><span><strong>Lecture</strong> -&nbsp; Tue, Jan 23rd&nbsp;</span></li><li><span><strong><a title="Knowledge Check 2 | Application Software" href="https://canvas.asu.edu/courses/178246/assignments/4864362" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864362" data-api-returntype="Assignment">Knowledge Check 2 | Application Software</a></strong></span><br><strong></strong></li><li>Due Date(s): <strong>Sunday, January 28th, 2024 by midnight</strong></li></ul><hr><ul><li><span><strong>Lab</strong> - Thu, Jan 25th&nbsp;</span></li><li><span><strong><a title="1.3 Cells and Worksheets Practice" href="https://canvas.asu.edu/courses/178246/assignments/4864308" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864308" data-api-returntype="Assignment">1.3 Cells and Worksheets Practice</a></strong></span></li><li><span><strong><a title="1.5 Formatting Cells and Sheets Practice" href="https://canvas.asu.edu/courses/178246/assignments/4864309" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864309" data-api-returntype="Assignment">1.5 Formatting Cells and Sheets Practice</a></strong></span></li><li><span><strong><a title="1.7 Sorting and Filtering Practice" href="https://canvas.asu.edu/courses/178246/assignments/4864310" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864310" data-api-returntype="Assignment">1.7 Sorting and Filtering Practice</a></strong></span></li><li><span><strong><a title="1.7 Sorting and Filtering Practice" href="https://canvas.asu.edu/courses/178246/assignments/4864310" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864310" data-api-returntype="Assignment"></a><a title="1.8 Excel Basics Assessment" href="https://canvas.asu.edu/courses/178246/assignments/4864311" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864311" data-api-returntype="Assignment">1.8 Excel Basics Assessment</a></strong></span></li><li>Due Date(s): <strong>Sunday, January 28th, 2024 by midnight</strong></li></ul></td></tr><tr><td><p>Week 4</p><span><strong>&nbsp;</strong></span></td><td><ul><li><span><strong>Lecture</strong> - Tue, Jan 30th&nbsp;</span></li><li><span><strong><a title="Knowledge Check 3 | Inside the Computer" href="https://canvas.asu.edu/courses/178246/assignments/4864363" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864363" data-api-returntype="Assignment">Knowledge Check 3 | Inside the Computer</a></strong></span><br><strong></strong></li><li>Due Date(s): <strong>Sunday, February 4th, 2024 by midnight</strong></li></ul><hr><ul><li><span><strong>Lab</strong> - Thu, Feb 1st</span></li><li><span><strong><a title="2.2 References and Calculations Practice" href="https://canvas.asu.edu/courses/178246/assignments/4864329" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864329" data-api-returntype="Assignment">2.2 References and Calculations Practice</a></strong></span></li><li><span><strong><a title="2.4 Summary Statistics Practice" href="https://canvas.asu.edu/courses/178246/assignments/4864330" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864330" data-api-returntype="Assignment">2.4 Summary Statistics Practice</a></strong></span></li><li><span><strong><a title="2.6 Financial Functions Practice" href="https://canvas.asu.edu/courses/178246/assignments/4864331" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864331" data-api-returntype="Assignment">2.6 Financial Functions Practice</a></strong></span></li><li><span><strong><a title="2.8 Formula Auditing Practice" href="https://canvas.asu.edu/courses/178246/assignments/4864332" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864332" data-api-returntype="Assignment">2.8 Formula Auditing Practice</a></strong></span></li><li><span><strong><a title="2.9 Formulas and Functions Assessment" href="https://canvas.asu.edu/courses/178246/assignments/4864333" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864333" data-api-returntype="Assignment">2.9 Formulas and Functions Assessment</a></strong></span></li><li><span>Due Date(s): <strong>Sunday, February 4th, 2024 by midnight</strong></span></li></ul></td></tr><tr><td><p>Week 5</p><span><strong>&nbsp;</strong></span></td><td><ul><li><span><strong>Lecture</strong> - Tue, Feb 6th</span></li><li><span><strong><a title="Knowledge Check 4 | Operating Systems" href="https://canvas.asu.edu/courses/178246/assignments/4864364" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864364" data-api-returntype="Assignment">Knowledge Check 4 | Operating Systems</a></strong></span><br><strong></strong></li><li>Due Date(s): <strong>Sunday, February 11th, 2024 by midnight</strong></li></ul><hr><ul><li><span><span><strong>Lab</strong> - Thu, Feb 8th</span></span></li><li><span><strong><a title="3.2 Boolean Functions Practice" href="https://canvas.asu.edu/courses/178246/assignments/4864334" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864334" data-api-returntype="Assignment">3.2 Boolean Functions Practice</a></strong></span></li><li><span><strong><a title="3.4 If Functions Practice" href="https://canvas.asu.edu/courses/178246/assignments/4864335" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864335" data-api-returntype="Assignment">3.4 If Functions Practice</a></strong></span></li><li><span><strong><a title="3.6 Conditional Functions Practice" href="https://canvas.asu.edu/courses/178246/assignments/4864336" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864336" data-api-returntype="Assignment">3.6 Conditional Functions Practice</a></strong></span></li><li><span><strong><a title="3.8 Reference Functions Practice" href="https://canvas.asu.edu/courses/178246/assignments/4864337" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864337" data-api-returntype="Assignment">3.8 Reference Functions Practice</a></strong></span></li><li><span><strong><a title="3.9 Logic and Reference Functions Assessment (Alternative Lookups)" href="https://canvas.asu.edu/courses/178246/assignments/4864338" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864338" data-api-returntype="Assignment">3.9 Logic and Reference Functions Assessment (Alternative Lookups)</a></strong></span></li><li>Due Date(s): <strong>Sunday, February 11th, 2024 by midnight</strong></li></ul></td></tr><tr><td><p>Week 6</p><span><strong>&nbsp;</strong></span></td><td><ul><li><span><strong>Lecture</strong> - Tue, Feb 13th</span></li><li><span><strong><a title="Knowledge Check 5 | Business Storage" href="https://canvas.asu.edu/courses/178246/assignments/4864365" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864365" data-api-returntype="Assignment">Knowledge Check 5 | Business Storage</a></strong></span><strong></strong><br><strong></strong></li><li><span><a title="Knowledge Check 5 | Business Storage" href="https://canvas.asu.edu/courses/$CANVAS_OBJECT_REFERENCE$/assignments/g6668e44610cc0861111d60a906ef3d03" data-api-endpoint="https://asu.instructure.com/api/v1/courses/123091/assignments/3257939" data-api-returntype="Assignment"></a></span>Due Date(s): <strong>Sunday, February 18th, 2024 by midnight</strong></li><li><span><strong>ZOOM Exam One Review: TBA</strong></span><strong></strong></li></ul><hr><ul><li><span><span><span><strong>Lab</strong> - Thu, Feb 15th</span></span></span></li><li><span><strong><a title="4.2 Date and Time Functions Practice" href="https://canvas.asu.edu/courses/178246/assignments/4864339" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864339" data-api-returntype="Assignment">4.2 Date and Time Functions Practice</a></strong></span></li><li><span><strong><a title="4.4 Text Functions Practice" href="https://canvas.asu.edu/courses/178246/assignments/4864340" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864340" data-api-returntype="Assignment">4.4 Text Functions Practice</a></strong></span></li><li><span><strong><a title="4.5 Date, Time, and Text Functions Assessment" href="https://canvas.asu.edu/courses/178246/assignments/4864341" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864341" data-api-returntype="Assignment">4.5 Date, Time, and Text Functions Assessment</a></strong></span></li><li><span>Due Date(s): <strong>Sunday, February 18th, 2024 by midnight</strong></span></li></ul></td></tr><tr><td></td><td><p><strong><span>Exam 1: February 22nd - 23rd</span><a title="Exam 1" href="https://canvas.asu.edu/courses/178246/assignments/4864353" data-course-type="assignments" data-published="true" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864353" data-api-returntype="Assignment"></a></strong></p></td></tr><tr><td><span><span><strong>&nbsp;</strong></span></span><p>Week 7</p></td><td><ul><li><span><strong>Lecture</strong> - Tue, Feb 20th</span></li><li><span><strong><a title="Knowledge Check 6 | System Software" href="https://canvas.asu.edu/courses/178246/assignments/4864366" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864366" data-api-returntype="Assignment">Knowledge Check 6 | System Software</a></strong></span><strong></strong><br><strong></strong></li><li><span><a title="Knowledge Check 6 | System Software" href="https://canvas.asu.edu/courses/$CANVAS_OBJECT_REFERENCE$/assignments/gce1e6b22e2cff82aca758d0f04f327a0" data-api-endpoint="https://asu.instructure.com/api/v1/courses/123091/assignments/3257940" data-api-returntype="Assignment"></a></span><span>Due Date(s): <strong>Sunday, February 25th, 2024 by midnight</strong></span></li></ul><hr><ul><li><span><span><span><strong>Lab</strong> - Thu, Feb 22nd</span></span></span></li><li><span><strong><a title="5.3 Column Charts Practice" href="https://canvas.asu.edu/courses/178246/assignments/4864343" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864343" data-api-returntype="Assignment">5.3 Column Charts Practice</a></strong></span></li><li><span><strong><a title="5.5 Stacked Column Charts Practice" href="https://canvas.asu.edu/courses/178246/assignments/4864344" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864344" data-api-returntype="Assignment">5.5 Stacked Column Charts Practice</a></strong></span></li><li><span><strong><a title="5.7 Pie Charts Practice" href="https://canvas.asu.edu/courses/178246/assignments/4864345" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864345" data-api-returntype="Assignment">5.7 Pie Charts Practice</a></strong></span></li><li><span><strong><a title="5.9 Line Charts Practice" href="https://canvas.asu.edu/courses/178246/assignments/4864346" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864346" data-api-returntype="Assignment">5.9 Line Charts Practice</a></strong></span></li><li><span><strong><a title="5.10 Charting Assessment" href="https://canvas.asu.edu/courses/178246/assignments/4864342" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864342" data-api-returntype="Assignment">5.10 Charting Assessment</a></strong></span></li><li><span>Due Date(s): <strong>Sunday, February 25th, 2024 by midnight</strong></span></li></ul></td></tr><tr><td><p>Week 8</p><span><strong>&nbsp;</strong></span></td><td><ul><li><span><strong>Lecture</strong> - Tue, February 27th</span></li><li><span><strong><a title="Knowledge Check 7 | Green Business Computing" href="https://canvas.asu.edu/courses/178246/assignments/4864367" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864367" data-api-returntype="Assignment">Knowledge Check 7 | Green Business Computing</a></strong></span></li><li><span><strong><a title="Knowledge Check 8 | Computer Networks" href="https://canvas.asu.edu/courses/178246/assignments/4864368" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864368" data-api-returntype="Assignment">Knowledge Check 8 | Computer Networks</a></strong></span></li><li><span>Due Date(s): <strong>Sunday, March 3rd, 2024 by midnight</strong></span><strong></strong></li></ul><hr><ul><li><span><span><span><span><strong>Lab</strong> - Thu, Feb 29th</span></span></span></span></li><li><span><strong><a title="6.2 Building Spreadsheet Models Practice" href="https://canvas.asu.edu/courses/178246/assignments/4864347" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864347" data-api-returntype="Assignment">6.2 Building Spreadsheet Models Practice</a></strong></span></li><li><span><strong><a title="6.4 What-if Analysis Practice" href="https://canvas.asu.edu/courses/178246/assignments/4864348" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864348" data-api-returntype="Assignment">6.4 What-if Analysis Practice</a></strong></span></li><li><span><strong><a title="6.5 Basic Modeling Assessment" href="https://canvas.asu.edu/courses/178246/assignments/4864349" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864349" data-api-returntype="Assignment">6.5 Basic Modeling Assessment</a></strong></span></li><li><span>Due Date(s): <strong>Sunday, March 3rd, 2024 by midnight</strong></span></li></ul></td></tr><tr><td><p>Mar 4th - 10th</p></td><td><p><span><strong>SPRING BREAK</strong></span></p></td></tr><tr><td><p>Week 9</p><span><strong>&nbsp;</strong></span></td><td><ul><li><span><strong>Lecture</strong> - Tue, Mar 12th</span><strong></strong></li><li><strong><span><a title="Knowledge Check 9 | Internet" href="https://canvas.asu.edu/courses/178246/assignments/4864369" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864369" data-api-returntype="Assignment">Knowledge Check 9 | Internet</a></span></strong></li><li><span><a title="Knowledge Check 8 | Computer Networks" href="https://canvas.asu.edu/courses/$CANVAS_OBJECT_REFERENCE$/assignments/g02f84ca4314a168cb45b1b2078471269" data-api-endpoint="https://asu.instructure.com/api/v1/courses/123091/assignments/3257942" data-api-returntype="Assignment"></a></span><span>Due Date(s): <strong>Sunday, March 17th, 2024 by midnight</strong></span></li></ul><hr><ul><li><span><span><span><span><span><span><strong>Lab</strong> - Thu, Mar 14th</span></span></span></span></span></span></li><li><a title="9.2 PivotTable Practice" href="https://canvas.asu.edu/courses/178246/assignments/4864350" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864350" data-api-returntype="Assignment"><strong><span>9.2 PivotTable Practice</span></strong></a></li><li><a title="9.3 PivotTable Assessment" href="https://canvas.asu.edu/courses/178246/assignments/4864351" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864351" data-api-returntype="Assignment"><strong><span>9.3 PivotTable Assessment</span></strong></a></li><li><span>Due Date(s): <strong>Sunday, March 17th, 2024 by midnight</strong></span></li></ul></td></tr><tr><td><p>Week 10</p><span><strong>&nbsp;</strong></span></td><td><ul><li><span><strong>Lecture</strong> - Tue, Mar 19th</span><strong></strong></li><li><strong><span><a title="Knowledge Check 10 | Business Websites" href="https://canvas.asu.edu/courses/178246/assignments/4864356" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864356" data-api-returntype="Assignment">Knowledge Check 10 | Business Websites</a></span></strong><strong></strong></li><li><span><a title="Knowledge Check 9 | Internet" href="https://canvas.asu.edu/courses/$CANVAS_OBJECT_REFERENCE$/assignments/g698110836c1822c002df3e2bb2c97f21" data-api-endpoint="https://asu.instructure.com/api/v1/courses/123091/assignments/3257943" data-api-returntype="Assignment"></a></span><span>Due Date(s): <strong>Sunday, March 24th, 2024 by midnight</strong></span></li></ul><hr><ul><li><span><span><span><span><span><span><span><span><strong>Lab</strong> - Thu, Mar 21st</span></span></span></span></span></span></span></span><span><span><span><span><span><span><span><span><span><strong><br></strong></span></span></span></span></span></span></span></span></span></li><li><strong><span><a title="11.4 Practice Designing Database Tables" href="https://canvas.asu.edu/courses/178246/assignments/4864312" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864312" data-api-returntype="Assignment">11.4 Practice Designing Database Tables</a></span></strong></li><li><strong><span><a title="11.6 Practice Working with Airtable" href="https://canvas.asu.edu/courses/178246/assignments/4864313" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864313" data-api-returntype="Assignment">11.6 Practice Working with Airtable</a></span></strong></li><li><strong><span><a title="11.7 Design and Build a Database Assessment" href="https://canvas.asu.edu/courses/178246/assignments/4864314" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864314" data-api-returntype="Assignment">11.7 Design and Build a Database Assessment</a></span></strong></li><li><span>Due Date(s): <strong>Sunday, March 24th, 2024 by midnight</strong></span></li></ul></td></tr><tr><td><p>Week 11</p><span><strong>&nbsp;</strong></span></td><td><ul><li><span><strong>Lecture</strong> -&nbsp; Tue, Mar 26th</span><strong><span><br></span></strong></li><li><strong><span><a title="Knowledge Check 11 | Computer Security" href="https://canvas.asu.edu/courses/178246/assignments/4864357" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864357" data-api-returntype="Assignment">Knowledge Check 11 | Computer Security</a></span></strong></li><li><span>Due Date(s): <strong>Sunday, March 31st, 2024 by midnight</strong></span></li><li><span><strong>ZOOM Midterm Review(s) TBA</strong></span></li></ul><hr><ul><li><span><span><span><span><span><span><span><span><span><strong>Lab</strong> - Thu, Mar 28th</span></span></span></span></span></span></span></span></span></li><li><strong><span><a title="12.4 Select Clause Practice" href="https://canvas.asu.edu/courses/178246/assignments/4864316" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864316" data-api-returntype="Assignment">12.4 Select Clause Practice</a></span></strong></li><li><strong><span><a title="12.5 Distinct Keyword Practice" href="https://canvas.asu.edu/courses/178246/assignments/4864317" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864317" data-api-returntype="Assignment">12.5 Distinct Keyword Practice</a></span></strong></li><li><strong><span><a title="12.7 Order By Clause Practice" href="https://canvas.asu.edu/courses/178246/assignments/4864318" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864318" data-api-returntype="Assignment">12.7 Order By Clause Practice</a></span></strong></li><li><strong><span><a title="12.9 Limit Clause Practice" href="https://canvas.asu.edu/courses/178246/assignments/4864319" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864319" data-api-returntype="Assignment">12.9 Limit Clause Practice</a></span></strong></li><li><strong><span><a title="12.10 Introduction to SQL Assessment - Simpsons" href="https://canvas.asu.edu/courses/178246/assignments/4864315" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864315" data-api-returntype="Assignment">12.10 Introduction to SQL Assessment - Simpsons</a></span></strong></li><li><span>Due Date(s): <strong>Sunday, April 7th, 2024 by midnight</strong></span></li></ul></td></tr><tr><td><strong><span><span><span><span>&nbsp;</span></span></span></span></strong></td><td><span><span><strong>Exam 2</strong></span></span></td></tr><tr><td><p>Week 12</p><span><strong>&nbsp;</strong></span></td><td><ul><li><span><strong>Lecture</strong> - Tue, Apr 2nd</span></li><li><strong><span><a title="Knowledge Check 12 | Information Systems in Business" href="https://canvas.asu.edu/courses/178246/assignments/4864358" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864358" data-api-returntype="Assignment">Knowledge Check 12 | Information Systems in Business</a></span></strong><br><strong></strong></li><li><span>Due Date(s): <strong>Sunday, April 7th, 2024 by midnight</strong></span></li></ul><hr><ul><li><span><span><span><span><span><span><span><span><span><span><strong>Lab</strong> - Thu, Apr 4</span></span></span></span></span></span></span></span></span></span></li><li><strong><span><a title="13.3 Simple Where Clause Practice" href="https://canvas.asu.edu/courses/178246/assignments/4864322" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864322" data-api-returntype="Assignment">13.3 Simple Where Clause Practice</a></span></strong></li><li><strong><span><a title="13.5 Where Clause with Null Practice" href="https://canvas.asu.edu/courses/178246/assignments/4864323" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864323" data-api-returntype="Assignment">13.5 Where Clause with Null Practice</a></span></strong></li><li><strong><span><a title="13.8 Compound Where Clause Practice" href="https://canvas.asu.edu/courses/178246/assignments/4864324" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864324" data-api-returntype="Assignment">13.8 Compound Where Clause Practice</a></span></strong></li><li><strong><span><a title="13.10 Where Clause with Wildcards Practice" href="https://canvas.asu.edu/courses/178246/assignments/4864320" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864320" data-api-returntype="Assignment">13.10 Where Clause with Wildcards Practice</a></span></strong></li><li><strong><span><a title="13.11 Queries with Restrictions Assessment" href="https://canvas.asu.edu/courses/178246/assignments/4864321" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864321" data-api-returntype="Assignment">13.11 Queries with Restrictions Assessment</a></span></strong></li><li><span>Due Date(s): <strong>Sunday, April 14th, 2024 by midnight</strong></span></li></ul></td></tr><tr><td><p>Week 13</p><span><strong>&nbsp;</strong></span></td><td><ul><li><span><strong>Lecture</strong> - Tue, Apr 9th</span></li><li><span><strong><a title="Knowledge Check 13 | Business System Reporting" href="https://canvas.asu.edu/courses/178246/assignments/4864359" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864359" data-api-returntype="Assignment">Knowledge Check 13 | Business System Reporting</a></strong></span></li><li><strong><span><a title="Knowledge Check 14 | Information Technology Careers" href="https://canvas.asu.edu/courses/178246/assignments/4864360" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864360" data-api-returntype="Assignment">Knowledge Check 14 | Information Technology Careers</a></span></strong><br><strong></strong></li><li><span>Due Date(s): <strong>Sunday, April 21st, 2024 by midnight</strong></span></li></ul><hr><ul><li><span><span><span><span><span><span><span><span><span><span><span><span><strong>Lab</strong> - Thu, Apr 11th</span></span></span></span></span></span></span></span></span></span></span></span></li><li><strong><span><a title="14.2 Joining Two Tables Practice" href="https://canvas.asu.edu/courses/178246/assignments/4864325" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864325" data-api-returntype="Assignment">14.2 Joining Two Tables Practice</a></span></strong></li><li><strong><span><a title="14.4 Joining Three or More Tables Practice" href="https://canvas.asu.edu/courses/178246/assignments/4864326" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864326" data-api-returntype="Assignment">14.4 Joining Three or More Tables Practice</a></span></strong></li><li><strong><span><a title="14.6 Queries with Join and Where Practice" href="https://canvas.asu.edu/courses/178246/assignments/4864327" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864327" data-api-returntype="Assignment">14.6 Queries with Join and Where Practice</a></span></strong></li><li><strong><span><a title="14.7 Join Queries Assessment" href="https://canvas.asu.edu/courses/178246/assignments/4864328" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864328" data-api-returntype="Assignment">14.7 Join Queries Assessment</a></span></strong></li><li><span>Due Date(s): <strong>Sunday, April 21st, 2024 by midnight</strong></span></li></ul></td></tr><tr><td><span><strong>&nbsp;</strong></span></td><td><ul><li><span><strong>Lecture</strong> - Tue, Apr 16th</span><strong></strong></li><li><strong><span><a title="Knowledge Check 15 | Database" href="https://canvas.asu.edu/courses/178246/assignments/4864361" data-api-endpoint="https://canvas.asu.edu/api/v1/courses/178246/assignments/4864361" data-api-returntype="Assignment">Knowledge Check 15 | Database</a></span></strong><br><strong></strong></li><li><span>Due Date(s): <strong>Sunday, April 28th, 2024 by midnight</strong></span></li></ul></td></tr><tr><td><span><strong>&nbsp;</strong></span></td><td><ul><li><span><strong>Lecture - Thur, Apr 18th</strong></span></li><li><span><strong>Final Exam Review</strong></span></li></ul></td></tr><tr><td><strong><span><span>&nbsp;</span></span></strong></td><td><strong>Final Exam</strong></td></tr></tbody></table>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Welcome to Literature ]]></title>
            <link>https://note.toshiki.devacademic/literature/</link>
            <guid>https://note.toshiki.devacademic/literature/</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="welcome-to-literature" tabindex="-1">Welcome to Literature <a class="header-anchor" href="#welcome-to-literature" aria-label="Permalink to &quot;Welcome to Literature&quot;">&ZeroWidthSpace;</a></h1>
]]></description>
            <content:encoded><![CDATA[<h1 id="welcome-to-literature" tabindex="-1">Welcome to Literature <a class="header-anchor" href="#welcome-to-literature" aria-label="Permalink to &quot;Welcome to Literature&quot;">&ZeroWidthSpace;</a></h1>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Patterns of Organization and Methods of Development]]></title>
            <link>https://note.toshiki.devacademic/literature/writing/methods-of-development</link>
            <guid>https://note.toshiki.devacademic/literature/writing/methods-of-development</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="patterns-of-organization-and-methods-of-development" tabindex="-1">Patterns of Organization and Methods of Development <a class="header-anchor" href="#patterns-of-organization-and-methods-of-development" aria-label="Permalink to &quot;Patterns of Organization and Methods of Development&quot;">&ZeroWidthSpace;</a></h1>
<blockquote>
<p>Patterns of organization can help your readers follow the ideas within your essay and your paragraphs, but they can also work as methods of development to help you recognize and further develop ideas and relationships in your writing. Here are some strategies that can help you with both organization and development in your essays.</p>
</blockquote>
<h2 id="major-patterns-of-organization" tabindex="-1">Major Patterns of Organization <a class="header-anchor" href="#major-patterns-of-organization" aria-label="Permalink to &quot;Major Patterns of Organization&quot;">&ZeroWidthSpace;</a></h2>
<p><img src="https://r2.toshiki.dev/image/19875203514_543f7bff51_z-300x201.jpg" alt="A fruit pie."></p>
<p>Read the following sentences:</p>
<ul>
<li>Now take the pie out of the oven and let it cool on the stovetop.</li>
<li>Mix the dry ingredients with the liquid ingredients.</li>
<li>Set the pie crust aside while you make the filling.</li>
</ul>
<p>How did it feel to read the above list? A bit confusing, I would guess. That’s because the steps for making a pie were not well organized, and the steps don’t include enough detail for us to know exactly what we should do. (Like what are the dry and liquid ingredients?) We all know that starting instructions from the beginning and giving each detailed step in the order it should happen is vital to having a good outcome, in this case a yummy pie! But it’s not always so simple to know how to organize or develop ideas, and sometimes there’s more than one way, which complicates things even further.</p>
<p>First, let’s take a look at a couple of ways to think about organization.</p>
<h2 id="general-to-specific-or-specific-to-general" tabindex="-1">General to Specific or Specific to General <a class="header-anchor" href="#general-to-specific-or-specific-to-general" aria-label="Permalink to &quot;General to Specific or Specific to General&quot;">&ZeroWidthSpace;</a></h2>
<p>It might be useful to think about organizing your topic like a triangle:</p>
<p><img src="https://r2.toshiki.dev/image/Patterns_of_Organizaiton_Triangles.png" alt="Two triangles. The first is an inverted pyramid for General to Specific, the second is a pyramid for Specific to General."></p>
<p>The first triangle represents starting with the most general, big picture information first, moving then to more detailed and often more personal information later in the paper. The second triangle represents an organizational structure that starts with the specific, small scale information first and then moves to the more global, big picture stuff.</p>
<p>For example, if your topic is traffic in Vancouver, British Columbia, an essay that uses the general-to-specific organizational structure might begin this way:</p>
<p>Many people consider Vancouver, British Columbia, to be a relaxed place to live. They would be shocked to know how bad the traffic is traveling major arteries into the city and even driving around the city itself.</p>
<p>An essay that uses the specific-to-general structure might start like this:</p>
<p>Transit is crowded, parking is expensive, and vehicles stop and go through the main streets of the city of Vancouver, British Columbia, and that is just once travelers brave the crowded arteries to enter the city; Vancouver’s traffic problem does not lend itself to the relaxed atmosphere many believe the city to have.</p>
<p>What’s the difference between these two introductions? And how might they appeal to the intended audience for this essay in different ways? The first introduction is looking at the big picture of the problem and mentions pollution’s impact on all citizens in Portland, while the second introduction focuses on one specific family. The first helps readers see how vast the problem really is, and the second helps connect readers to a real family, making an emotional appeal from the very beginning. Neither introduction is necessarily better. You’ll choose one over the other based on the kind of tone you’d like to create and how you’d like to affect your audience. It’s completely up to you to make this decision.</p>
<h2 id="does-the-triangle-mean-the-essay-keeps-getting-more-specific-or-more-broad-until-the-very-end" tabindex="-1">Does the Triangle Mean the Essay Keeps Getting More Specific or More Broad until the Very End? <a class="header-anchor" href="#does-the-triangle-mean-the-essay-keeps-getting-more-specific-or-more-broad-until-the-very-end" aria-label="Permalink to &quot;Does the Triangle Mean the Essay Keeps Getting More Specific or More Broad until the Very End?&quot;">&ZeroWidthSpace;</a></h2>
<p>The triangle is kind of a general guide, meaning you’re allowed to move around within it all you want. For example, it’s possible that each of your paragraphs will be its own triangle, starting with the general or specific and moving out or in. However, if you begin very broadly, it might be effective to end your essay in a more specific, personal way. And if you begin with a personal story, consider ending your essay by touching on the global impact and importance of your topic.</p>
<h2 id="are-there-other-ways-to-think-about-organizing-my-ideas" tabindex="-1">Are There Other Ways to Think about Organizing My Ideas? <a class="header-anchor" href="#are-there-other-ways-to-think-about-organizing-my-ideas" aria-label="Permalink to &quot;Are There Other Ways to Think about Organizing My Ideas?&quot;">&ZeroWidthSpace;</a></h2>
<p>Yes! Rather than thinking about which of your ideas are most specific or personal or which are more broad or universal, you might consider one of the following ways of organizing your ideas:</p>
<ul>
<li>Most important information first (consider what you want readers to focus on first)</li>
<li>Chronological order (the order in time that events take place)</li>
<li>Compare and contrast (ideas are organized together because of their relationship to each other)</li>
</ul>
<p>The section on Methods of Development, below, offers more detail about some of these organizational patterns, along with some others.</p>
<p>Choose one of the following topics, and practice writing a few opening sentences like we did above, once using the general-to-specific format and once using the specific-to-general. Which do you like better? What audience would be attracted to which one? Share with peers to see how others tackled this challenge. How would you rewrite their sentences? Why? Discuss your changes and listen to how your peers have revised your sentences. Taking in other people’s ideas will help you see new ways to approach your own writing and thinking.<br>
Topics:</p>
<ul>
<li>Facing fears</li>
<li>Safety in sports</li>
<li>Community policing</li>
<li>Educating prisoners</li>
<li>Sex education</li>
</ul>
<h2 id="methods-of-development" tabindex="-1">Methods of Development <a class="header-anchor" href="#methods-of-development" aria-label="Permalink to &quot;Methods of Development&quot;">&ZeroWidthSpace;</a></h2>
<p>The methods of development covered here are best used as ways to look at what’s already happening in your draft and to consider how you might emphasize or expand on any existing patterns. You might already be familiar with some of these patterns because teachers will sometimes assign them as the purpose for writing an essay. For example, you might have been asked to write a cause-and-effect essay or a comparison-and-contrast essay.</p>
<p>It’s important to emphasize here that patterns of organization or methods of developing content usually happen naturally as a consequence of the way the writer engages with and organizes information while writing. That is to say, most writers don’t sit down and say, “I think I’ll write a cause-and-effect essay today.” Instead, a writer might be more likely to be interested in a topic, say, the state of drinking water in the local community, and as the writer begins to explore the topic, certain cause-and-effect relationships between environmental pollutants and the community water supply may begin to emerge.</p>
<p>So if these patterns just occur naturally in writing, what’s the use in knowing about them? Well, sometimes you might be revising a draft and notice that some of your paragraphs are a bit underdeveloped. Maybe they lack a clear topic, or maybe they lack support. In either case, you can look to these common methods of development to find ways to sharpen those vague topics or to add support where needed. Do you have a clear cause statement somewhere but you haven’t explored the effects? Are you lacking detail somewhere where a narrative story or historical chronology can help build reader interest and add support? Are you struggling to define an idea that might benefit from some comparison or contrast? Read on to consider some of the ways that these strategies can help you in revision.</p>
<h3 id="cause-and-effect-or-effect-and-cause" tabindex="-1">Cause and Effect (or Effect and Cause) <a class="header-anchor" href="#cause-and-effect-or-effect-and-cause" aria-label="Permalink to &quot;Cause and Effect (or Effect and Cause)&quot;">&ZeroWidthSpace;</a></h3>
<p>Do you see a potential cause-and-effect relationship developing in your draft? The cause-and-effect pattern may be used to identify one or more causes followed by one or more effects or results. Or you may reverse this sequence and describe effects first and then the cause or causes. For example, the causes of water pollution might be followed by its effects on both humans and animals. You may use obvious transitions to clarify cause and effect, such as “What are the results? Here are some of them…” or you might simply use the words <em>cause</em>, <em>effect</em>, and <em>result</em>, to cue the reader about your about the relationships that you’re establishing.</p>
<h3 id="problem-solution" tabindex="-1">Problem-Solution <a class="header-anchor" href="#problem-solution" aria-label="Permalink to &quot;Problem-Solution&quot;">&ZeroWidthSpace;</a></h3>
<p>At some point does your essay explore a problem or suggest a solution? The problem-solution pattern is commonly used in identifying something that’s wrong and in contemplating what might be done to remedy the situation. There are probably more ways to organize a problem-solution approach, but but here are three possibilities:</p>
<ul>
<li>Describe the problem, followed by the solution.</li>
<li>Propose the solution first and then describe the problems that motivated it.</li>
<li>Or a problem may be followed by several solutions, one of which is selected as the best.</li>
</ul>
<p>When the solution is stated at the end of the paper, the pattern is sometimes called the delayed proposal. For a hostile audience, it may be effective to describe the problem, show why other solutions do not work, and finally suggest the favored solution. You can emphasize the words <em>problem</em> and <em>solution</em> to signal these sections of your paper for your reader.</p>
<h3 id="chronology-or-narrative" tabindex="-1">Chronology or Narrative <a class="header-anchor" href="#chronology-or-narrative" aria-label="Permalink to &quot;Chronology or Narrative&quot;">&ZeroWidthSpace;</a></h3>
<p>Do you need to develop support for a topic where telling a story can illustrate some important concept for your readers? Material arranged chronologically is explained as it occurs in time. A chronological or narrative method of development might help you find a way to add both interest and content to your essay. Material arranged chronologically is explained as it occurs in time. This pattern may be used to establish what has happened. Chronology or narrative can be a great way to introduce your essay by providing a background or history behind your topic. Or you may want to tell a story to develop one or more points in the body of your essay. You can use transitional words like <em>then</em>, <em>next</em>, and <em>finally</em> to make the parts of the chronology clear.</p>
<h3 id="comparison-and-contrast" tabindex="-1">Comparison and Contrast <a class="header-anchor" href="#comparison-and-contrast" aria-label="Permalink to &quot;Comparison and Contrast&quot;">&ZeroWidthSpace;</a></h3>
<p>Are you trying to define something? Do you need your readers to understand what something is and what it is not? The comparison-and-contrast method of development is particularly useful in extending a definition, or anywhere you need to show how a subject is like or unlike another subject. For example, the statement is often made that drug abuse is a medical problem instead of a criminal justice issue. An author might attempt to prove this point by comparing drug addiction to AIDS, cancer, or heart disease to redefine the term “addiction” as a medical problem. A statement in opposition to this idea could just as easily establish contrast by explaining all the ways that addiction is different from what we traditionally understand as an illness. In seeking to establish comparison or contrast in your writing, some words or terms that might be useful are <em>by contrast</em>, <em>in comparison</em>, <em>while</em>, <em>some</em>, and <em>others</em>.</p>
<div class="tip custom-block"><p class="custom-block-title">Summary</p>
<p>These four methods of development—cause and effect, problem-solution, chronology or narrative, and comparison and contrast—are just a few ways to organize and develop ideas and content in your essays. It’s important to note that they should not be a starting point for writers who want to write something authentic—something that they care deeply about. Instead, they can be a great way to help you look for what’s already happening with your topic or in a draft, to help you to write more, or to help you reorganize some parts of an essay that seem to lack connection or feel disjointed. Look for organizational patterns when you’re reading work by professional writers. Notice where they combine strategies (e.g., a problem-solution pattern that uses cause-and-effect organization, or a comparison-contrast pattern that uses narrative or chronology to develop similarities or differences). Pay attention to how different writers emphasize and develop their main ideas, and use what you find to inspire you in your own writing. Better yet, work on developing completely new patterns of your own.</p>
</div>
<div class="info custom-block"><p class="custom-block-title">Reference</p>
<ul>
<li>
<p>This chapter was adapted from “<a href="https://openoregon.pressbooks.pub/wrd/chapter/patterns-of-organization-and-methods-of-development/" target="_blank" rel="noreferrer">Patterns of Organization and Methods of Development</a>” in <em>The Word on College Reading and Writing</em> by Carol Burnell, Jaime Wood, Monique Babin, Susan Pesznecker, and Nicole Rosevear, which is licensed under a <a href="https://creativecommons.org/licenses/by-nc/4.0/" target="_blank" rel="noreferrer">CC BY-NC 4.0 Licence</a>. Adapted by Allison Kilgannon.</p>
</li>
<li>
<p>“<a href="https://flic.kr/p/whiByE" target="_blank" rel="noreferrer">Peach and lavender pie</a>” by <a href="https://www.flickr.com/photos/heatherjoan/" target="_blank" rel="noreferrer">Heather Joan</a> is licensed under a <a href="https://creativecommons.org/licenses/by-nc-nd/2.0/" target="_blank" rel="noreferrer">CC BY-NC-ND 2.0 Licence</a>.</p>
</li>
<li>
<p>“General to Specific vs. Specific to General Triangles” by Carol Burnell, Jaime Wood, Monique Babin, Susan Pesznecker, and Nicole Rosevear is under a <a href="https://creativecommons.org/licenses/by-nc/4.0/" target="_blank" rel="noreferrer">CC BY-NC 4.0 Licence</a>.</p>
</li>
<li>
<p>Kilgannon, Allison. “Patterns of Organization and Methods of Development.” Opentextbc.ca, 20 Aug. 2021, opentextbc.ca/advancedenglish/chapter/patterns-of-organization-and-methods-of-development/#:~:text=These%20four%20methods%20of%20development.</p>
</li>
</ul>
</div>
]]></description>
            <content:encoded><![CDATA[<h1 id="patterns-of-organization-and-methods-of-development" tabindex="-1">Patterns of Organization and Methods of Development <a class="header-anchor" href="#patterns-of-organization-and-methods-of-development" aria-label="Permalink to &quot;Patterns of Organization and Methods of Development&quot;">&ZeroWidthSpace;</a></h1>
<blockquote>
<p>Patterns of organization can help your readers follow the ideas within your essay and your paragraphs, but they can also work as methods of development to help you recognize and further develop ideas and relationships in your writing. Here are some strategies that can help you with both organization and development in your essays.</p>
</blockquote>
<h2 id="major-patterns-of-organization" tabindex="-1">Major Patterns of Organization <a class="header-anchor" href="#major-patterns-of-organization" aria-label="Permalink to &quot;Major Patterns of Organization&quot;">&ZeroWidthSpace;</a></h2>
<p><img src="https://r2.toshiki.dev/image/19875203514_543f7bff51_z-300x201.jpg" alt="A fruit pie."></p>
<p>Read the following sentences:</p>
<ul>
<li>Now take the pie out of the oven and let it cool on the stovetop.</li>
<li>Mix the dry ingredients with the liquid ingredients.</li>
<li>Set the pie crust aside while you make the filling.</li>
</ul>
<p>How did it feel to read the above list? A bit confusing, I would guess. That’s because the steps for making a pie were not well organized, and the steps don’t include enough detail for us to know exactly what we should do. (Like what are the dry and liquid ingredients?) We all know that starting instructions from the beginning and giving each detailed step in the order it should happen is vital to having a good outcome, in this case a yummy pie! But it’s not always so simple to know how to organize or develop ideas, and sometimes there’s more than one way, which complicates things even further.</p>
<p>First, let’s take a look at a couple of ways to think about organization.</p>
<h2 id="general-to-specific-or-specific-to-general" tabindex="-1">General to Specific or Specific to General <a class="header-anchor" href="#general-to-specific-or-specific-to-general" aria-label="Permalink to &quot;General to Specific or Specific to General&quot;">&ZeroWidthSpace;</a></h2>
<p>It might be useful to think about organizing your topic like a triangle:</p>
<p><img src="https://r2.toshiki.dev/image/Patterns_of_Organizaiton_Triangles.png" alt="Two triangles. The first is an inverted pyramid for General to Specific, the second is a pyramid for Specific to General."></p>
<p>The first triangle represents starting with the most general, big picture information first, moving then to more detailed and often more personal information later in the paper. The second triangle represents an organizational structure that starts with the specific, small scale information first and then moves to the more global, big picture stuff.</p>
<p>For example, if your topic is traffic in Vancouver, British Columbia, an essay that uses the general-to-specific organizational structure might begin this way:</p>
<p>Many people consider Vancouver, British Columbia, to be a relaxed place to live. They would be shocked to know how bad the traffic is traveling major arteries into the city and even driving around the city itself.</p>
<p>An essay that uses the specific-to-general structure might start like this:</p>
<p>Transit is crowded, parking is expensive, and vehicles stop and go through the main streets of the city of Vancouver, British Columbia, and that is just once travelers brave the crowded arteries to enter the city; Vancouver’s traffic problem does not lend itself to the relaxed atmosphere many believe the city to have.</p>
<p>What’s the difference between these two introductions? And how might they appeal to the intended audience for this essay in different ways? The first introduction is looking at the big picture of the problem and mentions pollution’s impact on all citizens in Portland, while the second introduction focuses on one specific family. The first helps readers see how vast the problem really is, and the second helps connect readers to a real family, making an emotional appeal from the very beginning. Neither introduction is necessarily better. You’ll choose one over the other based on the kind of tone you’d like to create and how you’d like to affect your audience. It’s completely up to you to make this decision.</p>
<h2 id="does-the-triangle-mean-the-essay-keeps-getting-more-specific-or-more-broad-until-the-very-end" tabindex="-1">Does the Triangle Mean the Essay Keeps Getting More Specific or More Broad until the Very End? <a class="header-anchor" href="#does-the-triangle-mean-the-essay-keeps-getting-more-specific-or-more-broad-until-the-very-end" aria-label="Permalink to &quot;Does the Triangle Mean the Essay Keeps Getting More Specific or More Broad until the Very End?&quot;">&ZeroWidthSpace;</a></h2>
<p>The triangle is kind of a general guide, meaning you’re allowed to move around within it all you want. For example, it’s possible that each of your paragraphs will be its own triangle, starting with the general or specific and moving out or in. However, if you begin very broadly, it might be effective to end your essay in a more specific, personal way. And if you begin with a personal story, consider ending your essay by touching on the global impact and importance of your topic.</p>
<h2 id="are-there-other-ways-to-think-about-organizing-my-ideas" tabindex="-1">Are There Other Ways to Think about Organizing My Ideas? <a class="header-anchor" href="#are-there-other-ways-to-think-about-organizing-my-ideas" aria-label="Permalink to &quot;Are There Other Ways to Think about Organizing My Ideas?&quot;">&ZeroWidthSpace;</a></h2>
<p>Yes! Rather than thinking about which of your ideas are most specific or personal or which are more broad or universal, you might consider one of the following ways of organizing your ideas:</p>
<ul>
<li>Most important information first (consider what you want readers to focus on first)</li>
<li>Chronological order (the order in time that events take place)</li>
<li>Compare and contrast (ideas are organized together because of their relationship to each other)</li>
</ul>
<p>The section on Methods of Development, below, offers more detail about some of these organizational patterns, along with some others.</p>
<p>Choose one of the following topics, and practice writing a few opening sentences like we did above, once using the general-to-specific format and once using the specific-to-general. Which do you like better? What audience would be attracted to which one? Share with peers to see how others tackled this challenge. How would you rewrite their sentences? Why? Discuss your changes and listen to how your peers have revised your sentences. Taking in other people’s ideas will help you see new ways to approach your own writing and thinking.<br>
Topics:</p>
<ul>
<li>Facing fears</li>
<li>Safety in sports</li>
<li>Community policing</li>
<li>Educating prisoners</li>
<li>Sex education</li>
</ul>
<h2 id="methods-of-development" tabindex="-1">Methods of Development <a class="header-anchor" href="#methods-of-development" aria-label="Permalink to &quot;Methods of Development&quot;">&ZeroWidthSpace;</a></h2>
<p>The methods of development covered here are best used as ways to look at what’s already happening in your draft and to consider how you might emphasize or expand on any existing patterns. You might already be familiar with some of these patterns because teachers will sometimes assign them as the purpose for writing an essay. For example, you might have been asked to write a cause-and-effect essay or a comparison-and-contrast essay.</p>
<p>It’s important to emphasize here that patterns of organization or methods of developing content usually happen naturally as a consequence of the way the writer engages with and organizes information while writing. That is to say, most writers don’t sit down and say, “I think I’ll write a cause-and-effect essay today.” Instead, a writer might be more likely to be interested in a topic, say, the state of drinking water in the local community, and as the writer begins to explore the topic, certain cause-and-effect relationships between environmental pollutants and the community water supply may begin to emerge.</p>
<p>So if these patterns just occur naturally in writing, what’s the use in knowing about them? Well, sometimes you might be revising a draft and notice that some of your paragraphs are a bit underdeveloped. Maybe they lack a clear topic, or maybe they lack support. In either case, you can look to these common methods of development to find ways to sharpen those vague topics or to add support where needed. Do you have a clear cause statement somewhere but you haven’t explored the effects? Are you lacking detail somewhere where a narrative story or historical chronology can help build reader interest and add support? Are you struggling to define an idea that might benefit from some comparison or contrast? Read on to consider some of the ways that these strategies can help you in revision.</p>
<h3 id="cause-and-effect-or-effect-and-cause" tabindex="-1">Cause and Effect (or Effect and Cause) <a class="header-anchor" href="#cause-and-effect-or-effect-and-cause" aria-label="Permalink to &quot;Cause and Effect (or Effect and Cause)&quot;">&ZeroWidthSpace;</a></h3>
<p>Do you see a potential cause-and-effect relationship developing in your draft? The cause-and-effect pattern may be used to identify one or more causes followed by one or more effects or results. Or you may reverse this sequence and describe effects first and then the cause or causes. For example, the causes of water pollution might be followed by its effects on both humans and animals. You may use obvious transitions to clarify cause and effect, such as “What are the results? Here are some of them…” or you might simply use the words <em>cause</em>, <em>effect</em>, and <em>result</em>, to cue the reader about your about the relationships that you’re establishing.</p>
<h3 id="problem-solution" tabindex="-1">Problem-Solution <a class="header-anchor" href="#problem-solution" aria-label="Permalink to &quot;Problem-Solution&quot;">&ZeroWidthSpace;</a></h3>
<p>At some point does your essay explore a problem or suggest a solution? The problem-solution pattern is commonly used in identifying something that’s wrong and in contemplating what might be done to remedy the situation. There are probably more ways to organize a problem-solution approach, but but here are three possibilities:</p>
<ul>
<li>Describe the problem, followed by the solution.</li>
<li>Propose the solution first and then describe the problems that motivated it.</li>
<li>Or a problem may be followed by several solutions, one of which is selected as the best.</li>
</ul>
<p>When the solution is stated at the end of the paper, the pattern is sometimes called the delayed proposal. For a hostile audience, it may be effective to describe the problem, show why other solutions do not work, and finally suggest the favored solution. You can emphasize the words <em>problem</em> and <em>solution</em> to signal these sections of your paper for your reader.</p>
<h3 id="chronology-or-narrative" tabindex="-1">Chronology or Narrative <a class="header-anchor" href="#chronology-or-narrative" aria-label="Permalink to &quot;Chronology or Narrative&quot;">&ZeroWidthSpace;</a></h3>
<p>Do you need to develop support for a topic where telling a story can illustrate some important concept for your readers? Material arranged chronologically is explained as it occurs in time. A chronological or narrative method of development might help you find a way to add both interest and content to your essay. Material arranged chronologically is explained as it occurs in time. This pattern may be used to establish what has happened. Chronology or narrative can be a great way to introduce your essay by providing a background or history behind your topic. Or you may want to tell a story to develop one or more points in the body of your essay. You can use transitional words like <em>then</em>, <em>next</em>, and <em>finally</em> to make the parts of the chronology clear.</p>
<h3 id="comparison-and-contrast" tabindex="-1">Comparison and Contrast <a class="header-anchor" href="#comparison-and-contrast" aria-label="Permalink to &quot;Comparison and Contrast&quot;">&ZeroWidthSpace;</a></h3>
<p>Are you trying to define something? Do you need your readers to understand what something is and what it is not? The comparison-and-contrast method of development is particularly useful in extending a definition, or anywhere you need to show how a subject is like or unlike another subject. For example, the statement is often made that drug abuse is a medical problem instead of a criminal justice issue. An author might attempt to prove this point by comparing drug addiction to AIDS, cancer, or heart disease to redefine the term “addiction” as a medical problem. A statement in opposition to this idea could just as easily establish contrast by explaining all the ways that addiction is different from what we traditionally understand as an illness. In seeking to establish comparison or contrast in your writing, some words or terms that might be useful are <em>by contrast</em>, <em>in comparison</em>, <em>while</em>, <em>some</em>, and <em>others</em>.</p>
<div class="tip custom-block"><p class="custom-block-title">Summary</p>
<p>These four methods of development—cause and effect, problem-solution, chronology or narrative, and comparison and contrast—are just a few ways to organize and develop ideas and content in your essays. It’s important to note that they should not be a starting point for writers who want to write something authentic—something that they care deeply about. Instead, they can be a great way to help you look for what’s already happening with your topic or in a draft, to help you to write more, or to help you reorganize some parts of an essay that seem to lack connection or feel disjointed. Look for organizational patterns when you’re reading work by professional writers. Notice where they combine strategies (e.g., a problem-solution pattern that uses cause-and-effect organization, or a comparison-contrast pattern that uses narrative or chronology to develop similarities or differences). Pay attention to how different writers emphasize and develop their main ideas, and use what you find to inspire you in your own writing. Better yet, work on developing completely new patterns of your own.</p>
</div>
<div class="info custom-block"><p class="custom-block-title">Reference</p>
<ul>
<li>
<p>This chapter was adapted from “<a href="https://openoregon.pressbooks.pub/wrd/chapter/patterns-of-organization-and-methods-of-development/" target="_blank" rel="noreferrer">Patterns of Organization and Methods of Development</a>” in <em>The Word on College Reading and Writing</em> by Carol Burnell, Jaime Wood, Monique Babin, Susan Pesznecker, and Nicole Rosevear, which is licensed under a <a href="https://creativecommons.org/licenses/by-nc/4.0/" target="_blank" rel="noreferrer">CC BY-NC 4.0 Licence</a>. Adapted by Allison Kilgannon.</p>
</li>
<li>
<p>“<a href="https://flic.kr/p/whiByE" target="_blank" rel="noreferrer">Peach and lavender pie</a>” by <a href="https://www.flickr.com/photos/heatherjoan/" target="_blank" rel="noreferrer">Heather Joan</a> is licensed under a <a href="https://creativecommons.org/licenses/by-nc-nd/2.0/" target="_blank" rel="noreferrer">CC BY-NC-ND 2.0 Licence</a>.</p>
</li>
<li>
<p>“General to Specific vs. Specific to General Triangles” by Carol Burnell, Jaime Wood, Monique Babin, Susan Pesznecker, and Nicole Rosevear is under a <a href="https://creativecommons.org/licenses/by-nc/4.0/" target="_blank" rel="noreferrer">CC BY-NC 4.0 Licence</a>.</p>
</li>
<li>
<p>Kilgannon, Allison. “Patterns of Organization and Methods of Development.” Opentextbc.ca, 20 Aug. 2021, opentextbc.ca/advancedenglish/chapter/patterns-of-organization-and-methods-of-development/#:~:text=These%20four%20methods%20of%20development.</p>
</li>
</ul>
</div>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Welcome to Physics ]]></title>
            <link>https://note.toshiki.devacademic/physics/</link>
            <guid>https://note.toshiki.devacademic/physics/</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="welcome-to-physics" tabindex="-1">Welcome to Physics <a class="header-anchor" href="#welcome-to-physics" aria-label="Permalink to &quot;Welcome to Physics&quot;">&ZeroWidthSpace;</a></h1>
]]></description>
            <content:encoded><![CDATA[<h1 id="welcome-to-physics" tabindex="-1">Welcome to Physics <a class="header-anchor" href="#welcome-to-physics" aria-label="Permalink to &quot;Welcome to Physics&quot;">&ZeroWidthSpace;</a></h1>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Formulas for IPhO 日本語版: Section 1 ]]></title>
            <link>https://note.toshiki.devacademic/physics/ipho-formulas-jpn/1</link>
            <guid>https://note.toshiki.devacademic/physics/ipho-formulas-jpn/1</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="formulas-for-ipho-日本語版-section-1" tabindex="-1">Formulas for IPhO 日本語版: Section 1 <a class="header-anchor" href="#formulas-for-ipho-日本語版-section-1" aria-label="Permalink to &quot;Formulas for IPhO 日本語版: Section 1&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="_1-数学" tabindex="-1">1: 数学 <a class="header-anchor" href="#_1-数学" aria-label="Permalink to &quot;1: 数学&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="_1-1-taylor-展開" tabindex="-1">1.1: Taylor 展開 <a class="header-anchor" href="#_1-1-taylor-展開" aria-label="Permalink to &quot;1.1: Taylor 展開&quot;">&ZeroWidthSpace;</a></h3>
<ol>
<li>
<p>Taylor 展開（アバウトに切り捨てる:</p>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mi>F</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo><mo>=</mo><mi>F</mi><mrow><mo fence="true">(</mo><msub><mi>x</mi><mn>0</mn></msub><mo fence="true">)</mo></mrow><mo>+</mo><mo>∑</mo><msup><mi>F</mi><mrow><mo stretchy="false">(</mo><mi>n</mi><mo stretchy="false">)</mo></mrow></msup><mrow><mo fence="true">(</mo><msub><mi>x</mi><mn>0</mn></msub><mo fence="true">)</mo></mrow><msup><mrow><mo fence="true">(</mo><mi>x</mi><mo>−</mo><msub><mi>x</mi><mn>0</mn></msub><mo fence="true">)</mo></mrow><mi>n</mi></msup><mi mathvariant="normal">/</mi><mi>n</mi></mrow><annotation encoding="application/x-tex">F(x)=F\left(x_{0}\right)+\sum F^{(n)}\left(x_{0}\right)\left(x-x_{0}\right)^{n} / n
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.13889em;">F</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">)</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.13889em;">F</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">0</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">)</span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1.6em;vertical-align:-0.55em;"></span><span class="mop op-symbol large-op" style="position:relative;top:0em;">∑</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.13889em;">F</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.938em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mopen mtight">(</span><span class="mord mathnormal mtight">n</span><span class="mclose mtight">)</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">0</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">)</span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord mathnormal">x</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">0</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">)</span></span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8043em;"><span style="top:-3.2029em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">n</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord">/</span><span class="mord mathnormal">n</span></span></span></span></span></p>
<p>線形近似（特別な場合）:</p>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mi>F</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo><mo>≈</mo><mi>F</mi><mrow><mo fence="true">(</mo><msub><mi>x</mi><mn>0</mn></msub><mo fence="true">)</mo></mrow><mo>+</mo><msup><mi>F</mi><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup><mrow><mo fence="true">(</mo><msub><mi>x</mi><mn>0</mn></msub><mo fence="true">)</mo></mrow><mrow><mo fence="true">(</mo><mi>x</mi><mo>−</mo><msub><mi>x</mi><mn>0</mn></msub><mo fence="true">)</mo></mrow></mrow><annotation encoding="application/x-tex">F(x) \approx F\left(x_{0}\right)+F^{\prime}\left(x_{0}\right)\left(x-x_{0}\right)
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.13889em;">F</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">)</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≈</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.13889em;">F</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">0</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">)</span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1.0519em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.13889em;">F</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8019em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">0</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">)</span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord mathnormal">x</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">0</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">)</span></span></span></span></span></span></p>
<p><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∣</mi><mi>x</mi><mi mathvariant="normal">∣</mi><mo>≪</mo><mn>1</mn></mrow><annotation encoding="application/x-tex">|x| \ll 1</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">∣</span><span class="mord mathnormal">x</span><span class="mord">∣</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≪</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">1</span></span></span></span> のときの例 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>:</mo></mrow><annotation encoding="application/x-tex">:</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mrel">:</span></span></span></span></p>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mi>sin</mi><mo>⁡</mo><mi>x</mi><mo>≈</mo><mi>x</mi><mo separator="true">,</mo><mi>cos</mi><mo>⁡</mo><mi>x</mi><mo>≈</mo><mn>1</mn><mo>−</mo><msup><mi>x</mi><mn>2</mn></msup><mi mathvariant="normal">/</mi><mn>2</mn><mo separator="true">,</mo><msup><mi>e</mi><mi>x</mi></msup><mo>≈</mo><mn>1</mn><mo>+</mo><mi>x</mi></mrow><annotation encoding="application/x-tex">\sin x \approx x, \cos x \approx 1-x^{2} / 2, e^{x} \approx 1+x
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6679em;"></span><span class="mop">sin</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">x</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≈</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6776em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">x</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">cos</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">x</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≈</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.7278em;vertical-align:-0.0833em;"></span><span class="mord">1</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1.1141em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span><span class="mord">/2</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal">e</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7144em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">x</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≈</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.7278em;vertical-align:-0.0833em;"></span><span class="mord">1</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">x</span></span></span></span></span></p>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mi>ln</mi><mo>⁡</mo><mo stretchy="false">(</mo><mn>1</mn><mo>+</mo><mi>x</mi><mo stretchy="false">)</mo><mo>≈</mo><mi>x</mi><mo separator="true">,</mo><mo stretchy="false">(</mo><mn>1</mn><mo>+</mo><mi>x</mi><msup><mo stretchy="false">)</mo><mi>n</mi></msup><mo>≈</mo><mn>1</mn><mo>+</mo><mi>n</mi><mi>x</mi></mrow><annotation encoding="application/x-tex">\ln (1+x) \approx x,(1+x)^{n} \approx 1+n x
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mop">ln</span><span class="mopen">(</span><span class="mord">1</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal">x</span><span class="mclose">)</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≈</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal">x</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mopen">(</span><span class="mord">1</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal">x</span><span class="mclose"><span class="mclose">)</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7144em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">n</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≈</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.7278em;vertical-align:-0.0833em;"></span><span class="mord">1</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">n</span><span class="mord mathnormal">x</span></span></span></span></span></p>
</li>
</ol>
<h3 id="_1-2-摂動法" tabindex="-1">1.2: 摂動法 <a class="header-anchor" href="#_1-2-摂動法" aria-label="Permalink to &quot;1.2: 摂動法&quot;">&ZeroWidthSpace;</a></h3>
<ol start="2">
<li>摂動法：摂動のない（直接解ける）問題の解を <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>0</mn></mrow><annotation encoding="application/x-tex">0</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">0</span></span></span></span> 番目の近似値として求め，前の似値に基づく次の近似値の補正を繰り返して解を求める．</li>
</ol>
<h3 id="_1-3-定数係数線形微分方程式" tabindex="-1">1.3: 定数係数線形微分方程式 <a class="header-anchor" href="#_1-3-定数係数線形微分方程式" aria-label="Permalink to &quot;1.3: 定数係数線形微分方程式&quot;">&ZeroWidthSpace;</a></h3>
<ol start="3">
<li>
<p>定数係数線形微分方程式 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><msup><mi>y</mi><mrow><mo mathvariant="normal">′</mo><mo mathvariant="normal">′</mo></mrow></msup><mo>+</mo><mi>b</mi><msup><mi>y</mi><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup><mo>+</mo><mi>c</mi><mi>y</mi><mo>=</mo><mn>0</mn></mrow><annotation encoding="application/x-tex">a y^{\prime \prime}+b y^{\prime}+c y=0</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9463em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">a</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">y</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7519em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′′</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.9463em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">b</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">y</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7519em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">cy</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">0</span></span></span></span> の解:</p>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mi>y</mi><mo>=</mo><mi>A</mi><mi>exp</mi><mo>⁡</mo><mrow><mo fence="true">(</mo><msub><mi>λ</mi><mn>1</mn></msub><mi>x</mi><mo fence="true">)</mo></mrow><mo>+</mo><mi>B</mi><mi>exp</mi><mo>⁡</mo><mrow><mo fence="true">(</mo><msub><mi>λ</mi><mn>2</mn></msub><mi>x</mi><mo fence="true">)</mo></mrow><mtext>. </mtext></mrow><annotation encoding="application/x-tex">y=A \exp \left(\lambda_1 x\right)+B \exp \left(\lambda_2 x\right) \text {. }
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">y</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal">A</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">exp</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord"><span class="mord mathnormal">λ</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord mathnormal">x</span><span class="mclose delimcenter" style="top:0em;">)</span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">exp</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord"><span class="mord mathnormal">λ</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord mathnormal">x</span><span class="mclose delimcenter" style="top:0em;">)</span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord text"><span class="mord">. </span></span></span></span></span></span></p>
<p>ここで <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>λ</mi><mrow><mn>1</mn><mo separator="true">,</mo><mn>2</mn></mrow></msub></mrow><annotation encoding="application/x-tex">\lambda_{1,2}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9805em;vertical-align:-0.2861em;"></span><span class="mord"><span class="mord mathnormal">λ</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">1</span><span class="mpunct mtight">,</span><span class="mord mtight">2</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span></span></span></span> は特性方程式 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><msup><mi>λ</mi><mn>2</mn></msup><mo>+</mo><mi>b</mi><mi>λ</mi><mo>+</mo><mi>c</mi><mo>=</mo><mn>0</mn></mrow><annotation encoding="application/x-tex">a \lambda^2+b \lambda+c=0</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8974em;vertical-align:-0.0833em;"></span><span class="mord mathnormal">a</span><span class="mord"><span class="mord mathnormal">λ</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.7778em;vertical-align:-0.0833em;"></span><span class="mord mathnormal">bλ</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">c</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">0</span></span></span></span> の異な る 2 解. もし <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mo separator="true">,</mo><mi>b</mi><mo separator="true">,</mo><mi>c</mi></mrow><annotation encoding="application/x-tex">a, b, c</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">a</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">b</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">c</span></span></span></span> が実数で特性方程式の解が複素数 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>λ</mi><mrow><mn>1</mn><mo separator="true">,</mo><mn>2</mn></mrow></msub><mo>=</mo><mi>γ</mi><mo>±</mo><mi>i</mi><mi>ω</mi></mrow><annotation encoding="application/x-tex">\lambda_{1,2}=\gamma \pm i \omega</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9805em;vertical-align:-0.2861em;"></span><span class="mord"><span class="mord mathnormal">λ</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">1</span><span class="mpunct mtight">,</span><span class="mord mtight">2</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.7778em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.05556em;">γ</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">±</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6595em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">iω</span></span></span></span> ならば,</p>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mi>y</mi><mo>=</mo><mi>C</mi><msup><mi>e</mi><mrow><mi>γ</mi><mi>x</mi></mrow></msup><mi>sin</mi><mo>⁡</mo><mrow><mo fence="true">(</mo><mi>ω</mi><mi>x</mi><mo>+</mo><msub><mi>φ</mi><mn>0</mn></msub><mo fence="true">)</mo></mrow></mrow><annotation encoding="application/x-tex">y=C e^{\gamma x} \sin \left(\omega x+\varphi_0\right)
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">y</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.07153em;">C</span><span class="mord"><span class="mord mathnormal">e</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7144em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.05556em;">γ</span><span class="mord mathnormal mtight">x</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">sin</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord mathnormal" style="margin-right:0.03588em;">ω</span><span class="mord mathnormal">x</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal">φ</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">0</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">)</span></span></span></span></span></span></p>
</li>
</ol>
<h3 id="_1-4-複素数" tabindex="-1">1.4: 複素数 <a class="header-anchor" href="#_1-4-複素数" aria-label="Permalink to &quot;1.4: 複素数&quot;">&ZeroWidthSpace;</a></h3>
<ol start="4">
<li>
<p>複素数</p>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mtable rowspacing="0.25em" columnalign="center" columnspacing="0em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mi>z</mi><mo>=</mo><mi>a</mi><mo>+</mo><mi>b</mi><mi>i</mi><mo>=</mo><mi mathvariant="normal">∣</mi><mi>z</mi><mi mathvariant="normal">∣</mi><msup><mi>e</mi><mrow><mi>i</mi><mi>φ</mi></mrow></msup><mo separator="true">,</mo><mover accent="true"><mi>z</mi><mo>ˉ</mo></mover><mo>=</mo><mi>a</mi><mo>−</mo><mi>b</mi><mi>i</mi><mo>=</mo><mi mathvariant="normal">∣</mi><mi>z</mi><mi mathvariant="normal">∣</mi><msup><mi>e</mi><mrow><mo>−</mo><mi>i</mi><mi>φ</mi></mrow></msup></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mi mathvariant="normal">∣</mi><mi>z</mi><msup><mi mathvariant="normal">∣</mi><mn>2</mn></msup><mo>=</mo><mi>z</mi><mover accent="true"><mi>z</mi><mo>ˉ</mo></mover><mo>=</mo><msup><mi>a</mi><mn>2</mn></msup><mo>+</mo><msup><mi>b</mi><mn>2</mn></msup><mo separator="true">,</mo><mi>φ</mi><mo>=</mo><mi>arg</mi><mo>⁡</mo><mi>z</mi><mo>=</mo><mi>arcsin</mi><mo>⁡</mo><mfrac><mi>b</mi><mrow><mi mathvariant="normal">∣</mi><mi>z</mi><mi mathvariant="normal">∣</mi></mrow></mfrac></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mi mathvariant="normal">Re</mi><mo>⁡</mo><mi>z</mi><mo>=</mo><mo stretchy="false">(</mo><mi>z</mi><mo>+</mo><mover accent="true"><mi>z</mi><mo>ˉ</mo></mover><mo stretchy="false">)</mo><mi mathvariant="normal">/</mi><mn>2</mn><mo separator="true">,</mo><mi mathvariant="normal">Im</mi><mo>⁡</mo><mi>z</mi><mo>=</mo><mo stretchy="false">(</mo><mi>z</mi><mo>−</mo><mover accent="true"><mi>z</mi><mo>ˉ</mo></mover><mo stretchy="false">)</mo><mi mathvariant="normal">/</mi><mn>2</mn><mi>i</mi></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow><mo fence="true">∣</mo><msub><mi>z</mi><mn>1</mn></msub><msub><mi>z</mi><mn>2</mn></msub><mo fence="true">∣</mo></mrow><mo>=</mo><mrow><mo fence="true">∣</mo><msub><mi>z</mi><mn>1</mn></msub><mo fence="true">∣</mo></mrow><mrow><mo fence="true">∣</mo><msub><mi>z</mi><mn>2</mn></msub><mo fence="true">∣</mo></mrow><mo separator="true">,</mo><mi>arg</mi><mo>⁡</mo><msub><mi>z</mi><mn>1</mn></msub><msub><mi>z</mi><mn>2</mn></msub><mo>=</mo><mi>arg</mi><mo>⁡</mo><msub><mi>z</mi><mn>1</mn></msub><mo>+</mo><mi>arg</mi><mo>⁡</mo><msub><mi>z</mi><mn>2</mn></msub></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><msup><mi>e</mi><mrow><mi>i</mi><mi>φ</mi></mrow></msup><mo>=</mo><mi>cos</mi><mo>⁡</mo><mi>φ</mi><mo>+</mo><mi>i</mi><mi>sin</mi><mo>⁡</mo><mi>φ</mi></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mi>cos</mi><mo>⁡</mo><mi>φ</mi><mo>=</mo><mfrac><mrow><msup><mi>e</mi><mrow><mi>i</mi><mi>φ</mi></mrow></msup><mo>+</mo><msup><mi>e</mi><mrow><mo>−</mo><mi>i</mi><mi>φ</mi></mrow></msup></mrow><mn>2</mn></mfrac><mo separator="true">,</mo><mi>sin</mi><mo>⁡</mo><mi>φ</mi><mo>=</mo><mfrac><mrow><msup><mi>e</mi><mrow><mi>i</mi><mi>φ</mi></mrow></msup><mo>−</mo><msup><mi>e</mi><mrow><mo>−</mo><mi>i</mi><mi>φ</mi></mrow></msup></mrow><mrow><mn>2</mn><mi>i</mi></mrow></mfrac></mrow></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{gathered}
z=a+b i=|z| e^{i \varphi}, \bar{z}=a-b i=|z| e^{-i \varphi} \\
|z|^2=z \bar{z}=a^2+b^2, \varphi=\arg z=\arcsin \frac{b}{|z|} \\
\operatorname{Re} z=(z+\bar{z}) / 2, \operatorname{Im} z=(z-\bar{z}) / 2 i \\
\left|z_1 z_2\right|=\left|z_1\right|\left|z_2\right|, \arg z_1 z_2=\arg z_1+\arg z_2 \\
e^{i \varphi}=\cos \varphi+i \sin \varphi \\
\cos \varphi=\frac{e^{i \varphi}+e^{-i \varphi}}{2}, \sin \varphi=\frac{e^{i \varphi}-e^{-i \varphi}}{2 i}
\end{gathered}
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:11.1644em;vertical-align:-5.3322em;"></span><span class="mord"><span class="mtable"><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:5.8322em;"><span style="top:-8.4592em;"><span class="pstrut" style="height:3.5017em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.04398em;">z</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord mathnormal">a</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal">bi</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord">∣</span><span class="mord mathnormal" style="margin-right:0.04398em;">z</span><span class="mord">∣</span><span class="mord"><span class="mord mathnormal">e</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8747em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">i</span><span class="mord mathnormal mtight">φ</span></span></span></span></span></span></span></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.5678em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord mathnormal" style="margin-right:0.04398em;">z</span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.1944em;"><span class="mord">ˉ</span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord mathnormal">a</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal">bi</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord">∣</span><span class="mord mathnormal" style="margin-right:0.04398em;">z</span><span class="mord">∣</span><span class="mord"><span class="mord mathnormal">e</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8747em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">−</span><span class="mord mathnormal mtight">i</span><span class="mord mathnormal mtight">φ</span></span></span></span></span></span></span></span></span></span></span><span style="top:-6.4278em;"><span class="pstrut" style="height:3.5017em;"></span><span class="mord"><span class="mord">∣</span><span class="mord mathnormal" style="margin-right:0.04398em;">z</span><span class="mord"><span class="mord">∣</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord mathnormal" style="margin-right:0.04398em;">z</span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.5678em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord mathnormal" style="margin-right:0.04398em;">z</span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.1944em;"><span class="mord">ˉ</span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal">b</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">φ</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mop">ar<span style="margin-right:0.01389em;">g</span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.04398em;">z</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mop">arcsin</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.3714em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">∣</span><span class="mord mathnormal" style="margin-right:0.04398em;">z</span><span class="mord">∣</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">b</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.936em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span><span style="top:-4.3518em;"><span class="pstrut" style="height:3.5017em;"></span><span class="mord"><span class="mop"><span class="mord mathrm">Re</span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.04398em;">z</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.04398em;">z</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.5678em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord mathnormal" style="margin-right:0.04398em;">z</span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.1944em;"><span class="mord">ˉ</span></span></span></span></span></span></span><span class="mclose">)</span><span class="mord">/2</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop"><span class="mord mathrm">Im</span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.04398em;">z</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.04398em;">z</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.5678em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord mathnormal" style="margin-right:0.04398em;">z</span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.1944em;"><span class="mord">ˉ</span></span></span></span></span></span></span><span class="mclose">)</span><span class="mord">/2</span><span class="mord mathnormal">i</span></span></span><span style="top:-2.8518em;"><span class="pstrut" style="height:3.5017em;"></span><span class="mord"><span class="minner"><span class="mopen delimcenter" style="top:0em;">∣</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.04398em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.044em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.04398em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.044em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">∣</span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">∣</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.04398em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.044em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">∣</span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">∣</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.04398em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.044em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">∣</span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">ar<span style="margin-right:0.01389em;">g</span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.04398em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.044em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.04398em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.044em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mop">ar<span style="margin-right:0.01389em;">g</span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.04398em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.044em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mop">ar<span style="margin-right:0.01389em;">g</span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.04398em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.044em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span><span style="top:-1.3171em;"><span class="pstrut" style="height:3.5017em;"></span><span class="mord"><span class="mord"><span class="mord mathnormal">e</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8747em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">i</span><span class="mord mathnormal mtight">φ</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mop">cos</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">φ</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal">i</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">sin</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">φ</span></span></span><span style="top:0.8446em;"><span class="pstrut" style="height:3.5017em;"></span><span class="mord"><span class="mop">cos</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">φ</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.5017em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">2</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"><span class="mord mathnormal">e</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8247em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">i</span><span class="mord mathnormal mtight">φ</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal">e</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8247em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">−</span><span class="mord mathnormal mtight">i</span><span class="mord mathnormal mtight">φ</span></span></span></span></span></span></span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">sin</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">φ</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.5017em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">2</span><span class="mord mathnormal">i</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"><span class="mord mathnormal">e</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8247em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">i</span><span class="mord mathnormal mtight">φ</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal">e</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8247em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">−</span><span class="mord mathnormal mtight">i</span><span class="mord mathnormal mtight">φ</span></span></span></span></span></span></span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:5.3322em;"><span></span></span></span></span></span></span></span></span></span></span></span></p>
</li>
</ol>
<h3 id="_1-5-ベクトルの内積と外積" tabindex="-1">1.5: ベクトルの内積と外積 <a class="header-anchor" href="#_1-5-ベクトルの内積と外積" aria-label="Permalink to &quot;1.5: ベクトルの内積と外積&quot;">&ZeroWidthSpace;</a></h3>
<ol start="5">
<li>
<p>ベクトルの内積と外積は分配法則が成立する : <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mo stretchy="false">(</mo><mi>b</mi><mo>+</mo><mi>c</mi><mo stretchy="false">)</mo><mo>=</mo><mi>a</mi><mi>b</mi><mo>+</mo><mi>a</mi><mi>c</mi></mrow><annotation encoding="application/x-tex">a(b+c)=a b+a c</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal">a</span><span class="mopen">(</span><span class="mord mathnormal">b</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal">c</span><span class="mclose">)</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.7778em;vertical-align:-0.0833em;"></span><span class="mord mathnormal">ab</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">a</span><span class="mord mathnormal">c</span></span></span></span></p>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mtable rowspacing="0.25em" columnalign="center" columnspacing="0em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mi mathvariant="bold-italic">a</mi><mo>⋅</mo><mi mathvariant="bold-italic">b</mi><mo>=</mo><mi mathvariant="bold-italic">b</mi><mo>⋅</mo><mi mathvariant="bold-italic">a</mi><mo>=</mo><msub><mi>a</mi><mi>x</mi></msub><msub><mi>b</mi><mi>x</mi></msub><mo>+</mo><msub><mi>a</mi><mi>y</mi></msub><msub><mi>b</mi><mi>y</mi></msub><mo>+</mo><mo>⋯</mo><mo>=</mo><mi>a</mi><mi>b</mi><mi>cos</mi><mo>⁡</mo><mi>φ</mi></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mi mathvariant="normal">∣</mi><mi mathvariant="bold-italic">a</mi><mo>×</mo><mi mathvariant="bold-italic">b</mi><mi mathvariant="normal">∣</mi><mo>=</mo><mi>a</mi><mi>b</mi><mi>sin</mi><mo>⁡</mo><mi>φ</mi><mo separator="true">,</mo><mi mathvariant="bold-italic">a</mi><mo>×</mo><mi mathvariant="bold-italic">b</mi><mo>=</mo><mo>−</mo><mi mathvariant="bold-italic">b</mi><mo>×</mo><mi mathvariant="bold-italic">a</mi><mo>⊥</mo><mi mathvariant="bold-italic">a</mi><mo separator="true">,</mo><mi mathvariant="bold-italic">b</mi></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mi mathvariant="bold-italic">a</mi><mo>×</mo><mi mathvariant="bold-italic">b</mi><mo>=</mo><mrow><mo fence="true">(</mo><msub><mi>a</mi><mi>y</mi></msub><msub><mi>b</mi><mi>z</mi></msub><mo>−</mo><msub><mi>a</mi><mi>z</mi></msub><msub><mi>b</mi><mi>y</mi></msub><mo fence="true">)</mo></mrow><msub><mi mathvariant="bold-italic">e</mi><mi>x</mi></msub><mo>+</mo><mrow><mo fence="true">(</mo><msub><mi>a</mi><mi>z</mi></msub><msub><mi>b</mi><mi>x</mi></msub><mo>−</mo><msub><mi>a</mi><mi>x</mi></msub><msub><mi>b</mi><mi>z</mi></msub><mo fence="true">)</mo></mrow><msub><mi mathvariant="bold-italic">e</mi><mi>y</mi></msub><mo>+</mo><mo>⋯</mo></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mi mathvariant="bold-italic">a</mi><mo>×</mo><mo stretchy="false">[</mo><mi mathvariant="bold-italic">b</mi><mo>×</mo><mi mathvariant="bold-italic">c</mi><mo stretchy="false">]</mo><mo>=</mo><mo stretchy="false">(</mo><mi mathvariant="bold-italic">a</mi><mo>⋅</mo><mi mathvariant="bold-italic">c</mi><mo stretchy="false">)</mo><mi mathvariant="bold-italic">b</mi><mo>−</mo><mo stretchy="false">(</mo><mi mathvariant="bold-italic">a</mi><mo>⋅</mo><mi mathvariant="bold-italic">b</mi><mo stretchy="false">)</mo><mi mathvariant="bold-italic">c</mi></mrow></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{gathered}
\boldsymbol{a} \cdot \boldsymbol{b}=\boldsymbol{b} \cdot \boldsymbol{a}=a_x b_x+a_y b_y+\cdots=a b \cos \varphi \\
|\boldsymbol{a} \times \boldsymbol{b}|=a b \sin \varphi, \boldsymbol{a} \times \boldsymbol{b}=-\boldsymbol{b} \times \boldsymbol{a} \perp \boldsymbol{a}, \boldsymbol{b} \\
\boldsymbol{a} \times \boldsymbol{b}=\left(a_y b_z-a_z b_y\right) \boldsymbol{e}_x+\left(a_z b_x-a_x b_z\right) \boldsymbol{e}_y+\cdots \\
\boldsymbol{a} \times[\boldsymbol{b} \times \boldsymbol{c}]=(\boldsymbol{a} \cdot \boldsymbol{c}) \boldsymbol{b}-(\boldsymbol{a} \cdot \boldsymbol{b}) \boldsymbol{c}
\end{gathered}
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:6em;vertical-align:-2.75em;"></span><span class="mord"><span class="mtable"><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:3.25em;"><span style="top:-5.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol">a</span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">⋅</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol">b</span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol">b</span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">⋅</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol">a</span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">x</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathnormal">b</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">x</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.03588em;">y</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathnormal">b</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.03588em;">y</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="minner">⋯</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord mathnormal">ab</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">cos</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">φ</span></span></span><span style="top:-3.91em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">∣</span><span class="mord"><span class="mord"><span class="mord boldsymbol">a</span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">×</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol">b</span></span></span><span class="mord">∣</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord mathnormal">ab</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">sin</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">φ</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol">a</span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">×</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol">b</span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord">−</span><span class="mord"><span class="mord"><span class="mord boldsymbol">b</span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">×</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol">a</span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">⊥</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol">a</span></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol">b</span></span></span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol">a</span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">×</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol">b</span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.03588em;">y</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathnormal">b</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.04398em;">z</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.04398em;">z</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathnormal">b</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.03588em;">y</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">)</span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol">e</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">x</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.04398em;">z</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathnormal">b</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">x</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">x</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathnormal">b</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.04398em;">z</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">)</span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol">e</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.03588em;">y</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="minner">⋯</span></span></span><span style="top:-0.91em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol">a</span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">×</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mopen">[</span><span class="mord"><span class="mord"><span class="mord boldsymbol">b</span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">×</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol">c</span></span></span><span class="mclose">]</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mopen">(</span><span class="mord"><span class="mord"><span class="mord boldsymbol">a</span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">⋅</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol">c</span></span></span><span class="mclose">)</span><span class="mord"><span class="mord"><span class="mord boldsymbol">b</span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mopen">(</span><span class="mord"><span class="mord"><span class="mord boldsymbol">a</span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">⋅</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol">b</span></span></span><span class="mclose">)</span><span class="mord"><span class="mord"><span class="mord boldsymbol">c</span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:2.75em;"><span></span></span></span></span></span></span></span></span></span></span></span></p>
<p>スカラー三重積（3 つのベクトルで張られる平行四面 体の体積）:</p>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mo stretchy="false">(</mo><mi mathvariant="bold-italic">a</mi><mo separator="true">,</mo><mi mathvariant="bold-italic">b</mi><mo separator="true">,</mo><mi mathvariant="bold-italic">c</mi><mo stretchy="false">)</mo><mo>≡</mo><mi mathvariant="bold-italic">a</mi><mo>⋅</mo><mo stretchy="false">[</mo><mi mathvariant="bold-italic">b</mi><mo>×</mo><mi mathvariant="bold-italic">c</mi><mo stretchy="false">]</mo><mo>=</mo><mo stretchy="false">[</mo><mi mathvariant="bold-italic">a</mi><mo>×</mo><mi mathvariant="bold-italic">b</mi><mo stretchy="false">]</mo><mo>⋅</mo><mi mathvariant="bold-italic">c</mi><mo>=</mo><mo stretchy="false">(</mo><mi mathvariant="bold-italic">b</mi><mo separator="true">,</mo><mi mathvariant="bold-italic">c</mi><mo separator="true">,</mo><mi mathvariant="bold-italic">a</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">(\boldsymbol{a}, \boldsymbol{b}, \boldsymbol{c}) \equiv \boldsymbol{a} \cdot[\boldsymbol{b} \times \boldsymbol{c}]=[\boldsymbol{a} \times \boldsymbol{b}] \cdot \boldsymbol{c}=(\boldsymbol{b}, \boldsymbol{c}, \boldsymbol{a})
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">(</span><span class="mord"><span class="mord"><span class="mord boldsymbol">a</span></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol">b</span></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol">c</span></span></span><span class="mclose">)</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≡</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.4445em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol">a</span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">⋅</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">[</span><span class="mord"><span class="mord"><span class="mord boldsymbol">b</span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">×</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol">c</span></span></span><span class="mclose">]</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">[</span><span class="mord"><span class="mord"><span class="mord boldsymbol">a</span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">×</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol">b</span></span></span><span class="mclose">]</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">⋅</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.4444em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol">c</span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">(</span><span class="mord"><span class="mord"><span class="mord boldsymbol">b</span></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol">c</span></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol">a</span></span></span><span class="mclose">)</span></span></span></span></span></p>
</li>
</ol>
<h3 id="_1-6-余弦定理と正弦定理" tabindex="-1">1.6: 余弦定理と正弦定理 <a class="header-anchor" href="#_1-6-余弦定理と正弦定理" aria-label="Permalink to &quot;1.6: 余弦定理と正弦定理&quot;">&ZeroWidthSpace;</a></h3>
<ol start="6">
<li>余弦定理と正弦定理：<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mtable rowspacing="0.25em" columnalign="right left" columnspacing="0em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><msup><mi>c</mi><mn>2</mn></msup><mo>=</mo><msup><mi>a</mi><mn>2</mn></msup><mo>+</mo><msup><mi>b</mi><mn>2</mn></msup><mo>−</mo><mn>2</mn><mi>a</mi><mi>b</mi><mi>cos</mi><mo>⁡</mo><mi>C</mi></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mi>a</mi><mi mathvariant="normal">/</mi><mi>sin</mi><mo>⁡</mo><mi>A</mi><mo>=</mo><mi>b</mi><mi mathvariant="normal">/</mi><mi>sin</mi><mo>⁡</mo><mi>B</mi><mo>=</mo><mn>2</mn><mi>R</mi></mrow></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{aligned}
&amp; c^2=a^2+b^2-2 a b \cos C \\
&amp; a / \sin A=b / \sin B=2 R
\end{aligned}
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:3.0241em;vertical-align:-1.2621em;"></span><span class="mord"><span class="mtable"><span class="col-align-r"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.7621em;"><span style="top:-3.7621em;"><span class="pstrut" style="height:2.8641em;"></span><span class="mord"></span></span><span style="top:-2.2621em;"><span class="pstrut" style="height:2.8641em;"></span><span class="mord"></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.2621em;"><span></span></span></span></span></span><span class="col-align-l"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.7621em;"><span style="top:-3.8979em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"></span><span class="mord"><span class="mord mathnormal">c</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal">b</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord">2</span><span class="mord mathnormal">ab</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">cos</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.07153em;">C</span></span></span><span style="top:-2.3979em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"></span><span class="mord mathnormal">a</span><span class="mord">/</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">sin</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">A</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord mathnormal">b</span><span class="mord">/</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">sin</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord">2</span><span class="mord mathnormal" style="margin-right:0.00773em;">R</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.2621em;"><span></span></span></span></span></span></span></span></span></span></span></span></p>
</li>
</ol>
<h3 id="_1-7-三角法" tabindex="-1">1.7: 三角法 <a class="header-anchor" href="#_1-7-三角法" aria-label="Permalink to &quot;1.7: 三角法&quot;">&ZeroWidthSpace;</a></h3>
<ol start="7">
<li>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mtable rowspacing="0.25em" columnalign="right left" columnspacing="0em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mi>sin</mi><mo>⁡</mo><mo stretchy="false">(</mo><mi>α</mi><mo>±</mo><mi>β</mi><mo stretchy="false">)</mo><mo>=</mo><mi>sin</mi><mo>⁡</mo><mi>α</mi><mi>cos</mi><mo>⁡</mo><mi>β</mi><mo>±</mo><mi>cos</mi><mo>⁡</mo><mi>α</mi><mi>sin</mi><mo>⁡</mo><mi>β</mi></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mi>cos</mi><mo>⁡</mo><mo stretchy="false">(</mo><mi>α</mi><mo>±</mo><mi>β</mi><mo stretchy="false">)</mo><mo>=</mo><mi>cos</mi><mo>⁡</mo><mi>α</mi><mi>cos</mi><mo>⁡</mo><mi>β</mi><mo>∓</mo><mi>sin</mi><mo>⁡</mo><mi>α</mi><mi>sin</mi><mo>⁡</mo><mi>β</mi></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mi>tan</mi><mo>⁡</mo><mo stretchy="false">(</mo><mi>α</mi><mo>±</mo><mi>β</mi><mo stretchy="false">)</mo><mo>=</mo><mo stretchy="false">(</mo><mi>tan</mi><mo>⁡</mo><mi>α</mi><mo>±</mo><mi>tan</mi><mo>⁡</mo><mi>β</mi><mo stretchy="false">)</mo><mi mathvariant="normal">/</mi><mo stretchy="false">(</mo><mn>1</mn><mo>∓</mo><mi>tan</mi><mo>⁡</mo><mi>α</mi><mi>tan</mi><mo>⁡</mo><mi>β</mi><mo stretchy="false">)</mo></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><msup><mrow><mi>cos</mi><mo>⁡</mo></mrow><mn>2</mn></msup><mi>α</mi><mo>=</mo><mfrac><mrow><mn>1</mn><mo>+</mo><mi>cos</mi><mo>⁡</mo><mn>2</mn><mi>α</mi></mrow><mn>2</mn></mfrac><mo separator="true">,</mo><msup><mrow><mi>sin</mi><mo>⁡</mo></mrow><mn>2</mn></msup><mi>α</mi><mo>=</mo><mfrac><mrow><mn>1</mn><mo>−</mo><mi>cos</mi><mo>⁡</mo><mn>2</mn><mi>α</mi></mrow><mn>2</mn></mfrac></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mi>cos</mi><mo>⁡</mo><mi>α</mi><mi>cos</mi><mo>⁡</mo><mi>β</mi><mo>=</mo><mfrac><mrow><mi>cos</mi><mo>⁡</mo><mo stretchy="false">(</mo><mi>α</mi><mo>+</mo><mi>β</mi><mo stretchy="false">)</mo><mo>+</mo><mi>cos</mi><mo>⁡</mo><mo stretchy="false">(</mo><mi>α</mi><mo>−</mo><mi>β</mi><mo stretchy="false">)</mo></mrow><mn>2</mn></mfrac><mo separator="true">,</mo><mo>…</mo></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mi>cos</mi><mo>⁡</mo><mi>α</mi><mo>+</mo><mi>cos</mi><mo>⁡</mo><mi>β</mi><mo>=</mo><mn>2</mn><mrow><mo fence="true">(</mo><mi>cos</mi><mo>⁡</mo><mfrac><mrow><mi>α</mi><mo>+</mo><mi>β</mi></mrow><mn>2</mn></mfrac><mo>+</mo><mi>cos</mi><mo>⁡</mo><mfrac><mrow><mi>α</mi><mo>−</mo><mi>β</mi></mrow><mn>2</mn></mfrac><mo fence="true">)</mo></mrow><mo separator="true">,</mo><mo>…</mo></mrow></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{aligned}
&amp; \sin (\alpha \pm \beta)=\sin \alpha \cos \beta \pm \cos \alpha \sin \beta \\
&amp; \cos (\alpha \pm \beta)=\cos \alpha \cos \beta \mp \sin \alpha \sin \beta \\
&amp; \tan (\alpha \pm \beta)=(\tan \alpha \pm \tan \beta) /(1 \mp \tan \alpha \tan \beta) \\
&amp; \cos ^2 \alpha=\frac{1+\cos 2 \alpha}{2}, \sin ^2 \alpha=\frac{1-\cos 2 \alpha}{2} \\
&amp; \cos \alpha \cos \beta=\frac{\cos (\alpha+\beta)+\cos (\alpha-\beta)}{2}, \ldots \\
&amp; \cos \alpha+\cos \beta=2\left(\cos \frac{\alpha+\beta}{2}+\cos \frac{\alpha-\beta}{2}\right), \ldots
\end{aligned}
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:11.9205em;vertical-align:-5.7102em;"></span><span class="mord"><span class="mtable"><span class="col-align-r"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:6.2102em;"><span style="top:-8.8202em;"><span class="pstrut" style="height:3.45em;"></span><span class="mord"></span></span><span style="top:-7.3202em;"><span class="pstrut" style="height:3.45em;"></span><span class="mord"></span></span><span style="top:-5.8202em;"><span class="pstrut" style="height:3.45em;"></span><span class="mord"></span></span><span style="top:-3.8388em;"><span class="pstrut" style="height:3.45em;"></span><span class="mord"></span></span><span style="top:-1.4258em;"><span class="pstrut" style="height:3.45em;"></span><span class="mord"></span></span><span style="top:1.0102em;"><span class="pstrut" style="height:3.45em;"></span><span class="mord"></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:5.7102em;"><span></span></span></span></span></span><span class="col-align-l"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:6.2102em;"><span style="top:-8.8202em;"><span class="pstrut" style="height:3.45em;"></span><span class="mord"><span class="mord"></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">sin</span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.0037em;">α</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">±</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal" style="margin-right:0.05278em;">β</span><span class="mclose">)</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mop">sin</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.0037em;">α</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">cos</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.05278em;">β</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">±</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mop">cos</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.0037em;">α</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">sin</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.05278em;">β</span></span></span><span style="top:-7.3202em;"><span class="pstrut" style="height:3.45em;"></span><span class="mord"><span class="mord"></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">cos</span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.0037em;">α</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">±</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal" style="margin-right:0.05278em;">β</span><span class="mclose">)</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mop">cos</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.0037em;">α</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">cos</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.05278em;">β</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">∓</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mop">sin</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.0037em;">α</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">sin</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.05278em;">β</span></span></span><span style="top:-5.8202em;"><span class="pstrut" style="height:3.45em;"></span><span class="mord"><span class="mord"></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">tan</span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.0037em;">α</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">±</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal" style="margin-right:0.05278em;">β</span><span class="mclose">)</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mopen">(</span><span class="mop">tan</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.0037em;">α</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">±</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mop">tan</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.05278em;">β</span><span class="mclose">)</span><span class="mord">/</span><span class="mopen">(</span><span class="mord">1</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">∓</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mop">tan</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.0037em;">α</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">tan</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.05278em;">β</span><span class="mclose">)</span></span></span><span style="top:-3.8388em;"><span class="pstrut" style="height:3.45em;"></span><span class="mord"><span class="mord"></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop"><span class="mop">cos</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.0037em;">α</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.3214em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">2</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">1</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mop">cos</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord">2</span><span class="mord mathnormal" style="margin-right:0.0037em;">α</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop"><span class="mop">sin</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8719em;"><span style="top:-3.1208em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.0037em;">α</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.3214em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">2</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">1</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mop">cos</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord">2</span><span class="mord mathnormal" style="margin-right:0.0037em;">α</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span><span style="top:-1.4258em;"><span class="pstrut" style="height:3.45em;"></span><span class="mord"><span class="mord"></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">cos</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.0037em;">α</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">cos</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.05278em;">β</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.427em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">2</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mop">cos</span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.0037em;">α</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal" style="margin-right:0.05278em;">β</span><span class="mclose">)</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mop">cos</span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.0037em;">α</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal" style="margin-right:0.05278em;">β</span><span class="mclose">)</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner">…</span></span></span><span style="top:1.0102em;"><span class="pstrut" style="height:3.45em;"></span><span class="mord"><span class="mord"></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">cos</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.0037em;">α</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mop">cos</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.05278em;">β</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord">2</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size3">(</span></span><span class="mop">cos</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.3714em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">2</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.0037em;">α</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal" style="margin-right:0.05278em;">β</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mop">cos</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.3714em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">2</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.0037em;">α</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal" style="margin-right:0.05278em;">β</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size3">)</span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner">…</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:5.7102em;"><span></span></span></span></span></span></span></span></span></span></span></span></p>
</li>
</ol>
<h3 id="_1-8-円周角" tabindex="-1">1.8: 円周角 <a class="header-anchor" href="#_1-8-円周角" aria-label="Permalink to &quot;1.8: 円周角&quot;">&ZeroWidthSpace;</a></h3>
<ol start="8">
<li>円周角は中心角の半分. よって，直角三角形の斜辺は その外接円の直径. もし四角形の対角の和が 180 度な らば，それは円に内接する.</li>
</ol>
<h3 id="_1-9-三角形の面樍" tabindex="-1">1.9: 三角形の面樍 <a class="header-anchor" href="#_1-9-三角形の面樍" aria-label="Permalink to &quot;1.9: 三角形の面樍&quot;">&ZeroWidthSpace;</a></h3>
<ol start="9">
<li>三角形の面樍 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>=</mo><mfrac><mn>1</mn><mn>2</mn></mfrac><mi>a</mi><msub><mi>h</mi><mi>a</mi></msub><mo>=</mo><mi>p</mi><mi>r</mi><mo>=</mo><msqrt><mrow><mi>p</mi><mo stretchy="false">(</mo><mi>p</mi><mo>−</mo><mi>a</mi><mo stretchy="false">)</mo><mo stretchy="false">(</mo><mi>p</mi><mo>−</mo><mi>b</mi><mo stretchy="false">)</mo><mo stretchy="false">(</mo><mi>p</mi><mo>−</mo><mi>c</mi><mo stretchy="false">)</mo></mrow></msqrt><mo>=</mo><mi>a</mi><mi>b</mi><mi>c</mi><mi mathvariant="normal">/</mi><mn>4</mn><mi>R</mi></mrow><annotation encoding="application/x-tex">=\frac{1}{2} a h_a=p r=\sqrt{p(p-a)(p-b)(p-c)}=a b c / 4 R</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.1901em;vertical-align:-0.345em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8451em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">1</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mord mathnormal">a</span><span class="mord"><span class="mord mathnormal">h</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">a</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">p</span><span class="mord mathnormal" style="margin-right:0.02778em;">r</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.24em;vertical-align:-0.305em;"></span><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.935em;"><span class="svg-align" style="top:-3.2em;"><span class="pstrut" style="height:3.2em;"></span><span class="mord" style="padding-left:1em;"><span class="mord mathnormal">p</span><span class="mopen">(</span><span class="mord mathnormal">p</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal">a</span><span class="mclose">)</span><span class="mopen">(</span><span class="mord mathnormal">p</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal">b</span><span class="mclose">)</span><span class="mopen">(</span><span class="mord mathnormal">p</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal">c</span><span class="mclose">)</span></span></span><span style="top:-2.895em;"><span class="pstrut" style="height:3.2em;"></span><span class="hide-tail" style="min-width:1.02em;height:1.28em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='1.28em' viewBox='0 0 400000 1296' preserveAspectRatio='xMinYMin slice'><path d='M263,681c0.7,0,18,39.7,52,119
c34,79.3,68.167,158.7,102.5,238c34.3,79.3,51.8,119.3,52.5,120
c340,-704.7,510.7,-1060.3,512,-1067
l0 -0
c4.7,-7.3,11,-11,19,-11
H40000v40H1012.3
s-271.3,567,-271.3,567c-38.7,80.7,-84,175,-136,283c-52,108,-89.167,185.3,-111.5,232
c-22.3,46.7,-33.8,70.3,-34.5,71c-4.7,4.7,-12.3,7,-23,7s-12,-1,-12,-1
s-109,-253,-109,-253c-72.7,-168,-109.3,-252,-110,-252c-10.7,8,-22,16.7,-34,26
c-22,17.3,-33.3,26,-34,26s-26,-26,-26,-26s76,-59,76,-59s76,-60,76,-60z
M1001 80h400000v40h-400000z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.305em;"><span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal">ab</span><span class="mord mathnormal">c</span><span class="mord">/4</span><span class="mord mathnormal" style="margin-right:0.00773em;">R</span></span></span></span></li>
</ol>
<h3 id="_1-10-重心" tabindex="-1">1.10: 重心 <a class="header-anchor" href="#_1-10-重心" aria-label="Permalink to &quot;1.10: 重心&quot;">&ZeroWidthSpace;</a></h3>
<ol start="10">
<li>三角形の重心は，中線の交点で，中線を 2:1 に内分する.\</li>
</ol>
<h3 id="_1-11-ベクトルアプローチ" tabindex="-1">1.11: ベクトルアプローチ <Badge type="tip" text="supplemental" /> <a class="header-anchor" href="#_1-11-ベクトルアプローチ" aria-label="Permalink to &quot;1.11: ベクトルアプローチ &lt;Badge type=&quot;tip&quot; text=&quot;supplemental&quot; /&gt;&quot;">&ZeroWidthSpace;</a></h3>
<ol>
<li>幾何の問題へのベクトルアプローチ.</li>
</ol>
<h3 id="_1-12-微分" tabindex="-1">1.12: 微分 <a class="header-anchor" href="#_1-12-微分" aria-label="Permalink to &quot;1.12: 微分&quot;">&ZeroWidthSpace;</a></h3>
<ol start="12">
<li>微分:<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mtable rowspacing="0.25em" columnalign="center" columnspacing="0em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mo stretchy="false">(</mo><mi>f</mi><mi>g</mi><msup><mo stretchy="false">)</mo><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup><mo>=</mo><msup><mi>f</mi><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup><mi>g</mi><mo>+</mo><mi>f</mi><msup><mi>g</mi><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup><mo separator="true">,</mo><mi>f</mi><mo stretchy="false">[</mo><mi>g</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo><msup><mo stretchy="false">]</mo><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup><mo>=</mo><msup><mi>f</mi><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup><mo stretchy="false">[</mo><mi>g</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo><mo stretchy="false">]</mo><msup><mi>g</mi><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mo stretchy="false">(</mo><mi>sin</mi><mo>⁡</mo><mi>x</mi><msup><mo stretchy="false">)</mo><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup><mo>=</mo><mi>cos</mi><mo>⁡</mo><mi>x</mi><mo separator="true">,</mo><mo stretchy="false">(</mo><mi>cos</mi><mo>⁡</mo><mi>x</mi><msup><mo stretchy="false">)</mo><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup><mo>=</mo><mo>−</mo><mi>sin</mi><mo>⁡</mo><mi>x</mi></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><msup><mrow><mo fence="true">(</mo><msup><mi>e</mi><mi>x</mi></msup><mo fence="true">)</mo></mrow><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup><mo>=</mo><msup><mi>e</mi><mi>x</mi></msup><mo separator="true">,</mo><mo stretchy="false">(</mo><mi>ln</mi><mo>⁡</mo><mi>x</mi><msup><mo stretchy="false">)</mo><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup><mo>=</mo><mn>1</mn><mi mathvariant="normal">/</mi><mi>x</mi><mo separator="true">,</mo><msup><mrow><mo fence="true">(</mo><msup><mi>x</mi><mi>n</mi></msup><mo fence="true">)</mo></mrow><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup><mo>=</mo><mi>n</mi><msup><mi>x</mi><mrow><mi>n</mi><mo>−</mo><mn>1</mn></mrow></msup></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mo stretchy="false">(</mo><mi>arctan</mi><mo>⁡</mo><mi>x</mi><msup><mo stretchy="false">)</mo><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup><mo>=</mo><mn>1</mn><mi mathvariant="normal">/</mi><mrow><mo fence="true">(</mo><mn>1</mn><mo>+</mo><msup><mi>x</mi><mn>2</mn></msup><mo fence="true">)</mo></mrow></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mo stretchy="false">(</mo><mi>arcsin</mi><mo>⁡</mo><mi>x</mi><msup><mo stretchy="false">)</mo><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup><mo>=</mo><mo>−</mo><mo stretchy="false">(</mo><mi>arccos</mi><mo>⁡</mo><mi>x</mi><msup><mo stretchy="false">)</mo><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup><mo>=</mo><mn>1</mn><mi mathvariant="normal">/</mi><msqrt><mrow><mn>1</mn><mo>−</mo><msup><mi>x</mi><mn>2</mn></msup></mrow></msqrt></mrow></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{gathered}
(f g)^{\prime}=f^{\prime} g+f g^{\prime}, f[g(x)]^{\prime}=f^{\prime}[g(x)] g^{\prime}(x) \\
(\sin x)^{\prime}=\cos x,(\cos x)^{\prime}=-\sin x \\
\left(e^x\right)^{\prime}=e^x,(\ln x)^{\prime}=1 / x,\left(x^n\right)^{\prime}=n x^{n-1} \\
(\arctan x)^{\prime}=1 /\left(1+x^2\right) \\
(\arcsin x)^{\prime}=-(\arccos x)^{\prime}=1 / \sqrt{1-x^2}
\end{gathered}
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:7.7982em;vertical-align:-3.6491em;"></span><span class="mord"><span class="mtable"><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:4.1491em;"><span style="top:-6.3713em;"><span class="pstrut" style="height:3.0623em;"></span><span class="mord"><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.10764em;">f</span><span class="mord mathnormal" style="margin-right:0.03588em;">g</span><span class="mclose"><span class="mclose">)</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8019em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.10764em;">f</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8019em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span><span class="mord mathnormal" style="margin-right:0.03588em;">g</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal" style="margin-right:0.10764em;">f</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">g</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8019em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.10764em;">f</span><span class="mopen">[</span><span class="mord mathnormal" style="margin-right:0.03588em;">g</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">)</span><span class="mclose"><span class="mclose">]</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8019em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.10764em;">f</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8019em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span><span class="mopen">[</span><span class="mord mathnormal" style="margin-right:0.03588em;">g</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">)]</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">g</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8019em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">)</span></span></span><span style="top:-4.8713em;"><span class="pstrut" style="height:3.0623em;"></span><span class="mord"><span class="mopen">(</span><span class="mop">sin</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">x</span><span class="mclose"><span class="mclose">)</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8019em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mop">cos</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">x</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mopen">(</span><span class="mop">cos</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">x</span><span class="mclose"><span class="mclose">)</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8019em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord">−</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">sin</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">x</span></span></span><span style="top:-3.3196em;"><span class="pstrut" style="height:3.0623em;"></span><span class="mord"><span class="minner"><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord"><span class="mord mathnormal">e</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7144em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">x</span></span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">)</span></span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8918em;"><span style="top:-3.2029em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mord mathnormal">e</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7144em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">x</span></span></span></span></span></span></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mopen">(</span><span class="mop">ln</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">x</span><span class="mclose"><span class="mclose">)</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8019em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord">1/</span><span class="mord mathnormal">x</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7144em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">n</span></span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">)</span></span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8918em;"><span style="top:-3.2029em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord mathnormal">n</span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">n</span><span class="mbin mtight">−</span><span class="mord mtight">1</span></span></span></span></span></span></span></span></span></span></span><span style="top:-1.7954em;"><span class="pstrut" style="height:3.0623em;"></span><span class="mord"><span class="mopen">(</span><span class="mop">arctan</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">x</span><span class="mclose"><span class="mclose">)</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8019em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord">1/</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size1">(</span></span><span class="mord">1</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size1">)</span></span></span></span></span><span style="top:-0.0732em;"><span class="pstrut" style="height:3.0623em;"></span><span class="mord"><span class="mopen">(</span><span class="mop">arcsin</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">x</span><span class="mclose"><span class="mclose">)</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8019em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord">−</span><span class="mopen">(</span><span class="mop">arccos</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">x</span><span class="mclose"><span class="mclose">)</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8019em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord">1/</span><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.0623em;"><span class="svg-align" style="top:-3.2em;"><span class="pstrut" style="height:3.2em;"></span><span class="mord" style="padding-left:1em;"><span class="mord">1</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7401em;"><span style="top:-2.989em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span><span style="top:-3.0223em;"><span class="pstrut" style="height:3.2em;"></span><span class="hide-tail" style="min-width:1.02em;height:1.28em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='1.28em' viewBox='0 0 400000 1296' preserveAspectRatio='xMinYMin slice'><path d='M263,681c0.7,0,18,39.7,52,119
c34,79.3,68.167,158.7,102.5,238c34.3,79.3,51.8,119.3,52.5,120
c340,-704.7,510.7,-1060.3,512,-1067
l0 -0
c4.7,-7.3,11,-11,19,-11
H40000v40H1012.3
s-271.3,567,-271.3,567c-38.7,80.7,-84,175,-136,283c-52,108,-89.167,185.3,-111.5,232
c-22.3,46.7,-33.8,70.3,-34.5,71c-4.7,4.7,-12.3,7,-23,7s-12,-1,-12,-1
s-109,-253,-109,-253c-72.7,-168,-109.3,-252,-110,-252c-10.7,8,-22,16.7,-34,26
c-22,17.3,-33.3,26,-34,26s-26,-26,-26,-26s76,-59,76,-59s76,-60,76,-60z
M1001 80h400000v40h-400000z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.1777em;"><span></span></span></span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:3.6491em;"><span></span></span></span></span></span></span></span></span></span></span></span></p>
</li>
</ol>
<h3 id="_1-13-積分" tabindex="-1">1.13: 積分 <a class="header-anchor" href="#_1-13-積分" aria-label="Permalink to &quot;1.13: 積分&quot;">&ZeroWidthSpace;</a></h3>
<ol start="13">
<li>積分：微分の公式の左辺と右辺を入れ替えたものと同 じ（逆演算）.例えば,<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mo>∫</mo><msup><mi>x</mi><mi>n</mi></msup><mrow><mtext> </mtext><mi mathvariant="normal">d</mi></mrow><mi>x</mi><mo>=</mo><msup><mi>x</mi><mrow><mi>n</mi><mo>+</mo><mn>1</mn></mrow></msup><mi mathvariant="normal">/</mi><mo stretchy="false">(</mo><mi>n</mi><mo>+</mo><mn>1</mn><mo stretchy="false">)</mo><mi mathvariant="normal">.</mi></mrow><annotation encoding="application/x-tex">\int x^n \mathrm{~d} x=x^{n+1} /(n+1) .
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.2222em;vertical-align:-0.8622em;"></span><span class="mop op-symbol large-op" style="margin-right:0.44445em;position:relative;top:-0.0011em;">∫</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7144em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">n</span></span></span></span></span></span></span></span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">d</span></span><span class="mord mathnormal">x</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.1141em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">n</span><span class="mbin mtight">+</span><span class="mord mtight">1</span></span></span></span></span></span></span></span></span><span class="mord">/</span><span class="mopen">(</span><span class="mord mathnormal">n</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">1</span><span class="mclose">)</span><span class="mord">.</span></span></span></span></span></p>
置換積分の特別な場合 :<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mo>∫</mo><mi>f</mi><mo stretchy="false">(</mo><mi>a</mi><mi>x</mi><mo>+</mo><mi>b</mi><mo stretchy="false">)</mo><mi mathvariant="normal">d</mi><mi>x</mi><mo>=</mo><mi>F</mi><mo stretchy="false">(</mo><mi>a</mi><mi>x</mi><mo>+</mo><mi>b</mi><mo stretchy="false">)</mo><mi mathvariant="normal">/</mi><mi>a</mi><mi mathvariant="normal">.</mi></mrow><annotation encoding="application/x-tex">\int f(a x+b) \mathrm{d} x=F(a x+b) / a .
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.2222em;vertical-align:-0.8622em;"></span><span class="mop op-symbol large-op" style="margin-right:0.44445em;position:relative;top:-0.0011em;">∫</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.10764em;">f</span><span class="mopen">(</span><span class="mord mathnormal">a</span><span class="mord mathnormal">x</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal">b</span><span class="mclose">)</span><span class="mord mathrm">d</span><span class="mord mathnormal">x</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.13889em;">F</span><span class="mopen">(</span><span class="mord mathnormal">a</span><span class="mord mathnormal">x</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal">b</span><span class="mclose">)</span><span class="mord">/</span><span class="mord mathnormal">a</span><span class="mord">.</span></span></span></span></span></p>
</li>
</ol>
<h3 id="_1-14-円錐曲線" tabindex="-1">1.14: 円錐曲線 <a class="header-anchor" href="#_1-14-円錐曲線" aria-label="Permalink to &quot;1.14: 円錐曲線&quot;">&ZeroWidthSpace;</a></h3>
<ol start="14">
<li>円錐曲線: <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>a</mi><mn>11</mn></msub><msup><mi>x</mi><mn>2</mn></msup><mo>+</mo><mn>2</mn><msub><mi>a</mi><mn>12</mn></msub><mi>x</mi><mi>y</mi><mo>+</mo><msub><mi>a</mi><mn>22</mn></msub><msup><mi>y</mi><mn>2</mn></msup><mo>+</mo><msub><mi>a</mi><mn>1</mn></msub><mi>x</mi><mo>+</mo><msub><mi>a</mi><mn>2</mn></msub><mi>y</mi><mo>+</mo><msub><mi>a</mi><mn>0</mn></msub><mo>=</mo></mrow><annotation encoding="application/x-tex">a_{11} x^2+2 a_{12} x y+a_{22} y^2+a_1 x+a_2 y+a_0=</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9641em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">11</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.8389em;vertical-align:-0.1944em;"></span><span class="mord">2</span><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">12</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord mathnormal">x</span><span class="mord mathnormal" style="margin-right:0.03588em;">y</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1.0085em;vertical-align:-0.1944em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">22</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">y</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.7333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord mathnormal">x</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.7778em;vertical-align:-0.1944em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord mathnormal" style="margin-right:0.03588em;">y</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">0</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span></span></span></span> 0 で, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>a</mi><mn>11</mn></msub><mo>=</mo><msub><mi>a</mi><mn>22</mn></msub></mrow><annotation encoding="application/x-tex">a_{11}=a_{22}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">11</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">22</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> ならば円, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>a</mi><mn>11</mn></msub><mrow><mo fence="true">(</mo><msub><mi>a</mi><mn>11</mn></msub><msub><mi>a</mi><mn>22</mn></msub><mo>−</mo><msubsup><mi>a</mi><mn>12</mn><mn>2</mn></msubsup><mo fence="true">)</mo></mrow><mo>&gt;</mo><mn>0</mn></mrow><annotation encoding="application/x-tex">a_{11}\left(a_{11} a_{22}-a_{12}^2\right)&gt;0</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2em;vertical-align:-0.35em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">11</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size1">(</span></span><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">11</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">22</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-2.4519em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">12</span></span></span></span><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2481em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size1">)</span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">&gt;</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">0</span></span></span></span> ならば楕円, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋯</mo><mo>&lt;</mo><mn>0</mn></mrow><annotation encoding="application/x-tex">\cdots&lt;0</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="minner">⋯</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">&lt;</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">0</span></span></span></span> ならば双曲線, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>a</mi><mn>11</mn></msub><msub><mi>a</mi><mn>22</mn></msub><mo>−</mo><msubsup><mi>a</mi><mn>12</mn><mn>2</mn></msubsup><mo>=</mo><mn>0</mn></mrow><annotation encoding="application/x-tex">a_{11} a_{22}-a_{12}^2=0</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">11</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">22</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1.0622em;vertical-align:-0.2481em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-2.4519em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">12</span></span></span></span><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2481em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">0</span></span></span></span> ならば放物線. 楕円 : <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>l</mi><mn>1</mn></msub><mo>+</mo><msub><mi>l</mi><mn>2</mn></msub><mo>=</mo><mn>2</mn><mi>a</mi><mo separator="true">,</mo><msub><mi>α</mi><mn>1</mn></msub><mo>=</mo><msub><mi>α</mi><mn>2</mn></msub></mrow><annotation encoding="application/x-tex">l_1+l_2=2 a, \alpha_1=\alpha_2</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8444em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.01968em;">l</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0197em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.8444em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.01968em;">l</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0197em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8389em;vertical-align:-0.1944em;"></span><span class="mord">2</span><span class="mord mathnormal">a</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.0037em;">α</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0037em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.0037em;">α</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0037em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> [訳 者注 : 焦点と曲線上の点を結ぶ直線と接線とのなす角 ], <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>A</mi><mo>=</mo><mi>π</mi><mi>a</mi><mi>b</mi></mrow><annotation encoding="application/x-tex">A=\pi a b</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal">A</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">πab</span></span></span></span>. 双曲線 : <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>l</mi><mn>1</mn></msub><mo>−</mo><msub><mi>l</mi><mn>2</mn></msub><mo>=</mo><mn>2</mn><mi>a</mi><mo separator="true">,</mo><msub><mi>α</mi><mn>1</mn></msub><mo>+</mo><msub><mi>α</mi><mn>2</mn></msub><mo>=</mo><mn>0</mn></mrow><annotation encoding="application/x-tex">l_1-l_2=2 a, \alpha_1+\alpha_2=0</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8444em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.01968em;">l</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0197em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.8444em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.01968em;">l</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0197em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8389em;vertical-align:-0.1944em;"></span><span class="mord">2</span><span class="mord mathnormal">a</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.0037em;">α</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0037em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.0037em;">α</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0037em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">0</span></span></span></span>. 放物線 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>:</mo><mi>l</mi><mo>+</mo><mi>h</mi><mo>=</mo></mrow><annotation encoding="application/x-tex">: l+h=</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mrel">:</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.7778em;vertical-align:-0.0833em;"></span><span class="mord mathnormal" style="margin-right:0.01968em;">l</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">h</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span></span></span></span> const., <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>α</mi><mn>1</mn></msub><mo>=</mo><msub><mi>α</mi><mn>2</mn></msub></mrow><annotation encoding="application/x-tex">\alpha_1=\alpha_2</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.0037em;">α</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0037em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.0037em;">α</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0037em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span>.</li>
</ol>
<h3 id="_1-15-数值計算-台形規則" tabindex="-1">1.15: 数值計算 &amp; 台形規則 <a class="header-anchor" href="#_1-15-数值計算-台形規則" aria-label="Permalink to &quot;1.15: 数值計算 &amp; 台形規則&quot;">&ZeroWidthSpace;</a></h3>
<ol start="15">
<li>数值計算. <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>f</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo><mo>=</mo><mn>0</mn></mrow><annotation encoding="application/x-tex">f(x)=0</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.10764em;">f</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">)</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">0</span></span></span></span> の解を求めるニュートン法 :<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><msub><mi>x</mi><mrow><mi>n</mi><mo>+</mo><mn>1</mn></mrow></msub><mo>=</mo><msub><mi>x</mi><mi>n</mi></msub><mo>−</mo><mi>f</mi><mrow><mo fence="true">(</mo><msub><mi>x</mi><mi>n</mi></msub><mo fence="true">)</mo></mrow><mi mathvariant="normal">/</mi><msup><mi>f</mi><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup><mrow><mo fence="true">(</mo><msub><mi>x</mi><mi>n</mi></msub><mo fence="true">)</mo></mrow></mrow><annotation encoding="application/x-tex">x_{n+1}=x_n-f\left(x_n\right) / f^{\prime}\left(x_n\right)
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6389em;vertical-align:-0.2083em;"></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">n</span><span class="mbin mtight">+</span><span class="mord mtight">1</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2083em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.7333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">n</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1.0519em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.10764em;">f</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">n</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">)</span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord">/</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.10764em;">f</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8019em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">n</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">)</span></span></span></span></span></span></p>
近似積分の台形規則：<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mtable rowspacing="0.16em" columnalign="right" columnspacing="1em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mrow><msubsup><mo>∫</mo><mi>a</mi><mi>b</mi></msubsup><mi>f</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo><mi mathvariant="normal">d</mi><mi>x</mi><mo>≈</mo><mfrac><mrow><mi>b</mi><mo>−</mo><mi>a</mi></mrow><mrow><mn>2</mn><mi>n</mi></mrow></mfrac><mrow><mo fence="true">[</mo><mi>f</mi><mrow><mo fence="true">(</mo><msub><mi>x</mi><mn>0</mn></msub><mo fence="true">)</mo></mrow><mo>+</mo><mn>2</mn><mrow><mo fence="true">{</mo><mi>f</mi><mrow><mo fence="true">(</mo><msub><mi>x</mi><mn>1</mn></msub><mo fence="true">)</mo></mrow><mo>+</mo><mo>⋯</mo><mtext> </mtext></mrow></mrow><mrow><mrow><mo>+</mo><mi>f</mi><mrow><mo fence="true">(</mo><msub><mi>x</mi><mrow><mi>n</mi><mo>−</mo><mn>1</mn></mrow></msub><mo fence="true">)</mo></mrow><mo fence="true">}</mo></mrow><mo>+</mo><mi>f</mi><mrow><mo fence="true">(</mo><msub><mi>x</mi><mi>n</mi></msub><mo fence="true">)</mo></mrow><mo fence="true">]</mo></mrow></mrow></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{array}{r}
\int_a^b f(x) \mathrm{d} x \approx \frac{b-a}{2 n}\left[f\left(x_0\right)+2\left\{f\left(x_1\right)+\cdots\right.\right.
\left.\left.+f\left(x_{n-1}\right)\right\}+f\left(x_n\right)\right]
\end{array}
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.404em;vertical-align:-0.452em;"></span><span class="mord"><span class="mtable"><span class="arraycolsep" style="width:0.5em;"></span><span class="col-align-r"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.952em;"><span style="top:-2.952em;"><span class="pstrut" style="height:3.044em;"></span><span class="mord"><span class="mop"><span class="mop op-symbol small-op" style="margin-right:0.19445em;position:relative;top:-0.0006em;">∫</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.044em;"><span style="top:-2.3442em;margin-left:-0.1945em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">a</span></span></span><span style="top:-3.2579em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">b</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.3558em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.10764em;">f</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">)</span><span class="mord mathrm">d</span><span class="mord mathnormal">x</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≈</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8801em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span><span class="mord mathnormal mtight">n</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">b</span><span class="mbin mtight">−</span><span class="mord mathnormal mtight">a</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">[</span><span class="mord mathnormal" style="margin-right:0.10764em;">f</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">0</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">)</span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord">2</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">{</span><span class="mord mathnormal" style="margin-right:0.10764em;">f</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">)</span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="minner">⋯</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mclose nulldelimiter"></span></span><span class="mclose nulldelimiter"></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen nulldelimiter"></span><span class="minner"><span class="mopen nulldelimiter"></span><span class="mord">+</span><span class="mord mathnormal" style="margin-right:0.10764em;">f</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">n</span><span class="mbin mtight">−</span><span class="mord mtight">1</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2083em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">)</span></span><span class="mclose delimcenter" style="top:0em;">}</span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal" style="margin-right:0.10764em;">f</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">n</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">)</span></span><span class="mclose delimcenter" style="top:0em;">]</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.452em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:0.5em;"></span></span></span></span></span></span></span></p>
</li>
</ol>
<h3 id="_1-16-ベクトルの微分-積分" tabindex="-1">1.16: ベクトルの微分 &amp; 積分 <a class="header-anchor" href="#_1-16-ベクトルの微分-積分" aria-label="Permalink to &quot;1.16: ベクトルの微分 &amp; 積分&quot;">&ZeroWidthSpace;</a></h3>
<ol start="16">
<li>ベクトルの微分と積分：成分ごとに微分/積分する．あるいは無限に近い<span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>2</mn></mrow><annotation encoding="application/x-tex">2</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">2</span></span></span></span>つのベクトルの差を求めることで 微分す.</li>
</ol>
]]></description>
            <content:encoded><![CDATA[<h1 id="formulas-for-ipho-日本語版-section-1" tabindex="-1">Formulas for IPhO 日本語版: Section 1 <a class="header-anchor" href="#formulas-for-ipho-日本語版-section-1" aria-label="Permalink to &quot;Formulas for IPhO 日本語版: Section 1&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="_1-数学" tabindex="-1">1: 数学 <a class="header-anchor" href="#_1-数学" aria-label="Permalink to &quot;1: 数学&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="_1-1-taylor-展開" tabindex="-1">1.1: Taylor 展開 <a class="header-anchor" href="#_1-1-taylor-展開" aria-label="Permalink to &quot;1.1: Taylor 展開&quot;">&ZeroWidthSpace;</a></h3>
<ol>
<li>
<p>Taylor 展開（アバウトに切り捨てる:</p>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mi>F</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo><mo>=</mo><mi>F</mi><mrow><mo fence="true">(</mo><msub><mi>x</mi><mn>0</mn></msub><mo fence="true">)</mo></mrow><mo>+</mo><mo>∑</mo><msup><mi>F</mi><mrow><mo stretchy="false">(</mo><mi>n</mi><mo stretchy="false">)</mo></mrow></msup><mrow><mo fence="true">(</mo><msub><mi>x</mi><mn>0</mn></msub><mo fence="true">)</mo></mrow><msup><mrow><mo fence="true">(</mo><mi>x</mi><mo>−</mo><msub><mi>x</mi><mn>0</mn></msub><mo fence="true">)</mo></mrow><mi>n</mi></msup><mi mathvariant="normal">/</mi><mi>n</mi></mrow><annotation encoding="application/x-tex">F(x)=F\left(x_{0}\right)+\sum F^{(n)}\left(x_{0}\right)\left(x-x_{0}\right)^{n} / n
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.13889em;">F</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">)</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.13889em;">F</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">0</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">)</span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1.6em;vertical-align:-0.55em;"></span><span class="mop op-symbol large-op" style="position:relative;top:0em;">∑</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.13889em;">F</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.938em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mopen mtight">(</span><span class="mord mathnormal mtight">n</span><span class="mclose mtight">)</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">0</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">)</span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord mathnormal">x</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">0</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">)</span></span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8043em;"><span style="top:-3.2029em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">n</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord">/</span><span class="mord mathnormal">n</span></span></span></span></span></p>
<p>線形近似（特別な場合）:</p>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mi>F</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo><mo>≈</mo><mi>F</mi><mrow><mo fence="true">(</mo><msub><mi>x</mi><mn>0</mn></msub><mo fence="true">)</mo></mrow><mo>+</mo><msup><mi>F</mi><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup><mrow><mo fence="true">(</mo><msub><mi>x</mi><mn>0</mn></msub><mo fence="true">)</mo></mrow><mrow><mo fence="true">(</mo><mi>x</mi><mo>−</mo><msub><mi>x</mi><mn>0</mn></msub><mo fence="true">)</mo></mrow></mrow><annotation encoding="application/x-tex">F(x) \approx F\left(x_{0}\right)+F^{\prime}\left(x_{0}\right)\left(x-x_{0}\right)
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.13889em;">F</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">)</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≈</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.13889em;">F</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">0</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">)</span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1.0519em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.13889em;">F</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8019em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">0</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">)</span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord mathnormal">x</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">0</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">)</span></span></span></span></span></span></p>
<p><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∣</mi><mi>x</mi><mi mathvariant="normal">∣</mi><mo>≪</mo><mn>1</mn></mrow><annotation encoding="application/x-tex">|x| \ll 1</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">∣</span><span class="mord mathnormal">x</span><span class="mord">∣</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≪</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">1</span></span></span></span> のときの例 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>:</mo></mrow><annotation encoding="application/x-tex">:</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mrel">:</span></span></span></span></p>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mi>sin</mi><mo>⁡</mo><mi>x</mi><mo>≈</mo><mi>x</mi><mo separator="true">,</mo><mi>cos</mi><mo>⁡</mo><mi>x</mi><mo>≈</mo><mn>1</mn><mo>−</mo><msup><mi>x</mi><mn>2</mn></msup><mi mathvariant="normal">/</mi><mn>2</mn><mo separator="true">,</mo><msup><mi>e</mi><mi>x</mi></msup><mo>≈</mo><mn>1</mn><mo>+</mo><mi>x</mi></mrow><annotation encoding="application/x-tex">\sin x \approx x, \cos x \approx 1-x^{2} / 2, e^{x} \approx 1+x
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6679em;"></span><span class="mop">sin</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">x</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≈</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6776em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">x</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">cos</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">x</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≈</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.7278em;vertical-align:-0.0833em;"></span><span class="mord">1</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1.1141em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span><span class="mord">/2</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal">e</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7144em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">x</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≈</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.7278em;vertical-align:-0.0833em;"></span><span class="mord">1</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">x</span></span></span></span></span></p>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mi>ln</mi><mo>⁡</mo><mo stretchy="false">(</mo><mn>1</mn><mo>+</mo><mi>x</mi><mo stretchy="false">)</mo><mo>≈</mo><mi>x</mi><mo separator="true">,</mo><mo stretchy="false">(</mo><mn>1</mn><mo>+</mo><mi>x</mi><msup><mo stretchy="false">)</mo><mi>n</mi></msup><mo>≈</mo><mn>1</mn><mo>+</mo><mi>n</mi><mi>x</mi></mrow><annotation encoding="application/x-tex">\ln (1+x) \approx x,(1+x)^{n} \approx 1+n x
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mop">ln</span><span class="mopen">(</span><span class="mord">1</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal">x</span><span class="mclose">)</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≈</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal">x</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mopen">(</span><span class="mord">1</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal">x</span><span class="mclose"><span class="mclose">)</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7144em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">n</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≈</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.7278em;vertical-align:-0.0833em;"></span><span class="mord">1</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">n</span><span class="mord mathnormal">x</span></span></span></span></span></p>
</li>
</ol>
<h3 id="_1-2-摂動法" tabindex="-1">1.2: 摂動法 <a class="header-anchor" href="#_1-2-摂動法" aria-label="Permalink to &quot;1.2: 摂動法&quot;">&ZeroWidthSpace;</a></h3>
<ol start="2">
<li>摂動法：摂動のない（直接解ける）問題の解を <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>0</mn></mrow><annotation encoding="application/x-tex">0</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">0</span></span></span></span> 番目の近似値として求め，前の似値に基づく次の近似値の補正を繰り返して解を求める．</li>
</ol>
<h3 id="_1-3-定数係数線形微分方程式" tabindex="-1">1.3: 定数係数線形微分方程式 <a class="header-anchor" href="#_1-3-定数係数線形微分方程式" aria-label="Permalink to &quot;1.3: 定数係数線形微分方程式&quot;">&ZeroWidthSpace;</a></h3>
<ol start="3">
<li>
<p>定数係数線形微分方程式 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><msup><mi>y</mi><mrow><mo mathvariant="normal">′</mo><mo mathvariant="normal">′</mo></mrow></msup><mo>+</mo><mi>b</mi><msup><mi>y</mi><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup><mo>+</mo><mi>c</mi><mi>y</mi><mo>=</mo><mn>0</mn></mrow><annotation encoding="application/x-tex">a y^{\prime \prime}+b y^{\prime}+c y=0</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9463em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">a</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">y</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7519em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′′</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.9463em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">b</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">y</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7519em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">cy</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">0</span></span></span></span> の解:</p>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mi>y</mi><mo>=</mo><mi>A</mi><mi>exp</mi><mo>⁡</mo><mrow><mo fence="true">(</mo><msub><mi>λ</mi><mn>1</mn></msub><mi>x</mi><mo fence="true">)</mo></mrow><mo>+</mo><mi>B</mi><mi>exp</mi><mo>⁡</mo><mrow><mo fence="true">(</mo><msub><mi>λ</mi><mn>2</mn></msub><mi>x</mi><mo fence="true">)</mo></mrow><mtext>. </mtext></mrow><annotation encoding="application/x-tex">y=A \exp \left(\lambda_1 x\right)+B \exp \left(\lambda_2 x\right) \text {. }
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">y</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal">A</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">exp</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord"><span class="mord mathnormal">λ</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord mathnormal">x</span><span class="mclose delimcenter" style="top:0em;">)</span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">exp</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord"><span class="mord mathnormal">λ</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord mathnormal">x</span><span class="mclose delimcenter" style="top:0em;">)</span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord text"><span class="mord">. </span></span></span></span></span></span></p>
<p>ここで <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>λ</mi><mrow><mn>1</mn><mo separator="true">,</mo><mn>2</mn></mrow></msub></mrow><annotation encoding="application/x-tex">\lambda_{1,2}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9805em;vertical-align:-0.2861em;"></span><span class="mord"><span class="mord mathnormal">λ</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">1</span><span class="mpunct mtight">,</span><span class="mord mtight">2</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span></span></span></span> は特性方程式 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><msup><mi>λ</mi><mn>2</mn></msup><mo>+</mo><mi>b</mi><mi>λ</mi><mo>+</mo><mi>c</mi><mo>=</mo><mn>0</mn></mrow><annotation encoding="application/x-tex">a \lambda^2+b \lambda+c=0</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8974em;vertical-align:-0.0833em;"></span><span class="mord mathnormal">a</span><span class="mord"><span class="mord mathnormal">λ</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.7778em;vertical-align:-0.0833em;"></span><span class="mord mathnormal">bλ</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">c</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">0</span></span></span></span> の異な る 2 解. もし <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mo separator="true">,</mo><mi>b</mi><mo separator="true">,</mo><mi>c</mi></mrow><annotation encoding="application/x-tex">a, b, c</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">a</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">b</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">c</span></span></span></span> が実数で特性方程式の解が複素数 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>λ</mi><mrow><mn>1</mn><mo separator="true">,</mo><mn>2</mn></mrow></msub><mo>=</mo><mi>γ</mi><mo>±</mo><mi>i</mi><mi>ω</mi></mrow><annotation encoding="application/x-tex">\lambda_{1,2}=\gamma \pm i \omega</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9805em;vertical-align:-0.2861em;"></span><span class="mord"><span class="mord mathnormal">λ</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">1</span><span class="mpunct mtight">,</span><span class="mord mtight">2</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.7778em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.05556em;">γ</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">±</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6595em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">iω</span></span></span></span> ならば,</p>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mi>y</mi><mo>=</mo><mi>C</mi><msup><mi>e</mi><mrow><mi>γ</mi><mi>x</mi></mrow></msup><mi>sin</mi><mo>⁡</mo><mrow><mo fence="true">(</mo><mi>ω</mi><mi>x</mi><mo>+</mo><msub><mi>φ</mi><mn>0</mn></msub><mo fence="true">)</mo></mrow></mrow><annotation encoding="application/x-tex">y=C e^{\gamma x} \sin \left(\omega x+\varphi_0\right)
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">y</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.07153em;">C</span><span class="mord"><span class="mord mathnormal">e</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7144em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.05556em;">γ</span><span class="mord mathnormal mtight">x</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">sin</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord mathnormal" style="margin-right:0.03588em;">ω</span><span class="mord mathnormal">x</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal">φ</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">0</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">)</span></span></span></span></span></span></p>
</li>
</ol>
<h3 id="_1-4-複素数" tabindex="-1">1.4: 複素数 <a class="header-anchor" href="#_1-4-複素数" aria-label="Permalink to &quot;1.4: 複素数&quot;">&ZeroWidthSpace;</a></h3>
<ol start="4">
<li>
<p>複素数</p>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mtable rowspacing="0.25em" columnalign="center" columnspacing="0em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mi>z</mi><mo>=</mo><mi>a</mi><mo>+</mo><mi>b</mi><mi>i</mi><mo>=</mo><mi mathvariant="normal">∣</mi><mi>z</mi><mi mathvariant="normal">∣</mi><msup><mi>e</mi><mrow><mi>i</mi><mi>φ</mi></mrow></msup><mo separator="true">,</mo><mover accent="true"><mi>z</mi><mo>ˉ</mo></mover><mo>=</mo><mi>a</mi><mo>−</mo><mi>b</mi><mi>i</mi><mo>=</mo><mi mathvariant="normal">∣</mi><mi>z</mi><mi mathvariant="normal">∣</mi><msup><mi>e</mi><mrow><mo>−</mo><mi>i</mi><mi>φ</mi></mrow></msup></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mi mathvariant="normal">∣</mi><mi>z</mi><msup><mi mathvariant="normal">∣</mi><mn>2</mn></msup><mo>=</mo><mi>z</mi><mover accent="true"><mi>z</mi><mo>ˉ</mo></mover><mo>=</mo><msup><mi>a</mi><mn>2</mn></msup><mo>+</mo><msup><mi>b</mi><mn>2</mn></msup><mo separator="true">,</mo><mi>φ</mi><mo>=</mo><mi>arg</mi><mo>⁡</mo><mi>z</mi><mo>=</mo><mi>arcsin</mi><mo>⁡</mo><mfrac><mi>b</mi><mrow><mi mathvariant="normal">∣</mi><mi>z</mi><mi mathvariant="normal">∣</mi></mrow></mfrac></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mi mathvariant="normal">Re</mi><mo>⁡</mo><mi>z</mi><mo>=</mo><mo stretchy="false">(</mo><mi>z</mi><mo>+</mo><mover accent="true"><mi>z</mi><mo>ˉ</mo></mover><mo stretchy="false">)</mo><mi mathvariant="normal">/</mi><mn>2</mn><mo separator="true">,</mo><mi mathvariant="normal">Im</mi><mo>⁡</mo><mi>z</mi><mo>=</mo><mo stretchy="false">(</mo><mi>z</mi><mo>−</mo><mover accent="true"><mi>z</mi><mo>ˉ</mo></mover><mo stretchy="false">)</mo><mi mathvariant="normal">/</mi><mn>2</mn><mi>i</mi></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow><mo fence="true">∣</mo><msub><mi>z</mi><mn>1</mn></msub><msub><mi>z</mi><mn>2</mn></msub><mo fence="true">∣</mo></mrow><mo>=</mo><mrow><mo fence="true">∣</mo><msub><mi>z</mi><mn>1</mn></msub><mo fence="true">∣</mo></mrow><mrow><mo fence="true">∣</mo><msub><mi>z</mi><mn>2</mn></msub><mo fence="true">∣</mo></mrow><mo separator="true">,</mo><mi>arg</mi><mo>⁡</mo><msub><mi>z</mi><mn>1</mn></msub><msub><mi>z</mi><mn>2</mn></msub><mo>=</mo><mi>arg</mi><mo>⁡</mo><msub><mi>z</mi><mn>1</mn></msub><mo>+</mo><mi>arg</mi><mo>⁡</mo><msub><mi>z</mi><mn>2</mn></msub></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><msup><mi>e</mi><mrow><mi>i</mi><mi>φ</mi></mrow></msup><mo>=</mo><mi>cos</mi><mo>⁡</mo><mi>φ</mi><mo>+</mo><mi>i</mi><mi>sin</mi><mo>⁡</mo><mi>φ</mi></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mi>cos</mi><mo>⁡</mo><mi>φ</mi><mo>=</mo><mfrac><mrow><msup><mi>e</mi><mrow><mi>i</mi><mi>φ</mi></mrow></msup><mo>+</mo><msup><mi>e</mi><mrow><mo>−</mo><mi>i</mi><mi>φ</mi></mrow></msup></mrow><mn>2</mn></mfrac><mo separator="true">,</mo><mi>sin</mi><mo>⁡</mo><mi>φ</mi><mo>=</mo><mfrac><mrow><msup><mi>e</mi><mrow><mi>i</mi><mi>φ</mi></mrow></msup><mo>−</mo><msup><mi>e</mi><mrow><mo>−</mo><mi>i</mi><mi>φ</mi></mrow></msup></mrow><mrow><mn>2</mn><mi>i</mi></mrow></mfrac></mrow></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{gathered}
z=a+b i=|z| e^{i \varphi}, \bar{z}=a-b i=|z| e^{-i \varphi} \\
|z|^2=z \bar{z}=a^2+b^2, \varphi=\arg z=\arcsin \frac{b}{|z|} \\
\operatorname{Re} z=(z+\bar{z}) / 2, \operatorname{Im} z=(z-\bar{z}) / 2 i \\
\left|z_1 z_2\right|=\left|z_1\right|\left|z_2\right|, \arg z_1 z_2=\arg z_1+\arg z_2 \\
e^{i \varphi}=\cos \varphi+i \sin \varphi \\
\cos \varphi=\frac{e^{i \varphi}+e^{-i \varphi}}{2}, \sin \varphi=\frac{e^{i \varphi}-e^{-i \varphi}}{2 i}
\end{gathered}
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:11.1644em;vertical-align:-5.3322em;"></span><span class="mord"><span class="mtable"><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:5.8322em;"><span style="top:-8.4592em;"><span class="pstrut" style="height:3.5017em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.04398em;">z</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord mathnormal">a</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal">bi</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord">∣</span><span class="mord mathnormal" style="margin-right:0.04398em;">z</span><span class="mord">∣</span><span class="mord"><span class="mord mathnormal">e</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8747em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">i</span><span class="mord mathnormal mtight">φ</span></span></span></span></span></span></span></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.5678em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord mathnormal" style="margin-right:0.04398em;">z</span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.1944em;"><span class="mord">ˉ</span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord mathnormal">a</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal">bi</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord">∣</span><span class="mord mathnormal" style="margin-right:0.04398em;">z</span><span class="mord">∣</span><span class="mord"><span class="mord mathnormal">e</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8747em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">−</span><span class="mord mathnormal mtight">i</span><span class="mord mathnormal mtight">φ</span></span></span></span></span></span></span></span></span></span></span><span style="top:-6.4278em;"><span class="pstrut" style="height:3.5017em;"></span><span class="mord"><span class="mord">∣</span><span class="mord mathnormal" style="margin-right:0.04398em;">z</span><span class="mord"><span class="mord">∣</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord mathnormal" style="margin-right:0.04398em;">z</span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.5678em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord mathnormal" style="margin-right:0.04398em;">z</span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.1944em;"><span class="mord">ˉ</span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal">b</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">φ</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mop">ar<span style="margin-right:0.01389em;">g</span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.04398em;">z</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mop">arcsin</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.3714em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">∣</span><span class="mord mathnormal" style="margin-right:0.04398em;">z</span><span class="mord">∣</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">b</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.936em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span><span style="top:-4.3518em;"><span class="pstrut" style="height:3.5017em;"></span><span class="mord"><span class="mop"><span class="mord mathrm">Re</span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.04398em;">z</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.04398em;">z</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.5678em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord mathnormal" style="margin-right:0.04398em;">z</span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.1944em;"><span class="mord">ˉ</span></span></span></span></span></span></span><span class="mclose">)</span><span class="mord">/2</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop"><span class="mord mathrm">Im</span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.04398em;">z</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.04398em;">z</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.5678em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord mathnormal" style="margin-right:0.04398em;">z</span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.1944em;"><span class="mord">ˉ</span></span></span></span></span></span></span><span class="mclose">)</span><span class="mord">/2</span><span class="mord mathnormal">i</span></span></span><span style="top:-2.8518em;"><span class="pstrut" style="height:3.5017em;"></span><span class="mord"><span class="minner"><span class="mopen delimcenter" style="top:0em;">∣</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.04398em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.044em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.04398em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.044em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">∣</span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">∣</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.04398em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.044em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">∣</span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">∣</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.04398em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.044em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">∣</span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">ar<span style="margin-right:0.01389em;">g</span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.04398em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.044em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.04398em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.044em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mop">ar<span style="margin-right:0.01389em;">g</span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.04398em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.044em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mop">ar<span style="margin-right:0.01389em;">g</span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.04398em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.044em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span><span style="top:-1.3171em;"><span class="pstrut" style="height:3.5017em;"></span><span class="mord"><span class="mord"><span class="mord mathnormal">e</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8747em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">i</span><span class="mord mathnormal mtight">φ</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mop">cos</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">φ</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal">i</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">sin</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">φ</span></span></span><span style="top:0.8446em;"><span class="pstrut" style="height:3.5017em;"></span><span class="mord"><span class="mop">cos</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">φ</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.5017em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">2</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"><span class="mord mathnormal">e</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8247em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">i</span><span class="mord mathnormal mtight">φ</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal">e</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8247em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">−</span><span class="mord mathnormal mtight">i</span><span class="mord mathnormal mtight">φ</span></span></span></span></span></span></span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">sin</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">φ</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.5017em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">2</span><span class="mord mathnormal">i</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"><span class="mord mathnormal">e</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8247em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">i</span><span class="mord mathnormal mtight">φ</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal">e</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8247em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">−</span><span class="mord mathnormal mtight">i</span><span class="mord mathnormal mtight">φ</span></span></span></span></span></span></span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:5.3322em;"><span></span></span></span></span></span></span></span></span></span></span></span></p>
</li>
</ol>
<h3 id="_1-5-ベクトルの内積と外積" tabindex="-1">1.5: ベクトルの内積と外積 <a class="header-anchor" href="#_1-5-ベクトルの内積と外積" aria-label="Permalink to &quot;1.5: ベクトルの内積と外積&quot;">&ZeroWidthSpace;</a></h3>
<ol start="5">
<li>
<p>ベクトルの内積と外積は分配法則が成立する : <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mo stretchy="false">(</mo><mi>b</mi><mo>+</mo><mi>c</mi><mo stretchy="false">)</mo><mo>=</mo><mi>a</mi><mi>b</mi><mo>+</mo><mi>a</mi><mi>c</mi></mrow><annotation encoding="application/x-tex">a(b+c)=a b+a c</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal">a</span><span class="mopen">(</span><span class="mord mathnormal">b</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal">c</span><span class="mclose">)</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.7778em;vertical-align:-0.0833em;"></span><span class="mord mathnormal">ab</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">a</span><span class="mord mathnormal">c</span></span></span></span></p>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mtable rowspacing="0.25em" columnalign="center" columnspacing="0em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mi mathvariant="bold-italic">a</mi><mo>⋅</mo><mi mathvariant="bold-italic">b</mi><mo>=</mo><mi mathvariant="bold-italic">b</mi><mo>⋅</mo><mi mathvariant="bold-italic">a</mi><mo>=</mo><msub><mi>a</mi><mi>x</mi></msub><msub><mi>b</mi><mi>x</mi></msub><mo>+</mo><msub><mi>a</mi><mi>y</mi></msub><msub><mi>b</mi><mi>y</mi></msub><mo>+</mo><mo>⋯</mo><mo>=</mo><mi>a</mi><mi>b</mi><mi>cos</mi><mo>⁡</mo><mi>φ</mi></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mi mathvariant="normal">∣</mi><mi mathvariant="bold-italic">a</mi><mo>×</mo><mi mathvariant="bold-italic">b</mi><mi mathvariant="normal">∣</mi><mo>=</mo><mi>a</mi><mi>b</mi><mi>sin</mi><mo>⁡</mo><mi>φ</mi><mo separator="true">,</mo><mi mathvariant="bold-italic">a</mi><mo>×</mo><mi mathvariant="bold-italic">b</mi><mo>=</mo><mo>−</mo><mi mathvariant="bold-italic">b</mi><mo>×</mo><mi mathvariant="bold-italic">a</mi><mo>⊥</mo><mi mathvariant="bold-italic">a</mi><mo separator="true">,</mo><mi mathvariant="bold-italic">b</mi></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mi mathvariant="bold-italic">a</mi><mo>×</mo><mi mathvariant="bold-italic">b</mi><mo>=</mo><mrow><mo fence="true">(</mo><msub><mi>a</mi><mi>y</mi></msub><msub><mi>b</mi><mi>z</mi></msub><mo>−</mo><msub><mi>a</mi><mi>z</mi></msub><msub><mi>b</mi><mi>y</mi></msub><mo fence="true">)</mo></mrow><msub><mi mathvariant="bold-italic">e</mi><mi>x</mi></msub><mo>+</mo><mrow><mo fence="true">(</mo><msub><mi>a</mi><mi>z</mi></msub><msub><mi>b</mi><mi>x</mi></msub><mo>−</mo><msub><mi>a</mi><mi>x</mi></msub><msub><mi>b</mi><mi>z</mi></msub><mo fence="true">)</mo></mrow><msub><mi mathvariant="bold-italic">e</mi><mi>y</mi></msub><mo>+</mo><mo>⋯</mo></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mi mathvariant="bold-italic">a</mi><mo>×</mo><mo stretchy="false">[</mo><mi mathvariant="bold-italic">b</mi><mo>×</mo><mi mathvariant="bold-italic">c</mi><mo stretchy="false">]</mo><mo>=</mo><mo stretchy="false">(</mo><mi mathvariant="bold-italic">a</mi><mo>⋅</mo><mi mathvariant="bold-italic">c</mi><mo stretchy="false">)</mo><mi mathvariant="bold-italic">b</mi><mo>−</mo><mo stretchy="false">(</mo><mi mathvariant="bold-italic">a</mi><mo>⋅</mo><mi mathvariant="bold-italic">b</mi><mo stretchy="false">)</mo><mi mathvariant="bold-italic">c</mi></mrow></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{gathered}
\boldsymbol{a} \cdot \boldsymbol{b}=\boldsymbol{b} \cdot \boldsymbol{a}=a_x b_x+a_y b_y+\cdots=a b \cos \varphi \\
|\boldsymbol{a} \times \boldsymbol{b}|=a b \sin \varphi, \boldsymbol{a} \times \boldsymbol{b}=-\boldsymbol{b} \times \boldsymbol{a} \perp \boldsymbol{a}, \boldsymbol{b} \\
\boldsymbol{a} \times \boldsymbol{b}=\left(a_y b_z-a_z b_y\right) \boldsymbol{e}_x+\left(a_z b_x-a_x b_z\right) \boldsymbol{e}_y+\cdots \\
\boldsymbol{a} \times[\boldsymbol{b} \times \boldsymbol{c}]=(\boldsymbol{a} \cdot \boldsymbol{c}) \boldsymbol{b}-(\boldsymbol{a} \cdot \boldsymbol{b}) \boldsymbol{c}
\end{gathered}
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:6em;vertical-align:-2.75em;"></span><span class="mord"><span class="mtable"><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:3.25em;"><span style="top:-5.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol">a</span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">⋅</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol">b</span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol">b</span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">⋅</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol">a</span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">x</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathnormal">b</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">x</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.03588em;">y</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathnormal">b</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.03588em;">y</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="minner">⋯</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord mathnormal">ab</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">cos</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">φ</span></span></span><span style="top:-3.91em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">∣</span><span class="mord"><span class="mord"><span class="mord boldsymbol">a</span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">×</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol">b</span></span></span><span class="mord">∣</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord mathnormal">ab</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">sin</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">φ</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol">a</span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">×</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol">b</span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord">−</span><span class="mord"><span class="mord"><span class="mord boldsymbol">b</span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">×</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol">a</span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">⊥</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol">a</span></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol">b</span></span></span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol">a</span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">×</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol">b</span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.03588em;">y</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathnormal">b</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.04398em;">z</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.04398em;">z</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathnormal">b</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.03588em;">y</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">)</span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol">e</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">x</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.04398em;">z</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathnormal">b</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">x</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">x</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathnormal">b</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.04398em;">z</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">)</span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol">e</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.03588em;">y</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="minner">⋯</span></span></span><span style="top:-0.91em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol">a</span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">×</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mopen">[</span><span class="mord"><span class="mord"><span class="mord boldsymbol">b</span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">×</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol">c</span></span></span><span class="mclose">]</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mopen">(</span><span class="mord"><span class="mord"><span class="mord boldsymbol">a</span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">⋅</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol">c</span></span></span><span class="mclose">)</span><span class="mord"><span class="mord"><span class="mord boldsymbol">b</span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mopen">(</span><span class="mord"><span class="mord"><span class="mord boldsymbol">a</span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">⋅</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol">b</span></span></span><span class="mclose">)</span><span class="mord"><span class="mord"><span class="mord boldsymbol">c</span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:2.75em;"><span></span></span></span></span></span></span></span></span></span></span></span></p>
<p>スカラー三重積（3 つのベクトルで張られる平行四面 体の体積）:</p>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mo stretchy="false">(</mo><mi mathvariant="bold-italic">a</mi><mo separator="true">,</mo><mi mathvariant="bold-italic">b</mi><mo separator="true">,</mo><mi mathvariant="bold-italic">c</mi><mo stretchy="false">)</mo><mo>≡</mo><mi mathvariant="bold-italic">a</mi><mo>⋅</mo><mo stretchy="false">[</mo><mi mathvariant="bold-italic">b</mi><mo>×</mo><mi mathvariant="bold-italic">c</mi><mo stretchy="false">]</mo><mo>=</mo><mo stretchy="false">[</mo><mi mathvariant="bold-italic">a</mi><mo>×</mo><mi mathvariant="bold-italic">b</mi><mo stretchy="false">]</mo><mo>⋅</mo><mi mathvariant="bold-italic">c</mi><mo>=</mo><mo stretchy="false">(</mo><mi mathvariant="bold-italic">b</mi><mo separator="true">,</mo><mi mathvariant="bold-italic">c</mi><mo separator="true">,</mo><mi mathvariant="bold-italic">a</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">(\boldsymbol{a}, \boldsymbol{b}, \boldsymbol{c}) \equiv \boldsymbol{a} \cdot[\boldsymbol{b} \times \boldsymbol{c}]=[\boldsymbol{a} \times \boldsymbol{b}] \cdot \boldsymbol{c}=(\boldsymbol{b}, \boldsymbol{c}, \boldsymbol{a})
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">(</span><span class="mord"><span class="mord"><span class="mord boldsymbol">a</span></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol">b</span></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol">c</span></span></span><span class="mclose">)</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≡</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.4445em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol">a</span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">⋅</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">[</span><span class="mord"><span class="mord"><span class="mord boldsymbol">b</span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">×</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol">c</span></span></span><span class="mclose">]</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">[</span><span class="mord"><span class="mord"><span class="mord boldsymbol">a</span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">×</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol">b</span></span></span><span class="mclose">]</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">⋅</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.4444em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol">c</span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">(</span><span class="mord"><span class="mord"><span class="mord boldsymbol">b</span></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol">c</span></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol">a</span></span></span><span class="mclose">)</span></span></span></span></span></p>
</li>
</ol>
<h3 id="_1-6-余弦定理と正弦定理" tabindex="-1">1.6: 余弦定理と正弦定理 <a class="header-anchor" href="#_1-6-余弦定理と正弦定理" aria-label="Permalink to &quot;1.6: 余弦定理と正弦定理&quot;">&ZeroWidthSpace;</a></h3>
<ol start="6">
<li>余弦定理と正弦定理：<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mtable rowspacing="0.25em" columnalign="right left" columnspacing="0em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><msup><mi>c</mi><mn>2</mn></msup><mo>=</mo><msup><mi>a</mi><mn>2</mn></msup><mo>+</mo><msup><mi>b</mi><mn>2</mn></msup><mo>−</mo><mn>2</mn><mi>a</mi><mi>b</mi><mi>cos</mi><mo>⁡</mo><mi>C</mi></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mi>a</mi><mi mathvariant="normal">/</mi><mi>sin</mi><mo>⁡</mo><mi>A</mi><mo>=</mo><mi>b</mi><mi mathvariant="normal">/</mi><mi>sin</mi><mo>⁡</mo><mi>B</mi><mo>=</mo><mn>2</mn><mi>R</mi></mrow></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{aligned}
&amp; c^2=a^2+b^2-2 a b \cos C \\
&amp; a / \sin A=b / \sin B=2 R
\end{aligned}
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:3.0241em;vertical-align:-1.2621em;"></span><span class="mord"><span class="mtable"><span class="col-align-r"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.7621em;"><span style="top:-3.7621em;"><span class="pstrut" style="height:2.8641em;"></span><span class="mord"></span></span><span style="top:-2.2621em;"><span class="pstrut" style="height:2.8641em;"></span><span class="mord"></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.2621em;"><span></span></span></span></span></span><span class="col-align-l"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.7621em;"><span style="top:-3.8979em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"></span><span class="mord"><span class="mord mathnormal">c</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal">b</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord">2</span><span class="mord mathnormal">ab</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">cos</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.07153em;">C</span></span></span><span style="top:-2.3979em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"></span><span class="mord mathnormal">a</span><span class="mord">/</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">sin</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">A</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord mathnormal">b</span><span class="mord">/</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">sin</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord">2</span><span class="mord mathnormal" style="margin-right:0.00773em;">R</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.2621em;"><span></span></span></span></span></span></span></span></span></span></span></span></p>
</li>
</ol>
<h3 id="_1-7-三角法" tabindex="-1">1.7: 三角法 <a class="header-anchor" href="#_1-7-三角法" aria-label="Permalink to &quot;1.7: 三角法&quot;">&ZeroWidthSpace;</a></h3>
<ol start="7">
<li>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mtable rowspacing="0.25em" columnalign="right left" columnspacing="0em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mi>sin</mi><mo>⁡</mo><mo stretchy="false">(</mo><mi>α</mi><mo>±</mo><mi>β</mi><mo stretchy="false">)</mo><mo>=</mo><mi>sin</mi><mo>⁡</mo><mi>α</mi><mi>cos</mi><mo>⁡</mo><mi>β</mi><mo>±</mo><mi>cos</mi><mo>⁡</mo><mi>α</mi><mi>sin</mi><mo>⁡</mo><mi>β</mi></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mi>cos</mi><mo>⁡</mo><mo stretchy="false">(</mo><mi>α</mi><mo>±</mo><mi>β</mi><mo stretchy="false">)</mo><mo>=</mo><mi>cos</mi><mo>⁡</mo><mi>α</mi><mi>cos</mi><mo>⁡</mo><mi>β</mi><mo>∓</mo><mi>sin</mi><mo>⁡</mo><mi>α</mi><mi>sin</mi><mo>⁡</mo><mi>β</mi></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mi>tan</mi><mo>⁡</mo><mo stretchy="false">(</mo><mi>α</mi><mo>±</mo><mi>β</mi><mo stretchy="false">)</mo><mo>=</mo><mo stretchy="false">(</mo><mi>tan</mi><mo>⁡</mo><mi>α</mi><mo>±</mo><mi>tan</mi><mo>⁡</mo><mi>β</mi><mo stretchy="false">)</mo><mi mathvariant="normal">/</mi><mo stretchy="false">(</mo><mn>1</mn><mo>∓</mo><mi>tan</mi><mo>⁡</mo><mi>α</mi><mi>tan</mi><mo>⁡</mo><mi>β</mi><mo stretchy="false">)</mo></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><msup><mrow><mi>cos</mi><mo>⁡</mo></mrow><mn>2</mn></msup><mi>α</mi><mo>=</mo><mfrac><mrow><mn>1</mn><mo>+</mo><mi>cos</mi><mo>⁡</mo><mn>2</mn><mi>α</mi></mrow><mn>2</mn></mfrac><mo separator="true">,</mo><msup><mrow><mi>sin</mi><mo>⁡</mo></mrow><mn>2</mn></msup><mi>α</mi><mo>=</mo><mfrac><mrow><mn>1</mn><mo>−</mo><mi>cos</mi><mo>⁡</mo><mn>2</mn><mi>α</mi></mrow><mn>2</mn></mfrac></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mi>cos</mi><mo>⁡</mo><mi>α</mi><mi>cos</mi><mo>⁡</mo><mi>β</mi><mo>=</mo><mfrac><mrow><mi>cos</mi><mo>⁡</mo><mo stretchy="false">(</mo><mi>α</mi><mo>+</mo><mi>β</mi><mo stretchy="false">)</mo><mo>+</mo><mi>cos</mi><mo>⁡</mo><mo stretchy="false">(</mo><mi>α</mi><mo>−</mo><mi>β</mi><mo stretchy="false">)</mo></mrow><mn>2</mn></mfrac><mo separator="true">,</mo><mo>…</mo></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mi>cos</mi><mo>⁡</mo><mi>α</mi><mo>+</mo><mi>cos</mi><mo>⁡</mo><mi>β</mi><mo>=</mo><mn>2</mn><mrow><mo fence="true">(</mo><mi>cos</mi><mo>⁡</mo><mfrac><mrow><mi>α</mi><mo>+</mo><mi>β</mi></mrow><mn>2</mn></mfrac><mo>+</mo><mi>cos</mi><mo>⁡</mo><mfrac><mrow><mi>α</mi><mo>−</mo><mi>β</mi></mrow><mn>2</mn></mfrac><mo fence="true">)</mo></mrow><mo separator="true">,</mo><mo>…</mo></mrow></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{aligned}
&amp; \sin (\alpha \pm \beta)=\sin \alpha \cos \beta \pm \cos \alpha \sin \beta \\
&amp; \cos (\alpha \pm \beta)=\cos \alpha \cos \beta \mp \sin \alpha \sin \beta \\
&amp; \tan (\alpha \pm \beta)=(\tan \alpha \pm \tan \beta) /(1 \mp \tan \alpha \tan \beta) \\
&amp; \cos ^2 \alpha=\frac{1+\cos 2 \alpha}{2}, \sin ^2 \alpha=\frac{1-\cos 2 \alpha}{2} \\
&amp; \cos \alpha \cos \beta=\frac{\cos (\alpha+\beta)+\cos (\alpha-\beta)}{2}, \ldots \\
&amp; \cos \alpha+\cos \beta=2\left(\cos \frac{\alpha+\beta}{2}+\cos \frac{\alpha-\beta}{2}\right), \ldots
\end{aligned}
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:11.9205em;vertical-align:-5.7102em;"></span><span class="mord"><span class="mtable"><span class="col-align-r"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:6.2102em;"><span style="top:-8.8202em;"><span class="pstrut" style="height:3.45em;"></span><span class="mord"></span></span><span style="top:-7.3202em;"><span class="pstrut" style="height:3.45em;"></span><span class="mord"></span></span><span style="top:-5.8202em;"><span class="pstrut" style="height:3.45em;"></span><span class="mord"></span></span><span style="top:-3.8388em;"><span class="pstrut" style="height:3.45em;"></span><span class="mord"></span></span><span style="top:-1.4258em;"><span class="pstrut" style="height:3.45em;"></span><span class="mord"></span></span><span style="top:1.0102em;"><span class="pstrut" style="height:3.45em;"></span><span class="mord"></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:5.7102em;"><span></span></span></span></span></span><span class="col-align-l"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:6.2102em;"><span style="top:-8.8202em;"><span class="pstrut" style="height:3.45em;"></span><span class="mord"><span class="mord"></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">sin</span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.0037em;">α</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">±</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal" style="margin-right:0.05278em;">β</span><span class="mclose">)</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mop">sin</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.0037em;">α</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">cos</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.05278em;">β</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">±</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mop">cos</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.0037em;">α</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">sin</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.05278em;">β</span></span></span><span style="top:-7.3202em;"><span class="pstrut" style="height:3.45em;"></span><span class="mord"><span class="mord"></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">cos</span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.0037em;">α</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">±</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal" style="margin-right:0.05278em;">β</span><span class="mclose">)</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mop">cos</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.0037em;">α</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">cos</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.05278em;">β</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">∓</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mop">sin</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.0037em;">α</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">sin</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.05278em;">β</span></span></span><span style="top:-5.8202em;"><span class="pstrut" style="height:3.45em;"></span><span class="mord"><span class="mord"></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">tan</span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.0037em;">α</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">±</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal" style="margin-right:0.05278em;">β</span><span class="mclose">)</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mopen">(</span><span class="mop">tan</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.0037em;">α</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">±</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mop">tan</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.05278em;">β</span><span class="mclose">)</span><span class="mord">/</span><span class="mopen">(</span><span class="mord">1</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">∓</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mop">tan</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.0037em;">α</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">tan</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.05278em;">β</span><span class="mclose">)</span></span></span><span style="top:-3.8388em;"><span class="pstrut" style="height:3.45em;"></span><span class="mord"><span class="mord"></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop"><span class="mop">cos</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.0037em;">α</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.3214em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">2</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">1</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mop">cos</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord">2</span><span class="mord mathnormal" style="margin-right:0.0037em;">α</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop"><span class="mop">sin</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8719em;"><span style="top:-3.1208em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.0037em;">α</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.3214em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">2</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">1</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mop">cos</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord">2</span><span class="mord mathnormal" style="margin-right:0.0037em;">α</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span><span style="top:-1.4258em;"><span class="pstrut" style="height:3.45em;"></span><span class="mord"><span class="mord"></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">cos</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.0037em;">α</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">cos</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.05278em;">β</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.427em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">2</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mop">cos</span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.0037em;">α</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal" style="margin-right:0.05278em;">β</span><span class="mclose">)</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mop">cos</span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.0037em;">α</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal" style="margin-right:0.05278em;">β</span><span class="mclose">)</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner">…</span></span></span><span style="top:1.0102em;"><span class="pstrut" style="height:3.45em;"></span><span class="mord"><span class="mord"></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">cos</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.0037em;">α</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mop">cos</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.05278em;">β</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord">2</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size3">(</span></span><span class="mop">cos</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.3714em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">2</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.0037em;">α</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal" style="margin-right:0.05278em;">β</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mop">cos</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.3714em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">2</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.0037em;">α</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal" style="margin-right:0.05278em;">β</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size3">)</span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner">…</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:5.7102em;"><span></span></span></span></span></span></span></span></span></span></span></span></p>
</li>
</ol>
<h3 id="_1-8-円周角" tabindex="-1">1.8: 円周角 <a class="header-anchor" href="#_1-8-円周角" aria-label="Permalink to &quot;1.8: 円周角&quot;">&ZeroWidthSpace;</a></h3>
<ol start="8">
<li>円周角は中心角の半分. よって，直角三角形の斜辺は その外接円の直径. もし四角形の対角の和が 180 度な らば，それは円に内接する.</li>
</ol>
<h3 id="_1-9-三角形の面樍" tabindex="-1">1.9: 三角形の面樍 <a class="header-anchor" href="#_1-9-三角形の面樍" aria-label="Permalink to &quot;1.9: 三角形の面樍&quot;">&ZeroWidthSpace;</a></h3>
<ol start="9">
<li>三角形の面樍 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>=</mo><mfrac><mn>1</mn><mn>2</mn></mfrac><mi>a</mi><msub><mi>h</mi><mi>a</mi></msub><mo>=</mo><mi>p</mi><mi>r</mi><mo>=</mo><msqrt><mrow><mi>p</mi><mo stretchy="false">(</mo><mi>p</mi><mo>−</mo><mi>a</mi><mo stretchy="false">)</mo><mo stretchy="false">(</mo><mi>p</mi><mo>−</mo><mi>b</mi><mo stretchy="false">)</mo><mo stretchy="false">(</mo><mi>p</mi><mo>−</mo><mi>c</mi><mo stretchy="false">)</mo></mrow></msqrt><mo>=</mo><mi>a</mi><mi>b</mi><mi>c</mi><mi mathvariant="normal">/</mi><mn>4</mn><mi>R</mi></mrow><annotation encoding="application/x-tex">=\frac{1}{2} a h_a=p r=\sqrt{p(p-a)(p-b)(p-c)}=a b c / 4 R</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.1901em;vertical-align:-0.345em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8451em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">1</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mord mathnormal">a</span><span class="mord"><span class="mord mathnormal">h</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">a</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">p</span><span class="mord mathnormal" style="margin-right:0.02778em;">r</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.24em;vertical-align:-0.305em;"></span><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.935em;"><span class="svg-align" style="top:-3.2em;"><span class="pstrut" style="height:3.2em;"></span><span class="mord" style="padding-left:1em;"><span class="mord mathnormal">p</span><span class="mopen">(</span><span class="mord mathnormal">p</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal">a</span><span class="mclose">)</span><span class="mopen">(</span><span class="mord mathnormal">p</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal">b</span><span class="mclose">)</span><span class="mopen">(</span><span class="mord mathnormal">p</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal">c</span><span class="mclose">)</span></span></span><span style="top:-2.895em;"><span class="pstrut" style="height:3.2em;"></span><span class="hide-tail" style="min-width:1.02em;height:1.28em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='1.28em' viewBox='0 0 400000 1296' preserveAspectRatio='xMinYMin slice'><path d='M263,681c0.7,0,18,39.7,52,119
c34,79.3,68.167,158.7,102.5,238c34.3,79.3,51.8,119.3,52.5,120
c340,-704.7,510.7,-1060.3,512,-1067
l0 -0
c4.7,-7.3,11,-11,19,-11
H40000v40H1012.3
s-271.3,567,-271.3,567c-38.7,80.7,-84,175,-136,283c-52,108,-89.167,185.3,-111.5,232
c-22.3,46.7,-33.8,70.3,-34.5,71c-4.7,4.7,-12.3,7,-23,7s-12,-1,-12,-1
s-109,-253,-109,-253c-72.7,-168,-109.3,-252,-110,-252c-10.7,8,-22,16.7,-34,26
c-22,17.3,-33.3,26,-34,26s-26,-26,-26,-26s76,-59,76,-59s76,-60,76,-60z
M1001 80h400000v40h-400000z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.305em;"><span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal">ab</span><span class="mord mathnormal">c</span><span class="mord">/4</span><span class="mord mathnormal" style="margin-right:0.00773em;">R</span></span></span></span></li>
</ol>
<h3 id="_1-10-重心" tabindex="-1">1.10: 重心 <a class="header-anchor" href="#_1-10-重心" aria-label="Permalink to &quot;1.10: 重心&quot;">&ZeroWidthSpace;</a></h3>
<ol start="10">
<li>三角形の重心は，中線の交点で，中線を 2:1 に内分する.\</li>
</ol>
<h3 id="_1-11-ベクトルアプローチ" tabindex="-1">1.11: ベクトルアプローチ <Badge type="tip" text="supplemental" /> <a class="header-anchor" href="#_1-11-ベクトルアプローチ" aria-label="Permalink to &quot;1.11: ベクトルアプローチ &lt;Badge type=&quot;tip&quot; text=&quot;supplemental&quot; /&gt;&quot;">&ZeroWidthSpace;</a></h3>
<ol>
<li>幾何の問題へのベクトルアプローチ.</li>
</ol>
<h3 id="_1-12-微分" tabindex="-1">1.12: 微分 <a class="header-anchor" href="#_1-12-微分" aria-label="Permalink to &quot;1.12: 微分&quot;">&ZeroWidthSpace;</a></h3>
<ol start="12">
<li>微分:<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mtable rowspacing="0.25em" columnalign="center" columnspacing="0em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mo stretchy="false">(</mo><mi>f</mi><mi>g</mi><msup><mo stretchy="false">)</mo><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup><mo>=</mo><msup><mi>f</mi><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup><mi>g</mi><mo>+</mo><mi>f</mi><msup><mi>g</mi><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup><mo separator="true">,</mo><mi>f</mi><mo stretchy="false">[</mo><mi>g</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo><msup><mo stretchy="false">]</mo><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup><mo>=</mo><msup><mi>f</mi><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup><mo stretchy="false">[</mo><mi>g</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo><mo stretchy="false">]</mo><msup><mi>g</mi><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mo stretchy="false">(</mo><mi>sin</mi><mo>⁡</mo><mi>x</mi><msup><mo stretchy="false">)</mo><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup><mo>=</mo><mi>cos</mi><mo>⁡</mo><mi>x</mi><mo separator="true">,</mo><mo stretchy="false">(</mo><mi>cos</mi><mo>⁡</mo><mi>x</mi><msup><mo stretchy="false">)</mo><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup><mo>=</mo><mo>−</mo><mi>sin</mi><mo>⁡</mo><mi>x</mi></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><msup><mrow><mo fence="true">(</mo><msup><mi>e</mi><mi>x</mi></msup><mo fence="true">)</mo></mrow><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup><mo>=</mo><msup><mi>e</mi><mi>x</mi></msup><mo separator="true">,</mo><mo stretchy="false">(</mo><mi>ln</mi><mo>⁡</mo><mi>x</mi><msup><mo stretchy="false">)</mo><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup><mo>=</mo><mn>1</mn><mi mathvariant="normal">/</mi><mi>x</mi><mo separator="true">,</mo><msup><mrow><mo fence="true">(</mo><msup><mi>x</mi><mi>n</mi></msup><mo fence="true">)</mo></mrow><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup><mo>=</mo><mi>n</mi><msup><mi>x</mi><mrow><mi>n</mi><mo>−</mo><mn>1</mn></mrow></msup></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mo stretchy="false">(</mo><mi>arctan</mi><mo>⁡</mo><mi>x</mi><msup><mo stretchy="false">)</mo><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup><mo>=</mo><mn>1</mn><mi mathvariant="normal">/</mi><mrow><mo fence="true">(</mo><mn>1</mn><mo>+</mo><msup><mi>x</mi><mn>2</mn></msup><mo fence="true">)</mo></mrow></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mo stretchy="false">(</mo><mi>arcsin</mi><mo>⁡</mo><mi>x</mi><msup><mo stretchy="false">)</mo><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup><mo>=</mo><mo>−</mo><mo stretchy="false">(</mo><mi>arccos</mi><mo>⁡</mo><mi>x</mi><msup><mo stretchy="false">)</mo><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup><mo>=</mo><mn>1</mn><mi mathvariant="normal">/</mi><msqrt><mrow><mn>1</mn><mo>−</mo><msup><mi>x</mi><mn>2</mn></msup></mrow></msqrt></mrow></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{gathered}
(f g)^{\prime}=f^{\prime} g+f g^{\prime}, f[g(x)]^{\prime}=f^{\prime}[g(x)] g^{\prime}(x) \\
(\sin x)^{\prime}=\cos x,(\cos x)^{\prime}=-\sin x \\
\left(e^x\right)^{\prime}=e^x,(\ln x)^{\prime}=1 / x,\left(x^n\right)^{\prime}=n x^{n-1} \\
(\arctan x)^{\prime}=1 /\left(1+x^2\right) \\
(\arcsin x)^{\prime}=-(\arccos x)^{\prime}=1 / \sqrt{1-x^2}
\end{gathered}
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:7.7982em;vertical-align:-3.6491em;"></span><span class="mord"><span class="mtable"><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:4.1491em;"><span style="top:-6.3713em;"><span class="pstrut" style="height:3.0623em;"></span><span class="mord"><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.10764em;">f</span><span class="mord mathnormal" style="margin-right:0.03588em;">g</span><span class="mclose"><span class="mclose">)</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8019em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.10764em;">f</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8019em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span><span class="mord mathnormal" style="margin-right:0.03588em;">g</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal" style="margin-right:0.10764em;">f</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">g</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8019em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.10764em;">f</span><span class="mopen">[</span><span class="mord mathnormal" style="margin-right:0.03588em;">g</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">)</span><span class="mclose"><span class="mclose">]</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8019em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.10764em;">f</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8019em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span><span class="mopen">[</span><span class="mord mathnormal" style="margin-right:0.03588em;">g</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">)]</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">g</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8019em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">)</span></span></span><span style="top:-4.8713em;"><span class="pstrut" style="height:3.0623em;"></span><span class="mord"><span class="mopen">(</span><span class="mop">sin</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">x</span><span class="mclose"><span class="mclose">)</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8019em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mop">cos</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">x</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mopen">(</span><span class="mop">cos</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">x</span><span class="mclose"><span class="mclose">)</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8019em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord">−</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">sin</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">x</span></span></span><span style="top:-3.3196em;"><span class="pstrut" style="height:3.0623em;"></span><span class="mord"><span class="minner"><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord"><span class="mord mathnormal">e</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7144em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">x</span></span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">)</span></span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8918em;"><span style="top:-3.2029em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mord mathnormal">e</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7144em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">x</span></span></span></span></span></span></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mopen">(</span><span class="mop">ln</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">x</span><span class="mclose"><span class="mclose">)</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8019em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord">1/</span><span class="mord mathnormal">x</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7144em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">n</span></span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">)</span></span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8918em;"><span style="top:-3.2029em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord mathnormal">n</span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">n</span><span class="mbin mtight">−</span><span class="mord mtight">1</span></span></span></span></span></span></span></span></span></span></span><span style="top:-1.7954em;"><span class="pstrut" style="height:3.0623em;"></span><span class="mord"><span class="mopen">(</span><span class="mop">arctan</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">x</span><span class="mclose"><span class="mclose">)</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8019em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord">1/</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size1">(</span></span><span class="mord">1</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size1">)</span></span></span></span></span><span style="top:-0.0732em;"><span class="pstrut" style="height:3.0623em;"></span><span class="mord"><span class="mopen">(</span><span class="mop">arcsin</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">x</span><span class="mclose"><span class="mclose">)</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8019em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord">−</span><span class="mopen">(</span><span class="mop">arccos</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">x</span><span class="mclose"><span class="mclose">)</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8019em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord">1/</span><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.0623em;"><span class="svg-align" style="top:-3.2em;"><span class="pstrut" style="height:3.2em;"></span><span class="mord" style="padding-left:1em;"><span class="mord">1</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7401em;"><span style="top:-2.989em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span><span style="top:-3.0223em;"><span class="pstrut" style="height:3.2em;"></span><span class="hide-tail" style="min-width:1.02em;height:1.28em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='1.28em' viewBox='0 0 400000 1296' preserveAspectRatio='xMinYMin slice'><path d='M263,681c0.7,0,18,39.7,52,119
c34,79.3,68.167,158.7,102.5,238c34.3,79.3,51.8,119.3,52.5,120
c340,-704.7,510.7,-1060.3,512,-1067
l0 -0
c4.7,-7.3,11,-11,19,-11
H40000v40H1012.3
s-271.3,567,-271.3,567c-38.7,80.7,-84,175,-136,283c-52,108,-89.167,185.3,-111.5,232
c-22.3,46.7,-33.8,70.3,-34.5,71c-4.7,4.7,-12.3,7,-23,7s-12,-1,-12,-1
s-109,-253,-109,-253c-72.7,-168,-109.3,-252,-110,-252c-10.7,8,-22,16.7,-34,26
c-22,17.3,-33.3,26,-34,26s-26,-26,-26,-26s76,-59,76,-59s76,-60,76,-60z
M1001 80h400000v40h-400000z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.1777em;"><span></span></span></span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:3.6491em;"><span></span></span></span></span></span></span></span></span></span></span></span></p>
</li>
</ol>
<h3 id="_1-13-積分" tabindex="-1">1.13: 積分 <a class="header-anchor" href="#_1-13-積分" aria-label="Permalink to &quot;1.13: 積分&quot;">&ZeroWidthSpace;</a></h3>
<ol start="13">
<li>積分：微分の公式の左辺と右辺を入れ替えたものと同 じ（逆演算）.例えば,<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mo>∫</mo><msup><mi>x</mi><mi>n</mi></msup><mrow><mtext> </mtext><mi mathvariant="normal">d</mi></mrow><mi>x</mi><mo>=</mo><msup><mi>x</mi><mrow><mi>n</mi><mo>+</mo><mn>1</mn></mrow></msup><mi mathvariant="normal">/</mi><mo stretchy="false">(</mo><mi>n</mi><mo>+</mo><mn>1</mn><mo stretchy="false">)</mo><mi mathvariant="normal">.</mi></mrow><annotation encoding="application/x-tex">\int x^n \mathrm{~d} x=x^{n+1} /(n+1) .
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.2222em;vertical-align:-0.8622em;"></span><span class="mop op-symbol large-op" style="margin-right:0.44445em;position:relative;top:-0.0011em;">∫</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7144em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">n</span></span></span></span></span></span></span></span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">d</span></span><span class="mord mathnormal">x</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.1141em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">n</span><span class="mbin mtight">+</span><span class="mord mtight">1</span></span></span></span></span></span></span></span></span><span class="mord">/</span><span class="mopen">(</span><span class="mord mathnormal">n</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">1</span><span class="mclose">)</span><span class="mord">.</span></span></span></span></span></p>
置換積分の特別な場合 :<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mo>∫</mo><mi>f</mi><mo stretchy="false">(</mo><mi>a</mi><mi>x</mi><mo>+</mo><mi>b</mi><mo stretchy="false">)</mo><mi mathvariant="normal">d</mi><mi>x</mi><mo>=</mo><mi>F</mi><mo stretchy="false">(</mo><mi>a</mi><mi>x</mi><mo>+</mo><mi>b</mi><mo stretchy="false">)</mo><mi mathvariant="normal">/</mi><mi>a</mi><mi mathvariant="normal">.</mi></mrow><annotation encoding="application/x-tex">\int f(a x+b) \mathrm{d} x=F(a x+b) / a .
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.2222em;vertical-align:-0.8622em;"></span><span class="mop op-symbol large-op" style="margin-right:0.44445em;position:relative;top:-0.0011em;">∫</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.10764em;">f</span><span class="mopen">(</span><span class="mord mathnormal">a</span><span class="mord mathnormal">x</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal">b</span><span class="mclose">)</span><span class="mord mathrm">d</span><span class="mord mathnormal">x</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.13889em;">F</span><span class="mopen">(</span><span class="mord mathnormal">a</span><span class="mord mathnormal">x</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal">b</span><span class="mclose">)</span><span class="mord">/</span><span class="mord mathnormal">a</span><span class="mord">.</span></span></span></span></span></p>
</li>
</ol>
<h3 id="_1-14-円錐曲線" tabindex="-1">1.14: 円錐曲線 <a class="header-anchor" href="#_1-14-円錐曲線" aria-label="Permalink to &quot;1.14: 円錐曲線&quot;">&ZeroWidthSpace;</a></h3>
<ol start="14">
<li>円錐曲線: <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>a</mi><mn>11</mn></msub><msup><mi>x</mi><mn>2</mn></msup><mo>+</mo><mn>2</mn><msub><mi>a</mi><mn>12</mn></msub><mi>x</mi><mi>y</mi><mo>+</mo><msub><mi>a</mi><mn>22</mn></msub><msup><mi>y</mi><mn>2</mn></msup><mo>+</mo><msub><mi>a</mi><mn>1</mn></msub><mi>x</mi><mo>+</mo><msub><mi>a</mi><mn>2</mn></msub><mi>y</mi><mo>+</mo><msub><mi>a</mi><mn>0</mn></msub><mo>=</mo></mrow><annotation encoding="application/x-tex">a_{11} x^2+2 a_{12} x y+a_{22} y^2+a_1 x+a_2 y+a_0=</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9641em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">11</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.8389em;vertical-align:-0.1944em;"></span><span class="mord">2</span><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">12</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord mathnormal">x</span><span class="mord mathnormal" style="margin-right:0.03588em;">y</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1.0085em;vertical-align:-0.1944em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">22</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">y</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.7333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord mathnormal">x</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.7778em;vertical-align:-0.1944em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord mathnormal" style="margin-right:0.03588em;">y</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">0</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span></span></span></span> 0 で, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>a</mi><mn>11</mn></msub><mo>=</mo><msub><mi>a</mi><mn>22</mn></msub></mrow><annotation encoding="application/x-tex">a_{11}=a_{22}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">11</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">22</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> ならば円, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>a</mi><mn>11</mn></msub><mrow><mo fence="true">(</mo><msub><mi>a</mi><mn>11</mn></msub><msub><mi>a</mi><mn>22</mn></msub><mo>−</mo><msubsup><mi>a</mi><mn>12</mn><mn>2</mn></msubsup><mo fence="true">)</mo></mrow><mo>&gt;</mo><mn>0</mn></mrow><annotation encoding="application/x-tex">a_{11}\left(a_{11} a_{22}-a_{12}^2\right)&gt;0</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2em;vertical-align:-0.35em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">11</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size1">(</span></span><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">11</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">22</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-2.4519em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">12</span></span></span></span><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2481em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size1">)</span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">&gt;</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">0</span></span></span></span> ならば楕円, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋯</mo><mo>&lt;</mo><mn>0</mn></mrow><annotation encoding="application/x-tex">\cdots&lt;0</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="minner">⋯</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">&lt;</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">0</span></span></span></span> ならば双曲線, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>a</mi><mn>11</mn></msub><msub><mi>a</mi><mn>22</mn></msub><mo>−</mo><msubsup><mi>a</mi><mn>12</mn><mn>2</mn></msubsup><mo>=</mo><mn>0</mn></mrow><annotation encoding="application/x-tex">a_{11} a_{22}-a_{12}^2=0</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">11</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">22</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1.0622em;vertical-align:-0.2481em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-2.4519em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">12</span></span></span></span><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2481em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">0</span></span></span></span> ならば放物線. 楕円 : <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>l</mi><mn>1</mn></msub><mo>+</mo><msub><mi>l</mi><mn>2</mn></msub><mo>=</mo><mn>2</mn><mi>a</mi><mo separator="true">,</mo><msub><mi>α</mi><mn>1</mn></msub><mo>=</mo><msub><mi>α</mi><mn>2</mn></msub></mrow><annotation encoding="application/x-tex">l_1+l_2=2 a, \alpha_1=\alpha_2</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8444em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.01968em;">l</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0197em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.8444em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.01968em;">l</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0197em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8389em;vertical-align:-0.1944em;"></span><span class="mord">2</span><span class="mord mathnormal">a</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.0037em;">α</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0037em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.0037em;">α</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0037em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> [訳 者注 : 焦点と曲線上の点を結ぶ直線と接線とのなす角 ], <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>A</mi><mo>=</mo><mi>π</mi><mi>a</mi><mi>b</mi></mrow><annotation encoding="application/x-tex">A=\pi a b</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal">A</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">πab</span></span></span></span>. 双曲線 : <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>l</mi><mn>1</mn></msub><mo>−</mo><msub><mi>l</mi><mn>2</mn></msub><mo>=</mo><mn>2</mn><mi>a</mi><mo separator="true">,</mo><msub><mi>α</mi><mn>1</mn></msub><mo>+</mo><msub><mi>α</mi><mn>2</mn></msub><mo>=</mo><mn>0</mn></mrow><annotation encoding="application/x-tex">l_1-l_2=2 a, \alpha_1+\alpha_2=0</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8444em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.01968em;">l</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0197em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.8444em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.01968em;">l</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0197em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8389em;vertical-align:-0.1944em;"></span><span class="mord">2</span><span class="mord mathnormal">a</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.0037em;">α</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0037em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.0037em;">α</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0037em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">0</span></span></span></span>. 放物線 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>:</mo><mi>l</mi><mo>+</mo><mi>h</mi><mo>=</mo></mrow><annotation encoding="application/x-tex">: l+h=</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mrel">:</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.7778em;vertical-align:-0.0833em;"></span><span class="mord mathnormal" style="margin-right:0.01968em;">l</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">h</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span></span></span></span> const., <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>α</mi><mn>1</mn></msub><mo>=</mo><msub><mi>α</mi><mn>2</mn></msub></mrow><annotation encoding="application/x-tex">\alpha_1=\alpha_2</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.0037em;">α</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0037em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.0037em;">α</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0037em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span>.</li>
</ol>
<h3 id="_1-15-数值計算-台形規則" tabindex="-1">1.15: 数值計算 &amp; 台形規則 <a class="header-anchor" href="#_1-15-数值計算-台形規則" aria-label="Permalink to &quot;1.15: 数值計算 &amp; 台形規則&quot;">&ZeroWidthSpace;</a></h3>
<ol start="15">
<li>数值計算. <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>f</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo><mo>=</mo><mn>0</mn></mrow><annotation encoding="application/x-tex">f(x)=0</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.10764em;">f</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">)</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">0</span></span></span></span> の解を求めるニュートン法 :<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><msub><mi>x</mi><mrow><mi>n</mi><mo>+</mo><mn>1</mn></mrow></msub><mo>=</mo><msub><mi>x</mi><mi>n</mi></msub><mo>−</mo><mi>f</mi><mrow><mo fence="true">(</mo><msub><mi>x</mi><mi>n</mi></msub><mo fence="true">)</mo></mrow><mi mathvariant="normal">/</mi><msup><mi>f</mi><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup><mrow><mo fence="true">(</mo><msub><mi>x</mi><mi>n</mi></msub><mo fence="true">)</mo></mrow></mrow><annotation encoding="application/x-tex">x_{n+1}=x_n-f\left(x_n\right) / f^{\prime}\left(x_n\right)
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6389em;vertical-align:-0.2083em;"></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">n</span><span class="mbin mtight">+</span><span class="mord mtight">1</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2083em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.7333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">n</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1.0519em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.10764em;">f</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">n</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">)</span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord">/</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.10764em;">f</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8019em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">n</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">)</span></span></span></span></span></span></p>
近似積分の台形規則：<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mtable rowspacing="0.16em" columnalign="right" columnspacing="1em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mrow><msubsup><mo>∫</mo><mi>a</mi><mi>b</mi></msubsup><mi>f</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo><mi mathvariant="normal">d</mi><mi>x</mi><mo>≈</mo><mfrac><mrow><mi>b</mi><mo>−</mo><mi>a</mi></mrow><mrow><mn>2</mn><mi>n</mi></mrow></mfrac><mrow><mo fence="true">[</mo><mi>f</mi><mrow><mo fence="true">(</mo><msub><mi>x</mi><mn>0</mn></msub><mo fence="true">)</mo></mrow><mo>+</mo><mn>2</mn><mrow><mo fence="true">{</mo><mi>f</mi><mrow><mo fence="true">(</mo><msub><mi>x</mi><mn>1</mn></msub><mo fence="true">)</mo></mrow><mo>+</mo><mo>⋯</mo><mtext> </mtext></mrow></mrow><mrow><mrow><mo>+</mo><mi>f</mi><mrow><mo fence="true">(</mo><msub><mi>x</mi><mrow><mi>n</mi><mo>−</mo><mn>1</mn></mrow></msub><mo fence="true">)</mo></mrow><mo fence="true">}</mo></mrow><mo>+</mo><mi>f</mi><mrow><mo fence="true">(</mo><msub><mi>x</mi><mi>n</mi></msub><mo fence="true">)</mo></mrow><mo fence="true">]</mo></mrow></mrow></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{array}{r}
\int_a^b f(x) \mathrm{d} x \approx \frac{b-a}{2 n}\left[f\left(x_0\right)+2\left\{f\left(x_1\right)+\cdots\right.\right.
\left.\left.+f\left(x_{n-1}\right)\right\}+f\left(x_n\right)\right]
\end{array}
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.404em;vertical-align:-0.452em;"></span><span class="mord"><span class="mtable"><span class="arraycolsep" style="width:0.5em;"></span><span class="col-align-r"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.952em;"><span style="top:-2.952em;"><span class="pstrut" style="height:3.044em;"></span><span class="mord"><span class="mop"><span class="mop op-symbol small-op" style="margin-right:0.19445em;position:relative;top:-0.0006em;">∫</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.044em;"><span style="top:-2.3442em;margin-left:-0.1945em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">a</span></span></span><span style="top:-3.2579em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">b</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.3558em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.10764em;">f</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">)</span><span class="mord mathrm">d</span><span class="mord mathnormal">x</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≈</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8801em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span><span class="mord mathnormal mtight">n</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">b</span><span class="mbin mtight">−</span><span class="mord mathnormal mtight">a</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">[</span><span class="mord mathnormal" style="margin-right:0.10764em;">f</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">0</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">)</span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord">2</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">{</span><span class="mord mathnormal" style="margin-right:0.10764em;">f</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">)</span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="minner">⋯</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mclose nulldelimiter"></span></span><span class="mclose nulldelimiter"></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen nulldelimiter"></span><span class="minner"><span class="mopen nulldelimiter"></span><span class="mord">+</span><span class="mord mathnormal" style="margin-right:0.10764em;">f</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">n</span><span class="mbin mtight">−</span><span class="mord mtight">1</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2083em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">)</span></span><span class="mclose delimcenter" style="top:0em;">}</span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal" style="margin-right:0.10764em;">f</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">n</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">)</span></span><span class="mclose delimcenter" style="top:0em;">]</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.452em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:0.5em;"></span></span></span></span></span></span></span></p>
</li>
</ol>
<h3 id="_1-16-ベクトルの微分-積分" tabindex="-1">1.16: ベクトルの微分 &amp; 積分 <a class="header-anchor" href="#_1-16-ベクトルの微分-積分" aria-label="Permalink to &quot;1.16: ベクトルの微分 &amp; 積分&quot;">&ZeroWidthSpace;</a></h3>
<ol start="16">
<li>ベクトルの微分と積分：成分ごとに微分/積分する．あるいは無限に近い<span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>2</mn></mrow><annotation encoding="application/x-tex">2</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">2</span></span></span></span>つのベクトルの差を求めることで 微分す.</li>
</ol>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Formulas for IPhO 日本語版: Section 10 ]]></title>
            <link>https://note.toshiki.devacademic/physics/ipho-formulas-jpn/10</link>
            <guid>https://note.toshiki.devacademic/physics/ipho-formulas-jpn/10</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="formulas-for-ipho-日本語版-section-10" tabindex="-1">Formulas for IPhO 日本語版: Section 10 <a class="header-anchor" href="#formulas-for-ipho-日本語版-section-10" aria-label="Permalink to &quot;Formulas for IPhO 日本語版: Section 10&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="_10-熱力学" tabindex="-1">10: 熱力学 <a class="header-anchor" href="#_10-熱力学" aria-label="Permalink to &quot;10: 熱力学&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="_10-1" tabindex="-1">10.1: <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>p</mi><mi>V</mi><mo>=</mo><mfrac><mi>w</mi><mi>M</mi></mfrac><mi>R</mi><mi>T</mi></mrow><annotation encoding="application/x-tex">p V=\frac{w}{M} R T</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8778em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">p</span><span class="mord mathnormal" style="margin-right:0.22222em;">V</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.0404em;vertical-align:-0.345em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6954em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.10903em;">M</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.02691em;">w</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mord mathnormal" style="margin-right:0.13889em;">RT</span></span></span></span> <a class="header-anchor" href="#_10-1" aria-label="Permalink to &quot;10.1: $p V=\frac{w}{M} R T$&quot;">&ZeroWidthSpace;</a></h3>
<ol>
<li><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>p</mi><mi>V</mi><mo>=</mo><mfrac><mi>w</mi><mi>M</mi></mfrac><mi>R</mi><mi>T</mi></mrow><annotation encoding="application/x-tex">p V=\frac{w}{M} R T</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8778em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">p</span><span class="mord mathnormal" style="margin-right:0.22222em;">V</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.0404em;vertical-align:-0.345em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6954em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.10903em;">M</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.02691em;">w</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mord mathnormal" style="margin-right:0.13889em;">RT</span></span></span></span>.</li>
</ol>
<h3 id="_10-2-モルの気体の内部エネルギー" tabindex="-1">10.2: モルの気体の内部エネルギー <a class="header-anchor" href="#_10-2-モルの気体の内部エネルギー" aria-label="Permalink to &quot;10.2: モルの気体の内部エネルギー&quot;">&ZeroWidthSpace;</a></h3>
<ol start="2">
<li>1 モルの気体の内部エネルギー: <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>U</mi><mo>=</mo><mfrac><mi>i</mi><mn>2</mn></mfrac><mi>R</mi><mi>T</mi></mrow><annotation encoding="application/x-tex">U=\frac{i}{2} R T</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.10903em;">U</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.2007em;vertical-align:-0.345em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8557em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">i</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mord mathnormal" style="margin-right:0.13889em;">RT</span></span></span></span> [訳者注: 単 原子分子理想気体 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>i</mi><mo>=</mo><mn>3</mn></mrow><annotation encoding="application/x-tex">i=3</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6595em;"></span><span class="mord mathnormal">i</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">3</span></span></span></span>, 二原子分子理想気体 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>i</mi><mo>=</mo><mn>5</mn><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">i=5]</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6595em;"></span><span class="mord mathnormal">i</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">5</span><span class="mclose">]</span></span></span></span>.</li>
</ol>
<h3 id="_10-3-標準状態" tabindex="-1">10.3: 標準状態 <a class="header-anchor" href="#_10-3-標準状態" aria-label="Permalink to &quot;10.3: 標準状態&quot;">&ZeroWidthSpace;</a></h3>
<ol start="3">
<li>標準状態での 1 モルの気体の体積は <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>22.4</mn><mrow><mtext> </mtext><mi mathvariant="normal">L</mi></mrow></mrow><annotation encoding="application/x-tex">22.4 \mathrm{~L}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">22.4</span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">L</span></span></span></span></span>.</li>
</ol>
<h3 id="_10-4-断熱過程" tabindex="-1">10.4: 断熱過程 <a class="header-anchor" href="#_10-4-断熱過程" aria-label="Permalink to &quot;10.4: 断熱過程&quot;">&ZeroWidthSpace;</a></h3>
<ol start="4">
<li>断熱過程: 音速に比べて遅く, 熱の出入りがない. <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>p</mi><msup><mi>V</mi><mi>γ</mi></msup><mo>=</mo></mrow><annotation encoding="application/x-tex">p V^\gamma=</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8778em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">p</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.22222em;">V</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6644em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.05556em;">γ</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span></span></span></span> const. <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true">(</mo><mi>T</mi><msup><mi>V</mi><mrow><mi>γ</mi><mo>−</mo><mn>1</mn></mrow></msup><mo>=</mo></mrow><annotation encoding="application/x-tex">\left(T V^{\gamma-1}=\right.</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2em;vertical-align:-0.35em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size1">(</span></span><span class="mord mathnormal" style="margin-right:0.13889em;">T</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.22222em;">V</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.05556em;">γ</span><span class="mbin mtight">−</span><span class="mord mtight">1</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mclose nulldelimiter"></span></span></span></span></span> const. <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mclose">)</span></span></span></span>.</li>
</ol>
<h3 id="_10-5-γ-cp-cv-i-2-i" tabindex="-1">10.5: γ=Cp/Cv=(i+2)/i <a class="header-anchor" href="#_10-5-γ-cp-cv-i-2-i" aria-label="Permalink to &quot;10.5: γ=Cp/Cv=(i+2)/i&quot;">&ZeroWidthSpace;</a></h3>
<ol start="5">
<li><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>γ</mi><mo>=</mo><msub><mi>c</mi><mi>p</mi></msub><mi mathvariant="normal">/</mi><msub><mi>c</mi><mi>v</mi></msub><mo>=</mo><mo stretchy="false">(</mo><mi>i</mi><mo>+</mo><mn>2</mn><mo stretchy="false">)</mo><mi mathvariant="normal">/</mi><mi>i</mi></mrow><annotation encoding="application/x-tex">\gamma=c_p / c_v=(i+2) / i</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.05556em;">γ</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.0361em;vertical-align:-0.2861em;"></span><span class="mord"><span class="mord mathnormal">c</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">p</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span><span class="mord">/</span><span class="mord"><span class="mord mathnormal">c</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.03588em;">v</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">(</span><span class="mord mathnormal">i</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">2</span><span class="mclose">)</span><span class="mord">/</span><span class="mord mathnormal">i</span></span></span></span>.</li>
</ol>
<h3 id="_10-6-boltzmann-分布" tabindex="-1">10.6: Boltzmann 分布 <a class="header-anchor" href="#_10-6-boltzmann-分布" aria-label="Permalink to &quot;10.6: Boltzmann 分布&quot;">&ZeroWidthSpace;</a></h3>
<ol start="6">
<li>Boltzmann 分布 :<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mi>ρ</mi><mo>=</mo><msub><mi>ρ</mi><mn>0</mn></msub><msup><mi>e</mi><mrow><mo>−</mo><mi>M</mi><mi>g</mi><mi>h</mi><mi mathvariant="normal">/</mi><mi>R</mi><mi>T</mi></mrow></msup><mo>=</mo><msub><mi>ρ</mi><mn>0</mn></msub><msup><mi>e</mi><mrow><mo>−</mo><mi>U</mi><mi mathvariant="normal">/</mi><msub><mi>k</mi><mi>B</mi></msub><mi>T</mi></mrow></msup></mrow><annotation encoding="application/x-tex">\rho=\rho_0 e^{-M g h / R T}=\rho_0 e^{-U / k_B T}
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">ρ</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.1324em;vertical-align:-0.1944em;"></span><span class="mord"><span class="mord mathnormal">ρ</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">0</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathnormal">e</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.938em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">−</span><span class="mord mathnormal mtight" style="margin-right:0.10903em;">M</span><span class="mord mathnormal mtight" style="margin-right:0.03588em;">g</span><span class="mord mathnormal mtight">h</span><span class="mord mtight">/</span><span class="mord mathnormal mtight" style="margin-right:0.13889em;">RT</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.1324em;vertical-align:-0.1944em;"></span><span class="mord"><span class="mord mathnormal">ρ</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">0</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathnormal">e</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.938em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">−</span><span class="mord mathnormal mtight" style="margin-right:0.10903em;">U</span><span class="mord mtight">/</span><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.03148em;">k</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3448em;"><span style="top:-2.3567em;margin-left:-0.0315em;margin-right:0.0714em;"><span class="pstrut" style="height:2.5em;"></span><span class="sizing reset-size3 size1 mtight"><span class="mord mathnormal mtight" style="margin-right:0.05017em;">B</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.1433em;"><span></span></span></span></span></span></span><span class="mord mathnormal mtight" style="margin-right:0.13889em;">T</span></span></span></span></span></span></span></span></span></span></span></span></span></p>
</li>
</ol>
<h3 id="_10-7-maxwell-分布" tabindex="-1">10.7: Maxwell 分布 <a class="header-anchor" href="#_10-7-maxwell-分布" aria-label="Permalink to &quot;10.7: Maxwell 分布&quot;">&ZeroWidthSpace;</a></h3>
<ol start="7">
<li>Maxwell 分布（v の速さをもつ分子の数）<div class="tip custom-block"><p class="custom-block-title">訳者注</p>
<p>位相空間で <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="bold-italic">v</mi></mrow><annotation encoding="application/x-tex">\boldsymbol{v}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4444em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03704em;">v</span></span></span></span></span></span> と <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="bold-italic">v</mi><mo>+</mo><mi mathvariant="normal">d</mi><mi mathvariant="bold-italic">v</mi></mrow><annotation encoding="application/x-tex">\boldsymbol{v}+\mathrm{d} \boldsymbol{v}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03704em;">v</span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathrm">d</span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03704em;">v</span></span></span></span></span></span> の間にある分子の数の分布 であり，v の速さをもつ分子の数の分布とは異なる] <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∝</mo><msup><mi>e</mi><mrow><mo>−</mo><mi>m</mi><msup><mi mathvariant="bold-italic">v</mi><mn>2</mn></msup><mi mathvariant="normal">/</mi><mn>2</mn><msub><mi>k</mi><mi>B</mi></msub><mi>T</mi></mrow></msup></mrow><annotation encoding="application/x-tex">\propto e^{-m \boldsymbol{v}^2 / 2 k_B T}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mrel">∝</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.9869em;"></span><span class="mord"><span class="mord mathnormal">e</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.9869em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">−</span><span class="mord mathnormal mtight">m</span><span class="mord mtight"><span class="mord mtight"><span class="mord mtight"><span class="mord boldsymbol mtight" style="margin-right:0.03704em;">v</span></span></span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8913em;"><span style="top:-2.931em;margin-right:0.0714em;"><span class="pstrut" style="height:2.5em;"></span><span class="sizing reset-size3 size1 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mord mtight">/2</span><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.03148em;">k</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3448em;"><span style="top:-2.3567em;margin-left:-0.0315em;margin-right:0.0714em;"><span class="pstrut" style="height:2.5em;"></span><span class="sizing reset-size3 size1 mtight"><span class="mord mathnormal mtight" style="margin-right:0.05017em;">B</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.1433em;"><span></span></span></span></span></span></span><span class="mord mathnormal mtight" style="margin-right:0.13889em;">T</span></span></span></span></span></span></span></span></span></span></span></span></p>
</div>
</li>
</ol>
<h3 id="_10-8-大気圧" tabindex="-1">10.8: 大気圧 <a class="header-anchor" href="#_10-8-大気圧" aria-label="Permalink to &quot;10.8: 大気圧&quot;">&ZeroWidthSpace;</a></h3>
<ol start="8">
<li>大気圧 : <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Δ</mi><mi>p</mi><mo>≪</mo><mi>p</mi></mrow><annotation encoding="application/x-tex">\Delta p \ll p</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8778em;vertical-align:-0.1944em;"></span><span class="mord">Δ</span><span class="mord mathnormal">p</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≪</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">p</span></span></span></span> ならば <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Δ</mi><mi>p</mi><mo>=</mo><mi>ρ</mi><mi>g</mi><mi mathvariant="normal">Δ</mi><mi>h</mi></mrow><annotation encoding="application/x-tex">\Delta p=\rho g \Delta h</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8778em;vertical-align:-0.1944em;"></span><span class="mord">Δ</span><span class="mord mathnormal">p</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">ρ</span><span class="mord mathnormal" style="margin-right:0.03588em;">g</span><span class="mord">Δ</span><span class="mord mathnormal">h</span></span></span></span>.</li>
</ol>
<h3 id="_10-9-公式" tabindex="-1">10.9: 公式 <a class="header-anchor" href="#_10-9-公式" aria-label="Permalink to &quot;10.9: 公式&quot;">&ZeroWidthSpace;</a></h3>
<ol start="9">
<li><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>p</mi><mo>=</mo><mfrac><mn>1</mn><mn>3</mn></mfrac><mi>m</mi><mi>n</mi><mover accent="true"><msup><mi>v</mi><mn>2</mn></msup><mo stretchy="true">‾</mo></mover><mo>=</mo><mi>n</mi><msub><mi>k</mi><mi>B</mi></msub><mi>T</mi><mo stretchy="false">(</mo><mi>n</mi></mrow><annotation encoding="application/x-tex">p=\frac{1}{3} m n \overline{v^2}=n k_B T(n</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">p</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.2851em;vertical-align:-0.345em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8451em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">3</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">1</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mord mathnormal">mn</span><span class="mord overline"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.9401em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7401em;"><span style="top:-2.989em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span><span style="top:-3.8601em;"><span class="pstrut" style="height:3em;"></span><span class="overline-line" style="border-bottom-width:0.04em;"></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal">n</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-left:-0.0315em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.05017em;">B</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord mathnormal" style="margin-right:0.13889em;">T</span><span class="mopen">(</span><span class="mord mathnormal">n</span></span></span></span> は数密度 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">)</mo><mo separator="true">,</mo><msqrt><mover accent="true"><mover accent="true"><msup><mi>v</mi><mn>2</mn></msup><mo stretchy="true">‾</mo></mover><mo stretchy="true">‾</mo></mover></msqrt><mo>=</mo></mrow><annotation encoding="application/x-tex">), \sqrt{\overline{\overline{v^2}}}=</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.84em;vertical-align:-0.2849em;"></span><span class="mclose">)</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.5551em;"><span class="svg-align" style="top:-3.8em;"><span class="pstrut" style="height:3.8em;"></span><span class="mord" style="padding-left:1em;"><span class="mord overline"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:1.1401em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord overline"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.9401em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7401em;"><span style="top:-2.989em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span><span style="top:-3.8601em;"><span class="pstrut" style="height:3em;"></span><span class="overline-line" style="border-bottom-width:0.04em;"></span></span></span></span></span></span></span></span><span style="top:-4.0601em;"><span class="pstrut" style="height:3em;"></span><span class="overline-line" style="border-bottom-width:0.04em;"></span></span></span></span></span></span></span></span><span style="top:-3.5151em;"><span class="pstrut" style="height:3.8em;"></span><span class="hide-tail" style="min-width:1.02em;height:1.88em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='1.88em' viewBox='0 0 400000 1944' preserveAspectRatio='xMinYMin slice'><path d='M983 90
l0 -0
c4,-6.7,10,-10,18,-10 H400000v40
H1013.1s-83.4,268,-264.1,840c-180.7,572,-277,876.3,-289,913c-4.7,4.7,-12.7,7,-24,7
s-12,0,-12,0c-1.3,-3.3,-3.7,-11.7,-7,-25c-35.3,-125.3,-106.7,-373.3,-214,-744
c-10,12,-21,25,-33,39s-32,39,-32,39c-6,-5.3,-15,-14,-27,-26s25,-30,25,-30
c26.7,-32.7,52,-63,76,-91s52,-60,52,-60s208,722,208,722
c56,-175.3,126.3,-397.3,211,-666c84.7,-268.7,153.8,-488.2,207.5,-658.5
c53.7,-170.3,84.5,-266.8,92.5,-289.5z
M1001 80h400000v40h-400000z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2849em;"><span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span></span></span></span> <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msqrt><mrow><mn>3</mn><msub><mi>k</mi><mi>B</mi></msub><mi>T</mi><mi mathvariant="normal">/</mi><mi>m</mi></mrow></msqrt><mo separator="true">,</mo><mi>ν</mi><mo>=</mo><mi>v</mi><mi>n</mi><mi>S</mi></mrow><annotation encoding="application/x-tex">\sqrt{3 k_B T / m}, \nu=v n S</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.24em;vertical-align:-0.305em;"></span><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.935em;"><span class="svg-align" style="top:-3.2em;"><span class="pstrut" style="height:3.2em;"></span><span class="mord" style="padding-left:1em;"><span class="mord">3</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-left:-0.0315em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.05017em;">B</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord mathnormal" style="margin-right:0.13889em;">T</span><span class="mord">/</span><span class="mord mathnormal">m</span></span></span><span style="top:-2.895em;"><span class="pstrut" style="height:3.2em;"></span><span class="hide-tail" style="min-width:1.02em;height:1.28em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='1.28em' viewBox='0 0 400000 1296' preserveAspectRatio='xMinYMin slice'><path d='M263,681c0.7,0,18,39.7,52,119
c34,79.3,68.167,158.7,102.5,238c34.3,79.3,51.8,119.3,52.5,120
c340,-704.7,510.7,-1060.3,512,-1067
l0 -0
c4.7,-7.3,11,-11,19,-11
H40000v40H1012.3
s-271.3,567,-271.3,567c-38.7,80.7,-84,175,-136,283c-52,108,-89.167,185.3,-111.5,232
c-22.3,46.7,-33.8,70.3,-34.5,71c-4.7,4.7,-12.3,7,-23,7s-12,-1,-12,-1
s-109,-253,-109,-253c-72.7,-168,-109.3,-252,-110,-252c-10.7,8,-22,16.7,-34,26
c-22,17.3,-33.3,26,-34,26s-26,-26,-26,-26s76,-59,76,-59s76,-60,76,-60z
M1001 80h400000v40h-400000z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.305em;"><span></span></span></span></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.06366em;">ν</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="mord mathnormal">n</span><span class="mord mathnormal" style="margin-right:0.05764em;">S</span></span></span></span>.</li>
</ol>
<h3 id="_10-10-carnot-サイクル" tabindex="-1">10.10: Carnot サイクル <a class="header-anchor" href="#_10-10-carnot-サイクル" aria-label="Permalink to &quot;10.10: Carnot サイクル&quot;">&ZeroWidthSpace;</a></h3>
<ol start="10">
<li>Carnot サイクル : 断熱過程 2 つと等温過程 2 つ. <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>S</mi><mo>−</mo><mi>T</mi></mrow><annotation encoding="application/x-tex">S-T</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7667em;vertical-align:-0.0833em;"></span><span class="mord mathnormal" style="margin-right:0.05764em;">S</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.13889em;">T</span></span></span></span> 座標を用いることにより <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>η</mi><mo>=</mo><mrow><mo fence="true">(</mo><msub><mi>T</mi><mn>1</mn></msub><mo>−</mo><msub><mi>T</mi><mn>2</mn></msub><mo fence="true">)</mo></mrow><mi mathvariant="normal">/</mi><msub><mi>T</mi><mn>1</mn></msub></mrow><annotation encoding="application/x-tex">\eta=\left(T_1-T_2\right) / T_1</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">η</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.13889em;">T</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.1389em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.13889em;">T</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.1389em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">)</span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord">/</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.13889em;">T</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.1389em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> を得る.</li>
</ol>
<h3 id="_10-11-ヒートポンプ" tabindex="-1">10.11: ヒートポンプ <a class="header-anchor" href="#_10-11-ヒートポンプ" aria-label="Permalink to &quot;10.11: ヒートポンプ&quot;">&ZeroWidthSpace;</a></h3>
<ol start="11">
<li>ヒートポンプ: Carnot サイクルの逆. <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>η</mi><mo>=</mo><mfrac><msub><mi>T</mi><mn>1</mn></msub><mrow><msub><mi>T</mi><mn>1</mn></msub><mo>−</mo><msub><mi>T</mi><mn>2</mn></msub></mrow></mfrac></mrow><annotation encoding="application/x-tex">\eta=\frac{T_1}{T_1-T_2}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">η</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.3335em;vertical-align:-0.4451em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8884em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.13889em;">T</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3173em;"><span style="top:-2.357em;margin-left:-0.1389em;margin-right:0.0714em;"><span class="pstrut" style="height:2.5em;"></span><span class="sizing reset-size3 size1 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.143em;"><span></span></span></span></span></span></span><span class="mbin mtight">−</span><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.13889em;">T</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3173em;"><span style="top:-2.357em;margin-left:-0.1389em;margin-right:0.0714em;"><span class="pstrut" style="height:2.5em;"></span><span class="sizing reset-size3 size1 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.143em;"><span></span></span></span></span></span></span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.4101em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.13889em;">T</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3173em;"><span style="top:-2.357em;margin-left:-0.1389em;margin-right:0.0714em;"><span class="pstrut" style="height:2.5em;"></span><span class="sizing reset-size3 size1 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.143em;"><span></span></span></span></span></span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.4451em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span>.</li>
</ol>
<h3 id="_10-12-エントロピー" tabindex="-1">10.12: エントロピー <a class="header-anchor" href="#_10-12-エントロピー" aria-label="Permalink to &quot;10.12: エントロピー&quot;">&ZeroWidthSpace;</a></h3>
<ol start="12">
<li>エントロピー <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>:</mo><mi mathvariant="normal">d</mi><mi>S</mi><mo>=</mo><mi mathvariant="normal">d</mi><mi>Q</mi><mi mathvariant="normal">/</mi><mi>T</mi></mrow><annotation encoding="application/x-tex">: \mathrm{d} S=\mathrm{d} Q / T</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mrel">:</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathrm">d</span><span class="mord mathnormal" style="margin-right:0.05764em;">S</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathrm">d</span><span class="mord mathnormal">Q</span><span class="mord">/</span><span class="mord mathnormal" style="margin-right:0.13889em;">T</span></span></span></span>.</li>
</ol>
<h3 id="_10-13-熱力学第一法則" tabindex="-1">10.13: 熱力学第一法則 <a class="header-anchor" href="#_10-13-熱力学第一法則" aria-label="Permalink to &quot;10.13: 熱力学第一法則&quot;">&ZeroWidthSpace;</a></h3>
<ol start="13">
<li>熱力学第一法則 : <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msup><mi mathvariant="normal">d</mi><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup><mi>U</mi><mo>=</mo><msup><mi mathvariant="normal">d</mi><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup><mi>A</mi><mo>+</mo><msup><mi mathvariant="normal">d</mi><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup><mi>Q</mi></mrow><annotation encoding="application/x-tex">\mathrm{d}^{\prime} U=\mathrm{d}^{\prime} A+\mathrm{d}^{\prime} Q</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7519em;"></span><span class="mord"><span class="mord mathrm">d</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7519em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span><span class="mord mathnormal" style="margin-right:0.10903em;">U</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8352em;vertical-align:-0.0833em;"></span><span class="mord"><span class="mord mathrm">d</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7519em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span><span class="mord mathnormal">A</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.9463em;vertical-align:-0.1944em;"></span><span class="mord"><span class="mord mathrm">d</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7519em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span><span class="mord mathnormal">Q</span></span></span></span></li>
</ol>
<h3 id="_10-14-熱力学第二法則" tabindex="-1">10.14: 熱力学第二法則 <a class="header-anchor" href="#_10-14-熱力学第二法則" aria-label="Permalink to &quot;10.14: 熱力学第二法則&quot;">&ZeroWidthSpace;</a></h3>
<ol start="14">
<li>熱力学第二法則 : <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Δ</mi><mi>S</mi><mo>≥</mo><mn>0</mn></mrow><annotation encoding="application/x-tex">\Delta S \geq 0</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8193em;vertical-align:-0.136em;"></span><span class="mord">Δ</span><span class="mord mathnormal" style="margin-right:0.05764em;">S</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≥</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">0</span></span></span></span> (また <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>η</mi><mtext>real </mtext></msub><mo>≤</mo><msub><mi>η</mi><mtext>Carnot </mtext></msub><mo fence="true">)</mo></mrow><annotation encoding="application/x-tex">\left.\eta_{\text {real }} \leq \eta_{\text {Carnot }}\right)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="minner"><span class="mopen nulldelimiter"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">η</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3361em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord text mtight"><span class="mord mtight">real </span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≤</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">η</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord text mtight"><span class="mord mtight">Carnot </span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">)</span></span></span></span></span>.</li>
</ol>
<h3 id="_10-15-気体のする仕事" tabindex="-1">10.15: 気体のする仕事 <a class="header-anchor" href="#_10-15-気体のする仕事" aria-label="Permalink to &quot;10.15: 気体のする仕事&quot;">&ZeroWidthSpace;</a></h3>
<ol start="15">
<li>気体のする仕事（<a href="./10.html#_10-10-carnot-サイクル">ポイント 10</a> も参照）:<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mi>A</mi><mo>=</mo><mo>∫</mo><mi>p</mi><mrow><mtext> </mtext><mi mathvariant="normal">d</mi></mrow><mi>V</mi><mo separator="true">,</mo><mspace width="1em"/><mtext> 断熱過程: </mtext><mi>A</mi><mo>=</mo><mfrac><mi>i</mi><mn>2</mn></mfrac><mi mathvariant="normal">Δ</mi><mo stretchy="false">(</mo><mi>p</mi><mi>V</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">A=\int p \mathrm{~d} V, \quad \text { 断熱過程: } A=\frac{i}{2} \Delta(p V)
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal">A</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:2.2222em;vertical-align:-0.8622em;"></span><span class="mop op-symbol large-op" style="margin-right:0.44445em;position:relative;top:-0.0011em;">∫</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">p</span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">d</span></span><span class="mord mathnormal" style="margin-right:0.22222em;">V</span><span class="mpunct">,</span><span class="mspace" style="margin-right:1em;"></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord text"><span class="mord"> </span><span class="mord cjk_fallback">断熱過程</span><span class="mord">: </span></span><span class="mord mathnormal">A</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:2.0225em;vertical-align:-0.686em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.3365em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">2</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mord">Δ</span><span class="mopen">(</span><span class="mord mathnormal">p</span><span class="mord mathnormal" style="margin-right:0.22222em;">V</span><span class="mclose">)</span></span></span></span></span></p>
</li>
</ol>
<h3 id="_10-16-dalton-の法則" tabindex="-1">10.16: Dalton の法則 <a class="header-anchor" href="#_10-16-dalton-の法則" aria-label="Permalink to &quot;10.16: Dalton の法則&quot;">&ZeroWidthSpace;</a></h3>
<ol start="16">
<li>
<p>Dalton の法則: <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>p</mi><mo>=</mo></mrow><annotation encoding="application/x-tex">p=</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">p</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span></span></span></span> <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∑</mo><msub><mi>p</mi><mi>i</mi></msub></mrow><annotation encoding="application/x-tex">\sum p_i</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mop op-symbol small-op" style="position:relative;top:0em;">∑</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal">p</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span></p>
<div class="tip custom-block"><p class="custom-block-title">訳者注</p>
<p>理想気体のみ成立</p>
</div>
</li>
</ol>
<h3 id="_10-17-沸騰" tabindex="-1">10.17: 沸騰 <a class="header-anchor" href="#_10-17-沸騰" aria-label="Permalink to &quot;10.17: 沸騰&quot;">&ZeroWidthSpace;</a></h3>
<ol start="17">
<li>沸騰: 飽和蒸気の圧力 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>p</mi><mi>v</mi></msub><mo>=</mo><msub><mi>p</mi><mn>0</mn></msub><mi mathvariant="normal">.</mi><mn>2</mn></mrow><annotation encoding="application/x-tex">p_v=p_0 .2</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord"><span class="mord mathnormal">p</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.03588em;">v</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8389em;vertical-align:-0.1944em;"></span><span class="mord"><span class="mord mathnormal">p</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">0</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord">.2</span></span></span></span> 液の界面では <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>p</mi><mrow><mi>v</mi><mn>1</mn></mrow></msub><mo>+</mo><msub><mi>p</mi><mrow><mi>v</mi><mn>2</mn></mrow></msub><mo>=</mo><msub><mi>p</mi><mn>0</mn></msub></mrow><annotation encoding="application/x-tex">p_{v 1}+p_{v 2}=p_0</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7778em;vertical-align:-0.1944em;"></span><span class="mord"><span class="mord mathnormal">p</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.03588em;">v</span><span class="mord mtight">1</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord"><span class="mord mathnormal">p</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.03588em;">v</span><span class="mord mtight">2</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord"><span class="mord mathnormal">p</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">0</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span>.</li>
</ol>
<h3 id="_10-18-熱流" tabindex="-1">10.18: 熱流 <a class="header-anchor" href="#_10-18-熱流" aria-label="Permalink to &quot;10.18: 熱流&quot;">&ZeroWidthSpace;</a></h3>
<ol start="18">
<li>熱流: <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>P</mi><mo>=</mo><mi>k</mi><mi>S</mi><mi mathvariant="normal">Δ</mi><mi>T</mi><mi mathvariant="normal">/</mi><mi>l</mi></mrow><annotation encoding="application/x-tex">P=k S \Delta T / l</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.13889em;">P</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="mord mathnormal" style="margin-right:0.05764em;">S</span><span class="mord">Δ</span><span class="mord mathnormal" style="margin-right:0.13889em;">T</span><span class="mord">/</span><span class="mord mathnormal" style="margin-right:0.01968em;">l</span></span></span></span> ( <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>k</mi></mrow><annotation encoding="application/x-tex">k</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal" style="margin-right:0.03148em;">k</span></span></span></span> は熱伝導率). 直流回路に似て いる <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">(</mo><mi>P</mi><mo>↔</mo><mi>I</mi><mo separator="true">,</mo><mi mathvariant="normal">Δ</mi><mi>T</mi><mo>↔</mo><mi>V</mi><mo separator="true">,</mo><mi>k</mi><mo>↔</mo><mn>1</mn><mi mathvariant="normal">/</mi><mi>ρ</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">(P \leftrightarrow I, \Delta T \leftrightarrow V, k \leftrightarrow 1 / \rho)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.13889em;">P</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">↔</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8778em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord">Δ</span><span class="mord mathnormal" style="margin-right:0.13889em;">T</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">↔</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.22222em;">V</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">↔</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">1/</span><span class="mord mathnormal">ρ</span><span class="mclose">)</span></span></span></span>.</li>
</ol>
<h3 id="_10-19-熱容量" tabindex="-1">10.19: 熱容量 <a class="header-anchor" href="#_10-19-熱容量" aria-label="Permalink to &quot;10.19: 熱容量&quot;">&ZeroWidthSpace;</a></h3>
<ol start="19">
<li>熱容量 : <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>Q</mi><mo>=</mo><mo>∫</mo><mi>c</mi><mo stretchy="false">(</mo><mi>T</mi><mo stretchy="false">)</mo><mi mathvariant="normal">d</mi><mi>T</mi></mrow><annotation encoding="application/x-tex">Q=\int c(T) \mathrm{d} T</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8778em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">Q</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.1111em;vertical-align:-0.3061em;"></span><span class="mop op-symbol small-op" style="margin-right:0.19445em;position:relative;top:-0.0006em;">∫</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">c</span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.13889em;">T</span><span class="mclose">)</span><span class="mord mathrm">d</span><span class="mord mathnormal" style="margin-right:0.13889em;">T</span></span></span></span>. 固体では低温で <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>c</mi><mo>∝</mo><msup><mi>T</mi><mn>3</mn></msup></mrow><annotation encoding="application/x-tex">c \propto T^3</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">c</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">∝</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8141em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.13889em;">T</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">3</span></span></span></span></span></span></span></span></span></span></span>, 高温で <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>c</mi><mo>=</mo><mn>3</mn><mi>N</mi><msub><mi>k</mi><mi>B</mi></msub></mrow><annotation encoding="application/x-tex">c=3 N k_B</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">c</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8444em;vertical-align:-0.15em;"></span><span class="mord">3</span><span class="mord mathnormal" style="margin-right:0.10903em;">N</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-left:-0.0315em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.05017em;">B</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> （Dulong-Petit の法則. ここで <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>N</mi></mrow><annotation encoding="application/x-tex">N</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.10903em;">N</span></span></span></span> は結晶中の原子数）</li>
</ol>
<h3 id="_10-20-表面張力" tabindex="-1">10.20: 表面張力 <a class="header-anchor" href="#_10-20-表面張力" aria-label="Permalink to &quot;10.20: 表面張力&quot;">&ZeroWidthSpace;</a></h3>
<ol start="20">
<li>表面張力 :<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mi>U</mi><mo>=</mo><mi>S</mi><mi>σ</mi><mo separator="true">,</mo><mi>F</mi><mo>=</mo><mi>l</mi><mi>σ</mi><mo separator="true">,</mo><mi>p</mi><mo>=</mo><mn>2</mn><mi>σ</mi><mi mathvariant="normal">/</mi><mi>R</mi></mrow><annotation encoding="application/x-tex">U=S \sigma, F=l \sigma, p=2 \sigma / R
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.10903em;">U</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8778em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.05764em;">S</span><span class="mord mathnormal" style="margin-right:0.03588em;">σ</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.13889em;">F</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.01968em;">l</span><span class="mord mathnormal" style="margin-right:0.03588em;">σ</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">p</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">2</span><span class="mord mathnormal" style="margin-right:0.03588em;">σ</span><span class="mord">/</span><span class="mord mathnormal" style="margin-right:0.00773em;">R</span></span></span></span></span></p>
</li>
</ol>
<h3 id="_10-21-stefan-boltzmann-の法則-灰色体" tabindex="-1">10.21: Stefan-Boltzmann の法則 (灰色体) <a class="header-anchor" href="#_10-21-stefan-boltzmann-の法則-灰色体" aria-label="Permalink to &quot;10.21: Stefan-Boltzmann の法則 (灰色体)&quot;">&ZeroWidthSpace;</a></h3>
<ol start="21">
<li>Stefan-Boltzmann の法則 (灰色体) : <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>P</mi><mo>=</mo><mi>ε</mi><mi>σ</mi><mi>A</mi><msup><mi>T</mi><mn>4</mn></msup></mrow><annotation encoding="application/x-tex">P=\varepsilon \sigma A T^4</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.13889em;">P</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8141em;"></span><span class="mord mathnormal">ε</span><span class="mord mathnormal" style="margin-right:0.03588em;">σ</span><span class="mord mathnormal">A</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.13889em;">T</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">4</span></span></span></span></span></span></span></span></span></span></span>.</li>
</ol>
<h3 id="_10-22-wien-の変位則" tabindex="-1">10.22: Wien の変位則 <a class="header-anchor" href="#_10-22-wien-の変位則" aria-label="Permalink to &quot;10.22: Wien の変位則&quot;">&ZeroWidthSpace;</a></h3>
<ol start="22">
<li>Wien の変位則: <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>ν</mi><mi>max</mi><mo>⁡</mo></msub><mo>=</mo><mi>A</mi><msub><mi>k</mi><mi>B</mi></msub><mi>T</mi><mi mathvariant="normal">/</mi><mi>h</mi><mo stretchy="false">(</mo><mi>A</mi><mo>≈</mo></mrow><annotation encoding="application/x-tex">\nu_{\max }=A k_B T / h(A \approx</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.06366em;">ν</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:-0.0637em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mop mtight"><span class="mtight">m</span><span class="mtight">a</span><span class="mtight">x</span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal">A</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-left:-0.0315em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.05017em;">B</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord mathnormal" style="margin-right:0.13889em;">T</span><span class="mord">/</span><span class="mord mathnormal">h</span><span class="mopen">(</span><span class="mord mathnormal">A</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≈</span></span></span></span> 2.8), <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>λ</mi><mi>max</mi><mo>⁡</mo></msub><mo>=</mo><mi>h</mi><mi>c</mi><mi mathvariant="normal">/</mi><msup><mi>A</mi><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup><msub><mi>k</mi><mi>B</mi></msub><mi>T</mi><mrow><mo fence="true">(</mo><msup><mi>A</mi><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup><mo>≈</mo><mn>5</mn><mo fence="true">)</mo></mrow></mrow><annotation encoding="application/x-tex">\lambda_{\max }=h c / A^{\prime} k_B T\left(A^{\prime} \approx 5\right)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8444em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal">λ</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mop mtight"><span class="mtight">m</span><span class="mtight">a</span><span class="mtight">x</span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.0019em;vertical-align:-0.25em;"></span><span class="mord mathnormal">h</span><span class="mord mathnormal">c</span><span class="mord">/</span><span class="mord"><span class="mord mathnormal">A</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7519em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-left:-0.0315em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.05017em;">B</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord mathnormal" style="margin-right:0.13889em;">T</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord"><span class="mord mathnormal">A</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7519em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≈</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord">5</span><span class="mclose delimcenter" style="top:0em;">)</span></span></span></span></span>.</li>
</ol>
]]></description>
            <content:encoded><![CDATA[<h1 id="formulas-for-ipho-日本語版-section-10" tabindex="-1">Formulas for IPhO 日本語版: Section 10 <a class="header-anchor" href="#formulas-for-ipho-日本語版-section-10" aria-label="Permalink to &quot;Formulas for IPhO 日本語版: Section 10&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="_10-熱力学" tabindex="-1">10: 熱力学 <a class="header-anchor" href="#_10-熱力学" aria-label="Permalink to &quot;10: 熱力学&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="_10-1" tabindex="-1">10.1: <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>p</mi><mi>V</mi><mo>=</mo><mfrac><mi>w</mi><mi>M</mi></mfrac><mi>R</mi><mi>T</mi></mrow><annotation encoding="application/x-tex">p V=\frac{w}{M} R T</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8778em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">p</span><span class="mord mathnormal" style="margin-right:0.22222em;">V</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.0404em;vertical-align:-0.345em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6954em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.10903em;">M</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.02691em;">w</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mord mathnormal" style="margin-right:0.13889em;">RT</span></span></span></span> <a class="header-anchor" href="#_10-1" aria-label="Permalink to &quot;10.1: $p V=\frac{w}{M} R T$&quot;">&ZeroWidthSpace;</a></h3>
<ol>
<li><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>p</mi><mi>V</mi><mo>=</mo><mfrac><mi>w</mi><mi>M</mi></mfrac><mi>R</mi><mi>T</mi></mrow><annotation encoding="application/x-tex">p V=\frac{w}{M} R T</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8778em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">p</span><span class="mord mathnormal" style="margin-right:0.22222em;">V</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.0404em;vertical-align:-0.345em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6954em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.10903em;">M</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.02691em;">w</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mord mathnormal" style="margin-right:0.13889em;">RT</span></span></span></span>.</li>
</ol>
<h3 id="_10-2-モルの気体の内部エネルギー" tabindex="-1">10.2: モルの気体の内部エネルギー <a class="header-anchor" href="#_10-2-モルの気体の内部エネルギー" aria-label="Permalink to &quot;10.2: モルの気体の内部エネルギー&quot;">&ZeroWidthSpace;</a></h3>
<ol start="2">
<li>1 モルの気体の内部エネルギー: <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>U</mi><mo>=</mo><mfrac><mi>i</mi><mn>2</mn></mfrac><mi>R</mi><mi>T</mi></mrow><annotation encoding="application/x-tex">U=\frac{i}{2} R T</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.10903em;">U</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.2007em;vertical-align:-0.345em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8557em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">i</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mord mathnormal" style="margin-right:0.13889em;">RT</span></span></span></span> [訳者注: 単 原子分子理想気体 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>i</mi><mo>=</mo><mn>3</mn></mrow><annotation encoding="application/x-tex">i=3</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6595em;"></span><span class="mord mathnormal">i</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">3</span></span></span></span>, 二原子分子理想気体 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>i</mi><mo>=</mo><mn>5</mn><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">i=5]</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6595em;"></span><span class="mord mathnormal">i</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">5</span><span class="mclose">]</span></span></span></span>.</li>
</ol>
<h3 id="_10-3-標準状態" tabindex="-1">10.3: 標準状態 <a class="header-anchor" href="#_10-3-標準状態" aria-label="Permalink to &quot;10.3: 標準状態&quot;">&ZeroWidthSpace;</a></h3>
<ol start="3">
<li>標準状態での 1 モルの気体の体積は <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>22.4</mn><mrow><mtext> </mtext><mi mathvariant="normal">L</mi></mrow></mrow><annotation encoding="application/x-tex">22.4 \mathrm{~L}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">22.4</span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">L</span></span></span></span></span>.</li>
</ol>
<h3 id="_10-4-断熱過程" tabindex="-1">10.4: 断熱過程 <a class="header-anchor" href="#_10-4-断熱過程" aria-label="Permalink to &quot;10.4: 断熱過程&quot;">&ZeroWidthSpace;</a></h3>
<ol start="4">
<li>断熱過程: 音速に比べて遅く, 熱の出入りがない. <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>p</mi><msup><mi>V</mi><mi>γ</mi></msup><mo>=</mo></mrow><annotation encoding="application/x-tex">p V^\gamma=</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8778em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">p</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.22222em;">V</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6644em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.05556em;">γ</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span></span></span></span> const. <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true">(</mo><mi>T</mi><msup><mi>V</mi><mrow><mi>γ</mi><mo>−</mo><mn>1</mn></mrow></msup><mo>=</mo></mrow><annotation encoding="application/x-tex">\left(T V^{\gamma-1}=\right.</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2em;vertical-align:-0.35em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size1">(</span></span><span class="mord mathnormal" style="margin-right:0.13889em;">T</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.22222em;">V</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.05556em;">γ</span><span class="mbin mtight">−</span><span class="mord mtight">1</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mclose nulldelimiter"></span></span></span></span></span> const. <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mclose">)</span></span></span></span>.</li>
</ol>
<h3 id="_10-5-γ-cp-cv-i-2-i" tabindex="-1">10.5: γ=Cp/Cv=(i+2)/i <a class="header-anchor" href="#_10-5-γ-cp-cv-i-2-i" aria-label="Permalink to &quot;10.5: γ=Cp/Cv=(i+2)/i&quot;">&ZeroWidthSpace;</a></h3>
<ol start="5">
<li><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>γ</mi><mo>=</mo><msub><mi>c</mi><mi>p</mi></msub><mi mathvariant="normal">/</mi><msub><mi>c</mi><mi>v</mi></msub><mo>=</mo><mo stretchy="false">(</mo><mi>i</mi><mo>+</mo><mn>2</mn><mo stretchy="false">)</mo><mi mathvariant="normal">/</mi><mi>i</mi></mrow><annotation encoding="application/x-tex">\gamma=c_p / c_v=(i+2) / i</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.05556em;">γ</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.0361em;vertical-align:-0.2861em;"></span><span class="mord"><span class="mord mathnormal">c</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">p</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span><span class="mord">/</span><span class="mord"><span class="mord mathnormal">c</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.03588em;">v</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">(</span><span class="mord mathnormal">i</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">2</span><span class="mclose">)</span><span class="mord">/</span><span class="mord mathnormal">i</span></span></span></span>.</li>
</ol>
<h3 id="_10-6-boltzmann-分布" tabindex="-1">10.6: Boltzmann 分布 <a class="header-anchor" href="#_10-6-boltzmann-分布" aria-label="Permalink to &quot;10.6: Boltzmann 分布&quot;">&ZeroWidthSpace;</a></h3>
<ol start="6">
<li>Boltzmann 分布 :<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mi>ρ</mi><mo>=</mo><msub><mi>ρ</mi><mn>0</mn></msub><msup><mi>e</mi><mrow><mo>−</mo><mi>M</mi><mi>g</mi><mi>h</mi><mi mathvariant="normal">/</mi><mi>R</mi><mi>T</mi></mrow></msup><mo>=</mo><msub><mi>ρ</mi><mn>0</mn></msub><msup><mi>e</mi><mrow><mo>−</mo><mi>U</mi><mi mathvariant="normal">/</mi><msub><mi>k</mi><mi>B</mi></msub><mi>T</mi></mrow></msup></mrow><annotation encoding="application/x-tex">\rho=\rho_0 e^{-M g h / R T}=\rho_0 e^{-U / k_B T}
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">ρ</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.1324em;vertical-align:-0.1944em;"></span><span class="mord"><span class="mord mathnormal">ρ</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">0</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathnormal">e</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.938em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">−</span><span class="mord mathnormal mtight" style="margin-right:0.10903em;">M</span><span class="mord mathnormal mtight" style="margin-right:0.03588em;">g</span><span class="mord mathnormal mtight">h</span><span class="mord mtight">/</span><span class="mord mathnormal mtight" style="margin-right:0.13889em;">RT</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.1324em;vertical-align:-0.1944em;"></span><span class="mord"><span class="mord mathnormal">ρ</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">0</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathnormal">e</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.938em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">−</span><span class="mord mathnormal mtight" style="margin-right:0.10903em;">U</span><span class="mord mtight">/</span><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.03148em;">k</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3448em;"><span style="top:-2.3567em;margin-left:-0.0315em;margin-right:0.0714em;"><span class="pstrut" style="height:2.5em;"></span><span class="sizing reset-size3 size1 mtight"><span class="mord mathnormal mtight" style="margin-right:0.05017em;">B</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.1433em;"><span></span></span></span></span></span></span><span class="mord mathnormal mtight" style="margin-right:0.13889em;">T</span></span></span></span></span></span></span></span></span></span></span></span></span></p>
</li>
</ol>
<h3 id="_10-7-maxwell-分布" tabindex="-1">10.7: Maxwell 分布 <a class="header-anchor" href="#_10-7-maxwell-分布" aria-label="Permalink to &quot;10.7: Maxwell 分布&quot;">&ZeroWidthSpace;</a></h3>
<ol start="7">
<li>Maxwell 分布（v の速さをもつ分子の数）<div class="tip custom-block"><p class="custom-block-title">訳者注</p>
<p>位相空間で <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="bold-italic">v</mi></mrow><annotation encoding="application/x-tex">\boldsymbol{v}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4444em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03704em;">v</span></span></span></span></span></span> と <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="bold-italic">v</mi><mo>+</mo><mi mathvariant="normal">d</mi><mi mathvariant="bold-italic">v</mi></mrow><annotation encoding="application/x-tex">\boldsymbol{v}+\mathrm{d} \boldsymbol{v}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03704em;">v</span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathrm">d</span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03704em;">v</span></span></span></span></span></span> の間にある分子の数の分布 であり，v の速さをもつ分子の数の分布とは異なる] <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∝</mo><msup><mi>e</mi><mrow><mo>−</mo><mi>m</mi><msup><mi mathvariant="bold-italic">v</mi><mn>2</mn></msup><mi mathvariant="normal">/</mi><mn>2</mn><msub><mi>k</mi><mi>B</mi></msub><mi>T</mi></mrow></msup></mrow><annotation encoding="application/x-tex">\propto e^{-m \boldsymbol{v}^2 / 2 k_B T}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mrel">∝</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.9869em;"></span><span class="mord"><span class="mord mathnormal">e</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.9869em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">−</span><span class="mord mathnormal mtight">m</span><span class="mord mtight"><span class="mord mtight"><span class="mord mtight"><span class="mord boldsymbol mtight" style="margin-right:0.03704em;">v</span></span></span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8913em;"><span style="top:-2.931em;margin-right:0.0714em;"><span class="pstrut" style="height:2.5em;"></span><span class="sizing reset-size3 size1 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mord mtight">/2</span><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.03148em;">k</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3448em;"><span style="top:-2.3567em;margin-left:-0.0315em;margin-right:0.0714em;"><span class="pstrut" style="height:2.5em;"></span><span class="sizing reset-size3 size1 mtight"><span class="mord mathnormal mtight" style="margin-right:0.05017em;">B</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.1433em;"><span></span></span></span></span></span></span><span class="mord mathnormal mtight" style="margin-right:0.13889em;">T</span></span></span></span></span></span></span></span></span></span></span></span></p>
</div>
</li>
</ol>
<h3 id="_10-8-大気圧" tabindex="-1">10.8: 大気圧 <a class="header-anchor" href="#_10-8-大気圧" aria-label="Permalink to &quot;10.8: 大気圧&quot;">&ZeroWidthSpace;</a></h3>
<ol start="8">
<li>大気圧 : <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Δ</mi><mi>p</mi><mo>≪</mo><mi>p</mi></mrow><annotation encoding="application/x-tex">\Delta p \ll p</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8778em;vertical-align:-0.1944em;"></span><span class="mord">Δ</span><span class="mord mathnormal">p</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≪</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">p</span></span></span></span> ならば <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Δ</mi><mi>p</mi><mo>=</mo><mi>ρ</mi><mi>g</mi><mi mathvariant="normal">Δ</mi><mi>h</mi></mrow><annotation encoding="application/x-tex">\Delta p=\rho g \Delta h</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8778em;vertical-align:-0.1944em;"></span><span class="mord">Δ</span><span class="mord mathnormal">p</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">ρ</span><span class="mord mathnormal" style="margin-right:0.03588em;">g</span><span class="mord">Δ</span><span class="mord mathnormal">h</span></span></span></span>.</li>
</ol>
<h3 id="_10-9-公式" tabindex="-1">10.9: 公式 <a class="header-anchor" href="#_10-9-公式" aria-label="Permalink to &quot;10.9: 公式&quot;">&ZeroWidthSpace;</a></h3>
<ol start="9">
<li><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>p</mi><mo>=</mo><mfrac><mn>1</mn><mn>3</mn></mfrac><mi>m</mi><mi>n</mi><mover accent="true"><msup><mi>v</mi><mn>2</mn></msup><mo stretchy="true">‾</mo></mover><mo>=</mo><mi>n</mi><msub><mi>k</mi><mi>B</mi></msub><mi>T</mi><mo stretchy="false">(</mo><mi>n</mi></mrow><annotation encoding="application/x-tex">p=\frac{1}{3} m n \overline{v^2}=n k_B T(n</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">p</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.2851em;vertical-align:-0.345em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8451em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">3</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">1</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mord mathnormal">mn</span><span class="mord overline"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.9401em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7401em;"><span style="top:-2.989em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span><span style="top:-3.8601em;"><span class="pstrut" style="height:3em;"></span><span class="overline-line" style="border-bottom-width:0.04em;"></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal">n</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-left:-0.0315em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.05017em;">B</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord mathnormal" style="margin-right:0.13889em;">T</span><span class="mopen">(</span><span class="mord mathnormal">n</span></span></span></span> は数密度 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">)</mo><mo separator="true">,</mo><msqrt><mover accent="true"><mover accent="true"><msup><mi>v</mi><mn>2</mn></msup><mo stretchy="true">‾</mo></mover><mo stretchy="true">‾</mo></mover></msqrt><mo>=</mo></mrow><annotation encoding="application/x-tex">), \sqrt{\overline{\overline{v^2}}}=</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.84em;vertical-align:-0.2849em;"></span><span class="mclose">)</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.5551em;"><span class="svg-align" style="top:-3.8em;"><span class="pstrut" style="height:3.8em;"></span><span class="mord" style="padding-left:1em;"><span class="mord overline"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:1.1401em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord overline"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.9401em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7401em;"><span style="top:-2.989em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span><span style="top:-3.8601em;"><span class="pstrut" style="height:3em;"></span><span class="overline-line" style="border-bottom-width:0.04em;"></span></span></span></span></span></span></span></span><span style="top:-4.0601em;"><span class="pstrut" style="height:3em;"></span><span class="overline-line" style="border-bottom-width:0.04em;"></span></span></span></span></span></span></span></span><span style="top:-3.5151em;"><span class="pstrut" style="height:3.8em;"></span><span class="hide-tail" style="min-width:1.02em;height:1.88em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='1.88em' viewBox='0 0 400000 1944' preserveAspectRatio='xMinYMin slice'><path d='M983 90
l0 -0
c4,-6.7,10,-10,18,-10 H400000v40
H1013.1s-83.4,268,-264.1,840c-180.7,572,-277,876.3,-289,913c-4.7,4.7,-12.7,7,-24,7
s-12,0,-12,0c-1.3,-3.3,-3.7,-11.7,-7,-25c-35.3,-125.3,-106.7,-373.3,-214,-744
c-10,12,-21,25,-33,39s-32,39,-32,39c-6,-5.3,-15,-14,-27,-26s25,-30,25,-30
c26.7,-32.7,52,-63,76,-91s52,-60,52,-60s208,722,208,722
c56,-175.3,126.3,-397.3,211,-666c84.7,-268.7,153.8,-488.2,207.5,-658.5
c53.7,-170.3,84.5,-266.8,92.5,-289.5z
M1001 80h400000v40h-400000z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2849em;"><span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span></span></span></span> <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msqrt><mrow><mn>3</mn><msub><mi>k</mi><mi>B</mi></msub><mi>T</mi><mi mathvariant="normal">/</mi><mi>m</mi></mrow></msqrt><mo separator="true">,</mo><mi>ν</mi><mo>=</mo><mi>v</mi><mi>n</mi><mi>S</mi></mrow><annotation encoding="application/x-tex">\sqrt{3 k_B T / m}, \nu=v n S</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.24em;vertical-align:-0.305em;"></span><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.935em;"><span class="svg-align" style="top:-3.2em;"><span class="pstrut" style="height:3.2em;"></span><span class="mord" style="padding-left:1em;"><span class="mord">3</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-left:-0.0315em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.05017em;">B</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord mathnormal" style="margin-right:0.13889em;">T</span><span class="mord">/</span><span class="mord mathnormal">m</span></span></span><span style="top:-2.895em;"><span class="pstrut" style="height:3.2em;"></span><span class="hide-tail" style="min-width:1.02em;height:1.28em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='1.28em' viewBox='0 0 400000 1296' preserveAspectRatio='xMinYMin slice'><path d='M263,681c0.7,0,18,39.7,52,119
c34,79.3,68.167,158.7,102.5,238c34.3,79.3,51.8,119.3,52.5,120
c340,-704.7,510.7,-1060.3,512,-1067
l0 -0
c4.7,-7.3,11,-11,19,-11
H40000v40H1012.3
s-271.3,567,-271.3,567c-38.7,80.7,-84,175,-136,283c-52,108,-89.167,185.3,-111.5,232
c-22.3,46.7,-33.8,70.3,-34.5,71c-4.7,4.7,-12.3,7,-23,7s-12,-1,-12,-1
s-109,-253,-109,-253c-72.7,-168,-109.3,-252,-110,-252c-10.7,8,-22,16.7,-34,26
c-22,17.3,-33.3,26,-34,26s-26,-26,-26,-26s76,-59,76,-59s76,-60,76,-60z
M1001 80h400000v40h-400000z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.305em;"><span></span></span></span></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.06366em;">ν</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="mord mathnormal">n</span><span class="mord mathnormal" style="margin-right:0.05764em;">S</span></span></span></span>.</li>
</ol>
<h3 id="_10-10-carnot-サイクル" tabindex="-1">10.10: Carnot サイクル <a class="header-anchor" href="#_10-10-carnot-サイクル" aria-label="Permalink to &quot;10.10: Carnot サイクル&quot;">&ZeroWidthSpace;</a></h3>
<ol start="10">
<li>Carnot サイクル : 断熱過程 2 つと等温過程 2 つ. <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>S</mi><mo>−</mo><mi>T</mi></mrow><annotation encoding="application/x-tex">S-T</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7667em;vertical-align:-0.0833em;"></span><span class="mord mathnormal" style="margin-right:0.05764em;">S</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.13889em;">T</span></span></span></span> 座標を用いることにより <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>η</mi><mo>=</mo><mrow><mo fence="true">(</mo><msub><mi>T</mi><mn>1</mn></msub><mo>−</mo><msub><mi>T</mi><mn>2</mn></msub><mo fence="true">)</mo></mrow><mi mathvariant="normal">/</mi><msub><mi>T</mi><mn>1</mn></msub></mrow><annotation encoding="application/x-tex">\eta=\left(T_1-T_2\right) / T_1</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">η</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.13889em;">T</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.1389em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.13889em;">T</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.1389em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">)</span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord">/</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.13889em;">T</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.1389em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> を得る.</li>
</ol>
<h3 id="_10-11-ヒートポンプ" tabindex="-1">10.11: ヒートポンプ <a class="header-anchor" href="#_10-11-ヒートポンプ" aria-label="Permalink to &quot;10.11: ヒートポンプ&quot;">&ZeroWidthSpace;</a></h3>
<ol start="11">
<li>ヒートポンプ: Carnot サイクルの逆. <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>η</mi><mo>=</mo><mfrac><msub><mi>T</mi><mn>1</mn></msub><mrow><msub><mi>T</mi><mn>1</mn></msub><mo>−</mo><msub><mi>T</mi><mn>2</mn></msub></mrow></mfrac></mrow><annotation encoding="application/x-tex">\eta=\frac{T_1}{T_1-T_2}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">η</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.3335em;vertical-align:-0.4451em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8884em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.13889em;">T</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3173em;"><span style="top:-2.357em;margin-left:-0.1389em;margin-right:0.0714em;"><span class="pstrut" style="height:2.5em;"></span><span class="sizing reset-size3 size1 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.143em;"><span></span></span></span></span></span></span><span class="mbin mtight">−</span><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.13889em;">T</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3173em;"><span style="top:-2.357em;margin-left:-0.1389em;margin-right:0.0714em;"><span class="pstrut" style="height:2.5em;"></span><span class="sizing reset-size3 size1 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.143em;"><span></span></span></span></span></span></span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.4101em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.13889em;">T</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3173em;"><span style="top:-2.357em;margin-left:-0.1389em;margin-right:0.0714em;"><span class="pstrut" style="height:2.5em;"></span><span class="sizing reset-size3 size1 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.143em;"><span></span></span></span></span></span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.4451em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span>.</li>
</ol>
<h3 id="_10-12-エントロピー" tabindex="-1">10.12: エントロピー <a class="header-anchor" href="#_10-12-エントロピー" aria-label="Permalink to &quot;10.12: エントロピー&quot;">&ZeroWidthSpace;</a></h3>
<ol start="12">
<li>エントロピー <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>:</mo><mi mathvariant="normal">d</mi><mi>S</mi><mo>=</mo><mi mathvariant="normal">d</mi><mi>Q</mi><mi mathvariant="normal">/</mi><mi>T</mi></mrow><annotation encoding="application/x-tex">: \mathrm{d} S=\mathrm{d} Q / T</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mrel">:</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathrm">d</span><span class="mord mathnormal" style="margin-right:0.05764em;">S</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathrm">d</span><span class="mord mathnormal">Q</span><span class="mord">/</span><span class="mord mathnormal" style="margin-right:0.13889em;">T</span></span></span></span>.</li>
</ol>
<h3 id="_10-13-熱力学第一法則" tabindex="-1">10.13: 熱力学第一法則 <a class="header-anchor" href="#_10-13-熱力学第一法則" aria-label="Permalink to &quot;10.13: 熱力学第一法則&quot;">&ZeroWidthSpace;</a></h3>
<ol start="13">
<li>熱力学第一法則 : <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msup><mi mathvariant="normal">d</mi><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup><mi>U</mi><mo>=</mo><msup><mi mathvariant="normal">d</mi><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup><mi>A</mi><mo>+</mo><msup><mi mathvariant="normal">d</mi><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup><mi>Q</mi></mrow><annotation encoding="application/x-tex">\mathrm{d}^{\prime} U=\mathrm{d}^{\prime} A+\mathrm{d}^{\prime} Q</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7519em;"></span><span class="mord"><span class="mord mathrm">d</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7519em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span><span class="mord mathnormal" style="margin-right:0.10903em;">U</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8352em;vertical-align:-0.0833em;"></span><span class="mord"><span class="mord mathrm">d</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7519em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span><span class="mord mathnormal">A</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.9463em;vertical-align:-0.1944em;"></span><span class="mord"><span class="mord mathrm">d</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7519em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span><span class="mord mathnormal">Q</span></span></span></span></li>
</ol>
<h3 id="_10-14-熱力学第二法則" tabindex="-1">10.14: 熱力学第二法則 <a class="header-anchor" href="#_10-14-熱力学第二法則" aria-label="Permalink to &quot;10.14: 熱力学第二法則&quot;">&ZeroWidthSpace;</a></h3>
<ol start="14">
<li>熱力学第二法則 : <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Δ</mi><mi>S</mi><mo>≥</mo><mn>0</mn></mrow><annotation encoding="application/x-tex">\Delta S \geq 0</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8193em;vertical-align:-0.136em;"></span><span class="mord">Δ</span><span class="mord mathnormal" style="margin-right:0.05764em;">S</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≥</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">0</span></span></span></span> (また <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>η</mi><mtext>real </mtext></msub><mo>≤</mo><msub><mi>η</mi><mtext>Carnot </mtext></msub><mo fence="true">)</mo></mrow><annotation encoding="application/x-tex">\left.\eta_{\text {real }} \leq \eta_{\text {Carnot }}\right)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="minner"><span class="mopen nulldelimiter"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">η</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3361em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord text mtight"><span class="mord mtight">real </span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≤</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">η</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord text mtight"><span class="mord mtight">Carnot </span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">)</span></span></span></span></span>.</li>
</ol>
<h3 id="_10-15-気体のする仕事" tabindex="-1">10.15: 気体のする仕事 <a class="header-anchor" href="#_10-15-気体のする仕事" aria-label="Permalink to &quot;10.15: 気体のする仕事&quot;">&ZeroWidthSpace;</a></h3>
<ol start="15">
<li>気体のする仕事（<a href="./10.html#_10-10-carnot-サイクル">ポイント 10</a> も参照）:<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mi>A</mi><mo>=</mo><mo>∫</mo><mi>p</mi><mrow><mtext> </mtext><mi mathvariant="normal">d</mi></mrow><mi>V</mi><mo separator="true">,</mo><mspace width="1em"/><mtext> 断熱過程: </mtext><mi>A</mi><mo>=</mo><mfrac><mi>i</mi><mn>2</mn></mfrac><mi mathvariant="normal">Δ</mi><mo stretchy="false">(</mo><mi>p</mi><mi>V</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">A=\int p \mathrm{~d} V, \quad \text { 断熱過程: } A=\frac{i}{2} \Delta(p V)
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal">A</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:2.2222em;vertical-align:-0.8622em;"></span><span class="mop op-symbol large-op" style="margin-right:0.44445em;position:relative;top:-0.0011em;">∫</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">p</span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">d</span></span><span class="mord mathnormal" style="margin-right:0.22222em;">V</span><span class="mpunct">,</span><span class="mspace" style="margin-right:1em;"></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord text"><span class="mord"> </span><span class="mord cjk_fallback">断熱過程</span><span class="mord">: </span></span><span class="mord mathnormal">A</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:2.0225em;vertical-align:-0.686em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.3365em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">2</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mord">Δ</span><span class="mopen">(</span><span class="mord mathnormal">p</span><span class="mord mathnormal" style="margin-right:0.22222em;">V</span><span class="mclose">)</span></span></span></span></span></p>
</li>
</ol>
<h3 id="_10-16-dalton-の法則" tabindex="-1">10.16: Dalton の法則 <a class="header-anchor" href="#_10-16-dalton-の法則" aria-label="Permalink to &quot;10.16: Dalton の法則&quot;">&ZeroWidthSpace;</a></h3>
<ol start="16">
<li>
<p>Dalton の法則: <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>p</mi><mo>=</mo></mrow><annotation encoding="application/x-tex">p=</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">p</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span></span></span></span> <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∑</mo><msub><mi>p</mi><mi>i</mi></msub></mrow><annotation encoding="application/x-tex">\sum p_i</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mop op-symbol small-op" style="position:relative;top:0em;">∑</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal">p</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span></p>
<div class="tip custom-block"><p class="custom-block-title">訳者注</p>
<p>理想気体のみ成立</p>
</div>
</li>
</ol>
<h3 id="_10-17-沸騰" tabindex="-1">10.17: 沸騰 <a class="header-anchor" href="#_10-17-沸騰" aria-label="Permalink to &quot;10.17: 沸騰&quot;">&ZeroWidthSpace;</a></h3>
<ol start="17">
<li>沸騰: 飽和蒸気の圧力 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>p</mi><mi>v</mi></msub><mo>=</mo><msub><mi>p</mi><mn>0</mn></msub><mi mathvariant="normal">.</mi><mn>2</mn></mrow><annotation encoding="application/x-tex">p_v=p_0 .2</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord"><span class="mord mathnormal">p</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.03588em;">v</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8389em;vertical-align:-0.1944em;"></span><span class="mord"><span class="mord mathnormal">p</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">0</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord">.2</span></span></span></span> 液の界面では <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>p</mi><mrow><mi>v</mi><mn>1</mn></mrow></msub><mo>+</mo><msub><mi>p</mi><mrow><mi>v</mi><mn>2</mn></mrow></msub><mo>=</mo><msub><mi>p</mi><mn>0</mn></msub></mrow><annotation encoding="application/x-tex">p_{v 1}+p_{v 2}=p_0</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7778em;vertical-align:-0.1944em;"></span><span class="mord"><span class="mord mathnormal">p</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.03588em;">v</span><span class="mord mtight">1</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord"><span class="mord mathnormal">p</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.03588em;">v</span><span class="mord mtight">2</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord"><span class="mord mathnormal">p</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">0</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span>.</li>
</ol>
<h3 id="_10-18-熱流" tabindex="-1">10.18: 熱流 <a class="header-anchor" href="#_10-18-熱流" aria-label="Permalink to &quot;10.18: 熱流&quot;">&ZeroWidthSpace;</a></h3>
<ol start="18">
<li>熱流: <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>P</mi><mo>=</mo><mi>k</mi><mi>S</mi><mi mathvariant="normal">Δ</mi><mi>T</mi><mi mathvariant="normal">/</mi><mi>l</mi></mrow><annotation encoding="application/x-tex">P=k S \Delta T / l</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.13889em;">P</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="mord mathnormal" style="margin-right:0.05764em;">S</span><span class="mord">Δ</span><span class="mord mathnormal" style="margin-right:0.13889em;">T</span><span class="mord">/</span><span class="mord mathnormal" style="margin-right:0.01968em;">l</span></span></span></span> ( <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>k</mi></mrow><annotation encoding="application/x-tex">k</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal" style="margin-right:0.03148em;">k</span></span></span></span> は熱伝導率). 直流回路に似て いる <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">(</mo><mi>P</mi><mo>↔</mo><mi>I</mi><mo separator="true">,</mo><mi mathvariant="normal">Δ</mi><mi>T</mi><mo>↔</mo><mi>V</mi><mo separator="true">,</mo><mi>k</mi><mo>↔</mo><mn>1</mn><mi mathvariant="normal">/</mi><mi>ρ</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">(P \leftrightarrow I, \Delta T \leftrightarrow V, k \leftrightarrow 1 / \rho)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.13889em;">P</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">↔</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8778em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord">Δ</span><span class="mord mathnormal" style="margin-right:0.13889em;">T</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">↔</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.22222em;">V</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">↔</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">1/</span><span class="mord mathnormal">ρ</span><span class="mclose">)</span></span></span></span>.</li>
</ol>
<h3 id="_10-19-熱容量" tabindex="-1">10.19: 熱容量 <a class="header-anchor" href="#_10-19-熱容量" aria-label="Permalink to &quot;10.19: 熱容量&quot;">&ZeroWidthSpace;</a></h3>
<ol start="19">
<li>熱容量 : <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>Q</mi><mo>=</mo><mo>∫</mo><mi>c</mi><mo stretchy="false">(</mo><mi>T</mi><mo stretchy="false">)</mo><mi mathvariant="normal">d</mi><mi>T</mi></mrow><annotation encoding="application/x-tex">Q=\int c(T) \mathrm{d} T</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8778em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">Q</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.1111em;vertical-align:-0.3061em;"></span><span class="mop op-symbol small-op" style="margin-right:0.19445em;position:relative;top:-0.0006em;">∫</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">c</span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.13889em;">T</span><span class="mclose">)</span><span class="mord mathrm">d</span><span class="mord mathnormal" style="margin-right:0.13889em;">T</span></span></span></span>. 固体では低温で <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>c</mi><mo>∝</mo><msup><mi>T</mi><mn>3</mn></msup></mrow><annotation encoding="application/x-tex">c \propto T^3</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">c</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">∝</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8141em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.13889em;">T</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">3</span></span></span></span></span></span></span></span></span></span></span>, 高温で <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>c</mi><mo>=</mo><mn>3</mn><mi>N</mi><msub><mi>k</mi><mi>B</mi></msub></mrow><annotation encoding="application/x-tex">c=3 N k_B</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">c</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8444em;vertical-align:-0.15em;"></span><span class="mord">3</span><span class="mord mathnormal" style="margin-right:0.10903em;">N</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-left:-0.0315em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.05017em;">B</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> （Dulong-Petit の法則. ここで <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>N</mi></mrow><annotation encoding="application/x-tex">N</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.10903em;">N</span></span></span></span> は結晶中の原子数）</li>
</ol>
<h3 id="_10-20-表面張力" tabindex="-1">10.20: 表面張力 <a class="header-anchor" href="#_10-20-表面張力" aria-label="Permalink to &quot;10.20: 表面張力&quot;">&ZeroWidthSpace;</a></h3>
<ol start="20">
<li>表面張力 :<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mi>U</mi><mo>=</mo><mi>S</mi><mi>σ</mi><mo separator="true">,</mo><mi>F</mi><mo>=</mo><mi>l</mi><mi>σ</mi><mo separator="true">,</mo><mi>p</mi><mo>=</mo><mn>2</mn><mi>σ</mi><mi mathvariant="normal">/</mi><mi>R</mi></mrow><annotation encoding="application/x-tex">U=S \sigma, F=l \sigma, p=2 \sigma / R
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.10903em;">U</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8778em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.05764em;">S</span><span class="mord mathnormal" style="margin-right:0.03588em;">σ</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.13889em;">F</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.01968em;">l</span><span class="mord mathnormal" style="margin-right:0.03588em;">σ</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">p</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">2</span><span class="mord mathnormal" style="margin-right:0.03588em;">σ</span><span class="mord">/</span><span class="mord mathnormal" style="margin-right:0.00773em;">R</span></span></span></span></span></p>
</li>
</ol>
<h3 id="_10-21-stefan-boltzmann-の法則-灰色体" tabindex="-1">10.21: Stefan-Boltzmann の法則 (灰色体) <a class="header-anchor" href="#_10-21-stefan-boltzmann-の法則-灰色体" aria-label="Permalink to &quot;10.21: Stefan-Boltzmann の法則 (灰色体)&quot;">&ZeroWidthSpace;</a></h3>
<ol start="21">
<li>Stefan-Boltzmann の法則 (灰色体) : <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>P</mi><mo>=</mo><mi>ε</mi><mi>σ</mi><mi>A</mi><msup><mi>T</mi><mn>4</mn></msup></mrow><annotation encoding="application/x-tex">P=\varepsilon \sigma A T^4</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.13889em;">P</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8141em;"></span><span class="mord mathnormal">ε</span><span class="mord mathnormal" style="margin-right:0.03588em;">σ</span><span class="mord mathnormal">A</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.13889em;">T</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">4</span></span></span></span></span></span></span></span></span></span></span>.</li>
</ol>
<h3 id="_10-22-wien-の変位則" tabindex="-1">10.22: Wien の変位則 <a class="header-anchor" href="#_10-22-wien-の変位則" aria-label="Permalink to &quot;10.22: Wien の変位則&quot;">&ZeroWidthSpace;</a></h3>
<ol start="22">
<li>Wien の変位則: <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>ν</mi><mi>max</mi><mo>⁡</mo></msub><mo>=</mo><mi>A</mi><msub><mi>k</mi><mi>B</mi></msub><mi>T</mi><mi mathvariant="normal">/</mi><mi>h</mi><mo stretchy="false">(</mo><mi>A</mi><mo>≈</mo></mrow><annotation encoding="application/x-tex">\nu_{\max }=A k_B T / h(A \approx</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.06366em;">ν</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:-0.0637em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mop mtight"><span class="mtight">m</span><span class="mtight">a</span><span class="mtight">x</span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal">A</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-left:-0.0315em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.05017em;">B</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord mathnormal" style="margin-right:0.13889em;">T</span><span class="mord">/</span><span class="mord mathnormal">h</span><span class="mopen">(</span><span class="mord mathnormal">A</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≈</span></span></span></span> 2.8), <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>λ</mi><mi>max</mi><mo>⁡</mo></msub><mo>=</mo><mi>h</mi><mi>c</mi><mi mathvariant="normal">/</mi><msup><mi>A</mi><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup><msub><mi>k</mi><mi>B</mi></msub><mi>T</mi><mrow><mo fence="true">(</mo><msup><mi>A</mi><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup><mo>≈</mo><mn>5</mn><mo fence="true">)</mo></mrow></mrow><annotation encoding="application/x-tex">\lambda_{\max }=h c / A^{\prime} k_B T\left(A^{\prime} \approx 5\right)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8444em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal">λ</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mop mtight"><span class="mtight">m</span><span class="mtight">a</span><span class="mtight">x</span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.0019em;vertical-align:-0.25em;"></span><span class="mord mathnormal">h</span><span class="mord mathnormal">c</span><span class="mord">/</span><span class="mord"><span class="mord mathnormal">A</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7519em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-left:-0.0315em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.05017em;">B</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord mathnormal" style="margin-right:0.13889em;">T</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord"><span class="mord mathnormal">A</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7519em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≈</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord">5</span><span class="mclose delimcenter" style="top:0em;">)</span></span></span></span></span>.</li>
</ol>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Formulas for IPhO 日本語版: Section 11 ]]></title>
            <link>https://note.toshiki.devacademic/physics/ipho-formulas-jpn/11</link>
            <guid>https://note.toshiki.devacademic/physics/ipho-formulas-jpn/11</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="formulas-for-ipho-日本語版-section-11" tabindex="-1">Formulas for IPhO 日本語版: Section 11 <a class="header-anchor" href="#formulas-for-ipho-日本語版-section-11" aria-label="Permalink to &quot;Formulas for IPhO 日本語版: Section 11&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="_11-量子力学" tabindex="-1">11: 量子力学 <a class="header-anchor" href="#_11-量子力学" aria-label="Permalink to &quot;11: 量子力学&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="_11-1-p-hk" tabindex="-1">11.1:p=hk <a class="header-anchor" href="#_11-1-p-hk" aria-label="Permalink to &quot;11.1:p=hk&quot;">&ZeroWidthSpace;</a></h3>
<ol>
<li><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="bold-italic">p</mi><mo>=</mo><mi mathvariant="normal">ℏ</mi><mi mathvariant="bold-italic">k</mi><mo stretchy="false">(</mo><mi mathvariant="normal">∣</mi><mi mathvariant="bold-italic">p</mi><mi mathvariant="normal">∣</mi><mo>=</mo><mi>h</mi><mi mathvariant="normal">/</mi><mi>λ</mi><mo stretchy="false">)</mo><mo separator="true">,</mo><mi>E</mi><mo>=</mo><mi mathvariant="normal">ℏ</mi><mi>ω</mi><mo>=</mo><mi>h</mi><mi>ν</mi></mrow><annotation encoding="application/x-tex">\boldsymbol{p}=\hbar \boldsymbol{k}(|\boldsymbol{p}|=h / \lambda), E=\hbar \omega=h \nu</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6389em;vertical-align:-0.1944em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol">p</span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">ℏ</span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.01852em;">k</span></span></span><span class="mopen">(</span><span class="mord">∣</span><span class="mord"><span class="mord"><span class="mord boldsymbol">p</span></span></span><span class="mord">∣</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal">h</span><span class="mord">/</span><span class="mord mathnormal">λ</span><span class="mclose">)</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.05764em;">E</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord">ℏ</span><span class="mord mathnormal" style="margin-right:0.03588em;">ω</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">h</span><span class="mord mathnormal" style="margin-right:0.06366em;">ν</span></span></span></span>.</li>
</ol>
<h3 id="_11-2-干渉" tabindex="-1">11.2: 干渉 <a class="header-anchor" href="#_11-2-干渉" aria-label="Permalink to &quot;11.2: 干渉&quot;">&ZeroWidthSpace;</a></h3>
<ol start="2">
<li>干渉 : 波動光学のように.</li>
</ol>
<h3 id="_11-3-不確定性" tabindex="-1">11.3: 不確定性 <a class="header-anchor" href="#_11-3-不確定性" aria-label="Permalink to &quot;11.3: 不確定性&quot;">&ZeroWidthSpace;</a></h3>
<ol start="3">
<li>
<p>不確定性（数学の定理）:</p>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mi mathvariant="normal">Δ</mi><mi>p</mi><mi mathvariant="normal">Δ</mi><mi>x</mi><mo>≥</mo><mfrac><mi mathvariant="normal">ℏ</mi><mn>2</mn></mfrac><mo separator="true">,</mo><mi mathvariant="normal">Δ</mi><mi>E</mi><mi mathvariant="normal">Δ</mi><mi>t</mi><mo>≥</mo><mfrac><mi mathvariant="normal">ℏ</mi><mn>2</mn></mfrac><mo separator="true">,</mo><mi mathvariant="normal">Δ</mi><mi>ω</mi><mi mathvariant="normal">Δ</mi><mi>t</mi><mo>≥</mo><mfrac><mn>1</mn><mn>2</mn></mfrac></mrow><annotation encoding="application/x-tex">\Delta p \Delta x \geq \frac{\hbar}{2}, \Delta E \Delta t \geq \frac{\hbar}{2}, \Delta \omega \Delta t \geq \frac{1}{2}
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8778em;vertical-align:-0.1944em;"></span><span class="mord">Δ</span><span class="mord mathnormal">p</span><span class="mord">Δ</span><span class="mord mathnormal">x</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≥</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:2.0519em;vertical-align:-0.686em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.3659em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">2</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">ℏ</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord">Δ</span><span class="mord mathnormal" style="margin-right:0.05764em;">E</span><span class="mord">Δ</span><span class="mord mathnormal">t</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≥</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:2.0519em;vertical-align:-0.686em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.3659em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">2</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">ℏ</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord">Δ</span><span class="mord mathnormal" style="margin-right:0.03588em;">ω</span><span class="mord">Δ</span><span class="mord mathnormal">t</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≥</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:2.0074em;vertical-align:-0.686em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.3214em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">2</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span></span></p>
<p>滑らかでない場合の定性的な推定には <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>h</mi></mrow><annotation encoding="application/x-tex">h</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">h</span></span></span></span> の方が適する <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">(</mo><mi mathvariant="normal">Δ</mi><mi>p</mi><mi mathvariant="normal">Δ</mi><mi>x</mi><mo>≈</mo><mi>h</mi></mrow><annotation encoding="application/x-tex">(\Delta p \Delta x \approx h</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">(</span><span class="mord">Δ</span><span class="mord mathnormal">p</span><span class="mord">Δ</span><span class="mord mathnormal">x</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≈</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">h</span></span></span></span> など <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mclose">)</span></span></span></span>.</p>
</li>
</ol>
<h3 id="_11-4-スペクトル" tabindex="-1">11.4: スペクトル <a class="header-anchor" href="#_11-4-スペクトル" aria-label="Permalink to &quot;11.4: スペクトル&quot;">&ZeroWidthSpace;</a></h3>
<ol start="4">
<li>スペクトル : <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>h</mi><mi>ν</mi><mo>=</mo><msub><mi>E</mi><mi>n</mi></msub><mo>−</mo><msub><mi>E</mi><mi>m</mi></msub></mrow><annotation encoding="application/x-tex">h \nu=E_n-E_m</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">h</span><span class="mord mathnormal" style="margin-right:0.06366em;">ν</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.05764em;">E</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:-0.0576em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">n</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.05764em;">E</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:-0.0576em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">m</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span>. スペクトル線の幅は寿 命に関係し, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Γ</mi><mi>τ</mi><mo>≈</mo><mi mathvariant="normal">ℏ</mi></mrow><annotation encoding="application/x-tex">\Gamma \tau \approx \hbar</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">Γ</span><span class="mord mathnormal" style="margin-right:0.1132em;">τ</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≈</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord">ℏ</span></span></span></span>.</li>
</ol>
<h3 id="_11-5-振動子" tabindex="-1">11.5: 振動子 <a class="header-anchor" href="#_11-5-振動子" aria-label="Permalink to &quot;11.5: 振動子&quot;">&ZeroWidthSpace;</a></h3>
<ol start="5">
<li>振動子（例えば分子）のエネルギー準位（固有振動数 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mrow><msub><mi>ν</mi><mn>0</mn></msub><mo fence="true">)</mo></mrow><mo>:</mo><msub><mi>E</mi><mi>n</mi></msub><mo>=</mo><mrow><mo fence="true">(</mo><mi>n</mi><mo>+</mo><mfrac><mn>1</mn><mn>2</mn></mfrac><mo fence="true">)</mo></mrow><mi>h</mi><msub><mi>ν</mi><mn>0</mn></msub></mrow><annotation encoding="application/x-tex">\left.\nu_0\right): E_n=\left(n+\frac{1}{2}\right) h \nu_0</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="minner"><span class="mopen nulldelimiter"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.06366em;">ν</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0637em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">0</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">)</span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">:</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.05764em;">E</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:-0.0576em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">n</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.2em;vertical-align:-0.35em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size1">(</span></span><span class="mord mathnormal">n</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8451em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">1</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size1">)</span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">h</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.06366em;">ν</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0637em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">0</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span>. 多数の固有振動数の場合, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>E</mi><mo>=</mo><mo>∑</mo><mi>h</mi><msub><mi>n</mi><mi>i</mi></msub><msub><mi>ν</mi><mi>i</mi></msub></mrow><annotation encoding="application/x-tex">E=\sum h n_i \nu_i</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.05764em;">E</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mop op-symbol small-op" style="position:relative;top:0em;">∑</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">h</span><span class="mord"><span class="mord mathnormal">n</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.06366em;">ν</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:-0.0637em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span>.</li>
</ol>
<h3 id="_11-6-トンネル効果" tabindex="-1">11.6: トンネル効果 <a class="header-anchor" href="#_11-6-トンネル効果" aria-label="Permalink to &quot;11.6: トンネル効果&quot;">&ZeroWidthSpace;</a></h3>
<ol start="6">
<li>トンネル効果: 幅 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>l</mi></mrow><annotation encoding="application/x-tex">l</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal" style="margin-right:0.01968em;">l</span></span></span></span> の障壁 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Γ</mi></mrow><annotation encoding="application/x-tex">\Gamma</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">Γ</span></span></span></span> は, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Γ</mi><mi>τ</mi><mo>≈</mo><mi mathvariant="normal">ℏ</mi><mo stretchy="false">(</mo><mi>τ</mi><mo>=</mo></mrow><annotation encoding="application/x-tex">\Gamma \tau \approx \hbar(\tau=</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">Γ</span><span class="mord mathnormal" style="margin-right:0.1132em;">τ</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≈</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">ℏ</span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.1132em;">τ</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span></span></span></span> <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>l</mi><mi mathvariant="normal">/</mi><msqrt><mrow><mi mathvariant="normal">Γ</mi><mi mathvariant="normal">/</mi><mi>m</mi></mrow></msqrt><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">l / \sqrt{\Gamma / m})</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.24em;vertical-align:-0.305em;"></span><span class="mord mathnormal" style="margin-right:0.01968em;">l</span><span class="mord">/</span><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.935em;"><span class="svg-align" style="top:-3.2em;"><span class="pstrut" style="height:3.2em;"></span><span class="mord" style="padding-left:1em;"><span class="mord">Γ/</span><span class="mord mathnormal">m</span></span></span><span style="top:-2.895em;"><span class="pstrut" style="height:3.2em;"></span><span class="hide-tail" style="min-width:1.02em;height:1.28em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='1.28em' viewBox='0 0 400000 1296' preserveAspectRatio='xMinYMin slice'><path d='M263,681c0.7,0,18,39.7,52,119
c34,79.3,68.167,158.7,102.5,238c34.3,79.3,51.8,119.3,52.5,120
c340,-704.7,510.7,-1060.3,512,-1067
l0 -0
c4.7,-7.3,11,-11,19,-11
H40000v40H1012.3
s-271.3,567,-271.3,567c-38.7,80.7,-84,175,-136,283c-52,108,-89.167,185.3,-111.5,232
c-22.3,46.7,-33.8,70.3,-34.5,71c-4.7,4.7,-12.3,7,-23,7s-12,-1,-12,-1
s-109,-253,-109,-253c-72.7,-168,-109.3,-252,-110,-252c-10.7,8,-22,16.7,-34,26
c-22,17.3,-33.3,26,-34,26s-26,-26,-26,-26s76,-59,76,-59s76,-60,76,-60z
M1001 80h400000v40h-400000z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.305em;"><span></span></span></span></span></span><span class="mclose">)</span></span></span></span> であれば容易に透過する.</li>
</ol>
<h3 id="_11-7-bohr-モデル" tabindex="-1">11.7: Bohr モデル <a class="header-anchor" href="#_11-7-bohr-モデル" aria-label="Permalink to &quot;11.7: Bohr モデル&quot;">&ZeroWidthSpace;</a></h3>
<ol start="7">
<li>Bohr モデル : <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>E</mi><mi>n</mi></msub><mo>∝</mo><mo>−</mo><mn>1</mn><mi mathvariant="normal">/</mi><msup><mi>n</mi><mn>2</mn></msup></mrow><annotation encoding="application/x-tex">E_n \propto-1 / n^2</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.05764em;">E</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:-0.0576em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">n</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">∝</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.0641em;vertical-align:-0.25em;"></span><span class="mord">−</span><span class="mord">1/</span><span class="mord"><span class="mord mathnormal">n</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span></span>. (古典的に計算される) 円軌道では, 軌道の長さが波長 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>λ</mi><mo>=</mo><mi>h</mi><mi mathvariant="normal">/</mi><mi>m</mi><mi>v</mi></mrow><annotation encoding="application/x-tex">\lambda=h / m v</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">λ</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal">h</span><span class="mord">/</span><span class="mord mathnormal">m</span><span class="mord mathnormal" style="margin-right:0.03588em;">v</span></span></span></span> の整数倍.</li>
</ol>
<h3 id="_11-8-compton-効果" tabindex="-1">11.8: Compton 効果 <a class="header-anchor" href="#_11-8-compton-効果" aria-label="Permalink to &quot;11.8: Compton 効果&quot;">&ZeroWidthSpace;</a></h3>
<ol start="8">
<li>Compton 効果: 光子が電子から散乱されると, 光子の <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Δ</mi><mi>λ</mi><mo>=</mo><msub><mi>λ</mi><mi>C</mi></msub><mo stretchy="false">(</mo><mn>1</mn><mo>−</mo><mi>cos</mi><mo>⁡</mo><mi>θ</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">\Delta \lambda=\lambda_C(1-\cos \theta)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">Δ</span><span class="mord mathnormal">λ</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord mathnormal">λ</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.07153em;">C</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mopen">(</span><span class="mord">1</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mop">cos</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.02778em;">θ</span><span class="mclose">)</span></span></span></span></li>
</ol>
<h3 id="_11-9-光電効果" tabindex="-1">11.9: 光電効果 <a class="header-anchor" href="#_11-9-光電効果" aria-label="Permalink to &quot;11.9: 光電効果&quot;">&ZeroWidthSpace;</a></h3>
<ol start="9">
<li>光電効果: <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>W</mi><mo>+</mo><mi>m</mi><msubsup><mi>v</mi><mi>max</mi><mo>⁡</mo><mn>2</mn></msubsup><mi mathvariant="normal">/</mi><mn>2</mn><mo>=</mo><mi>h</mi><mi>ν</mi></mrow><annotation encoding="application/x-tex">W+m v_{\max }^2 / 2=h \nu</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7667em;vertical-align:-0.0833em;"></span><span class="mord mathnormal" style="margin-right:0.13889em;">W</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1.0641em;vertical-align:-0.25em;"></span><span class="mord mathnormal">m</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-2.453em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mop mtight"><span class="mtight">m</span><span class="mtight">a</span><span class="mtight">x</span></span></span></span></span><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.247em;"><span></span></span></span></span></span></span><span class="mord">/2</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">h</span><span class="mord mathnormal" style="margin-right:0.06366em;">ν</span></span></span></span> ( <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>W</mi></mrow><annotation encoding="application/x-tex">W</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.13889em;">W</span></span></span></span> は仕事関数 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mclose">)</span></span></span></span>. <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>I</mi><mo>−</mo><mi>V</mi></mrow><annotation encoding="application/x-tex">I-V</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7667em;vertical-align:-0.0833em;"></span><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.22222em;">V</span></span></span></span> グラフ：光電流は阻止電圧 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>V</mi><mo>=</mo><mo>−</mo><mo stretchy="false">(</mo><mi>h</mi><mi>ν</mi><mo>−</mo><mi>W</mi><mo stretchy="false">)</mo><mi mathvariant="normal">/</mi><mi>e</mi></mrow><annotation encoding="application/x-tex">V=-(h \nu-W) / e</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.22222em;">V</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">−</span><span class="mopen">(</span><span class="mord mathnormal">h</span><span class="mord mathnormal" style="margin-right:0.06366em;">ν</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.13889em;">W</span><span class="mclose">)</span><span class="mord">/</span><span class="mord mathnormal">e</span></span></span></span> で始まり, 正方向に電圧が大きくなると緩和する.</li>
</ol>
<h3 id="_11-10-stefan-boltzmann-の法則" tabindex="-1">11.10: Stefan-Boltzmann の法則 <a class="header-anchor" href="#_11-10-stefan-boltzmann-の法則" aria-label="Permalink to &quot;11.10: Stefan-Boltzmann の法則&quot;">&ZeroWidthSpace;</a></h3>
<ol start="10">
<li>Stefan-Boltzmann の法則 : <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>P</mi><mo>=</mo><mi>σ</mi><mi>A</mi><msup><mi>T</mi><mn>4</mn></msup></mrow><annotation encoding="application/x-tex">P=\sigma A T^4</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.13889em;">P</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8141em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">σ</span><span class="mord mathnormal">A</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.13889em;">T</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">4</span></span></span></span></span></span></span></span></span></span></span></li>
</ol>
]]></description>
            <content:encoded><![CDATA[<h1 id="formulas-for-ipho-日本語版-section-11" tabindex="-1">Formulas for IPhO 日本語版: Section 11 <a class="header-anchor" href="#formulas-for-ipho-日本語版-section-11" aria-label="Permalink to &quot;Formulas for IPhO 日本語版: Section 11&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="_11-量子力学" tabindex="-1">11: 量子力学 <a class="header-anchor" href="#_11-量子力学" aria-label="Permalink to &quot;11: 量子力学&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="_11-1-p-hk" tabindex="-1">11.1:p=hk <a class="header-anchor" href="#_11-1-p-hk" aria-label="Permalink to &quot;11.1:p=hk&quot;">&ZeroWidthSpace;</a></h3>
<ol>
<li><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="bold-italic">p</mi><mo>=</mo><mi mathvariant="normal">ℏ</mi><mi mathvariant="bold-italic">k</mi><mo stretchy="false">(</mo><mi mathvariant="normal">∣</mi><mi mathvariant="bold-italic">p</mi><mi mathvariant="normal">∣</mi><mo>=</mo><mi>h</mi><mi mathvariant="normal">/</mi><mi>λ</mi><mo stretchy="false">)</mo><mo separator="true">,</mo><mi>E</mi><mo>=</mo><mi mathvariant="normal">ℏ</mi><mi>ω</mi><mo>=</mo><mi>h</mi><mi>ν</mi></mrow><annotation encoding="application/x-tex">\boldsymbol{p}=\hbar \boldsymbol{k}(|\boldsymbol{p}|=h / \lambda), E=\hbar \omega=h \nu</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6389em;vertical-align:-0.1944em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol">p</span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">ℏ</span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.01852em;">k</span></span></span><span class="mopen">(</span><span class="mord">∣</span><span class="mord"><span class="mord"><span class="mord boldsymbol">p</span></span></span><span class="mord">∣</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal">h</span><span class="mord">/</span><span class="mord mathnormal">λ</span><span class="mclose">)</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.05764em;">E</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord">ℏ</span><span class="mord mathnormal" style="margin-right:0.03588em;">ω</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">h</span><span class="mord mathnormal" style="margin-right:0.06366em;">ν</span></span></span></span>.</li>
</ol>
<h3 id="_11-2-干渉" tabindex="-1">11.2: 干渉 <a class="header-anchor" href="#_11-2-干渉" aria-label="Permalink to &quot;11.2: 干渉&quot;">&ZeroWidthSpace;</a></h3>
<ol start="2">
<li>干渉 : 波動光学のように.</li>
</ol>
<h3 id="_11-3-不確定性" tabindex="-1">11.3: 不確定性 <a class="header-anchor" href="#_11-3-不確定性" aria-label="Permalink to &quot;11.3: 不確定性&quot;">&ZeroWidthSpace;</a></h3>
<ol start="3">
<li>
<p>不確定性（数学の定理）:</p>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mi mathvariant="normal">Δ</mi><mi>p</mi><mi mathvariant="normal">Δ</mi><mi>x</mi><mo>≥</mo><mfrac><mi mathvariant="normal">ℏ</mi><mn>2</mn></mfrac><mo separator="true">,</mo><mi mathvariant="normal">Δ</mi><mi>E</mi><mi mathvariant="normal">Δ</mi><mi>t</mi><mo>≥</mo><mfrac><mi mathvariant="normal">ℏ</mi><mn>2</mn></mfrac><mo separator="true">,</mo><mi mathvariant="normal">Δ</mi><mi>ω</mi><mi mathvariant="normal">Δ</mi><mi>t</mi><mo>≥</mo><mfrac><mn>1</mn><mn>2</mn></mfrac></mrow><annotation encoding="application/x-tex">\Delta p \Delta x \geq \frac{\hbar}{2}, \Delta E \Delta t \geq \frac{\hbar}{2}, \Delta \omega \Delta t \geq \frac{1}{2}
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8778em;vertical-align:-0.1944em;"></span><span class="mord">Δ</span><span class="mord mathnormal">p</span><span class="mord">Δ</span><span class="mord mathnormal">x</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≥</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:2.0519em;vertical-align:-0.686em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.3659em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">2</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">ℏ</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord">Δ</span><span class="mord mathnormal" style="margin-right:0.05764em;">E</span><span class="mord">Δ</span><span class="mord mathnormal">t</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≥</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:2.0519em;vertical-align:-0.686em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.3659em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">2</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">ℏ</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord">Δ</span><span class="mord mathnormal" style="margin-right:0.03588em;">ω</span><span class="mord">Δ</span><span class="mord mathnormal">t</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≥</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:2.0074em;vertical-align:-0.686em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.3214em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">2</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span></span></p>
<p>滑らかでない場合の定性的な推定には <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>h</mi></mrow><annotation encoding="application/x-tex">h</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">h</span></span></span></span> の方が適する <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">(</mo><mi mathvariant="normal">Δ</mi><mi>p</mi><mi mathvariant="normal">Δ</mi><mi>x</mi><mo>≈</mo><mi>h</mi></mrow><annotation encoding="application/x-tex">(\Delta p \Delta x \approx h</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">(</span><span class="mord">Δ</span><span class="mord mathnormal">p</span><span class="mord">Δ</span><span class="mord mathnormal">x</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≈</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">h</span></span></span></span> など <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mclose">)</span></span></span></span>.</p>
</li>
</ol>
<h3 id="_11-4-スペクトル" tabindex="-1">11.4: スペクトル <a class="header-anchor" href="#_11-4-スペクトル" aria-label="Permalink to &quot;11.4: スペクトル&quot;">&ZeroWidthSpace;</a></h3>
<ol start="4">
<li>スペクトル : <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>h</mi><mi>ν</mi><mo>=</mo><msub><mi>E</mi><mi>n</mi></msub><mo>−</mo><msub><mi>E</mi><mi>m</mi></msub></mrow><annotation encoding="application/x-tex">h \nu=E_n-E_m</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">h</span><span class="mord mathnormal" style="margin-right:0.06366em;">ν</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.05764em;">E</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:-0.0576em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">n</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.05764em;">E</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:-0.0576em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">m</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span>. スペクトル線の幅は寿 命に関係し, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Γ</mi><mi>τ</mi><mo>≈</mo><mi mathvariant="normal">ℏ</mi></mrow><annotation encoding="application/x-tex">\Gamma \tau \approx \hbar</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">Γ</span><span class="mord mathnormal" style="margin-right:0.1132em;">τ</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≈</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord">ℏ</span></span></span></span>.</li>
</ol>
<h3 id="_11-5-振動子" tabindex="-1">11.5: 振動子 <a class="header-anchor" href="#_11-5-振動子" aria-label="Permalink to &quot;11.5: 振動子&quot;">&ZeroWidthSpace;</a></h3>
<ol start="5">
<li>振動子（例えば分子）のエネルギー準位（固有振動数 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mrow><msub><mi>ν</mi><mn>0</mn></msub><mo fence="true">)</mo></mrow><mo>:</mo><msub><mi>E</mi><mi>n</mi></msub><mo>=</mo><mrow><mo fence="true">(</mo><mi>n</mi><mo>+</mo><mfrac><mn>1</mn><mn>2</mn></mfrac><mo fence="true">)</mo></mrow><mi>h</mi><msub><mi>ν</mi><mn>0</mn></msub></mrow><annotation encoding="application/x-tex">\left.\nu_0\right): E_n=\left(n+\frac{1}{2}\right) h \nu_0</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="minner"><span class="mopen nulldelimiter"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.06366em;">ν</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0637em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">0</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">)</span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">:</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.05764em;">E</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:-0.0576em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">n</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.2em;vertical-align:-0.35em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size1">(</span></span><span class="mord mathnormal">n</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8451em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">1</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size1">)</span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">h</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.06366em;">ν</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0637em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">0</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span>. 多数の固有振動数の場合, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>E</mi><mo>=</mo><mo>∑</mo><mi>h</mi><msub><mi>n</mi><mi>i</mi></msub><msub><mi>ν</mi><mi>i</mi></msub></mrow><annotation encoding="application/x-tex">E=\sum h n_i \nu_i</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.05764em;">E</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mop op-symbol small-op" style="position:relative;top:0em;">∑</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">h</span><span class="mord"><span class="mord mathnormal">n</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.06366em;">ν</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:-0.0637em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span>.</li>
</ol>
<h3 id="_11-6-トンネル効果" tabindex="-1">11.6: トンネル効果 <a class="header-anchor" href="#_11-6-トンネル効果" aria-label="Permalink to &quot;11.6: トンネル効果&quot;">&ZeroWidthSpace;</a></h3>
<ol start="6">
<li>トンネル効果: 幅 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>l</mi></mrow><annotation encoding="application/x-tex">l</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal" style="margin-right:0.01968em;">l</span></span></span></span> の障壁 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Γ</mi></mrow><annotation encoding="application/x-tex">\Gamma</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">Γ</span></span></span></span> は, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Γ</mi><mi>τ</mi><mo>≈</mo><mi mathvariant="normal">ℏ</mi><mo stretchy="false">(</mo><mi>τ</mi><mo>=</mo></mrow><annotation encoding="application/x-tex">\Gamma \tau \approx \hbar(\tau=</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">Γ</span><span class="mord mathnormal" style="margin-right:0.1132em;">τ</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≈</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">ℏ</span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.1132em;">τ</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span></span></span></span> <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>l</mi><mi mathvariant="normal">/</mi><msqrt><mrow><mi mathvariant="normal">Γ</mi><mi mathvariant="normal">/</mi><mi>m</mi></mrow></msqrt><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">l / \sqrt{\Gamma / m})</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.24em;vertical-align:-0.305em;"></span><span class="mord mathnormal" style="margin-right:0.01968em;">l</span><span class="mord">/</span><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.935em;"><span class="svg-align" style="top:-3.2em;"><span class="pstrut" style="height:3.2em;"></span><span class="mord" style="padding-left:1em;"><span class="mord">Γ/</span><span class="mord mathnormal">m</span></span></span><span style="top:-2.895em;"><span class="pstrut" style="height:3.2em;"></span><span class="hide-tail" style="min-width:1.02em;height:1.28em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='1.28em' viewBox='0 0 400000 1296' preserveAspectRatio='xMinYMin slice'><path d='M263,681c0.7,0,18,39.7,52,119
c34,79.3,68.167,158.7,102.5,238c34.3,79.3,51.8,119.3,52.5,120
c340,-704.7,510.7,-1060.3,512,-1067
l0 -0
c4.7,-7.3,11,-11,19,-11
H40000v40H1012.3
s-271.3,567,-271.3,567c-38.7,80.7,-84,175,-136,283c-52,108,-89.167,185.3,-111.5,232
c-22.3,46.7,-33.8,70.3,-34.5,71c-4.7,4.7,-12.3,7,-23,7s-12,-1,-12,-1
s-109,-253,-109,-253c-72.7,-168,-109.3,-252,-110,-252c-10.7,8,-22,16.7,-34,26
c-22,17.3,-33.3,26,-34,26s-26,-26,-26,-26s76,-59,76,-59s76,-60,76,-60z
M1001 80h400000v40h-400000z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.305em;"><span></span></span></span></span></span><span class="mclose">)</span></span></span></span> であれば容易に透過する.</li>
</ol>
<h3 id="_11-7-bohr-モデル" tabindex="-1">11.7: Bohr モデル <a class="header-anchor" href="#_11-7-bohr-モデル" aria-label="Permalink to &quot;11.7: Bohr モデル&quot;">&ZeroWidthSpace;</a></h3>
<ol start="7">
<li>Bohr モデル : <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>E</mi><mi>n</mi></msub><mo>∝</mo><mo>−</mo><mn>1</mn><mi mathvariant="normal">/</mi><msup><mi>n</mi><mn>2</mn></msup></mrow><annotation encoding="application/x-tex">E_n \propto-1 / n^2</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.05764em;">E</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:-0.0576em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">n</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">∝</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.0641em;vertical-align:-0.25em;"></span><span class="mord">−</span><span class="mord">1/</span><span class="mord"><span class="mord mathnormal">n</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span></span>. (古典的に計算される) 円軌道では, 軌道の長さが波長 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>λ</mi><mo>=</mo><mi>h</mi><mi mathvariant="normal">/</mi><mi>m</mi><mi>v</mi></mrow><annotation encoding="application/x-tex">\lambda=h / m v</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">λ</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal">h</span><span class="mord">/</span><span class="mord mathnormal">m</span><span class="mord mathnormal" style="margin-right:0.03588em;">v</span></span></span></span> の整数倍.</li>
</ol>
<h3 id="_11-8-compton-効果" tabindex="-1">11.8: Compton 効果 <a class="header-anchor" href="#_11-8-compton-効果" aria-label="Permalink to &quot;11.8: Compton 効果&quot;">&ZeroWidthSpace;</a></h3>
<ol start="8">
<li>Compton 効果: 光子が電子から散乱されると, 光子の <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Δ</mi><mi>λ</mi><mo>=</mo><msub><mi>λ</mi><mi>C</mi></msub><mo stretchy="false">(</mo><mn>1</mn><mo>−</mo><mi>cos</mi><mo>⁡</mo><mi>θ</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">\Delta \lambda=\lambda_C(1-\cos \theta)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">Δ</span><span class="mord mathnormal">λ</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord mathnormal">λ</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.07153em;">C</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mopen">(</span><span class="mord">1</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mop">cos</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.02778em;">θ</span><span class="mclose">)</span></span></span></span></li>
</ol>
<h3 id="_11-9-光電効果" tabindex="-1">11.9: 光電効果 <a class="header-anchor" href="#_11-9-光電効果" aria-label="Permalink to &quot;11.9: 光電効果&quot;">&ZeroWidthSpace;</a></h3>
<ol start="9">
<li>光電効果: <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>W</mi><mo>+</mo><mi>m</mi><msubsup><mi>v</mi><mi>max</mi><mo>⁡</mo><mn>2</mn></msubsup><mi mathvariant="normal">/</mi><mn>2</mn><mo>=</mo><mi>h</mi><mi>ν</mi></mrow><annotation encoding="application/x-tex">W+m v_{\max }^2 / 2=h \nu</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7667em;vertical-align:-0.0833em;"></span><span class="mord mathnormal" style="margin-right:0.13889em;">W</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1.0641em;vertical-align:-0.25em;"></span><span class="mord mathnormal">m</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-2.453em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mop mtight"><span class="mtight">m</span><span class="mtight">a</span><span class="mtight">x</span></span></span></span></span><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.247em;"><span></span></span></span></span></span></span><span class="mord">/2</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">h</span><span class="mord mathnormal" style="margin-right:0.06366em;">ν</span></span></span></span> ( <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>W</mi></mrow><annotation encoding="application/x-tex">W</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.13889em;">W</span></span></span></span> は仕事関数 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mclose">)</span></span></span></span>. <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>I</mi><mo>−</mo><mi>V</mi></mrow><annotation encoding="application/x-tex">I-V</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7667em;vertical-align:-0.0833em;"></span><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.22222em;">V</span></span></span></span> グラフ：光電流は阻止電圧 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>V</mi><mo>=</mo><mo>−</mo><mo stretchy="false">(</mo><mi>h</mi><mi>ν</mi><mo>−</mo><mi>W</mi><mo stretchy="false">)</mo><mi mathvariant="normal">/</mi><mi>e</mi></mrow><annotation encoding="application/x-tex">V=-(h \nu-W) / e</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.22222em;">V</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">−</span><span class="mopen">(</span><span class="mord mathnormal">h</span><span class="mord mathnormal" style="margin-right:0.06366em;">ν</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.13889em;">W</span><span class="mclose">)</span><span class="mord">/</span><span class="mord mathnormal">e</span></span></span></span> で始まり, 正方向に電圧が大きくなると緩和する.</li>
</ol>
<h3 id="_11-10-stefan-boltzmann-の法則" tabindex="-1">11.10: Stefan-Boltzmann の法則 <a class="header-anchor" href="#_11-10-stefan-boltzmann-の法則" aria-label="Permalink to &quot;11.10: Stefan-Boltzmann の法則&quot;">&ZeroWidthSpace;</a></h3>
<ol start="10">
<li>Stefan-Boltzmann の法則 : <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>P</mi><mo>=</mo><mi>σ</mi><mi>A</mi><msup><mi>T</mi><mn>4</mn></msup></mrow><annotation encoding="application/x-tex">P=\sigma A T^4</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.13889em;">P</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8141em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">σ</span><span class="mord mathnormal">A</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.13889em;">T</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">4</span></span></span></span></span></span></span></span></span></span></span></li>
</ol>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Formulas for IPhO 日本語版: Section 12 ]]></title>
            <link>https://note.toshiki.devacademic/physics/ipho-formulas-jpn/12</link>
            <guid>https://note.toshiki.devacademic/physics/ipho-formulas-jpn/12</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="formulas-for-ipho-日本語版-section-12" tabindex="-1">Formulas for IPhO 日本語版: Section 12 <a class="header-anchor" href="#formulas-for-ipho-日本語版-section-12" aria-label="Permalink to &quot;Formulas for IPhO 日本語版: Section 12&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="_12-kepler-の法則" tabindex="-1">12: Kepler の法則 <a class="header-anchor" href="#_12-kepler-の法則" aria-label="Permalink to &quot;12: Kepler の法則&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="_12-1-f-u" tabindex="-1">12.1: F &amp; U <a class="header-anchor" href="#_12-1-f-u" aria-label="Permalink to &quot;12.1: F &amp; U&quot;">&ZeroWidthSpace;</a></h3>
<ol>
<li><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>F</mi><mo>=</mo><mi>G</mi><mi>M</mi><mi>m</mi><mi mathvariant="normal">/</mi><msup><mi>r</mi><mn>2</mn></msup><mo separator="true">,</mo><mi>U</mi><mo>=</mo><mo>−</mo><mi>G</mi><mi>M</mi><mi>m</mi><mi mathvariant="normal">/</mi><mi>r</mi><mtext>. </mtext></mrow><annotation encoding="application/x-tex">F=G M m / r^2, U=-G M m / r \text {. }</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.13889em;">F</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.0641em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.10903em;">GM</span><span class="mord mathnormal">m</span><span class="mord">/</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.02778em;">r</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.10903em;">U</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">−</span><span class="mord mathnormal" style="margin-right:0.10903em;">GM</span><span class="mord mathnormal">m</span><span class="mord">/</span><span class="mord mathnormal" style="margin-right:0.02778em;">r</span><span class="mord text"><span class="mord">. </span></span></span></span></span></li>
</ol>
<h3 id="_12-2-kepler-の第一法則" tabindex="-1">12.2: Kepler の第一法則 <a class="header-anchor" href="#_12-2-kepler-の第一法則" aria-label="Permalink to &quot;12.2: Kepler の第一法則&quot;">&ZeroWidthSpace;</a></h3>
<ol start="2">
<li>Kepler の第一法則 (2 質点の重力相互作用)：それぞ れの軌道は，系の質量中心に焦点を持つ楕円，双曲線, 放物線になる. これは Runge-Lenz ベクトルから得ら れる (ポイント 9).</li>
</ol>
<h3 id="_12-3-kepler-の第二法則" tabindex="-1">12.3: Kepler の第二法則 <a class="header-anchor" href="#_12-3-kepler-の第二法則" aria-label="Permalink to &quot;12.3: Kepler の第二法則&quot;">&ZeroWidthSpace;</a></h3>
<ol start="3">
<li>Kepler の第二法則（角運動量の保存）: 中心力が働く 場にある質点について，その位置ベクトルは単位時間 に一定の面積を描く.</li>
</ol>
<h3 id="_12-4-kepler-の第三法則" tabindex="-1">12.4: Kepler の第三法則 <a class="header-anchor" href="#_12-4-kepler-の第三法則" aria-label="Permalink to &quot;12.4: Kepler の第三法則&quot;">&ZeroWidthSpace;</a></h3>
<ol start="4">
<li>Kepler の第三法則 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>:</mo><msup><mi>r</mi><mrow><mo>−</mo><mn>2</mn></mrow></msup></mrow><annotation encoding="application/x-tex">: r^{-2}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mrel">:</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8141em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.02778em;">r</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">−</span><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span></span></span> に比例する力が働く場で楕円 軌道を描く複数の質点について, 周期は長半径の <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mfrac><mn>3</mn><mn>2</mn></mfrac></mrow><annotation encoding="application/x-tex">\frac{3}{2}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1901em;vertical-align:-0.345em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8451em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">3</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span> 乗 に比例する :<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><msubsup><mi>T</mi><mn>1</mn><mn>2</mn></msubsup><mi mathvariant="normal">/</mi><msubsup><mi>T</mi><mn>2</mn><mn>2</mn></msubsup><mo>=</mo><msubsup><mi>a</mi><mn>1</mn><mn>3</mn></msubsup><mi mathvariant="normal">/</mi><msubsup><mi>a</mi><mn>2</mn><mn>3</mn></msubsup></mrow><annotation encoding="application/x-tex">T_1^2 / T_2^2=a_1^3 / a_2^3
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1141em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.13889em;">T</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-2.453em;margin-left:-0.1389em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.247em;"><span></span></span></span></span></span></span><span class="mord">/</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.13889em;">T</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-2.453em;margin-left:-0.1389em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.247em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.1141em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-2.453em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">3</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.247em;"><span></span></span></span></span></span></span><span class="mord">/</span><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-2.453em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">3</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.247em;"><span></span></span></span></span></span></span></span></span></span></span></p>
</li>
</ol>
<h3 id="_12-5-楕円軌道" tabindex="-1">12.5: 楕円軌道 <a class="header-anchor" href="#_12-5-楕円軌道" aria-label="Permalink to &quot;12.5: 楕円軌道&quot;">&ZeroWidthSpace;</a></h3>
<ol start="5">
<li>重力場中で楕円軌道を描く質点の全エネルギー <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">(</mo><mi>K</mi><mo>+</mo><mi>U</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">(K+U)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.07153em;">K</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.10903em;">U</span><span class="mclose">)</span></span></span></span> :<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mi>E</mi><mo>=</mo><mo>−</mo><mi>G</mi><mi>M</mi><mi>m</mi><mi mathvariant="normal">/</mi><mn>2</mn><mi>a</mi></mrow><annotation encoding="application/x-tex">E=-G M m / 2 a
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.05764em;">E</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">−</span><span class="mord mathnormal" style="margin-right:0.10903em;">GM</span><span class="mord mathnormal">m</span><span class="mord">/2</span><span class="mord mathnormal">a</span></span></span></span></span></p>
</li>
</ol>
<h3 id="_12-6-楕円率" tabindex="-1">12.6: 楕円率 <a class="header-anchor" href="#_12-6-楕円率" aria-label="Permalink to &quot;12.6: 楕円率&quot;">&ZeroWidthSpace;</a></h3>
<ol>
<li>楕円率が <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ε</mi><mo>=</mo><mi>d</mi><mi mathvariant="normal">/</mi><mi>a</mi><mo>≪</mo><mn>1</mn></mrow><annotation encoding="application/x-tex">\varepsilon=d / a \ll 1</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">ε</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal">d</span><span class="mord">/</span><span class="mord mathnormal">a</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≪</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">1</span></span></span></span> の場合, 軌道は焦点をずらし た円形をしていると考えられる.</li>
</ol>
<h3 id="_12-7-楕円の性質" tabindex="-1">12.7: 楕円の性質 <a class="header-anchor" href="#_12-7-楕円の性質" aria-label="Permalink to &quot;12.7: 楕円の性質&quot;">&ZeroWidthSpace;</a></h3>
<ol start="2">
<li>楕円の性質 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>:</mo><msub><mi>l</mi><mn>1</mn></msub><mo>+</mo><msub><mi>l</mi><mn>2</mn></msub><mo>=</mo><mn>2</mn><mi>a</mi><mtext>（</mtext><msub><mi>l</mi><mn>1</mn></msub></mrow><annotation encoding="application/x-tex">: l_1+l_2=2 a （ l_1</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mrel">:</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8444em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.01968em;">l</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0197em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.8444em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.01968em;">l</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0197em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8444em;vertical-align:-0.15em;"></span><span class="mord">2</span><span class="mord mathnormal">a</span><span class="mord cjk_fallback">（</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.01968em;">l</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0197em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> と <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>l</mi><mn>2</mn></msub></mrow><annotation encoding="application/x-tex">l_2</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8444em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.01968em;">l</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0197em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> は焦点までの距 離). <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>α</mi><mn>1</mn></msub><mo>=</mo><msub><mi>α</mi><mn>2</mn></msub></mrow><annotation encoding="application/x-tex">\alpha_1=\alpha_2</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.0037em;">α</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0037em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.0037em;">α</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0037em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> (一方の焦点から出た光は他方の焦点に 反射する). <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>S</mi><mo>=</mo><mi>π</mi><mi>a</mi><mi>b</mi></mrow><annotation encoding="application/x-tex">S=\pi a b</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.05764em;">S</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">πab</span></span></span></span>.</li>
</ol>
<h3 id="_12-8-円の中心" tabindex="-1">12.8: 円の中心 <a class="header-anchor" href="#_12-8-円の中心" aria-label="Permalink to &quot;12.8: 円の中心&quot;">&ZeroWidthSpace;</a></h3>
<ol start="3">
<li>円とその円の中心に焦点をもつ楕円は長軸の部分での み接する.</li>
</ol>
<h3 id="_12-9-nge-lenz-ベクトル" tabindex="-1">12.9: nge-Lenz ベクトル <Badge type="tip" text="supplemental" /> <a class="header-anchor" href="#_12-9-nge-lenz-ベクトル" aria-label="Permalink to &quot;12.9: nge-Lenz ベクトル &lt;Badge type=&quot;tip&quot; text=&quot;supplemental&quot; /&gt;&quot;">&ZeroWidthSpace;</a></h3>
<ol start="4">
<li>Runge-Lenz ベクトル（楕円率ベクトル）[訳者注：こ のベクトルはむしろ離心率と関係する.そこでここで は離心率ベクトルとして知られるベクトルを代わりに 記す.これは焦点から近日点に向かう向きで，大きさ が離心率 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>e</mi></mrow><annotation encoding="application/x-tex">e</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">e</span></span></span></span> に一致する.]：<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mi mathvariant="bold-italic">e</mi><mo>=</mo><mfrac><mrow><mi mathvariant="bold-italic">v</mi><mo>×</mo><mi mathvariant="bold-italic">M</mi></mrow><mrow><mi>G</mi><mi>M</mi><mi>m</mi></mrow></mfrac><mo>−</mo><msub><mi mathvariant="bold-italic">e</mi><mi>r</mi></msub><mo>=</mo><mtext> const. </mtext></mrow><annotation encoding="application/x-tex">\boldsymbol{e}=\frac{\boldsymbol{v} \times \boldsymbol{M}}{G M m}-\boldsymbol{e}_r=\text { const. }
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4444em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol">e</span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:2.0491em;vertical-align:-0.686em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.3631em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.10903em;">GM</span><span class="mord mathnormal">m</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03704em;">v</span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">×</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.11424em;">M</span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.5944em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol">e</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.02778em;">r</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6151em;"></span><span class="mord text"><span class="mord"> const. </span></span></span></span></span></span></p>
</li>
</ol>
]]></description>
            <content:encoded><![CDATA[<h1 id="formulas-for-ipho-日本語版-section-12" tabindex="-1">Formulas for IPhO 日本語版: Section 12 <a class="header-anchor" href="#formulas-for-ipho-日本語版-section-12" aria-label="Permalink to &quot;Formulas for IPhO 日本語版: Section 12&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="_12-kepler-の法則" tabindex="-1">12: Kepler の法則 <a class="header-anchor" href="#_12-kepler-の法則" aria-label="Permalink to &quot;12: Kepler の法則&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="_12-1-f-u" tabindex="-1">12.1: F &amp; U <a class="header-anchor" href="#_12-1-f-u" aria-label="Permalink to &quot;12.1: F &amp; U&quot;">&ZeroWidthSpace;</a></h3>
<ol>
<li><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>F</mi><mo>=</mo><mi>G</mi><mi>M</mi><mi>m</mi><mi mathvariant="normal">/</mi><msup><mi>r</mi><mn>2</mn></msup><mo separator="true">,</mo><mi>U</mi><mo>=</mo><mo>−</mo><mi>G</mi><mi>M</mi><mi>m</mi><mi mathvariant="normal">/</mi><mi>r</mi><mtext>. </mtext></mrow><annotation encoding="application/x-tex">F=G M m / r^2, U=-G M m / r \text {. }</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.13889em;">F</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.0641em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.10903em;">GM</span><span class="mord mathnormal">m</span><span class="mord">/</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.02778em;">r</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.10903em;">U</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">−</span><span class="mord mathnormal" style="margin-right:0.10903em;">GM</span><span class="mord mathnormal">m</span><span class="mord">/</span><span class="mord mathnormal" style="margin-right:0.02778em;">r</span><span class="mord text"><span class="mord">. </span></span></span></span></span></li>
</ol>
<h3 id="_12-2-kepler-の第一法則" tabindex="-1">12.2: Kepler の第一法則 <a class="header-anchor" href="#_12-2-kepler-の第一法則" aria-label="Permalink to &quot;12.2: Kepler の第一法則&quot;">&ZeroWidthSpace;</a></h3>
<ol start="2">
<li>Kepler の第一法則 (2 質点の重力相互作用)：それぞ れの軌道は，系の質量中心に焦点を持つ楕円，双曲線, 放物線になる. これは Runge-Lenz ベクトルから得ら れる (ポイント 9).</li>
</ol>
<h3 id="_12-3-kepler-の第二法則" tabindex="-1">12.3: Kepler の第二法則 <a class="header-anchor" href="#_12-3-kepler-の第二法則" aria-label="Permalink to &quot;12.3: Kepler の第二法則&quot;">&ZeroWidthSpace;</a></h3>
<ol start="3">
<li>Kepler の第二法則（角運動量の保存）: 中心力が働く 場にある質点について，その位置ベクトルは単位時間 に一定の面積を描く.</li>
</ol>
<h3 id="_12-4-kepler-の第三法則" tabindex="-1">12.4: Kepler の第三法則 <a class="header-anchor" href="#_12-4-kepler-の第三法則" aria-label="Permalink to &quot;12.4: Kepler の第三法則&quot;">&ZeroWidthSpace;</a></h3>
<ol start="4">
<li>Kepler の第三法則 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>:</mo><msup><mi>r</mi><mrow><mo>−</mo><mn>2</mn></mrow></msup></mrow><annotation encoding="application/x-tex">: r^{-2}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mrel">:</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8141em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.02778em;">r</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">−</span><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span></span></span> に比例する力が働く場で楕円 軌道を描く複数の質点について, 周期は長半径の <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mfrac><mn>3</mn><mn>2</mn></mfrac></mrow><annotation encoding="application/x-tex">\frac{3}{2}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1901em;vertical-align:-0.345em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8451em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">3</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span> 乗 に比例する :<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><msubsup><mi>T</mi><mn>1</mn><mn>2</mn></msubsup><mi mathvariant="normal">/</mi><msubsup><mi>T</mi><mn>2</mn><mn>2</mn></msubsup><mo>=</mo><msubsup><mi>a</mi><mn>1</mn><mn>3</mn></msubsup><mi mathvariant="normal">/</mi><msubsup><mi>a</mi><mn>2</mn><mn>3</mn></msubsup></mrow><annotation encoding="application/x-tex">T_1^2 / T_2^2=a_1^3 / a_2^3
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1141em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.13889em;">T</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-2.453em;margin-left:-0.1389em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.247em;"><span></span></span></span></span></span></span><span class="mord">/</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.13889em;">T</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-2.453em;margin-left:-0.1389em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.247em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.1141em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-2.453em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">3</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.247em;"><span></span></span></span></span></span></span><span class="mord">/</span><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-2.453em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">3</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.247em;"><span></span></span></span></span></span></span></span></span></span></span></p>
</li>
</ol>
<h3 id="_12-5-楕円軌道" tabindex="-1">12.5: 楕円軌道 <a class="header-anchor" href="#_12-5-楕円軌道" aria-label="Permalink to &quot;12.5: 楕円軌道&quot;">&ZeroWidthSpace;</a></h3>
<ol start="5">
<li>重力場中で楕円軌道を描く質点の全エネルギー <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">(</mo><mi>K</mi><mo>+</mo><mi>U</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">(K+U)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.07153em;">K</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.10903em;">U</span><span class="mclose">)</span></span></span></span> :<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mi>E</mi><mo>=</mo><mo>−</mo><mi>G</mi><mi>M</mi><mi>m</mi><mi mathvariant="normal">/</mi><mn>2</mn><mi>a</mi></mrow><annotation encoding="application/x-tex">E=-G M m / 2 a
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.05764em;">E</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">−</span><span class="mord mathnormal" style="margin-right:0.10903em;">GM</span><span class="mord mathnormal">m</span><span class="mord">/2</span><span class="mord mathnormal">a</span></span></span></span></span></p>
</li>
</ol>
<h3 id="_12-6-楕円率" tabindex="-1">12.6: 楕円率 <a class="header-anchor" href="#_12-6-楕円率" aria-label="Permalink to &quot;12.6: 楕円率&quot;">&ZeroWidthSpace;</a></h3>
<ol>
<li>楕円率が <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ε</mi><mo>=</mo><mi>d</mi><mi mathvariant="normal">/</mi><mi>a</mi><mo>≪</mo><mn>1</mn></mrow><annotation encoding="application/x-tex">\varepsilon=d / a \ll 1</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">ε</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal">d</span><span class="mord">/</span><span class="mord mathnormal">a</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≪</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">1</span></span></span></span> の場合, 軌道は焦点をずらし た円形をしていると考えられる.</li>
</ol>
<h3 id="_12-7-楕円の性質" tabindex="-1">12.7: 楕円の性質 <a class="header-anchor" href="#_12-7-楕円の性質" aria-label="Permalink to &quot;12.7: 楕円の性質&quot;">&ZeroWidthSpace;</a></h3>
<ol start="2">
<li>楕円の性質 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>:</mo><msub><mi>l</mi><mn>1</mn></msub><mo>+</mo><msub><mi>l</mi><mn>2</mn></msub><mo>=</mo><mn>2</mn><mi>a</mi><mtext>（</mtext><msub><mi>l</mi><mn>1</mn></msub></mrow><annotation encoding="application/x-tex">: l_1+l_2=2 a （ l_1</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mrel">:</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8444em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.01968em;">l</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0197em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.8444em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.01968em;">l</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0197em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8444em;vertical-align:-0.15em;"></span><span class="mord">2</span><span class="mord mathnormal">a</span><span class="mord cjk_fallback">（</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.01968em;">l</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0197em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> と <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>l</mi><mn>2</mn></msub></mrow><annotation encoding="application/x-tex">l_2</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8444em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.01968em;">l</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0197em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> は焦点までの距 離). <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>α</mi><mn>1</mn></msub><mo>=</mo><msub><mi>α</mi><mn>2</mn></msub></mrow><annotation encoding="application/x-tex">\alpha_1=\alpha_2</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.0037em;">α</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0037em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.0037em;">α</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0037em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> (一方の焦点から出た光は他方の焦点に 反射する). <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>S</mi><mo>=</mo><mi>π</mi><mi>a</mi><mi>b</mi></mrow><annotation encoding="application/x-tex">S=\pi a b</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.05764em;">S</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">πab</span></span></span></span>.</li>
</ol>
<h3 id="_12-8-円の中心" tabindex="-1">12.8: 円の中心 <a class="header-anchor" href="#_12-8-円の中心" aria-label="Permalink to &quot;12.8: 円の中心&quot;">&ZeroWidthSpace;</a></h3>
<ol start="3">
<li>円とその円の中心に焦点をもつ楕円は長軸の部分での み接する.</li>
</ol>
<h3 id="_12-9-nge-lenz-ベクトル" tabindex="-1">12.9: nge-Lenz ベクトル <Badge type="tip" text="supplemental" /> <a class="header-anchor" href="#_12-9-nge-lenz-ベクトル" aria-label="Permalink to &quot;12.9: nge-Lenz ベクトル &lt;Badge type=&quot;tip&quot; text=&quot;supplemental&quot; /&gt;&quot;">&ZeroWidthSpace;</a></h3>
<ol start="4">
<li>Runge-Lenz ベクトル（楕円率ベクトル）[訳者注：こ のベクトルはむしろ離心率と関係する.そこでここで は離心率ベクトルとして知られるベクトルを代わりに 記す.これは焦点から近日点に向かう向きで，大きさ が離心率 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>e</mi></mrow><annotation encoding="application/x-tex">e</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">e</span></span></span></span> に一致する.]：<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mi mathvariant="bold-italic">e</mi><mo>=</mo><mfrac><mrow><mi mathvariant="bold-italic">v</mi><mo>×</mo><mi mathvariant="bold-italic">M</mi></mrow><mrow><mi>G</mi><mi>M</mi><mi>m</mi></mrow></mfrac><mo>−</mo><msub><mi mathvariant="bold-italic">e</mi><mi>r</mi></msub><mo>=</mo><mtext> const. </mtext></mrow><annotation encoding="application/x-tex">\boldsymbol{e}=\frac{\boldsymbol{v} \times \boldsymbol{M}}{G M m}-\boldsymbol{e}_r=\text { const. }
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4444em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol">e</span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:2.0491em;vertical-align:-0.686em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.3631em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.10903em;">GM</span><span class="mord mathnormal">m</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03704em;">v</span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">×</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.11424em;">M</span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.5944em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol">e</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.02778em;">r</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6151em;"></span><span class="mord text"><span class="mord"> const. </span></span></span></span></span></span></p>
</li>
</ol>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Formulas for IPhO 日本語版: Section 13 ]]></title>
            <link>https://note.toshiki.devacademic/physics/ipho-formulas-jpn/13</link>
            <guid>https://note.toshiki.devacademic/physics/ipho-formulas-jpn/13</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="formulas-for-ipho-日本語版-section-13" tabindex="-1">Formulas for IPhO 日本語版: Section 13 <a class="header-anchor" href="#formulas-for-ipho-日本語版-section-13" aria-label="Permalink to &quot;Formulas for IPhO 日本語版: Section 13&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="_13-相対性理論" tabindex="-1">13: 相対性理論 <a class="header-anchor" href="#_13-相対性理論" aria-label="Permalink to &quot;13: 相対性理論&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="_13-1-lorentz-変換" tabindex="-1">13.1:Lorentz 変換 <a class="header-anchor" href="#_13-1-lorentz-変換" aria-label="Permalink to &quot;13.1:Lorentz 変換&quot;">&ZeroWidthSpace;</a></h3>
<ol>
<li>
<p>Lorentz 変換 (Minkowski 幾何学の 4 次元時空の回 転）(慣性系間の速度が <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mrow><mi mathvariant="bold-italic">V</mi><mo>=</mo><mi>V</mi><msub><mi mathvariant="bold-italic">e</mi><mi>x</mi></msub><mo fence="true">)</mo></mrow><mo>:</mo><mi>β</mi><mo>=</mo><mi>V</mi><mi mathvariant="normal">/</mi><mi>c</mi><mo separator="true">,</mo><mi>γ</mi><mo>=</mo></mrow><annotation encoding="application/x-tex">\left.\boldsymbol{V}=V \boldsymbol{e}_x\right): \beta=V / c, \gamma=</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="minner"><span class="mopen nulldelimiter"></span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.25555em;">V</span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord mathnormal" style="margin-right:0.22222em;">V</span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol">e</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">x</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">)</span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">:</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.05278em;">β</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.22222em;">V</span><span class="mord">/</span><span class="mord mathnormal">c</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.05556em;">γ</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span></span></span></span></p>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mtable rowspacing="0.25em" columnalign="right left" columnspacing="0em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mn>1</mn><mi mathvariant="normal">/</mi><msqrt><mrow><mn>1</mn><mo>−</mo><msup><mi>β</mi><mn>2</mn></msup></mrow></msqrt><mtext> として, </mtext></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mspace width="2em"/><mi>c</mi><msup><mi>t</mi><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup><mo>=</mo><mi>γ</mi><mo stretchy="false">(</mo><mi>c</mi><mi>t</mi><mo>−</mo><mi>β</mi><mi>x</mi><mo stretchy="false">)</mo><mo separator="true">,</mo><msup><mi>x</mi><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup><mo>=</mo><mi>γ</mi><mo stretchy="false">(</mo><mi>x</mi><mo>−</mo><mi>β</mi><mi>c</mi><mi>t</mi><mo stretchy="false">)</mo><mo separator="true">,</mo><msup><mi>y</mi><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup><mo>=</mo><mi>y</mi></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><msup><mi>E</mi><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup><mi mathvariant="normal">/</mi><mi>c</mi><mo>=</mo><mi>γ</mi><mrow><mo fence="true">(</mo><mi>E</mi><mi mathvariant="normal">/</mi><mi>c</mi><mo>−</mo><mi>β</mi><msub><mi>p</mi><mi>x</mi></msub><mo fence="true">)</mo></mrow><mo separator="true">,</mo><msubsup><mi>p</mi><mi>x</mi><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msubsup><mo>=</mo><mi>γ</mi><mrow><mo fence="true">(</mo><msub><mi>p</mi><mi>x</mi></msub><mo>−</mo><mi>β</mi><mi>E</mi><mi mathvariant="normal">/</mi><mi>c</mi><mo fence="true">)</mo></mrow><mo separator="true">,</mo><msubsup><mi>p</mi><mi>y</mi><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msubsup><mo>=</mo><msub><mi>p</mi><mi>y</mi></msub></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mtext> ここで, </mtext></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mi>E</mi><mo>=</mo><mfrac><mrow><mi>m</mi><msup><mi>c</mi><mn>2</mn></msup></mrow><msqrt><mrow><mn>1</mn><mo>−</mo><msup><mi>v</mi><mn>2</mn></msup><mi mathvariant="normal">/</mi><msup><mi>c</mi><mn>2</mn></msup></mrow></msqrt></mfrac><mo>=</mo><mi>m</mi><msup><mi>c</mi><mn>2</mn></msup><mo>+</mo><mfrac><mn>1</mn><mn>2</mn></mfrac><mi>m</mi><msup><mi>v</mi><mn>2</mn></msup><mo>+</mo><mo>⋯</mo></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><msub><mi>p</mi><mi>x</mi></msub><mo>=</mo><mfrac><mrow><mi>m</mi><msub><mi>v</mi><mi>x</mi></msub></mrow><msqrt><mrow><mn>1</mn><mo>−</mo><msup><mi>v</mi><mn>2</mn></msup><mi mathvariant="normal">/</mi><msup><mi>c</mi><mn>2</mn></msup></mrow></msqrt></mfrac><mo separator="true">,</mo><mtext> etc. </mtext></mrow></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{aligned}
&amp; 1 / \sqrt{1-\beta^2} \text { として, } \\
&amp; \qquad c t^{\prime}=\gamma(c t-\beta x), x^{\prime}=\gamma(x-\beta c t), y^{\prime}=y \\
&amp; E^{\prime} / c=\gamma\left(E / c-\beta p_x\right), p_x^{\prime}=\gamma\left(p_x-\beta E / c\right), p_y^{\prime}=p_y \\
&amp; \text { ここで, } \\
&amp; E=\frac{m c^2}{\sqrt{1-v^2 / c^2}}=m c^2+\frac{1}{2} m v^2+\cdots \\
&amp; p_x=\frac{m v_x}{\sqrt{1-v^2 / c^2}}, \text { etc. }
\end{aligned}
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:11.6485em;vertical-align:-5.5742em;"></span><span class="mord"><span class="mtable"><span class="col-align-r"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:6.0742em;"><span style="top:-8.5586em;"><span class="pstrut" style="height:3.4911em;"></span><span class="mord"></span></span><span style="top:-7.0586em;"><span class="pstrut" style="height:3.4911em;"></span><span class="mord"></span></span><span style="top:-5.5586em;"><span class="pstrut" style="height:3.4911em;"></span><span class="mord"></span></span><span style="top:-4.0355em;"><span class="pstrut" style="height:3.4911em;"></span><span class="mord"></span></span><span style="top:-1.8844em;"><span class="pstrut" style="height:3.4911em;"></span><span class="mord"></span></span><span style="top:0.6531em;"><span class="pstrut" style="height:3.4911em;"></span><span class="mord"></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:5.5742em;"><span></span></span></span></span></span><span class="col-align-l"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:6.0742em;"><span style="top:-8.5586em;"><span class="pstrut" style="height:3.4911em;"></span><span class="mord"><span class="mord"></span><span class="mord">1/</span><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.0067em;"><span class="svg-align" style="top:-3.2em;"><span class="pstrut" style="height:3.2em;"></span><span class="mord" style="padding-left:1em;"><span class="mord">1</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.05278em;">β</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7401em;"><span style="top:-2.989em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span><span style="top:-2.9667em;"><span class="pstrut" style="height:3.2em;"></span><span class="hide-tail" style="min-width:1.02em;height:1.28em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='1.28em' viewBox='0 0 400000 1296' preserveAspectRatio='xMinYMin slice'><path d='M263,681c0.7,0,18,39.7,52,119
c34,79.3,68.167,158.7,102.5,238c34.3,79.3,51.8,119.3,52.5,120
c340,-704.7,510.7,-1060.3,512,-1067
l0 -0
c4.7,-7.3,11,-11,19,-11
H40000v40H1012.3
s-271.3,567,-271.3,567c-38.7,80.7,-84,175,-136,283c-52,108,-89.167,185.3,-111.5,232
c-22.3,46.7,-33.8,70.3,-34.5,71c-4.7,4.7,-12.3,7,-23,7s-12,-1,-12,-1
s-109,-253,-109,-253c-72.7,-168,-109.3,-252,-110,-252c-10.7,8,-22,16.7,-34,26
c-22,17.3,-33.3,26,-34,26s-26,-26,-26,-26s76,-59,76,-59s76,-60,76,-60z
M1001 80h400000v40h-400000z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2333em;"><span></span></span></span></span></span><span class="mord text"><span class="mord"> </span><span class="mord cjk_fallback">として</span><span class="mord">, </span></span></span></span><span style="top:-7.0586em;"><span class="pstrut" style="height:3.4911em;"></span><span class="mord"><span class="mord"></span><span class="mspace" style="margin-right:2em;"></span><span class="mord mathnormal">c</span><span class="mord"><span class="mord mathnormal">t</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8019em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord mathnormal" style="margin-right:0.05556em;">γ</span><span class="mopen">(</span><span class="mord mathnormal">c</span><span class="mord mathnormal">t</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal" style="margin-right:0.05278em;">β</span><span class="mord mathnormal">x</span><span class="mclose">)</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8019em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord mathnormal" style="margin-right:0.05556em;">γ</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal" style="margin-right:0.05278em;">β</span><span class="mord mathnormal">c</span><span class="mord mathnormal">t</span><span class="mclose">)</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">y</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8019em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">y</span></span></span><span style="top:-5.5586em;"><span class="pstrut" style="height:3.4911em;"></span><span class="mord"><span class="mord"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.05764em;">E</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8019em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span><span class="mord">/</span><span class="mord mathnormal">c</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord mathnormal" style="margin-right:0.05556em;">γ</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord mathnormal" style="margin-right:0.05764em;">E</span><span class="mord">/</span><span class="mord mathnormal">c</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal" style="margin-right:0.05278em;">β</span><span class="mord"><span class="mord mathnormal">p</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">x</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">)</span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal">p</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8019em;"><span style="top:-2.453em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">x</span></span></span><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.247em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord mathnormal" style="margin-right:0.05556em;">γ</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord"><span class="mord mathnormal">p</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">x</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal" style="margin-right:0.05764em;">βE</span><span class="mord">/</span><span class="mord mathnormal">c</span><span class="mclose delimcenter" style="top:0em;">)</span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal">p</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8019em;"><span style="top:-2.453em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.03588em;">y</span></span></span><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.3831em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mord mathnormal">p</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.03588em;">y</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span></span></span><span style="top:-4.0355em;"><span class="pstrut" style="height:3.4911em;"></span><span class="mord"><span class="mord"></span><span class="mord text"><span class="mord"> </span><span class="mord cjk_fallback">ここで</span><span class="mord">, </span></span></span></span><span style="top:-1.8844em;"><span class="pstrut" style="height:3.4911em;"></span><span class="mord"><span class="mord"></span><span class="mord mathnormal" style="margin-right:0.05764em;">E</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.4911em;"><span style="top:-2.175em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.935em;"><span class="svg-align" style="top:-3.2em;"><span class="pstrut" style="height:3.2em;"></span><span class="mord" style="padding-left:1em;"><span class="mord">1</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7401em;"><span style="top:-2.989em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mord">/</span><span class="mord"><span class="mord mathnormal">c</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7401em;"><span style="top:-2.989em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span><span style="top:-2.895em;"><span class="pstrut" style="height:3.2em;"></span><span class="hide-tail" style="min-width:1.02em;height:1.28em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='1.28em' viewBox='0 0 400000 1296' preserveAspectRatio='xMinYMin slice'><path d='M263,681c0.7,0,18,39.7,52,119
c34,79.3,68.167,158.7,102.5,238c34.3,79.3,51.8,119.3,52.5,120
c340,-704.7,510.7,-1060.3,512,-1067
l0 -0
c4.7,-7.3,11,-11,19,-11
H40000v40H1012.3
s-271.3,567,-271.3,567c-38.7,80.7,-84,175,-136,283c-52,108,-89.167,185.3,-111.5,232
c-22.3,46.7,-33.8,70.3,-34.5,71c-4.7,4.7,-12.3,7,-23,7s-12,-1,-12,-1
s-109,-253,-109,-253c-72.7,-168,-109.3,-252,-110,-252c-10.7,8,-22,16.7,-34,26
c-22,17.3,-33.3,26,-34,26s-26,-26,-26,-26s76,-59,76,-59s76,-60,76,-60z
M1001 80h400000v40h-400000z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.305em;"><span></span></span></span></span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">m</span><span class="mord"><span class="mord mathnormal">c</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.13em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord mathnormal">m</span><span class="mord"><span class="mord mathnormal">c</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.3214em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">2</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mord mathnormal">m</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="minner">⋯</span></span></span><span style="top:0.6531em;"><span class="pstrut" style="height:3.4911em;"></span><span class="mord"><span class="mord"></span><span class="mord"><span class="mord mathnormal">p</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">x</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1076em;"><span style="top:-2.175em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.935em;"><span class="svg-align" style="top:-3.2em;"><span class="pstrut" style="height:3.2em;"></span><span class="mord" style="padding-left:1em;"><span class="mord">1</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7401em;"><span style="top:-2.989em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mord">/</span><span class="mord"><span class="mord mathnormal">c</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7401em;"><span style="top:-2.989em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span><span style="top:-2.895em;"><span class="pstrut" style="height:3.2em;"></span><span class="hide-tail" style="min-width:1.02em;height:1.28em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='1.28em' viewBox='0 0 400000 1296' preserveAspectRatio='xMinYMin slice'><path d='M263,681c0.7,0,18,39.7,52,119
c34,79.3,68.167,158.7,102.5,238c34.3,79.3,51.8,119.3,52.5,120
c340,-704.7,510.7,-1060.3,512,-1067
l0 -0
c4.7,-7.3,11,-11,19,-11
H40000v40H1012.3
s-271.3,567,-271.3,567c-38.7,80.7,-84,175,-136,283c-52,108,-89.167,185.3,-111.5,232
c-22.3,46.7,-33.8,70.3,-34.5,71c-4.7,4.7,-12.3,7,-23,7s-12,-1,-12,-1
s-109,-253,-109,-253c-72.7,-168,-109.3,-252,-110,-252c-10.7,8,-22,16.7,-34,26
c-22,17.3,-33.3,26,-34,26s-26,-26,-26,-26s76,-59,76,-59s76,-60,76,-60z
M1001 80h400000v40h-400000z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.305em;"><span></span></span></span></span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">m</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">x</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.13em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord text"><span class="mord"> etc. </span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:5.5742em;"><span></span></span></span></span></span></span></span></span></span></span></span></p>
</li>
</ol>
<h3 id="_13-2-4-元ベクトルの長" tabindex="-1">13.2: 4 元ベクトルの長 <a class="header-anchor" href="#_13-2-4-元ベクトルの長" aria-label="Permalink to &quot;13.2: 4 元ベクトルの長&quot;">&ZeroWidthSpace;</a></h3>
<ol start="2">
<li>4 元ベクトルの長さ (スカラー量であり Lorentz 変換 で不変）:<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mtable rowspacing="0.25em" columnalign="right left" columnspacing="0em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><msup><mi>s</mi><mn>2</mn></msup></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mo>=</mo><mo stretchy="false">(</mo><mi>c</mi><mi>t</mi><msup><mo stretchy="false">)</mo><mn>2</mn></msup><mo>−</mo><msup><mi>x</mi><mn>2</mn></msup><mo>−</mo><msup><mi>y</mi><mn>2</mn></msup><mo>−</mo><msup><mi>z</mi><mn>2</mn></msup></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mo stretchy="false">(</mo><mi>m</mi><mi>c</mi><msup><mo stretchy="false">)</mo><mn>2</mn></msup></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mo>=</mo><mo stretchy="false">(</mo><mi>E</mi><mi mathvariant="normal">/</mi><mi>c</mi><msup><mo stretchy="false">)</mo><mn>2</mn></msup><mo>−</mo><msubsup><mi>p</mi><mi>x</mi><mn>2</mn></msubsup><mo>−</mo><msubsup><mi>p</mi><mi>y</mi><mn>2</mn></msubsup><mo>−</mo><msubsup><mi>p</mi><mi>z</mi><mn>2</mn></msubsup></mrow></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{aligned}
s^2 &amp; =(c t)^2-x^2-y^2-z^2 \\
(m c)^2 &amp; =(E / c)^2-p_x^2-p_y^2-p_z^2
\end{aligned}
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:3.0713em;vertical-align:-1.2857em;"></span><span class="mord"><span class="mtable"><span class="col-align-r"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.7857em;"><span style="top:-3.9216em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"><span class="mord mathnormal">s</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span><span style="top:-2.3974em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mopen">(</span><span class="mord mathnormal">m</span><span class="mord mathnormal">c</span><span class="mclose"><span class="mclose">)</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.2857em;"><span></span></span></span></span></span><span class="col-align-l"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.7857em;"><span style="top:-3.9216em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mopen">(</span><span class="mord mathnormal">c</span><span class="mord mathnormal">t</span><span class="mclose"><span class="mclose">)</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">y</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.04398em;">z</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span><span style="top:-2.3974em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.05764em;">E</span><span class="mord">/</span><span class="mord mathnormal">c</span><span class="mclose"><span class="mclose">)</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal">p</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-2.453em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">x</span></span></span><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.247em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal">p</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-2.453em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.03588em;">y</span></span></span><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.3831em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal">p</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-2.453em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.04398em;">z</span></span></span><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.247em;"><span></span></span></span></span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.2857em;"><span></span></span></span></span></span></span></span></span></span></span></span></p>
</li>
</ol>
<h3 id="_13-3-速度の加算" tabindex="-1">13.3: 速度の加算 <a class="header-anchor" href="#_13-3-速度の加算" aria-label="Permalink to &quot;13.3: 速度の加算&quot;">&ZeroWidthSpace;</a></h3>
<ol start="3">
<li>速度の加算 :<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><msub><mi>v</mi><mi>x</mi></msub><mo>=</mo><mfrac><mrow><msubsup><mi>v</mi><mi>x</mi><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msubsup><mo>+</mo><mi>V</mi></mrow><mrow><mn>1</mn><mo>+</mo><msubsup><mi>v</mi><mi>x</mi><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msubsup><mi>V</mi><mi mathvariant="normal">/</mi><msup><mi>c</mi><mn>2</mn></msup></mrow></mfrac><mo separator="true">,</mo><msub><mi>v</mi><mi>y</mi></msub><mo>=</mo><mfrac><msubsup><mi>v</mi><mi>y</mi><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msubsup><mrow><mi>γ</mi><mrow><mo fence="true">(</mo><mn>1</mn><mo>+</mo><msubsup><mi>v</mi><mi>x</mi><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msubsup><mi>V</mi><mi mathvariant="normal">/</mi><msup><mi>c</mi><mn>2</mn></msup><mo fence="true">)</mo></mrow></mrow></mfrac></mrow><annotation encoding="application/x-tex">v_x=\frac{v_x^{\prime}+V}{1+v_x^{\prime} V / c^2}, v_y=\frac{v_y^{\prime}}{\gamma\left(1+v_x^{\prime} V / c^2\right)}
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">x</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:2.3649em;vertical-align:-0.936em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.4289em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">1</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6779em;"><span style="top:-2.453em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">x</span></span></span><span style="top:-2.989em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.247em;"><span></span></span></span></span></span></span><span class="mord mathnormal" style="margin-right:0.22222em;">V</span><span class="mord">/</span><span class="mord"><span class="mord mathnormal">c</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7401em;"><span style="top:-2.989em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.7519em;"><span style="top:-2.453em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">x</span></span></span><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.247em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal" style="margin-right:0.22222em;">V</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.936em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.03588em;">y</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:2.461em;vertical-align:-0.936em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.525em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.05556em;">γ</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord">1</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6779em;"><span style="top:-2.453em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">x</span></span></span><span style="top:-2.989em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.247em;"><span></span></span></span></span></span></span><span class="mord mathnormal" style="margin-right:0.22222em;">V</span><span class="mord">/</span><span class="mord"><span class="mord mathnormal">c</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7401em;"><span style="top:-2.989em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">)</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.7731em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.7519em;"><span style="top:-2.453em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.03588em;">y</span></span></span><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.3831em;"><span></span></span></span></span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.936em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span></span></p>
</li>
</ol>
<h3 id="_13-4-doppler-効果" tabindex="-1">13.4: Doppler 効果 <a class="header-anchor" href="#_13-4-doppler-効果" aria-label="Permalink to &quot;13.4: Doppler 効果&quot;">&ZeroWidthSpace;</a></h3>
<ol start="4">
<li>Doppler 効果 :<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mi>ν</mi><mo>=</mo><mi>γ</mi><mo stretchy="false">(</mo><mn>1</mn><mo>+</mo><mi>β</mi><mi>cos</mi><mo>⁡</mo><mi>θ</mi><mo stretchy="false">)</mo><msub><mi>ν</mi><mn>0</mn></msub></mrow><annotation encoding="application/x-tex">\nu=\gamma(1+\beta \cos \theta) \nu_0
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal" style="margin-right:0.06366em;">ν</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.05556em;">γ</span><span class="mopen">(</span><span class="mord">1</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.05278em;">β</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">cos</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.02778em;">θ</span><span class="mclose">)</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.06366em;">ν</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0637em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">0</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span></span></p>
</li>
</ol>
<h3 id="_13-5-minkowski-空間" tabindex="-1">13.5: Minkowski 空間 <a class="header-anchor" href="#_13-5-minkowski-空間" aria-label="Permalink to &quot;13.5: Minkowski 空間&quot;">&ZeroWidthSpace;</a></h3>
<ol start="5">
<li>Minkowski 空間は, 時間が虚数（ <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">(</mo><mi>t</mi><mi>i</mi><mi>c</mi><mi>t</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">(t i c t)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">(</span><span class="mord mathnormal">t</span><span class="mord mathnormal">i</span><span class="mord mathnormal">c</span><span class="mord mathnormal">t</span><span class="mclose">)</span></span></span></span> であれば Euclid 空間にすることができる. 回転角 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>φ</mi></mrow><annotation encoding="application/x-tex">\varphi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">φ</span></span></span></span> に対して, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>tan</mi><mo>⁡</mo><mi>φ</mi><mo>=</mo><mi>v</mi><mi mathvariant="normal">/</mi><mi>i</mi><mi>c</mi></mrow><annotation encoding="application/x-tex">\tan \varphi=v / i c</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8095em;vertical-align:-0.1944em;"></span><span class="mop">tan</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">φ</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="mord">/</span><span class="mord mathnormal">i</span><span class="mord mathnormal">c</span></span></span></span> となり, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>sin</mi><mo>⁡</mo><mi>φ</mi><mo separator="true">,</mo><mi>cos</mi><mo>⁡</mo><mi>φ</mi></mrow><annotation encoding="application/x-tex">\sin \varphi, \cos \varphi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8623em;vertical-align:-0.1944em;"></span><span class="mop">sin</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">φ</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">cos</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">φ</span></span></span></span> を <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>tan</mi><mo>⁡</mo><mi>φ</mi></mrow><annotation encoding="application/x-tex">\tan \varphi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8095em;vertical-align:-0.1944em;"></span><span class="mop">tan</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">φ</span></span></span></span> で表して Euclid 幾何学の公式を適用する (Lorentz 変換).</li>
</ol>
<h3 id="_13-6-長さの縮み" tabindex="-1">13.6: 長さの縮み <a class="header-anchor" href="#_13-6-長さの縮み" aria-label="Permalink to &quot;13.6: 長さの縮み&quot;">&ZeroWidthSpace;</a></h3>
<ol start="6">
<li>長さの縮み : <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msup><mi>l</mi><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup><mo>=</mo><msub><mi>l</mi><mn>0</mn></msub><mi mathvariant="normal">/</mi><mi>γ</mi></mrow><annotation encoding="application/x-tex">l^{\prime}=l_0 / \gamma</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7519em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.01968em;">l</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7519em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.01968em;">l</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0197em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">0</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord">/</span><span class="mord mathnormal" style="margin-right:0.05556em;">γ</span></span></span></span>.</li>
</ol>
<h3 id="_13-7-時間の遅れ" tabindex="-1">13.7: 時間の遅れ <a class="header-anchor" href="#_13-7-時間の遅れ" aria-label="Permalink to &quot;13.7: 時間の遅れ&quot;">&ZeroWidthSpace;</a></h3>
<ol start="7">
<li>時間の遅れ: <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msup><mi>t</mi><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup><mo>=</mo><msub><mi>t</mi><mn>0</mn></msub><mi>γ</mi></mrow><annotation encoding="application/x-tex">t^{\prime}=t_0 \gamma</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7519em;"></span><span class="mord"><span class="mord mathnormal">t</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7519em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8095em;vertical-align:-0.1944em;"></span><span class="mord"><span class="mord mathnormal">t</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">0</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord mathnormal" style="margin-right:0.05556em;">γ</span></span></span></span>.</li>
</ol>
<h3 id="_13-8-同時刻の相対性" tabindex="-1">13.8: 同時刻の相対性 <a class="header-anchor" href="#_13-8-同時刻の相対性" aria-label="Permalink to &quot;13.8: 同時刻の相対性&quot;">&ZeroWidthSpace;</a></h3>
<ol start="8">
<li>同時刻の相対性 : <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Δ</mi><mi>t</mi><mo>=</mo><mo>−</mo><mi>γ</mi><mi>v</mi><mi mathvariant="normal">Δ</mi><mi>x</mi><mi mathvariant="normal">/</mi><msup><mi>c</mi><mn>2</mn></msup></mrow><annotation encoding="application/x-tex">\Delta t=-\gamma v \Delta x / c^2</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">Δ</span><span class="mord mathnormal">t</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.0641em;vertical-align:-0.25em;"></span><span class="mord">−</span><span class="mord mathnormal" style="margin-right:0.05556em;">γ</span><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="mord">Δ</span><span class="mord mathnormal">x</span><span class="mord">/</span><span class="mord"><span class="mord mathnormal">c</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span></span>.</li>
</ol>
<h3 id="_13-9-f-dp-dt" tabindex="-1">13.9: F=dp/dt <a class="header-anchor" href="#_13-9-f-dp-dt" aria-label="Permalink to &quot;13.9: F=dp/dt&quot;">&ZeroWidthSpace;</a></h3>
<ol start="9">
<li><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="bold-italic">F</mi><mo>=</mo><mi mathvariant="normal">d</mi><mi mathvariant="bold-italic">p</mi><mi mathvariant="normal">/</mi><mi mathvariant="normal">d</mi><mi>t</mi><mrow><mo fence="true">(</mo><mo>=</mo><mfrac><mi mathvariant="normal">d</mi><mrow><mi mathvariant="normal">d</mi><mi>t</mi></mrow></mfrac><mo stretchy="false">(</mo><mi>γ</mi><mi>m</mi><mi mathvariant="bold-italic">v</mi><mo stretchy="false">)</mo><mo fence="true">)</mo></mrow><mo stretchy="false">(</mo></mrow><annotation encoding="application/x-tex">\boldsymbol{F}=\mathrm{d} \boldsymbol{p} / \mathrm{d} t\left(=\frac{\mathrm{d}}{\mathrm{d} t}(\gamma m \boldsymbol{v})\right)(</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6861em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.15972em;">F</span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.2301em;vertical-align:-0.35em;"></span><span class="mord mathrm">d</span><span class="mord"><span class="mord"><span class="mord boldsymbol">p</span></span></span><span class="mord">/</span><span class="mord mathrm">d</span><span class="mord mathnormal">t</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size1">(</span></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8801em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathrm mtight">d</span><span class="mord mathnormal mtight">t</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathrm mtight">d</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mopen">(</span><span class="mord mathnormal">γm</span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03704em;">v</span></span></span><span class="mclose">)</span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size1">)</span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mopen">(</span></span></span></span> ここでの <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>γ</mi><mo>=</mo></mrow><annotation encoding="application/x-tex">\gamma=</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.05556em;">γ</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span></span></span></span> <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>1</mn><mi mathvariant="normal">/</mi><msqrt><mrow><mn>1</mn><mo>−</mo><msup><mi>v</mi><mn>2</mn></msup><mi mathvariant="normal">/</mi><msup><mi>c</mi><mn>2</mn></msup></mrow></msqrt><mo fence="true">)</mo></mrow><annotation encoding="application/x-tex">\left.1 / \sqrt{1-v^2 / c^2}\right)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.8em;vertical-align:-0.65em;"></span><span class="minner"><span class="mopen nulldelimiter"></span><span class="mord">1/</span><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.935em;"><span class="svg-align" style="top:-3.2em;"><span class="pstrut" style="height:3.2em;"></span><span class="mord" style="padding-left:1em;"><span class="mord">1</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7401em;"><span style="top:-2.989em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mord">/</span><span class="mord"><span class="mord mathnormal">c</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7401em;"><span style="top:-2.989em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span><span style="top:-2.895em;"><span class="pstrut" style="height:3.2em;"></span><span class="hide-tail" style="min-width:1.02em;height:1.28em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='1.28em' viewBox='0 0 400000 1296' preserveAspectRatio='xMinYMin slice'><path d='M263,681c0.7,0,18,39.7,52,119
c34,79.3,68.167,158.7,102.5,238c34.3,79.3,51.8,119.3,52.5,120
c340,-704.7,510.7,-1060.3,512,-1067
l0 -0
c4.7,-7.3,11,-11,19,-11
H40000v40H1012.3
s-271.3,567,-271.3,567c-38.7,80.7,-84,175,-136,283c-52,108,-89.167,185.3,-111.5,232
c-22.3,46.7,-33.8,70.3,-34.5,71c-4.7,4.7,-12.3,7,-23,7s-12,-1,-12,-1
s-109,-253,-109,-253c-72.7,-168,-109.3,-252,-110,-252c-10.7,8,-22,16.7,-34,26
c-22,17.3,-33.3,26,-34,26s-26,-26,-26,-26s76,-59,76,-59s76,-60,76,-60z
M1001 80h400000v40h-400000z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.305em;"><span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size2">)</span></span></span></span></span></span></li>
</ol>
<h3 id="_13-10-超相対論的極限" tabindex="-1">13.10: 超相対論的極限 <a class="header-anchor" href="#_13-10-超相対論的極限" aria-label="Permalink to &quot;13.10: 超相対論的極限&quot;">&ZeroWidthSpace;</a></h3>
<ol start="10">
<li>超相対論的極限 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>:</mo><mi>v</mi><mo>≈</mo><mi>c</mi><mo separator="true">,</mo><mi>p</mi><mo>≈</mo><mi>m</mi><mi>c</mi><mo separator="true">,</mo><msqrt><mrow><mn>1</mn><mo>−</mo><mo stretchy="false">(</mo><mi>v</mi><mi mathvariant="normal">/</mi><mi>c</mi><msup><mo stretchy="false">)</mo><mn>2</mn></msup></mrow></msqrt><mo>≈</mo></mrow><annotation encoding="application/x-tex">: v \approx c, p \approx m c, \sqrt{1-(v / c)^2} \approx</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mrel">:</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.4831em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≈</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6776em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">c</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">p</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≈</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.24em;vertical-align:-0.305em;"></span><span class="mord mathnormal">m</span><span class="mord mathnormal">c</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.935em;"><span class="svg-align" style="top:-3.2em;"><span class="pstrut" style="height:3.2em;"></span><span class="mord" style="padding-left:1em;"><span class="mord">1</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="mord">/</span><span class="mord mathnormal">c</span><span class="mclose"><span class="mclose">)</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7401em;"><span style="top:-2.989em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span><span style="top:-2.895em;"><span class="pstrut" style="height:3.2em;"></span><span class="hide-tail" style="min-width:1.02em;height:1.28em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='1.28em' viewBox='0 0 400000 1296' preserveAspectRatio='xMinYMin slice'><path d='M263,681c0.7,0,18,39.7,52,119
c34,79.3,68.167,158.7,102.5,238c34.3,79.3,51.8,119.3,52.5,120
c340,-704.7,510.7,-1060.3,512,-1067
l0 -0
c4.7,-7.3,11,-11,19,-11
H40000v40H1012.3
s-271.3,567,-271.3,567c-38.7,80.7,-84,175,-136,283c-52,108,-89.167,185.3,-111.5,232
c-22.3,46.7,-33.8,70.3,-34.5,71c-4.7,4.7,-12.3,7,-23,7s-12,-1,-12,-1
s-109,-253,-109,-253c-72.7,-168,-109.3,-252,-110,-252c-10.7,8,-22,16.7,-34,26
c-22,17.3,-33.3,26,-34,26s-26,-26,-26,-26s76,-59,76,-59s76,-60,76,-60z
M1001 80h400000v40h-400000z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.305em;"><span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≈</span></span></span></span> <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msqrt><mrow><mn>2</mn><mo stretchy="false">(</mo><mn>1</mn><mo>−</mo><mi>v</mi><mi mathvariant="normal">/</mi><mi>c</mi><mo stretchy="false">)</mo></mrow></msqrt></mrow><annotation encoding="application/x-tex">\sqrt{2(1-v / c)}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.24em;vertical-align:-0.305em;"></span><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.935em;"><span class="svg-align" style="top:-3.2em;"><span class="pstrut" style="height:3.2em;"></span><span class="mord" style="padding-left:1em;"><span class="mord">2</span><span class="mopen">(</span><span class="mord">1</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="mord">/</span><span class="mord mathnormal">c</span><span class="mclose">)</span></span></span><span style="top:-2.895em;"><span class="pstrut" style="height:3.2em;"></span><span class="hide-tail" style="min-width:1.02em;height:1.28em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='1.28em' viewBox='0 0 400000 1296' preserveAspectRatio='xMinYMin slice'><path d='M263,681c0.7,0,18,39.7,52,119
c34,79.3,68.167,158.7,102.5,238c34.3,79.3,51.8,119.3,52.5,120
c340,-704.7,510.7,-1060.3,512,-1067
l0 -0
c4.7,-7.3,11,-11,19,-11
H40000v40H1012.3
s-271.3,567,-271.3,567c-38.7,80.7,-84,175,-136,283c-52,108,-89.167,185.3,-111.5,232
c-22.3,46.7,-33.8,70.3,-34.5,71c-4.7,4.7,-12.3,7,-23,7s-12,-1,-12,-1
s-109,-253,-109,-253c-72.7,-168,-109.3,-252,-110,-252c-10.7,8,-22,16.7,-34,26
c-22,17.3,-33.3,26,-34,26s-26,-26,-26,-26s76,-59,76,-59s76,-60,76,-60z
M1001 80h400000v40h-400000z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.305em;"><span></span></span></span></span></span></span></span></span></li>
</ol>
<h3 id="_13-11-電場と磁場の-lorentz-変換" tabindex="-1">13.11: 電場と磁場の Lorentz 変換 <Badge type="tip" text="supplemental" /> <a class="header-anchor" href="#_13-11-電場と磁場の-lorentz-変換" aria-label="Permalink to &quot;13.11: 電場と磁場の Lorentz 変換 &lt;Badge type=&quot;tip&quot; text=&quot;supplemental&quot; /&gt;&quot;">&ZeroWidthSpace;</a></h3>
<ol start="11">
<li>電場と磁場の Lorentz 変換 : <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msubsup><mi mathvariant="bold-italic">E</mi><mi mathvariant="normal">∥</mi><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msubsup><mo>=</mo><msub><mi mathvariant="bold-italic">E</mi><mi mathvariant="normal">∥</mi></msub><mo separator="true">,</mo><msubsup><mi mathvariant="bold-italic">B</mi><mi mathvariant="normal">∥</mi><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msubsup><mo>=</mo><msub><mi mathvariant="bold-italic">B</mi><mi mathvariant="normal">∥</mi></msub></mrow><annotation encoding="application/x-tex">\boldsymbol{E}_{\|}^{\prime}=\boldsymbol{E}_{\|}, \boldsymbol{B}_{\|}^{\prime}=\boldsymbol{B}_{\|}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2499em;vertical-align:-0.422em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.05451em;">E</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8279em;"><span style="top:-2.453em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">∥</span></span></span></span><span style="top:-3.139em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.422em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.2499em;vertical-align:-0.422em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.05451em;">E</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3448em;"><span style="top:-2.5198em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">∥</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.3552em;"><span></span></span></span></span></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.04835em;">B</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8279em;"><span style="top:-2.453em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">∥</span></span></span></span><span style="top:-3.139em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.422em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.0413em;vertical-align:-0.3552em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.04835em;">B</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3448em;"><span style="top:-2.5198em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">∥</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.3552em;"><span></span></span></span></span></span></span></span></span></span>,<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mtable rowspacing="0.25em" columnalign="center" columnspacing="0em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><msubsup><mi mathvariant="bold-italic">E</mi><mo lspace="0em" rspace="0em">⊥</mo><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msubsup><mi mathvariant="normal">/</mi><mi>c</mi><mo>=</mo><mi>γ</mi><mrow><mo fence="true">(</mo><msub><mi mathvariant="bold-italic">E</mi><mo lspace="0em" rspace="0em">⊥</mo></msub><mi mathvariant="normal">/</mi><mi>c</mi><mo>+</mo><mi mathvariant="bold-italic">v</mi><mi mathvariant="normal">/</mi><mi>c</mi><mo>×</mo><msub><mi mathvariant="bold-italic">B</mi><mo lspace="0em" rspace="0em">⊥</mo></msub><mo fence="true">)</mo></mrow><mo separator="true">,</mo></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><msubsup><mi mathvariant="bold-italic">B</mi><mo lspace="0em" rspace="0em">⊥</mo><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msubsup><mo>=</mo><mi>γ</mi><mrow><mo fence="true">(</mo><msub><mi mathvariant="bold-italic">B</mi><mo lspace="0em" rspace="0em">⊥</mo></msub><mo>−</mo><mi mathvariant="bold-italic">v</mi><mi mathvariant="normal">/</mi><mi>c</mi><mo>×</mo><msub><mi mathvariant="bold-italic">E</mi><mo lspace="0em" rspace="0em">⊥</mo></msub><mi mathvariant="normal">/</mi><mi>c</mi><mo fence="true">)</mo></mrow></mrow></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{gathered}
\boldsymbol{E}_{\perp}^{\prime} / c=\gamma\left(\boldsymbol{E}_{\perp} / c+\boldsymbol{v} / c \times \boldsymbol{B}_{\perp}\right), \\
\boldsymbol{B}_{\perp}^{\prime}=\gamma\left(\boldsymbol{B}_{\perp}-\boldsymbol{v} / c \times \boldsymbol{E}_{\perp} / c\right)
\end{gathered}
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:3em;vertical-align:-1.25em;"></span><span class="mord"><span class="mtable"><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.75em;"><span style="top:-3.91em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.05451em;">E</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8279em;"><span style="top:-2.453em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mrel mtight">⊥</span></span></span></span><span style="top:-3.139em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.247em;"><span></span></span></span></span></span></span><span class="mord">/</span><span class="mord mathnormal">c</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord mathnormal" style="margin-right:0.05556em;">γ</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.05451em;">E</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3361em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mrel mtight">⊥</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord">/</span><span class="mord mathnormal">c</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03704em;">v</span></span></span><span class="mord">/</span><span class="mord mathnormal">c</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">×</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.04835em;">B</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3361em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mrel mtight">⊥</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">)</span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mpunct">,</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.04835em;">B</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8279em;"><span style="top:-2.453em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mrel mtight">⊥</span></span></span></span><span style="top:-3.139em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.247em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord mathnormal" style="margin-right:0.05556em;">γ</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.04835em;">B</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3361em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mrel mtight">⊥</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03704em;">v</span></span></span><span class="mord">/</span><span class="mord mathnormal">c</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">×</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.05451em;">E</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3361em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mrel mtight">⊥</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord">/</span><span class="mord mathnormal">c</span><span class="mclose delimcenter" style="top:0em;">)</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.25em;"><span></span></span></span></span></span></span></span></span></span></span></span></p>
</li>
</ol>
]]></description>
            <content:encoded><![CDATA[<h1 id="formulas-for-ipho-日本語版-section-13" tabindex="-1">Formulas for IPhO 日本語版: Section 13 <a class="header-anchor" href="#formulas-for-ipho-日本語版-section-13" aria-label="Permalink to &quot;Formulas for IPhO 日本語版: Section 13&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="_13-相対性理論" tabindex="-1">13: 相対性理論 <a class="header-anchor" href="#_13-相対性理論" aria-label="Permalink to &quot;13: 相対性理論&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="_13-1-lorentz-変換" tabindex="-1">13.1:Lorentz 変換 <a class="header-anchor" href="#_13-1-lorentz-変換" aria-label="Permalink to &quot;13.1:Lorentz 変換&quot;">&ZeroWidthSpace;</a></h3>
<ol>
<li>
<p>Lorentz 変換 (Minkowski 幾何学の 4 次元時空の回 転）(慣性系間の速度が <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mrow><mi mathvariant="bold-italic">V</mi><mo>=</mo><mi>V</mi><msub><mi mathvariant="bold-italic">e</mi><mi>x</mi></msub><mo fence="true">)</mo></mrow><mo>:</mo><mi>β</mi><mo>=</mo><mi>V</mi><mi mathvariant="normal">/</mi><mi>c</mi><mo separator="true">,</mo><mi>γ</mi><mo>=</mo></mrow><annotation encoding="application/x-tex">\left.\boldsymbol{V}=V \boldsymbol{e}_x\right): \beta=V / c, \gamma=</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="minner"><span class="mopen nulldelimiter"></span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.25555em;">V</span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord mathnormal" style="margin-right:0.22222em;">V</span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol">e</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">x</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">)</span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">:</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.05278em;">β</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.22222em;">V</span><span class="mord">/</span><span class="mord mathnormal">c</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.05556em;">γ</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span></span></span></span></p>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mtable rowspacing="0.25em" columnalign="right left" columnspacing="0em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mn>1</mn><mi mathvariant="normal">/</mi><msqrt><mrow><mn>1</mn><mo>−</mo><msup><mi>β</mi><mn>2</mn></msup></mrow></msqrt><mtext> として, </mtext></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mspace width="2em"/><mi>c</mi><msup><mi>t</mi><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup><mo>=</mo><mi>γ</mi><mo stretchy="false">(</mo><mi>c</mi><mi>t</mi><mo>−</mo><mi>β</mi><mi>x</mi><mo stretchy="false">)</mo><mo separator="true">,</mo><msup><mi>x</mi><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup><mo>=</mo><mi>γ</mi><mo stretchy="false">(</mo><mi>x</mi><mo>−</mo><mi>β</mi><mi>c</mi><mi>t</mi><mo stretchy="false">)</mo><mo separator="true">,</mo><msup><mi>y</mi><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup><mo>=</mo><mi>y</mi></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><msup><mi>E</mi><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup><mi mathvariant="normal">/</mi><mi>c</mi><mo>=</mo><mi>γ</mi><mrow><mo fence="true">(</mo><mi>E</mi><mi mathvariant="normal">/</mi><mi>c</mi><mo>−</mo><mi>β</mi><msub><mi>p</mi><mi>x</mi></msub><mo fence="true">)</mo></mrow><mo separator="true">,</mo><msubsup><mi>p</mi><mi>x</mi><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msubsup><mo>=</mo><mi>γ</mi><mrow><mo fence="true">(</mo><msub><mi>p</mi><mi>x</mi></msub><mo>−</mo><mi>β</mi><mi>E</mi><mi mathvariant="normal">/</mi><mi>c</mi><mo fence="true">)</mo></mrow><mo separator="true">,</mo><msubsup><mi>p</mi><mi>y</mi><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msubsup><mo>=</mo><msub><mi>p</mi><mi>y</mi></msub></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mtext> ここで, </mtext></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mi>E</mi><mo>=</mo><mfrac><mrow><mi>m</mi><msup><mi>c</mi><mn>2</mn></msup></mrow><msqrt><mrow><mn>1</mn><mo>−</mo><msup><mi>v</mi><mn>2</mn></msup><mi mathvariant="normal">/</mi><msup><mi>c</mi><mn>2</mn></msup></mrow></msqrt></mfrac><mo>=</mo><mi>m</mi><msup><mi>c</mi><mn>2</mn></msup><mo>+</mo><mfrac><mn>1</mn><mn>2</mn></mfrac><mi>m</mi><msup><mi>v</mi><mn>2</mn></msup><mo>+</mo><mo>⋯</mo></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><msub><mi>p</mi><mi>x</mi></msub><mo>=</mo><mfrac><mrow><mi>m</mi><msub><mi>v</mi><mi>x</mi></msub></mrow><msqrt><mrow><mn>1</mn><mo>−</mo><msup><mi>v</mi><mn>2</mn></msup><mi mathvariant="normal">/</mi><msup><mi>c</mi><mn>2</mn></msup></mrow></msqrt></mfrac><mo separator="true">,</mo><mtext> etc. </mtext></mrow></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{aligned}
&amp; 1 / \sqrt{1-\beta^2} \text { として, } \\
&amp; \qquad c t^{\prime}=\gamma(c t-\beta x), x^{\prime}=\gamma(x-\beta c t), y^{\prime}=y \\
&amp; E^{\prime} / c=\gamma\left(E / c-\beta p_x\right), p_x^{\prime}=\gamma\left(p_x-\beta E / c\right), p_y^{\prime}=p_y \\
&amp; \text { ここで, } \\
&amp; E=\frac{m c^2}{\sqrt{1-v^2 / c^2}}=m c^2+\frac{1}{2} m v^2+\cdots \\
&amp; p_x=\frac{m v_x}{\sqrt{1-v^2 / c^2}}, \text { etc. }
\end{aligned}
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:11.6485em;vertical-align:-5.5742em;"></span><span class="mord"><span class="mtable"><span class="col-align-r"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:6.0742em;"><span style="top:-8.5586em;"><span class="pstrut" style="height:3.4911em;"></span><span class="mord"></span></span><span style="top:-7.0586em;"><span class="pstrut" style="height:3.4911em;"></span><span class="mord"></span></span><span style="top:-5.5586em;"><span class="pstrut" style="height:3.4911em;"></span><span class="mord"></span></span><span style="top:-4.0355em;"><span class="pstrut" style="height:3.4911em;"></span><span class="mord"></span></span><span style="top:-1.8844em;"><span class="pstrut" style="height:3.4911em;"></span><span class="mord"></span></span><span style="top:0.6531em;"><span class="pstrut" style="height:3.4911em;"></span><span class="mord"></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:5.5742em;"><span></span></span></span></span></span><span class="col-align-l"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:6.0742em;"><span style="top:-8.5586em;"><span class="pstrut" style="height:3.4911em;"></span><span class="mord"><span class="mord"></span><span class="mord">1/</span><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.0067em;"><span class="svg-align" style="top:-3.2em;"><span class="pstrut" style="height:3.2em;"></span><span class="mord" style="padding-left:1em;"><span class="mord">1</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.05278em;">β</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7401em;"><span style="top:-2.989em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span><span style="top:-2.9667em;"><span class="pstrut" style="height:3.2em;"></span><span class="hide-tail" style="min-width:1.02em;height:1.28em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='1.28em' viewBox='0 0 400000 1296' preserveAspectRatio='xMinYMin slice'><path d='M263,681c0.7,0,18,39.7,52,119
c34,79.3,68.167,158.7,102.5,238c34.3,79.3,51.8,119.3,52.5,120
c340,-704.7,510.7,-1060.3,512,-1067
l0 -0
c4.7,-7.3,11,-11,19,-11
H40000v40H1012.3
s-271.3,567,-271.3,567c-38.7,80.7,-84,175,-136,283c-52,108,-89.167,185.3,-111.5,232
c-22.3,46.7,-33.8,70.3,-34.5,71c-4.7,4.7,-12.3,7,-23,7s-12,-1,-12,-1
s-109,-253,-109,-253c-72.7,-168,-109.3,-252,-110,-252c-10.7,8,-22,16.7,-34,26
c-22,17.3,-33.3,26,-34,26s-26,-26,-26,-26s76,-59,76,-59s76,-60,76,-60z
M1001 80h400000v40h-400000z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2333em;"><span></span></span></span></span></span><span class="mord text"><span class="mord"> </span><span class="mord cjk_fallback">として</span><span class="mord">, </span></span></span></span><span style="top:-7.0586em;"><span class="pstrut" style="height:3.4911em;"></span><span class="mord"><span class="mord"></span><span class="mspace" style="margin-right:2em;"></span><span class="mord mathnormal">c</span><span class="mord"><span class="mord mathnormal">t</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8019em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord mathnormal" style="margin-right:0.05556em;">γ</span><span class="mopen">(</span><span class="mord mathnormal">c</span><span class="mord mathnormal">t</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal" style="margin-right:0.05278em;">β</span><span class="mord mathnormal">x</span><span class="mclose">)</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8019em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord mathnormal" style="margin-right:0.05556em;">γ</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal" style="margin-right:0.05278em;">β</span><span class="mord mathnormal">c</span><span class="mord mathnormal">t</span><span class="mclose">)</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">y</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8019em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">y</span></span></span><span style="top:-5.5586em;"><span class="pstrut" style="height:3.4911em;"></span><span class="mord"><span class="mord"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.05764em;">E</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8019em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span><span class="mord">/</span><span class="mord mathnormal">c</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord mathnormal" style="margin-right:0.05556em;">γ</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord mathnormal" style="margin-right:0.05764em;">E</span><span class="mord">/</span><span class="mord mathnormal">c</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal" style="margin-right:0.05278em;">β</span><span class="mord"><span class="mord mathnormal">p</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">x</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">)</span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal">p</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8019em;"><span style="top:-2.453em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">x</span></span></span><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.247em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord mathnormal" style="margin-right:0.05556em;">γ</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord"><span class="mord mathnormal">p</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">x</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal" style="margin-right:0.05764em;">βE</span><span class="mord">/</span><span class="mord mathnormal">c</span><span class="mclose delimcenter" style="top:0em;">)</span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal">p</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8019em;"><span style="top:-2.453em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.03588em;">y</span></span></span><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.3831em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mord mathnormal">p</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.03588em;">y</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span></span></span><span style="top:-4.0355em;"><span class="pstrut" style="height:3.4911em;"></span><span class="mord"><span class="mord"></span><span class="mord text"><span class="mord"> </span><span class="mord cjk_fallback">ここで</span><span class="mord">, </span></span></span></span><span style="top:-1.8844em;"><span class="pstrut" style="height:3.4911em;"></span><span class="mord"><span class="mord"></span><span class="mord mathnormal" style="margin-right:0.05764em;">E</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.4911em;"><span style="top:-2.175em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.935em;"><span class="svg-align" style="top:-3.2em;"><span class="pstrut" style="height:3.2em;"></span><span class="mord" style="padding-left:1em;"><span class="mord">1</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7401em;"><span style="top:-2.989em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mord">/</span><span class="mord"><span class="mord mathnormal">c</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7401em;"><span style="top:-2.989em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span><span style="top:-2.895em;"><span class="pstrut" style="height:3.2em;"></span><span class="hide-tail" style="min-width:1.02em;height:1.28em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='1.28em' viewBox='0 0 400000 1296' preserveAspectRatio='xMinYMin slice'><path d='M263,681c0.7,0,18,39.7,52,119
c34,79.3,68.167,158.7,102.5,238c34.3,79.3,51.8,119.3,52.5,120
c340,-704.7,510.7,-1060.3,512,-1067
l0 -0
c4.7,-7.3,11,-11,19,-11
H40000v40H1012.3
s-271.3,567,-271.3,567c-38.7,80.7,-84,175,-136,283c-52,108,-89.167,185.3,-111.5,232
c-22.3,46.7,-33.8,70.3,-34.5,71c-4.7,4.7,-12.3,7,-23,7s-12,-1,-12,-1
s-109,-253,-109,-253c-72.7,-168,-109.3,-252,-110,-252c-10.7,8,-22,16.7,-34,26
c-22,17.3,-33.3,26,-34,26s-26,-26,-26,-26s76,-59,76,-59s76,-60,76,-60z
M1001 80h400000v40h-400000z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.305em;"><span></span></span></span></span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">m</span><span class="mord"><span class="mord mathnormal">c</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.13em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord mathnormal">m</span><span class="mord"><span class="mord mathnormal">c</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.3214em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">2</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mord mathnormal">m</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="minner">⋯</span></span></span><span style="top:0.6531em;"><span class="pstrut" style="height:3.4911em;"></span><span class="mord"><span class="mord"></span><span class="mord"><span class="mord mathnormal">p</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">x</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1076em;"><span style="top:-2.175em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.935em;"><span class="svg-align" style="top:-3.2em;"><span class="pstrut" style="height:3.2em;"></span><span class="mord" style="padding-left:1em;"><span class="mord">1</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7401em;"><span style="top:-2.989em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mord">/</span><span class="mord"><span class="mord mathnormal">c</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7401em;"><span style="top:-2.989em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span><span style="top:-2.895em;"><span class="pstrut" style="height:3.2em;"></span><span class="hide-tail" style="min-width:1.02em;height:1.28em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='1.28em' viewBox='0 0 400000 1296' preserveAspectRatio='xMinYMin slice'><path d='M263,681c0.7,0,18,39.7,52,119
c34,79.3,68.167,158.7,102.5,238c34.3,79.3,51.8,119.3,52.5,120
c340,-704.7,510.7,-1060.3,512,-1067
l0 -0
c4.7,-7.3,11,-11,19,-11
H40000v40H1012.3
s-271.3,567,-271.3,567c-38.7,80.7,-84,175,-136,283c-52,108,-89.167,185.3,-111.5,232
c-22.3,46.7,-33.8,70.3,-34.5,71c-4.7,4.7,-12.3,7,-23,7s-12,-1,-12,-1
s-109,-253,-109,-253c-72.7,-168,-109.3,-252,-110,-252c-10.7,8,-22,16.7,-34,26
c-22,17.3,-33.3,26,-34,26s-26,-26,-26,-26s76,-59,76,-59s76,-60,76,-60z
M1001 80h400000v40h-400000z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.305em;"><span></span></span></span></span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">m</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">x</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.13em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord text"><span class="mord"> etc. </span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:5.5742em;"><span></span></span></span></span></span></span></span></span></span></span></span></p>
</li>
</ol>
<h3 id="_13-2-4-元ベクトルの長" tabindex="-1">13.2: 4 元ベクトルの長 <a class="header-anchor" href="#_13-2-4-元ベクトルの長" aria-label="Permalink to &quot;13.2: 4 元ベクトルの長&quot;">&ZeroWidthSpace;</a></h3>
<ol start="2">
<li>4 元ベクトルの長さ (スカラー量であり Lorentz 変換 で不変）:<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mtable rowspacing="0.25em" columnalign="right left" columnspacing="0em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><msup><mi>s</mi><mn>2</mn></msup></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mo>=</mo><mo stretchy="false">(</mo><mi>c</mi><mi>t</mi><msup><mo stretchy="false">)</mo><mn>2</mn></msup><mo>−</mo><msup><mi>x</mi><mn>2</mn></msup><mo>−</mo><msup><mi>y</mi><mn>2</mn></msup><mo>−</mo><msup><mi>z</mi><mn>2</mn></msup></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mo stretchy="false">(</mo><mi>m</mi><mi>c</mi><msup><mo stretchy="false">)</mo><mn>2</mn></msup></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mo>=</mo><mo stretchy="false">(</mo><mi>E</mi><mi mathvariant="normal">/</mi><mi>c</mi><msup><mo stretchy="false">)</mo><mn>2</mn></msup><mo>−</mo><msubsup><mi>p</mi><mi>x</mi><mn>2</mn></msubsup><mo>−</mo><msubsup><mi>p</mi><mi>y</mi><mn>2</mn></msubsup><mo>−</mo><msubsup><mi>p</mi><mi>z</mi><mn>2</mn></msubsup></mrow></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{aligned}
s^2 &amp; =(c t)^2-x^2-y^2-z^2 \\
(m c)^2 &amp; =(E / c)^2-p_x^2-p_y^2-p_z^2
\end{aligned}
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:3.0713em;vertical-align:-1.2857em;"></span><span class="mord"><span class="mtable"><span class="col-align-r"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.7857em;"><span style="top:-3.9216em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"><span class="mord mathnormal">s</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span><span style="top:-2.3974em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mopen">(</span><span class="mord mathnormal">m</span><span class="mord mathnormal">c</span><span class="mclose"><span class="mclose">)</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.2857em;"><span></span></span></span></span></span><span class="col-align-l"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.7857em;"><span style="top:-3.9216em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mopen">(</span><span class="mord mathnormal">c</span><span class="mord mathnormal">t</span><span class="mclose"><span class="mclose">)</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">y</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.04398em;">z</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span><span style="top:-2.3974em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.05764em;">E</span><span class="mord">/</span><span class="mord mathnormal">c</span><span class="mclose"><span class="mclose">)</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal">p</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-2.453em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">x</span></span></span><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.247em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal">p</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-2.453em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.03588em;">y</span></span></span><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.3831em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal">p</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-2.453em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.04398em;">z</span></span></span><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.247em;"><span></span></span></span></span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.2857em;"><span></span></span></span></span></span></span></span></span></span></span></span></p>
</li>
</ol>
<h3 id="_13-3-速度の加算" tabindex="-1">13.3: 速度の加算 <a class="header-anchor" href="#_13-3-速度の加算" aria-label="Permalink to &quot;13.3: 速度の加算&quot;">&ZeroWidthSpace;</a></h3>
<ol start="3">
<li>速度の加算 :<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><msub><mi>v</mi><mi>x</mi></msub><mo>=</mo><mfrac><mrow><msubsup><mi>v</mi><mi>x</mi><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msubsup><mo>+</mo><mi>V</mi></mrow><mrow><mn>1</mn><mo>+</mo><msubsup><mi>v</mi><mi>x</mi><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msubsup><mi>V</mi><mi mathvariant="normal">/</mi><msup><mi>c</mi><mn>2</mn></msup></mrow></mfrac><mo separator="true">,</mo><msub><mi>v</mi><mi>y</mi></msub><mo>=</mo><mfrac><msubsup><mi>v</mi><mi>y</mi><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msubsup><mrow><mi>γ</mi><mrow><mo fence="true">(</mo><mn>1</mn><mo>+</mo><msubsup><mi>v</mi><mi>x</mi><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msubsup><mi>V</mi><mi mathvariant="normal">/</mi><msup><mi>c</mi><mn>2</mn></msup><mo fence="true">)</mo></mrow></mrow></mfrac></mrow><annotation encoding="application/x-tex">v_x=\frac{v_x^{\prime}+V}{1+v_x^{\prime} V / c^2}, v_y=\frac{v_y^{\prime}}{\gamma\left(1+v_x^{\prime} V / c^2\right)}
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">x</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:2.3649em;vertical-align:-0.936em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.4289em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">1</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6779em;"><span style="top:-2.453em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">x</span></span></span><span style="top:-2.989em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.247em;"><span></span></span></span></span></span></span><span class="mord mathnormal" style="margin-right:0.22222em;">V</span><span class="mord">/</span><span class="mord"><span class="mord mathnormal">c</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7401em;"><span style="top:-2.989em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.7519em;"><span style="top:-2.453em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">x</span></span></span><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.247em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal" style="margin-right:0.22222em;">V</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.936em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.03588em;">y</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:2.461em;vertical-align:-0.936em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.525em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.05556em;">γ</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord">1</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6779em;"><span style="top:-2.453em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">x</span></span></span><span style="top:-2.989em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.247em;"><span></span></span></span></span></span></span><span class="mord mathnormal" style="margin-right:0.22222em;">V</span><span class="mord">/</span><span class="mord"><span class="mord mathnormal">c</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7401em;"><span style="top:-2.989em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">)</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.7731em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.7519em;"><span style="top:-2.453em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.03588em;">y</span></span></span><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.3831em;"><span></span></span></span></span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.936em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span></span></p>
</li>
</ol>
<h3 id="_13-4-doppler-効果" tabindex="-1">13.4: Doppler 効果 <a class="header-anchor" href="#_13-4-doppler-効果" aria-label="Permalink to &quot;13.4: Doppler 効果&quot;">&ZeroWidthSpace;</a></h3>
<ol start="4">
<li>Doppler 効果 :<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mi>ν</mi><mo>=</mo><mi>γ</mi><mo stretchy="false">(</mo><mn>1</mn><mo>+</mo><mi>β</mi><mi>cos</mi><mo>⁡</mo><mi>θ</mi><mo stretchy="false">)</mo><msub><mi>ν</mi><mn>0</mn></msub></mrow><annotation encoding="application/x-tex">\nu=\gamma(1+\beta \cos \theta) \nu_0
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal" style="margin-right:0.06366em;">ν</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.05556em;">γ</span><span class="mopen">(</span><span class="mord">1</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.05278em;">β</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">cos</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.02778em;">θ</span><span class="mclose">)</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.06366em;">ν</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0637em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">0</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span></span></p>
</li>
</ol>
<h3 id="_13-5-minkowski-空間" tabindex="-1">13.5: Minkowski 空間 <a class="header-anchor" href="#_13-5-minkowski-空間" aria-label="Permalink to &quot;13.5: Minkowski 空間&quot;">&ZeroWidthSpace;</a></h3>
<ol start="5">
<li>Minkowski 空間は, 時間が虚数（ <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">(</mo><mi>t</mi><mi>i</mi><mi>c</mi><mi>t</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">(t i c t)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">(</span><span class="mord mathnormal">t</span><span class="mord mathnormal">i</span><span class="mord mathnormal">c</span><span class="mord mathnormal">t</span><span class="mclose">)</span></span></span></span> であれば Euclid 空間にすることができる. 回転角 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>φ</mi></mrow><annotation encoding="application/x-tex">\varphi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">φ</span></span></span></span> に対して, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>tan</mi><mo>⁡</mo><mi>φ</mi><mo>=</mo><mi>v</mi><mi mathvariant="normal">/</mi><mi>i</mi><mi>c</mi></mrow><annotation encoding="application/x-tex">\tan \varphi=v / i c</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8095em;vertical-align:-0.1944em;"></span><span class="mop">tan</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">φ</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="mord">/</span><span class="mord mathnormal">i</span><span class="mord mathnormal">c</span></span></span></span> となり, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>sin</mi><mo>⁡</mo><mi>φ</mi><mo separator="true">,</mo><mi>cos</mi><mo>⁡</mo><mi>φ</mi></mrow><annotation encoding="application/x-tex">\sin \varphi, \cos \varphi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8623em;vertical-align:-0.1944em;"></span><span class="mop">sin</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">φ</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">cos</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">φ</span></span></span></span> を <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>tan</mi><mo>⁡</mo><mi>φ</mi></mrow><annotation encoding="application/x-tex">\tan \varphi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8095em;vertical-align:-0.1944em;"></span><span class="mop">tan</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">φ</span></span></span></span> で表して Euclid 幾何学の公式を適用する (Lorentz 変換).</li>
</ol>
<h3 id="_13-6-長さの縮み" tabindex="-1">13.6: 長さの縮み <a class="header-anchor" href="#_13-6-長さの縮み" aria-label="Permalink to &quot;13.6: 長さの縮み&quot;">&ZeroWidthSpace;</a></h3>
<ol start="6">
<li>長さの縮み : <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msup><mi>l</mi><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup><mo>=</mo><msub><mi>l</mi><mn>0</mn></msub><mi mathvariant="normal">/</mi><mi>γ</mi></mrow><annotation encoding="application/x-tex">l^{\prime}=l_0 / \gamma</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7519em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.01968em;">l</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7519em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.01968em;">l</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0197em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">0</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord">/</span><span class="mord mathnormal" style="margin-right:0.05556em;">γ</span></span></span></span>.</li>
</ol>
<h3 id="_13-7-時間の遅れ" tabindex="-1">13.7: 時間の遅れ <a class="header-anchor" href="#_13-7-時間の遅れ" aria-label="Permalink to &quot;13.7: 時間の遅れ&quot;">&ZeroWidthSpace;</a></h3>
<ol start="7">
<li>時間の遅れ: <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msup><mi>t</mi><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup><mo>=</mo><msub><mi>t</mi><mn>0</mn></msub><mi>γ</mi></mrow><annotation encoding="application/x-tex">t^{\prime}=t_0 \gamma</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7519em;"></span><span class="mord"><span class="mord mathnormal">t</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7519em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8095em;vertical-align:-0.1944em;"></span><span class="mord"><span class="mord mathnormal">t</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">0</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord mathnormal" style="margin-right:0.05556em;">γ</span></span></span></span>.</li>
</ol>
<h3 id="_13-8-同時刻の相対性" tabindex="-1">13.8: 同時刻の相対性 <a class="header-anchor" href="#_13-8-同時刻の相対性" aria-label="Permalink to &quot;13.8: 同時刻の相対性&quot;">&ZeroWidthSpace;</a></h3>
<ol start="8">
<li>同時刻の相対性 : <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Δ</mi><mi>t</mi><mo>=</mo><mo>−</mo><mi>γ</mi><mi>v</mi><mi mathvariant="normal">Δ</mi><mi>x</mi><mi mathvariant="normal">/</mi><msup><mi>c</mi><mn>2</mn></msup></mrow><annotation encoding="application/x-tex">\Delta t=-\gamma v \Delta x / c^2</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">Δ</span><span class="mord mathnormal">t</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.0641em;vertical-align:-0.25em;"></span><span class="mord">−</span><span class="mord mathnormal" style="margin-right:0.05556em;">γ</span><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="mord">Δ</span><span class="mord mathnormal">x</span><span class="mord">/</span><span class="mord"><span class="mord mathnormal">c</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span></span>.</li>
</ol>
<h3 id="_13-9-f-dp-dt" tabindex="-1">13.9: F=dp/dt <a class="header-anchor" href="#_13-9-f-dp-dt" aria-label="Permalink to &quot;13.9: F=dp/dt&quot;">&ZeroWidthSpace;</a></h3>
<ol start="9">
<li><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="bold-italic">F</mi><mo>=</mo><mi mathvariant="normal">d</mi><mi mathvariant="bold-italic">p</mi><mi mathvariant="normal">/</mi><mi mathvariant="normal">d</mi><mi>t</mi><mrow><mo fence="true">(</mo><mo>=</mo><mfrac><mi mathvariant="normal">d</mi><mrow><mi mathvariant="normal">d</mi><mi>t</mi></mrow></mfrac><mo stretchy="false">(</mo><mi>γ</mi><mi>m</mi><mi mathvariant="bold-italic">v</mi><mo stretchy="false">)</mo><mo fence="true">)</mo></mrow><mo stretchy="false">(</mo></mrow><annotation encoding="application/x-tex">\boldsymbol{F}=\mathrm{d} \boldsymbol{p} / \mathrm{d} t\left(=\frac{\mathrm{d}}{\mathrm{d} t}(\gamma m \boldsymbol{v})\right)(</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6861em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.15972em;">F</span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.2301em;vertical-align:-0.35em;"></span><span class="mord mathrm">d</span><span class="mord"><span class="mord"><span class="mord boldsymbol">p</span></span></span><span class="mord">/</span><span class="mord mathrm">d</span><span class="mord mathnormal">t</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size1">(</span></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8801em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathrm mtight">d</span><span class="mord mathnormal mtight">t</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathrm mtight">d</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mopen">(</span><span class="mord mathnormal">γm</span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03704em;">v</span></span></span><span class="mclose">)</span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size1">)</span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mopen">(</span></span></span></span> ここでの <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>γ</mi><mo>=</mo></mrow><annotation encoding="application/x-tex">\gamma=</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.05556em;">γ</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span></span></span></span> <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>1</mn><mi mathvariant="normal">/</mi><msqrt><mrow><mn>1</mn><mo>−</mo><msup><mi>v</mi><mn>2</mn></msup><mi mathvariant="normal">/</mi><msup><mi>c</mi><mn>2</mn></msup></mrow></msqrt><mo fence="true">)</mo></mrow><annotation encoding="application/x-tex">\left.1 / \sqrt{1-v^2 / c^2}\right)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.8em;vertical-align:-0.65em;"></span><span class="minner"><span class="mopen nulldelimiter"></span><span class="mord">1/</span><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.935em;"><span class="svg-align" style="top:-3.2em;"><span class="pstrut" style="height:3.2em;"></span><span class="mord" style="padding-left:1em;"><span class="mord">1</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7401em;"><span style="top:-2.989em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mord">/</span><span class="mord"><span class="mord mathnormal">c</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7401em;"><span style="top:-2.989em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span><span style="top:-2.895em;"><span class="pstrut" style="height:3.2em;"></span><span class="hide-tail" style="min-width:1.02em;height:1.28em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='1.28em' viewBox='0 0 400000 1296' preserveAspectRatio='xMinYMin slice'><path d='M263,681c0.7,0,18,39.7,52,119
c34,79.3,68.167,158.7,102.5,238c34.3,79.3,51.8,119.3,52.5,120
c340,-704.7,510.7,-1060.3,512,-1067
l0 -0
c4.7,-7.3,11,-11,19,-11
H40000v40H1012.3
s-271.3,567,-271.3,567c-38.7,80.7,-84,175,-136,283c-52,108,-89.167,185.3,-111.5,232
c-22.3,46.7,-33.8,70.3,-34.5,71c-4.7,4.7,-12.3,7,-23,7s-12,-1,-12,-1
s-109,-253,-109,-253c-72.7,-168,-109.3,-252,-110,-252c-10.7,8,-22,16.7,-34,26
c-22,17.3,-33.3,26,-34,26s-26,-26,-26,-26s76,-59,76,-59s76,-60,76,-60z
M1001 80h400000v40h-400000z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.305em;"><span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size2">)</span></span></span></span></span></span></li>
</ol>
<h3 id="_13-10-超相対論的極限" tabindex="-1">13.10: 超相対論的極限 <a class="header-anchor" href="#_13-10-超相対論的極限" aria-label="Permalink to &quot;13.10: 超相対論的極限&quot;">&ZeroWidthSpace;</a></h3>
<ol start="10">
<li>超相対論的極限 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>:</mo><mi>v</mi><mo>≈</mo><mi>c</mi><mo separator="true">,</mo><mi>p</mi><mo>≈</mo><mi>m</mi><mi>c</mi><mo separator="true">,</mo><msqrt><mrow><mn>1</mn><mo>−</mo><mo stretchy="false">(</mo><mi>v</mi><mi mathvariant="normal">/</mi><mi>c</mi><msup><mo stretchy="false">)</mo><mn>2</mn></msup></mrow></msqrt><mo>≈</mo></mrow><annotation encoding="application/x-tex">: v \approx c, p \approx m c, \sqrt{1-(v / c)^2} \approx</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mrel">:</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.4831em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≈</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6776em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">c</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">p</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≈</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.24em;vertical-align:-0.305em;"></span><span class="mord mathnormal">m</span><span class="mord mathnormal">c</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.935em;"><span class="svg-align" style="top:-3.2em;"><span class="pstrut" style="height:3.2em;"></span><span class="mord" style="padding-left:1em;"><span class="mord">1</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="mord">/</span><span class="mord mathnormal">c</span><span class="mclose"><span class="mclose">)</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7401em;"><span style="top:-2.989em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span><span style="top:-2.895em;"><span class="pstrut" style="height:3.2em;"></span><span class="hide-tail" style="min-width:1.02em;height:1.28em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='1.28em' viewBox='0 0 400000 1296' preserveAspectRatio='xMinYMin slice'><path d='M263,681c0.7,0,18,39.7,52,119
c34,79.3,68.167,158.7,102.5,238c34.3,79.3,51.8,119.3,52.5,120
c340,-704.7,510.7,-1060.3,512,-1067
l0 -0
c4.7,-7.3,11,-11,19,-11
H40000v40H1012.3
s-271.3,567,-271.3,567c-38.7,80.7,-84,175,-136,283c-52,108,-89.167,185.3,-111.5,232
c-22.3,46.7,-33.8,70.3,-34.5,71c-4.7,4.7,-12.3,7,-23,7s-12,-1,-12,-1
s-109,-253,-109,-253c-72.7,-168,-109.3,-252,-110,-252c-10.7,8,-22,16.7,-34,26
c-22,17.3,-33.3,26,-34,26s-26,-26,-26,-26s76,-59,76,-59s76,-60,76,-60z
M1001 80h400000v40h-400000z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.305em;"><span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≈</span></span></span></span> <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msqrt><mrow><mn>2</mn><mo stretchy="false">(</mo><mn>1</mn><mo>−</mo><mi>v</mi><mi mathvariant="normal">/</mi><mi>c</mi><mo stretchy="false">)</mo></mrow></msqrt></mrow><annotation encoding="application/x-tex">\sqrt{2(1-v / c)}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.24em;vertical-align:-0.305em;"></span><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.935em;"><span class="svg-align" style="top:-3.2em;"><span class="pstrut" style="height:3.2em;"></span><span class="mord" style="padding-left:1em;"><span class="mord">2</span><span class="mopen">(</span><span class="mord">1</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="mord">/</span><span class="mord mathnormal">c</span><span class="mclose">)</span></span></span><span style="top:-2.895em;"><span class="pstrut" style="height:3.2em;"></span><span class="hide-tail" style="min-width:1.02em;height:1.28em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='1.28em' viewBox='0 0 400000 1296' preserveAspectRatio='xMinYMin slice'><path d='M263,681c0.7,0,18,39.7,52,119
c34,79.3,68.167,158.7,102.5,238c34.3,79.3,51.8,119.3,52.5,120
c340,-704.7,510.7,-1060.3,512,-1067
l0 -0
c4.7,-7.3,11,-11,19,-11
H40000v40H1012.3
s-271.3,567,-271.3,567c-38.7,80.7,-84,175,-136,283c-52,108,-89.167,185.3,-111.5,232
c-22.3,46.7,-33.8,70.3,-34.5,71c-4.7,4.7,-12.3,7,-23,7s-12,-1,-12,-1
s-109,-253,-109,-253c-72.7,-168,-109.3,-252,-110,-252c-10.7,8,-22,16.7,-34,26
c-22,17.3,-33.3,26,-34,26s-26,-26,-26,-26s76,-59,76,-59s76,-60,76,-60z
M1001 80h400000v40h-400000z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.305em;"><span></span></span></span></span></span></span></span></span></li>
</ol>
<h3 id="_13-11-電場と磁場の-lorentz-変換" tabindex="-1">13.11: 電場と磁場の Lorentz 変換 <Badge type="tip" text="supplemental" /> <a class="header-anchor" href="#_13-11-電場と磁場の-lorentz-変換" aria-label="Permalink to &quot;13.11: 電場と磁場の Lorentz 変換 &lt;Badge type=&quot;tip&quot; text=&quot;supplemental&quot; /&gt;&quot;">&ZeroWidthSpace;</a></h3>
<ol start="11">
<li>電場と磁場の Lorentz 変換 : <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msubsup><mi mathvariant="bold-italic">E</mi><mi mathvariant="normal">∥</mi><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msubsup><mo>=</mo><msub><mi mathvariant="bold-italic">E</mi><mi mathvariant="normal">∥</mi></msub><mo separator="true">,</mo><msubsup><mi mathvariant="bold-italic">B</mi><mi mathvariant="normal">∥</mi><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msubsup><mo>=</mo><msub><mi mathvariant="bold-italic">B</mi><mi mathvariant="normal">∥</mi></msub></mrow><annotation encoding="application/x-tex">\boldsymbol{E}_{\|}^{\prime}=\boldsymbol{E}_{\|}, \boldsymbol{B}_{\|}^{\prime}=\boldsymbol{B}_{\|}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2499em;vertical-align:-0.422em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.05451em;">E</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8279em;"><span style="top:-2.453em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">∥</span></span></span></span><span style="top:-3.139em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.422em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.2499em;vertical-align:-0.422em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.05451em;">E</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3448em;"><span style="top:-2.5198em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">∥</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.3552em;"><span></span></span></span></span></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.04835em;">B</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8279em;"><span style="top:-2.453em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">∥</span></span></span></span><span style="top:-3.139em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.422em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.0413em;vertical-align:-0.3552em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.04835em;">B</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3448em;"><span style="top:-2.5198em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">∥</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.3552em;"><span></span></span></span></span></span></span></span></span></span>,<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mtable rowspacing="0.25em" columnalign="center" columnspacing="0em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><msubsup><mi mathvariant="bold-italic">E</mi><mo lspace="0em" rspace="0em">⊥</mo><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msubsup><mi mathvariant="normal">/</mi><mi>c</mi><mo>=</mo><mi>γ</mi><mrow><mo fence="true">(</mo><msub><mi mathvariant="bold-italic">E</mi><mo lspace="0em" rspace="0em">⊥</mo></msub><mi mathvariant="normal">/</mi><mi>c</mi><mo>+</mo><mi mathvariant="bold-italic">v</mi><mi mathvariant="normal">/</mi><mi>c</mi><mo>×</mo><msub><mi mathvariant="bold-italic">B</mi><mo lspace="0em" rspace="0em">⊥</mo></msub><mo fence="true">)</mo></mrow><mo separator="true">,</mo></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><msubsup><mi mathvariant="bold-italic">B</mi><mo lspace="0em" rspace="0em">⊥</mo><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msubsup><mo>=</mo><mi>γ</mi><mrow><mo fence="true">(</mo><msub><mi mathvariant="bold-italic">B</mi><mo lspace="0em" rspace="0em">⊥</mo></msub><mo>−</mo><mi mathvariant="bold-italic">v</mi><mi mathvariant="normal">/</mi><mi>c</mi><mo>×</mo><msub><mi mathvariant="bold-italic">E</mi><mo lspace="0em" rspace="0em">⊥</mo></msub><mi mathvariant="normal">/</mi><mi>c</mi><mo fence="true">)</mo></mrow></mrow></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{gathered}
\boldsymbol{E}_{\perp}^{\prime} / c=\gamma\left(\boldsymbol{E}_{\perp} / c+\boldsymbol{v} / c \times \boldsymbol{B}_{\perp}\right), \\
\boldsymbol{B}_{\perp}^{\prime}=\gamma\left(\boldsymbol{B}_{\perp}-\boldsymbol{v} / c \times \boldsymbol{E}_{\perp} / c\right)
\end{gathered}
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:3em;vertical-align:-1.25em;"></span><span class="mord"><span class="mtable"><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.75em;"><span style="top:-3.91em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.05451em;">E</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8279em;"><span style="top:-2.453em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mrel mtight">⊥</span></span></span></span><span style="top:-3.139em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.247em;"><span></span></span></span></span></span></span><span class="mord">/</span><span class="mord mathnormal">c</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord mathnormal" style="margin-right:0.05556em;">γ</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.05451em;">E</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3361em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mrel mtight">⊥</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord">/</span><span class="mord mathnormal">c</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03704em;">v</span></span></span><span class="mord">/</span><span class="mord mathnormal">c</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">×</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.04835em;">B</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3361em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mrel mtight">⊥</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">)</span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mpunct">,</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.04835em;">B</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8279em;"><span style="top:-2.453em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mrel mtight">⊥</span></span></span></span><span style="top:-3.139em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.247em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord mathnormal" style="margin-right:0.05556em;">γ</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.04835em;">B</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3361em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mrel mtight">⊥</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03704em;">v</span></span></span><span class="mord">/</span><span class="mord mathnormal">c</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">×</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.05451em;">E</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3361em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mrel mtight">⊥</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord">/</span><span class="mord mathnormal">c</span><span class="mclose delimcenter" style="top:0em;">)</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.25em;"><span></span></span></span></span></span></span></span></span></span></span></span></p>
</li>
</ol>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Formulas for IPhO 日本語版: Section 2 ]]></title>
            <link>https://note.toshiki.devacademic/physics/ipho-formulas-jpn/2</link>
            <guid>https://note.toshiki.devacademic/physics/ipho-formulas-jpn/2</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="formulas-for-ipho-日本語版-section-2" tabindex="-1">Formulas for IPhO 日本語版: Section 2 <a class="header-anchor" href="#formulas-for-ipho-日本語版-section-2" aria-label="Permalink to &quot;Formulas for IPhO 日本語版: Section 2&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="_2-一般的な推奨事" tabindex="-1">2: 一般的な推奨事 <a class="header-anchor" href="#_2-一般的な推奨事" aria-label="Permalink to &quot;2: 一般的な推奨事&quot;">&ZeroWidthSpace;</a></h2>
<ol>
<li>全ての計算式の正しさを確かめる：a) 次元を調べる.
b) 簡単で特別な場合を調べる（2 つの変数が等しい, 1
つの変数が 0 または <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∞</mi></mrow><annotation encoding="application/x-tex">\infty</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord">∞</span></span></span></span> ). c) 解の定性的な挙動の妥当 性を調ベる. 2.もし問題文中に驚くベき偶然の一致があれば（例えば 2 つのものが同じ), 解答の鍵はそこにあるかもしれ ない.</li>
<li>問題文中の推奨事項をよく読む. 些細な部分に重要な 情報が含まれている場合があるので，問題文の文言に 注意する. かなり時間をかけても問題が解けない場合 は, 問題を誤解しているかもしれないので, もう一度 問題文を読む.</li>
<li>長くて時間のかかる計算は, 簡略化しなければならな い始めの方程式を全て書き出したのち, 最後（他の全 てが終わったとき) まで先送りする.</li>
<li>絶望的に難しいと思われる問題でも，たいてい非常に シンプルな解法がある.オリンピックの問題に限って 言えば，絶対に解ける.</li>
<li>実験では, a) 測定するほどの時問が無いとしても, 実 験計画の概略を書く，b) 結果の正確さを高める方法を 考える，c) 測定した值を全て（表として）書き出す.</li>
</ol>
]]></description>
            <content:encoded><![CDATA[<h1 id="formulas-for-ipho-日本語版-section-2" tabindex="-1">Formulas for IPhO 日本語版: Section 2 <a class="header-anchor" href="#formulas-for-ipho-日本語版-section-2" aria-label="Permalink to &quot;Formulas for IPhO 日本語版: Section 2&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="_2-一般的な推奨事" tabindex="-1">2: 一般的な推奨事 <a class="header-anchor" href="#_2-一般的な推奨事" aria-label="Permalink to &quot;2: 一般的な推奨事&quot;">&ZeroWidthSpace;</a></h2>
<ol>
<li>全ての計算式の正しさを確かめる：a) 次元を調べる.
b) 簡単で特別な場合を調べる（2 つの変数が等しい, 1
つの変数が 0 または <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∞</mi></mrow><annotation encoding="application/x-tex">\infty</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord">∞</span></span></span></span> ). c) 解の定性的な挙動の妥当 性を調ベる. 2.もし問題文中に驚くベき偶然の一致があれば（例えば 2 つのものが同じ), 解答の鍵はそこにあるかもしれ ない.</li>
<li>問題文中の推奨事項をよく読む. 些細な部分に重要な 情報が含まれている場合があるので，問題文の文言に 注意する. かなり時間をかけても問題が解けない場合 は, 問題を誤解しているかもしれないので, もう一度 問題文を読む.</li>
<li>長くて時間のかかる計算は, 簡略化しなければならな い始めの方程式を全て書き出したのち, 最後（他の全 てが終わったとき) まで先送りする.</li>
<li>絶望的に難しいと思われる問題でも，たいてい非常に シンプルな解法がある.オリンピックの問題に限って 言えば，絶対に解ける.</li>
<li>実験では, a) 測定するほどの時問が無いとしても, 実 験計画の概略を書く，b) 結果の正確さを高める方法を 考える，c) 測定した值を全て（表として）書き出す.</li>
</ol>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Formulas for IPhO 日本語版: Section 3 ]]></title>
            <link>https://note.toshiki.devacademic/physics/ipho-formulas-jpn/3</link>
            <guid>https://note.toshiki.devacademic/physics/ipho-formulas-jpn/3</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="formulas-for-ipho-日本語版-section-3" tabindex="-1">Formulas for IPhO 日本語版: Section 3 <a class="header-anchor" href="#formulas-for-ipho-日本語版-section-3" aria-label="Permalink to &quot;Formulas for IPhO 日本語版: Section 3&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="_3-運動学" tabindex="-1">3: 運動学 <a class="header-anchor" href="#_3-運動学" aria-label="Permalink to &quot;3: 運動学&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="_3-1-質点" tabindex="-1">3.1: 質点 <a class="header-anchor" href="#_3-1-質点" aria-label="Permalink to &quot;3.1: 質点&quot;">&ZeroWidthSpace;</a></h3>
<ol>
<li>質点または剛体の並進運動の場合（積分 → グラフの下
の面積）：<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mtable rowspacing="0.25em" columnalign="center" columnspacing="0em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mi mathvariant="bold-italic">v</mi><mo>=</mo><mfrac><mrow><mi mathvariant="normal">d</mi><mi mathvariant="bold-italic">x</mi></mrow><mrow><mi mathvariant="normal">d</mi><mi>t</mi></mrow></mfrac><mo separator="true">,</mo><mi mathvariant="bold-italic">x</mi><mo>=</mo><mo>∫</mo><mi mathvariant="bold-italic">v</mi><mi mathvariant="normal">d</mi><mi>t</mi><mrow><mo fence="true">(</mo><mi>x</mi><mo>=</mo><mo>∫</mo><msub><mi>v</mi><mi>x</mi></msub><mrow><mtext> </mtext><mi mathvariant="normal">d</mi></mrow><mi>t</mi><mtext> など </mtext><mo fence="true">)</mo></mrow></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mi mathvariant="bold-italic">a</mi><mo>=</mo><mfrac><mrow><mi mathvariant="normal">d</mi><mi mathvariant="bold-italic">v</mi></mrow><mrow><mi mathvariant="normal">d</mi><mi>t</mi></mrow></mfrac><mo>=</mo><mfrac><mrow><msup><mi mathvariant="normal">d</mi><mn>2</mn></msup><mi mathvariant="bold-italic">x</mi></mrow><mrow><mi mathvariant="normal">d</mi><msup><mi>t</mi><mn>2</mn></msup></mrow></mfrac><mo separator="true">,</mo><mi mathvariant="bold-italic">v</mi><mo>=</mo><mo>∫</mo><mi mathvariant="bold-italic">a</mi><mi mathvariant="normal">d</mi><mi>t</mi></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mi>t</mi><mo>=</mo><mo>∫</mo><msubsup><mi>v</mi><mi>x</mi><mrow><mo>−</mo><mn>1</mn></mrow></msubsup><mrow><mtext> </mtext><mi mathvariant="normal">d</mi></mrow><mi>x</mi><mo>=</mo><mo>∫</mo><msubsup><mi>a</mi><mi>x</mi><mrow><mo>−</mo><mn>1</mn></mrow></msubsup><mrow><mtext> </mtext><mi mathvariant="normal">d</mi></mrow><msub><mi>v</mi><mi>x</mi></msub><mo separator="true">,</mo><mi>x</mi><mo>=</mo><mo>∫</mo><mfrac><msub><mi>v</mi><mi>x</mi></msub><msub><mi>a</mi><mi>x</mi></msub></mfrac><mrow><mtext> </mtext><mi mathvariant="normal">d</mi></mrow><msub><mi>v</mi><mi>x</mi></msub></mrow></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{gathered}
\boldsymbol{v}=\frac{\mathrm{d} \boldsymbol{x}}{\mathrm{d} t}, \boldsymbol{x}=\int \boldsymbol{v} \mathrm{d} t\left(x=\int v_x \mathrm{~d} t \text { など }\right) \\
\boldsymbol{a}=\frac{\mathrm{d} \boldsymbol{v}}{\mathrm{d} t}=\frac{\mathrm{d}^2 \boldsymbol{x}}{\mathrm{d} t^2}, \boldsymbol{v}=\int \boldsymbol{a} \mathrm{d} t \\
t=\int v_x^{-1} \mathrm{~d} x=\int a_x^{-1} \mathrm{~d} v_x, x=\int \frac{v_x}{a_x} \mathrm{~d} v_x
\end{gathered}
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:7.8756em;vertical-align:-3.6878em;"></span><span class="mord"><span class="mtable"><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:4.1878em;"><span style="top:-6.2289em;"><span class="pstrut" style="height:3.4911em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03704em;">v</span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.3714em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathrm">d</span><span class="mord mathnormal">t</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathrm">d</span><span class="mord"><span class="mord"><span class="mord boldsymbol">x</span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol">x</span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mop op-symbol large-op" style="margin-right:0.44445em;position:relative;top:-0.0011em;">∫</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03704em;">v</span></span></span><span class="mord mathrm">d</span><span class="mord mathnormal">t</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size3">(</span></span><span class="mord mathnormal">x</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mop op-symbol large-op" style="margin-right:0.44445em;position:relative;top:-0.0011em;">∫</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">x</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">d</span></span><span class="mord mathnormal">t</span><span class="mord text"><span class="mord"> </span><span class="mord cjk_fallback">など</span><span class="mord"> </span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size3">)</span></span></span></span></span><span style="top:-3.4878em;"><span class="pstrut" style="height:3.4911em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol">a</span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.3714em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathrm">d</span><span class="mord mathnormal">t</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathrm">d</span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03704em;">v</span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.4911em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathrm">d</span><span class="mord"><span class="mord mathnormal">t</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7401em;"><span style="top:-2.989em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"><span class="mord mathrm">d</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mord"><span class="mord"><span class="mord boldsymbol">x</span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03704em;">v</span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mop op-symbol large-op" style="margin-right:0.44445em;position:relative;top:-0.0011em;">∫</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol">a</span></span></span><span class="mord mathrm">d</span><span class="mord mathnormal">t</span></span></span><span style="top:-0.9655em;"><span class="pstrut" style="height:3.4911em;"></span><span class="mord"><span class="mord mathnormal">t</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mop op-symbol large-op" style="margin-right:0.44445em;position:relative;top:-0.0011em;">∫</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-2.453em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">x</span></span></span><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">−</span><span class="mord mtight">1</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.247em;"><span></span></span></span></span></span></span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">d</span></span><span class="mord mathnormal">x</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mop op-symbol large-op" style="margin-right:0.44445em;position:relative;top:-0.0011em;">∫</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-2.453em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">x</span></span></span><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">−</span><span class="mord mtight">1</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.247em;"><span></span></span></span></span></span></span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">d</span></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">x</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">x</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mop op-symbol large-op" style="margin-right:0.44445em;position:relative;top:-0.0011em;">∫</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1076em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">x</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">x</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.836em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">d</span></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">x</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:3.6878em;"><span></span></span></span></span></span></span></span></span></span></span></span></p>
もし <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi></mrow><annotation encoding="application/x-tex">a</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">a</span></span></span></span> が定数ならば, これらの積分は簡単に求めるこ
とができて, 例えば<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mi>x</mi><mo>=</mo><msub><mi>v</mi><mn>0</mn></msub><mi>t</mi><mo>+</mo><mi>a</mi><msup><mi>t</mi><mn>2</mn></msup><mi mathvariant="normal">/</mi><mn>2</mn><mo>=</mo><mrow><mo fence="true">(</mo><msup><mi>v</mi><mn>2</mn></msup><mo>−</mo><msubsup><mi>v</mi><mn>0</mn><mn>2</mn></msubsup><mo fence="true">)</mo></mrow><mi mathvariant="normal">/</mi><mn>2</mn><mi>a</mi><mtext>. </mtext></mrow><annotation encoding="application/x-tex">x=v_0 t+a t^2 / 2=\left(v^2-v_0^2\right) / 2 a \text {. }
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">x</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.7651em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">0</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord mathnormal">t</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1.1141em;vertical-align:-0.25em;"></span><span class="mord mathnormal">a</span><span class="mord"><span class="mord mathnormal">t</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mord">/2</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.2141em;vertical-align:-0.35em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size1">(</span></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-2.453em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">0</span></span></span><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.247em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size1">)</span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord">/2</span><span class="mord mathnormal">a</span><span class="mord text"><span class="mord">. </span></span></span></span></span></span></p>
</li>
</ol>
<h3 id="_3-2-回転運動" tabindex="-1">3.2: 回転運動 <a class="header-anchor" href="#_3-2-回転運動" aria-label="Permalink to &quot;3.2: 回転運動&quot;">&ZeroWidthSpace;</a></h3>
<ol start="2">
<li>回転運動は, 並進運動と似ていて：<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mtable rowspacing="0.25em" columnalign="right left" columnspacing="0em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mi>ω</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mo>=</mo><mi mathvariant="normal">d</mi><mi>φ</mi><mi mathvariant="normal">/</mi><mi mathvariant="normal">d</mi><mi>t</mi><mo separator="true">,</mo><mi>ε</mi><mo>=</mo><mi mathvariant="normal">d</mi><mi>ω</mi><mi mathvariant="normal">/</mi><mi mathvariant="normal">d</mi><mi>t</mi></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mi mathvariant="bold-italic">a</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mo>=</mo><mi mathvariant="bold-italic">τ</mi><mi mathvariant="normal">d</mi><mi>v</mi><mi mathvariant="normal">/</mi><mi mathvariant="normal">d</mi><mi>t</mi><mo>+</mo><mi mathvariant="bold-italic">n</mi><msup><mi>v</mi><mn>2</mn></msup><mi mathvariant="normal">/</mi><mi>R</mi></mrow></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{aligned}
\omega &amp; =\mathrm{d} \varphi / \mathrm{d} t, \varepsilon=\mathrm{d} \omega / \mathrm{d} t \\
\boldsymbol{a} &amp; =\boldsymbol{\tau} \mathrm{d} v / \mathrm{d} t+\boldsymbol{n} v^2 / R
\end{aligned}
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:3.0241em;vertical-align:-1.2621em;"></span><span class="mord"><span class="mtable"><span class="col-align-r"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.7621em;"><span style="top:-3.9221em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">ω</span></span></span><span style="top:-2.3979em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol">a</span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.2621em;"><span></span></span></span></span></span><span class="col-align-l"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.7621em;"><span style="top:-3.9221em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord mathrm">d</span><span class="mord mathnormal">φ</span><span class="mord">/</span><span class="mord mathrm">d</span><span class="mord mathnormal">t</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">ε</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord mathrm">d</span><span class="mord mathnormal" style="margin-right:0.03588em;">ω</span><span class="mord">/</span><span class="mord mathrm">d</span><span class="mord mathnormal">t</span></span></span><span style="top:-2.3979em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.13472em;">τ</span></span></span><span class="mord mathrm">d</span><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="mord">/</span><span class="mord mathrm">d</span><span class="mord mathnormal">t</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol">n</span></span></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mord">/</span><span class="mord mathnormal" style="margin-right:0.00773em;">R</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.2621em;"><span></span></span></span></span></span></span></span></span></span></span></span></p>
</li>
</ol>
<h3 id="_3-3-曲線運動" tabindex="-1">3.3: 曲線運動 <a class="header-anchor" href="#_3-3-曲線運動" aria-label="Permalink to &quot;3.3: 曲線運動&quot;">&ZeroWidthSpace;</a></h3>
<ol start="3">
<li>曲線運動は，ポイント 1 と同じだが，ベクトルは線速 度，加速度，経路長に置き換える.</li>
</ol>
<h3 id="_3-4-剛体の運動" tabindex="-1">3.4: 剛体の運動 <a class="header-anchor" href="#_3-4-剛体の運動" aria-label="Permalink to &quot;3.4: 剛体の運動&quot;">&ZeroWidthSpace;</a></h3>
<ol start="4">
<li>剛体の運動:
<ul>
<li><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>v</mi><mi>A</mi></msub><mi>cos</mi><mo>⁡</mo><mi>α</mi><mo>=</mo><msub><mi>v</mi><mi>B</mi></msub><mi>cos</mi><mo>⁡</mo><mi>β</mi></mrow><annotation encoding="application/x-tex">v_A \cos \alpha=v_B \cos \beta</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">A</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">cos</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.0037em;">α</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.05017em;">B</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">cos</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.05278em;">β</span></span></span></span> ここで, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi mathvariant="bold-italic">v</mi><mi>A</mi></msub></mrow><annotation encoding="application/x-tex">\boldsymbol{v}_A</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5944em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03704em;">v</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">A</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> と <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi mathvariant="bold-italic">v</mi><mi>B</mi></msub></mrow><annotation encoding="application/x-tex">\boldsymbol{v}_B</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5944em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03704em;">v</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.05017em;">B</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> は剛体上の点 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>A</mi></mrow><annotation encoding="application/x-tex">A</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal">A</span></span></span></span> と <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>B</mi></mrow><annotation encoding="application/x-tex">B</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span></span> の速度, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>α</mi></mrow><annotation encoding="application/x-tex">\alpha</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal" style="margin-right:0.0037em;">α</span></span></span></span> と <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>β</mi></mrow><annotation encoding="application/x-tex">\beta</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.05278em;">β</span></span></span></span> は <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi mathvariant="bold-italic">v</mi><mi>A</mi></msub></mrow><annotation encoding="application/x-tex">\boldsymbol{v}_A</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5944em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03704em;">v</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">A</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> と <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi mathvariant="bold-italic">v</mi><mi>B</mi></msub></mrow><annotation encoding="application/x-tex">\boldsymbol{v}_B</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5944em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03704em;">v</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.05017em;">B</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> が直線 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>A</mi><mi>B</mi></mrow><annotation encoding="application/x-tex">A B</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span></span> となす角.</li>
<li>瞬間回転中心 (#質点の軌道 の曲率中心）は, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="bold-italic">a</mi></mrow><annotation encoding="application/x-tex">\boldsymbol{a}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4444em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol">a</span></span></span></span></span></span> と <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="bold-italic">b</mi></mrow><annotation encoding="application/x-tex">\boldsymbol{b}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol">b</span></span></span></span></span></span> に下ろした垂線の交点. 又は もし <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi mathvariant="bold-italic">v</mi><mi>A</mi></msub><mo separator="true">,</mo><msub><mi mathvariant="bold-italic">v</mi><mi>B</mi></msub><mo>⊥</mo><mi>A</mi><mi>B</mi></mrow><annotation encoding="application/x-tex">\boldsymbol{v}_A, \boldsymbol{v}_B \perp A B</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03704em;">v</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">A</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03704em;">v</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.05017em;">B</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">⊥</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span></span> ならば, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi mathvariant="bold-italic">v</mi><mi>A</mi></msub></mrow><annotation encoding="application/x-tex">\boldsymbol{v}_A</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5944em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03704em;">v</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">A</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> と <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi mathvariant="bold-italic">v</mi><mi>B</mi></msub></mrow><annotation encoding="application/x-tex">\boldsymbol{v}_B</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5944em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03704em;">v</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.05017em;">B</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> の先端を結ぶ 直線と <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>A</mi><mi>B</mi></mrow><annotation encoding="application/x-tex">A B</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span></span> の交点.</li>
</ul>
</li>
</ol>
<h3 id="_3-5-非慣性系" tabindex="-1">3.5: 非慣性系 <a class="header-anchor" href="#_3-5-非慣性系" aria-label="Permalink to &quot;3.5: 非慣性系&quot;">&ZeroWidthSpace;</a></h3>
<ol start="5">
<li>非慣性系：<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mtable rowspacing="0.16em" columnalign="right" columnspacing="1em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mrow><mspace width="1em"/><msub><mi mathvariant="bold-italic">v</mi><mn>2</mn></msub><mo>=</mo><msub><mi mathvariant="bold-italic">v</mi><mn>0</mn></msub><mo>+</mo><msub><mi mathvariant="bold-italic">v</mi><mn>1</mn></msub><mo separator="true">,</mo><msub><mi mathvariant="bold-italic">a</mi><mn>2</mn></msub><mo>=</mo><msub><mi mathvariant="bold-italic">a</mi><mn>0</mn></msub><mo>+</mo><msub><mi mathvariant="bold-italic">a</mi><mn>1</mn></msub><mo>+</mo><msup><mi>ω</mi><mn>2</mn></msup><mi mathvariant="bold-italic">R</mi><mo>+</mo><msub><mi mathvariant="bold-italic">a</mi><mrow><mi>C</mi><mi>o</mi><mi>r</mi></mrow></msub></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mrow><mtext> ここで, </mtext><msub><mi mathvariant="bold-italic">a</mi><mrow><mi>C</mi><mi>o</mi><mi>r</mi></mrow></msub><mo>⊥</mo><msub><mi mathvariant="bold-italic">v</mi><mn>1</mn></msub><mi mathvariant="normal">.</mi><mtext> もし </mtext><msub><mi mathvariant="bold-italic">v</mi><mn>1</mn></msub><mo>=</mo><mn>0</mn><mtext> なら </mtext><msub><mi mathvariant="bold-italic">a</mi><mrow><mi>C</mi><mi>o</mi><mi>r</mi></mrow></msub><mo>=</mo><mn>0.</mn></mrow></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{array}{r}
\quad \boldsymbol{v}_2=\boldsymbol{v}_0+\boldsymbol{v}_1, \boldsymbol{a}_2=\boldsymbol{a}_0+\boldsymbol{a}_1+\omega^2 \boldsymbol{R}+\boldsymbol{a}_{C o r} \\
\text { ここで, } \boldsymbol{a}_{C o r} \perp \boldsymbol{v}_1 . \text { もし } \boldsymbol{v}_1=0 \text { なら } \boldsymbol{a}_{C o r}=0 .
\end{array}
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.4em;vertical-align:-0.95em;"></span><span class="mord"><span class="mtable"><span class="arraycolsep" style="width:0.5em;"></span><span class="col-align-r"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mspace" style="margin-right:1em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03704em;">v</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03704em;">v</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">0</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03704em;">v</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol">a</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol">a</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">0</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol">a</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">ω</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.00421em;">R</span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol">a</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.07153em;">C</span><span class="mord mathnormal mtight" style="margin-right:0.02778em;">or</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord text"><span class="mord"> </span><span class="mord cjk_fallback">ここで</span><span class="mord">, </span></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol">a</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.07153em;">C</span><span class="mord mathnormal mtight" style="margin-right:0.02778em;">or</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">⊥</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03704em;">v</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord">.</span><span class="mord text"><span class="mord"> </span><span class="mord cjk_fallback">もし</span><span class="mord"> </span></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03704em;">v</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord">0</span><span class="mord text"><span class="mord"> </span><span class="mord cjk_fallback">なら</span><span class="mord"> </span></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol">a</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.07153em;">C</span><span class="mord mathnormal mtight" style="margin-right:0.02778em;">or</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord">0.</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:0.5em;"></span></span></span></span></span></span></span></p>
</li>
</ol>
<h3 id="_3-6-弾道問題" tabindex="-1">3.6: 弾道問題 <Badge type="tip" text="supplemental" /> <a class="header-anchor" href="#_3-6-弾道問題" aria-label="Permalink to &quot;3.6: 弾道問題 &lt;Badge type=&quot;tip&quot; text=&quot;supplemental&quot; /&gt;&quot;">&ZeroWidthSpace;</a></h3>
<ol start="6">
<li>弾道問題：到達可能な範囲は<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mi>y</mi><mo>≤</mo><msubsup><mi>v</mi><mn>0</mn><mn>2</mn></msubsup><mi mathvariant="normal">/</mi><mo stretchy="false">(</mo><mn>2</mn><mi>g</mi><mo stretchy="false">)</mo><mo>−</mo><mi>g</mi><msup><mi>x</mi><mn>2</mn></msup><mi mathvariant="normal">/</mi><mrow><mo fence="true">(</mo><mn>2</mn><msubsup><mi>v</mi><mn>0</mn><mn>2</mn></msubsup><mo fence="true">)</mo></mrow></mrow><annotation encoding="application/x-tex">y \leq v_0^2 /(2 g)-g x^2 /\left(2 v_0^2\right)
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8304em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">y</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≤</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.1141em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-2.453em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">0</span></span></span><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.247em;"><span></span></span></span></span></span></span><span class="mord">/</span><span class="mopen">(</span><span class="mord">2</span><span class="mord mathnormal" style="margin-right:0.03588em;">g</span><span class="mclose">)</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1.2141em;vertical-align:-0.35em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">g</span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mord">/</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size1">(</span></span><span class="mord">2</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-2.453em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">0</span></span></span><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.247em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size1">)</span></span></span></span></span></span></span></p>
最適な弾道では, 初速度と終速（衝突時の速度）が垂直 になる.</li>
</ol>
<h3 id="_3-7-最短経路" tabindex="-1">3.7: 最短経路 <a class="header-anchor" href="#_3-7-最短経路" aria-label="Permalink to &quot;3.7: 最短経路&quot;">&ZeroWidthSpace;</a></h3>
<ol start="7">
<li>最短経路を求めるには，Fermat と Huygens の原理が 使える.</li>
</ol>
<h3 id="_3-8-ベクトル" tabindex="-1">3.8: ベクトル <a class="header-anchor" href="#_3-8-ベクトル" aria-label="Permalink to &quot;3.8: ベクトル&quot;">&ZeroWidthSpace;</a></h3>
<ol start="8">
<li>ベクトル（速度，加速度）を求めるには，その向きと （場合によっては傾いた）ある軸への射影を求めれば 充分.</li>
</ol>
]]></description>
            <content:encoded><![CDATA[<h1 id="formulas-for-ipho-日本語版-section-3" tabindex="-1">Formulas for IPhO 日本語版: Section 3 <a class="header-anchor" href="#formulas-for-ipho-日本語版-section-3" aria-label="Permalink to &quot;Formulas for IPhO 日本語版: Section 3&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="_3-運動学" tabindex="-1">3: 運動学 <a class="header-anchor" href="#_3-運動学" aria-label="Permalink to &quot;3: 運動学&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="_3-1-質点" tabindex="-1">3.1: 質点 <a class="header-anchor" href="#_3-1-質点" aria-label="Permalink to &quot;3.1: 質点&quot;">&ZeroWidthSpace;</a></h3>
<ol>
<li>質点または剛体の並進運動の場合（積分 → グラフの下
の面積）：<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mtable rowspacing="0.25em" columnalign="center" columnspacing="0em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mi mathvariant="bold-italic">v</mi><mo>=</mo><mfrac><mrow><mi mathvariant="normal">d</mi><mi mathvariant="bold-italic">x</mi></mrow><mrow><mi mathvariant="normal">d</mi><mi>t</mi></mrow></mfrac><mo separator="true">,</mo><mi mathvariant="bold-italic">x</mi><mo>=</mo><mo>∫</mo><mi mathvariant="bold-italic">v</mi><mi mathvariant="normal">d</mi><mi>t</mi><mrow><mo fence="true">(</mo><mi>x</mi><mo>=</mo><mo>∫</mo><msub><mi>v</mi><mi>x</mi></msub><mrow><mtext> </mtext><mi mathvariant="normal">d</mi></mrow><mi>t</mi><mtext> など </mtext><mo fence="true">)</mo></mrow></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mi mathvariant="bold-italic">a</mi><mo>=</mo><mfrac><mrow><mi mathvariant="normal">d</mi><mi mathvariant="bold-italic">v</mi></mrow><mrow><mi mathvariant="normal">d</mi><mi>t</mi></mrow></mfrac><mo>=</mo><mfrac><mrow><msup><mi mathvariant="normal">d</mi><mn>2</mn></msup><mi mathvariant="bold-italic">x</mi></mrow><mrow><mi mathvariant="normal">d</mi><msup><mi>t</mi><mn>2</mn></msup></mrow></mfrac><mo separator="true">,</mo><mi mathvariant="bold-italic">v</mi><mo>=</mo><mo>∫</mo><mi mathvariant="bold-italic">a</mi><mi mathvariant="normal">d</mi><mi>t</mi></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mi>t</mi><mo>=</mo><mo>∫</mo><msubsup><mi>v</mi><mi>x</mi><mrow><mo>−</mo><mn>1</mn></mrow></msubsup><mrow><mtext> </mtext><mi mathvariant="normal">d</mi></mrow><mi>x</mi><mo>=</mo><mo>∫</mo><msubsup><mi>a</mi><mi>x</mi><mrow><mo>−</mo><mn>1</mn></mrow></msubsup><mrow><mtext> </mtext><mi mathvariant="normal">d</mi></mrow><msub><mi>v</mi><mi>x</mi></msub><mo separator="true">,</mo><mi>x</mi><mo>=</mo><mo>∫</mo><mfrac><msub><mi>v</mi><mi>x</mi></msub><msub><mi>a</mi><mi>x</mi></msub></mfrac><mrow><mtext> </mtext><mi mathvariant="normal">d</mi></mrow><msub><mi>v</mi><mi>x</mi></msub></mrow></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{gathered}
\boldsymbol{v}=\frac{\mathrm{d} \boldsymbol{x}}{\mathrm{d} t}, \boldsymbol{x}=\int \boldsymbol{v} \mathrm{d} t\left(x=\int v_x \mathrm{~d} t \text { など }\right) \\
\boldsymbol{a}=\frac{\mathrm{d} \boldsymbol{v}}{\mathrm{d} t}=\frac{\mathrm{d}^2 \boldsymbol{x}}{\mathrm{d} t^2}, \boldsymbol{v}=\int \boldsymbol{a} \mathrm{d} t \\
t=\int v_x^{-1} \mathrm{~d} x=\int a_x^{-1} \mathrm{~d} v_x, x=\int \frac{v_x}{a_x} \mathrm{~d} v_x
\end{gathered}
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:7.8756em;vertical-align:-3.6878em;"></span><span class="mord"><span class="mtable"><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:4.1878em;"><span style="top:-6.2289em;"><span class="pstrut" style="height:3.4911em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03704em;">v</span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.3714em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathrm">d</span><span class="mord mathnormal">t</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathrm">d</span><span class="mord"><span class="mord"><span class="mord boldsymbol">x</span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol">x</span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mop op-symbol large-op" style="margin-right:0.44445em;position:relative;top:-0.0011em;">∫</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03704em;">v</span></span></span><span class="mord mathrm">d</span><span class="mord mathnormal">t</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size3">(</span></span><span class="mord mathnormal">x</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mop op-symbol large-op" style="margin-right:0.44445em;position:relative;top:-0.0011em;">∫</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">x</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">d</span></span><span class="mord mathnormal">t</span><span class="mord text"><span class="mord"> </span><span class="mord cjk_fallback">など</span><span class="mord"> </span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size3">)</span></span></span></span></span><span style="top:-3.4878em;"><span class="pstrut" style="height:3.4911em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol">a</span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.3714em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathrm">d</span><span class="mord mathnormal">t</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathrm">d</span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03704em;">v</span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.4911em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathrm">d</span><span class="mord"><span class="mord mathnormal">t</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7401em;"><span style="top:-2.989em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"><span class="mord mathrm">d</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mord"><span class="mord"><span class="mord boldsymbol">x</span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03704em;">v</span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mop op-symbol large-op" style="margin-right:0.44445em;position:relative;top:-0.0011em;">∫</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol">a</span></span></span><span class="mord mathrm">d</span><span class="mord mathnormal">t</span></span></span><span style="top:-0.9655em;"><span class="pstrut" style="height:3.4911em;"></span><span class="mord"><span class="mord mathnormal">t</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mop op-symbol large-op" style="margin-right:0.44445em;position:relative;top:-0.0011em;">∫</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-2.453em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">x</span></span></span><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">−</span><span class="mord mtight">1</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.247em;"><span></span></span></span></span></span></span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">d</span></span><span class="mord mathnormal">x</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mop op-symbol large-op" style="margin-right:0.44445em;position:relative;top:-0.0011em;">∫</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-2.453em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">x</span></span></span><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">−</span><span class="mord mtight">1</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.247em;"><span></span></span></span></span></span></span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">d</span></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">x</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">x</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mop op-symbol large-op" style="margin-right:0.44445em;position:relative;top:-0.0011em;">∫</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1076em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">x</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">x</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.836em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">d</span></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">x</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:3.6878em;"><span></span></span></span></span></span></span></span></span></span></span></span></p>
もし <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi></mrow><annotation encoding="application/x-tex">a</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">a</span></span></span></span> が定数ならば, これらの積分は簡単に求めるこ
とができて, 例えば<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mi>x</mi><mo>=</mo><msub><mi>v</mi><mn>0</mn></msub><mi>t</mi><mo>+</mo><mi>a</mi><msup><mi>t</mi><mn>2</mn></msup><mi mathvariant="normal">/</mi><mn>2</mn><mo>=</mo><mrow><mo fence="true">(</mo><msup><mi>v</mi><mn>2</mn></msup><mo>−</mo><msubsup><mi>v</mi><mn>0</mn><mn>2</mn></msubsup><mo fence="true">)</mo></mrow><mi mathvariant="normal">/</mi><mn>2</mn><mi>a</mi><mtext>. </mtext></mrow><annotation encoding="application/x-tex">x=v_0 t+a t^2 / 2=\left(v^2-v_0^2\right) / 2 a \text {. }
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">x</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.7651em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">0</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord mathnormal">t</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1.1141em;vertical-align:-0.25em;"></span><span class="mord mathnormal">a</span><span class="mord"><span class="mord mathnormal">t</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mord">/2</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.2141em;vertical-align:-0.35em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size1">(</span></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-2.453em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">0</span></span></span><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.247em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size1">)</span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord">/2</span><span class="mord mathnormal">a</span><span class="mord text"><span class="mord">. </span></span></span></span></span></span></p>
</li>
</ol>
<h3 id="_3-2-回転運動" tabindex="-1">3.2: 回転運動 <a class="header-anchor" href="#_3-2-回転運動" aria-label="Permalink to &quot;3.2: 回転運動&quot;">&ZeroWidthSpace;</a></h3>
<ol start="2">
<li>回転運動は, 並進運動と似ていて：<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mtable rowspacing="0.25em" columnalign="right left" columnspacing="0em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mi>ω</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mo>=</mo><mi mathvariant="normal">d</mi><mi>φ</mi><mi mathvariant="normal">/</mi><mi mathvariant="normal">d</mi><mi>t</mi><mo separator="true">,</mo><mi>ε</mi><mo>=</mo><mi mathvariant="normal">d</mi><mi>ω</mi><mi mathvariant="normal">/</mi><mi mathvariant="normal">d</mi><mi>t</mi></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mi mathvariant="bold-italic">a</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mo>=</mo><mi mathvariant="bold-italic">τ</mi><mi mathvariant="normal">d</mi><mi>v</mi><mi mathvariant="normal">/</mi><mi mathvariant="normal">d</mi><mi>t</mi><mo>+</mo><mi mathvariant="bold-italic">n</mi><msup><mi>v</mi><mn>2</mn></msup><mi mathvariant="normal">/</mi><mi>R</mi></mrow></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{aligned}
\omega &amp; =\mathrm{d} \varphi / \mathrm{d} t, \varepsilon=\mathrm{d} \omega / \mathrm{d} t \\
\boldsymbol{a} &amp; =\boldsymbol{\tau} \mathrm{d} v / \mathrm{d} t+\boldsymbol{n} v^2 / R
\end{aligned}
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:3.0241em;vertical-align:-1.2621em;"></span><span class="mord"><span class="mtable"><span class="col-align-r"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.7621em;"><span style="top:-3.9221em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">ω</span></span></span><span style="top:-2.3979em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol">a</span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.2621em;"><span></span></span></span></span></span><span class="col-align-l"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.7621em;"><span style="top:-3.9221em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord mathrm">d</span><span class="mord mathnormal">φ</span><span class="mord">/</span><span class="mord mathrm">d</span><span class="mord mathnormal">t</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">ε</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord mathrm">d</span><span class="mord mathnormal" style="margin-right:0.03588em;">ω</span><span class="mord">/</span><span class="mord mathrm">d</span><span class="mord mathnormal">t</span></span></span><span style="top:-2.3979em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.13472em;">τ</span></span></span><span class="mord mathrm">d</span><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="mord">/</span><span class="mord mathrm">d</span><span class="mord mathnormal">t</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol">n</span></span></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mord">/</span><span class="mord mathnormal" style="margin-right:0.00773em;">R</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.2621em;"><span></span></span></span></span></span></span></span></span></span></span></span></p>
</li>
</ol>
<h3 id="_3-3-曲線運動" tabindex="-1">3.3: 曲線運動 <a class="header-anchor" href="#_3-3-曲線運動" aria-label="Permalink to &quot;3.3: 曲線運動&quot;">&ZeroWidthSpace;</a></h3>
<ol start="3">
<li>曲線運動は，ポイント 1 と同じだが，ベクトルは線速 度，加速度，経路長に置き換える.</li>
</ol>
<h3 id="_3-4-剛体の運動" tabindex="-1">3.4: 剛体の運動 <a class="header-anchor" href="#_3-4-剛体の運動" aria-label="Permalink to &quot;3.4: 剛体の運動&quot;">&ZeroWidthSpace;</a></h3>
<ol start="4">
<li>剛体の運動:
<ul>
<li><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>v</mi><mi>A</mi></msub><mi>cos</mi><mo>⁡</mo><mi>α</mi><mo>=</mo><msub><mi>v</mi><mi>B</mi></msub><mi>cos</mi><mo>⁡</mo><mi>β</mi></mrow><annotation encoding="application/x-tex">v_A \cos \alpha=v_B \cos \beta</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">A</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">cos</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.0037em;">α</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.05017em;">B</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">cos</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.05278em;">β</span></span></span></span> ここで, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi mathvariant="bold-italic">v</mi><mi>A</mi></msub></mrow><annotation encoding="application/x-tex">\boldsymbol{v}_A</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5944em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03704em;">v</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">A</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> と <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi mathvariant="bold-italic">v</mi><mi>B</mi></msub></mrow><annotation encoding="application/x-tex">\boldsymbol{v}_B</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5944em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03704em;">v</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.05017em;">B</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> は剛体上の点 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>A</mi></mrow><annotation encoding="application/x-tex">A</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal">A</span></span></span></span> と <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>B</mi></mrow><annotation encoding="application/x-tex">B</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span></span> の速度, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>α</mi></mrow><annotation encoding="application/x-tex">\alpha</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal" style="margin-right:0.0037em;">α</span></span></span></span> と <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>β</mi></mrow><annotation encoding="application/x-tex">\beta</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.05278em;">β</span></span></span></span> は <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi mathvariant="bold-italic">v</mi><mi>A</mi></msub></mrow><annotation encoding="application/x-tex">\boldsymbol{v}_A</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5944em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03704em;">v</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">A</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> と <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi mathvariant="bold-italic">v</mi><mi>B</mi></msub></mrow><annotation encoding="application/x-tex">\boldsymbol{v}_B</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5944em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03704em;">v</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.05017em;">B</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> が直線 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>A</mi><mi>B</mi></mrow><annotation encoding="application/x-tex">A B</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span></span> となす角.</li>
<li>瞬間回転中心 (#質点の軌道 の曲率中心）は, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="bold-italic">a</mi></mrow><annotation encoding="application/x-tex">\boldsymbol{a}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4444em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol">a</span></span></span></span></span></span> と <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="bold-italic">b</mi></mrow><annotation encoding="application/x-tex">\boldsymbol{b}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol">b</span></span></span></span></span></span> に下ろした垂線の交点. 又は もし <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi mathvariant="bold-italic">v</mi><mi>A</mi></msub><mo separator="true">,</mo><msub><mi mathvariant="bold-italic">v</mi><mi>B</mi></msub><mo>⊥</mo><mi>A</mi><mi>B</mi></mrow><annotation encoding="application/x-tex">\boldsymbol{v}_A, \boldsymbol{v}_B \perp A B</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03704em;">v</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">A</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03704em;">v</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.05017em;">B</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">⊥</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span></span> ならば, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi mathvariant="bold-italic">v</mi><mi>A</mi></msub></mrow><annotation encoding="application/x-tex">\boldsymbol{v}_A</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5944em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03704em;">v</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">A</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> と <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi mathvariant="bold-italic">v</mi><mi>B</mi></msub></mrow><annotation encoding="application/x-tex">\boldsymbol{v}_B</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5944em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03704em;">v</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.05017em;">B</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> の先端を結ぶ 直線と <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>A</mi><mi>B</mi></mrow><annotation encoding="application/x-tex">A B</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span></span> の交点.</li>
</ul>
</li>
</ol>
<h3 id="_3-5-非慣性系" tabindex="-1">3.5: 非慣性系 <a class="header-anchor" href="#_3-5-非慣性系" aria-label="Permalink to &quot;3.5: 非慣性系&quot;">&ZeroWidthSpace;</a></h3>
<ol start="5">
<li>非慣性系：<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mtable rowspacing="0.16em" columnalign="right" columnspacing="1em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mrow><mspace width="1em"/><msub><mi mathvariant="bold-italic">v</mi><mn>2</mn></msub><mo>=</mo><msub><mi mathvariant="bold-italic">v</mi><mn>0</mn></msub><mo>+</mo><msub><mi mathvariant="bold-italic">v</mi><mn>1</mn></msub><mo separator="true">,</mo><msub><mi mathvariant="bold-italic">a</mi><mn>2</mn></msub><mo>=</mo><msub><mi mathvariant="bold-italic">a</mi><mn>0</mn></msub><mo>+</mo><msub><mi mathvariant="bold-italic">a</mi><mn>1</mn></msub><mo>+</mo><msup><mi>ω</mi><mn>2</mn></msup><mi mathvariant="bold-italic">R</mi><mo>+</mo><msub><mi mathvariant="bold-italic">a</mi><mrow><mi>C</mi><mi>o</mi><mi>r</mi></mrow></msub></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mrow><mtext> ここで, </mtext><msub><mi mathvariant="bold-italic">a</mi><mrow><mi>C</mi><mi>o</mi><mi>r</mi></mrow></msub><mo>⊥</mo><msub><mi mathvariant="bold-italic">v</mi><mn>1</mn></msub><mi mathvariant="normal">.</mi><mtext> もし </mtext><msub><mi mathvariant="bold-italic">v</mi><mn>1</mn></msub><mo>=</mo><mn>0</mn><mtext> なら </mtext><msub><mi mathvariant="bold-italic">a</mi><mrow><mi>C</mi><mi>o</mi><mi>r</mi></mrow></msub><mo>=</mo><mn>0.</mn></mrow></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{array}{r}
\quad \boldsymbol{v}_2=\boldsymbol{v}_0+\boldsymbol{v}_1, \boldsymbol{a}_2=\boldsymbol{a}_0+\boldsymbol{a}_1+\omega^2 \boldsymbol{R}+\boldsymbol{a}_{C o r} \\
\text { ここで, } \boldsymbol{a}_{C o r} \perp \boldsymbol{v}_1 . \text { もし } \boldsymbol{v}_1=0 \text { なら } \boldsymbol{a}_{C o r}=0 .
\end{array}
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.4em;vertical-align:-0.95em;"></span><span class="mord"><span class="mtable"><span class="arraycolsep" style="width:0.5em;"></span><span class="col-align-r"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mspace" style="margin-right:1em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03704em;">v</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03704em;">v</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">0</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03704em;">v</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol">a</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol">a</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">0</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol">a</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">ω</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.00421em;">R</span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol">a</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.07153em;">C</span><span class="mord mathnormal mtight" style="margin-right:0.02778em;">or</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord text"><span class="mord"> </span><span class="mord cjk_fallback">ここで</span><span class="mord">, </span></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol">a</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.07153em;">C</span><span class="mord mathnormal mtight" style="margin-right:0.02778em;">or</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">⊥</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03704em;">v</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord">.</span><span class="mord text"><span class="mord"> </span><span class="mord cjk_fallback">もし</span><span class="mord"> </span></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03704em;">v</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord">0</span><span class="mord text"><span class="mord"> </span><span class="mord cjk_fallback">なら</span><span class="mord"> </span></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol">a</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.07153em;">C</span><span class="mord mathnormal mtight" style="margin-right:0.02778em;">or</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord">0.</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:0.5em;"></span></span></span></span></span></span></span></p>
</li>
</ol>
<h3 id="_3-6-弾道問題" tabindex="-1">3.6: 弾道問題 <Badge type="tip" text="supplemental" /> <a class="header-anchor" href="#_3-6-弾道問題" aria-label="Permalink to &quot;3.6: 弾道問題 &lt;Badge type=&quot;tip&quot; text=&quot;supplemental&quot; /&gt;&quot;">&ZeroWidthSpace;</a></h3>
<ol start="6">
<li>弾道問題：到達可能な範囲は<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mi>y</mi><mo>≤</mo><msubsup><mi>v</mi><mn>0</mn><mn>2</mn></msubsup><mi mathvariant="normal">/</mi><mo stretchy="false">(</mo><mn>2</mn><mi>g</mi><mo stretchy="false">)</mo><mo>−</mo><mi>g</mi><msup><mi>x</mi><mn>2</mn></msup><mi mathvariant="normal">/</mi><mrow><mo fence="true">(</mo><mn>2</mn><msubsup><mi>v</mi><mn>0</mn><mn>2</mn></msubsup><mo fence="true">)</mo></mrow></mrow><annotation encoding="application/x-tex">y \leq v_0^2 /(2 g)-g x^2 /\left(2 v_0^2\right)
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8304em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">y</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≤</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.1141em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-2.453em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">0</span></span></span><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.247em;"><span></span></span></span></span></span></span><span class="mord">/</span><span class="mopen">(</span><span class="mord">2</span><span class="mord mathnormal" style="margin-right:0.03588em;">g</span><span class="mclose">)</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1.2141em;vertical-align:-0.35em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">g</span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mord">/</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size1">(</span></span><span class="mord">2</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-2.453em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">0</span></span></span><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.247em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size1">)</span></span></span></span></span></span></span></p>
最適な弾道では, 初速度と終速（衝突時の速度）が垂直 になる.</li>
</ol>
<h3 id="_3-7-最短経路" tabindex="-1">3.7: 最短経路 <a class="header-anchor" href="#_3-7-最短経路" aria-label="Permalink to &quot;3.7: 最短経路&quot;">&ZeroWidthSpace;</a></h3>
<ol start="7">
<li>最短経路を求めるには，Fermat と Huygens の原理が 使える.</li>
</ol>
<h3 id="_3-8-ベクトル" tabindex="-1">3.8: ベクトル <a class="header-anchor" href="#_3-8-ベクトル" aria-label="Permalink to &quot;3.8: ベクトル&quot;">&ZeroWidthSpace;</a></h3>
<ol start="8">
<li>ベクトル（速度，加速度）を求めるには，その向きと （場合によっては傾いた）ある軸への射影を求めれば 充分.</li>
</ol>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Formulas for IPhO 日本語版: Section 4 ]]></title>
            <link>https://note.toshiki.devacademic/physics/ipho-formulas-jpn/4</link>
            <guid>https://note.toshiki.devacademic/physics/ipho-formulas-jpn/4</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="formulas-for-ipho-日本語版-section-4" tabindex="-1">Formulas for IPhO 日本語版: Section 4 <a class="header-anchor" href="#formulas-for-ipho-日本語版-section-4" aria-label="Permalink to &quot;Formulas for IPhO 日本語版: Section 4&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="_4-力学" tabindex="-1">4: 力学 <a class="header-anchor" href="#_4-力学" aria-label="Permalink to &quot;4: 力学&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="_4-1-剛体の二次元的な平衡" tabindex="-1">4.1: 剛体の二次元的な平衡 <a class="header-anchor" href="#_4-1-剛体の二次元的な平衡" aria-label="Permalink to &quot;4.1: 剛体の二次元的な平衡&quot;">&ZeroWidthSpace;</a></h3>
<ol>
<li>剛体の二次元的な平衡 : 力についての 2 つの式とトル クについての 1 つの式. 1 （又は 2 ）個の力についての 式は 1（又は 2）個のトルクについての式で代用でき る. トルクの方が良い場合が多く，原点を適切に選択 することで「退屈な」力を消すことができる. もし 2 点 のみに力がかかっているならば，（正味の）力がかかっ ている直線は一致する. 3 点であれば, 3 つの直線は 1 点で交わる.</li>
</ol>
<h3 id="_4-2-垂直抗力" tabindex="-1">4.2: 垂直抗力 <a class="header-anchor" href="#_4-2-垂直抗力" aria-label="Permalink to &quot;4.2: 垂直抗力&quot;">&ZeroWidthSpace;</a></h3>
<ol start="2">
<li>垂直抗力と摩擦力は 1 つの力に合成でき, 垂直抗力に 対して <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>arctan</mi><mo>⁡</mo><mi>μ</mi></mrow><annotation encoding="application/x-tex">\arctan \mu</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8095em;vertical-align:-0.1944em;"></span><span class="mop">arctan</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">μ</span></span></span></span> の角度で接触点に加わる.</li>
</ol>
<h3 id="_4-3-並進運動と回転運動" tabindex="-1">4.3: 並進運動と回転運動 <a class="header-anchor" href="#_4-3-並進運動と回転運動" aria-label="Permalink to &quot;4.3: 並進運動と回転運動&quot;">&ZeroWidthSpace;</a></h3>
<ol start="3">
<li>並進運動と回転運動についての Newton の第二法則：<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mi mathvariant="bold-italic">F</mi><mo>=</mo><mi>m</mi><mi mathvariant="bold-italic">a</mi><mo separator="true">,</mo><mi mathvariant="bold-italic">M</mi><mo>=</mo><mi>I</mi><mi mathvariant="bold-italic">ε</mi><mspace width="1em"/><mo stretchy="false">(</mo><mi mathvariant="bold-italic">M</mi><mo>=</mo><mi mathvariant="bold-italic">r</mi><mo>×</mo><mi mathvariant="bold-italic">F</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">\boldsymbol{F}=m \boldsymbol{a}, \boldsymbol{M}=I \boldsymbol{\varepsilon} \quad(\boldsymbol{M}=\boldsymbol{r} \times \boldsymbol{F})
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6861em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.15972em;">F</span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8805em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">m</span><span class="mord"><span class="mord"><span class="mord boldsymbol">a</span></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.11424em;">M</span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="mord"><span class="mord"><span class="mord boldsymbol">ε</span></span></span><span class="mspace" style="margin-right:1em;"></span><span class="mopen">(</span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.11424em;">M</span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03194em;">r</span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">×</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.15972em;">F</span></span></span><span class="mclose">)</span></span></span></span></span></p>
二次元の場合には <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>M</mi></mrow><annotation encoding="application/x-tex">M</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.10903em;">M</span></span></span></span> と <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ε</mi></mrow><annotation encoding="application/x-tex">\varepsilon</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">ε</span></span></span></span> は本質的にスカラーで, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>M</mi><mo>=</mo><mi>F</mi><mi>l</mi><mo>=</mo><msub><mi>F</mi><mi>t</mi></msub><mi>r</mi><mo stretchy="false">(</mo><mi>l</mi></mrow><annotation encoding="application/x-tex">M=F l=F_t r(l</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.10903em;">M</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal" style="margin-right:0.01968em;">Fl</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.13889em;">F</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.2806em;"><span style="top:-2.55em;margin-left:-0.1389em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">t</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord mathnormal" style="margin-right:0.02778em;">r</span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.01968em;">l</span></span></span></span> は力のうでの長さ <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mclose">)</span></span></span></span></li>
</ol>
<h3 id="_4-4-一般化座標" tabindex="-1">4.4: 一般化座標 <a class="header-anchor" href="#_4-4-一般化座標" aria-label="Permalink to &quot;4.4: 一般化座標&quot;">&ZeroWidthSpace;</a></h3>
<ol start="4">
<li>一般化座標. 系の状態が 1 つの変数 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ξ</mi></mrow><annotation encoding="application/x-tex">\xi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.04601em;">ξ</span></span></span></span> とその時間微分 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mi>ξ</mi><mo>˙</mo></mover></mrow><annotation encoding="application/x-tex">\dot{\xi}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1257em;vertical-align:-0.1944em;"></span><span class="mord accent"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.9313em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord mathnormal" style="margin-right:0.04601em;">ξ</span></span><span style="top:-3.2634em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.0278em;"><span class="mord">˙</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.1944em;"><span></span></span></span></span></span></span></span></span> で表され，ポテンシャルエネルギーが <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>U</mi><mo>=</mo><mi>U</mi><mo stretchy="false">(</mo><mi>ξ</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">U=U(\xi)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.10903em;">U</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.10903em;">U</span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.04601em;">ξ</span><span class="mclose">)</span></span></span></span>, 運動エネルギーが <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>K</mi><mo>=</mo><mi>μ</mi><msup><mi>ξ</mi><mn>2</mn></msup><mi mathvariant="normal">/</mi><mn>2</mn></mrow><annotation encoding="application/x-tex">K=\mu \xi^2 / 2</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.07153em;">K</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.0641em;vertical-align:-0.25em;"></span><span class="mord mathnormal">μ</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.04601em;">ξ</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mord">/2</span></span></span></span> であるならば, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>μ</mi><mover accent="true"><mi>ξ</mi><mo>¨</mo></mover><mo>=</mo></mrow><annotation encoding="application/x-tex">\mu \ddot{\xi}=</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1257em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">μ</span><span class="mord accent"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.9313em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord mathnormal" style="margin-right:0.04601em;">ξ</span></span><span style="top:-3.2634em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.1389em;"><span class="mord">¨</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.1944em;"><span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span></span></span></span> <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>−</mo><mi mathvariant="normal">d</mi><mi>U</mi><mo stretchy="false">(</mo><mi>ξ</mi><mo stretchy="false">)</mo><mi mathvariant="normal">/</mi><mi mathvariant="normal">d</mi><mi>ξ</mi></mrow><annotation encoding="application/x-tex">-\mathrm{d} U(\xi) / \mathrm{d} \xi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">−</span><span class="mord mathrm">d</span><span class="mord mathnormal" style="margin-right:0.10903em;">U</span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.04601em;">ξ</span><span class="mclose">)</span><span class="mord">/</span><span class="mord mathrm">d</span><span class="mord mathnormal" style="margin-right:0.04601em;">ξ</span></span></span></span>. (したがって並進運動では, 力はポテン シャルエネルギーの微分)</li>
</ol>
<h3 id="_4-5-系質点" tabindex="-1">4.5: 系質点 <a class="header-anchor" href="#_4-5-系質点" aria-label="Permalink to &quot;4.5: 系質点&quot;">&ZeroWidthSpace;</a></h3>
<ol start="5">
<li>系が質点 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>m</mi><mi>i</mi></msub></mrow><annotation encoding="application/x-tex">m_i</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal">m</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> で構成されているとき：<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mtable rowspacing="0.25em" columnalign="right left" columnspacing="0em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><msub><mi mathvariant="bold-italic">r</mi><mi>c</mi></msub><mo>=</mo><mo>∑</mo><msub><mi>m</mi><mi>i</mi></msub><msub><mi mathvariant="bold-italic">r</mi><mi>i</mi></msub><mi mathvariant="normal">/</mi><mo>∑</mo><msub><mi>m</mi><mi>j</mi></msub><mo separator="true">,</mo><mi mathvariant="bold-italic">P</mi><mo>=</mo><mo>∑</mo><msub><mi>m</mi><mi>i</mi></msub><msub><mi mathvariant="bold-italic">v</mi><mi>i</mi></msub></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mi mathvariant="bold-italic">L</mi><mo>=</mo><mo>∑</mo><msub><mi>m</mi><mi>i</mi></msub><msub><mi mathvariant="bold-italic">r</mi><mi>i</mi></msub><mo>×</mo><msub><mi mathvariant="bold-italic">v</mi><mi>i</mi></msub><mo separator="true">,</mo><mi>K</mi><mo>=</mo><mo>∑</mo><msub><mi>m</mi><mi>i</mi></msub><msubsup><mi>v</mi><mi>i</mi><mn>2</mn></msubsup><mi mathvariant="normal">/</mi><mn>2</mn></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><msub><mi>I</mi><mi>z</mi></msub><mo>=</mo><mo>∑</mo><msub><mi>m</mi><mi>i</mi></msub><mrow><mo fence="true">(</mo><msubsup><mi>x</mi><mi>i</mi><mn>2</mn></msubsup><mo>+</mo><msubsup><mi>y</mi><mi>i</mi><mn>2</mn></msubsup><mo fence="true">)</mo></mrow><mo>=</mo><mo>∫</mo><mrow><mo fence="true">(</mo><msup><mi>x</mi><mn>2</mn></msup><mo>+</mo><msup><mi>y</mi><mn>2</mn></msup><mo fence="true">)</mo></mrow><mi mathvariant="normal">d</mi><mi>m</mi></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{aligned}
&amp; \boldsymbol{r}_c=\sum m_i \boldsymbol{r}_i / \sum m_j, \boldsymbol{P}=\sum m_i \boldsymbol{v}_i \\
&amp; \boldsymbol{L}=\sum m_i \boldsymbol{r}_i \times \boldsymbol{v}_i, K=\sum m_i v_i^2 / 2 \\
&amp; I_z=\sum m_i\left(x_i^2+y_i^2\right)=\int\left(x^2+y^2\right) \mathrm{d} m \\
&amp;
\end{aligned}
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:7.8223em;vertical-align:-3.6611em;"></span><span class="mord"><span class="mtable"><span class="col-align-r"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:4.1611em;"><span style="top:-6.4711em;"><span class="pstrut" style="height:3.36em;"></span><span class="mord"></span></span><span style="top:-4.5711em;"><span class="pstrut" style="height:3.36em;"></span><span class="mord"></span></span><span style="top:-2.3611em;"><span class="pstrut" style="height:3.36em;"></span><span class="mord"></span></span><span style="top:-0.3589em;"><span class="pstrut" style="height:3.36em;"></span><span class="mord"></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:3.6611em;"><span></span></span></span></span></span><span class="col-align-l"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:4.1611em;"><span style="top:-6.4711em;"><span class="pstrut" style="height:3.36em;"></span><span class="mord"><span class="mord"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03194em;">r</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mop op-symbol large-op" style="position:relative;top:0em;">∑</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal">m</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03194em;">r</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord">/</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop op-symbol large-op" style="position:relative;top:0em;">∑</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal">m</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.05724em;">j</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.15972em;">P</span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mop op-symbol large-op" style="position:relative;top:0em;">∑</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal">m</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03704em;">v</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span><span style="top:-4.5711em;"><span class="pstrut" style="height:3.36em;"></span><span class="mord"><span class="mord"></span><span class="mord"><span class="mord"><span class="mord boldsymbol">L</span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mop op-symbol large-op" style="position:relative;top:0em;">∑</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal">m</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03194em;">r</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">×</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03704em;">v</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.07153em;">K</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mop op-symbol large-op" style="position:relative;top:0em;">∑</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal">m</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-2.453em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.247em;"><span></span></span></span></span></span></span><span class="mord">/2</span></span></span><span style="top:-2.3611em;"><span class="pstrut" style="height:3.36em;"></span><span class="mord"><span class="mord"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:-0.0785em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.04398em;">z</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mop op-symbol large-op" style="position:relative;top:0em;">∑</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal">m</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size1">(</span></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-2.453em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.247em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">y</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-2.453em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.247em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size1">)</span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mop op-symbol large-op" style="margin-right:0.44445em;position:relative;top:-0.0011em;">∫</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size1">(</span></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">y</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size1">)</span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathrm">d</span><span class="mord mathnormal">m</span></span></span><span style="top:-0.3589em;"><span class="pstrut" style="height:3.36em;"></span><span class="mord"><span class="mord"></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:3.6611em;"><span></span></span></span></span></span></span></span></span></span></span></span></p>
</li>
</ol>
<h3 id="_4-6-質量中心の速度" tabindex="-1">4.6: 質量中心の速度 <a class="header-anchor" href="#_4-6-質量中心の速度" aria-label="Permalink to &quot;4.6: 質量中心の速度&quot;">&ZeroWidthSpace;</a></h3>
<ol start="6">
<li>質量中心の速度が <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi mathvariant="bold-italic">v</mi><mi>c</mi></msub></mrow><annotation encoding="application/x-tex">\boldsymbol{v}_c</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5944em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03704em;">v</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> であるような系 (添え字 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>c</mi></mrow><annotation encoding="application/x-tex">c</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">c</span></span></span></span> は質量 中心についての物理量であることを示す）:<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mtable rowspacing="0.25em" columnalign="center" columnspacing="0em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mi mathvariant="bold-italic">L</mi><mo>=</mo><msub><mi mathvariant="bold-italic">L</mi><mi>c</mi></msub><mo>+</mo><msub><mi>M</mi><mi mathvariant="normal">Σ</mi></msub><msub><mi mathvariant="bold-italic">R</mi><mi>c</mi></msub><mo>×</mo><msub><mi mathvariant="bold-italic">v</mi><mi>c</mi></msub><mo separator="true">,</mo><mi>K</mi><mo>=</mo><msub><mi>K</mi><mi>c</mi></msub><mo>+</mo><msub><mi>M</mi><mi mathvariant="normal">Σ</mi></msub><msubsup><mi>v</mi><mi>c</mi><mn>2</mn></msubsup><mi mathvariant="normal">/</mi><mn>2</mn></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mi mathvariant="bold-italic">P</mi><mo>=</mo><msub><mi mathvariant="bold-italic">P</mi><mi>c</mi></msub><mo>+</mo><msub><mi>M</mi><mi mathvariant="normal">Σ</mi></msub><msub><mi mathvariant="bold-italic">v</mi><mi>c</mi></msub><mi mathvariant="normal">.</mi></mrow></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{gathered}
\boldsymbol{L}=\boldsymbol{L}_c+M_{\Sigma} \boldsymbol{R}_c \times \boldsymbol{v}_c, K=K_c+M_{\Sigma} v_c^2 / 2 \\
\boldsymbol{P}=\boldsymbol{P}_c+M_{\Sigma} \boldsymbol{v}_c .
\end{gathered}
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:3.0241em;vertical-align:-1.2621em;"></span><span class="mord"><span class="mtable"><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.7621em;"><span style="top:-3.8979em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol">L</span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol">L</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.10903em;">M</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-left:-0.109em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">Σ</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.00421em;">R</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">×</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03704em;">v</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.07153em;">K</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.07153em;">K</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:-0.0715em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.10903em;">M</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-left:-0.109em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">Σ</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-2.453em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">c</span></span></span><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.247em;"><span></span></span></span></span></span></span><span class="mord">/2</span></span></span><span style="top:-2.3979em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.15972em;">P</span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.15972em;">P</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.10903em;">M</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-left:-0.109em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">Σ</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03704em;">v</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord">.</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.2621em;"><span></span></span></span></span></span></span></span></span></span></span></span></p>
</li>
</ol>
<h3 id="_4-7-steiner-定理" tabindex="-1">4.7: Steiner 定理 <a class="header-anchor" href="#_4-7-steiner-定理" aria-label="Permalink to &quot;4.7: Steiner 定理&quot;">&ZeroWidthSpace;</a></h3>
<ol start="7">
<li>Steiner の定理（平行軸の定理）も同じような形で は質量中心の回転軸からの距離）:<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mi>I</mi><mo>=</mo><msub><mi>I</mi><mi>c</mi></msub><mo>+</mo><mi>m</mi><msup><mi>b</mi><mn>2</mn></msup></mrow><annotation encoding="application/x-tex">I=I_c+m b^2
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:-0.0785em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.8641em;"></span><span class="mord mathnormal">m</span><span class="mord"><span class="mord mathnormal">b</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span></span></span></p>
</li>
</ol>
<h3 id="_4-8-ポイント-6" tabindex="-1">4.8: ポイント 6 <a class="header-anchor" href="#_4-8-ポイント-6" aria-label="Permalink to &quot;4.8: ポイント 6&quot;">&ZeroWidthSpace;</a></h3>
<ol start="8">
<li>ポイント 6 の <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="bold-italic">P</mi></mrow><annotation encoding="application/x-tex">\boldsymbol{P}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6861em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.15972em;">P</span></span></span></span></span></span> と <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="bold-italic">L</mi></mrow><annotation encoding="application/x-tex">\boldsymbol{L}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6861em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol">L</span></span></span></span></span></span> を用いて, Newton の第二法則 :<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><msub><mi mathvariant="bold-italic">F</mi><mi mathvariant="normal">Σ</mi></msub><mo>=</mo><mi mathvariant="normal">d</mi><mi mathvariant="bold-italic">P</mi><mi mathvariant="normal">/</mi><mi mathvariant="normal">d</mi><mi>t</mi><mo separator="true">,</mo><msub><mi mathvariant="bold-italic">M</mi><mi mathvariant="normal">Σ</mi></msub><mo>=</mo><mi mathvariant="normal">d</mi><mi mathvariant="bold-italic">L</mi><mi mathvariant="normal">/</mi><mi mathvariant="normal">d</mi><mi>t</mi></mrow><annotation encoding="application/x-tex">\boldsymbol{F}_{\Sigma}=\mathrm{d} \boldsymbol{P} / \mathrm{d} t, \boldsymbol{M}_{\Sigma}=\mathrm{d} \boldsymbol{L} / \mathrm{d} t
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8361em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.15972em;">F</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">Σ</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathrm">d</span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.15972em;">P</span></span></span><span class="mord">/</span><span class="mord mathrm">d</span><span class="mord mathnormal">t</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.11424em;">M</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">Σ</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathrm">d</span><span class="mord"><span class="mord"><span class="mord boldsymbol">L</span></span></span><span class="mord">/</span><span class="mord mathrm">d</span><span class="mord mathnormal">t</span></span></span></span></span></p>
</li>
</ol>
<h3 id="_4-9-ポイント-5" tabindex="-1">4.9: ポイント 5 <a class="header-anchor" href="#_4-9-ポイント-5" aria-label="Permalink to &quot;4.9: ポイント 5&quot;">&ZeroWidthSpace;</a></h3>
<ol start="9">
<li>ポイント 5 にに加えて，質量中心を通る <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>z</mi></mrow><annotation encoding="application/x-tex">z</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal" style="margin-right:0.04398em;">z</span></span></span></span> 軸に対する慣性モ一メントは <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>I</mi><mrow><mi>z</mi><mn>0</mn></mrow></msub><mo>=</mo></mrow><annotation encoding="application/x-tex">I_{z 0}=</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0785em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.04398em;">z</span><span class="mord mtight">0</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span></span></span></span> <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mo>∑</mo><mrow><mi>i</mi><mo separator="true">,</mo><mi>j</mi></mrow></msub><msub><mi>m</mi><mi>i</mi></msub><msub><mi>m</mi><mi>j</mi></msub><mrow><mo fence="true">[</mo><msup><mrow><mo fence="true">(</mo><msub><mi>x</mi><mi>i</mi></msub><mo>−</mo><msub><mi>x</mi><mi>j</mi></msub><mo fence="true">)</mo></mrow><mn>2</mn></msup><mo>+</mo><msup><mrow><mo fence="true">(</mo><msub><mi>y</mi><mi>i</mi></msub><mo>−</mo><msub><mi>y</mi><mi>j</mi></msub><mo fence="true">)</mo></mrow><mn>2</mn></msup><mo fence="true">]</mo></mrow><mi mathvariant="normal">/</mi><mrow><mo fence="true">(</mo><mn>2</mn><msub><mi>M</mi><mi mathvariant="normal">Σ</mi></msub><mo fence="true">)</mo></mrow></mrow><annotation encoding="application/x-tex">\sum_{i, j} m_i m_j\left[\left(x_i-x_j\right)^2+\left(y_i-y_j\right)^2\right] /\left(2 M_{\Sigma}\right)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.8em;vertical-align:-0.65em;"></span><span class="mop"><span class="mop op-symbol small-op" style="position:relative;top:0em;">∑</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.162em;"><span style="top:-2.4003em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">i</span><span class="mpunct mtight">,</span><span class="mord mathnormal mtight" style="margin-right:0.05724em;">j</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.4358em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal">m</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathnormal">m</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.05724em;">j</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size2">[</span></span><span class="minner"><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.05724em;">j</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">)</span></span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.954em;"><span style="top:-3.2029em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="minner"><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">y</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">y</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.05724em;">j</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">)</span></span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.954em;"><span style="top:-3.2029em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size2">]</span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord">/</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord">2</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.10903em;">M</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-left:-0.109em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">Σ</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">)</span></span></span></span></span></li>
</ol>
<h3 id="_4-10-原点に対する慣性" tabindex="-1">4.10: 原点に対する慣性 <a class="header-anchor" href="#_4-10-原点に対する慣性" aria-label="Permalink to &quot;4.10: 原点に対する慣性&quot;">&ZeroWidthSpace;</a></h3>
<ol start="10">
<li>原点に対する慣性モ一メント <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>θ</mi><mo>=</mo><mo>∑</mo><msub><mi>m</mi><mi>i</mi></msub><msubsup><mi>r</mi><mi>i</mi><mn>2</mn></msubsup></mrow><annotation encoding="application/x-tex">\theta=\sum m_i r_i^2</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal" style="margin-right:0.02778em;">θ</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.0728em;vertical-align:-0.2587em;"></span><span class="mop op-symbol small-op" style="position:relative;top:0em;">∑</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal">m</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.02778em;">r</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-2.4413em;margin-left:-0.0278em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2587em;"><span></span></span></span></span></span></span></span></span></span> は, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>2</mn><mi>θ</mi><mo>=</mo><msub><mi>I</mi><mi>x</mi></msub><mo>+</mo><msub><mi>I</mi><mi>y</mi></msub><mo>+</mo><msub><mi>I</mi><mi>z</mi></msub></mrow><annotation encoding="application/x-tex">2 \theta=I_x+I_y+I_z</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">2</span><span class="mord mathnormal" style="margin-right:0.02778em;">θ</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:-0.0785em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">x</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.9694em;vertical-align:-0.2861em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:-0.0785em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.03588em;">y</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:-0.0785em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.04398em;">z</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> を用いることで二次元物体や等 方性のある物体の <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>I</mi><mi>z</mi></msub></mrow><annotation encoding="application/x-tex">I_z</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:-0.0785em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.04398em;">z</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> を計算するのに有用.</li>
</ol>
<h3 id="_4-11-相当単振子の長" tabindex="-1">4.11: 相当単振子の長 <a class="header-anchor" href="#_4-11-相当単振子の長" aria-label="Permalink to &quot;4.11: 相当単振子の長&quot;">&ZeroWidthSpace;</a></h3>
<ol start="11">
<li>相当単振子の長さが <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mi>l</mi><mo>~</mo></mover></mrow><annotation encoding="application/x-tex">\tilde{l}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9313em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.9313em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord mathnormal" style="margin-right:0.01968em;">l</span></span><span style="top:-3.6134em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.1667em;"><span class="mord">~</span></span></span></span></span></span></span></span></span></span> である物理振子 :<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mtable rowspacing="0.25em" columnalign="right left" columnspacing="0em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><msup><mi>ω</mi><mn>2</mn></msup><mo stretchy="false">(</mo><mi>l</mi><mo stretchy="false">)</mo><mo>=</mo><mi>g</mi><mi mathvariant="normal">/</mi><mrow><mo fence="true">(</mo><mi>l</mi><mo>+</mo><msub><mi>I</mi><mi>c</mi></msub><mi mathvariant="normal">/</mi><mi>m</mi><mi>l</mi><mo fence="true">)</mo></mrow></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mi>ω</mi><mo stretchy="false">(</mo><mi>l</mi><mo stretchy="false">)</mo><mo>=</mo><mi>ω</mi><mo stretchy="false">(</mo><mover accent="true"><mi>l</mi><mo>~</mo></mover><mo>−</mo><mi>l</mi><mo stretchy="false">)</mo><mo>=</mo><msqrt><mrow><mi>g</mi><mi mathvariant="normal">/</mi><mover accent="true"><mi>l</mi><mo>~</mo></mover></mrow></msqrt><mo separator="true">,</mo><mspace width="1em"/><mover accent="true"><mi>l</mi><mo>~</mo></mover><mo>=</mo><mi>l</mi><mo>+</mo><msub><mi>I</mi><mi>c</mi></msub><mi mathvariant="normal">/</mi><mi>m</mi><mi>l</mi></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{aligned}
&amp; \omega^2(l)=g /\left(l+I_c / m l\right) \\
&amp; \omega(l)=\omega(\tilde{l}-l)=\sqrt{g / \tilde{l}}, \quad \tilde{l}=l+I_c / m l \\
&amp;
\end{aligned}
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:5.1641em;vertical-align:-2.3321em;"></span><span class="mord"><span class="mtable"><span class="col-align-r"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:2.8321em;"><span style="top:-5.3425em;"><span class="pstrut" style="height:3.3745em;"></span><span class="mord"></span></span><span style="top:-3.3079em;"><span class="pstrut" style="height:3.3745em;"></span><span class="mord"></span></span><span style="top:-1.7025em;"><span class="pstrut" style="height:3.3745em;"></span><span class="mord"></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:2.3321em;"><span></span></span></span></span></span><span class="col-align-l"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:2.8321em;"><span style="top:-5.3425em;"><span class="pstrut" style="height:3.3745em;"></span><span class="mord"><span class="mord"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">ω</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.01968em;">l</span><span class="mclose">)</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">g</span><span class="mord">/</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord mathnormal" style="margin-right:0.01968em;">l</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:-0.0785em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord">/</span><span class="mord mathnormal">m</span><span class="mord mathnormal" style="margin-right:0.01968em;">l</span><span class="mclose delimcenter" style="top:0em;">)</span></span></span></span><span style="top:-3.3079em;"><span class="pstrut" style="height:3.3745em;"></span><span class="mord"><span class="mord"></span><span class="mord mathnormal" style="margin-right:0.03588em;">ω</span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.01968em;">l</span><span class="mclose">)</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">ω</span><span class="mopen">(</span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.9313em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord mathnormal" style="margin-right:0.01968em;">l</span></span><span style="top:-3.6134em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.1667em;"><span class="mord">~</span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal" style="margin-right:0.01968em;">l</span><span class="mclose">)</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.3745em;"><span class="svg-align" style="top:-3.8em;"><span class="pstrut" style="height:3.8em;"></span><span class="mord" style="padding-left:1em;"><span class="mord mathnormal" style="margin-right:0.03588em;">g</span><span class="mord">/</span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.9313em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord mathnormal" style="margin-right:0.01968em;">l</span></span><span style="top:-3.6134em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.1667em;"><span class="mord">~</span></span></span></span></span></span></span></span></span><span style="top:-3.3345em;"><span class="pstrut" style="height:3.8em;"></span><span class="hide-tail" style="min-width:1.02em;height:1.88em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='1.88em' viewBox='0 0 400000 1944' preserveAspectRatio='xMinYMin slice'><path d='M983 90
l0 -0
c4,-6.7,10,-10,18,-10 H400000v40
H1013.1s-83.4,268,-264.1,840c-180.7,572,-277,876.3,-289,913c-4.7,4.7,-12.7,7,-24,7
s-12,0,-12,0c-1.3,-3.3,-3.7,-11.7,-7,-25c-35.3,-125.3,-106.7,-373.3,-214,-744
c-10,12,-21,25,-33,39s-32,39,-32,39c-6,-5.3,-15,-14,-27,-26s25,-30,25,-30
c26.7,-32.7,52,-63,76,-91s52,-60,52,-60s208,722,208,722
c56,-175.3,126.3,-397.3,211,-666c84.7,-268.7,153.8,-488.2,207.5,-658.5
c53.7,-170.3,84.5,-266.8,92.5,-289.5z
M1001 80h400000v40h-400000z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.4655em;"><span></span></span></span></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:1em;"></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.9313em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord mathnormal" style="margin-right:0.01968em;">l</span></span><span style="top:-3.6134em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.1667em;"><span class="mord">~</span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord mathnormal" style="margin-right:0.01968em;">l</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:-0.0785em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord">/</span><span class="mord mathnormal">m</span><span class="mord mathnormal" style="margin-right:0.01968em;">l</span></span></span><span style="top:-1.7025em;"><span class="pstrut" style="height:3.3745em;"></span><span class="mord"><span class="mord"></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:2.3321em;"><span></span></span></span></span></span></span></span></span></span></span></span></p>
</li>
</ol>
<h3 id="_4-12-慣性モーメントの係数" tabindex="-1">4.12: 慣性モーメントの係数 <a class="header-anchor" href="#_4-12-慣性モーメントの係数" aria-label="Permalink to &quot;4.12: 慣性モーメントの係数&quot;">&ZeroWidthSpace;</a></h3>
<ol start="12">
<li>慣性モーメントの係数 : 円柱 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mfrac><mn>1</mn><mn>2</mn></mfrac></mrow><annotation encoding="application/x-tex">\frac{1}{2}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1901em;vertical-align:-0.345em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8451em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">1</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span>, 球 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mfrac><mn>2</mn><mn>5</mn></mfrac></mrow><annotation encoding="application/x-tex">\frac{2}{5}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1901em;vertical-align:-0.345em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8451em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">5</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span>, 球殼 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mfrac><mn>2</mn><mn>3</mn></mfrac></mrow><annotation encoding="application/x-tex">\frac{2}{3}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1901em;vertical-align:-0.345em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8451em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">3</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span>, 棒 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mfrac><mn>1</mn><mn>12</mn></mfrac></mrow><annotation encoding="application/x-tex">\frac{1}{12}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1901em;vertical-align:-0.345em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8451em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">12</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">1</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span> （端に対しては <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mfrac><mn>1</mn><mn>3</mn></mfrac></mrow><annotation encoding="application/x-tex">\frac{1}{3}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1901em;vertical-align:-0.345em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8451em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">3</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">1</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span> ), 正方形 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mfrac><mn>1</mn><mn>6</mn></mfrac></mrow><annotation encoding="application/x-tex">\frac{1}{6}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1901em;vertical-align:-0.345em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8451em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">6</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">1</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span>.</li>
</ol>
<h3 id="_4-13-よく使われる保存則" tabindex="-1">4.13: よく使われる保存則 <a class="header-anchor" href="#_4-13-よく使われる保存則" aria-label="Permalink to &quot;4.13: よく使われる保存則&quot;">&ZeroWidthSpace;</a></h3>
<ol start="13">
<li>よく使われる保存則：エネルギー（弾性衝突，摩擦な し), 運動量（正味の外力なし, 各方向について成立), 角運動量（正味の外トルクなし, 例えば, 外力のうでの 長さが 0 (これが 2 又は 3 点のまわりに成り立てば運 動量保存で代用できる))</li>
</ol>
<h3 id="_4-14-非慣性系における見かけの力" tabindex="-1">4.14: 非慣性系における見かけの力 <a class="header-anchor" href="#_4-14-非慣性系における見かけの力" aria-label="Permalink to &quot;4.14: 非慣性系における見かけの力&quot;">&ZeroWidthSpace;</a></h3>
<ol start="14">
<li>非慣性系における見かけの力 : 慣性力 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>−</mo><mi>m</mi><mi>a</mi></mrow><annotation encoding="application/x-tex">-m a</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mord">−</span><span class="mord mathnormal">ma</span></span></span></span>, 遠心力 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>m</mi><msup><mi>ω</mi><mn>2</mn></msup><mi mathvariant="bold-italic">R</mi></mrow><annotation encoding="application/x-tex">m \omega^2 \boldsymbol{R}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8141em;"></span><span class="mord mathnormal">m</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">ω</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.00421em;">R</span></span></span></span></span></span>, Coriolis 力 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>2</mn><mi>m</mi><mi mathvariant="bold-italic">v</mi><mo>×</mo><mi mathvariant="normal">Ω</mi></mrow><annotation encoding="application/x-tex">2 m \boldsymbol{v} \times \Omega</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7278em;vertical-align:-0.0833em;"></span><span class="mord">2</span><span class="mord mathnormal">m</span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03704em;">v</span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">×</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">Ω</span></span></span></span> (避けた方がよい. 速 度に垂直なので仕事はしない).</li>
</ol>
<h3 id="_4-15-傾いた座標" tabindex="-1">4.15: 傾いた座標 <a class="header-anchor" href="#_4-15-傾いた座標" aria-label="Permalink to &quot;4.15: 傾いた座標&quot;">&ZeroWidthSpace;</a></h3>
<ol start="15">
<li>傾いた座標：斜面上での運動については, 斜面に平行 と垂直な方向に軸をとるのがよい。このとき重力加速 度は <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>x</mi></mrow><annotation encoding="application/x-tex">x</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">x</span></span></span></span> 成分と <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>y</mi></mrow><annotation encoding="application/x-tex">y</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">y</span></span></span></span> 成分をもつ. 軸は斜交することもある が, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="bold-italic">v</mi><mo>=</mo><msub><mi>v</mi><mi>x</mi></msub><msub><mi mathvariant="bold-italic">e</mi><mi>x</mi></msub><mo>+</mo><msub><mi>v</mi><mi>y</mi></msub><msub><mi mathvariant="bold-italic">e</mi><mi>y</mi></msub></mrow><annotation encoding="application/x-tex">\boldsymbol{v}=v_x \boldsymbol{e}_x+v_y \boldsymbol{e}_y</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4444em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03704em;">v</span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.7333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">x</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol">e</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">x</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.7305em;vertical-align:-0.2861em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.03588em;">y</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol">e</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.03588em;">y</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span></span></span></span> のとき <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>v</mi><mi>x</mi></msub></mrow><annotation encoding="application/x-tex">v_x</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">x</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> は <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="bold-italic">v</mi></mrow><annotation encoding="application/x-tex">\boldsymbol{v}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4444em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03704em;">v</span></span></span></span></span></span> の <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>x</mi></mrow><annotation encoding="application/x-tex">x</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">x</span></span></span></span> 軸への射 影ではない.</li>
</ol>
<h3 id="_4-16-2-つの物体の衝突" tabindex="-1">4.16: 2 つの物体の衝突 <a class="header-anchor" href="#_4-16-2-つの物体の衝突" aria-label="Permalink to &quot;4.16: 2 つの物体の衝突&quot;">&ZeroWidthSpace;</a></h3>
<ol start="16">
<li>2 つの物体の衝突 : 保存されるのは, a) 全運動量, b) 全角運動量，c) 一方の物体の衝突点に関する角運動量, d) 全エネルギー（弾性衝突の場合， 摩擦がある場合 は, 摩擦力に垂直な方向の運動エネルギーが保存される. e) 衝突中に滑りが止まったならば，接触点の最終 速度は接触面上にある. f) 滑りが止まらなかったなら ば, 一方の物体から他方に伝わる運動量は, 接触面の 法線と <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>arctan</mi><mo>⁡</mo><mi>μ</mi></mrow><annotation encoding="application/x-tex">\arctan \mu</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8095em;vertical-align:-0.1944em;"></span><span class="mop">arctan</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">μ</span></span></span></span> の角度をなす.</li>
</ol>
<h3 id="_4-17-剛体のすべての運動" tabindex="-1">4.17: 剛体のすべての運動 <a class="header-anchor" href="#_4-17-剛体のすべての運動" aria-label="Permalink to &quot;4.17: 剛体のすべての運動&quot;">&ZeroWidthSpace;</a></h3>
<ol start="17">
<li>剛体のすべての運動は (物体の各点の速度を見ると) 瞬 間回転中心 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>C</mi></mrow><annotation encoding="application/x-tex">C</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.07153em;">C</span></span></span></span> まわりの回転として表せる. 物体上の点 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>P</mi></mrow><annotation encoding="application/x-tex">P</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.13889em;">P</span></span></span></span> の <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>C</mi></mrow><annotation encoding="application/x-tex">C</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.07153em;">C</span></span></span></span> からの距離は <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>P</mi></mrow><annotation encoding="application/x-tex">P</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.13889em;">P</span></span></span></span> の軌跡の曲率半径とは異なる ことに注意せよ.</li>
</ol>
<h3 id="_4-18-紐の張力" tabindex="-1">4.18: 紐の張力 <a class="header-anchor" href="#_4-18-紐の張力" aria-label="Permalink to &quot;4.18: 紐の張力&quot;">&ZeroWidthSpace;</a></h3>
<ol start="18">
<li>紐の張力：重さのある吊り紐では, 張力の水平成分は 一定で垂直成分は下にある紐の重さにより変わる. 滑 らかな面の上の紐による（単位長さあたりの）力は，そ の曲率半径と張力で決まり, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>N</mi><mo>=</mo><mi>T</mi><mi mathvariant="normal">/</mi><mi>R</mi></mrow><annotation encoding="application/x-tex">N=T / R</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.10903em;">N</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.13889em;">T</span><span class="mord">/</span><span class="mord mathnormal" style="margin-right:0.00773em;">R</span></span></span></span>. 似た場合と して, 表面張力による圧力は <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>p</mi><mo>=</mo><mn>2</mn><mi>σ</mi><mi mathvariant="normal">/</mi><mi>R</mi></mrow><annotation encoding="application/x-tex">p=2 \sigma / R</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">p</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">2</span><span class="mord mathnormal" style="margin-right:0.03588em;">σ</span><span class="mord">/</span><span class="mord mathnormal" style="margin-right:0.00773em;">R</span></span></span></span>. 導出には直 径に沿った圧力を調ベる.</li>
</ol>
<h3 id="_4-19-液体の表面" tabindex="-1">4.19: 液体の表面 <a class="header-anchor" href="#_4-19-液体の表面" aria-label="Permalink to &quot;4.19: 液体の表面&quot;">&ZeroWidthSpace;</a></h3>
<ol start="19">
<li>液体の表面は（表面張力を無視すれば）等ポテンシャ ル面になる. 非圧縮性流体では, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>w</mi></mrow><annotation encoding="application/x-tex">w</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal" style="margin-right:0.02691em;">w</span></span></span></span> をポテンシャルエ ネルギーの体積密度として, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>p</mi><mo>=</mo><msub><mi>P</mi><mn>0</mn></msub><mo>−</mo><mi>w</mi></mrow><annotation encoding="application/x-tex">p=P_0-w</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">p</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.13889em;">P</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.1389em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">0</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal" style="margin-right:0.02691em;">w</span></span></span></span>.</li>
</ol>
<h3 id="_4-20-非圧縮性流体に対する-bernoulli-の法則" tabindex="-1">4.20: 非圧縮性流体に対する Bernoulli の法則 <a class="header-anchor" href="#_4-20-非圧縮性流体に対する-bernoulli-の法則" aria-label="Permalink to &quot;4.20: 非圧縮性流体に対する Bernoulli の法則&quot;">&ZeroWidthSpace;</a></h3>
<ol start="20">
<li>非圧縮性流体に対する Bernoulli の法則：<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mi>p</mi><mo>+</mo><mfrac><mn>1</mn><mn>2</mn></mfrac><mi>ρ</mi><msup><mi>v</mi><mn>2</mn></msup><mo>+</mo><mi>ρ</mi><mi>ϕ</mi><mo>=</mo><mtext> const. </mtext></mrow><annotation encoding="application/x-tex">p+\frac{1}{2} \rho v^2+\rho \phi=\text { const. }
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7778em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">p</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:2.0074em;vertical-align:-0.686em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.3214em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">2</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mord mathnormal">ρ</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">ρϕ</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6151em;"></span><span class="mord text"><span class="mord"> const. </span></span></span></span></span></span></p>
一様な重力場では <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ϕ</mi><mo>=</mo><mi>g</mi><mi>h</mi></mrow><annotation encoding="application/x-tex">\phi=g h</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">ϕ</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">g</span><span class="mord mathnormal">h</span></span></span></span>. 比熱が <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>c</mi><mi>p</mi></msub><mo stretchy="false">[</mo><mrow><mtext> </mtext><mi mathvariant="normal">J</mi></mrow><mi mathvariant="normal">/</mi><mrow><mi mathvariant="normal">k</mi><mi mathvariant="normal">g</mi></mrow><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">c_p[\mathrm{~J} / \mathrm{kg}]</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0361em;vertical-align:-0.2861em;"></span><span class="mord"><span class="mord mathnormal">c</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">p</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span><span class="mopen">[</span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">J</span></span><span class="mord">/</span><span class="mord"><span class="mord mathrm" style="margin-right:0.01389em;">kg</span></span><span class="mclose">]</span></span></span></span> である気 体では,<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mfrac><mn>1</mn><mn>2</mn></mfrac><msup><mi>v</mi><mn>2</mn></msup><mo>+</mo><msub><mi>c</mi><mi>p</mi></msub><mi>T</mi><mo>=</mo><mtext> const. </mtext></mrow><annotation encoding="application/x-tex">\frac{1}{2} v^2+c_p T=\text { const. }
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.0074em;vertical-align:-0.686em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.3214em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">2</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.9694em;vertical-align:-0.2861em;"></span><span class="mord"><span class="mord mathnormal">c</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">p</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span><span class="mord mathnormal" style="margin-right:0.13889em;">T</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6151em;"></span><span class="mord text"><span class="mord"> const. </span></span></span></span></span></span></p>
</li>
</ol>
<h3 id="_4-21-直線的な流線" tabindex="-1">4.21: 直線的な流線 <Badge type="tip" text="supplemental" /> <a class="header-anchor" href="#_4-21-直線的な流線" aria-label="Permalink to &quot;4.21: 直線的な流線 &lt;Badge type=&quot;tip&quot; text=&quot;supplemental&quot; /&gt;&quot;">&ZeroWidthSpace;</a></h3>
<ol start="21">
<li>直線的な流線に沾う運動量の連続性 : <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>p</mi><mo>+</mo><mi>ρ</mi><msup><mi>v</mi><mn>2</mn></msup><mo>=</mo></mrow><annotation encoding="application/x-tex">p+\rho v^2=</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7778em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">p</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1.0085em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">ρ</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span></span></span></span> const.</li>
</ol>
<h3 id="_4-22-断熱不変量" tabindex="-1">4.22: 断熱不変量 <Badge type="tip" text="supplemental" /> <a class="header-anchor" href="#_4-22-断熱不変量" aria-label="Permalink to &quot;4.22: 断熱不変量 &lt;Badge type=&quot;tip&quot; text=&quot;supplemental&quot; /&gt;&quot;">&ZeroWidthSpace;</a></h3>
<ol start="22">
<li>断熱不変量 : 振動する系の 1 周期の間のパラメータの 相対的な変化が小さければ，位相空間（ <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>x</mi><mo>−</mo><mi>p</mi></mrow><annotation encoding="application/x-tex">x-p</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mord mathnormal">x</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">p</span></span></span></span> 座標で表さ れる）上に書かれるループの面積は非常に高い精度で 保存される.</li>
</ol>
<h3 id="_4-23-安定性" tabindex="-1">4.23: 安定性 <a class="header-anchor" href="#_4-23-安定性" aria-label="Permalink to &quot;4.23: 安定性&quot;">&ZeroWidthSpace;</a></h3>
<ol start="23">
<li>安定性を調ベるには, a) ポテンシャルエネルギー最小 の原理，又は b) 仮想仕事の原理を用いる.</li>
</ol>
<h3 id="_4-24-空間的に有限な運動に対する-virial-定理" tabindex="-1">4.24: 空間的に有限な運動に対する Virial 定理 <Badge type="tip" text="supplemental" /> <a class="header-anchor" href="#_4-24-空間的に有限な運動に対する-virial-定理" aria-label="Permalink to &quot;4.24: 空間的に有限な運動に対する Virial 定理 &lt;Badge type=&quot;tip&quot; text=&quot;supplemental&quot; /&gt;&quot;">&ZeroWidthSpace;</a></h3>
<ol start="24">
<li>空間的に有限な運動に対する Virial 定理：a) もし <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>F</mi><mo>∝</mo><mi mathvariant="normal">∣</mi><mi mathvariant="bold-italic">r</mi><mi mathvariant="normal">∣</mi></mrow><annotation encoding="application/x-tex">F \propto|\boldsymbol{r}|</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.13889em;">F</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">∝</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">∣</span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03194em;">r</span></span></span><span class="mord">∣</span></span></span></span> ならば <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">⟨</mo><mi>K</mi><mo stretchy="false">⟩</mo><mo>=</mo><mo stretchy="false">⟨</mo><mi>U</mi><mo stretchy="false">⟩</mo></mrow><annotation encoding="application/x-tex">\langle K\rangle=\langle U\rangle</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">⟨</span><span class="mord mathnormal" style="margin-right:0.07153em;">K</span><span class="mclose">⟩</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">⟨</span><span class="mord mathnormal" style="margin-right:0.10903em;">U</span><span class="mclose">⟩</span></span></span></span> (時間平均). b) もし <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>F</mi><mo>∝</mo><mi mathvariant="normal">∣</mi><mi mathvariant="bold-italic">r</mi><msup><mi mathvariant="normal">∣</mi><mrow><mo>−</mo><mn>2</mn></mrow></msup></mrow><annotation encoding="application/x-tex">F \propto|\boldsymbol{r}|^{-2}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.13889em;">F</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">∝</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.0641em;vertical-align:-0.25em;"></span><span class="mord">∣</span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03194em;">r</span></span></span><span class="mord"><span class="mord">∣</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">−</span><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span></span></span> ならば <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>2</mn><mo stretchy="false">⟨</mo><mi>K</mi><mo stretchy="false">⟩</mo><mo>=</mo><mo>−</mo><mo stretchy="false">⟨</mo><mi>U</mi><mo stretchy="false">⟩</mo></mrow><annotation encoding="application/x-tex">2\langle K\rangle=-\langle U\rangle</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">2</span><span class="mopen">⟨</span><span class="mord mathnormal" style="margin-right:0.07153em;">K</span><span class="mclose">⟩</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">−</span><span class="mopen">⟨</span><span class="mord mathnormal" style="margin-right:0.10903em;">U</span><span class="mclose">⟩</span></span></span></span>.</li>
</ol>
<h3 id="_4-25-tsiolkovsky-公式" tabindex="-1">4.25: Tsiolkovsky 公式 <a class="header-anchor" href="#_4-25-tsiolkovsky-公式" aria-label="Permalink to &quot;4.25: Tsiolkovsky 公式&quot;">&ZeroWidthSpace;</a></h3>
<ol start="25">
<li>Tsiolkovsky の公式（ロケット）: <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Δ</mi><mi>v</mi><mo>=</mo><mi>u</mi><mi>ln</mi><mo>⁡</mo><mfrac><mi>M</mi><mi>m</mi></mfrac></mrow><annotation encoding="application/x-tex">\Delta v=u \ln \frac{M}{m}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">Δ</span><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.2173em;vertical-align:-0.345em;"></span><span class="mord mathnormal">u</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">ln</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8723em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">m</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.10903em;">M</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span></li>
</ol>
]]></description>
            <content:encoded><![CDATA[<h1 id="formulas-for-ipho-日本語版-section-4" tabindex="-1">Formulas for IPhO 日本語版: Section 4 <a class="header-anchor" href="#formulas-for-ipho-日本語版-section-4" aria-label="Permalink to &quot;Formulas for IPhO 日本語版: Section 4&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="_4-力学" tabindex="-1">4: 力学 <a class="header-anchor" href="#_4-力学" aria-label="Permalink to &quot;4: 力学&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="_4-1-剛体の二次元的な平衡" tabindex="-1">4.1: 剛体の二次元的な平衡 <a class="header-anchor" href="#_4-1-剛体の二次元的な平衡" aria-label="Permalink to &quot;4.1: 剛体の二次元的な平衡&quot;">&ZeroWidthSpace;</a></h3>
<ol>
<li>剛体の二次元的な平衡 : 力についての 2 つの式とトル クについての 1 つの式. 1 （又は 2 ）個の力についての 式は 1（又は 2）個のトルクについての式で代用でき る. トルクの方が良い場合が多く，原点を適切に選択 することで「退屈な」力を消すことができる. もし 2 点 のみに力がかかっているならば，（正味の）力がかかっ ている直線は一致する. 3 点であれば, 3 つの直線は 1 点で交わる.</li>
</ol>
<h3 id="_4-2-垂直抗力" tabindex="-1">4.2: 垂直抗力 <a class="header-anchor" href="#_4-2-垂直抗力" aria-label="Permalink to &quot;4.2: 垂直抗力&quot;">&ZeroWidthSpace;</a></h3>
<ol start="2">
<li>垂直抗力と摩擦力は 1 つの力に合成でき, 垂直抗力に 対して <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>arctan</mi><mo>⁡</mo><mi>μ</mi></mrow><annotation encoding="application/x-tex">\arctan \mu</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8095em;vertical-align:-0.1944em;"></span><span class="mop">arctan</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">μ</span></span></span></span> の角度で接触点に加わる.</li>
</ol>
<h3 id="_4-3-並進運動と回転運動" tabindex="-1">4.3: 並進運動と回転運動 <a class="header-anchor" href="#_4-3-並進運動と回転運動" aria-label="Permalink to &quot;4.3: 並進運動と回転運動&quot;">&ZeroWidthSpace;</a></h3>
<ol start="3">
<li>並進運動と回転運動についての Newton の第二法則：<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mi mathvariant="bold-italic">F</mi><mo>=</mo><mi>m</mi><mi mathvariant="bold-italic">a</mi><mo separator="true">,</mo><mi mathvariant="bold-italic">M</mi><mo>=</mo><mi>I</mi><mi mathvariant="bold-italic">ε</mi><mspace width="1em"/><mo stretchy="false">(</mo><mi mathvariant="bold-italic">M</mi><mo>=</mo><mi mathvariant="bold-italic">r</mi><mo>×</mo><mi mathvariant="bold-italic">F</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">\boldsymbol{F}=m \boldsymbol{a}, \boldsymbol{M}=I \boldsymbol{\varepsilon} \quad(\boldsymbol{M}=\boldsymbol{r} \times \boldsymbol{F})
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6861em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.15972em;">F</span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8805em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">m</span><span class="mord"><span class="mord"><span class="mord boldsymbol">a</span></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.11424em;">M</span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="mord"><span class="mord"><span class="mord boldsymbol">ε</span></span></span><span class="mspace" style="margin-right:1em;"></span><span class="mopen">(</span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.11424em;">M</span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03194em;">r</span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">×</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.15972em;">F</span></span></span><span class="mclose">)</span></span></span></span></span></p>
二次元の場合には <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>M</mi></mrow><annotation encoding="application/x-tex">M</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.10903em;">M</span></span></span></span> と <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ε</mi></mrow><annotation encoding="application/x-tex">\varepsilon</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">ε</span></span></span></span> は本質的にスカラーで, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>M</mi><mo>=</mo><mi>F</mi><mi>l</mi><mo>=</mo><msub><mi>F</mi><mi>t</mi></msub><mi>r</mi><mo stretchy="false">(</mo><mi>l</mi></mrow><annotation encoding="application/x-tex">M=F l=F_t r(l</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.10903em;">M</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal" style="margin-right:0.01968em;">Fl</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.13889em;">F</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.2806em;"><span style="top:-2.55em;margin-left:-0.1389em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">t</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord mathnormal" style="margin-right:0.02778em;">r</span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.01968em;">l</span></span></span></span> は力のうでの長さ <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mclose">)</span></span></span></span></li>
</ol>
<h3 id="_4-4-一般化座標" tabindex="-1">4.4: 一般化座標 <a class="header-anchor" href="#_4-4-一般化座標" aria-label="Permalink to &quot;4.4: 一般化座標&quot;">&ZeroWidthSpace;</a></h3>
<ol start="4">
<li>一般化座標. 系の状態が 1 つの変数 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ξ</mi></mrow><annotation encoding="application/x-tex">\xi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.04601em;">ξ</span></span></span></span> とその時間微分 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mi>ξ</mi><mo>˙</mo></mover></mrow><annotation encoding="application/x-tex">\dot{\xi}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1257em;vertical-align:-0.1944em;"></span><span class="mord accent"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.9313em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord mathnormal" style="margin-right:0.04601em;">ξ</span></span><span style="top:-3.2634em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.0278em;"><span class="mord">˙</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.1944em;"><span></span></span></span></span></span></span></span></span> で表され，ポテンシャルエネルギーが <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>U</mi><mo>=</mo><mi>U</mi><mo stretchy="false">(</mo><mi>ξ</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">U=U(\xi)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.10903em;">U</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.10903em;">U</span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.04601em;">ξ</span><span class="mclose">)</span></span></span></span>, 運動エネルギーが <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>K</mi><mo>=</mo><mi>μ</mi><msup><mi>ξ</mi><mn>2</mn></msup><mi mathvariant="normal">/</mi><mn>2</mn></mrow><annotation encoding="application/x-tex">K=\mu \xi^2 / 2</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.07153em;">K</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.0641em;vertical-align:-0.25em;"></span><span class="mord mathnormal">μ</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.04601em;">ξ</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mord">/2</span></span></span></span> であるならば, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>μ</mi><mover accent="true"><mi>ξ</mi><mo>¨</mo></mover><mo>=</mo></mrow><annotation encoding="application/x-tex">\mu \ddot{\xi}=</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1257em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">μ</span><span class="mord accent"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.9313em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord mathnormal" style="margin-right:0.04601em;">ξ</span></span><span style="top:-3.2634em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.1389em;"><span class="mord">¨</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.1944em;"><span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span></span></span></span> <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>−</mo><mi mathvariant="normal">d</mi><mi>U</mi><mo stretchy="false">(</mo><mi>ξ</mi><mo stretchy="false">)</mo><mi mathvariant="normal">/</mi><mi mathvariant="normal">d</mi><mi>ξ</mi></mrow><annotation encoding="application/x-tex">-\mathrm{d} U(\xi) / \mathrm{d} \xi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">−</span><span class="mord mathrm">d</span><span class="mord mathnormal" style="margin-right:0.10903em;">U</span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.04601em;">ξ</span><span class="mclose">)</span><span class="mord">/</span><span class="mord mathrm">d</span><span class="mord mathnormal" style="margin-right:0.04601em;">ξ</span></span></span></span>. (したがって並進運動では, 力はポテン シャルエネルギーの微分)</li>
</ol>
<h3 id="_4-5-系質点" tabindex="-1">4.5: 系質点 <a class="header-anchor" href="#_4-5-系質点" aria-label="Permalink to &quot;4.5: 系質点&quot;">&ZeroWidthSpace;</a></h3>
<ol start="5">
<li>系が質点 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>m</mi><mi>i</mi></msub></mrow><annotation encoding="application/x-tex">m_i</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal">m</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> で構成されているとき：<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mtable rowspacing="0.25em" columnalign="right left" columnspacing="0em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><msub><mi mathvariant="bold-italic">r</mi><mi>c</mi></msub><mo>=</mo><mo>∑</mo><msub><mi>m</mi><mi>i</mi></msub><msub><mi mathvariant="bold-italic">r</mi><mi>i</mi></msub><mi mathvariant="normal">/</mi><mo>∑</mo><msub><mi>m</mi><mi>j</mi></msub><mo separator="true">,</mo><mi mathvariant="bold-italic">P</mi><mo>=</mo><mo>∑</mo><msub><mi>m</mi><mi>i</mi></msub><msub><mi mathvariant="bold-italic">v</mi><mi>i</mi></msub></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mi mathvariant="bold-italic">L</mi><mo>=</mo><mo>∑</mo><msub><mi>m</mi><mi>i</mi></msub><msub><mi mathvariant="bold-italic">r</mi><mi>i</mi></msub><mo>×</mo><msub><mi mathvariant="bold-italic">v</mi><mi>i</mi></msub><mo separator="true">,</mo><mi>K</mi><mo>=</mo><mo>∑</mo><msub><mi>m</mi><mi>i</mi></msub><msubsup><mi>v</mi><mi>i</mi><mn>2</mn></msubsup><mi mathvariant="normal">/</mi><mn>2</mn></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><msub><mi>I</mi><mi>z</mi></msub><mo>=</mo><mo>∑</mo><msub><mi>m</mi><mi>i</mi></msub><mrow><mo fence="true">(</mo><msubsup><mi>x</mi><mi>i</mi><mn>2</mn></msubsup><mo>+</mo><msubsup><mi>y</mi><mi>i</mi><mn>2</mn></msubsup><mo fence="true">)</mo></mrow><mo>=</mo><mo>∫</mo><mrow><mo fence="true">(</mo><msup><mi>x</mi><mn>2</mn></msup><mo>+</mo><msup><mi>y</mi><mn>2</mn></msup><mo fence="true">)</mo></mrow><mi mathvariant="normal">d</mi><mi>m</mi></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{aligned}
&amp; \boldsymbol{r}_c=\sum m_i \boldsymbol{r}_i / \sum m_j, \boldsymbol{P}=\sum m_i \boldsymbol{v}_i \\
&amp; \boldsymbol{L}=\sum m_i \boldsymbol{r}_i \times \boldsymbol{v}_i, K=\sum m_i v_i^2 / 2 \\
&amp; I_z=\sum m_i\left(x_i^2+y_i^2\right)=\int\left(x^2+y^2\right) \mathrm{d} m \\
&amp;
\end{aligned}
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:7.8223em;vertical-align:-3.6611em;"></span><span class="mord"><span class="mtable"><span class="col-align-r"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:4.1611em;"><span style="top:-6.4711em;"><span class="pstrut" style="height:3.36em;"></span><span class="mord"></span></span><span style="top:-4.5711em;"><span class="pstrut" style="height:3.36em;"></span><span class="mord"></span></span><span style="top:-2.3611em;"><span class="pstrut" style="height:3.36em;"></span><span class="mord"></span></span><span style="top:-0.3589em;"><span class="pstrut" style="height:3.36em;"></span><span class="mord"></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:3.6611em;"><span></span></span></span></span></span><span class="col-align-l"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:4.1611em;"><span style="top:-6.4711em;"><span class="pstrut" style="height:3.36em;"></span><span class="mord"><span class="mord"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03194em;">r</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mop op-symbol large-op" style="position:relative;top:0em;">∑</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal">m</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03194em;">r</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord">/</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop op-symbol large-op" style="position:relative;top:0em;">∑</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal">m</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.05724em;">j</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.15972em;">P</span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mop op-symbol large-op" style="position:relative;top:0em;">∑</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal">m</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03704em;">v</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span><span style="top:-4.5711em;"><span class="pstrut" style="height:3.36em;"></span><span class="mord"><span class="mord"></span><span class="mord"><span class="mord"><span class="mord boldsymbol">L</span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mop op-symbol large-op" style="position:relative;top:0em;">∑</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal">m</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03194em;">r</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">×</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03704em;">v</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.07153em;">K</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mop op-symbol large-op" style="position:relative;top:0em;">∑</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal">m</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-2.453em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.247em;"><span></span></span></span></span></span></span><span class="mord">/2</span></span></span><span style="top:-2.3611em;"><span class="pstrut" style="height:3.36em;"></span><span class="mord"><span class="mord"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:-0.0785em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.04398em;">z</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mop op-symbol large-op" style="position:relative;top:0em;">∑</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal">m</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size1">(</span></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-2.453em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.247em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">y</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-2.453em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.247em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size1">)</span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mop op-symbol large-op" style="margin-right:0.44445em;position:relative;top:-0.0011em;">∫</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size1">(</span></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">y</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size1">)</span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathrm">d</span><span class="mord mathnormal">m</span></span></span><span style="top:-0.3589em;"><span class="pstrut" style="height:3.36em;"></span><span class="mord"><span class="mord"></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:3.6611em;"><span></span></span></span></span></span></span></span></span></span></span></span></p>
</li>
</ol>
<h3 id="_4-6-質量中心の速度" tabindex="-1">4.6: 質量中心の速度 <a class="header-anchor" href="#_4-6-質量中心の速度" aria-label="Permalink to &quot;4.6: 質量中心の速度&quot;">&ZeroWidthSpace;</a></h3>
<ol start="6">
<li>質量中心の速度が <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi mathvariant="bold-italic">v</mi><mi>c</mi></msub></mrow><annotation encoding="application/x-tex">\boldsymbol{v}_c</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5944em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03704em;">v</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> であるような系 (添え字 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>c</mi></mrow><annotation encoding="application/x-tex">c</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">c</span></span></span></span> は質量 中心についての物理量であることを示す）:<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mtable rowspacing="0.25em" columnalign="center" columnspacing="0em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mi mathvariant="bold-italic">L</mi><mo>=</mo><msub><mi mathvariant="bold-italic">L</mi><mi>c</mi></msub><mo>+</mo><msub><mi>M</mi><mi mathvariant="normal">Σ</mi></msub><msub><mi mathvariant="bold-italic">R</mi><mi>c</mi></msub><mo>×</mo><msub><mi mathvariant="bold-italic">v</mi><mi>c</mi></msub><mo separator="true">,</mo><mi>K</mi><mo>=</mo><msub><mi>K</mi><mi>c</mi></msub><mo>+</mo><msub><mi>M</mi><mi mathvariant="normal">Σ</mi></msub><msubsup><mi>v</mi><mi>c</mi><mn>2</mn></msubsup><mi mathvariant="normal">/</mi><mn>2</mn></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mi mathvariant="bold-italic">P</mi><mo>=</mo><msub><mi mathvariant="bold-italic">P</mi><mi>c</mi></msub><mo>+</mo><msub><mi>M</mi><mi mathvariant="normal">Σ</mi></msub><msub><mi mathvariant="bold-italic">v</mi><mi>c</mi></msub><mi mathvariant="normal">.</mi></mrow></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{gathered}
\boldsymbol{L}=\boldsymbol{L}_c+M_{\Sigma} \boldsymbol{R}_c \times \boldsymbol{v}_c, K=K_c+M_{\Sigma} v_c^2 / 2 \\
\boldsymbol{P}=\boldsymbol{P}_c+M_{\Sigma} \boldsymbol{v}_c .
\end{gathered}
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:3.0241em;vertical-align:-1.2621em;"></span><span class="mord"><span class="mtable"><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.7621em;"><span style="top:-3.8979em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol">L</span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol">L</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.10903em;">M</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-left:-0.109em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">Σ</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.00421em;">R</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">×</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03704em;">v</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.07153em;">K</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.07153em;">K</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:-0.0715em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.10903em;">M</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-left:-0.109em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">Σ</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-2.453em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">c</span></span></span><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.247em;"><span></span></span></span></span></span></span><span class="mord">/2</span></span></span><span style="top:-2.3979em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.15972em;">P</span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.15972em;">P</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.10903em;">M</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-left:-0.109em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">Σ</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03704em;">v</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord">.</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.2621em;"><span></span></span></span></span></span></span></span></span></span></span></span></p>
</li>
</ol>
<h3 id="_4-7-steiner-定理" tabindex="-1">4.7: Steiner 定理 <a class="header-anchor" href="#_4-7-steiner-定理" aria-label="Permalink to &quot;4.7: Steiner 定理&quot;">&ZeroWidthSpace;</a></h3>
<ol start="7">
<li>Steiner の定理（平行軸の定理）も同じような形で は質量中心の回転軸からの距離）:<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mi>I</mi><mo>=</mo><msub><mi>I</mi><mi>c</mi></msub><mo>+</mo><mi>m</mi><msup><mi>b</mi><mn>2</mn></msup></mrow><annotation encoding="application/x-tex">I=I_c+m b^2
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:-0.0785em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.8641em;"></span><span class="mord mathnormal">m</span><span class="mord"><span class="mord mathnormal">b</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span></span></span></p>
</li>
</ol>
<h3 id="_4-8-ポイント-6" tabindex="-1">4.8: ポイント 6 <a class="header-anchor" href="#_4-8-ポイント-6" aria-label="Permalink to &quot;4.8: ポイント 6&quot;">&ZeroWidthSpace;</a></h3>
<ol start="8">
<li>ポイント 6 の <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="bold-italic">P</mi></mrow><annotation encoding="application/x-tex">\boldsymbol{P}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6861em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.15972em;">P</span></span></span></span></span></span> と <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="bold-italic">L</mi></mrow><annotation encoding="application/x-tex">\boldsymbol{L}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6861em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol">L</span></span></span></span></span></span> を用いて, Newton の第二法則 :<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><msub><mi mathvariant="bold-italic">F</mi><mi mathvariant="normal">Σ</mi></msub><mo>=</mo><mi mathvariant="normal">d</mi><mi mathvariant="bold-italic">P</mi><mi mathvariant="normal">/</mi><mi mathvariant="normal">d</mi><mi>t</mi><mo separator="true">,</mo><msub><mi mathvariant="bold-italic">M</mi><mi mathvariant="normal">Σ</mi></msub><mo>=</mo><mi mathvariant="normal">d</mi><mi mathvariant="bold-italic">L</mi><mi mathvariant="normal">/</mi><mi mathvariant="normal">d</mi><mi>t</mi></mrow><annotation encoding="application/x-tex">\boldsymbol{F}_{\Sigma}=\mathrm{d} \boldsymbol{P} / \mathrm{d} t, \boldsymbol{M}_{\Sigma}=\mathrm{d} \boldsymbol{L} / \mathrm{d} t
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8361em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.15972em;">F</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">Σ</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathrm">d</span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.15972em;">P</span></span></span><span class="mord">/</span><span class="mord mathrm">d</span><span class="mord mathnormal">t</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.11424em;">M</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">Σ</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathrm">d</span><span class="mord"><span class="mord"><span class="mord boldsymbol">L</span></span></span><span class="mord">/</span><span class="mord mathrm">d</span><span class="mord mathnormal">t</span></span></span></span></span></p>
</li>
</ol>
<h3 id="_4-9-ポイント-5" tabindex="-1">4.9: ポイント 5 <a class="header-anchor" href="#_4-9-ポイント-5" aria-label="Permalink to &quot;4.9: ポイント 5&quot;">&ZeroWidthSpace;</a></h3>
<ol start="9">
<li>ポイント 5 にに加えて，質量中心を通る <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>z</mi></mrow><annotation encoding="application/x-tex">z</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal" style="margin-right:0.04398em;">z</span></span></span></span> 軸に対する慣性モ一メントは <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>I</mi><mrow><mi>z</mi><mn>0</mn></mrow></msub><mo>=</mo></mrow><annotation encoding="application/x-tex">I_{z 0}=</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0785em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.04398em;">z</span><span class="mord mtight">0</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span></span></span></span> <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mo>∑</mo><mrow><mi>i</mi><mo separator="true">,</mo><mi>j</mi></mrow></msub><msub><mi>m</mi><mi>i</mi></msub><msub><mi>m</mi><mi>j</mi></msub><mrow><mo fence="true">[</mo><msup><mrow><mo fence="true">(</mo><msub><mi>x</mi><mi>i</mi></msub><mo>−</mo><msub><mi>x</mi><mi>j</mi></msub><mo fence="true">)</mo></mrow><mn>2</mn></msup><mo>+</mo><msup><mrow><mo fence="true">(</mo><msub><mi>y</mi><mi>i</mi></msub><mo>−</mo><msub><mi>y</mi><mi>j</mi></msub><mo fence="true">)</mo></mrow><mn>2</mn></msup><mo fence="true">]</mo></mrow><mi mathvariant="normal">/</mi><mrow><mo fence="true">(</mo><mn>2</mn><msub><mi>M</mi><mi mathvariant="normal">Σ</mi></msub><mo fence="true">)</mo></mrow></mrow><annotation encoding="application/x-tex">\sum_{i, j} m_i m_j\left[\left(x_i-x_j\right)^2+\left(y_i-y_j\right)^2\right] /\left(2 M_{\Sigma}\right)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.8em;vertical-align:-0.65em;"></span><span class="mop"><span class="mop op-symbol small-op" style="position:relative;top:0em;">∑</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.162em;"><span style="top:-2.4003em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">i</span><span class="mpunct mtight">,</span><span class="mord mathnormal mtight" style="margin-right:0.05724em;">j</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.4358em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal">m</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathnormal">m</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.05724em;">j</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size2">[</span></span><span class="minner"><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.05724em;">j</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">)</span></span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.954em;"><span style="top:-3.2029em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="minner"><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">y</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">y</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.05724em;">j</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">)</span></span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.954em;"><span style="top:-3.2029em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size2">]</span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord">/</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord">2</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.10903em;">M</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-left:-0.109em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">Σ</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">)</span></span></span></span></span></li>
</ol>
<h3 id="_4-10-原点に対する慣性" tabindex="-1">4.10: 原点に対する慣性 <a class="header-anchor" href="#_4-10-原点に対する慣性" aria-label="Permalink to &quot;4.10: 原点に対する慣性&quot;">&ZeroWidthSpace;</a></h3>
<ol start="10">
<li>原点に対する慣性モ一メント <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>θ</mi><mo>=</mo><mo>∑</mo><msub><mi>m</mi><mi>i</mi></msub><msubsup><mi>r</mi><mi>i</mi><mn>2</mn></msubsup></mrow><annotation encoding="application/x-tex">\theta=\sum m_i r_i^2</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal" style="margin-right:0.02778em;">θ</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.0728em;vertical-align:-0.2587em;"></span><span class="mop op-symbol small-op" style="position:relative;top:0em;">∑</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal">m</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.02778em;">r</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-2.4413em;margin-left:-0.0278em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2587em;"><span></span></span></span></span></span></span></span></span></span> は, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>2</mn><mi>θ</mi><mo>=</mo><msub><mi>I</mi><mi>x</mi></msub><mo>+</mo><msub><mi>I</mi><mi>y</mi></msub><mo>+</mo><msub><mi>I</mi><mi>z</mi></msub></mrow><annotation encoding="application/x-tex">2 \theta=I_x+I_y+I_z</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">2</span><span class="mord mathnormal" style="margin-right:0.02778em;">θ</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:-0.0785em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">x</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.9694em;vertical-align:-0.2861em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:-0.0785em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.03588em;">y</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:-0.0785em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.04398em;">z</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> を用いることで二次元物体や等 方性のある物体の <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>I</mi><mi>z</mi></msub></mrow><annotation encoding="application/x-tex">I_z</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:-0.0785em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.04398em;">z</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> を計算するのに有用.</li>
</ol>
<h3 id="_4-11-相当単振子の長" tabindex="-1">4.11: 相当単振子の長 <a class="header-anchor" href="#_4-11-相当単振子の長" aria-label="Permalink to &quot;4.11: 相当単振子の長&quot;">&ZeroWidthSpace;</a></h3>
<ol start="11">
<li>相当単振子の長さが <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mi>l</mi><mo>~</mo></mover></mrow><annotation encoding="application/x-tex">\tilde{l}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9313em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.9313em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord mathnormal" style="margin-right:0.01968em;">l</span></span><span style="top:-3.6134em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.1667em;"><span class="mord">~</span></span></span></span></span></span></span></span></span></span> である物理振子 :<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mtable rowspacing="0.25em" columnalign="right left" columnspacing="0em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><msup><mi>ω</mi><mn>2</mn></msup><mo stretchy="false">(</mo><mi>l</mi><mo stretchy="false">)</mo><mo>=</mo><mi>g</mi><mi mathvariant="normal">/</mi><mrow><mo fence="true">(</mo><mi>l</mi><mo>+</mo><msub><mi>I</mi><mi>c</mi></msub><mi mathvariant="normal">/</mi><mi>m</mi><mi>l</mi><mo fence="true">)</mo></mrow></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mi>ω</mi><mo stretchy="false">(</mo><mi>l</mi><mo stretchy="false">)</mo><mo>=</mo><mi>ω</mi><mo stretchy="false">(</mo><mover accent="true"><mi>l</mi><mo>~</mo></mover><mo>−</mo><mi>l</mi><mo stretchy="false">)</mo><mo>=</mo><msqrt><mrow><mi>g</mi><mi mathvariant="normal">/</mi><mover accent="true"><mi>l</mi><mo>~</mo></mover></mrow></msqrt><mo separator="true">,</mo><mspace width="1em"/><mover accent="true"><mi>l</mi><mo>~</mo></mover><mo>=</mo><mi>l</mi><mo>+</mo><msub><mi>I</mi><mi>c</mi></msub><mi mathvariant="normal">/</mi><mi>m</mi><mi>l</mi></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{aligned}
&amp; \omega^2(l)=g /\left(l+I_c / m l\right) \\
&amp; \omega(l)=\omega(\tilde{l}-l)=\sqrt{g / \tilde{l}}, \quad \tilde{l}=l+I_c / m l \\
&amp;
\end{aligned}
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:5.1641em;vertical-align:-2.3321em;"></span><span class="mord"><span class="mtable"><span class="col-align-r"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:2.8321em;"><span style="top:-5.3425em;"><span class="pstrut" style="height:3.3745em;"></span><span class="mord"></span></span><span style="top:-3.3079em;"><span class="pstrut" style="height:3.3745em;"></span><span class="mord"></span></span><span style="top:-1.7025em;"><span class="pstrut" style="height:3.3745em;"></span><span class="mord"></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:2.3321em;"><span></span></span></span></span></span><span class="col-align-l"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:2.8321em;"><span style="top:-5.3425em;"><span class="pstrut" style="height:3.3745em;"></span><span class="mord"><span class="mord"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">ω</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.01968em;">l</span><span class="mclose">)</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">g</span><span class="mord">/</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord mathnormal" style="margin-right:0.01968em;">l</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:-0.0785em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord">/</span><span class="mord mathnormal">m</span><span class="mord mathnormal" style="margin-right:0.01968em;">l</span><span class="mclose delimcenter" style="top:0em;">)</span></span></span></span><span style="top:-3.3079em;"><span class="pstrut" style="height:3.3745em;"></span><span class="mord"><span class="mord"></span><span class="mord mathnormal" style="margin-right:0.03588em;">ω</span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.01968em;">l</span><span class="mclose">)</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">ω</span><span class="mopen">(</span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.9313em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord mathnormal" style="margin-right:0.01968em;">l</span></span><span style="top:-3.6134em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.1667em;"><span class="mord">~</span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal" style="margin-right:0.01968em;">l</span><span class="mclose">)</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.3745em;"><span class="svg-align" style="top:-3.8em;"><span class="pstrut" style="height:3.8em;"></span><span class="mord" style="padding-left:1em;"><span class="mord mathnormal" style="margin-right:0.03588em;">g</span><span class="mord">/</span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.9313em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord mathnormal" style="margin-right:0.01968em;">l</span></span><span style="top:-3.6134em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.1667em;"><span class="mord">~</span></span></span></span></span></span></span></span></span><span style="top:-3.3345em;"><span class="pstrut" style="height:3.8em;"></span><span class="hide-tail" style="min-width:1.02em;height:1.88em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='1.88em' viewBox='0 0 400000 1944' preserveAspectRatio='xMinYMin slice'><path d='M983 90
l0 -0
c4,-6.7,10,-10,18,-10 H400000v40
H1013.1s-83.4,268,-264.1,840c-180.7,572,-277,876.3,-289,913c-4.7,4.7,-12.7,7,-24,7
s-12,0,-12,0c-1.3,-3.3,-3.7,-11.7,-7,-25c-35.3,-125.3,-106.7,-373.3,-214,-744
c-10,12,-21,25,-33,39s-32,39,-32,39c-6,-5.3,-15,-14,-27,-26s25,-30,25,-30
c26.7,-32.7,52,-63,76,-91s52,-60,52,-60s208,722,208,722
c56,-175.3,126.3,-397.3,211,-666c84.7,-268.7,153.8,-488.2,207.5,-658.5
c53.7,-170.3,84.5,-266.8,92.5,-289.5z
M1001 80h400000v40h-400000z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.4655em;"><span></span></span></span></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:1em;"></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.9313em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord mathnormal" style="margin-right:0.01968em;">l</span></span><span style="top:-3.6134em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.1667em;"><span class="mord">~</span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord mathnormal" style="margin-right:0.01968em;">l</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:-0.0785em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord">/</span><span class="mord mathnormal">m</span><span class="mord mathnormal" style="margin-right:0.01968em;">l</span></span></span><span style="top:-1.7025em;"><span class="pstrut" style="height:3.3745em;"></span><span class="mord"><span class="mord"></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:2.3321em;"><span></span></span></span></span></span></span></span></span></span></span></span></p>
</li>
</ol>
<h3 id="_4-12-慣性モーメントの係数" tabindex="-1">4.12: 慣性モーメントの係数 <a class="header-anchor" href="#_4-12-慣性モーメントの係数" aria-label="Permalink to &quot;4.12: 慣性モーメントの係数&quot;">&ZeroWidthSpace;</a></h3>
<ol start="12">
<li>慣性モーメントの係数 : 円柱 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mfrac><mn>1</mn><mn>2</mn></mfrac></mrow><annotation encoding="application/x-tex">\frac{1}{2}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1901em;vertical-align:-0.345em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8451em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">1</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span>, 球 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mfrac><mn>2</mn><mn>5</mn></mfrac></mrow><annotation encoding="application/x-tex">\frac{2}{5}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1901em;vertical-align:-0.345em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8451em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">5</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span>, 球殼 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mfrac><mn>2</mn><mn>3</mn></mfrac></mrow><annotation encoding="application/x-tex">\frac{2}{3}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1901em;vertical-align:-0.345em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8451em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">3</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span>, 棒 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mfrac><mn>1</mn><mn>12</mn></mfrac></mrow><annotation encoding="application/x-tex">\frac{1}{12}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1901em;vertical-align:-0.345em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8451em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">12</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">1</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span> （端に対しては <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mfrac><mn>1</mn><mn>3</mn></mfrac></mrow><annotation encoding="application/x-tex">\frac{1}{3}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1901em;vertical-align:-0.345em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8451em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">3</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">1</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span> ), 正方形 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mfrac><mn>1</mn><mn>6</mn></mfrac></mrow><annotation encoding="application/x-tex">\frac{1}{6}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1901em;vertical-align:-0.345em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8451em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">6</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">1</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span>.</li>
</ol>
<h3 id="_4-13-よく使われる保存則" tabindex="-1">4.13: よく使われる保存則 <a class="header-anchor" href="#_4-13-よく使われる保存則" aria-label="Permalink to &quot;4.13: よく使われる保存則&quot;">&ZeroWidthSpace;</a></h3>
<ol start="13">
<li>よく使われる保存則：エネルギー（弾性衝突，摩擦な し), 運動量（正味の外力なし, 各方向について成立), 角運動量（正味の外トルクなし, 例えば, 外力のうでの 長さが 0 (これが 2 又は 3 点のまわりに成り立てば運 動量保存で代用できる))</li>
</ol>
<h3 id="_4-14-非慣性系における見かけの力" tabindex="-1">4.14: 非慣性系における見かけの力 <a class="header-anchor" href="#_4-14-非慣性系における見かけの力" aria-label="Permalink to &quot;4.14: 非慣性系における見かけの力&quot;">&ZeroWidthSpace;</a></h3>
<ol start="14">
<li>非慣性系における見かけの力 : 慣性力 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>−</mo><mi>m</mi><mi>a</mi></mrow><annotation encoding="application/x-tex">-m a</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mord">−</span><span class="mord mathnormal">ma</span></span></span></span>, 遠心力 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>m</mi><msup><mi>ω</mi><mn>2</mn></msup><mi mathvariant="bold-italic">R</mi></mrow><annotation encoding="application/x-tex">m \omega^2 \boldsymbol{R}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8141em;"></span><span class="mord mathnormal">m</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">ω</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.00421em;">R</span></span></span></span></span></span>, Coriolis 力 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>2</mn><mi>m</mi><mi mathvariant="bold-italic">v</mi><mo>×</mo><mi mathvariant="normal">Ω</mi></mrow><annotation encoding="application/x-tex">2 m \boldsymbol{v} \times \Omega</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7278em;vertical-align:-0.0833em;"></span><span class="mord">2</span><span class="mord mathnormal">m</span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03704em;">v</span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">×</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">Ω</span></span></span></span> (避けた方がよい. 速 度に垂直なので仕事はしない).</li>
</ol>
<h3 id="_4-15-傾いた座標" tabindex="-1">4.15: 傾いた座標 <a class="header-anchor" href="#_4-15-傾いた座標" aria-label="Permalink to &quot;4.15: 傾いた座標&quot;">&ZeroWidthSpace;</a></h3>
<ol start="15">
<li>傾いた座標：斜面上での運動については, 斜面に平行 と垂直な方向に軸をとるのがよい。このとき重力加速 度は <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>x</mi></mrow><annotation encoding="application/x-tex">x</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">x</span></span></span></span> 成分と <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>y</mi></mrow><annotation encoding="application/x-tex">y</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">y</span></span></span></span> 成分をもつ. 軸は斜交することもある が, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="bold-italic">v</mi><mo>=</mo><msub><mi>v</mi><mi>x</mi></msub><msub><mi mathvariant="bold-italic">e</mi><mi>x</mi></msub><mo>+</mo><msub><mi>v</mi><mi>y</mi></msub><msub><mi mathvariant="bold-italic">e</mi><mi>y</mi></msub></mrow><annotation encoding="application/x-tex">\boldsymbol{v}=v_x \boldsymbol{e}_x+v_y \boldsymbol{e}_y</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4444em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03704em;">v</span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.7333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">x</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol">e</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">x</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.7305em;vertical-align:-0.2861em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.03588em;">y</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol">e</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.03588em;">y</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span></span></span></span> のとき <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>v</mi><mi>x</mi></msub></mrow><annotation encoding="application/x-tex">v_x</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">x</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> は <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="bold-italic">v</mi></mrow><annotation encoding="application/x-tex">\boldsymbol{v}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4444em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03704em;">v</span></span></span></span></span></span> の <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>x</mi></mrow><annotation encoding="application/x-tex">x</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">x</span></span></span></span> 軸への射 影ではない.</li>
</ol>
<h3 id="_4-16-2-つの物体の衝突" tabindex="-1">4.16: 2 つの物体の衝突 <a class="header-anchor" href="#_4-16-2-つの物体の衝突" aria-label="Permalink to &quot;4.16: 2 つの物体の衝突&quot;">&ZeroWidthSpace;</a></h3>
<ol start="16">
<li>2 つの物体の衝突 : 保存されるのは, a) 全運動量, b) 全角運動量，c) 一方の物体の衝突点に関する角運動量, d) 全エネルギー（弾性衝突の場合， 摩擦がある場合 は, 摩擦力に垂直な方向の運動エネルギーが保存される. e) 衝突中に滑りが止まったならば，接触点の最終 速度は接触面上にある. f) 滑りが止まらなかったなら ば, 一方の物体から他方に伝わる運動量は, 接触面の 法線と <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>arctan</mi><mo>⁡</mo><mi>μ</mi></mrow><annotation encoding="application/x-tex">\arctan \mu</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8095em;vertical-align:-0.1944em;"></span><span class="mop">arctan</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">μ</span></span></span></span> の角度をなす.</li>
</ol>
<h3 id="_4-17-剛体のすべての運動" tabindex="-1">4.17: 剛体のすべての運動 <a class="header-anchor" href="#_4-17-剛体のすべての運動" aria-label="Permalink to &quot;4.17: 剛体のすべての運動&quot;">&ZeroWidthSpace;</a></h3>
<ol start="17">
<li>剛体のすべての運動は (物体の各点の速度を見ると) 瞬 間回転中心 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>C</mi></mrow><annotation encoding="application/x-tex">C</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.07153em;">C</span></span></span></span> まわりの回転として表せる. 物体上の点 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>P</mi></mrow><annotation encoding="application/x-tex">P</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.13889em;">P</span></span></span></span> の <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>C</mi></mrow><annotation encoding="application/x-tex">C</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.07153em;">C</span></span></span></span> からの距離は <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>P</mi></mrow><annotation encoding="application/x-tex">P</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.13889em;">P</span></span></span></span> の軌跡の曲率半径とは異なる ことに注意せよ.</li>
</ol>
<h3 id="_4-18-紐の張力" tabindex="-1">4.18: 紐の張力 <a class="header-anchor" href="#_4-18-紐の張力" aria-label="Permalink to &quot;4.18: 紐の張力&quot;">&ZeroWidthSpace;</a></h3>
<ol start="18">
<li>紐の張力：重さのある吊り紐では, 張力の水平成分は 一定で垂直成分は下にある紐の重さにより変わる. 滑 らかな面の上の紐による（単位長さあたりの）力は，そ の曲率半径と張力で決まり, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>N</mi><mo>=</mo><mi>T</mi><mi mathvariant="normal">/</mi><mi>R</mi></mrow><annotation encoding="application/x-tex">N=T / R</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.10903em;">N</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.13889em;">T</span><span class="mord">/</span><span class="mord mathnormal" style="margin-right:0.00773em;">R</span></span></span></span>. 似た場合と して, 表面張力による圧力は <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>p</mi><mo>=</mo><mn>2</mn><mi>σ</mi><mi mathvariant="normal">/</mi><mi>R</mi></mrow><annotation encoding="application/x-tex">p=2 \sigma / R</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">p</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">2</span><span class="mord mathnormal" style="margin-right:0.03588em;">σ</span><span class="mord">/</span><span class="mord mathnormal" style="margin-right:0.00773em;">R</span></span></span></span>. 導出には直 径に沿った圧力を調ベる.</li>
</ol>
<h3 id="_4-19-液体の表面" tabindex="-1">4.19: 液体の表面 <a class="header-anchor" href="#_4-19-液体の表面" aria-label="Permalink to &quot;4.19: 液体の表面&quot;">&ZeroWidthSpace;</a></h3>
<ol start="19">
<li>液体の表面は（表面張力を無視すれば）等ポテンシャ ル面になる. 非圧縮性流体では, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>w</mi></mrow><annotation encoding="application/x-tex">w</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal" style="margin-right:0.02691em;">w</span></span></span></span> をポテンシャルエ ネルギーの体積密度として, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>p</mi><mo>=</mo><msub><mi>P</mi><mn>0</mn></msub><mo>−</mo><mi>w</mi></mrow><annotation encoding="application/x-tex">p=P_0-w</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">p</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.13889em;">P</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.1389em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">0</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal" style="margin-right:0.02691em;">w</span></span></span></span>.</li>
</ol>
<h3 id="_4-20-非圧縮性流体に対する-bernoulli-の法則" tabindex="-1">4.20: 非圧縮性流体に対する Bernoulli の法則 <a class="header-anchor" href="#_4-20-非圧縮性流体に対する-bernoulli-の法則" aria-label="Permalink to &quot;4.20: 非圧縮性流体に対する Bernoulli の法則&quot;">&ZeroWidthSpace;</a></h3>
<ol start="20">
<li>非圧縮性流体に対する Bernoulli の法則：<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mi>p</mi><mo>+</mo><mfrac><mn>1</mn><mn>2</mn></mfrac><mi>ρ</mi><msup><mi>v</mi><mn>2</mn></msup><mo>+</mo><mi>ρ</mi><mi>ϕ</mi><mo>=</mo><mtext> const. </mtext></mrow><annotation encoding="application/x-tex">p+\frac{1}{2} \rho v^2+\rho \phi=\text { const. }
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7778em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">p</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:2.0074em;vertical-align:-0.686em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.3214em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">2</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mord mathnormal">ρ</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">ρϕ</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6151em;"></span><span class="mord text"><span class="mord"> const. </span></span></span></span></span></span></p>
一様な重力場では <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ϕ</mi><mo>=</mo><mi>g</mi><mi>h</mi></mrow><annotation encoding="application/x-tex">\phi=g h</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">ϕ</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">g</span><span class="mord mathnormal">h</span></span></span></span>. 比熱が <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>c</mi><mi>p</mi></msub><mo stretchy="false">[</mo><mrow><mtext> </mtext><mi mathvariant="normal">J</mi></mrow><mi mathvariant="normal">/</mi><mrow><mi mathvariant="normal">k</mi><mi mathvariant="normal">g</mi></mrow><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">c_p[\mathrm{~J} / \mathrm{kg}]</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0361em;vertical-align:-0.2861em;"></span><span class="mord"><span class="mord mathnormal">c</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">p</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span><span class="mopen">[</span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">J</span></span><span class="mord">/</span><span class="mord"><span class="mord mathrm" style="margin-right:0.01389em;">kg</span></span><span class="mclose">]</span></span></span></span> である気 体では,<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mfrac><mn>1</mn><mn>2</mn></mfrac><msup><mi>v</mi><mn>2</mn></msup><mo>+</mo><msub><mi>c</mi><mi>p</mi></msub><mi>T</mi><mo>=</mo><mtext> const. </mtext></mrow><annotation encoding="application/x-tex">\frac{1}{2} v^2+c_p T=\text { const. }
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.0074em;vertical-align:-0.686em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.3214em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">2</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.9694em;vertical-align:-0.2861em;"></span><span class="mord"><span class="mord mathnormal">c</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">p</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span><span class="mord mathnormal" style="margin-right:0.13889em;">T</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6151em;"></span><span class="mord text"><span class="mord"> const. </span></span></span></span></span></span></p>
</li>
</ol>
<h3 id="_4-21-直線的な流線" tabindex="-1">4.21: 直線的な流線 <Badge type="tip" text="supplemental" /> <a class="header-anchor" href="#_4-21-直線的な流線" aria-label="Permalink to &quot;4.21: 直線的な流線 &lt;Badge type=&quot;tip&quot; text=&quot;supplemental&quot; /&gt;&quot;">&ZeroWidthSpace;</a></h3>
<ol start="21">
<li>直線的な流線に沾う運動量の連続性 : <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>p</mi><mo>+</mo><mi>ρ</mi><msup><mi>v</mi><mn>2</mn></msup><mo>=</mo></mrow><annotation encoding="application/x-tex">p+\rho v^2=</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7778em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">p</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1.0085em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">ρ</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span></span></span></span> const.</li>
</ol>
<h3 id="_4-22-断熱不変量" tabindex="-1">4.22: 断熱不変量 <Badge type="tip" text="supplemental" /> <a class="header-anchor" href="#_4-22-断熱不変量" aria-label="Permalink to &quot;4.22: 断熱不変量 &lt;Badge type=&quot;tip&quot; text=&quot;supplemental&quot; /&gt;&quot;">&ZeroWidthSpace;</a></h3>
<ol start="22">
<li>断熱不変量 : 振動する系の 1 周期の間のパラメータの 相対的な変化が小さければ，位相空間（ <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>x</mi><mo>−</mo><mi>p</mi></mrow><annotation encoding="application/x-tex">x-p</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mord mathnormal">x</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">p</span></span></span></span> 座標で表さ れる）上に書かれるループの面積は非常に高い精度で 保存される.</li>
</ol>
<h3 id="_4-23-安定性" tabindex="-1">4.23: 安定性 <a class="header-anchor" href="#_4-23-安定性" aria-label="Permalink to &quot;4.23: 安定性&quot;">&ZeroWidthSpace;</a></h3>
<ol start="23">
<li>安定性を調ベるには, a) ポテンシャルエネルギー最小 の原理，又は b) 仮想仕事の原理を用いる.</li>
</ol>
<h3 id="_4-24-空間的に有限な運動に対する-virial-定理" tabindex="-1">4.24: 空間的に有限な運動に対する Virial 定理 <Badge type="tip" text="supplemental" /> <a class="header-anchor" href="#_4-24-空間的に有限な運動に対する-virial-定理" aria-label="Permalink to &quot;4.24: 空間的に有限な運動に対する Virial 定理 &lt;Badge type=&quot;tip&quot; text=&quot;supplemental&quot; /&gt;&quot;">&ZeroWidthSpace;</a></h3>
<ol start="24">
<li>空間的に有限な運動に対する Virial 定理：a) もし <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>F</mi><mo>∝</mo><mi mathvariant="normal">∣</mi><mi mathvariant="bold-italic">r</mi><mi mathvariant="normal">∣</mi></mrow><annotation encoding="application/x-tex">F \propto|\boldsymbol{r}|</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.13889em;">F</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">∝</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">∣</span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03194em;">r</span></span></span><span class="mord">∣</span></span></span></span> ならば <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">⟨</mo><mi>K</mi><mo stretchy="false">⟩</mo><mo>=</mo><mo stretchy="false">⟨</mo><mi>U</mi><mo stretchy="false">⟩</mo></mrow><annotation encoding="application/x-tex">\langle K\rangle=\langle U\rangle</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">⟨</span><span class="mord mathnormal" style="margin-right:0.07153em;">K</span><span class="mclose">⟩</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">⟨</span><span class="mord mathnormal" style="margin-right:0.10903em;">U</span><span class="mclose">⟩</span></span></span></span> (時間平均). b) もし <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>F</mi><mo>∝</mo><mi mathvariant="normal">∣</mi><mi mathvariant="bold-italic">r</mi><msup><mi mathvariant="normal">∣</mi><mrow><mo>−</mo><mn>2</mn></mrow></msup></mrow><annotation encoding="application/x-tex">F \propto|\boldsymbol{r}|^{-2}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.13889em;">F</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">∝</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.0641em;vertical-align:-0.25em;"></span><span class="mord">∣</span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03194em;">r</span></span></span><span class="mord"><span class="mord">∣</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">−</span><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span></span></span> ならば <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>2</mn><mo stretchy="false">⟨</mo><mi>K</mi><mo stretchy="false">⟩</mo><mo>=</mo><mo>−</mo><mo stretchy="false">⟨</mo><mi>U</mi><mo stretchy="false">⟩</mo></mrow><annotation encoding="application/x-tex">2\langle K\rangle=-\langle U\rangle</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">2</span><span class="mopen">⟨</span><span class="mord mathnormal" style="margin-right:0.07153em;">K</span><span class="mclose">⟩</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">−</span><span class="mopen">⟨</span><span class="mord mathnormal" style="margin-right:0.10903em;">U</span><span class="mclose">⟩</span></span></span></span>.</li>
</ol>
<h3 id="_4-25-tsiolkovsky-公式" tabindex="-1">4.25: Tsiolkovsky 公式 <a class="header-anchor" href="#_4-25-tsiolkovsky-公式" aria-label="Permalink to &quot;4.25: Tsiolkovsky 公式&quot;">&ZeroWidthSpace;</a></h3>
<ol start="25">
<li>Tsiolkovsky の公式（ロケット）: <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Δ</mi><mi>v</mi><mo>=</mo><mi>u</mi><mi>ln</mi><mo>⁡</mo><mfrac><mi>M</mi><mi>m</mi></mfrac></mrow><annotation encoding="application/x-tex">\Delta v=u \ln \frac{M}{m}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">Δ</span><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.2173em;vertical-align:-0.345em;"></span><span class="mord mathnormal">u</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">ln</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8723em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">m</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.10903em;">M</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span></li>
</ol>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Formulas for IPhO 日本語版: Section 5 ]]></title>
            <link>https://note.toshiki.devacademic/physics/ipho-formulas-jpn/5</link>
            <guid>https://note.toshiki.devacademic/physics/ipho-formulas-jpn/5</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="formulas-for-ipho-日本語版-section-5" tabindex="-1">Formulas for IPhO 日本語版: Section 5 <a class="header-anchor" href="#formulas-for-ipho-日本語版-section-5" aria-label="Permalink to &quot;Formulas for IPhO 日本語版: Section 5&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="_5-振動と波" tabindex="-1">5. 振動と波 <a class="header-anchor" href="#_5-振動と波" aria-label="Permalink to &quot;5. 振動と波&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="_5-1-減衰振動" tabindex="-1">5.1: 減衰振動 <a class="header-anchor" href="#_5-1-減衰振動" aria-label="Permalink to &quot;5.1: 減衰振動&quot;">&ZeroWidthSpace;</a></h3>
<ol>
<li>減衰振動：<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mover accent="true"><mi>x</mi><mo>¨</mo></mover><mo>+</mo><mn>2</mn><mi>γ</mi><mover accent="true"><mi>x</mi><mo>˙</mo></mover><mo>+</mo><msubsup><mi>ω</mi><mn>0</mn><mn>2</mn></msubsup><mi>x</mi><mo>=</mo><mn>0</mn><mo stretchy="false">(</mo><mi>γ</mi><mo>&lt;</mo><mi>ω</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">\ddot{x}+2 \gamma \dot{x}+\omega_0^2 x=0(\gamma&lt;\omega)
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7512em;vertical-align:-0.0833em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6679em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord mathnormal">x</span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.2222em;"><span class="mord">¨</span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.8623em;vertical-align:-0.1944em;"></span><span class="mord">2</span><span class="mord mathnormal" style="margin-right:0.05556em;">γ</span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6679em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord mathnormal">x</span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.1111em;"><span class="mord">˙</span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1.1111em;vertical-align:-0.247em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">ω</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-2.453em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">0</span></span></span><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.247em;"><span></span></span></span></span></span></span><span class="mord mathnormal">x</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">0</span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.05556em;">γ</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">&lt;</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">ω</span><span class="mclose">)</span></span></span></span></span></p>
この方程式の解は ((Section 1: #3)[1#_1-3-定数係数線形微分方程式] 参照) :<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mi>x</mi><mo>=</mo><msub><mi>x</mi><mn>0</mn></msub><msup><mi>e</mi><mrow><mo>−</mo><mi>γ</mi><mi>t</mi></mrow></msup><mi>sin</mi><mo>⁡</mo><mrow><mo fence="true">(</mo><mi>t</mi><msqrt><mrow><msubsup><mi>ω</mi><mn>0</mn><mn>2</mn></msubsup><mo>−</mo><msup><mi>γ</mi><mn>2</mn></msup></mrow></msqrt><mo>−</mo><msub><mi>φ</mi><mn>0</mn></msub><mo fence="true">)</mo></mrow></mrow><annotation encoding="application/x-tex">x=x_0 e^{-\gamma t} \sin \left(t \sqrt{\omega_0^2-\gamma^2}-\varphi_0\right)
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">x</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:2.4em;vertical-align:-0.95em;"></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">0</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathnormal">e</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8436em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">−</span><span class="mord mathnormal mtight" style="margin-right:0.05556em;">γ</span><span class="mord mathnormal mtight">t</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">sin</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size3">(</span></span><span class="mord mathnormal">t</span><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.2987em;"><span class="svg-align" style="top:-3.8em;"><span class="pstrut" style="height:3.8em;"></span><span class="mord" style="padding-left:1em;"><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">ω</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.7959em;"><span style="top:-2.4337em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">0</span></span></span><span style="top:-3.0448em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2663em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.05556em;">γ</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7401em;"><span style="top:-2.989em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span><span style="top:-3.2587em;"><span class="pstrut" style="height:3.8em;"></span><span class="hide-tail" style="min-width:1.02em;height:1.88em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='1.88em' viewBox='0 0 400000 1944' preserveAspectRatio='xMinYMin slice'><path d='M983 90
l0 -0
c4,-6.7,10,-10,18,-10 H400000v40
H1013.1s-83.4,268,-264.1,840c-180.7,572,-277,876.3,-289,913c-4.7,4.7,-12.7,7,-24,7
s-12,0,-12,0c-1.3,-3.3,-3.7,-11.7,-7,-25c-35.3,-125.3,-106.7,-373.3,-214,-744
c-10,12,-21,25,-33,39s-32,39,-32,39c-6,-5.3,-15,-14,-27,-26s25,-30,25,-30
c26.7,-32.7,52,-63,76,-91s52,-60,52,-60s208,722,208,722
c56,-175.3,126.3,-397.3,211,-666c84.7,-268.7,153.8,-488.2,207.5,-658.5
c53.7,-170.3,84.5,-266.8,92.5,-289.5z
M1001 80h400000v40h-400000z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.5413em;"><span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal">φ</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">0</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size3">)</span></span></span></span></span></span></span></p>
</li>
</ol>
<h3 id="_5-2-連成振動の式" tabindex="-1">5.2: 連成振動の式 <a class="header-anchor" href="#_5-2-連成振動の式" aria-label="Permalink to &quot;5.2: 連成振動の式&quot;">&ZeroWidthSpace;</a></h3>
<ol start="2">
<li>連成振動の式 : <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mover accent="true"><mi>x</mi><mo>¨</mo></mover><mi>i</mi></msub><mo>=</mo><msub><mo>∑</mo><mi>j</mi></msub><msub><mi>a</mi><mrow><mi>i</mi><mi>j</mi></mrow></msub><msub><mi>x</mi><mi>j</mi></msub></mrow><annotation encoding="application/x-tex">\ddot{x}_i=\sum_j a_{i j} x_j</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8179em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6679em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord mathnormal">x</span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.2222em;"><span class="mord">¨</span></span></span></span></span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.1858em;vertical-align:-0.4358em;"></span><span class="mop"><span class="mop op-symbol small-op" style="position:relative;top:0em;">∑</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.162em;"><span style="top:-2.4003em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.05724em;">j</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.4358em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.05724em;">ij</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.05724em;">j</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span></span></span></span></li>
</ol>
<h3 id="_5-3-連成振動の系" tabindex="-1">5.3: 連成振動の系 <a class="header-anchor" href="#_5-3-連成振動の系" aria-label="Permalink to &quot;5.3: 連成振動の系&quot;">&ZeroWidthSpace;</a></h3>
<ol start="3">
<li>
<p><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>N</mi></mrow><annotation encoding="application/x-tex">N</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.10903em;">N</span></span></span></span> 個の連成振動の系は, すべての振動子が同じ振動数 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>ω</mi><mi>i</mi></msub></mrow><annotation encoding="application/x-tex">\omega_i</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">ω</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> で <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>x</mi><mi>j</mi></msub><mo>=</mo><msub><mi>x</mi><mrow><mi>j</mi><mn>0</mn></mrow></msub><mi>sin</mi><mo>⁡</mo><mrow><mo fence="true">(</mo><msub><mi>ω</mi><mi>i</mi></msub><mi>t</mi><mo>+</mo><msub><mi>φ</mi><mrow><mi>i</mi><mi>j</mi></mrow></msub><mo fence="true">)</mo></mrow></mrow><annotation encoding="application/x-tex">x_j=x_{j 0} \sin \left(\omega_i t+\varphi_{i j}\right)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7167em;vertical-align:-0.2861em;"></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.05724em;">j</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.0361em;vertical-align:-0.2861em;"></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.05724em;">j</span><span class="mord mtight">0</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">sin</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">ω</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord mathnormal">t</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal">φ</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.05724em;">ij</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">)</span></span></span></span></span> のように振動するとい う固有モードを <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>N</mi></mrow><annotation encoding="application/x-tex">N</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.10903em;">N</span></span></span></span> 個持つ. 固有振動数 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>ω</mi><mi>i</mi></msub><mtext>も</mtext><mi>N</mi></mrow><annotation encoding="application/x-tex">\omega_i も N</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">ω</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord cjk_fallback">も</span><span class="mord mathnormal" style="margin-right:0.10903em;">N</span></span></span></span> 個持 つ (一致するかもしれない, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>ω</mi><mi>i</mi></msub><mo>=</mo><msub><mi>ω</mi><mi>j</mi></msub></mrow><annotation encoding="application/x-tex">\omega_i=\omega_j</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">ω</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.7167em;vertical-align:-0.2861em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">ω</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.05724em;">j</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span></span></span></span> ). 一般解 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">(</mo><mn>2</mn><mi>N</mi></mrow><annotation encoding="application/x-tex">(2 N</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">(</span><span class="mord">2</span><span class="mord mathnormal" style="margin-right:0.10903em;">N</span></span></span></span> 個の積分定数 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>X</mi><mi>i</mi></msub><mo separator="true">,</mo><msub><mi>ϕ</mi><mi>i</mi></msub></mrow><annotation encoding="application/x-tex">X_i, \phi_i</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.07847em;">X</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:-0.0785em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal">ϕ</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> を持つ) は全ての固有振動の重ね 合わせ :</p>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><msub><mi>x</mi><mi>j</mi></msub><mo>=</mo><munder><mo>∑</mo><mi>i</mi></munder><msub><mi>X</mi><mi>i</mi></msub><msub><mi>x</mi><mrow><mi>j</mi><mn>0</mn></mrow></msub><mi>sin</mi><mo>⁡</mo><mrow><mo fence="true">(</mo><msub><mi>ω</mi><mi>i</mi></msub><mi>t</mi><mo>+</mo><msub><mi>φ</mi><mrow><mi>i</mi><mi>j</mi></mrow></msub><mo>+</mo><msub><mi>ϕ</mi><mi>i</mi></msub><mo fence="true">)</mo></mrow></mrow><annotation encoding="application/x-tex">x_j=\sum_i X_i x_{j 0} \sin \left(\omega_i t+\varphi_{i j}+\phi_i\right)
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7167em;vertical-align:-0.2861em;"></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.05724em;">j</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:2.3277em;vertical-align:-1.2777em;"></span><span class="mop op-limits"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.05em;"><span style="top:-1.8723em;margin-left:0em;"><span class="pstrut" style="height:3.05em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span><span style="top:-3.05em;"><span class="pstrut" style="height:3.05em;"></span><span><span class="mop op-symbol large-op">∑</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.2777em;"><span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.07847em;">X</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:-0.0785em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.05724em;">j</span><span class="mord mtight">0</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">sin</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">ω</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord mathnormal">t</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal">φ</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.05724em;">ij</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal">ϕ</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">)</span></span></span></span></span></span></p>
</li>
</ol>
<h3 id="_5-4-一般化座標" tabindex="-1">5.4: 一般化座標 <a class="header-anchor" href="#_5-4-一般化座標" aria-label="Permalink to &quot;5.4: 一般化座標&quot;">&ZeroWidthSpace;</a></h3>
<ol start="4">
<li>一般化座標 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ξ</mi></mrow><annotation encoding="application/x-tex">\xi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.04601em;">ξ</span></span></span></span> ((Section 4: #4)[4#_4-4-一般化座標] 参照) で表され <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>K</mi><mo>=</mo><mi>μ</mi><msup><mover accent="true"><mi>ξ</mi><mo>˙</mo></mover><mn>2</mn></msup><mi mathvariant="normal">/</mi><mn>2</mn></mrow><annotation encoding="application/x-tex">K=\mu \dot{\xi}^2 / 2</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.07153em;">K</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.1813em;vertical-align:-0.25em;"></span><span class="mord mathnormal">μ</span><span class="mord"><span class="mord accent"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.9313em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord mathnormal" style="margin-right:0.04601em;">ξ</span></span><span style="top:-3.2634em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.0278em;"><span class="mord">˙</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.1944em;"><span></span></span></span></span></span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mord">/2</span></span></span></span> である系は, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ξ</mi><mo>=</mo><mn>0</mn></mrow><annotation encoding="application/x-tex">\xi=0</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.04601em;">ξ</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">0</span></span></span></span> の点で平衡. 小さな振動につ いて <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>U</mi><mo stretchy="false">(</mo><mi>ξ</mi><mo stretchy="false">)</mo><mo>≈</mo><mi>κ</mi><msup><mi>ξ</mi><mn>2</mn></msup><mi mathvariant="normal">/</mi><mn>2</mn></mrow><annotation encoding="application/x-tex">U(\xi) \approx \kappa \xi^2 / 2</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.10903em;">U</span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.04601em;">ξ</span><span class="mclose">)</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≈</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.0641em;vertical-align:-0.25em;"></span><span class="mord mathnormal">κ</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.04601em;">ξ</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mord">/2</span></span></span></span> (ここで <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>κ</mi><mo>=</mo><msup><mi>U</mi><mrow><mo mathvariant="normal">′</mo><mo mathvariant="normal">′</mo></mrow></msup><mo stretchy="false">(</mo><mn>0</mn><mo stretchy="false">)</mo><mo fence="true">)</mo></mrow><annotation encoding="application/x-tex">\left.\kappa=U^{\prime \prime}(0)\right)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0019em;vertical-align:-0.25em;"></span><span class="minner"><span class="mopen nulldelimiter"></span><span class="mord mathnormal">κ</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.10903em;">U</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7519em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′′</span></span></span></span></span></span></span></span></span><span class="mopen">(</span><span class="mord">0</span><span class="mclose">)</span><span class="mclose delimcenter" style="top:0em;">)</span></span></span></span></span> であり <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msup><mi>ω</mi><mn>2</mn></msup><mo>=</mo><mi>κ</mi><mi mathvariant="normal">/</mi><mi>μ</mi></mrow><annotation encoding="application/x-tex">\omega^2=\kappa / \mu</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8141em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">ω</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal">κ</span><span class="mord">/</span><span class="mord mathnormal">μ</span></span></span></span>.</li>
</ol>
<h3 id="_5-5-波の位相" tabindex="-1">5.5: 波の位相 <a class="header-anchor" href="#_5-5-波の位相" aria-label="Permalink to &quot;5.5: 波の位相&quot;">&ZeroWidthSpace;</a></h3>
<ol start="5">
<li><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>x</mi><mo separator="true">,</mo><mi>t</mi></mrow><annotation encoding="application/x-tex">x, t</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8095em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">x</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">t</span></span></span></span> での波の位相は <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>φ</mi><mo>=</mo><mi>k</mi><mi>x</mi><mo>−</mo><mi>ω</mi><mi>t</mi><mo>+</mo><msub><mi>φ</mi><mn>0</mn></msub></mrow><annotation encoding="application/x-tex">\varphi=k x-\omega t+\varphi_0</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">φ</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.7778em;vertical-align:-0.0833em;"></span><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="mord mathnormal">x</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6984em;vertical-align:-0.0833em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">ω</span><span class="mord mathnormal">t</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord"><span class="mord mathnormal">φ</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">0</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> で, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>k</mi><mo>=</mo><mn>2</mn><mi>π</mi><mi mathvariant="normal">/</mi><mi>λ</mi></mrow><annotation encoding="application/x-tex">k=2 \pi / \lambda</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">2</span><span class="mord mathnormal" style="margin-right:0.03588em;">π</span><span class="mord">/</span><span class="mord mathnormal">λ</span></span></span></span> は波数. <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>x</mi><mo separator="true">,</mo><mi>t</mi></mrow><annotation encoding="application/x-tex">x, t</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8095em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">x</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">t</span></span></span></span> での值は <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>a</mi><mn>0</mn></msub><mi>cos</mi><mo>⁡</mo><mi>φ</mi><mo>=</mo><mi mathvariant="normal">Re</mi><mo>⁡</mo><msub><mi>a</mi><mn>0</mn></msub><msup><mi>e</mi><mrow><mi>i</mi><mi>φ</mi></mrow></msup></mrow><annotation encoding="application/x-tex">a_0 \cos \varphi=\operatorname{Re} a_0 e^{i \varphi}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">0</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">cos</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">φ</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.9747em;vertical-align:-0.15em;"></span><span class="mop"><span class="mord mathrm">Re</span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">0</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathnormal">e</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8247em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">i</span><span class="mord mathnormal mtight">φ</span></span></span></span></span></span></span></span></span></span></span></span>. 位相速 度は <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>v</mi><mi>f</mi></msub><mo>=</mo><mi>ν</mi><mi>λ</mi><mo>=</mo><mi>ω</mi><mi mathvariant="normal">/</mi><mi>k</mi></mrow><annotation encoding="application/x-tex">v_f=\nu \lambda=\omega / k</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7167em;vertical-align:-0.2861em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3361em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.10764em;">f</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal" style="margin-right:0.06366em;">ν</span><span class="mord mathnormal">λ</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">ω</span><span class="mord">/</span><span class="mord mathnormal" style="margin-right:0.03148em;">k</span></span></span></span> で， 群速度は <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>v</mi><mi>g</mi></msub><mo>=</mo><mi mathvariant="normal">d</mi><mi>ω</mi><mi mathvariant="normal">/</mi><mi mathvariant="normal">d</mi><mi>k</mi></mrow><annotation encoding="application/x-tex">v_g=\mathrm{d} \omega / \mathrm{d} k</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7167em;vertical-align:-0.2861em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.03588em;">g</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathrm">d</span><span class="mord mathnormal" style="margin-right:0.03588em;">ω</span><span class="mord">/</span><span class="mord mathrm">d</span><span class="mord mathnormal" style="margin-right:0.03148em;">k</span></span></span></span>.</li>
</ol>
<h3 id="_5-6-線形波" tabindex="-1">5.6: 線形波 <a class="header-anchor" href="#_5-6-線形波" aria-label="Permalink to &quot;5.6: 線形波&quot;">&ZeroWidthSpace;</a></h3>
<ol start="6">
<li>
<p>線形波（電磁波, 小振幅の音波や水面波）の場合, どん なパルス波も正弦波の重ね合わせとして表せる. 定常 波は 2 つの逆向きに進む同じ波の合成 :</p>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><msup><mi>e</mi><mrow><mi>i</mi><mo stretchy="false">(</mo><mi>k</mi><mi>x</mi><mo>−</mo><mi>ω</mi><mi>t</mi><mo stretchy="false">)</mo></mrow></msup><mo>+</mo><msup><mi>e</mi><mrow><mi>i</mi><mo stretchy="false">(</mo><mo>−</mo><mi>k</mi><mi>x</mi><mo>−</mo><mi>ω</mi><mi>t</mi><mo stretchy="false">)</mo></mrow></msup><mo>=</mo><mn>2</mn><msup><mi>e</mi><mrow><mo>−</mo><mi>i</mi><mi>ω</mi><mi>t</mi></mrow></msup><mi>cos</mi><mo>⁡</mo><mi>k</mi><mi>t</mi></mrow><annotation encoding="application/x-tex">e^{i(k x-\omega t)}+e^{i(-k x-\omega t)}=2 e^{-i \omega t} \cos k t
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0213em;vertical-align:-0.0833em;"></span><span class="mord"><span class="mord mathnormal">e</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.938em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">i</span><span class="mopen mtight">(</span><span class="mord mathnormal mtight" style="margin-right:0.03148em;">k</span><span class="mord mathnormal mtight">x</span><span class="mbin mtight">−</span><span class="mord mathnormal mtight" style="margin-right:0.03588em;">ω</span><span class="mord mathnormal mtight">t</span><span class="mclose mtight">)</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.938em;"></span><span class="mord"><span class="mord mathnormal">e</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.938em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">i</span><span class="mopen mtight">(</span><span class="mord mtight">−</span><span class="mord mathnormal mtight" style="margin-right:0.03148em;">k</span><span class="mord mathnormal mtight">x</span><span class="mbin mtight">−</span><span class="mord mathnormal mtight" style="margin-right:0.03588em;">ω</span><span class="mord mathnormal mtight">t</span><span class="mclose mtight">)</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8747em;"></span><span class="mord">2</span><span class="mord"><span class="mord mathnormal">e</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8747em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">−</span><span class="mord mathnormal mtight" style="margin-right:0.03588em;">iω</span><span class="mord mathnormal mtight">t</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">cos</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="mord mathnormal">t</span></span></span></span></span></p>
</li>
</ol>
<h3 id="_5-7-気体中の音速" tabindex="-1">5.7: 気体中の音速 <a class="header-anchor" href="#_5-7-気体中の音速" aria-label="Permalink to &quot;5.7: 気体中の音速&quot;">&ZeroWidthSpace;</a></h3>
<ol start="7">
<li>
<p>気体中の音速 :</p>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><msub><mi>c</mi><mi>s</mi></msub><mo>=</mo><msqrt><mrow><mo stretchy="false">(</mo><mi mathvariant="normal">∂</mi><mi>p</mi><mi mathvariant="normal">/</mi><mi mathvariant="normal">∂</mi><mi>ρ</mi><msub><mo stretchy="false">)</mo><mtext>断熱 </mtext></msub></mrow></msqrt><mo>=</mo><msqrt><mrow><mi>γ</mi><mi>p</mi><mi mathvariant="normal">/</mi><mi>ρ</mi></mrow></msqrt><mo>=</mo><msqrt><mrow><mi>γ</mi><mover accent="true"><msup><mi>v</mi><mn>2</mn></msup><mo stretchy="true">‾</mo></mover><mi mathvariant="normal">/</mi><mn>3</mn></mrow></msqrt></mrow><annotation encoding="application/x-tex">c_s=\sqrt{(\partial p / \partial \rho)_{\text {断熱 }}}=\sqrt{\gamma p / \rho}=\sqrt{\gamma \overline{v^2} / 3}
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal">c</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">s</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.24em;vertical-align:-0.2561em;"></span><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.9839em;"><span class="svg-align" style="top:-3.2em;"><span class="pstrut" style="height:3.2em;"></span><span class="mord" style="padding-left:1em;"><span class="mopen">(</span><span class="mord" style="margin-right:0.05556em;">∂</span><span class="mord mathnormal">p</span><span class="mord">/</span><span class="mord" style="margin-right:0.05556em;">∂</span><span class="mord mathnormal">ρ</span><span class="mclose"><span class="mclose">)</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord text mtight"><span class="mord cjk_fallback mtight">断熱</span><span class="mord mtight"> </span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span><span style="top:-2.9439em;"><span class="pstrut" style="height:3.2em;"></span><span class="hide-tail" style="min-width:1.02em;height:1.28em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='1.28em' viewBox='0 0 400000 1296' preserveAspectRatio='xMinYMin slice'><path d='M263,681c0.7,0,18,39.7,52,119
c34,79.3,68.167,158.7,102.5,238c34.3,79.3,51.8,119.3,52.5,120
c340,-704.7,510.7,-1060.3,512,-1067
l0 -0
c4.7,-7.3,11,-11,19,-11
H40000v40H1012.3
s-271.3,567,-271.3,567c-38.7,80.7,-84,175,-136,283c-52,108,-89.167,185.3,-111.5,232
c-22.3,46.7,-33.8,70.3,-34.5,71c-4.7,4.7,-12.3,7,-23,7s-12,-1,-12,-1
s-109,-253,-109,-253c-72.7,-168,-109.3,-252,-110,-252c-10.7,8,-22,16.7,-34,26
c-22,17.3,-33.3,26,-34,26s-26,-26,-26,-26s76,-59,76,-59s76,-60,76,-60z
M1001 80h400000v40h-400000z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2561em;"><span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.24em;vertical-align:-0.2561em;"></span><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.9839em;"><span class="svg-align" style="top:-3.2em;"><span class="pstrut" style="height:3.2em;"></span><span class="mord" style="padding-left:1em;"><span class="mord mathnormal" style="margin-right:0.05556em;">γ</span><span class="mord mathnormal">p</span><span class="mord">/</span><span class="mord mathnormal">ρ</span></span></span><span style="top:-2.9439em;"><span class="pstrut" style="height:3.2em;"></span><span class="hide-tail" style="min-width:1.02em;height:1.28em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='1.28em' viewBox='0 0 400000 1296' preserveAspectRatio='xMinYMin slice'><path d='M263,681c0.7,0,18,39.7,52,119
c34,79.3,68.167,158.7,102.5,238c34.3,79.3,51.8,119.3,52.5,120
c340,-704.7,510.7,-1060.3,512,-1067
l0 -0
c4.7,-7.3,11,-11,19,-11
H40000v40H1012.3
s-271.3,567,-271.3,567c-38.7,80.7,-84,175,-136,283c-52,108,-89.167,185.3,-111.5,232
c-22.3,46.7,-33.8,70.3,-34.5,71c-4.7,4.7,-12.3,7,-23,7s-12,-1,-12,-1
s-109,-253,-109,-253c-72.7,-168,-109.3,-252,-110,-252c-10.7,8,-22,16.7,-34,26
c-22,17.3,-33.3,26,-34,26s-26,-26,-26,-26s76,-59,76,-59s76,-60,76,-60z
M1001 80h400000v40h-400000z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2561em;"><span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.84em;vertical-align:-0.4611em;"></span><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.3789em;"><span class="svg-align" style="top:-3.8em;"><span class="pstrut" style="height:3.8em;"></span><span class="mord" style="padding-left:1em;"><span class="mord mathnormal" style="margin-right:0.05556em;">γ</span><span class="mord overline"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.9401em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7401em;"><span style="top:-2.989em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span><span style="top:-3.8601em;"><span class="pstrut" style="height:3em;"></span><span class="overline-line" style="border-bottom-width:0.04em;"></span></span></span></span></span></span><span class="mord">/3</span></span></span><span style="top:-3.3389em;"><span class="pstrut" style="height:3.8em;"></span><span class="hide-tail" style="min-width:1.02em;height:1.88em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='1.88em' viewBox='0 0 400000 1944' preserveAspectRatio='xMinYMin slice'><path d='M983 90
l0 -0
c4,-6.7,10,-10,18,-10 H400000v40
H1013.1s-83.4,268,-264.1,840c-180.7,572,-277,876.3,-289,913c-4.7,4.7,-12.7,7,-24,7
s-12,0,-12,0c-1.3,-3.3,-3.7,-11.7,-7,-25c-35.3,-125.3,-106.7,-373.3,-214,-744
c-10,12,-21,25,-33,39s-32,39,-32,39c-6,-5.3,-15,-14,-27,-26s25,-30,25,-30
c26.7,-32.7,52,-63,76,-91s52,-60,52,-60s208,722,208,722
c56,-175.3,126.3,-397.3,211,-666c84.7,-268.7,153.8,-488.2,207.5,-658.5
c53.7,-170.3,84.5,-266.8,92.5,-289.5z
M1001 80h400000v40h-400000z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.4611em;"><span></span></span></span></span></span></span></span></span></span></p>
</li>
</ol>
<h3 id="_5-8-弾性体中の音速" tabindex="-1">5.8: 弾性体中の音速 <a class="header-anchor" href="#_5-8-弾性体中の音速" aria-label="Permalink to &quot;5.8: 弾性体中の音速&quot;">&ZeroWidthSpace;</a></h3>
<ol start="8">
<li>弾性体中の音速は <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>c</mi><mi>s</mi></msub><mo>=</mo><msqrt><mrow><mi>E</mi><mi mathvariant="normal">/</mi><mi>ρ</mi></mrow></msqrt></mrow><annotation encoding="application/x-tex">c_s=\sqrt{E / \rho}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal">c</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">s</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.24em;vertical-align:-0.305em;"></span><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.935em;"><span class="svg-align" style="top:-3.2em;"><span class="pstrut" style="height:3.2em;"></span><span class="mord" style="padding-left:1em;"><span class="mord mathnormal" style="margin-right:0.05764em;">E</span><span class="mord">/</span><span class="mord mathnormal">ρ</span></span></span><span style="top:-2.895em;"><span class="pstrut" style="height:3.2em;"></span><span class="hide-tail" style="min-width:1.02em;height:1.28em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='1.28em' viewBox='0 0 400000 1296' preserveAspectRatio='xMinYMin slice'><path d='M263,681c0.7,0,18,39.7,52,119
c34,79.3,68.167,158.7,102.5,238c34.3,79.3,51.8,119.3,52.5,120
c340,-704.7,510.7,-1060.3,512,-1067
l0 -0
c4.7,-7.3,11,-11,19,-11
H40000v40H1012.3
s-271.3,567,-271.3,567c-38.7,80.7,-84,175,-136,283c-52,108,-89.167,185.3,-111.5,232
c-22.3,46.7,-33.8,70.3,-34.5,71c-4.7,4.7,-12.3,7,-23,7s-12,-1,-12,-1
s-109,-253,-109,-253c-72.7,-168,-109.3,-252,-110,-252c-10.7,8,-22,16.7,-34,26
c-22,17.3,-33.3,26,-34,26s-26,-26,-26,-26s76,-59,76,-59s76,-60,76,-60z
M1001 80h400000v40h-400000z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.305em;"><span></span></span></span></span></span></span></span></span>.</li>
</ol>
<h3 id="_5-9-浅水波" tabindex="-1">5.9: 浅水波 <a class="header-anchor" href="#_5-9-浅水波" aria-label="Permalink to &quot;5.9: 浅水波&quot;">&ZeroWidthSpace;</a></h3>
<ol start="9">
<li>浅水波 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">(</mo><mi>h</mi><mo>≪</mo><mi>λ</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">(h \ll \lambda)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">(</span><span class="mord mathnormal">h</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≪</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal">λ</span><span class="mclose">)</span></span></span></span> の速さ: <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>v</mi><mo>=</mo><msqrt><mrow><mi>g</mi><mi>h</mi></mrow></msqrt></mrow><annotation encoding="application/x-tex">v=\sqrt{g h}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.04em;vertical-align:-0.205em;"></span><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.835em;"><span class="svg-align" style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord" style="padding-left:0.833em;"><span class="mord mathnormal" style="margin-right:0.03588em;">g</span><span class="mord mathnormal">h</span></span></span><span style="top:-2.795em;"><span class="pstrut" style="height:3em;"></span><span class="hide-tail" style="min-width:0.853em;height:1.08em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='1.08em' viewBox='0 0 400000 1080' preserveAspectRatio='xMinYMin slice'><path d='M95,702
c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14
c0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54
c44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10
s173,378,173,378c0.7,0,35.3,-71,104,-213c68.7,-142,137.5,-285,206.5,-429
c69,-144,104.5,-217.7,106.5,-221
l0 -0
c5.3,-9.3,12,-14,20,-14
H400000v40H845.2724
s-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7
c-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z
M834 80h400000v40h-400000z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.205em;"><span></span></span></span></span></span></span></span></span>. 弦の場合： <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>v</mi><mo>=</mo><msqrt><mrow><mi>T</mi><mi mathvariant="normal">/</mi><msub><mi>ρ</mi><mrow><mi>l</mi><mi>i</mi><mi>n</mi></mrow></msub></mrow></msqrt></mrow><annotation encoding="application/x-tex">v=\sqrt{T / \rho_{l i n}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.24em;vertical-align:-0.305em;"></span><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.935em;"><span class="svg-align" style="top:-3.2em;"><span class="pstrut" style="height:3.2em;"></span><span class="mord" style="padding-left:1em;"><span class="mord mathnormal" style="margin-right:0.13889em;">T</span><span class="mord">/</span><span class="mord"><span class="mord mathnormal">ρ</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3361em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.01968em;">l</span><span class="mord mathnormal mtight">in</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span><span style="top:-2.895em;"><span class="pstrut" style="height:3.2em;"></span><span class="hide-tail" style="min-width:1.02em;height:1.28em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='1.28em' viewBox='0 0 400000 1296' preserveAspectRatio='xMinYMin slice'><path d='M263,681c0.7,0,18,39.7,52,119
c34,79.3,68.167,158.7,102.5,238c34.3,79.3,51.8,119.3,52.5,120
c340,-704.7,510.7,-1060.3,512,-1067
l0 -0
c4.7,-7.3,11,-11,19,-11
H40000v40H1012.3
s-271.3,567,-271.3,567c-38.7,80.7,-84,175,-136,283c-52,108,-89.167,185.3,-111.5,232
c-22.3,46.7,-33.8,70.3,-34.5,71c-4.7,4.7,-12.3,7,-23,7s-12,-1,-12,-1
s-109,-253,-109,-253c-72.7,-168,-109.3,-252,-110,-252c-10.7,8,-22,16.7,-34,26
c-22,17.3,-33.3,26,-34,26s-26,-26,-26,-26s76,-59,76,-59s76,-60,76,-60z
M1001 80h400000v40h-400000z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.305em;"><span></span></span></span></span></span></span></span></span>.</li>
</ol>
<h3 id="_5-10-doppler-効果" tabindex="-1">5.10: Doppler 効果 <a class="header-anchor" href="#_5-10-doppler-効果" aria-label="Permalink to &quot;5.10: Doppler 効果&quot;">&ZeroWidthSpace;</a></h3>
<ol start="10">
<li>Doppler 効果 : <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ν</mi><mo>=</mo><msub><mi>ν</mi><mn>0</mn></msub><mfrac><mrow><mn>1</mn><mo>+</mo><msub><mi>v</mi><mi mathvariant="normal">∥</mi></msub><mi mathvariant="normal">/</mi><msub><mi>c</mi><mi>s</mi></msub></mrow><mrow><mn>1</mn><mo>−</mo><msub><mi>u</mi><mi mathvariant="normal">∥</mi></msub><mi mathvariant="normal">/</mi><msub><mi>c</mi><mi>s</mi></msub></mrow></mfrac></mrow><annotation encoding="application/x-tex">\nu=\nu_0 \frac{1+v_{\|} / c_s}{1-u_{\|} / c_s}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal" style="margin-right:0.06366em;">ν</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.6973em;vertical-align:-0.6036em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.06366em;">ν</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0637em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">0</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.0936em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">1</span><span class="mbin mtight">−</span><span class="mord mtight"><span class="mord mathnormal mtight">u</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3448em;"><span style="top:-2.3448em;margin-left:0em;margin-right:0.0714em;"><span class="pstrut" style="height:2.5357em;"></span><span class="sizing reset-size3 size1 mtight"><span class="mord mtight"><span class="mord mtight">∥</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.3695em;"><span></span></span></span></span></span></span><span class="mord mtight">/</span><span class="mord mtight"><span class="mord mathnormal mtight">c</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1645em;"><span style="top:-2.357em;margin-left:0em;margin-right:0.0714em;"><span class="pstrut" style="height:2.5em;"></span><span class="sizing reset-size3 size1 mtight"><span class="mord mathnormal mtight">s</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.143em;"><span></span></span></span></span></span></span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.5686em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">1</span><span class="mbin mtight">+</span><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3448em;"><span style="top:-2.3448em;margin-left:-0.0359em;margin-right:0.0714em;"><span class="pstrut" style="height:2.5357em;"></span><span class="sizing reset-size3 size1 mtight"><span class="mord mtight"><span class="mord mtight">∥</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.3695em;"><span></span></span></span></span></span></span><span class="mord mtight">/</span><span class="mord mtight"><span class="mord mathnormal mtight">c</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1645em;"><span style="top:-2.357em;margin-left:0em;margin-right:0.0714em;"><span class="pstrut" style="height:2.5em;"></span><span class="sizing reset-size3 size1 mtight"><span class="mord mathnormal mtight">s</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.143em;"><span></span></span></span></span></span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.6036em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span>.</li>
</ol>
<h3 id="_5-11-huygens-の原理" tabindex="-1">5.11: Huygens の原理 <a class="header-anchor" href="#_5-11-huygens-の原理" aria-label="Permalink to &quot;5.11: Huygens の原理&quot;">&ZeroWidthSpace;</a></h3>
<ol start="11">
<li>Huygens の原理 : 波面は段階的に構成される. 過去 の波面のすべての点に仮想的な波源を置く. 結果は距 離 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Δ</mi><mi>x</mi><mo>=</mo><msub><mi>c</mi><mi>s</mi></msub><mi mathvariant="normal">Δ</mi><mi>t</mi></mrow><annotation encoding="application/x-tex">\Delta x=c_s \Delta t</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">Δ</span><span class="mord mathnormal">x</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal">c</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">s</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord">Δ</span><span class="mord mathnormal">t</span></span></span></span> で区切られた曲線（ここで <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Δ</mi><mi>t</mi></mrow><annotation encoding="application/x-tex">\Delta t</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">Δ</span><span class="mord mathnormal">t</span></span></span></span> は時間 間隔， <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>c</mi><mi>s</mi></msub></mrow><annotation encoding="application/x-tex">c_s</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal">c</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">s</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> は与えられた点の速度). 波は波面に垂直に 進む.</li>
</ol>
]]></description>
            <content:encoded><![CDATA[<h1 id="formulas-for-ipho-日本語版-section-5" tabindex="-1">Formulas for IPhO 日本語版: Section 5 <a class="header-anchor" href="#formulas-for-ipho-日本語版-section-5" aria-label="Permalink to &quot;Formulas for IPhO 日本語版: Section 5&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="_5-振動と波" tabindex="-1">5. 振動と波 <a class="header-anchor" href="#_5-振動と波" aria-label="Permalink to &quot;5. 振動と波&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="_5-1-減衰振動" tabindex="-1">5.1: 減衰振動 <a class="header-anchor" href="#_5-1-減衰振動" aria-label="Permalink to &quot;5.1: 減衰振動&quot;">&ZeroWidthSpace;</a></h3>
<ol>
<li>減衰振動：<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mover accent="true"><mi>x</mi><mo>¨</mo></mover><mo>+</mo><mn>2</mn><mi>γ</mi><mover accent="true"><mi>x</mi><mo>˙</mo></mover><mo>+</mo><msubsup><mi>ω</mi><mn>0</mn><mn>2</mn></msubsup><mi>x</mi><mo>=</mo><mn>0</mn><mo stretchy="false">(</mo><mi>γ</mi><mo>&lt;</mo><mi>ω</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">\ddot{x}+2 \gamma \dot{x}+\omega_0^2 x=0(\gamma&lt;\omega)
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7512em;vertical-align:-0.0833em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6679em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord mathnormal">x</span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.2222em;"><span class="mord">¨</span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.8623em;vertical-align:-0.1944em;"></span><span class="mord">2</span><span class="mord mathnormal" style="margin-right:0.05556em;">γ</span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6679em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord mathnormal">x</span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.1111em;"><span class="mord">˙</span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1.1111em;vertical-align:-0.247em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">ω</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-2.453em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">0</span></span></span><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.247em;"><span></span></span></span></span></span></span><span class="mord mathnormal">x</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">0</span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.05556em;">γ</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">&lt;</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">ω</span><span class="mclose">)</span></span></span></span></span></p>
この方程式の解は ((Section 1: #3)[1#_1-3-定数係数線形微分方程式] 参照) :<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mi>x</mi><mo>=</mo><msub><mi>x</mi><mn>0</mn></msub><msup><mi>e</mi><mrow><mo>−</mo><mi>γ</mi><mi>t</mi></mrow></msup><mi>sin</mi><mo>⁡</mo><mrow><mo fence="true">(</mo><mi>t</mi><msqrt><mrow><msubsup><mi>ω</mi><mn>0</mn><mn>2</mn></msubsup><mo>−</mo><msup><mi>γ</mi><mn>2</mn></msup></mrow></msqrt><mo>−</mo><msub><mi>φ</mi><mn>0</mn></msub><mo fence="true">)</mo></mrow></mrow><annotation encoding="application/x-tex">x=x_0 e^{-\gamma t} \sin \left(t \sqrt{\omega_0^2-\gamma^2}-\varphi_0\right)
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">x</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:2.4em;vertical-align:-0.95em;"></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">0</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathnormal">e</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8436em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">−</span><span class="mord mathnormal mtight" style="margin-right:0.05556em;">γ</span><span class="mord mathnormal mtight">t</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">sin</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size3">(</span></span><span class="mord mathnormal">t</span><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.2987em;"><span class="svg-align" style="top:-3.8em;"><span class="pstrut" style="height:3.8em;"></span><span class="mord" style="padding-left:1em;"><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">ω</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.7959em;"><span style="top:-2.4337em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">0</span></span></span><span style="top:-3.0448em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2663em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.05556em;">γ</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7401em;"><span style="top:-2.989em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span><span style="top:-3.2587em;"><span class="pstrut" style="height:3.8em;"></span><span class="hide-tail" style="min-width:1.02em;height:1.88em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='1.88em' viewBox='0 0 400000 1944' preserveAspectRatio='xMinYMin slice'><path d='M983 90
l0 -0
c4,-6.7,10,-10,18,-10 H400000v40
H1013.1s-83.4,268,-264.1,840c-180.7,572,-277,876.3,-289,913c-4.7,4.7,-12.7,7,-24,7
s-12,0,-12,0c-1.3,-3.3,-3.7,-11.7,-7,-25c-35.3,-125.3,-106.7,-373.3,-214,-744
c-10,12,-21,25,-33,39s-32,39,-32,39c-6,-5.3,-15,-14,-27,-26s25,-30,25,-30
c26.7,-32.7,52,-63,76,-91s52,-60,52,-60s208,722,208,722
c56,-175.3,126.3,-397.3,211,-666c84.7,-268.7,153.8,-488.2,207.5,-658.5
c53.7,-170.3,84.5,-266.8,92.5,-289.5z
M1001 80h400000v40h-400000z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.5413em;"><span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal">φ</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">0</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size3">)</span></span></span></span></span></span></span></p>
</li>
</ol>
<h3 id="_5-2-連成振動の式" tabindex="-1">5.2: 連成振動の式 <a class="header-anchor" href="#_5-2-連成振動の式" aria-label="Permalink to &quot;5.2: 連成振動の式&quot;">&ZeroWidthSpace;</a></h3>
<ol start="2">
<li>連成振動の式 : <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mover accent="true"><mi>x</mi><mo>¨</mo></mover><mi>i</mi></msub><mo>=</mo><msub><mo>∑</mo><mi>j</mi></msub><msub><mi>a</mi><mrow><mi>i</mi><mi>j</mi></mrow></msub><msub><mi>x</mi><mi>j</mi></msub></mrow><annotation encoding="application/x-tex">\ddot{x}_i=\sum_j a_{i j} x_j</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8179em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6679em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord mathnormal">x</span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.2222em;"><span class="mord">¨</span></span></span></span></span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.1858em;vertical-align:-0.4358em;"></span><span class="mop"><span class="mop op-symbol small-op" style="position:relative;top:0em;">∑</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.162em;"><span style="top:-2.4003em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.05724em;">j</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.4358em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.05724em;">ij</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.05724em;">j</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span></span></span></span></li>
</ol>
<h3 id="_5-3-連成振動の系" tabindex="-1">5.3: 連成振動の系 <a class="header-anchor" href="#_5-3-連成振動の系" aria-label="Permalink to &quot;5.3: 連成振動の系&quot;">&ZeroWidthSpace;</a></h3>
<ol start="3">
<li>
<p><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>N</mi></mrow><annotation encoding="application/x-tex">N</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.10903em;">N</span></span></span></span> 個の連成振動の系は, すべての振動子が同じ振動数 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>ω</mi><mi>i</mi></msub></mrow><annotation encoding="application/x-tex">\omega_i</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">ω</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> で <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>x</mi><mi>j</mi></msub><mo>=</mo><msub><mi>x</mi><mrow><mi>j</mi><mn>0</mn></mrow></msub><mi>sin</mi><mo>⁡</mo><mrow><mo fence="true">(</mo><msub><mi>ω</mi><mi>i</mi></msub><mi>t</mi><mo>+</mo><msub><mi>φ</mi><mrow><mi>i</mi><mi>j</mi></mrow></msub><mo fence="true">)</mo></mrow></mrow><annotation encoding="application/x-tex">x_j=x_{j 0} \sin \left(\omega_i t+\varphi_{i j}\right)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7167em;vertical-align:-0.2861em;"></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.05724em;">j</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.0361em;vertical-align:-0.2861em;"></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.05724em;">j</span><span class="mord mtight">0</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">sin</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">ω</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord mathnormal">t</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal">φ</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.05724em;">ij</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">)</span></span></span></span></span> のように振動するとい う固有モードを <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>N</mi></mrow><annotation encoding="application/x-tex">N</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.10903em;">N</span></span></span></span> 個持つ. 固有振動数 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>ω</mi><mi>i</mi></msub><mtext>も</mtext><mi>N</mi></mrow><annotation encoding="application/x-tex">\omega_i も N</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">ω</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord cjk_fallback">も</span><span class="mord mathnormal" style="margin-right:0.10903em;">N</span></span></span></span> 個持 つ (一致するかもしれない, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>ω</mi><mi>i</mi></msub><mo>=</mo><msub><mi>ω</mi><mi>j</mi></msub></mrow><annotation encoding="application/x-tex">\omega_i=\omega_j</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">ω</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.7167em;vertical-align:-0.2861em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">ω</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.05724em;">j</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span></span></span></span> ). 一般解 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">(</mo><mn>2</mn><mi>N</mi></mrow><annotation encoding="application/x-tex">(2 N</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">(</span><span class="mord">2</span><span class="mord mathnormal" style="margin-right:0.10903em;">N</span></span></span></span> 個の積分定数 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>X</mi><mi>i</mi></msub><mo separator="true">,</mo><msub><mi>ϕ</mi><mi>i</mi></msub></mrow><annotation encoding="application/x-tex">X_i, \phi_i</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.07847em;">X</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:-0.0785em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal">ϕ</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> を持つ) は全ての固有振動の重ね 合わせ :</p>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><msub><mi>x</mi><mi>j</mi></msub><mo>=</mo><munder><mo>∑</mo><mi>i</mi></munder><msub><mi>X</mi><mi>i</mi></msub><msub><mi>x</mi><mrow><mi>j</mi><mn>0</mn></mrow></msub><mi>sin</mi><mo>⁡</mo><mrow><mo fence="true">(</mo><msub><mi>ω</mi><mi>i</mi></msub><mi>t</mi><mo>+</mo><msub><mi>φ</mi><mrow><mi>i</mi><mi>j</mi></mrow></msub><mo>+</mo><msub><mi>ϕ</mi><mi>i</mi></msub><mo fence="true">)</mo></mrow></mrow><annotation encoding="application/x-tex">x_j=\sum_i X_i x_{j 0} \sin \left(\omega_i t+\varphi_{i j}+\phi_i\right)
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7167em;vertical-align:-0.2861em;"></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.05724em;">j</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:2.3277em;vertical-align:-1.2777em;"></span><span class="mop op-limits"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.05em;"><span style="top:-1.8723em;margin-left:0em;"><span class="pstrut" style="height:3.05em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span><span style="top:-3.05em;"><span class="pstrut" style="height:3.05em;"></span><span><span class="mop op-symbol large-op">∑</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.2777em;"><span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.07847em;">X</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:-0.0785em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.05724em;">j</span><span class="mord mtight">0</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">sin</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">ω</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord mathnormal">t</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal">φ</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.05724em;">ij</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal">ϕ</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">)</span></span></span></span></span></span></p>
</li>
</ol>
<h3 id="_5-4-一般化座標" tabindex="-1">5.4: 一般化座標 <a class="header-anchor" href="#_5-4-一般化座標" aria-label="Permalink to &quot;5.4: 一般化座標&quot;">&ZeroWidthSpace;</a></h3>
<ol start="4">
<li>一般化座標 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ξ</mi></mrow><annotation encoding="application/x-tex">\xi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.04601em;">ξ</span></span></span></span> ((Section 4: #4)[4#_4-4-一般化座標] 参照) で表され <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>K</mi><mo>=</mo><mi>μ</mi><msup><mover accent="true"><mi>ξ</mi><mo>˙</mo></mover><mn>2</mn></msup><mi mathvariant="normal">/</mi><mn>2</mn></mrow><annotation encoding="application/x-tex">K=\mu \dot{\xi}^2 / 2</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.07153em;">K</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.1813em;vertical-align:-0.25em;"></span><span class="mord mathnormal">μ</span><span class="mord"><span class="mord accent"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.9313em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord mathnormal" style="margin-right:0.04601em;">ξ</span></span><span style="top:-3.2634em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.0278em;"><span class="mord">˙</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.1944em;"><span></span></span></span></span></span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mord">/2</span></span></span></span> である系は, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ξ</mi><mo>=</mo><mn>0</mn></mrow><annotation encoding="application/x-tex">\xi=0</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.04601em;">ξ</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">0</span></span></span></span> の点で平衡. 小さな振動につ いて <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>U</mi><mo stretchy="false">(</mo><mi>ξ</mi><mo stretchy="false">)</mo><mo>≈</mo><mi>κ</mi><msup><mi>ξ</mi><mn>2</mn></msup><mi mathvariant="normal">/</mi><mn>2</mn></mrow><annotation encoding="application/x-tex">U(\xi) \approx \kappa \xi^2 / 2</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.10903em;">U</span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.04601em;">ξ</span><span class="mclose">)</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≈</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.0641em;vertical-align:-0.25em;"></span><span class="mord mathnormal">κ</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.04601em;">ξ</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mord">/2</span></span></span></span> (ここで <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>κ</mi><mo>=</mo><msup><mi>U</mi><mrow><mo mathvariant="normal">′</mo><mo mathvariant="normal">′</mo></mrow></msup><mo stretchy="false">(</mo><mn>0</mn><mo stretchy="false">)</mo><mo fence="true">)</mo></mrow><annotation encoding="application/x-tex">\left.\kappa=U^{\prime \prime}(0)\right)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0019em;vertical-align:-0.25em;"></span><span class="minner"><span class="mopen nulldelimiter"></span><span class="mord mathnormal">κ</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.10903em;">U</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7519em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′′</span></span></span></span></span></span></span></span></span><span class="mopen">(</span><span class="mord">0</span><span class="mclose">)</span><span class="mclose delimcenter" style="top:0em;">)</span></span></span></span></span> であり <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msup><mi>ω</mi><mn>2</mn></msup><mo>=</mo><mi>κ</mi><mi mathvariant="normal">/</mi><mi>μ</mi></mrow><annotation encoding="application/x-tex">\omega^2=\kappa / \mu</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8141em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">ω</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal">κ</span><span class="mord">/</span><span class="mord mathnormal">μ</span></span></span></span>.</li>
</ol>
<h3 id="_5-5-波の位相" tabindex="-1">5.5: 波の位相 <a class="header-anchor" href="#_5-5-波の位相" aria-label="Permalink to &quot;5.5: 波の位相&quot;">&ZeroWidthSpace;</a></h3>
<ol start="5">
<li><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>x</mi><mo separator="true">,</mo><mi>t</mi></mrow><annotation encoding="application/x-tex">x, t</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8095em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">x</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">t</span></span></span></span> での波の位相は <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>φ</mi><mo>=</mo><mi>k</mi><mi>x</mi><mo>−</mo><mi>ω</mi><mi>t</mi><mo>+</mo><msub><mi>φ</mi><mn>0</mn></msub></mrow><annotation encoding="application/x-tex">\varphi=k x-\omega t+\varphi_0</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">φ</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.7778em;vertical-align:-0.0833em;"></span><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="mord mathnormal">x</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6984em;vertical-align:-0.0833em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">ω</span><span class="mord mathnormal">t</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord"><span class="mord mathnormal">φ</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">0</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> で, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>k</mi><mo>=</mo><mn>2</mn><mi>π</mi><mi mathvariant="normal">/</mi><mi>λ</mi></mrow><annotation encoding="application/x-tex">k=2 \pi / \lambda</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">2</span><span class="mord mathnormal" style="margin-right:0.03588em;">π</span><span class="mord">/</span><span class="mord mathnormal">λ</span></span></span></span> は波数. <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>x</mi><mo separator="true">,</mo><mi>t</mi></mrow><annotation encoding="application/x-tex">x, t</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8095em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">x</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">t</span></span></span></span> での值は <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>a</mi><mn>0</mn></msub><mi>cos</mi><mo>⁡</mo><mi>φ</mi><mo>=</mo><mi mathvariant="normal">Re</mi><mo>⁡</mo><msub><mi>a</mi><mn>0</mn></msub><msup><mi>e</mi><mrow><mi>i</mi><mi>φ</mi></mrow></msup></mrow><annotation encoding="application/x-tex">a_0 \cos \varphi=\operatorname{Re} a_0 e^{i \varphi}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">0</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">cos</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">φ</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.9747em;vertical-align:-0.15em;"></span><span class="mop"><span class="mord mathrm">Re</span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">0</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathnormal">e</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8247em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">i</span><span class="mord mathnormal mtight">φ</span></span></span></span></span></span></span></span></span></span></span></span>. 位相速 度は <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>v</mi><mi>f</mi></msub><mo>=</mo><mi>ν</mi><mi>λ</mi><mo>=</mo><mi>ω</mi><mi mathvariant="normal">/</mi><mi>k</mi></mrow><annotation encoding="application/x-tex">v_f=\nu \lambda=\omega / k</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7167em;vertical-align:-0.2861em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3361em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.10764em;">f</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal" style="margin-right:0.06366em;">ν</span><span class="mord mathnormal">λ</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">ω</span><span class="mord">/</span><span class="mord mathnormal" style="margin-right:0.03148em;">k</span></span></span></span> で， 群速度は <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>v</mi><mi>g</mi></msub><mo>=</mo><mi mathvariant="normal">d</mi><mi>ω</mi><mi mathvariant="normal">/</mi><mi mathvariant="normal">d</mi><mi>k</mi></mrow><annotation encoding="application/x-tex">v_g=\mathrm{d} \omega / \mathrm{d} k</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7167em;vertical-align:-0.2861em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.03588em;">g</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathrm">d</span><span class="mord mathnormal" style="margin-right:0.03588em;">ω</span><span class="mord">/</span><span class="mord mathrm">d</span><span class="mord mathnormal" style="margin-right:0.03148em;">k</span></span></span></span>.</li>
</ol>
<h3 id="_5-6-線形波" tabindex="-1">5.6: 線形波 <a class="header-anchor" href="#_5-6-線形波" aria-label="Permalink to &quot;5.6: 線形波&quot;">&ZeroWidthSpace;</a></h3>
<ol start="6">
<li>
<p>線形波（電磁波, 小振幅の音波や水面波）の場合, どん なパルス波も正弦波の重ね合わせとして表せる. 定常 波は 2 つの逆向きに進む同じ波の合成 :</p>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><msup><mi>e</mi><mrow><mi>i</mi><mo stretchy="false">(</mo><mi>k</mi><mi>x</mi><mo>−</mo><mi>ω</mi><mi>t</mi><mo stretchy="false">)</mo></mrow></msup><mo>+</mo><msup><mi>e</mi><mrow><mi>i</mi><mo stretchy="false">(</mo><mo>−</mo><mi>k</mi><mi>x</mi><mo>−</mo><mi>ω</mi><mi>t</mi><mo stretchy="false">)</mo></mrow></msup><mo>=</mo><mn>2</mn><msup><mi>e</mi><mrow><mo>−</mo><mi>i</mi><mi>ω</mi><mi>t</mi></mrow></msup><mi>cos</mi><mo>⁡</mo><mi>k</mi><mi>t</mi></mrow><annotation encoding="application/x-tex">e^{i(k x-\omega t)}+e^{i(-k x-\omega t)}=2 e^{-i \omega t} \cos k t
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0213em;vertical-align:-0.0833em;"></span><span class="mord"><span class="mord mathnormal">e</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.938em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">i</span><span class="mopen mtight">(</span><span class="mord mathnormal mtight" style="margin-right:0.03148em;">k</span><span class="mord mathnormal mtight">x</span><span class="mbin mtight">−</span><span class="mord mathnormal mtight" style="margin-right:0.03588em;">ω</span><span class="mord mathnormal mtight">t</span><span class="mclose mtight">)</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.938em;"></span><span class="mord"><span class="mord mathnormal">e</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.938em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">i</span><span class="mopen mtight">(</span><span class="mord mtight">−</span><span class="mord mathnormal mtight" style="margin-right:0.03148em;">k</span><span class="mord mathnormal mtight">x</span><span class="mbin mtight">−</span><span class="mord mathnormal mtight" style="margin-right:0.03588em;">ω</span><span class="mord mathnormal mtight">t</span><span class="mclose mtight">)</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8747em;"></span><span class="mord">2</span><span class="mord"><span class="mord mathnormal">e</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8747em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">−</span><span class="mord mathnormal mtight" style="margin-right:0.03588em;">iω</span><span class="mord mathnormal mtight">t</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">cos</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="mord mathnormal">t</span></span></span></span></span></p>
</li>
</ol>
<h3 id="_5-7-気体中の音速" tabindex="-1">5.7: 気体中の音速 <a class="header-anchor" href="#_5-7-気体中の音速" aria-label="Permalink to &quot;5.7: 気体中の音速&quot;">&ZeroWidthSpace;</a></h3>
<ol start="7">
<li>
<p>気体中の音速 :</p>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><msub><mi>c</mi><mi>s</mi></msub><mo>=</mo><msqrt><mrow><mo stretchy="false">(</mo><mi mathvariant="normal">∂</mi><mi>p</mi><mi mathvariant="normal">/</mi><mi mathvariant="normal">∂</mi><mi>ρ</mi><msub><mo stretchy="false">)</mo><mtext>断熱 </mtext></msub></mrow></msqrt><mo>=</mo><msqrt><mrow><mi>γ</mi><mi>p</mi><mi mathvariant="normal">/</mi><mi>ρ</mi></mrow></msqrt><mo>=</mo><msqrt><mrow><mi>γ</mi><mover accent="true"><msup><mi>v</mi><mn>2</mn></msup><mo stretchy="true">‾</mo></mover><mi mathvariant="normal">/</mi><mn>3</mn></mrow></msqrt></mrow><annotation encoding="application/x-tex">c_s=\sqrt{(\partial p / \partial \rho)_{\text {断熱 }}}=\sqrt{\gamma p / \rho}=\sqrt{\gamma \overline{v^2} / 3}
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal">c</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">s</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.24em;vertical-align:-0.2561em;"></span><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.9839em;"><span class="svg-align" style="top:-3.2em;"><span class="pstrut" style="height:3.2em;"></span><span class="mord" style="padding-left:1em;"><span class="mopen">(</span><span class="mord" style="margin-right:0.05556em;">∂</span><span class="mord mathnormal">p</span><span class="mord">/</span><span class="mord" style="margin-right:0.05556em;">∂</span><span class="mord mathnormal">ρ</span><span class="mclose"><span class="mclose">)</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord text mtight"><span class="mord cjk_fallback mtight">断熱</span><span class="mord mtight"> </span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span><span style="top:-2.9439em;"><span class="pstrut" style="height:3.2em;"></span><span class="hide-tail" style="min-width:1.02em;height:1.28em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='1.28em' viewBox='0 0 400000 1296' preserveAspectRatio='xMinYMin slice'><path d='M263,681c0.7,0,18,39.7,52,119
c34,79.3,68.167,158.7,102.5,238c34.3,79.3,51.8,119.3,52.5,120
c340,-704.7,510.7,-1060.3,512,-1067
l0 -0
c4.7,-7.3,11,-11,19,-11
H40000v40H1012.3
s-271.3,567,-271.3,567c-38.7,80.7,-84,175,-136,283c-52,108,-89.167,185.3,-111.5,232
c-22.3,46.7,-33.8,70.3,-34.5,71c-4.7,4.7,-12.3,7,-23,7s-12,-1,-12,-1
s-109,-253,-109,-253c-72.7,-168,-109.3,-252,-110,-252c-10.7,8,-22,16.7,-34,26
c-22,17.3,-33.3,26,-34,26s-26,-26,-26,-26s76,-59,76,-59s76,-60,76,-60z
M1001 80h400000v40h-400000z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2561em;"><span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.24em;vertical-align:-0.2561em;"></span><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.9839em;"><span class="svg-align" style="top:-3.2em;"><span class="pstrut" style="height:3.2em;"></span><span class="mord" style="padding-left:1em;"><span class="mord mathnormal" style="margin-right:0.05556em;">γ</span><span class="mord mathnormal">p</span><span class="mord">/</span><span class="mord mathnormal">ρ</span></span></span><span style="top:-2.9439em;"><span class="pstrut" style="height:3.2em;"></span><span class="hide-tail" style="min-width:1.02em;height:1.28em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='1.28em' viewBox='0 0 400000 1296' preserveAspectRatio='xMinYMin slice'><path d='M263,681c0.7,0,18,39.7,52,119
c34,79.3,68.167,158.7,102.5,238c34.3,79.3,51.8,119.3,52.5,120
c340,-704.7,510.7,-1060.3,512,-1067
l0 -0
c4.7,-7.3,11,-11,19,-11
H40000v40H1012.3
s-271.3,567,-271.3,567c-38.7,80.7,-84,175,-136,283c-52,108,-89.167,185.3,-111.5,232
c-22.3,46.7,-33.8,70.3,-34.5,71c-4.7,4.7,-12.3,7,-23,7s-12,-1,-12,-1
s-109,-253,-109,-253c-72.7,-168,-109.3,-252,-110,-252c-10.7,8,-22,16.7,-34,26
c-22,17.3,-33.3,26,-34,26s-26,-26,-26,-26s76,-59,76,-59s76,-60,76,-60z
M1001 80h400000v40h-400000z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2561em;"><span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.84em;vertical-align:-0.4611em;"></span><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.3789em;"><span class="svg-align" style="top:-3.8em;"><span class="pstrut" style="height:3.8em;"></span><span class="mord" style="padding-left:1em;"><span class="mord mathnormal" style="margin-right:0.05556em;">γ</span><span class="mord overline"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.9401em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7401em;"><span style="top:-2.989em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span><span style="top:-3.8601em;"><span class="pstrut" style="height:3em;"></span><span class="overline-line" style="border-bottom-width:0.04em;"></span></span></span></span></span></span><span class="mord">/3</span></span></span><span style="top:-3.3389em;"><span class="pstrut" style="height:3.8em;"></span><span class="hide-tail" style="min-width:1.02em;height:1.88em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='1.88em' viewBox='0 0 400000 1944' preserveAspectRatio='xMinYMin slice'><path d='M983 90
l0 -0
c4,-6.7,10,-10,18,-10 H400000v40
H1013.1s-83.4,268,-264.1,840c-180.7,572,-277,876.3,-289,913c-4.7,4.7,-12.7,7,-24,7
s-12,0,-12,0c-1.3,-3.3,-3.7,-11.7,-7,-25c-35.3,-125.3,-106.7,-373.3,-214,-744
c-10,12,-21,25,-33,39s-32,39,-32,39c-6,-5.3,-15,-14,-27,-26s25,-30,25,-30
c26.7,-32.7,52,-63,76,-91s52,-60,52,-60s208,722,208,722
c56,-175.3,126.3,-397.3,211,-666c84.7,-268.7,153.8,-488.2,207.5,-658.5
c53.7,-170.3,84.5,-266.8,92.5,-289.5z
M1001 80h400000v40h-400000z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.4611em;"><span></span></span></span></span></span></span></span></span></span></p>
</li>
</ol>
<h3 id="_5-8-弾性体中の音速" tabindex="-1">5.8: 弾性体中の音速 <a class="header-anchor" href="#_5-8-弾性体中の音速" aria-label="Permalink to &quot;5.8: 弾性体中の音速&quot;">&ZeroWidthSpace;</a></h3>
<ol start="8">
<li>弾性体中の音速は <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>c</mi><mi>s</mi></msub><mo>=</mo><msqrt><mrow><mi>E</mi><mi mathvariant="normal">/</mi><mi>ρ</mi></mrow></msqrt></mrow><annotation encoding="application/x-tex">c_s=\sqrt{E / \rho}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal">c</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">s</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.24em;vertical-align:-0.305em;"></span><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.935em;"><span class="svg-align" style="top:-3.2em;"><span class="pstrut" style="height:3.2em;"></span><span class="mord" style="padding-left:1em;"><span class="mord mathnormal" style="margin-right:0.05764em;">E</span><span class="mord">/</span><span class="mord mathnormal">ρ</span></span></span><span style="top:-2.895em;"><span class="pstrut" style="height:3.2em;"></span><span class="hide-tail" style="min-width:1.02em;height:1.28em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='1.28em' viewBox='0 0 400000 1296' preserveAspectRatio='xMinYMin slice'><path d='M263,681c0.7,0,18,39.7,52,119
c34,79.3,68.167,158.7,102.5,238c34.3,79.3,51.8,119.3,52.5,120
c340,-704.7,510.7,-1060.3,512,-1067
l0 -0
c4.7,-7.3,11,-11,19,-11
H40000v40H1012.3
s-271.3,567,-271.3,567c-38.7,80.7,-84,175,-136,283c-52,108,-89.167,185.3,-111.5,232
c-22.3,46.7,-33.8,70.3,-34.5,71c-4.7,4.7,-12.3,7,-23,7s-12,-1,-12,-1
s-109,-253,-109,-253c-72.7,-168,-109.3,-252,-110,-252c-10.7,8,-22,16.7,-34,26
c-22,17.3,-33.3,26,-34,26s-26,-26,-26,-26s76,-59,76,-59s76,-60,76,-60z
M1001 80h400000v40h-400000z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.305em;"><span></span></span></span></span></span></span></span></span>.</li>
</ol>
<h3 id="_5-9-浅水波" tabindex="-1">5.9: 浅水波 <a class="header-anchor" href="#_5-9-浅水波" aria-label="Permalink to &quot;5.9: 浅水波&quot;">&ZeroWidthSpace;</a></h3>
<ol start="9">
<li>浅水波 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">(</mo><mi>h</mi><mo>≪</mo><mi>λ</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">(h \ll \lambda)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">(</span><span class="mord mathnormal">h</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≪</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal">λ</span><span class="mclose">)</span></span></span></span> の速さ: <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>v</mi><mo>=</mo><msqrt><mrow><mi>g</mi><mi>h</mi></mrow></msqrt></mrow><annotation encoding="application/x-tex">v=\sqrt{g h}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.04em;vertical-align:-0.205em;"></span><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.835em;"><span class="svg-align" style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord" style="padding-left:0.833em;"><span class="mord mathnormal" style="margin-right:0.03588em;">g</span><span class="mord mathnormal">h</span></span></span><span style="top:-2.795em;"><span class="pstrut" style="height:3em;"></span><span class="hide-tail" style="min-width:0.853em;height:1.08em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='1.08em' viewBox='0 0 400000 1080' preserveAspectRatio='xMinYMin slice'><path d='M95,702
c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14
c0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54
c44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10
s173,378,173,378c0.7,0,35.3,-71,104,-213c68.7,-142,137.5,-285,206.5,-429
c69,-144,104.5,-217.7,106.5,-221
l0 -0
c5.3,-9.3,12,-14,20,-14
H400000v40H845.2724
s-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7
c-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z
M834 80h400000v40h-400000z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.205em;"><span></span></span></span></span></span></span></span></span>. 弦の場合： <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>v</mi><mo>=</mo><msqrt><mrow><mi>T</mi><mi mathvariant="normal">/</mi><msub><mi>ρ</mi><mrow><mi>l</mi><mi>i</mi><mi>n</mi></mrow></msub></mrow></msqrt></mrow><annotation encoding="application/x-tex">v=\sqrt{T / \rho_{l i n}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.24em;vertical-align:-0.305em;"></span><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.935em;"><span class="svg-align" style="top:-3.2em;"><span class="pstrut" style="height:3.2em;"></span><span class="mord" style="padding-left:1em;"><span class="mord mathnormal" style="margin-right:0.13889em;">T</span><span class="mord">/</span><span class="mord"><span class="mord mathnormal">ρ</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3361em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.01968em;">l</span><span class="mord mathnormal mtight">in</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span><span style="top:-2.895em;"><span class="pstrut" style="height:3.2em;"></span><span class="hide-tail" style="min-width:1.02em;height:1.28em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='1.28em' viewBox='0 0 400000 1296' preserveAspectRatio='xMinYMin slice'><path d='M263,681c0.7,0,18,39.7,52,119
c34,79.3,68.167,158.7,102.5,238c34.3,79.3,51.8,119.3,52.5,120
c340,-704.7,510.7,-1060.3,512,-1067
l0 -0
c4.7,-7.3,11,-11,19,-11
H40000v40H1012.3
s-271.3,567,-271.3,567c-38.7,80.7,-84,175,-136,283c-52,108,-89.167,185.3,-111.5,232
c-22.3,46.7,-33.8,70.3,-34.5,71c-4.7,4.7,-12.3,7,-23,7s-12,-1,-12,-1
s-109,-253,-109,-253c-72.7,-168,-109.3,-252,-110,-252c-10.7,8,-22,16.7,-34,26
c-22,17.3,-33.3,26,-34,26s-26,-26,-26,-26s76,-59,76,-59s76,-60,76,-60z
M1001 80h400000v40h-400000z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.305em;"><span></span></span></span></span></span></span></span></span>.</li>
</ol>
<h3 id="_5-10-doppler-効果" tabindex="-1">5.10: Doppler 効果 <a class="header-anchor" href="#_5-10-doppler-効果" aria-label="Permalink to &quot;5.10: Doppler 効果&quot;">&ZeroWidthSpace;</a></h3>
<ol start="10">
<li>Doppler 効果 : <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ν</mi><mo>=</mo><msub><mi>ν</mi><mn>0</mn></msub><mfrac><mrow><mn>1</mn><mo>+</mo><msub><mi>v</mi><mi mathvariant="normal">∥</mi></msub><mi mathvariant="normal">/</mi><msub><mi>c</mi><mi>s</mi></msub></mrow><mrow><mn>1</mn><mo>−</mo><msub><mi>u</mi><mi mathvariant="normal">∥</mi></msub><mi mathvariant="normal">/</mi><msub><mi>c</mi><mi>s</mi></msub></mrow></mfrac></mrow><annotation encoding="application/x-tex">\nu=\nu_0 \frac{1+v_{\|} / c_s}{1-u_{\|} / c_s}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal" style="margin-right:0.06366em;">ν</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.6973em;vertical-align:-0.6036em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.06366em;">ν</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0637em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">0</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.0936em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">1</span><span class="mbin mtight">−</span><span class="mord mtight"><span class="mord mathnormal mtight">u</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3448em;"><span style="top:-2.3448em;margin-left:0em;margin-right:0.0714em;"><span class="pstrut" style="height:2.5357em;"></span><span class="sizing reset-size3 size1 mtight"><span class="mord mtight"><span class="mord mtight">∥</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.3695em;"><span></span></span></span></span></span></span><span class="mord mtight">/</span><span class="mord mtight"><span class="mord mathnormal mtight">c</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1645em;"><span style="top:-2.357em;margin-left:0em;margin-right:0.0714em;"><span class="pstrut" style="height:2.5em;"></span><span class="sizing reset-size3 size1 mtight"><span class="mord mathnormal mtight">s</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.143em;"><span></span></span></span></span></span></span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.5686em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">1</span><span class="mbin mtight">+</span><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3448em;"><span style="top:-2.3448em;margin-left:-0.0359em;margin-right:0.0714em;"><span class="pstrut" style="height:2.5357em;"></span><span class="sizing reset-size3 size1 mtight"><span class="mord mtight"><span class="mord mtight">∥</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.3695em;"><span></span></span></span></span></span></span><span class="mord mtight">/</span><span class="mord mtight"><span class="mord mathnormal mtight">c</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1645em;"><span style="top:-2.357em;margin-left:0em;margin-right:0.0714em;"><span class="pstrut" style="height:2.5em;"></span><span class="sizing reset-size3 size1 mtight"><span class="mord mathnormal mtight">s</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.143em;"><span></span></span></span></span></span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.6036em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span>.</li>
</ol>
<h3 id="_5-11-huygens-の原理" tabindex="-1">5.11: Huygens の原理 <a class="header-anchor" href="#_5-11-huygens-の原理" aria-label="Permalink to &quot;5.11: Huygens の原理&quot;">&ZeroWidthSpace;</a></h3>
<ol start="11">
<li>Huygens の原理 : 波面は段階的に構成される. 過去 の波面のすべての点に仮想的な波源を置く. 結果は距 離 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Δ</mi><mi>x</mi><mo>=</mo><msub><mi>c</mi><mi>s</mi></msub><mi mathvariant="normal">Δ</mi><mi>t</mi></mrow><annotation encoding="application/x-tex">\Delta x=c_s \Delta t</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">Δ</span><span class="mord mathnormal">x</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal">c</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">s</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord">Δ</span><span class="mord mathnormal">t</span></span></span></span> で区切られた曲線（ここで <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Δ</mi><mi>t</mi></mrow><annotation encoding="application/x-tex">\Delta t</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">Δ</span><span class="mord mathnormal">t</span></span></span></span> は時間 間隔， <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>c</mi><mi>s</mi></msub></mrow><annotation encoding="application/x-tex">c_s</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal">c</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">s</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> は与えられた点の速度). 波は波面に垂直に 進む.</li>
</ol>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Formulas for IPhO 日本語版: Section 6 ]]></title>
            <link>https://note.toshiki.devacademic/physics/ipho-formulas-jpn/6</link>
            <guid>https://note.toshiki.devacademic/physics/ipho-formulas-jpn/6</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="formulas-for-ipho-日本語版-section-6" tabindex="-1">Formulas for IPhO 日本語版: Section 6 <a class="header-anchor" href="#formulas-for-ipho-日本語版-section-6" aria-label="Permalink to &quot;Formulas for IPhO 日本語版: Section 6&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="_6-幾何光学-測光" tabindex="-1">6: 幾何光学，測光 <a class="header-anchor" href="#_6-幾何光学-測光" aria-label="Permalink to &quot;6: 幾何光学，測光&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="_6-1-fermat-原理" tabindex="-1">6.1: Fermat 原理 <a class="header-anchor" href="#_6-1-fermat-原理" aria-label="Permalink to &quot;6.1: Fermat 原理&quot;">&ZeroWidthSpace;</a></h3>
<ol>
<li>Fermat の原理 : 点 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>A</mi></mrow><annotation encoding="application/x-tex">A</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal">A</span></span></span></span> から <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>B</mi></mrow><annotation encoding="application/x-tex">B</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span></span> への波の経路は波の移動 時間が最も短いもの.</li>
</ol>
<h3 id="_6-2-snell-法則" tabindex="-1">6.2: Snell 法則 <a class="header-anchor" href="#_6-2-snell-法則" aria-label="Permalink to &quot;6.2: Snell 法則&quot;">&ZeroWidthSpace;</a></h3>
<ol start="2">
<li>Snell の法則 :</li>
</ol>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mi>sin</mi><mo>⁡</mo><msub><mi>α</mi><mn>1</mn></msub><mi mathvariant="normal">/</mi><mi>sin</mi><mo>⁡</mo><msub><mi>α</mi><mn>2</mn></msub><mo>=</mo><msub><mi>n</mi><mn>2</mn></msub><mi mathvariant="normal">/</mi><msub><mi>n</mi><mn>1</mn></msub><mo>=</mo><msub><mi>v</mi><mn>1</mn></msub><mi mathvariant="normal">/</mi><msub><mi>v</mi><mn>2</mn></msub><mi mathvariant="normal">.</mi></mrow><annotation encoding="application/x-tex">\sin \alpha_1 / \sin \alpha_2=n_2 / n_1=v_1 / v_2 .
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mop">sin</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.0037em;">α</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0037em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord">/</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">sin</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.0037em;">α</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0037em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord mathnormal">n</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord">/</span><span class="mord"><span class="mord mathnormal">n</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord">/</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord">.</span></span></span></span></span></p>
<h3 id="_6-3-屈折率" tabindex="-1">6.3: 屈折率 <a class="header-anchor" href="#_6-3-屈折率" aria-label="Permalink to &quot;6.3: 屈折率&quot;">&ZeroWidthSpace;</a></h3>
<ol start="3">
<li>屈折率が連続的に変化するならば，媒質を屈折率が <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>n</mi></mrow><annotation encoding="application/x-tex">n</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">n</span></span></span></span> で一定のいくつかの仮想的な層に分けて Snell の 法則を適用する. 光線は屈折率一定の層に沿って進む こともでき,もし全反射の条件をわずかに満たせば, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msup><mi>n</mi><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup><mo>=</mo><mi>n</mi><mi mathvariant="normal">/</mi><mi>r</mi><mspace width="1em"/><mo stretchy="false">(</mo><mi>r</mi></mrow><annotation encoding="application/x-tex">n^{\prime}=n / r \quad(r</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7519em;"></span><span class="mord"><span class="mord mathnormal">n</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7519em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal">n</span><span class="mord">/</span><span class="mord mathnormal" style="margin-right:0.02778em;">r</span><span class="mspace" style="margin-right:1em;"></span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.02778em;">r</span></span></span></span> は曲率半径 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mclose">)</span></span></span></span></li>
</ol>
<h3 id="_6-4-屈折率な座標" tabindex="-1">6.4: 屈折率な座標 <a class="header-anchor" href="#_6-4-屈折率な座標" aria-label="Permalink to &quot;6.4: 屈折率な座標&quot;">&ZeroWidthSpace;</a></h3>
<ol start="4">
<li>屈折率が <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">z</mi></mrow><annotation encoding="application/x-tex">\mathrm{z}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathrm">z</span></span></span></span> 座標にのみ依存するならば, 光子の運動量 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>p</mi><mi>x</mi></msub><mo separator="true">,</mo><msub><mi>p</mi><mi>y</mi></msub></mrow><annotation encoding="application/x-tex">p_x, p_y</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7167em;vertical-align:-0.2861em;"></span><span class="mord"><span class="mord mathnormal">p</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">x</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal">p</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.03588em;">y</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span></span></span></span> とエネルギーは保存される:</li>
</ol>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><msub><mi>k</mi><mi>x</mi></msub><mo separator="true">,</mo><msub><mi>k</mi><mi>y</mi></msub><mo>=</mo><mtext> const., </mtext><mi mathvariant="normal">∣</mi><mi mathvariant="bold-italic">k</mi><mi mathvariant="normal">∣</mi><mi mathvariant="normal">/</mi><mi>n</mi><mo>=</mo><mtext> const. </mtext></mrow><annotation encoding="application/x-tex">k_x, k_y=\text { const., }|\boldsymbol{k}| / n=\text { const. }
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9805em;vertical-align:-0.2861em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:-0.0315em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">x</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:-0.0315em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.03588em;">y</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord text"><span class="mord"> const., </span></span><span class="mord">∣</span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.01852em;">k</span></span></span><span class="mord">∣/</span><span class="mord mathnormal">n</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6151em;"></span><span class="mord text"><span class="mord"> const. </span></span></span></span></span></span></p>
<h3 id="_6-5-薄いレンズの式" tabindex="-1">6.5:薄いレンズの式 <a class="header-anchor" href="#_6-5-薄いレンズの式" aria-label="Permalink to &quot;6.5:薄いレンズの式&quot;">&ZeroWidthSpace;</a></h3>
<ol start="6">
<li>薄いレンズの式（符号に注意する）：</li>
</ol>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mn>1</mn><mi mathvariant="normal">/</mi><mi>a</mi><mo>+</mo><mn>1</mn><mi mathvariant="normal">/</mi><mi>b</mi><mo>=</mo><mn>1</mn><mi mathvariant="normal">/</mi><mi>f</mi><mo>≡</mo><mi>D</mi></mrow><annotation encoding="application/x-tex">1 / a+1 / b=1 / f \equiv D
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">1/</span><span class="mord mathnormal">a</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">1/</span><span class="mord mathnormal">b</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">1/</span><span class="mord mathnormal" style="margin-right:0.10764em;">f</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≡</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.02778em;">D</span></span></span></span></span></p>
<h3 id="_6-6-newton-の式" tabindex="-1">6.6: Newton の式 <a class="header-anchor" href="#_6-6-newton-の式" aria-label="Permalink to &quot;6.6: Newton の式&quot;">&ZeroWidthSpace;</a></h3>
<ol start="6">
<li>Newton の式 : 物体側焦点から物体までの距離を <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>x</mi><mn>1</mn></msub></mrow><annotation encoding="application/x-tex">x_1</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span>, 像側焦点から像までの距離を <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>x</mi><mn>2</mn></msub></mrow><annotation encoding="application/x-tex">x_2</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> とすると, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>x</mi><mn>1</mn></msub><msub><mi>x</mi><mn>2</mn></msub><mo>=</mo><msup><mi>f</mi><mn>2</mn></msup></mrow><annotation encoding="application/x-tex">x_1 x_2=f^2</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.0085em;vertical-align:-0.1944em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.10764em;">f</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span></span></li>
</ol>
<h3 id="_6-7-像の位置を求める視差法" tabindex="-1">6.7: 像の位置を求める視差法 <a class="header-anchor" href="#_6-7-像の位置を求める視差法" aria-label="Permalink to &quot;6.7: 像の位置を求める視差法&quot;">&ZeroWidthSpace;</a></h3>
<ol start="7">
<li>像の位置を求める視差法 : 目の位置と垂直に動かした ときに，鉛筆の先が像に対してずれないような位置を 探す.</li>
</ol>
<h3 id="_6-8-レンズを通る光線の経路の幾何学的な描き方" tabindex="-1">6.8: レンズを通る光線の経路の幾何学的な描き方 <a class="header-anchor" href="#_6-8-レンズを通る光線の経路の幾何学的な描き方" aria-label="Permalink to &quot;6.8: レンズを通る光線の経路の幾何学的な描き方&quot;">&ZeroWidthSpace;</a></h3>
<ol start="8">
<li>レンズを通る光線の経路の幾何学的な描き方：a) レン ズの中心を通る光線は屈折しない。b) 光軸に平行な光 線は焦点を通る，c) 屈折後, 初めに平行だった光線どうしは焦点面（焦点を通り光軸に垂直な平面）上で集 まる．d) 平面の像は平面であり，この 2 つの平面はレ ンズの平面上で交わる．</li>
</ol>
<h3 id="_6-9-光束" tabindex="-1">6.9: 光束 <a class="header-anchor" href="#_6-9-光束" aria-label="Permalink to &quot;6.9: 光束&quot;">&ZeroWidthSpace;</a></h3>
<ol start="9">
<li>光束 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Φ</mi></mrow><annotation encoding="application/x-tex">\Phi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">Φ</span></span></span></span> [単位: lumen <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">(</mo><mi mathvariant="normal">lm</mi><mo>⁡</mo><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">(\operatorname{lm})</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">(</span><span class="mop"><span class="mord mathrm">lm</span></span><span class="mclose">)</span></span></span></span>] は, 光のエネルギー を示し, 眼の感度に応じて重み付けされる. 光度 [candela (cd)]は（光源から出る）立体角あたりの 光束で, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>I</mi><mo>=</mo><mi mathvariant="normal">Φ</mi><mi mathvariant="normal">/</mi><mi mathvariant="normal">Ω</mi></mrow><annotation encoding="application/x-tex">I=\Phi / \Omega</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">Φ/Ω</span></span></span></span>. 照度 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">[</mo><mi mathvariant="normal">lux</mi><mo>⁡</mo><mo stretchy="false">(</mo><mrow><mi mathvariant="normal">l</mi><mi mathvariant="normal">x</mi></mrow><mo stretchy="false">)</mo><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">[\operatorname{lux}(\mathrm{lx})]</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">[</span><span class="mop"><span class="mord mathrm">lux</span></span><span class="mopen">(</span><span class="mord"><span class="mord mathrm">lx</span></span><span class="mclose">)]</span></span></span></span> は（面に入射する） 面積あたりの光束で, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>E</mi><mo>=</mo><mi mathvariant="normal">Φ</mi><mi mathvariant="normal">/</mi><mi>S</mi></mrow><annotation encoding="application/x-tex">E=\Phi / S</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.05764em;">E</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">Φ/</span><span class="mord mathnormal" style="margin-right:0.05764em;">S</span></span></span></span>.</li>
</ol>
<h3 id="_6-10-gauss-定理" tabindex="-1">6.10: Gauss 定理 <a class="header-anchor" href="#_6-10-gauss-定理" aria-label="Permalink to &quot;6.10: Gauss 定理&quot;">&ZeroWidthSpace;</a></h3>
<ol start="10">
<li>光束についての Gauss の定理 : 光度 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>I</mi><mi>i</mi></msub></mrow><annotation encoding="application/x-tex">I_i</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:-0.0785em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> の点光源を囲 む閉曲面を通って外に出る光束は, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Φ</mi><mo>=</mo><mn>4</mn><mi>π</mi><mo>∑</mo><msub><mi>I</mi><mi>i</mi></msub></mrow><annotation encoding="application/x-tex">\Phi=4 \pi \sum I_i</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">Φ</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">4</span><span class="mord mathnormal" style="margin-right:0.03588em;">π</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop op-symbol small-op" style="position:relative;top:0em;">∑</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:-0.0785em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span>. 光 源が 1 つで距離が <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>r</mi></mrow><annotation encoding="application/x-tex">r</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal" style="margin-right:0.02778em;">r</span></span></span></span> のとき <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>E</mi><mo>=</mo><mi>I</mi><mi mathvariant="normal">/</mi><msup><mi>r</mi><mn>2</mn></msup></mrow><annotation encoding="application/x-tex">E=I / r^2</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.05764em;">E</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.0641em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="mord">/</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.02778em;">r</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span></span></li>
</ol>
<h3 id="_6-11-実験のヒント" tabindex="-1">6.11: 実験のヒント <a class="header-anchor" href="#_6-11-実験のヒント" aria-label="Permalink to &quot;6.11: 実験のヒント&quot;">&ZeroWidthSpace;</a></h3>
<ol start="11">
<li>実験のヒント：紙についた油污れが周囲の紙と同じ明 るさならば，その紙は両面から同じように照らされて いる.</li>
</ol>
]]></description>
            <content:encoded><![CDATA[<h1 id="formulas-for-ipho-日本語版-section-6" tabindex="-1">Formulas for IPhO 日本語版: Section 6 <a class="header-anchor" href="#formulas-for-ipho-日本語版-section-6" aria-label="Permalink to &quot;Formulas for IPhO 日本語版: Section 6&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="_6-幾何光学-測光" tabindex="-1">6: 幾何光学，測光 <a class="header-anchor" href="#_6-幾何光学-測光" aria-label="Permalink to &quot;6: 幾何光学，測光&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="_6-1-fermat-原理" tabindex="-1">6.1: Fermat 原理 <a class="header-anchor" href="#_6-1-fermat-原理" aria-label="Permalink to &quot;6.1: Fermat 原理&quot;">&ZeroWidthSpace;</a></h3>
<ol>
<li>Fermat の原理 : 点 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>A</mi></mrow><annotation encoding="application/x-tex">A</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal">A</span></span></span></span> から <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>B</mi></mrow><annotation encoding="application/x-tex">B</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span></span> への波の経路は波の移動 時間が最も短いもの.</li>
</ol>
<h3 id="_6-2-snell-法則" tabindex="-1">6.2: Snell 法則 <a class="header-anchor" href="#_6-2-snell-法則" aria-label="Permalink to &quot;6.2: Snell 法則&quot;">&ZeroWidthSpace;</a></h3>
<ol start="2">
<li>Snell の法則 :</li>
</ol>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mi>sin</mi><mo>⁡</mo><msub><mi>α</mi><mn>1</mn></msub><mi mathvariant="normal">/</mi><mi>sin</mi><mo>⁡</mo><msub><mi>α</mi><mn>2</mn></msub><mo>=</mo><msub><mi>n</mi><mn>2</mn></msub><mi mathvariant="normal">/</mi><msub><mi>n</mi><mn>1</mn></msub><mo>=</mo><msub><mi>v</mi><mn>1</mn></msub><mi mathvariant="normal">/</mi><msub><mi>v</mi><mn>2</mn></msub><mi mathvariant="normal">.</mi></mrow><annotation encoding="application/x-tex">\sin \alpha_1 / \sin \alpha_2=n_2 / n_1=v_1 / v_2 .
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mop">sin</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.0037em;">α</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0037em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord">/</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">sin</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.0037em;">α</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0037em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord mathnormal">n</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord">/</span><span class="mord"><span class="mord mathnormal">n</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord">/</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord">.</span></span></span></span></span></p>
<h3 id="_6-3-屈折率" tabindex="-1">6.3: 屈折率 <a class="header-anchor" href="#_6-3-屈折率" aria-label="Permalink to &quot;6.3: 屈折率&quot;">&ZeroWidthSpace;</a></h3>
<ol start="3">
<li>屈折率が連続的に変化するならば，媒質を屈折率が <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>n</mi></mrow><annotation encoding="application/x-tex">n</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">n</span></span></span></span> で一定のいくつかの仮想的な層に分けて Snell の 法則を適用する. 光線は屈折率一定の層に沿って進む こともでき,もし全反射の条件をわずかに満たせば, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msup><mi>n</mi><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup><mo>=</mo><mi>n</mi><mi mathvariant="normal">/</mi><mi>r</mi><mspace width="1em"/><mo stretchy="false">(</mo><mi>r</mi></mrow><annotation encoding="application/x-tex">n^{\prime}=n / r \quad(r</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7519em;"></span><span class="mord"><span class="mord mathnormal">n</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7519em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal">n</span><span class="mord">/</span><span class="mord mathnormal" style="margin-right:0.02778em;">r</span><span class="mspace" style="margin-right:1em;"></span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.02778em;">r</span></span></span></span> は曲率半径 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mclose">)</span></span></span></span></li>
</ol>
<h3 id="_6-4-屈折率な座標" tabindex="-1">6.4: 屈折率な座標 <a class="header-anchor" href="#_6-4-屈折率な座標" aria-label="Permalink to &quot;6.4: 屈折率な座標&quot;">&ZeroWidthSpace;</a></h3>
<ol start="4">
<li>屈折率が <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">z</mi></mrow><annotation encoding="application/x-tex">\mathrm{z}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathrm">z</span></span></span></span> 座標にのみ依存するならば, 光子の運動量 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>p</mi><mi>x</mi></msub><mo separator="true">,</mo><msub><mi>p</mi><mi>y</mi></msub></mrow><annotation encoding="application/x-tex">p_x, p_y</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7167em;vertical-align:-0.2861em;"></span><span class="mord"><span class="mord mathnormal">p</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">x</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal">p</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.03588em;">y</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span></span></span></span> とエネルギーは保存される:</li>
</ol>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><msub><mi>k</mi><mi>x</mi></msub><mo separator="true">,</mo><msub><mi>k</mi><mi>y</mi></msub><mo>=</mo><mtext> const., </mtext><mi mathvariant="normal">∣</mi><mi mathvariant="bold-italic">k</mi><mi mathvariant="normal">∣</mi><mi mathvariant="normal">/</mi><mi>n</mi><mo>=</mo><mtext> const. </mtext></mrow><annotation encoding="application/x-tex">k_x, k_y=\text { const., }|\boldsymbol{k}| / n=\text { const. }
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9805em;vertical-align:-0.2861em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:-0.0315em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">x</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:-0.0315em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.03588em;">y</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord text"><span class="mord"> const., </span></span><span class="mord">∣</span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.01852em;">k</span></span></span><span class="mord">∣/</span><span class="mord mathnormal">n</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6151em;"></span><span class="mord text"><span class="mord"> const. </span></span></span></span></span></span></p>
<h3 id="_6-5-薄いレンズの式" tabindex="-1">6.5:薄いレンズの式 <a class="header-anchor" href="#_6-5-薄いレンズの式" aria-label="Permalink to &quot;6.5:薄いレンズの式&quot;">&ZeroWidthSpace;</a></h3>
<ol start="6">
<li>薄いレンズの式（符号に注意する）：</li>
</ol>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mn>1</mn><mi mathvariant="normal">/</mi><mi>a</mi><mo>+</mo><mn>1</mn><mi mathvariant="normal">/</mi><mi>b</mi><mo>=</mo><mn>1</mn><mi mathvariant="normal">/</mi><mi>f</mi><mo>≡</mo><mi>D</mi></mrow><annotation encoding="application/x-tex">1 / a+1 / b=1 / f \equiv D
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">1/</span><span class="mord mathnormal">a</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">1/</span><span class="mord mathnormal">b</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">1/</span><span class="mord mathnormal" style="margin-right:0.10764em;">f</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≡</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.02778em;">D</span></span></span></span></span></p>
<h3 id="_6-6-newton-の式" tabindex="-1">6.6: Newton の式 <a class="header-anchor" href="#_6-6-newton-の式" aria-label="Permalink to &quot;6.6: Newton の式&quot;">&ZeroWidthSpace;</a></h3>
<ol start="6">
<li>Newton の式 : 物体側焦点から物体までの距離を <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>x</mi><mn>1</mn></msub></mrow><annotation encoding="application/x-tex">x_1</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span>, 像側焦点から像までの距離を <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>x</mi><mn>2</mn></msub></mrow><annotation encoding="application/x-tex">x_2</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> とすると, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>x</mi><mn>1</mn></msub><msub><mi>x</mi><mn>2</mn></msub><mo>=</mo><msup><mi>f</mi><mn>2</mn></msup></mrow><annotation encoding="application/x-tex">x_1 x_2=f^2</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.0085em;vertical-align:-0.1944em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.10764em;">f</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span></span></li>
</ol>
<h3 id="_6-7-像の位置を求める視差法" tabindex="-1">6.7: 像の位置を求める視差法 <a class="header-anchor" href="#_6-7-像の位置を求める視差法" aria-label="Permalink to &quot;6.7: 像の位置を求める視差法&quot;">&ZeroWidthSpace;</a></h3>
<ol start="7">
<li>像の位置を求める視差法 : 目の位置と垂直に動かした ときに，鉛筆の先が像に対してずれないような位置を 探す.</li>
</ol>
<h3 id="_6-8-レンズを通る光線の経路の幾何学的な描き方" tabindex="-1">6.8: レンズを通る光線の経路の幾何学的な描き方 <a class="header-anchor" href="#_6-8-レンズを通る光線の経路の幾何学的な描き方" aria-label="Permalink to &quot;6.8: レンズを通る光線の経路の幾何学的な描き方&quot;">&ZeroWidthSpace;</a></h3>
<ol start="8">
<li>レンズを通る光線の経路の幾何学的な描き方：a) レン ズの中心を通る光線は屈折しない。b) 光軸に平行な光 線は焦点を通る，c) 屈折後, 初めに平行だった光線どうしは焦点面（焦点を通り光軸に垂直な平面）上で集 まる．d) 平面の像は平面であり，この 2 つの平面はレ ンズの平面上で交わる．</li>
</ol>
<h3 id="_6-9-光束" tabindex="-1">6.9: 光束 <a class="header-anchor" href="#_6-9-光束" aria-label="Permalink to &quot;6.9: 光束&quot;">&ZeroWidthSpace;</a></h3>
<ol start="9">
<li>光束 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Φ</mi></mrow><annotation encoding="application/x-tex">\Phi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">Φ</span></span></span></span> [単位: lumen <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">(</mo><mi mathvariant="normal">lm</mi><mo>⁡</mo><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">(\operatorname{lm})</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">(</span><span class="mop"><span class="mord mathrm">lm</span></span><span class="mclose">)</span></span></span></span>] は, 光のエネルギー を示し, 眼の感度に応じて重み付けされる. 光度 [candela (cd)]は（光源から出る）立体角あたりの 光束で, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>I</mi><mo>=</mo><mi mathvariant="normal">Φ</mi><mi mathvariant="normal">/</mi><mi mathvariant="normal">Ω</mi></mrow><annotation encoding="application/x-tex">I=\Phi / \Omega</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">Φ/Ω</span></span></span></span>. 照度 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">[</mo><mi mathvariant="normal">lux</mi><mo>⁡</mo><mo stretchy="false">(</mo><mrow><mi mathvariant="normal">l</mi><mi mathvariant="normal">x</mi></mrow><mo stretchy="false">)</mo><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">[\operatorname{lux}(\mathrm{lx})]</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">[</span><span class="mop"><span class="mord mathrm">lux</span></span><span class="mopen">(</span><span class="mord"><span class="mord mathrm">lx</span></span><span class="mclose">)]</span></span></span></span> は（面に入射する） 面積あたりの光束で, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>E</mi><mo>=</mo><mi mathvariant="normal">Φ</mi><mi mathvariant="normal">/</mi><mi>S</mi></mrow><annotation encoding="application/x-tex">E=\Phi / S</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.05764em;">E</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">Φ/</span><span class="mord mathnormal" style="margin-right:0.05764em;">S</span></span></span></span>.</li>
</ol>
<h3 id="_6-10-gauss-定理" tabindex="-1">6.10: Gauss 定理 <a class="header-anchor" href="#_6-10-gauss-定理" aria-label="Permalink to &quot;6.10: Gauss 定理&quot;">&ZeroWidthSpace;</a></h3>
<ol start="10">
<li>光束についての Gauss の定理 : 光度 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>I</mi><mi>i</mi></msub></mrow><annotation encoding="application/x-tex">I_i</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:-0.0785em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> の点光源を囲 む閉曲面を通って外に出る光束は, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Φ</mi><mo>=</mo><mn>4</mn><mi>π</mi><mo>∑</mo><msub><mi>I</mi><mi>i</mi></msub></mrow><annotation encoding="application/x-tex">\Phi=4 \pi \sum I_i</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">Φ</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">4</span><span class="mord mathnormal" style="margin-right:0.03588em;">π</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop op-symbol small-op" style="position:relative;top:0em;">∑</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:-0.0785em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span>. 光 源が 1 つで距離が <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>r</mi></mrow><annotation encoding="application/x-tex">r</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal" style="margin-right:0.02778em;">r</span></span></span></span> のとき <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>E</mi><mo>=</mo><mi>I</mi><mi mathvariant="normal">/</mi><msup><mi>r</mi><mn>2</mn></msup></mrow><annotation encoding="application/x-tex">E=I / r^2</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.05764em;">E</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.0641em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="mord">/</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.02778em;">r</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span></span></li>
</ol>
<h3 id="_6-11-実験のヒント" tabindex="-1">6.11: 実験のヒント <a class="header-anchor" href="#_6-11-実験のヒント" aria-label="Permalink to &quot;6.11: 実験のヒント&quot;">&ZeroWidthSpace;</a></h3>
<ol start="11">
<li>実験のヒント：紙についた油污れが周囲の紙と同じ明 るさならば，その紙は両面から同じように照らされて いる.</li>
</ol>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Formulas for IPhO 日本語版: Section 7 ]]></title>
            <link>https://note.toshiki.devacademic/physics/ipho-formulas-jpn/7</link>
            <guid>https://note.toshiki.devacademic/physics/ipho-formulas-jpn/7</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="formulas-for-ipho-日本語版-section-7" tabindex="-1">Formulas for IPhO 日本語版: Section 7 <a class="header-anchor" href="#formulas-for-ipho-日本語版-section-7" aria-label="Permalink to &quot;Formulas for IPhO 日本語版: Section 7&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="_7-波動光学" tabindex="-1">7: 波動光学 <a class="header-anchor" href="#_7-波動光学" aria-label="Permalink to &quot;7: 波動光学&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="_7-1-huygens-の原理に基づいた回折" tabindex="-1">7.1: Huygens の原理に基づいた回折 <a class="header-anchor" href="#_7-1-huygens-の原理に基づいた回折" aria-label="Permalink to &quot;7.1: Huygens の原理に基づいた回折&quot;">&ZeroWidthSpace;</a></h3>
<ol>
<li>Huygens の原理に基づいた回折 : 障害物が波面を切断 すると波面は小さな断片に分割され，それが仮想的な 点波源となり，観測点での波の振幅はこれらの波源か らの寄与の重ね合わせとなる.</li>
</ol>
<h3 id="_7-2-二重スリット" tabindex="-1">7.2: 二重スリット <a class="header-anchor" href="#_7-2-二重スリット" aria-label="Permalink to &quot;7.2: 二重スリット&quot;">&ZeroWidthSpace;</a></h3>
<ol start="2">
<li>二重スリット（幅は <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>d</mi><mo>≪</mo><mi>a</mi><mo separator="true">,</mo><mi>λ</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">d \ll a, \lambda)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7335em;vertical-align:-0.0391em;"></span><span class="mord mathnormal">d</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≪</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal">a</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">λ</span><span class="mclose">)</span></span></span></span> による干渉:強 め合う角 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>φ</mi><mi>max</mi><mo>⁡</mo></msub><mo>=</mo><mi>arcsin</mi><mo>⁡</mo><mo stretchy="false">(</mo><mi>n</mi><mi>λ</mi><mi mathvariant="normal">/</mi><mi>d</mi><mo stretchy="false">)</mo><mo separator="true">,</mo><mi>n</mi><mo>∈</mo><mi mathvariant="double-struck">Z</mi><mi mathvariant="normal">.</mi><mi>I</mi><mo>∝</mo></mrow><annotation encoding="application/x-tex">\varphi_{\max }=\arcsin (n \lambda / d), n \in \mathbb{Z} . I \propto</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord"><span class="mord mathnormal">φ</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mop mtight"><span class="mtight">m</span><span class="mtight">a</span><span class="mtight">x</span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mop">arcsin</span><span class="mopen">(</span><span class="mord mathnormal">nλ</span><span class="mord">/</span><span class="mord mathnormal">d</span><span class="mclose">)</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">n</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">∈</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord mathbb">Z</span><span class="mord">.</span><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">∝</span></span></span></span> <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msup><mrow><mi>cos</mi><mo>⁡</mo></mrow><mn>2</mn></msup><mrow><mo fence="true">(</mo><mi>k</mi><mfrac><mi>a</mi><mn>2</mn></mfrac><mi>sin</mi><mo>⁡</mo><mi>φ</mi><mo fence="true">)</mo></mrow><mo separator="true">,</mo><mo stretchy="false">(</mo><mi>k</mi><mo>=</mo><mn>2</mn><mi>π</mi><mi mathvariant="normal">/</mi><mi>λ</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">\cos ^2\left(k \frac{a}{2} \sin \varphi\right),(k=2 \pi / \lambda)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2em;vertical-align:-0.35em;"></span><span class="mop"><span class="mop">cos</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size1">(</span></span><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6954em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">a</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">sin</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">φ</span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size1">)</span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">2</span><span class="mord mathnormal" style="margin-right:0.03588em;">π</span><span class="mord">/</span><span class="mord mathnormal">λ</span><span class="mclose">)</span></span></span></span></li>
</ol>
<h3 id="_7-3-単スリット-弱め合う角" tabindex="-1">7.3: 単スリット-弱め合う角 <a class="header-anchor" href="#_7-3-単スリット-弱め合う角" aria-label="Permalink to &quot;7.3: 単スリット-弱め合う角&quot;">&ZeroWidthSpace;</a></h3>
<ol start="3">
<li>単スリット:弱め合う角: <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>φ</mi><mtext>min </mtext></msub><mo>=</mo><mi>arcsin</mi><mo>⁡</mo><mo stretchy="false">(</mo><mi>n</mi><mi>λ</mi><mi mathvariant="normal">/</mi><mi>d</mi><mo stretchy="false">)</mo><mo separator="true">,</mo><mi>n</mi><mo>∈</mo></mrow><annotation encoding="application/x-tex">\varphi_{\text {min }}=\arcsin (n \lambda / d), n \in</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord"><span class="mord mathnormal">φ</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3175em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord text mtight"><span class="mord mtight">min </span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mop">arcsin</span><span class="mopen">(</span><span class="mord mathnormal">nλ</span><span class="mord">/</span><span class="mord mathnormal">d</span><span class="mclose">)</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">n</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">∈</span></span></span></span> <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="double-struck">Z</mi><mo separator="true">,</mo><mi>n</mi><mo mathvariant="normal">≠</mo><mn>0</mn></mrow><annotation encoding="application/x-tex">\mathbb{Z}, n \neq 0</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathbb">Z</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">n</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel"><span class="mrel"><span class="mord vbox"><span class="thinbox"><span class="rlap"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="inner"><span class="mord"><span class="mrel"></span></span></span><span class="fix"></span></span></span></span></span><span class="mrel">=</span></span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">0</span></span></span></span>. 中央の強め合う部分は <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>n</mi><mo>=</mo><mo>±</mo><mn>1</mn></mrow><annotation encoding="application/x-tex">n=\pm 1</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">n</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.7278em;vertical-align:-0.0833em;"></span><span class="mord">±</span><span class="mord">1</span></span></span></span> の間である ことに注意せよ. <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>I</mi><mo>∝</mo><msup><mrow><mi>sin</mi><mo>⁡</mo></mrow><mn>2</mn></msup><mrow><mo fence="true">(</mo><mi>k</mi><mfrac><mi>d</mi><mn>2</mn></mfrac><mi>sin</mi><mo>⁡</mo><mi>φ</mi><mo fence="true">)</mo></mrow><mi mathvariant="normal">/</mi><mi>sin</mi><mo>⁡</mo><mi>φ</mi></mrow><annotation encoding="application/x-tex">I \propto \sin ^2\left(k \frac{d}{2} \sin \varphi\right) / \sin \varphi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">∝</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.2301em;vertical-align:-0.35em;"></span><span class="mop"><span class="mop">sin</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8719em;"><span style="top:-3.1208em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size1">(</span></span><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8801em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">d</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">sin</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">φ</span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size1">)</span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord">/</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">sin</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">φ</span></span></span></span></li>
</ol>
<h3 id="_7-4-回折格子" tabindex="-1">7.4: 回折格子 <a class="header-anchor" href="#_7-4-回折格子" aria-label="Permalink to &quot;7.4: 回折格子&quot;">&ZeroWidthSpace;</a></h3>
<ol start="4">
<li>回折格子：主な強め合う角はポイント 2 と同じで, 主 な強め合う角の幅は <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>d</mi></mrow><annotation encoding="application/x-tex">d</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">d</span></span></span></span> を回折格子の正味の長さとすれ ばポイント 3 と同じ. <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>n</mi></mrow><annotation encoding="application/x-tex">n</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">n</span></span></span></span> 番目の明線のスペクトルの分 解能は，溝の総数を <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>N</mi></mrow><annotation encoding="application/x-tex">N</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.10903em;">N</span></span></span></span> 本として <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mfrac><mi>λ</mi><mrow><mi mathvariant="normal">Δ</mi><mi>λ</mi></mrow></mfrac><mo>=</mo><mi>n</mi><mi>N</mi></mrow><annotation encoding="application/x-tex">\frac{\lambda}{\Delta \lambda}=n N</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2251em;vertical-align:-0.345em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8801em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">Δ</span><span class="mord mathnormal mtight">λ</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">λ</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal">n</span><span class="mord mathnormal" style="margin-right:0.10903em;">N</span></span></span></span>.</li>
</ol>
<h3 id="_7-5-分光器の分解能" tabindex="-1">7.5: 分光器の分解能 <a class="header-anchor" href="#_7-5-分光器の分解能" aria-label="Permalink to &quot;7.5: 分光器の分解能&quot;">&ZeroWidthSpace;</a></h3>
<ol start="5">
<li>分光器の分解能 : 最短の光線と最長の光線の光学距離 の差を <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>L</mi></mrow><annotation encoding="application/x-tex">L</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal">L</span></span></span></span> として, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mfrac><mi>λ</mi><mrow><mi mathvariant="normal">Δ</mi><mi>λ</mi></mrow></mfrac><mo>=</mo><mfrac><mi>L</mi><mi>λ</mi></mfrac></mrow><annotation encoding="application/x-tex">\frac{\lambda}{\Delta \lambda}=\frac{L}{\lambda}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2251em;vertical-align:-0.345em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8801em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">Δ</span><span class="mord mathnormal mtight">λ</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">λ</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.2173em;vertical-align:-0.345em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8723em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">λ</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">L</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span>.</li>
</ol>
<h3 id="_7-6-プリズムの分解能" tabindex="-1">7.6: プリズムの分解能 <a class="header-anchor" href="#_7-6-プリズムの分解能" aria-label="Permalink to &quot;7.6: プリズムの分解能&quot;">&ZeroWidthSpace;</a></h3>
<ol start="7">
<li>プリズムの分解能 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>:</mo><mfrac><mi>λ</mi><mrow><mi mathvariant="normal">Δ</mi><mi>λ</mi></mrow></mfrac><mo>=</mo><mi>a</mi><mfrac><mrow><mi mathvariant="normal">d</mi><mi>n</mi></mrow><mrow><mrow><mtext> </mtext><mi mathvariant="normal">d</mi></mrow><mi>λ</mi></mrow></mfrac></mrow><annotation encoding="application/x-tex">: \frac{\lambda}{\Delta \lambda}=a \frac{\mathrm{d} n}{\mathrm{~d} \lambda}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mrel">:</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.2251em;vertical-align:-0.345em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8801em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">Δ</span><span class="mord mathnormal mtight">λ</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">λ</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.2251em;vertical-align:-0.345em;"></span><span class="mord mathnormal">a</span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8801em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight"><span class="mspace nobreak mtight"><span class="mtight"> </span></span><span class="mord mathrm mtight">d</span></span><span class="mord mathnormal mtight">λ</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathrm mtight">d</span><span class="mord mathnormal mtight">n</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span></li>
</ol>
<h3 id="_7-7-角度距離" tabindex="-1">7.7: 角度距離 <a class="header-anchor" href="#_7-7-角度距離" aria-label="Permalink to &quot;7.7: 角度距離&quot;">&ZeroWidthSpace;</a></h3>
<ol start="7">
<li>理想的な望遠鏡 (レンズ) で 2 点を解像するときの角度距離 : <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>φ</mi><mo>≈</mo><mn>1.22</mn><mi>λ</mi><mi mathvariant="normal">/</mi><mi>d</mi></mrow><annotation encoding="application/x-tex">\varphi \approx 1.22 \lambda / d</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6776em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">φ</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≈</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">1.22</span><span class="mord mathnormal">λ</span><span class="mord">/</span><span class="mord mathnormal">d</span></span></span></span>. この角度では, 一方の点の中 心が他方の点の最初の回折最小值に当たる.</li>
</ol>
<h3 id="_7-8-bragg-の法則" tabindex="-1">7.8: Bragg の法則 <a class="header-anchor" href="#_7-8-bragg-の法則" aria-label="Permalink to &quot;7.8: Bragg の法則&quot;">&ZeroWidthSpace;</a></h3>
<ol start="8">
<li>Bragg の法則：間隔が <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>d</mi></mrow><annotation encoding="application/x-tex">d</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">d</span></span></span></span> の平行な結晶面の組は, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>2</mn><mi>d</mi><mi>sin</mi><mo>⁡</mo><mi>θ</mi><mo>=</mo><mi>n</mi><mi>λ</mi></mrow><annotation encoding="application/x-tex">2 d \sin \theta=n \lambda</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">2</span><span class="mord mathnormal">d</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">sin</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.02778em;">θ</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">nλ</span></span></span></span> ならば <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">X</mi></mrow><annotation encoding="application/x-tex">\mathrm{X}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathrm">X</span></span></span></span> 線を反射する. ここで <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>θ</mi></mrow><annotation encoding="application/x-tex">\theta</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal" style="margin-right:0.02778em;">θ</span></span></span></span> は結 晶面と X 線がなす角 (かすめ角).</li>
</ol>
<h3 id="_7-9-高密度電体媒質反射" tabindex="-1">7.9: 高密度電体媒質反射 <a class="header-anchor" href="#_7-9-高密度電体媒質反射" aria-label="Permalink to &quot;7.9: 高密度電体媒質反射&quot;">&ZeroWidthSpace;</a></h3>
<ol start="9">
<li>光学的に高密度な誘電体媒質による反射 : 位相が <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>π</mi></mrow><annotation encoding="application/x-tex">\pi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">π</span></span></span></span> ず れる. 半透明の薄膜では <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>ϕ</mi><mo lspace="0em" rspace="0em">→</mo></msub><mo>+</mo><msub><mi>ϕ</mi><mo lspace="0em" rspace="0em">←</mo></msub><mo>=</mo><mi>π</mi></mrow><annotation encoding="application/x-tex">\phi_{\rightarrow}+\phi_{\leftarrow}=\pi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord"><span class="mord mathnormal">ϕ</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1068em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mrel mtight">→</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord"><span class="mord mathnormal">ϕ</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1068em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mrel mtight">←</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">π</span></span></span></span>. ここで <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>ϕ</mi><mo lspace="0em" rspace="0em">→</mo></msub></mrow><annotation encoding="application/x-tex">\phi_{\rightarrow}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord"><span class="mord mathnormal">ϕ</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1068em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mrel mtight">→</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> と <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>ϕ</mi><mo lspace="0em" rspace="0em">←</mo></msub></mrow><annotation encoding="application/x-tex">\phi_{\leftarrow}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord"><span class="mord mathnormal">ϕ</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1068em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mrel mtight">←</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> は反射波と透過波の位相差（矢印は入射方向を 示す)</li>
</ol>
<h3 id="_7-10-fabry-perot-干渉計" tabindex="-1">7.10: Fabry-Pérot 干渉計 <a class="header-anchor" href="#_7-10-fabry-perot-干渉計" aria-label="Permalink to &quot;7.10: Fabry-Pérot 干渉計&quot;">&ZeroWidthSpace;</a></h3>
<ol start="10">
<li>Fabry-Pérot 干渉計 : 高い反射率 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>r</mi><mo stretchy="false">(</mo><mn>1</mn><mo>−</mo><mi>r</mi><mo>≪</mo><mn>1</mn><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">r(1-r \ll 1)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.02778em;">r</span><span class="mopen">(</span><span class="mord">1</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mord mathnormal" style="margin-right:0.02778em;">r</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≪</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">1</span><span class="mclose">)</span></span></span></span> を持 つ 2 枚の平行な半透明の鏡. 分解能は <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mfrac><mi>ν</mi><mrow><mi mathvariant="normal">Δ</mi><mi>ν</mi></mrow></mfrac><mo>≈</mo><mfrac><mrow><mn>2</mn><mi>a</mi></mrow><mrow><mi>λ</mi><mo stretchy="false">(</mo><mn>1</mn><mo>−</mo><mi>r</mi><mo stretchy="false">)</mo></mrow></mfrac></mrow><annotation encoding="application/x-tex">\frac{\nu}{\Delta \nu} \approx \frac{2 a}{\lambda(1-r)}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0404em;vertical-align:-0.345em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6954em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">Δ</span><span class="mord mathnormal mtight" style="margin-right:0.06366em;">ν</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.06366em;">ν</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≈</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.3651em;vertical-align:-0.52em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8451em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">λ</span><span class="mopen mtight">(</span><span class="mord mtight">1</span><span class="mbin mtight">−</span><span class="mord mathnormal mtight" style="margin-right:0.02778em;">r</span><span class="mclose mtight">)</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span><span class="mord mathnormal mtight">a</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.52em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span>. 5 つの平面波 (干渉計の前で左右に進む波, 内部を左右 に進む波，後ろを進む波）を設定して境界条件を課す ことで，透過スペクトルを求められる.</li>
</ol>
<h3 id="_7-11-コヒーレントな電磁波" tabindex="-1">7.11: コヒーレントな電磁波 <a class="header-anchor" href="#_7-11-コヒーレントな電磁波" aria-label="Permalink to &quot;7.11: コヒーレントな電磁波&quot;">&ZeroWidthSpace;</a></h3>
<ol start="11">
<li>コヒーレントな電磁波: 電場をベクトル为で表し, ベク トル間の角度を位相差とする. 屈折率が <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>n</mi><mo>=</mo><mi>n</mi><mo stretchy="false">(</mo><mi>ω</mi><mo stretchy="false">)</mo><mo>=</mo></mrow><annotation encoding="application/x-tex">n=n(\omega)=</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">n</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal">n</span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.03588em;">ω</span><span class="mclose">)</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span></span></span></span> <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msqrt><mrow><mi>ε</mi><mo stretchy="false">(</mo><mi>ω</mi><mo stretchy="false">)</mo></mrow></msqrt></mrow><annotation encoding="application/x-tex">\sqrt{\varepsilon(\omega)}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.24em;vertical-align:-0.305em;"></span><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.935em;"><span class="svg-align" style="top:-3.2em;"><span class="pstrut" style="height:3.2em;"></span><span class="mord" style="padding-left:1em;"><span class="mord mathnormal">ε</span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.03588em;">ω</span><span class="mclose">)</span></span></span><span style="top:-2.895em;"><span class="pstrut" style="height:3.2em;"></span><span class="hide-tail" style="min-width:1.02em;height:1.28em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='1.28em' viewBox='0 0 400000 1296' preserveAspectRatio='xMinYMin slice'><path d='M263,681c0.7,0,18,39.7,52,119
c34,79.3,68.167,158.7,102.5,238c34.3,79.3,51.8,119.3,52.5,120
c340,-704.7,510.7,-1060.3,512,-1067
l0 -0
c4.7,-7.3,11,-11,19,-11
H40000v40H1012.3
s-271.3,567,-271.3,567c-38.7,80.7,-84,175,-136,283c-52,108,-89.167,185.3,-111.5,232
c-22.3,46.7,-33.8,70.3,-34.5,71c-4.7,4.7,-12.3,7,-23,7s-12,-1,-12,-1
s-109,-253,-109,-253c-72.7,-168,-109.3,-252,-110,-252c-10.7,8,-22,16.7,-34,26
c-22,17.3,-33.3,26,-34,26s-26,-26,-26,-26s76,-59,76,-59s76,-60,76,-60z
M1001 80h400000v40h-400000z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.305em;"><span></span></span></span></span></span></span></span></span> (普通 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>μ</mi><mo>≈</mo><mn>1</mn></mrow><annotation encoding="application/x-tex">\mu \approx 1</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6776em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">μ</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≈</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">1</span></span></span></span> ) であることに注意せよ. エネ ルギー流密度（単位面積を通過する単位時間あたりの エネルギー）: <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>I</mi><mo>=</mo><mi>c</mi><mi>n</mi><msub><mi>ε</mi><mn>0</mn></msub><msup><mi>E</mi><mn>2</mn></msup><mo>=</mo><mfrac><mi>c</mi><mrow><mi>n</mi><msub><mi>μ</mi><mn>0</mn></msub></mrow></mfrac><msup><mi>B</mi><mn>2</mn></msup><mo stretchy="false">(</mo><mi>E</mi></mrow><annotation encoding="application/x-tex">I=c n \varepsilon_0 E^2=\frac{c}{n \mu_0} B^2(E</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.9641em;vertical-align:-0.15em;"></span><span class="mord mathnormal">c</span><span class="mord mathnormal">n</span><span class="mord"><span class="mord mathnormal">ε</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">0</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.05764em;">E</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.2952em;vertical-align:-0.4811em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6954em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">n</span><span class="mord mtight"><span class="mord mathnormal mtight">μ</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3173em;"><span style="top:-2.357em;margin-left:0em;margin-right:0.0714em;"><span class="pstrut" style="height:2.5em;"></span><span class="sizing reset-size3 size1 mtight"><span class="mord mtight">0</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.143em;"><span></span></span></span></span></span></span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">c</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.4811em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.05017em;">B</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.05764em;">E</span></span></span></span> と <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>B</mi></mrow><annotation encoding="application/x-tex">B</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span></span> は実 効值)</li>
</ol>
<h3 id="_7-12-malus-の法則" tabindex="-1">7.12: Malus の法則 <a class="header-anchor" href="#_7-12-malus-の法則" aria-label="Permalink to &quot;7.12: Malus の法則&quot;">&ZeroWidthSpace;</a></h3>
<ol start="12">
<li>Malus の法則 : 直線偏光が角度 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>φ</mi></mrow><annotation encoding="application/x-tex">\varphi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">φ</span></span></span></span> で偏光板を通過する と <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>I</mi><mo>=</mo><msub><mi>I</mi><mn>0</mn></msub><msup><mrow><mi>cos</mi><mo>⁡</mo></mrow><mn>2</mn></msup><mi>φ</mi></mrow><annotation encoding="application/x-tex">I=I_0 \cos ^2 \varphi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.0085em;vertical-align:-0.1944em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0785em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">0</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop"><span class="mop">cos</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">φ</span></span></span></span></li>
</ol>
<h3 id="_7-13-1-4-波長版" tabindex="-1">7.13: 1/4 波長版 <a class="header-anchor" href="#_7-13-1-4-波長版" aria-label="Permalink to &quot;7.13: 1/4 波長版&quot;">&ZeroWidthSpace;</a></h3>
<ol start="13">
<li><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>1</mn><mi mathvariant="normal">/</mi><mn>4</mn></mrow><annotation encoding="application/x-tex">1 / 4</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">1/4</span></span></span></span> 波長版 : 直線偏光成分間の位相が <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>π</mi><mi mathvariant="normal">/</mi><mn>2</mn></mrow><annotation encoding="application/x-tex">\pi / 2</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">π</span><span class="mord">/2</span></span></span></span> ずれる.</li>
</ol>
<h3 id="_7-14-brewster-角" tabindex="-1">7.14: Brewster 角 <a class="header-anchor" href="#_7-14-brewster-角" aria-label="Permalink to &quot;7.14: Brewster 角&quot;">&ZeroWidthSpace;</a></h3>
<ol start="14">
<li>Brewster 角: 入射角が <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>tan</mi><mo>⁡</mo><mi>φ</mi><mo>=</mo><mi>n</mi></mrow><annotation encoding="application/x-tex">\tan \varphi=n</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8095em;vertical-align:-0.1944em;"></span><span class="mop">tan</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">φ</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">n</span></span></span></span> を満たすとき, 反 射波と屈折波が垂直になり反射波は直線偏光となる.</li>
</ol>
<h3 id="_7-15-光学素子による回折" tabindex="-1">7.15: 光学素子による回折 <a class="header-anchor" href="#_7-15-光学素子による回折" aria-label="Permalink to &quot;7.15: 光学素子による回折&quot;">&ZeroWidthSpace;</a></h3>
<ol start="15">
<li>光学素子による回折 : レンズやプリズムなどを通る光 の光学距離を計算する必要はなく, 図形的に考える. 例えば，双プリズムは二重スリットによる回折と同じ 回折をする.</li>
</ol>
<h3 id="_7-16-光ファイバー" tabindex="-1">7.16: 光ファイバー <Badge type="tip" text="supplemental" /> <a class="header-anchor" href="#_7-16-光ファイバー" aria-label="Permalink to &quot;7.16: 光ファイバー &lt;Badge type=&quot;tip&quot; text=&quot;supplemental&quot; /&gt;&quot;">&ZeroWidthSpace;</a></h3>
<ol start="17">
<li>光ファイバー：Mach-Zehnder 干渉計は二重スリッ トによる干渉と, 円形共振器は Fabry-Pérot 干渉計 と似ている. Bragg フィルターは <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">X</mi></mrow><annotation encoding="application/x-tex">\mathrm{X}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathrm">X</span></span></span></span> 線の場合と同 じように働く. シングルモードの光ファイバーでは, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Δ</mi><mi>n</mi><mi mathvariant="normal">/</mi><mi>n</mi><mo>≈</mo><mfrac><mn>1</mn><mn>2</mn></mfrac><mo stretchy="false">(</mo><mi>λ</mi><mi mathvariant="normal">/</mi><mi>d</mi><msup><mo stretchy="false">)</mo><mn>2</mn></msup></mrow><annotation encoding="application/x-tex">\Delta n / n \approx \frac{1}{2}(\lambda / d)^2</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">Δ</span><span class="mord mathnormal">n</span><span class="mord">/</span><span class="mord mathnormal">n</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≈</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.1901em;vertical-align:-0.345em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8451em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">1</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mopen">(</span><span class="mord mathnormal">λ</span><span class="mord">/</span><span class="mord mathnormal">d</span><span class="mclose"><span class="mclose">)</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span></span>.</li>
</ol>
]]></description>
            <content:encoded><![CDATA[<h1 id="formulas-for-ipho-日本語版-section-7" tabindex="-1">Formulas for IPhO 日本語版: Section 7 <a class="header-anchor" href="#formulas-for-ipho-日本語版-section-7" aria-label="Permalink to &quot;Formulas for IPhO 日本語版: Section 7&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="_7-波動光学" tabindex="-1">7: 波動光学 <a class="header-anchor" href="#_7-波動光学" aria-label="Permalink to &quot;7: 波動光学&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="_7-1-huygens-の原理に基づいた回折" tabindex="-1">7.1: Huygens の原理に基づいた回折 <a class="header-anchor" href="#_7-1-huygens-の原理に基づいた回折" aria-label="Permalink to &quot;7.1: Huygens の原理に基づいた回折&quot;">&ZeroWidthSpace;</a></h3>
<ol>
<li>Huygens の原理に基づいた回折 : 障害物が波面を切断 すると波面は小さな断片に分割され，それが仮想的な 点波源となり，観測点での波の振幅はこれらの波源か らの寄与の重ね合わせとなる.</li>
</ol>
<h3 id="_7-2-二重スリット" tabindex="-1">7.2: 二重スリット <a class="header-anchor" href="#_7-2-二重スリット" aria-label="Permalink to &quot;7.2: 二重スリット&quot;">&ZeroWidthSpace;</a></h3>
<ol start="2">
<li>二重スリット（幅は <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>d</mi><mo>≪</mo><mi>a</mi><mo separator="true">,</mo><mi>λ</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">d \ll a, \lambda)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7335em;vertical-align:-0.0391em;"></span><span class="mord mathnormal">d</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≪</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal">a</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">λ</span><span class="mclose">)</span></span></span></span> による干渉:強 め合う角 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>φ</mi><mi>max</mi><mo>⁡</mo></msub><mo>=</mo><mi>arcsin</mi><mo>⁡</mo><mo stretchy="false">(</mo><mi>n</mi><mi>λ</mi><mi mathvariant="normal">/</mi><mi>d</mi><mo stretchy="false">)</mo><mo separator="true">,</mo><mi>n</mi><mo>∈</mo><mi mathvariant="double-struck">Z</mi><mi mathvariant="normal">.</mi><mi>I</mi><mo>∝</mo></mrow><annotation encoding="application/x-tex">\varphi_{\max }=\arcsin (n \lambda / d), n \in \mathbb{Z} . I \propto</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord"><span class="mord mathnormal">φ</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mop mtight"><span class="mtight">m</span><span class="mtight">a</span><span class="mtight">x</span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mop">arcsin</span><span class="mopen">(</span><span class="mord mathnormal">nλ</span><span class="mord">/</span><span class="mord mathnormal">d</span><span class="mclose">)</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">n</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">∈</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord mathbb">Z</span><span class="mord">.</span><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">∝</span></span></span></span> <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msup><mrow><mi>cos</mi><mo>⁡</mo></mrow><mn>2</mn></msup><mrow><mo fence="true">(</mo><mi>k</mi><mfrac><mi>a</mi><mn>2</mn></mfrac><mi>sin</mi><mo>⁡</mo><mi>φ</mi><mo fence="true">)</mo></mrow><mo separator="true">,</mo><mo stretchy="false">(</mo><mi>k</mi><mo>=</mo><mn>2</mn><mi>π</mi><mi mathvariant="normal">/</mi><mi>λ</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">\cos ^2\left(k \frac{a}{2} \sin \varphi\right),(k=2 \pi / \lambda)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2em;vertical-align:-0.35em;"></span><span class="mop"><span class="mop">cos</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size1">(</span></span><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6954em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">a</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">sin</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">φ</span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size1">)</span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">2</span><span class="mord mathnormal" style="margin-right:0.03588em;">π</span><span class="mord">/</span><span class="mord mathnormal">λ</span><span class="mclose">)</span></span></span></span></li>
</ol>
<h3 id="_7-3-単スリット-弱め合う角" tabindex="-1">7.3: 単スリット-弱め合う角 <a class="header-anchor" href="#_7-3-単スリット-弱め合う角" aria-label="Permalink to &quot;7.3: 単スリット-弱め合う角&quot;">&ZeroWidthSpace;</a></h3>
<ol start="3">
<li>単スリット:弱め合う角: <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>φ</mi><mtext>min </mtext></msub><mo>=</mo><mi>arcsin</mi><mo>⁡</mo><mo stretchy="false">(</mo><mi>n</mi><mi>λ</mi><mi mathvariant="normal">/</mi><mi>d</mi><mo stretchy="false">)</mo><mo separator="true">,</mo><mi>n</mi><mo>∈</mo></mrow><annotation encoding="application/x-tex">\varphi_{\text {min }}=\arcsin (n \lambda / d), n \in</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord"><span class="mord mathnormal">φ</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3175em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord text mtight"><span class="mord mtight">min </span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mop">arcsin</span><span class="mopen">(</span><span class="mord mathnormal">nλ</span><span class="mord">/</span><span class="mord mathnormal">d</span><span class="mclose">)</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">n</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">∈</span></span></span></span> <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="double-struck">Z</mi><mo separator="true">,</mo><mi>n</mi><mo mathvariant="normal">≠</mo><mn>0</mn></mrow><annotation encoding="application/x-tex">\mathbb{Z}, n \neq 0</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathbb">Z</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">n</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel"><span class="mrel"><span class="mord vbox"><span class="thinbox"><span class="rlap"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="inner"><span class="mord"><span class="mrel"></span></span></span><span class="fix"></span></span></span></span></span><span class="mrel">=</span></span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">0</span></span></span></span>. 中央の強め合う部分は <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>n</mi><mo>=</mo><mo>±</mo><mn>1</mn></mrow><annotation encoding="application/x-tex">n=\pm 1</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">n</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.7278em;vertical-align:-0.0833em;"></span><span class="mord">±</span><span class="mord">1</span></span></span></span> の間である ことに注意せよ. <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>I</mi><mo>∝</mo><msup><mrow><mi>sin</mi><mo>⁡</mo></mrow><mn>2</mn></msup><mrow><mo fence="true">(</mo><mi>k</mi><mfrac><mi>d</mi><mn>2</mn></mfrac><mi>sin</mi><mo>⁡</mo><mi>φ</mi><mo fence="true">)</mo></mrow><mi mathvariant="normal">/</mi><mi>sin</mi><mo>⁡</mo><mi>φ</mi></mrow><annotation encoding="application/x-tex">I \propto \sin ^2\left(k \frac{d}{2} \sin \varphi\right) / \sin \varphi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">∝</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.2301em;vertical-align:-0.35em;"></span><span class="mop"><span class="mop">sin</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8719em;"><span style="top:-3.1208em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size1">(</span></span><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8801em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">d</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">sin</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">φ</span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size1">)</span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord">/</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">sin</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">φ</span></span></span></span></li>
</ol>
<h3 id="_7-4-回折格子" tabindex="-1">7.4: 回折格子 <a class="header-anchor" href="#_7-4-回折格子" aria-label="Permalink to &quot;7.4: 回折格子&quot;">&ZeroWidthSpace;</a></h3>
<ol start="4">
<li>回折格子：主な強め合う角はポイント 2 と同じで, 主 な強め合う角の幅は <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>d</mi></mrow><annotation encoding="application/x-tex">d</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">d</span></span></span></span> を回折格子の正味の長さとすれ ばポイント 3 と同じ. <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>n</mi></mrow><annotation encoding="application/x-tex">n</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">n</span></span></span></span> 番目の明線のスペクトルの分 解能は，溝の総数を <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>N</mi></mrow><annotation encoding="application/x-tex">N</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.10903em;">N</span></span></span></span> 本として <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mfrac><mi>λ</mi><mrow><mi mathvariant="normal">Δ</mi><mi>λ</mi></mrow></mfrac><mo>=</mo><mi>n</mi><mi>N</mi></mrow><annotation encoding="application/x-tex">\frac{\lambda}{\Delta \lambda}=n N</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2251em;vertical-align:-0.345em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8801em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">Δ</span><span class="mord mathnormal mtight">λ</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">λ</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal">n</span><span class="mord mathnormal" style="margin-right:0.10903em;">N</span></span></span></span>.</li>
</ol>
<h3 id="_7-5-分光器の分解能" tabindex="-1">7.5: 分光器の分解能 <a class="header-anchor" href="#_7-5-分光器の分解能" aria-label="Permalink to &quot;7.5: 分光器の分解能&quot;">&ZeroWidthSpace;</a></h3>
<ol start="5">
<li>分光器の分解能 : 最短の光線と最長の光線の光学距離 の差を <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>L</mi></mrow><annotation encoding="application/x-tex">L</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal">L</span></span></span></span> として, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mfrac><mi>λ</mi><mrow><mi mathvariant="normal">Δ</mi><mi>λ</mi></mrow></mfrac><mo>=</mo><mfrac><mi>L</mi><mi>λ</mi></mfrac></mrow><annotation encoding="application/x-tex">\frac{\lambda}{\Delta \lambda}=\frac{L}{\lambda}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2251em;vertical-align:-0.345em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8801em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">Δ</span><span class="mord mathnormal mtight">λ</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">λ</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.2173em;vertical-align:-0.345em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8723em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">λ</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">L</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span>.</li>
</ol>
<h3 id="_7-6-プリズムの分解能" tabindex="-1">7.6: プリズムの分解能 <a class="header-anchor" href="#_7-6-プリズムの分解能" aria-label="Permalink to &quot;7.6: プリズムの分解能&quot;">&ZeroWidthSpace;</a></h3>
<ol start="7">
<li>プリズムの分解能 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>:</mo><mfrac><mi>λ</mi><mrow><mi mathvariant="normal">Δ</mi><mi>λ</mi></mrow></mfrac><mo>=</mo><mi>a</mi><mfrac><mrow><mi mathvariant="normal">d</mi><mi>n</mi></mrow><mrow><mrow><mtext> </mtext><mi mathvariant="normal">d</mi></mrow><mi>λ</mi></mrow></mfrac></mrow><annotation encoding="application/x-tex">: \frac{\lambda}{\Delta \lambda}=a \frac{\mathrm{d} n}{\mathrm{~d} \lambda}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mrel">:</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.2251em;vertical-align:-0.345em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8801em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">Δ</span><span class="mord mathnormal mtight">λ</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">λ</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.2251em;vertical-align:-0.345em;"></span><span class="mord mathnormal">a</span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8801em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight"><span class="mspace nobreak mtight"><span class="mtight"> </span></span><span class="mord mathrm mtight">d</span></span><span class="mord mathnormal mtight">λ</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathrm mtight">d</span><span class="mord mathnormal mtight">n</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span></li>
</ol>
<h3 id="_7-7-角度距離" tabindex="-1">7.7: 角度距離 <a class="header-anchor" href="#_7-7-角度距離" aria-label="Permalink to &quot;7.7: 角度距離&quot;">&ZeroWidthSpace;</a></h3>
<ol start="7">
<li>理想的な望遠鏡 (レンズ) で 2 点を解像するときの角度距離 : <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>φ</mi><mo>≈</mo><mn>1.22</mn><mi>λ</mi><mi mathvariant="normal">/</mi><mi>d</mi></mrow><annotation encoding="application/x-tex">\varphi \approx 1.22 \lambda / d</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6776em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">φ</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≈</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">1.22</span><span class="mord mathnormal">λ</span><span class="mord">/</span><span class="mord mathnormal">d</span></span></span></span>. この角度では, 一方の点の中 心が他方の点の最初の回折最小值に当たる.</li>
</ol>
<h3 id="_7-8-bragg-の法則" tabindex="-1">7.8: Bragg の法則 <a class="header-anchor" href="#_7-8-bragg-の法則" aria-label="Permalink to &quot;7.8: Bragg の法則&quot;">&ZeroWidthSpace;</a></h3>
<ol start="8">
<li>Bragg の法則：間隔が <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>d</mi></mrow><annotation encoding="application/x-tex">d</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">d</span></span></span></span> の平行な結晶面の組は, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>2</mn><mi>d</mi><mi>sin</mi><mo>⁡</mo><mi>θ</mi><mo>=</mo><mi>n</mi><mi>λ</mi></mrow><annotation encoding="application/x-tex">2 d \sin \theta=n \lambda</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">2</span><span class="mord mathnormal">d</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">sin</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.02778em;">θ</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">nλ</span></span></span></span> ならば <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">X</mi></mrow><annotation encoding="application/x-tex">\mathrm{X}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathrm">X</span></span></span></span> 線を反射する. ここで <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>θ</mi></mrow><annotation encoding="application/x-tex">\theta</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal" style="margin-right:0.02778em;">θ</span></span></span></span> は結 晶面と X 線がなす角 (かすめ角).</li>
</ol>
<h3 id="_7-9-高密度電体媒質反射" tabindex="-1">7.9: 高密度電体媒質反射 <a class="header-anchor" href="#_7-9-高密度電体媒質反射" aria-label="Permalink to &quot;7.9: 高密度電体媒質反射&quot;">&ZeroWidthSpace;</a></h3>
<ol start="9">
<li>光学的に高密度な誘電体媒質による反射 : 位相が <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>π</mi></mrow><annotation encoding="application/x-tex">\pi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">π</span></span></span></span> ず れる. 半透明の薄膜では <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>ϕ</mi><mo lspace="0em" rspace="0em">→</mo></msub><mo>+</mo><msub><mi>ϕ</mi><mo lspace="0em" rspace="0em">←</mo></msub><mo>=</mo><mi>π</mi></mrow><annotation encoding="application/x-tex">\phi_{\rightarrow}+\phi_{\leftarrow}=\pi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord"><span class="mord mathnormal">ϕ</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1068em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mrel mtight">→</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord"><span class="mord mathnormal">ϕ</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1068em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mrel mtight">←</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">π</span></span></span></span>. ここで <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>ϕ</mi><mo lspace="0em" rspace="0em">→</mo></msub></mrow><annotation encoding="application/x-tex">\phi_{\rightarrow}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord"><span class="mord mathnormal">ϕ</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1068em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mrel mtight">→</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> と <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>ϕ</mi><mo lspace="0em" rspace="0em">←</mo></msub></mrow><annotation encoding="application/x-tex">\phi_{\leftarrow}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord"><span class="mord mathnormal">ϕ</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1068em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mrel mtight">←</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> は反射波と透過波の位相差（矢印は入射方向を 示す)</li>
</ol>
<h3 id="_7-10-fabry-perot-干渉計" tabindex="-1">7.10: Fabry-Pérot 干渉計 <a class="header-anchor" href="#_7-10-fabry-perot-干渉計" aria-label="Permalink to &quot;7.10: Fabry-Pérot 干渉計&quot;">&ZeroWidthSpace;</a></h3>
<ol start="10">
<li>Fabry-Pérot 干渉計 : 高い反射率 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>r</mi><mo stretchy="false">(</mo><mn>1</mn><mo>−</mo><mi>r</mi><mo>≪</mo><mn>1</mn><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">r(1-r \ll 1)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.02778em;">r</span><span class="mopen">(</span><span class="mord">1</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mord mathnormal" style="margin-right:0.02778em;">r</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≪</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">1</span><span class="mclose">)</span></span></span></span> を持 つ 2 枚の平行な半透明の鏡. 分解能は <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mfrac><mi>ν</mi><mrow><mi mathvariant="normal">Δ</mi><mi>ν</mi></mrow></mfrac><mo>≈</mo><mfrac><mrow><mn>2</mn><mi>a</mi></mrow><mrow><mi>λ</mi><mo stretchy="false">(</mo><mn>1</mn><mo>−</mo><mi>r</mi><mo stretchy="false">)</mo></mrow></mfrac></mrow><annotation encoding="application/x-tex">\frac{\nu}{\Delta \nu} \approx \frac{2 a}{\lambda(1-r)}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0404em;vertical-align:-0.345em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6954em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">Δ</span><span class="mord mathnormal mtight" style="margin-right:0.06366em;">ν</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.06366em;">ν</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≈</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.3651em;vertical-align:-0.52em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8451em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">λ</span><span class="mopen mtight">(</span><span class="mord mtight">1</span><span class="mbin mtight">−</span><span class="mord mathnormal mtight" style="margin-right:0.02778em;">r</span><span class="mclose mtight">)</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span><span class="mord mathnormal mtight">a</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.52em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span>. 5 つの平面波 (干渉計の前で左右に進む波, 内部を左右 に進む波，後ろを進む波）を設定して境界条件を課す ことで，透過スペクトルを求められる.</li>
</ol>
<h3 id="_7-11-コヒーレントな電磁波" tabindex="-1">7.11: コヒーレントな電磁波 <a class="header-anchor" href="#_7-11-コヒーレントな電磁波" aria-label="Permalink to &quot;7.11: コヒーレントな電磁波&quot;">&ZeroWidthSpace;</a></h3>
<ol start="11">
<li>コヒーレントな電磁波: 電場をベクトル为で表し, ベク トル間の角度を位相差とする. 屈折率が <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>n</mi><mo>=</mo><mi>n</mi><mo stretchy="false">(</mo><mi>ω</mi><mo stretchy="false">)</mo><mo>=</mo></mrow><annotation encoding="application/x-tex">n=n(\omega)=</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">n</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal">n</span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.03588em;">ω</span><span class="mclose">)</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span></span></span></span> <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msqrt><mrow><mi>ε</mi><mo stretchy="false">(</mo><mi>ω</mi><mo stretchy="false">)</mo></mrow></msqrt></mrow><annotation encoding="application/x-tex">\sqrt{\varepsilon(\omega)}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.24em;vertical-align:-0.305em;"></span><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.935em;"><span class="svg-align" style="top:-3.2em;"><span class="pstrut" style="height:3.2em;"></span><span class="mord" style="padding-left:1em;"><span class="mord mathnormal">ε</span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.03588em;">ω</span><span class="mclose">)</span></span></span><span style="top:-2.895em;"><span class="pstrut" style="height:3.2em;"></span><span class="hide-tail" style="min-width:1.02em;height:1.28em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='1.28em' viewBox='0 0 400000 1296' preserveAspectRatio='xMinYMin slice'><path d='M263,681c0.7,0,18,39.7,52,119
c34,79.3,68.167,158.7,102.5,238c34.3,79.3,51.8,119.3,52.5,120
c340,-704.7,510.7,-1060.3,512,-1067
l0 -0
c4.7,-7.3,11,-11,19,-11
H40000v40H1012.3
s-271.3,567,-271.3,567c-38.7,80.7,-84,175,-136,283c-52,108,-89.167,185.3,-111.5,232
c-22.3,46.7,-33.8,70.3,-34.5,71c-4.7,4.7,-12.3,7,-23,7s-12,-1,-12,-1
s-109,-253,-109,-253c-72.7,-168,-109.3,-252,-110,-252c-10.7,8,-22,16.7,-34,26
c-22,17.3,-33.3,26,-34,26s-26,-26,-26,-26s76,-59,76,-59s76,-60,76,-60z
M1001 80h400000v40h-400000z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.305em;"><span></span></span></span></span></span></span></span></span> (普通 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>μ</mi><mo>≈</mo><mn>1</mn></mrow><annotation encoding="application/x-tex">\mu \approx 1</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6776em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">μ</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≈</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">1</span></span></span></span> ) であることに注意せよ. エネ ルギー流密度（単位面積を通過する単位時間あたりの エネルギー）: <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>I</mi><mo>=</mo><mi>c</mi><mi>n</mi><msub><mi>ε</mi><mn>0</mn></msub><msup><mi>E</mi><mn>2</mn></msup><mo>=</mo><mfrac><mi>c</mi><mrow><mi>n</mi><msub><mi>μ</mi><mn>0</mn></msub></mrow></mfrac><msup><mi>B</mi><mn>2</mn></msup><mo stretchy="false">(</mo><mi>E</mi></mrow><annotation encoding="application/x-tex">I=c n \varepsilon_0 E^2=\frac{c}{n \mu_0} B^2(E</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.9641em;vertical-align:-0.15em;"></span><span class="mord mathnormal">c</span><span class="mord mathnormal">n</span><span class="mord"><span class="mord mathnormal">ε</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">0</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.05764em;">E</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.2952em;vertical-align:-0.4811em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6954em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">n</span><span class="mord mtight"><span class="mord mathnormal mtight">μ</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3173em;"><span style="top:-2.357em;margin-left:0em;margin-right:0.0714em;"><span class="pstrut" style="height:2.5em;"></span><span class="sizing reset-size3 size1 mtight"><span class="mord mtight">0</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.143em;"><span></span></span></span></span></span></span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">c</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.4811em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.05017em;">B</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.05764em;">E</span></span></span></span> と <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>B</mi></mrow><annotation encoding="application/x-tex">B</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span></span> は実 効值)</li>
</ol>
<h3 id="_7-12-malus-の法則" tabindex="-1">7.12: Malus の法則 <a class="header-anchor" href="#_7-12-malus-の法則" aria-label="Permalink to &quot;7.12: Malus の法則&quot;">&ZeroWidthSpace;</a></h3>
<ol start="12">
<li>Malus の法則 : 直線偏光が角度 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>φ</mi></mrow><annotation encoding="application/x-tex">\varphi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">φ</span></span></span></span> で偏光板を通過する と <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>I</mi><mo>=</mo><msub><mi>I</mi><mn>0</mn></msub><msup><mrow><mi>cos</mi><mo>⁡</mo></mrow><mn>2</mn></msup><mi>φ</mi></mrow><annotation encoding="application/x-tex">I=I_0 \cos ^2 \varphi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.0085em;vertical-align:-0.1944em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0785em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">0</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop"><span class="mop">cos</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">φ</span></span></span></span></li>
</ol>
<h3 id="_7-13-1-4-波長版" tabindex="-1">7.13: 1/4 波長版 <a class="header-anchor" href="#_7-13-1-4-波長版" aria-label="Permalink to &quot;7.13: 1/4 波長版&quot;">&ZeroWidthSpace;</a></h3>
<ol start="13">
<li><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>1</mn><mi mathvariant="normal">/</mi><mn>4</mn></mrow><annotation encoding="application/x-tex">1 / 4</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">1/4</span></span></span></span> 波長版 : 直線偏光成分間の位相が <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>π</mi><mi mathvariant="normal">/</mi><mn>2</mn></mrow><annotation encoding="application/x-tex">\pi / 2</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">π</span><span class="mord">/2</span></span></span></span> ずれる.</li>
</ol>
<h3 id="_7-14-brewster-角" tabindex="-1">7.14: Brewster 角 <a class="header-anchor" href="#_7-14-brewster-角" aria-label="Permalink to &quot;7.14: Brewster 角&quot;">&ZeroWidthSpace;</a></h3>
<ol start="14">
<li>Brewster 角: 入射角が <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>tan</mi><mo>⁡</mo><mi>φ</mi><mo>=</mo><mi>n</mi></mrow><annotation encoding="application/x-tex">\tan \varphi=n</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8095em;vertical-align:-0.1944em;"></span><span class="mop">tan</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">φ</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">n</span></span></span></span> を満たすとき, 反 射波と屈折波が垂直になり反射波は直線偏光となる.</li>
</ol>
<h3 id="_7-15-光学素子による回折" tabindex="-1">7.15: 光学素子による回折 <a class="header-anchor" href="#_7-15-光学素子による回折" aria-label="Permalink to &quot;7.15: 光学素子による回折&quot;">&ZeroWidthSpace;</a></h3>
<ol start="15">
<li>光学素子による回折 : レンズやプリズムなどを通る光 の光学距離を計算する必要はなく, 図形的に考える. 例えば，双プリズムは二重スリットによる回折と同じ 回折をする.</li>
</ol>
<h3 id="_7-16-光ファイバー" tabindex="-1">7.16: 光ファイバー <Badge type="tip" text="supplemental" /> <a class="header-anchor" href="#_7-16-光ファイバー" aria-label="Permalink to &quot;7.16: 光ファイバー &lt;Badge type=&quot;tip&quot; text=&quot;supplemental&quot; /&gt;&quot;">&ZeroWidthSpace;</a></h3>
<ol start="17">
<li>光ファイバー：Mach-Zehnder 干渉計は二重スリッ トによる干渉と, 円形共振器は Fabry-Pérot 干渉計 と似ている. Bragg フィルターは <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">X</mi></mrow><annotation encoding="application/x-tex">\mathrm{X}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathrm">X</span></span></span></span> 線の場合と同 じように働く. シングルモードの光ファイバーでは, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Δ</mi><mi>n</mi><mi mathvariant="normal">/</mi><mi>n</mi><mo>≈</mo><mfrac><mn>1</mn><mn>2</mn></mfrac><mo stretchy="false">(</mo><mi>λ</mi><mi mathvariant="normal">/</mi><mi>d</mi><msup><mo stretchy="false">)</mo><mn>2</mn></msup></mrow><annotation encoding="application/x-tex">\Delta n / n \approx \frac{1}{2}(\lambda / d)^2</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">Δ</span><span class="mord mathnormal">n</span><span class="mord">/</span><span class="mord mathnormal">n</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≈</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.1901em;vertical-align:-0.345em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8451em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">1</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mopen">(</span><span class="mord mathnormal">λ</span><span class="mord">/</span><span class="mord mathnormal">d</span><span class="mclose"><span class="mclose">)</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span></span>.</li>
</ol>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Formulas for IPhO 日本語版: Section 8 ]]></title>
            <link>https://note.toshiki.devacademic/physics/ipho-formulas-jpn/8</link>
            <guid>https://note.toshiki.devacademic/physics/ipho-formulas-jpn/8</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="formulas-for-ipho-日本語版-section-8" tabindex="-1">Formulas for IPhO 日本語版: Section 8 <a class="header-anchor" href="#formulas-for-ipho-日本語版-section-8" aria-label="Permalink to &quot;Formulas for IPhO 日本語版: Section 8&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="_8-電気回路" tabindex="-1">8: 電気回路 <a class="header-anchor" href="#_8-電気回路" aria-label="Permalink to &quot;8: 電気回路&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="_8-1-v-i-r-p-v-i" tabindex="-1">8.1: V=I R, P=V I <a class="header-anchor" href="#_8-1-v-i-r-p-v-i" aria-label="Permalink to &quot;8.1: V=I R, P=V I&quot;">&ZeroWidthSpace;</a></h3>
<ol>
<li><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>V</mi><mo>=</mo><mi>I</mi><mi>R</mi><mo separator="true">,</mo><mi>P</mi><mo>=</mo><mi>V</mi><mi>I</mi></mrow><annotation encoding="application/x-tex">V=I R, P=V I</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.22222em;">V</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8778em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="mord mathnormal" style="margin-right:0.00773em;">R</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.13889em;">P</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.22222em;">V</span><span class="mord mathnormal" style="margin-right:0.07847em;">I</span></span></span></span><p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><msub><mi>R</mi><mtext>直列 </mtext></msub><mo>=</mo><mo>∑</mo><msub><mi>R</mi><mi>i</mi></msub><mo separator="true">,</mo><msubsup><mi>R</mi><mtext>並列 </mtext><mrow><mo>−</mo><mn>1</mn></mrow></msubsup><mo>=</mo><mo>∑</mo><msubsup><mi>R</mi><mi>i</mi><mrow><mo>−</mo><mn>1</mn></mrow></msubsup></mrow><annotation encoding="application/x-tex">R_{\text {直列 }}=\sum R_i, R_{\text {並列 }}^{-1}=\sum R_i^{-1}
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.00773em;">R</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-left:-0.0077em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord text mtight"><span class="mord cjk_fallback mtight">直列</span><span class="mord mtight"> </span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.6em;vertical-align:-0.55em;"></span><span class="mop op-symbol large-op" style="position:relative;top:0em;">∑</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.00773em;">R</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:-0.0077em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.00773em;">R</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-2.4163em;margin-left:-0.0077em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord text mtight"><span class="mord cjk_fallback mtight">並列</span><span class="mord mtight"> </span></span></span></span></span><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">−</span><span class="mord mtight">1</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2837em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.6em;vertical-align:-0.55em;"></span><span class="mop op-symbol large-op" style="position:relative;top:0em;">∑</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.00773em;">R</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-2.433em;margin-left:-0.0077em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">−</span><span class="mord mtight">1</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.267em;"><span></span></span></span></span></span></span></span></span></span></span></p>
</li>
</ol>
<h3 id="_8-2-kirchhoff-の法則" tabindex="-1">8.2: Kirchhoff の法則 <a class="header-anchor" href="#_8-2-kirchhoff-の法則" aria-label="Permalink to &quot;8.2: Kirchhoff の法則&quot;">&ZeroWidthSpace;</a></h3>
<ol start="2">
<li>Kirchhoff の法則 :<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><munder><mo>∑</mo><mstyle scriptlevel="1"><mtable rowspacing="0.1em" columnalign="center" columnspacing="1em"><mtr><mtd><mstyle scriptlevel="1" displaystyle="false"><mtext> 節点 </mtext></mstyle></mtd></mtr></mtable></mstyle></munder><mi>I</mi><mo>=</mo><mn>0</mn><mo separator="true">,</mo><munder><mo>∑</mo><mtext>閉路 </mtext></munder><mi>V</mi><mo>=</mo><mn>0</mn></mrow><annotation encoding="application/x-tex">\sum_{\substack{\text { 節点 }}} I=0, \sum_{\text {閉路 }} V=0
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.4703em;vertical-align:-1.4203em;"></span><span class="mop op-limits"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.05em;"><span style="top:-1.8568em;margin-left:0em;"><span class="pstrut" style="height:3.05em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight"><span class="mtable"><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6817em;"><span style="top:-2.6983em;"><span class="pstrut" style="height:2.7em;"></span><span class="mord mtight"><span class="mord text mtight"><span class="mord mtight"> </span><span class="mord cjk_fallback mtight">節点</span><span class="mord mtight"> </span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.1817em;"><span></span></span></span></span></span></span></span></span></span></span><span style="top:-3.05em;"><span class="pstrut" style="height:3.05em;"></span><span><span class="mop op-symbol large-op">∑</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.4203em;"><span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:2.3443em;vertical-align:-1.2943em;"></span><span class="mord">0</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop op-limits"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.05em;"><span style="top:-1.8557em;margin-left:0em;"><span class="pstrut" style="height:3.05em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord text mtight"><span class="mord cjk_fallback mtight">閉路</span><span class="mord mtight"> </span></span></span></span></span><span style="top:-3.05em;"><span class="pstrut" style="height:3.05em;"></span><span><span class="mop op-symbol large-op">∑</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.2943em;"><span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.22222em;">V</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">0</span></span></span></span></span></p>
</li>
</ol>
<h3 id="_8-3-ポイント-2-の方程式を減らすために" tabindex="-1">8.3: ポイント 2 の方程式を減らすために <a class="header-anchor" href="#_8-3-ポイント-2-の方程式を減らすために" aria-label="Permalink to &quot;8.3: ポイント 2 の方程式を減らすために&quot;">&ZeroWidthSpace;</a></h3>
<ol start="3">
<li>ポイント 2 の方程式を減らすために: 節点電位法. ルー プ電流法. 等価回路 (3 端子の場合 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇒</mo><mi mathvariant="normal">△</mi><mtext>又</mtext></mrow><annotation encoding="application/x-tex">\Rightarrow \triangle 又</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">⇒</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord">△</span><span class="mord cjk_fallback">又</span></span></span></span> 又 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>Y</mi></mrow><annotation encoding="application/x-tex">Y</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.22222em;">Y</span></span></span></span> の形, 起電力のある 2 端子の場合 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇒</mo></mrow><annotation encoding="application/x-tex">\Rightarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">⇒</span></span></span></span> 抵抗と電池の直列)</li>
</ol>
<h3 id="_8-4-無限につながる抵抗" tabindex="-1">8.4: 無限につながる抵抗 <a class="header-anchor" href="#_8-4-無限につながる抵抗" aria-label="Permalink to &quot;8.4: 無限につながる抵抗&quot;">&ZeroWidthSpace;</a></h3>
<ol start="4">
<li>無限につながる抵抗 : 無限に続く格子の隣り合う節点 間で，自己相似性を使う。鏡像法の一般化された方法.</li>
</ol>
<h3 id="_8-5-交流回路" tabindex="-1">8.5: 交流回路 <a class="header-anchor" href="#_8-5-交流回路" aria-label="Permalink to &quot;8.5: 交流回路&quot;">&ZeroWidthSpace;</a></h3>
<ol start="5">
<li>交流回路: <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>R</mi></mrow><annotation encoding="application/x-tex">R</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.00773em;">R</span></span></span></span> を <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>Z</mi></mrow><annotation encoding="application/x-tex">Z</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.07153em;">Z</span></span></span></span> に置き換えてポイント <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>1</mn><mo>∼</mo><mn>4</mn></mrow><annotation encoding="application/x-tex">1 \sim 4</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">1</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">∼</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">4</span></span></span></span> を用 いる.<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mtable rowspacing="0.25em" columnalign="center" columnspacing="0em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><msub><mi>Z</mi><mi>R</mi></msub><mo>=</mo><mi>R</mi><mo separator="true">,</mo><msub><mi>Z</mi><mi>C</mi></msub><mo>=</mo><mn>1</mn><mi mathvariant="normal">/</mi><mi>i</mi><mi>ω</mi><mi>C</mi><mo separator="true">,</mo><msub><mi>Z</mi><mi>L</mi></msub><mo>=</mo><mi>i</mi><mi>ω</mi><mi>L</mi></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mi>φ</mi><mo>=</mo><mi>arg</mi><mo>⁡</mo><mi>Z</mi><mo separator="true">,</mo><msub><mi>V</mi><mtext>eff </mtext></msub><mo>=</mo><mi mathvariant="normal">∣</mi><mi>Z</mi><mi mathvariant="normal">∣</mi><msub><mi>I</mi><mtext>eff </mtext></msub></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mi>P</mi><mo>=</mo><mi mathvariant="normal">∣</mi><mi>V</mi><mi mathvariant="normal">∣</mi><mi mathvariant="normal">∣</mi><mi>I</mi><mi mathvariant="normal">∣</mi><mi>cos</mi><mo>⁡</mo><mo stretchy="false">(</mo><mi>arg</mi><mo>⁡</mo><mi>Z</mi><mo stretchy="false">)</mo><mo>=</mo><mo>∑</mo><msubsup><mi>I</mi><mi>i</mi><mn>2</mn></msubsup><msub><mi>R</mi><mi>i</mi></msub></mrow></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{gathered}
Z_R=R, Z_C=1 / i \omega C, Z_L=i \omega L \\
\varphi=\arg Z, V_{\text {eff }}=|Z| I_{\text {eff }} \\
P=|V||I| \cos (\arg Z)=\sum I_i^2 R_i
\end{gathered}
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:4.9em;vertical-align:-2.2em;"></span><span class="mord"><span class="mtable"><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:2.7em;"><span style="top:-4.91em;"><span class="pstrut" style="height:3.05em;"></span><span class="mord"><span class="mord"><span class="mord mathnormal" style="margin-right:0.07153em;">Z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-left:-0.0715em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.00773em;">R</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord mathnormal" style="margin-right:0.00773em;">R</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.07153em;">Z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-left:-0.0715em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.07153em;">C</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord">1/</span><span class="mord mathnormal" style="margin-right:0.03588em;">iω</span><span class="mord mathnormal" style="margin-right:0.07153em;">C</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.07153em;">Z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-left:-0.0715em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">L</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">iω</span><span class="mord mathnormal">L</span></span></span><span style="top:-3.41em;"><span class="pstrut" style="height:3.05em;"></span><span class="mord"><span class="mord mathnormal">φ</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mop">ar<span style="margin-right:0.01389em;">g</span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.07153em;">Z</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.22222em;">V</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3361em;"><span style="top:-2.55em;margin-left:-0.2222em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord text mtight"><span class="mord mtight">eff </span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord">∣</span><span class="mord mathnormal" style="margin-right:0.07153em;">Z</span><span class="mord">∣</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3361em;"><span style="top:-2.55em;margin-left:-0.0785em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord text mtight"><span class="mord mtight">eff </span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span><span style="top:-1.7em;"><span class="pstrut" style="height:3.05em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.13889em;">P</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord">∣</span><span class="mord mathnormal" style="margin-right:0.22222em;">V</span><span class="mord">∣∣</span><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="mord">∣</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">cos</span><span class="mopen">(</span><span class="mop">ar<span style="margin-right:0.01389em;">g</span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.07153em;">Z</span><span class="mclose">)</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mop op-symbol large-op" style="position:relative;top:0em;">∑</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-2.453em;margin-left:-0.0785em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.247em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.00773em;">R</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:-0.0077em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:2.2em;"><span></span></span></span></span></span></span></span></span></span></span></span></p>
</li>
</ol>
<h3 id="_8-6-特性時間" tabindex="-1">8.6: 特性時間 <a class="header-anchor" href="#_8-6-特性時間" aria-label="Permalink to &quot;8.6: 特性時間&quot;">&ZeroWidthSpace;</a></h3>
<ol start="6">
<li>特性時間: <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>τ</mi><mrow><mi>R</mi><mi>C</mi></mrow></msub><mo>=</mo><mi>R</mi><mi>C</mi><mo separator="true">,</mo><msub><mi>τ</mi><mrow><mi>L</mi><mi>R</mi></mrow></msub><mo>=</mo><mi>L</mi><mi mathvariant="normal">/</mi><mi>R</mi><mi mathvariant="normal">.</mi><msub><mi>ω</mi><mrow><mi>L</mi><mi>C</mi></mrow></msub><mo>=</mo></mrow><annotation encoding="application/x-tex">\tau_{R C}=R C, \tau_{L R}=L / R . \omega_{L C}=</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.1132em;">τ</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-left:-0.1132em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.07153em;">RC</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8778em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.07153em;">RC</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.1132em;">τ</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-left:-0.1132em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">L</span><span class="mord mathnormal mtight" style="margin-right:0.00773em;">R</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal">L</span><span class="mord">/</span><span class="mord mathnormal" style="margin-right:0.00773em;">R</span><span class="mord">.</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">ω</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">L</span><span class="mord mathnormal mtight" style="margin-right:0.07153em;">C</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span></span></span></span> <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>1</mn><mi mathvariant="normal">/</mi><msqrt><mrow><mi>L</mi><mi>C</mi></mrow></msqrt></mrow><annotation encoding="application/x-tex">1 / \sqrt{L C}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1767em;vertical-align:-0.25em;"></span><span class="mord">1/</span><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.9267em;"><span class="svg-align" style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord" style="padding-left:0.833em;"><span class="mord mathnormal">L</span><span class="mord mathnormal" style="margin-right:0.07153em;">C</span></span></span><span style="top:-2.8867em;"><span class="pstrut" style="height:3em;"></span><span class="hide-tail" style="min-width:0.853em;height:1.08em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='1.08em' viewBox='0 0 400000 1080' preserveAspectRatio='xMinYMin slice'><path d='M95,702
c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14
c0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54
c44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10
s173,378,173,378c0.7,0,35.3,-71,104,-213c68.7,-142,137.5,-285,206.5,-429
c69,-144,104.5,-217.7,106.5,-221
l0 -0
c5.3,-9.3,12,-14,20,-14
H400000v40H845.2724
s-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7
c-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z
M834 80h400000v40h-400000z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.1133em;"><span></span></span></span></span></span></span></span></span>. 定常的な電流分布への緩和は指数関数的で <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∝</mo><msup><mi>e</mi><mrow><mo>−</mo><mi>t</mi><mi mathvariant="normal">/</mi><mi>τ</mi></mrow></msup></mrow><annotation encoding="application/x-tex">\propto e^{-t / \tau}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mrel">∝</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.888em;"></span><span class="mord"><span class="mord mathnormal">e</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.888em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">−</span><span class="mord mathnormal mtight">t</span><span class="mord mtight">/</span><span class="mord mathnormal mtight" style="margin-right:0.1132em;">τ</span></span></span></span></span></span></span></span></span></span></span></span></li>
</ol>
<h3 id="_8-7-電気回路のエネルギー保存則" tabindex="-1">8.7: 電気回路のエネルギー保存則 <a class="header-anchor" href="#_8-7-電気回路のエネルギー保存則" aria-label="Permalink to &quot;8.7: 電気回路のエネルギー保存則&quot;">&ZeroWidthSpace;</a></h3>
<ol start="8">
<li>電気回路のエネルギー保存則 : <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Δ</mi><mi>W</mi><mo>+</mo><mi>Q</mi><mo>=</mo><mi>q</mi><mi>V</mi></mrow><annotation encoding="application/x-tex">\Delta W+Q=q V</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7667em;vertical-align:-0.0833em;"></span><span class="mord">Δ</span><span class="mord mathnormal" style="margin-right:0.13889em;">W</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.8778em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">Q</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8778em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">q</span><span class="mord mathnormal" style="margin-right:0.22222em;">V</span></span></span></span>. ここ で <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi></mrow><annotation encoding="application/x-tex">q</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">q</span></span></span></span> は電圧降下 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>V</mi></mrow><annotation encoding="application/x-tex">V</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.22222em;">V</span></span></span></span> を通った電気量で, 電源のする仕事 は <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>A</mi><mo>=</mo><mi>q</mi><msub><mi>V</mi><mrow><mi mathvariant="normal">e</mi><mi mathvariant="normal">m</mi><mi mathvariant="normal">f</mi></mrow></msub></mrow><annotation encoding="application/x-tex">A=q V_{\mathrm{emf}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal">A</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8778em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">q</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.22222em;">V</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3361em;"><span style="top:-2.55em;margin-left:-0.2222em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight"><span class="mord mathrm mtight" style="margin-right:0.07778em;">emf</span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span></li>
</ol>
<h3 id="_8-8-コンデンサーの位置エネルギー式" tabindex="-1">8.8: コンデンサーの位置エネルギー式 <a class="header-anchor" href="#_8-8-コンデンサーの位置エネルギー式" aria-label="Permalink to &quot;8.8: コンデンサーの位置エネルギー式&quot;">&ZeroWidthSpace;</a></h3>
<ol start="8">
<li>コンデンサーの位置エネルギー式:
<span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>W</mi><mi>C</mi></msub><mo>=</mo><mi>C</mi><msup><mi>V</mi><mn>2</mn></msup><mi mathvariant="normal">/</mi><mn>2</mn><mo separator="true">,</mo><msub><mi>W</mi><mi>L</mi></msub><mo>=</mo><mi>L</mi><msup><mi>I</mi><mn>2</mn></msup><mi mathvariant="normal">/</mi><mn>2</mn></mrow><annotation encoding="application/x-tex">W_C=C V^2 / 2, W_L=L I^2 / 2</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.13889em;">W</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-left:-0.1389em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.07153em;">C</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.0641em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.07153em;">C</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.22222em;">V</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mord">/2</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.13889em;">W</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-left:-0.1389em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">L</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.0641em;vertical-align:-0.25em;"></span><span class="mord mathnormal">L</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mord">/2</span></span></span></span>.</li>
</ol>
<h3 id="_8-9-磁束密度" tabindex="-1">8.9: 磁束密度 <a class="header-anchor" href="#_8-9-磁束密度" aria-label="Permalink to &quot;8.9: 磁束密度&quot;">&ZeroWidthSpace;</a></h3>
<ol start="9">
<li><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>V</mi><mrow><mi mathvariant="normal">e</mi><mi mathvariant="normal">m</mi><mi mathvariant="normal">f</mi></mrow></msub><mo>=</mo><mo>−</mo><mi mathvariant="normal">d</mi><mi mathvariant="normal">Φ</mi><mi mathvariant="normal">/</mi><mi mathvariant="normal">d</mi><mi>t</mi><mo>=</mo><mi mathvariant="normal">d</mi><mo stretchy="false">(</mo><mi>L</mi><mi>I</mi><mo stretchy="false">)</mo><mi mathvariant="normal">/</mi><mi mathvariant="normal">d</mi><mi>t</mi><mo separator="true">,</mo><mi mathvariant="normal">Φ</mi><mo>=</mo><mi>B</mi><mi>S</mi></mrow><annotation encoding="application/x-tex">V_{\mathrm{emf}}=-\mathrm{d} \Phi / \mathrm{d} t=\mathrm{d}(L I) / \mathrm{d} t, \Phi=B S</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.22222em;">V</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3361em;"><span style="top:-2.55em;margin-left:-0.2222em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight"><span class="mord mathrm mtight" style="margin-right:0.07778em;">emf</span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">−</span><span class="mord mathrm">d</span><span class="mord">Φ/</span><span class="mord mathrm">d</span><span class="mord mathnormal">t</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathrm">d</span><span class="mopen">(</span><span class="mord mathnormal">L</span><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="mclose">)</span><span class="mord">/</span><span class="mord mathrm">d</span><span class="mord mathnormal">t</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord">Φ</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.05764em;">BS</span></span></span></span>.</li>
</ol>
<h3 id="_8-10-非線形素子" tabindex="-1">8.10: 非線形素子 <a class="header-anchor" href="#_8-10-非線形素子" aria-label="Permalink to &quot;8.10: 非線形素子&quot;">&ZeroWidthSpace;</a></h3>
<ol start="10">
<li>非 線形素子: <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>V</mi><mo>−</mo><mi>I</mi></mrow><annotation encoding="application/x-tex">V-I</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7667em;vertical-align:-0.0833em;"></span><span class="mord mathnormal" style="margin-right:0.22222em;">V</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.07847em;">I</span></span></span></span> グラフでの非線形曲線と Ohm/Kirchhoff の法則を表す直線との交点として 为形的に解を求める. 複数の交点があれば安定性を調 ベる. いくつかの解は普通安定でない.</li>
</ol>
<h3 id="_8-11-短時間と長時間の極限を利用" tabindex="-1">8.11: 短時間と長時間の極限を利用 <a class="header-anchor" href="#_8-11-短時間と長時間の極限を利用" aria-label="Permalink to &quot;8.11: 短時間と長時間の極限を利用&quot;">&ZeroWidthSpace;</a></h3>
<ol start="11">
<li>短時間と長時間の極限を利用する: <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>t</mi><mtext>observation </mtext></msub><mo>≫</mo></mrow><annotation encoding="application/x-tex">t_{\text {observation }} \gg</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7651em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal">t</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3361em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord text mtight"><span class="mord mtight">observation </span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≫</span></span></span></span> <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>τ</mi><mrow><mi>R</mi><mi>C</mi></mrow></msub></mrow><annotation encoding="application/x-tex">\tau_{R C}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.1132em;">τ</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-left:-0.1132em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.07153em;">RC</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> or <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>τ</mi><mrow><mi>L</mi><mi>R</mi></mrow></msub></mrow><annotation encoding="application/x-tex">\tau_{L R}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.1132em;">τ</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-left:-0.1132em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">L</span><span class="mord mathnormal mtight" style="margin-right:0.00773em;">R</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> ならば, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>I</mi><mi>C</mi></msub><mo>≈</mo><mn>0</mn><mo stretchy="false">(</mo><mi>C</mi></mrow><annotation encoding="application/x-tex">I_C \approx 0(C</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-left:-0.0785em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.07153em;">C</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≈</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">0</span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.07153em;">C</span></span></span></span> は断線している）又 は <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>V</mi><mi>L</mi></msub><mo>≈</mo><mn>0</mn></mrow><annotation encoding="application/x-tex">V_L \approx 0</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.22222em;">V</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-left:-0.2222em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">L</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≈</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">0</span></span></span></span> ( <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>L</mi></mrow><annotation encoding="application/x-tex">L</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal">L</span></span></span></span> は短絡している）のような準平衡状態に 達する. <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>t</mi><mtext>observation </mtext></msub><mo>≪</mo><msub><mi>τ</mi><mrow><mi>R</mi><mi>C</mi></mrow></msub></mrow><annotation encoding="application/x-tex">t_{\text {observation }} \ll \tau_{R C}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7651em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal">t</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3361em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord text mtight"><span class="mord mtight">observation </span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≪</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.1132em;">τ</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-left:-0.1132em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.07153em;">RC</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> or <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>τ</mi><mrow><mi>L</mi><mi>R</mi></mrow></msub></mrow><annotation encoding="application/x-tex">\tau_{L R}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.1132em;">τ</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-left:-0.1132em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">L</span><span class="mord mathnormal mtight" style="margin-right:0.00773em;">R</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> ならば, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>C</mi></mrow><annotation encoding="application/x-tex">C</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.07153em;">C</span></span></span></span> の電 気量の変化や <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>L</mi></mrow><annotation encoding="application/x-tex">L</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal">L</span></span></span></span> での電流の変化は小さく, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Δ</mi><mi>Q</mi><mo>≪</mo><mi>Q</mi></mrow><annotation encoding="application/x-tex">\Delta Q \ll Q</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8778em;vertical-align:-0.1944em;"></span><span class="mord">Δ</span><span class="mord mathnormal">Q</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≪</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8778em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">Q</span></span></span></span> や <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Δ</mi><mi>I</mi><mo>≪</mo><mi>I</mi></mrow><annotation encoding="application/x-tex">\Delta I \ll I</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7224em;vertical-align:-0.0391em;"></span><span class="mord">Δ</span><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≪</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.07847em;">I</span></span></span></span>. 即ち <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>C</mi></mrow><annotation encoding="application/x-tex">C</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.07153em;">C</span></span></span></span> は短絡していて <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>L</mi></mrow><annotation encoding="application/x-tex">L</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal">L</span></span></span></span> は断線して いる.</li>
</ol>
<h3 id="_8-12-推論" tabindex="-1">8.12: 推論 <a class="header-anchor" href="#_8-12-推論" aria-label="Permalink to &quot;8.12: 推論&quot;">&ZeroWidthSpace;</a></h3>
<ol start="12">
<li><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>L</mi><mo mathvariant="normal">≠</mo><mn>0</mn></mrow><annotation encoding="application/x-tex">L \neq 0</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">L</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel"><span class="mrel"><span class="mord vbox"><span class="thinbox"><span class="rlap"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="inner"><span class="mord"><span class="mrel"></span></span></span><span class="fix"></span></span></span></span></span><span class="mrel">=</span></span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">0</span></span></span></span> ならば, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>I</mi><mo stretchy="false">(</mo><mi>t</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">I(t)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="mopen">(</span><span class="mord mathnormal">t</span><span class="mclose">)</span></span></span></span> は連続.</li>
</ol>
<h3 id="_8-13-超電導の回路" tabindex="-1">8.13: 超電導の回路 <a class="header-anchor" href="#_8-13-超電導の回路" aria-label="Permalink to &quot;8.13: 超電導の回路&quot;">&ZeroWidthSpace;</a></h3>
<ol start="13">
<li>超電導の回路について, 磁束 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Φ</mi><mo>=</mo></mrow><annotation encoding="application/x-tex">\Phi=</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">Φ</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span></span></span></span> const.. 特に, 外部 磁場が無ければ <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>L</mi><mi>I</mi><mo>=</mo></mrow><annotation encoding="application/x-tex">L I=</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal">L</span><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span></span></span></span> const.</li>
</ol>
<h3 id="_8-14-相互誘導" tabindex="-1">8.14: 相互誘導 <a class="header-anchor" href="#_8-14-相互誘導" aria-label="Permalink to &quot;8.14: 相互誘導&quot;">&ZeroWidthSpace;</a></h3>
<ol start="14">
<li>相互誘導 : 回路 1 を通る磁束は <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi mathvariant="normal">Φ</mi><mn>1</mn></msub><mo>=</mo><msub><mi>L</mi><mn>1</mn></msub><msub><mi>I</mi><mn>1</mn></msub><mo>+</mo><msub><mi>L</mi><mn>12</mn></msub><msub><mi>I</mi><mn>2</mn></msub></mrow><annotation encoding="application/x-tex">\Phi_1=L_1 I_1+L_{12} I_2</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord">Φ</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal">L</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0785em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal">L</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">12</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0785em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> ( <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>I</mi><mn>2</mn></msub></mrow><annotation encoding="application/x-tex">I_2</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0785em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> は回路 2 を流れる電流) で, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>L</mi><mn>12</mn></msub><mo>=</mo><msub><mi>L</mi><mn>21</mn></msub><mo>≡</mo><mi>M</mi></mrow><annotation encoding="application/x-tex">L_{12}=L_{21} \equiv M</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal">L</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">12</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal">L</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">21</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≡</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.10903em;">M</span></span></span></span> と <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>M</mi><mo>≤</mo><msqrt><mrow><msub><mi>L</mi><mn>1</mn></msub><msub><mi>L</mi><mn>2</mn></msub></mrow></msqrt></mrow><annotation encoding="application/x-tex">M \leq \sqrt{L_1 L_2}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8193em;vertical-align:-0.136em;"></span><span class="mord mathnormal" style="margin-right:0.10903em;">M</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≤</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.04em;vertical-align:-0.1883em;"></span><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8517em;"><span class="svg-align" style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord" style="padding-left:0.833em;"><span class="mord"><span class="mord mathnormal">L</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathnormal">L</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span><span style="top:-2.8117em;"><span class="pstrut" style="height:3em;"></span><span class="hide-tail" style="min-width:0.853em;height:1.08em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='1.08em' viewBox='0 0 400000 1080' preserveAspectRatio='xMinYMin slice'><path d='M95,702
c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14
c0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54
c44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10
s173,378,173,378c0.7,0,35.3,-71,104,-213c68.7,-142,137.5,-285,206.5,-429
c69,-144,104.5,-217.7,106.5,-221
l0 -0
c5.3,-9.3,12,-14,20,-14
H400000v40H845.2724
s-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7
c-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z
M834 80h400000v40h-400000z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.1883em;"><span></span></span></span></span></span></span></span></span> が成立.</li>
</ol>
]]></description>
            <content:encoded><![CDATA[<h1 id="formulas-for-ipho-日本語版-section-8" tabindex="-1">Formulas for IPhO 日本語版: Section 8 <a class="header-anchor" href="#formulas-for-ipho-日本語版-section-8" aria-label="Permalink to &quot;Formulas for IPhO 日本語版: Section 8&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="_8-電気回路" tabindex="-1">8: 電気回路 <a class="header-anchor" href="#_8-電気回路" aria-label="Permalink to &quot;8: 電気回路&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="_8-1-v-i-r-p-v-i" tabindex="-1">8.1: V=I R, P=V I <a class="header-anchor" href="#_8-1-v-i-r-p-v-i" aria-label="Permalink to &quot;8.1: V=I R, P=V I&quot;">&ZeroWidthSpace;</a></h3>
<ol>
<li><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>V</mi><mo>=</mo><mi>I</mi><mi>R</mi><mo separator="true">,</mo><mi>P</mi><mo>=</mo><mi>V</mi><mi>I</mi></mrow><annotation encoding="application/x-tex">V=I R, P=V I</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.22222em;">V</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8778em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="mord mathnormal" style="margin-right:0.00773em;">R</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.13889em;">P</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.22222em;">V</span><span class="mord mathnormal" style="margin-right:0.07847em;">I</span></span></span></span><p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><msub><mi>R</mi><mtext>直列 </mtext></msub><mo>=</mo><mo>∑</mo><msub><mi>R</mi><mi>i</mi></msub><mo separator="true">,</mo><msubsup><mi>R</mi><mtext>並列 </mtext><mrow><mo>−</mo><mn>1</mn></mrow></msubsup><mo>=</mo><mo>∑</mo><msubsup><mi>R</mi><mi>i</mi><mrow><mo>−</mo><mn>1</mn></mrow></msubsup></mrow><annotation encoding="application/x-tex">R_{\text {直列 }}=\sum R_i, R_{\text {並列 }}^{-1}=\sum R_i^{-1}
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.00773em;">R</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-left:-0.0077em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord text mtight"><span class="mord cjk_fallback mtight">直列</span><span class="mord mtight"> </span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.6em;vertical-align:-0.55em;"></span><span class="mop op-symbol large-op" style="position:relative;top:0em;">∑</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.00773em;">R</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:-0.0077em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.00773em;">R</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-2.4163em;margin-left:-0.0077em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord text mtight"><span class="mord cjk_fallback mtight">並列</span><span class="mord mtight"> </span></span></span></span></span><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">−</span><span class="mord mtight">1</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2837em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.6em;vertical-align:-0.55em;"></span><span class="mop op-symbol large-op" style="position:relative;top:0em;">∑</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.00773em;">R</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-2.433em;margin-left:-0.0077em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">−</span><span class="mord mtight">1</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.267em;"><span></span></span></span></span></span></span></span></span></span></span></p>
</li>
</ol>
<h3 id="_8-2-kirchhoff-の法則" tabindex="-1">8.2: Kirchhoff の法則 <a class="header-anchor" href="#_8-2-kirchhoff-の法則" aria-label="Permalink to &quot;8.2: Kirchhoff の法則&quot;">&ZeroWidthSpace;</a></h3>
<ol start="2">
<li>Kirchhoff の法則 :<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><munder><mo>∑</mo><mstyle scriptlevel="1"><mtable rowspacing="0.1em" columnalign="center" columnspacing="1em"><mtr><mtd><mstyle scriptlevel="1" displaystyle="false"><mtext> 節点 </mtext></mstyle></mtd></mtr></mtable></mstyle></munder><mi>I</mi><mo>=</mo><mn>0</mn><mo separator="true">,</mo><munder><mo>∑</mo><mtext>閉路 </mtext></munder><mi>V</mi><mo>=</mo><mn>0</mn></mrow><annotation encoding="application/x-tex">\sum_{\substack{\text { 節点 }}} I=0, \sum_{\text {閉路 }} V=0
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.4703em;vertical-align:-1.4203em;"></span><span class="mop op-limits"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.05em;"><span style="top:-1.8568em;margin-left:0em;"><span class="pstrut" style="height:3.05em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight"><span class="mtable"><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6817em;"><span style="top:-2.6983em;"><span class="pstrut" style="height:2.7em;"></span><span class="mord mtight"><span class="mord text mtight"><span class="mord mtight"> </span><span class="mord cjk_fallback mtight">節点</span><span class="mord mtight"> </span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.1817em;"><span></span></span></span></span></span></span></span></span></span></span><span style="top:-3.05em;"><span class="pstrut" style="height:3.05em;"></span><span><span class="mop op-symbol large-op">∑</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.4203em;"><span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:2.3443em;vertical-align:-1.2943em;"></span><span class="mord">0</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop op-limits"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.05em;"><span style="top:-1.8557em;margin-left:0em;"><span class="pstrut" style="height:3.05em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord text mtight"><span class="mord cjk_fallback mtight">閉路</span><span class="mord mtight"> </span></span></span></span></span><span style="top:-3.05em;"><span class="pstrut" style="height:3.05em;"></span><span><span class="mop op-symbol large-op">∑</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.2943em;"><span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.22222em;">V</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">0</span></span></span></span></span></p>
</li>
</ol>
<h3 id="_8-3-ポイント-2-の方程式を減らすために" tabindex="-1">8.3: ポイント 2 の方程式を減らすために <a class="header-anchor" href="#_8-3-ポイント-2-の方程式を減らすために" aria-label="Permalink to &quot;8.3: ポイント 2 の方程式を減らすために&quot;">&ZeroWidthSpace;</a></h3>
<ol start="3">
<li>ポイント 2 の方程式を減らすために: 節点電位法. ルー プ電流法. 等価回路 (3 端子の場合 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇒</mo><mi mathvariant="normal">△</mi><mtext>又</mtext></mrow><annotation encoding="application/x-tex">\Rightarrow \triangle 又</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">⇒</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord">△</span><span class="mord cjk_fallback">又</span></span></span></span> 又 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>Y</mi></mrow><annotation encoding="application/x-tex">Y</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.22222em;">Y</span></span></span></span> の形, 起電力のある 2 端子の場合 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇒</mo></mrow><annotation encoding="application/x-tex">\Rightarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">⇒</span></span></span></span> 抵抗と電池の直列)</li>
</ol>
<h3 id="_8-4-無限につながる抵抗" tabindex="-1">8.4: 無限につながる抵抗 <a class="header-anchor" href="#_8-4-無限につながる抵抗" aria-label="Permalink to &quot;8.4: 無限につながる抵抗&quot;">&ZeroWidthSpace;</a></h3>
<ol start="4">
<li>無限につながる抵抗 : 無限に続く格子の隣り合う節点 間で，自己相似性を使う。鏡像法の一般化された方法.</li>
</ol>
<h3 id="_8-5-交流回路" tabindex="-1">8.5: 交流回路 <a class="header-anchor" href="#_8-5-交流回路" aria-label="Permalink to &quot;8.5: 交流回路&quot;">&ZeroWidthSpace;</a></h3>
<ol start="5">
<li>交流回路: <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>R</mi></mrow><annotation encoding="application/x-tex">R</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.00773em;">R</span></span></span></span> を <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>Z</mi></mrow><annotation encoding="application/x-tex">Z</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.07153em;">Z</span></span></span></span> に置き換えてポイント <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>1</mn><mo>∼</mo><mn>4</mn></mrow><annotation encoding="application/x-tex">1 \sim 4</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">1</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">∼</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">4</span></span></span></span> を用 いる.<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mtable rowspacing="0.25em" columnalign="center" columnspacing="0em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><msub><mi>Z</mi><mi>R</mi></msub><mo>=</mo><mi>R</mi><mo separator="true">,</mo><msub><mi>Z</mi><mi>C</mi></msub><mo>=</mo><mn>1</mn><mi mathvariant="normal">/</mi><mi>i</mi><mi>ω</mi><mi>C</mi><mo separator="true">,</mo><msub><mi>Z</mi><mi>L</mi></msub><mo>=</mo><mi>i</mi><mi>ω</mi><mi>L</mi></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mi>φ</mi><mo>=</mo><mi>arg</mi><mo>⁡</mo><mi>Z</mi><mo separator="true">,</mo><msub><mi>V</mi><mtext>eff </mtext></msub><mo>=</mo><mi mathvariant="normal">∣</mi><mi>Z</mi><mi mathvariant="normal">∣</mi><msub><mi>I</mi><mtext>eff </mtext></msub></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mi>P</mi><mo>=</mo><mi mathvariant="normal">∣</mi><mi>V</mi><mi mathvariant="normal">∣</mi><mi mathvariant="normal">∣</mi><mi>I</mi><mi mathvariant="normal">∣</mi><mi>cos</mi><mo>⁡</mo><mo stretchy="false">(</mo><mi>arg</mi><mo>⁡</mo><mi>Z</mi><mo stretchy="false">)</mo><mo>=</mo><mo>∑</mo><msubsup><mi>I</mi><mi>i</mi><mn>2</mn></msubsup><msub><mi>R</mi><mi>i</mi></msub></mrow></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{gathered}
Z_R=R, Z_C=1 / i \omega C, Z_L=i \omega L \\
\varphi=\arg Z, V_{\text {eff }}=|Z| I_{\text {eff }} \\
P=|V||I| \cos (\arg Z)=\sum I_i^2 R_i
\end{gathered}
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:4.9em;vertical-align:-2.2em;"></span><span class="mord"><span class="mtable"><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:2.7em;"><span style="top:-4.91em;"><span class="pstrut" style="height:3.05em;"></span><span class="mord"><span class="mord"><span class="mord mathnormal" style="margin-right:0.07153em;">Z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-left:-0.0715em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.00773em;">R</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord mathnormal" style="margin-right:0.00773em;">R</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.07153em;">Z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-left:-0.0715em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.07153em;">C</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord">1/</span><span class="mord mathnormal" style="margin-right:0.03588em;">iω</span><span class="mord mathnormal" style="margin-right:0.07153em;">C</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.07153em;">Z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-left:-0.0715em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">L</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">iω</span><span class="mord mathnormal">L</span></span></span><span style="top:-3.41em;"><span class="pstrut" style="height:3.05em;"></span><span class="mord"><span class="mord mathnormal">φ</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mop">ar<span style="margin-right:0.01389em;">g</span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.07153em;">Z</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.22222em;">V</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3361em;"><span style="top:-2.55em;margin-left:-0.2222em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord text mtight"><span class="mord mtight">eff </span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord">∣</span><span class="mord mathnormal" style="margin-right:0.07153em;">Z</span><span class="mord">∣</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3361em;"><span style="top:-2.55em;margin-left:-0.0785em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord text mtight"><span class="mord mtight">eff </span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span><span style="top:-1.7em;"><span class="pstrut" style="height:3.05em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.13889em;">P</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord">∣</span><span class="mord mathnormal" style="margin-right:0.22222em;">V</span><span class="mord">∣∣</span><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="mord">∣</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop">cos</span><span class="mopen">(</span><span class="mop">ar<span style="margin-right:0.01389em;">g</span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.07153em;">Z</span><span class="mclose">)</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mop op-symbol large-op" style="position:relative;top:0em;">∑</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-2.453em;margin-left:-0.0785em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.247em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.00773em;">R</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:-0.0077em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:2.2em;"><span></span></span></span></span></span></span></span></span></span></span></span></p>
</li>
</ol>
<h3 id="_8-6-特性時間" tabindex="-1">8.6: 特性時間 <a class="header-anchor" href="#_8-6-特性時間" aria-label="Permalink to &quot;8.6: 特性時間&quot;">&ZeroWidthSpace;</a></h3>
<ol start="6">
<li>特性時間: <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>τ</mi><mrow><mi>R</mi><mi>C</mi></mrow></msub><mo>=</mo><mi>R</mi><mi>C</mi><mo separator="true">,</mo><msub><mi>τ</mi><mrow><mi>L</mi><mi>R</mi></mrow></msub><mo>=</mo><mi>L</mi><mi mathvariant="normal">/</mi><mi>R</mi><mi mathvariant="normal">.</mi><msub><mi>ω</mi><mrow><mi>L</mi><mi>C</mi></mrow></msub><mo>=</mo></mrow><annotation encoding="application/x-tex">\tau_{R C}=R C, \tau_{L R}=L / R . \omega_{L C}=</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.1132em;">τ</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-left:-0.1132em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.07153em;">RC</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8778em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.07153em;">RC</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.1132em;">τ</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-left:-0.1132em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">L</span><span class="mord mathnormal mtight" style="margin-right:0.00773em;">R</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal">L</span><span class="mord">/</span><span class="mord mathnormal" style="margin-right:0.00773em;">R</span><span class="mord">.</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">ω</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">L</span><span class="mord mathnormal mtight" style="margin-right:0.07153em;">C</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span></span></span></span> <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>1</mn><mi mathvariant="normal">/</mi><msqrt><mrow><mi>L</mi><mi>C</mi></mrow></msqrt></mrow><annotation encoding="application/x-tex">1 / \sqrt{L C}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1767em;vertical-align:-0.25em;"></span><span class="mord">1/</span><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.9267em;"><span class="svg-align" style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord" style="padding-left:0.833em;"><span class="mord mathnormal">L</span><span class="mord mathnormal" style="margin-right:0.07153em;">C</span></span></span><span style="top:-2.8867em;"><span class="pstrut" style="height:3em;"></span><span class="hide-tail" style="min-width:0.853em;height:1.08em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='1.08em' viewBox='0 0 400000 1080' preserveAspectRatio='xMinYMin slice'><path d='M95,702
c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14
c0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54
c44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10
s173,378,173,378c0.7,0,35.3,-71,104,-213c68.7,-142,137.5,-285,206.5,-429
c69,-144,104.5,-217.7,106.5,-221
l0 -0
c5.3,-9.3,12,-14,20,-14
H400000v40H845.2724
s-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7
c-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z
M834 80h400000v40h-400000z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.1133em;"><span></span></span></span></span></span></span></span></span>. 定常的な電流分布への緩和は指数関数的で <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∝</mo><msup><mi>e</mi><mrow><mo>−</mo><mi>t</mi><mi mathvariant="normal">/</mi><mi>τ</mi></mrow></msup></mrow><annotation encoding="application/x-tex">\propto e^{-t / \tau}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mrel">∝</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.888em;"></span><span class="mord"><span class="mord mathnormal">e</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.888em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">−</span><span class="mord mathnormal mtight">t</span><span class="mord mtight">/</span><span class="mord mathnormal mtight" style="margin-right:0.1132em;">τ</span></span></span></span></span></span></span></span></span></span></span></span></li>
</ol>
<h3 id="_8-7-電気回路のエネルギー保存則" tabindex="-1">8.7: 電気回路のエネルギー保存則 <a class="header-anchor" href="#_8-7-電気回路のエネルギー保存則" aria-label="Permalink to &quot;8.7: 電気回路のエネルギー保存則&quot;">&ZeroWidthSpace;</a></h3>
<ol start="8">
<li>電気回路のエネルギー保存則 : <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Δ</mi><mi>W</mi><mo>+</mo><mi>Q</mi><mo>=</mo><mi>q</mi><mi>V</mi></mrow><annotation encoding="application/x-tex">\Delta W+Q=q V</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7667em;vertical-align:-0.0833em;"></span><span class="mord">Δ</span><span class="mord mathnormal" style="margin-right:0.13889em;">W</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.8778em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">Q</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8778em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">q</span><span class="mord mathnormal" style="margin-right:0.22222em;">V</span></span></span></span>. ここ で <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi></mrow><annotation encoding="application/x-tex">q</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">q</span></span></span></span> は電圧降下 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>V</mi></mrow><annotation encoding="application/x-tex">V</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.22222em;">V</span></span></span></span> を通った電気量で, 電源のする仕事 は <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>A</mi><mo>=</mo><mi>q</mi><msub><mi>V</mi><mrow><mi mathvariant="normal">e</mi><mi mathvariant="normal">m</mi><mi mathvariant="normal">f</mi></mrow></msub></mrow><annotation encoding="application/x-tex">A=q V_{\mathrm{emf}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal">A</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8778em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">q</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.22222em;">V</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3361em;"><span style="top:-2.55em;margin-left:-0.2222em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight"><span class="mord mathrm mtight" style="margin-right:0.07778em;">emf</span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span></li>
</ol>
<h3 id="_8-8-コンデンサーの位置エネルギー式" tabindex="-1">8.8: コンデンサーの位置エネルギー式 <a class="header-anchor" href="#_8-8-コンデンサーの位置エネルギー式" aria-label="Permalink to &quot;8.8: コンデンサーの位置エネルギー式&quot;">&ZeroWidthSpace;</a></h3>
<ol start="8">
<li>コンデンサーの位置エネルギー式:
<span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>W</mi><mi>C</mi></msub><mo>=</mo><mi>C</mi><msup><mi>V</mi><mn>2</mn></msup><mi mathvariant="normal">/</mi><mn>2</mn><mo separator="true">,</mo><msub><mi>W</mi><mi>L</mi></msub><mo>=</mo><mi>L</mi><msup><mi>I</mi><mn>2</mn></msup><mi mathvariant="normal">/</mi><mn>2</mn></mrow><annotation encoding="application/x-tex">W_C=C V^2 / 2, W_L=L I^2 / 2</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.13889em;">W</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-left:-0.1389em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.07153em;">C</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.0641em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.07153em;">C</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.22222em;">V</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mord">/2</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.13889em;">W</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-left:-0.1389em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">L</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.0641em;vertical-align:-0.25em;"></span><span class="mord mathnormal">L</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mord">/2</span></span></span></span>.</li>
</ol>
<h3 id="_8-9-磁束密度" tabindex="-1">8.9: 磁束密度 <a class="header-anchor" href="#_8-9-磁束密度" aria-label="Permalink to &quot;8.9: 磁束密度&quot;">&ZeroWidthSpace;</a></h3>
<ol start="9">
<li><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>V</mi><mrow><mi mathvariant="normal">e</mi><mi mathvariant="normal">m</mi><mi mathvariant="normal">f</mi></mrow></msub><mo>=</mo><mo>−</mo><mi mathvariant="normal">d</mi><mi mathvariant="normal">Φ</mi><mi mathvariant="normal">/</mi><mi mathvariant="normal">d</mi><mi>t</mi><mo>=</mo><mi mathvariant="normal">d</mi><mo stretchy="false">(</mo><mi>L</mi><mi>I</mi><mo stretchy="false">)</mo><mi mathvariant="normal">/</mi><mi mathvariant="normal">d</mi><mi>t</mi><mo separator="true">,</mo><mi mathvariant="normal">Φ</mi><mo>=</mo><mi>B</mi><mi>S</mi></mrow><annotation encoding="application/x-tex">V_{\mathrm{emf}}=-\mathrm{d} \Phi / \mathrm{d} t=\mathrm{d}(L I) / \mathrm{d} t, \Phi=B S</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.22222em;">V</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3361em;"><span style="top:-2.55em;margin-left:-0.2222em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight"><span class="mord mathrm mtight" style="margin-right:0.07778em;">emf</span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">−</span><span class="mord mathrm">d</span><span class="mord">Φ/</span><span class="mord mathrm">d</span><span class="mord mathnormal">t</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathrm">d</span><span class="mopen">(</span><span class="mord mathnormal">L</span><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="mclose">)</span><span class="mord">/</span><span class="mord mathrm">d</span><span class="mord mathnormal">t</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord">Φ</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.05764em;">BS</span></span></span></span>.</li>
</ol>
<h3 id="_8-10-非線形素子" tabindex="-1">8.10: 非線形素子 <a class="header-anchor" href="#_8-10-非線形素子" aria-label="Permalink to &quot;8.10: 非線形素子&quot;">&ZeroWidthSpace;</a></h3>
<ol start="10">
<li>非 線形素子: <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>V</mi><mo>−</mo><mi>I</mi></mrow><annotation encoding="application/x-tex">V-I</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7667em;vertical-align:-0.0833em;"></span><span class="mord mathnormal" style="margin-right:0.22222em;">V</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.07847em;">I</span></span></span></span> グラフでの非線形曲線と Ohm/Kirchhoff の法則を表す直線との交点として 为形的に解を求める. 複数の交点があれば安定性を調 ベる. いくつかの解は普通安定でない.</li>
</ol>
<h3 id="_8-11-短時間と長時間の極限を利用" tabindex="-1">8.11: 短時間と長時間の極限を利用 <a class="header-anchor" href="#_8-11-短時間と長時間の極限を利用" aria-label="Permalink to &quot;8.11: 短時間と長時間の極限を利用&quot;">&ZeroWidthSpace;</a></h3>
<ol start="11">
<li>短時間と長時間の極限を利用する: <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>t</mi><mtext>observation </mtext></msub><mo>≫</mo></mrow><annotation encoding="application/x-tex">t_{\text {observation }} \gg</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7651em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal">t</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3361em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord text mtight"><span class="mord mtight">observation </span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≫</span></span></span></span> <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>τ</mi><mrow><mi>R</mi><mi>C</mi></mrow></msub></mrow><annotation encoding="application/x-tex">\tau_{R C}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.1132em;">τ</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-left:-0.1132em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.07153em;">RC</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> or <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>τ</mi><mrow><mi>L</mi><mi>R</mi></mrow></msub></mrow><annotation encoding="application/x-tex">\tau_{L R}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.1132em;">τ</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-left:-0.1132em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">L</span><span class="mord mathnormal mtight" style="margin-right:0.00773em;">R</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> ならば, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>I</mi><mi>C</mi></msub><mo>≈</mo><mn>0</mn><mo stretchy="false">(</mo><mi>C</mi></mrow><annotation encoding="application/x-tex">I_C \approx 0(C</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-left:-0.0785em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.07153em;">C</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≈</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">0</span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.07153em;">C</span></span></span></span> は断線している）又 は <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>V</mi><mi>L</mi></msub><mo>≈</mo><mn>0</mn></mrow><annotation encoding="application/x-tex">V_L \approx 0</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.22222em;">V</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-left:-0.2222em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">L</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≈</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">0</span></span></span></span> ( <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>L</mi></mrow><annotation encoding="application/x-tex">L</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal">L</span></span></span></span> は短絡している）のような準平衡状態に 達する. <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>t</mi><mtext>observation </mtext></msub><mo>≪</mo><msub><mi>τ</mi><mrow><mi>R</mi><mi>C</mi></mrow></msub></mrow><annotation encoding="application/x-tex">t_{\text {observation }} \ll \tau_{R C}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7651em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal">t</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3361em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord text mtight"><span class="mord mtight">observation </span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≪</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.1132em;">τ</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-left:-0.1132em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.07153em;">RC</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> or <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>τ</mi><mrow><mi>L</mi><mi>R</mi></mrow></msub></mrow><annotation encoding="application/x-tex">\tau_{L R}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.1132em;">τ</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-left:-0.1132em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">L</span><span class="mord mathnormal mtight" style="margin-right:0.00773em;">R</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> ならば, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>C</mi></mrow><annotation encoding="application/x-tex">C</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.07153em;">C</span></span></span></span> の電 気量の変化や <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>L</mi></mrow><annotation encoding="application/x-tex">L</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal">L</span></span></span></span> での電流の変化は小さく, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Δ</mi><mi>Q</mi><mo>≪</mo><mi>Q</mi></mrow><annotation encoding="application/x-tex">\Delta Q \ll Q</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8778em;vertical-align:-0.1944em;"></span><span class="mord">Δ</span><span class="mord mathnormal">Q</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≪</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8778em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">Q</span></span></span></span> や <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Δ</mi><mi>I</mi><mo>≪</mo><mi>I</mi></mrow><annotation encoding="application/x-tex">\Delta I \ll I</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7224em;vertical-align:-0.0391em;"></span><span class="mord">Δ</span><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≪</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.07847em;">I</span></span></span></span>. 即ち <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>C</mi></mrow><annotation encoding="application/x-tex">C</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.07153em;">C</span></span></span></span> は短絡していて <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>L</mi></mrow><annotation encoding="application/x-tex">L</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal">L</span></span></span></span> は断線して いる.</li>
</ol>
<h3 id="_8-12-推論" tabindex="-1">8.12: 推論 <a class="header-anchor" href="#_8-12-推論" aria-label="Permalink to &quot;8.12: 推論&quot;">&ZeroWidthSpace;</a></h3>
<ol start="12">
<li><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>L</mi><mo mathvariant="normal">≠</mo><mn>0</mn></mrow><annotation encoding="application/x-tex">L \neq 0</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">L</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel"><span class="mrel"><span class="mord vbox"><span class="thinbox"><span class="rlap"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="inner"><span class="mord"><span class="mrel"></span></span></span><span class="fix"></span></span></span></span></span><span class="mrel">=</span></span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">0</span></span></span></span> ならば, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>I</mi><mo stretchy="false">(</mo><mi>t</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">I(t)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="mopen">(</span><span class="mord mathnormal">t</span><span class="mclose">)</span></span></span></span> は連続.</li>
</ol>
<h3 id="_8-13-超電導の回路" tabindex="-1">8.13: 超電導の回路 <a class="header-anchor" href="#_8-13-超電導の回路" aria-label="Permalink to &quot;8.13: 超電導の回路&quot;">&ZeroWidthSpace;</a></h3>
<ol start="13">
<li>超電導の回路について, 磁束 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Φ</mi><mo>=</mo></mrow><annotation encoding="application/x-tex">\Phi=</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">Φ</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span></span></span></span> const.. 特に, 外部 磁場が無ければ <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>L</mi><mi>I</mi><mo>=</mo></mrow><annotation encoding="application/x-tex">L I=</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal">L</span><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span></span></span></span> const.</li>
</ol>
<h3 id="_8-14-相互誘導" tabindex="-1">8.14: 相互誘導 <a class="header-anchor" href="#_8-14-相互誘導" aria-label="Permalink to &quot;8.14: 相互誘導&quot;">&ZeroWidthSpace;</a></h3>
<ol start="14">
<li>相互誘導 : 回路 1 を通る磁束は <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi mathvariant="normal">Φ</mi><mn>1</mn></msub><mo>=</mo><msub><mi>L</mi><mn>1</mn></msub><msub><mi>I</mi><mn>1</mn></msub><mo>+</mo><msub><mi>L</mi><mn>12</mn></msub><msub><mi>I</mi><mn>2</mn></msub></mrow><annotation encoding="application/x-tex">\Phi_1=L_1 I_1+L_{12} I_2</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord">Φ</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal">L</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0785em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal">L</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">12</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0785em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> ( <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>I</mi><mn>2</mn></msub></mrow><annotation encoding="application/x-tex">I_2</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0785em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> は回路 2 を流れる電流) で, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>L</mi><mn>12</mn></msub><mo>=</mo><msub><mi>L</mi><mn>21</mn></msub><mo>≡</mo><mi>M</mi></mrow><annotation encoding="application/x-tex">L_{12}=L_{21} \equiv M</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal">L</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">12</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal">L</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">21</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≡</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.10903em;">M</span></span></span></span> と <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>M</mi><mo>≤</mo><msqrt><mrow><msub><mi>L</mi><mn>1</mn></msub><msub><mi>L</mi><mn>2</mn></msub></mrow></msqrt></mrow><annotation encoding="application/x-tex">M \leq \sqrt{L_1 L_2}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8193em;vertical-align:-0.136em;"></span><span class="mord mathnormal" style="margin-right:0.10903em;">M</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≤</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.04em;vertical-align:-0.1883em;"></span><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8517em;"><span class="svg-align" style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord" style="padding-left:0.833em;"><span class="mord"><span class="mord mathnormal">L</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathnormal">L</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span><span style="top:-2.8117em;"><span class="pstrut" style="height:3em;"></span><span class="hide-tail" style="min-width:0.853em;height:1.08em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='1.08em' viewBox='0 0 400000 1080' preserveAspectRatio='xMinYMin slice'><path d='M95,702
c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14
c0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54
c44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10
s173,378,173,378c0.7,0,35.3,-71,104,-213c68.7,-142,137.5,-285,206.5,-429
c69,-144,104.5,-217.7,106.5,-221
l0 -0
c5.3,-9.3,12,-14,20,-14
H400000v40H845.2724
s-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7
c-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z
M834 80h400000v40h-400000z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.1883em;"><span></span></span></span></span></span></span></span></span> が成立.</li>
</ol>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Formulas for IPhO 日本語版: Section 9 ]]></title>
            <link>https://note.toshiki.devacademic/physics/ipho-formulas-jpn/9</link>
            <guid>https://note.toshiki.devacademic/physics/ipho-formulas-jpn/9</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="formulas-for-ipho-日本語版-section-9" tabindex="-1">Formulas for IPhO 日本語版: Section 9 <a class="header-anchor" href="#formulas-for-ipho-日本語版-section-9" aria-label="Permalink to &quot;Formulas for IPhO 日本語版: Section 9&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="_9-電磁気学" tabindex="-1">9: 電磁気学 <a class="header-anchor" href="#_9-電磁気学" aria-label="Permalink to &quot;9: 電磁気学&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="_9-1-coulomb-の法則" tabindex="-1">9.1: Coulomb の法則 <a class="header-anchor" href="#_9-1-coulomb-の法則" aria-label="Permalink to &quot;9.1: Coulomb の法則&quot;">&ZeroWidthSpace;</a></h3>
<ol>
<li><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>F</mi><mo>=</mo><mi>k</mi><msub><mi>q</mi><mn>1</mn></msub><msub><mi>q</mi><mn>2</mn></msub><mi mathvariant="normal">/</mi><msup><mi>r</mi><mn>2</mn></msup><mo separator="true">,</mo><mi>U</mi><mo>=</mo><mi>k</mi><msub><mi>q</mi><mn>1</mn></msub><msub><mi>q</mi><mn>2</mn></msub><mi mathvariant="normal">/</mi><mi>r</mi></mrow><annotation encoding="application/x-tex">F=k q_1 q_2 / r^2, U=k q_1 q_2 / r</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.13889em;">F</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.0641em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">q</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">q</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord">/</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.02778em;">r</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.10903em;">U</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">q</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">q</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord">/</span><span class="mord mathnormal" style="margin-right:0.02778em;">r</span></span></span></span> で, Kepler の法則が 使える (<a href="./12.html">Section 12 参照</a>).</li>
</ol>
<h3 id="_9-2-gauss-の法則" tabindex="-1">9.2: Gauss の法則 <a class="header-anchor" href="#_9-2-gauss-の法則" aria-label="Permalink to &quot;9.2: Gauss の法則&quot;">&ZeroWidthSpace;</a></h3>
<ol start="2">
<li>
<p>Gauss の法則 : <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∮</mo><mi mathvariant="bold-italic">B</mi><mo>⋅</mo><mi mathvariant="normal">d</mi><mi mathvariant="bold-italic">S</mi><mo>=</mo><mn>0</mn></mrow><annotation encoding="application/x-tex">\oint \boldsymbol{B} \cdot \mathrm{d} \boldsymbol{S}=0</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1111em;vertical-align:-0.3061em;"></span><span class="mop op-symbol small-op" style="margin-right:0.19445em;position:relative;top:-0.0006em;">∮</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.04835em;">B</span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">⋅</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathrm">d</span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.05382em;">S</span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">0</span></span></span></span>,</p>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mo>∮</mo><mi>ε</mi><mi mathvariant="bold-italic">E</mi><mo>⋅</mo><mi mathvariant="normal">d</mi><mi mathvariant="bold-italic">S</mi><mo>=</mo><mi>Q</mi><mo separator="true">,</mo><mo>∮</mo><mi mathvariant="bold-italic">g</mi><mo>⋅</mo><mi mathvariant="normal">d</mi><mi mathvariant="bold-italic">S</mi><mo>=</mo><mo>−</mo><mn>4</mn><mi>π</mi><mi>G</mi><mi>M</mi></mrow><annotation encoding="application/x-tex">\oint \varepsilon \boldsymbol{E} \cdot \mathrm{d} \boldsymbol{S}=Q, \oint \boldsymbol{g} \cdot \mathrm{d} \boldsymbol{S}=-4 \pi G M
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.2222em;vertical-align:-0.8622em;"></span><span class="mop op-symbol large-op" style="margin-right:0.44445em;position:relative;top:-0.0011em;">∮</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">ε</span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.05451em;">E</span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">⋅</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathrm">d</span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.05382em;">S</span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:2.2222em;vertical-align:-0.8622em;"></span><span class="mord mathnormal">Q</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop op-symbol large-op" style="margin-right:0.44445em;position:relative;top:-0.0011em;">∮</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03704em;">g</span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">⋅</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathrm">d</span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.05382em;">S</span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.7667em;vertical-align:-0.0833em;"></span><span class="mord">−</span><span class="mord">4</span><span class="mord mathnormal" style="margin-right:0.03588em;">π</span><span class="mord mathnormal" style="margin-right:0.10903em;">GM</span></span></span></span></span></p>
</li>
</ol>
<h3 id="_9-3-循環定理" tabindex="-1">9.3: 循環定理 <a class="header-anchor" href="#_9-3-循環定理" aria-label="Permalink to &quot;9.3: 循環定理&quot;">&ZeroWidthSpace;</a></h3>
<ol start="3">
<li>
<p>循環定理 :</p>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mo>∮</mo><mi mathvariant="bold-italic">E</mi><mo>⋅</mo><mi mathvariant="normal">d</mi><mi mathvariant="bold-italic">l</mi><mo>=</mo><mn>0</mn><mo stretchy="false">(</mo><mo>=</mo><mover accent="true"><mi mathvariant="normal">Φ</mi><mo>˙</mo></mover><mo stretchy="false">)</mo><mo separator="true">,</mo><mo>∮</mo><mfrac><mrow><mi mathvariant="bold-italic">B</mi><mo>⋅</mo><mi mathvariant="normal">d</mi><mi mathvariant="bold-italic">l</mi></mrow><mi>μ</mi></mfrac><mo>=</mo><mi>I</mi><mo separator="true">,</mo><mo>∮</mo><mi mathvariant="bold-italic">g</mi><mo>⋅</mo><mi mathvariant="normal">d</mi><mi mathvariant="bold-italic">l</mi><mo>=</mo><mn>0</mn></mrow><annotation encoding="application/x-tex">\oint \boldsymbol{E} \cdot \mathrm{d} \boldsymbol{l}=0(=\dot{\Phi}), \oint \frac{\boldsymbol{B} \cdot \mathrm{d} \boldsymbol{l}}{\mu}=I, \oint \boldsymbol{g} \cdot \mathrm{d} \boldsymbol{l}=0
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.2222em;vertical-align:-0.8622em;"></span><span class="mop op-symbol large-op" style="margin-right:0.44445em;position:relative;top:-0.0011em;">∮</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.05451em;">E</span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">⋅</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathrm">d</span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.0088em;">l</span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">0</span><span class="mopen">(</span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:2.2519em;vertical-align:-0.8804em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.9202em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord">Φ</span></span><span style="top:-3.2523em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.1389em;"><span class="mord">˙</span></span></span></span></span></span></span><span class="mclose">)</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop op-symbol large-op" style="margin-right:0.44445em;position:relative;top:-0.0011em;">∮</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.3714em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">μ</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.04835em;">B</span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">⋅</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathrm">d</span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.0088em;">l</span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.8804em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:2.2222em;vertical-align:-0.8622em;"></span><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop op-symbol large-op" style="margin-right:0.44445em;position:relative;top:-0.0011em;">∮</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03704em;">g</span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">⋅</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathrm">d</span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.0088em;">l</span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">0</span></span></span></span></span></p>
</li>
</ol>
<h3 id="_9-4-電流素片により生じる磁束密度" tabindex="-1">9.4: 電流素片により生じる磁束密度 <a class="header-anchor" href="#_9-4-電流素片により生じる磁束密度" aria-label="Permalink to &quot;9.4: 電流素片により生じる磁束密度&quot;">&ZeroWidthSpace;</a></h3>
<ol start="4">
<li>電流素片により生じる磁束密度 :<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mi mathvariant="normal">d</mi><mi mathvariant="bold-italic">B</mi><mo>=</mo><mfrac><mrow><mi>μ</mi><mi>I</mi></mrow><mrow><mn>4</mn><mi>π</mi></mrow></mfrac><mfrac><mrow><mi mathvariant="normal">d</mi><mi mathvariant="bold-italic">l</mi><mo>×</mo><msub><mi mathvariant="bold-italic">e</mi><mi>r</mi></msub></mrow><msup><mi>r</mi><mn>2</mn></msup></mfrac><mi mathvariant="normal">.</mi></mrow><annotation encoding="application/x-tex">\mathrm{d} \boldsymbol{B}=\frac{\mu I}{4 \pi} \frac{\mathrm{d} \boldsymbol{l} \times \boldsymbol{e}_r}{r^2} .
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathrm">d</span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.04835em;">B</span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:2.0574em;vertical-align:-0.686em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.3603em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">4</span><span class="mord mathnormal" style="margin-right:0.03588em;">π</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">μ</span><span class="mord mathnormal" style="margin-right:0.07847em;">I</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.3714em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"><span class="mord mathnormal" style="margin-right:0.02778em;">r</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7401em;"><span style="top:-2.989em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathrm">d</span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.0088em;">l</span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">×</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol">e</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.02778em;">r</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mord">.</span></span></span></span></span></p>
したがって電流 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>I</mi></mrow><annotation encoding="application/x-tex">I</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.07847em;">I</span></span></span></span> が流れる円形回路の中心では <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>B</mi><mo>=</mo><mfrac><mrow><msub><mi>μ</mi><mn>0</mn></msub><mi>I</mi></mrow><mrow><mn>2</mn><mi>r</mi></mrow></mfrac></mrow><annotation encoding="application/x-tex">B=\frac{\mu_0 I}{2 r}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.2694em;vertical-align:-0.345em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.9244em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span><span class="mord mathnormal mtight" style="margin-right:0.02778em;">r</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.4461em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight"><span class="mord mathnormal mtight">μ</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3173em;"><span style="top:-2.357em;margin-left:0em;margin-right:0.0714em;"><span class="pstrut" style="height:2.5em;"></span><span class="sizing reset-size3 size1 mtight"><span class="mord mtight">0</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.143em;"><span></span></span></span></span></span></span><span class="mord mathnormal mtight" style="margin-right:0.07847em;">I</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span>.</li>
</ol>
<h3 id="_9-5-ローレンツ力" tabindex="-1">9.5: ローレンツ力 <a class="header-anchor" href="#_9-5-ローレンツ力" aria-label="Permalink to &quot;9.5: ローレンツ力&quot;">&ZeroWidthSpace;</a></h3>
<ol start="5">
<li><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="bold-italic">F</mi><mo>=</mo><mi>e</mi><mo stretchy="false">(</mo><mi mathvariant="bold-italic">E</mi><mo>+</mo><mi mathvariant="bold-italic">v</mi><mo>×</mo><mi mathvariant="bold-italic">B</mi><mo stretchy="false">)</mo><mo separator="true">,</mo><mi mathvariant="bold-italic">F</mi><mo>=</mo><mi mathvariant="bold-italic">I</mi><mo>×</mo><mi mathvariant="bold-italic">B</mi><mi>l</mi></mrow><annotation encoding="application/x-tex">\boldsymbol{F}=e(\boldsymbol{E}+\boldsymbol{v} \times \boldsymbol{B}), \boldsymbol{F}=\boldsymbol{I} \times \boldsymbol{B} l</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6861em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.15972em;">F</span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal">e</span><span class="mopen">(</span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.05451em;">E</span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03704em;">v</span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">×</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.04835em;">B</span></span></span><span class="mclose">)</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.15972em;">F</span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.7694em;vertical-align:-0.0833em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.07778em;">I</span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">×</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.04835em;">B</span></span></span><span class="mord mathnormal" style="margin-right:0.01968em;">l</span></span></span></span>.</li>
</ol>
<h3 id="_9-6-gauss-の定理と循環定理より" tabindex="-1">9.6: Gauss の定理と循環定理より <a class="header-anchor" href="#_9-6-gauss-の定理と循環定理より" aria-label="Permalink to &quot;9.6: Gauss の定理と循環定理より&quot;">&ZeroWidthSpace;</a></h3>
<ol start="6">
<li>Gauss の定理と循環定理より：帯電した導線について <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>E</mi><mo>=</mo><mfrac><mi>σ</mi><mrow><mn>2</mn><mi>π</mi><msub><mi>ε</mi><mn>0</mn></msub><mi>r</mi></mrow></mfrac></mrow><annotation encoding="application/x-tex">E=\frac{\sigma}{2 \pi \varepsilon_0 r}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.05764em;">E</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.1405em;vertical-align:-0.4451em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6954em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span><span class="mord mathnormal mtight" style="margin-right:0.03588em;">π</span><span class="mord mtight"><span class="mord mathnormal mtight">ε</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3173em;"><span style="top:-2.357em;margin-left:0em;margin-right:0.0714em;"><span class="pstrut" style="height:2.5em;"></span><span class="sizing reset-size3 size1 mtight"><span class="mord mtight">0</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.143em;"><span></span></span></span></span></span></span><span class="mord mathnormal mtight" style="margin-right:0.02778em;">r</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.03588em;">σ</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.4451em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span>, 電流が流れる導線について <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>B</mi><mo>=</mo><mfrac><mrow><msub><mi>μ</mi><mn>0</mn></msub><mi>I</mi></mrow><mrow><mn>2</mn><mi>π</mi><mi>r</mi></mrow></mfrac></mrow><annotation encoding="application/x-tex">B=\frac{\mu_0 I}{2 \pi r}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.2694em;vertical-align:-0.345em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.9244em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span><span class="mord mathnormal mtight" style="margin-right:0.03588em;">π</span><span class="mord mathnormal mtight" style="margin-right:0.02778em;">r</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.4461em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight"><span class="mord mathnormal mtight">μ</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3173em;"><span style="top:-2.357em;margin-left:0em;margin-right:0.0714em;"><span class="pstrut" style="height:2.5em;"></span><span class="sizing reset-size3 size1 mtight"><span class="mord mtight">0</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.143em;"><span></span></span></span></span></span></span><span class="mord mathnormal mtight" style="margin-right:0.07847em;">I</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span>. 帯電した面について <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>E</mi><mo>=</mo><mfrac><mi>σ</mi><mrow><mn>2</mn><msub><mi>ε</mi><mn>0</mn></msub></mrow></mfrac></mrow><annotation encoding="application/x-tex">E=\frac{\sigma}{2 \varepsilon_0}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.05764em;">E</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.1405em;vertical-align:-0.4451em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6954em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span><span class="mord mtight"><span class="mord mathnormal mtight">ε</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3173em;"><span style="top:-2.357em;margin-left:0em;margin-right:0.0714em;"><span class="pstrut" style="height:2.5em;"></span><span class="sizing reset-size3 size1 mtight"><span class="mord mtight">0</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.143em;"><span></span></span></span></span></span></span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.03588em;">σ</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.4451em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span>, 電流が流れる面につい て <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>B</mi><mo>=</mo><mfrac><mrow><msub><mi>μ</mi><mn>0</mn></msub><mi>i</mi></mrow><mn>2</mn></mfrac></mrow><annotation encoding="application/x-tex">B=\frac{\mu_0 i}{2}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.2528em;vertical-align:-0.345em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.9078em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.4461em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight"><span class="mord mathnormal mtight">μ</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3173em;"><span style="top:-2.357em;margin-left:0em;margin-right:0.0714em;"><span class="pstrut" style="height:2.5em;"></span><span class="sizing reset-size3 size1 mtight"><span class="mord mtight">0</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.143em;"><span></span></span></span></span></span></span><span class="mord mathnormal mtight">i</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span>. 一様に帯電した球殼（又は無限に長い円 筒）の内部で <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>E</mi><mo>=</mo><mn>0</mn></mrow><annotation encoding="application/x-tex">E=0</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.05764em;">E</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">0</span></span></span></span>, 軸に沿って表面に電流が流れる 円筒の内部で <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>B</mi><mo>=</mo><mn>0</mn></mrow><annotation encoding="application/x-tex">B=0</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">0</span></span></span></span>. 密度 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ρ</mi></mrow><annotation encoding="application/x-tex">\rho</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">ρ</span></span></span></span> で一様に帯電, 又は一様 な電流 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="bold-italic">i</mi></mrow><annotation encoding="application/x-tex">\boldsymbol{i}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6933em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol">i</span></span></span></span></span></span> が流れる, 球 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">(</mo><mi>d</mi><mo>=</mo><mn>3</mn><mo stretchy="false">)</mo><mi mathvariant="normal">/</mi></mrow><annotation encoding="application/x-tex">(d=3) /</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">(</span><span class="mord mathnormal">d</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">3</span><span class="mclose">)</span><span class="mord">/</span></span></span></span> 円柱 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">(</mo><mi>d</mi><mo>−</mo><mn>2</mn><mo stretchy="false">)</mo><mi mathvariant="normal">/</mi></mrow><annotation encoding="application/x-tex">(d-2) /</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">(</span><span class="mord mathnormal">d</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">2</span><span class="mclose">)</span><span class="mord">/</span></span></span></span> 平面 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">(</mo><mi>d</mi><mo>=</mo><mn>1</mn><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">(d=1)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">(</span><span class="mord mathnormal">d</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">1</span><span class="mclose">)</span></span></span></span> の内部で,<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mi mathvariant="bold-italic">E</mi><mo>=</mo><mfrac><mi>ρ</mi><mrow><mi>ε</mi><mi>d</mi></mrow></mfrac><mi mathvariant="bold-italic">r</mi><mo separator="true">,</mo><mi mathvariant="bold-italic">B</mi><mo>=</mo><mfrac><mn>1</mn><mrow><mi>μ</mi><mi>d</mi></mrow></mfrac><mi mathvariant="bold-italic">i</mi><mo>×</mo><mi mathvariant="bold-italic">r</mi></mrow><annotation encoding="application/x-tex">\boldsymbol{E}=\frac{\rho}{\varepsilon d} \boldsymbol{r}, \boldsymbol{B}=\frac{1}{\mu d} \boldsymbol{i} \times \boldsymbol{r}
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6861em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.05451em;">E</span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.7936em;vertical-align:-0.686em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1076em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">ε</span><span class="mord mathnormal">d</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">ρ</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03194em;">r</span></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.04835em;">B</span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:2.2019em;vertical-align:-0.8804em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.3214em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">μ</span><span class="mord mathnormal">d</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.8804em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mord"><span class="mord"><span class="mord boldsymbol">i</span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">×</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.4444em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03194em;">r</span></span></span></span></span></span></span></p>
</li>
</ol>
<h3 id="_9-7-長いソレノイド" tabindex="-1">9.7: 長いソレノイド <a class="header-anchor" href="#_9-7-長いソレノイド" aria-label="Permalink to &quot;9.7: 長いソレノイド&quot;">&ZeroWidthSpace;</a></h3>
<ol start="7">
<li>長いソレノイド: 内部で <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>B</mi><mo>=</mo><mi>μ</mi><mi>n</mi><mi>I</mi></mrow><annotation encoding="application/x-tex">B=\mu n I</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8778em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">μ</span><span class="mord mathnormal">n</span><span class="mord mathnormal" style="margin-right:0.07847em;">I</span></span></span></span>, 外部で <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>B</mi><mo>=</mo><mn>0</mn></mrow><annotation encoding="application/x-tex">B=0</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">0</span></span></span></span>. 磁束 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Φ</mi><mo>=</mo><mi>N</mi><mi>B</mi><mi>S</mi><mrow><mo fence="true">(</mo><mi>n</mi><mo>=</mo><mfrac><mi>N</mi><mi>l</mi></mfrac><mo fence="true">)</mo></mrow></mrow><annotation encoding="application/x-tex">\Phi=N B S\left(n=\frac{N}{l}\right)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">Φ</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.2223em;vertical-align:-0.35em;"></span><span class="mord mathnormal" style="margin-right:0.05764em;">NBS</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size1">(</span></span><span class="mord mathnormal">n</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8723em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.01968em;">l</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.10903em;">N</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size1">)</span></span></span></span></span></span>. インダクタンス <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>L</mi><mo>=</mo></mrow><annotation encoding="application/x-tex">L=</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal">L</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span></span></span></span> <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Φ</mi><mi mathvariant="normal">/</mi><mi>I</mi><mo>=</mo><mi>μ</mi><msup><mi>n</mi><mn>2</mn></msup><mi>V</mi></mrow><annotation encoding="application/x-tex">\Phi / I=\mu n^2 V</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">Φ/</span><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.0085em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">μ</span><span class="mord"><span class="mord mathnormal">n</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mord mathnormal" style="margin-right:0.22222em;">V</span></span></span></span>. 短いソレノイド <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>:</mo><msub><mi>B</mi><mi mathvariant="normal">∥</mi></msub><mo>=</mo><mfrac><mrow><mi>μ</mi><mi>n</mi><mi>I</mi><mi mathvariant="normal">Ω</mi></mrow><mrow><mn>4</mn><mi>π</mi></mrow></mfrac><mo stretchy="false">(</mo><mi mathvariant="normal">Ω</mi></mrow><annotation encoding="application/x-tex">: B_{\|}=\frac{\mu n I \Omega}{4 \pi}(\Omega</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mrel">:</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.0385em;vertical-align:-0.3552em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.05017em;">B</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3448em;"><span style="top:-2.5198em;margin-left:-0.0502em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">∥</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.3552em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.2694em;vertical-align:-0.345em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.9244em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">4</span><span class="mord mathnormal mtight" style="margin-right:0.03588em;">π</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.4461em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">μ</span><span class="mord mathnormal mtight">n</span><span class="mord mathnormal mtight" style="margin-right:0.07847em;">I</span><span class="mord mtight">Ω</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mopen">(</span><span class="mord">Ω</span></span></span></span> は 立体角).</li>
</ol>
<h3 id="_9-8-磁場を小型コイルや衝撃検流計で測定する" tabindex="-1">9.8: 磁場を小型コイルや衝撃検流計で測定する <a class="header-anchor" href="#_9-8-磁場を小型コイルや衝撃検流計で測定する" aria-label="Permalink to &quot;9.8: 磁場を小型コイルや衝撃検流計で測定する&quot;">&ZeroWidthSpace;</a></h3>
<ol start="9">
<li>磁場を小型コイルや衝撃検流計で測定する： <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo>=</mo></mrow><annotation encoding="application/x-tex">q=</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">q</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span></span></span></span> <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∫</mo><mfrac><mi>V</mi><mi>R</mi></mfrac><mrow><mtext> </mtext><mi mathvariant="normal">d</mi></mrow><mi>t</mi><mo>=</mo><mi>N</mi><mi>S</mi><mi mathvariant="normal">Δ</mi><mi>B</mi><mi mathvariant="normal">/</mi><mi>R</mi></mrow><annotation encoding="application/x-tex">\int \frac{V}{R} \mathrm{~d} t=N S \Delta B / R</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2173em;vertical-align:-0.345em;"></span><span class="mop op-symbol small-op" style="margin-right:0.19445em;position:relative;top:-0.0006em;">∫</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8723em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.00773em;">R</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.22222em;">V</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">d</span></span><span class="mord mathnormal">t</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.05764em;">NS</span><span class="mord">Δ</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span><span class="mord">/</span><span class="mord mathnormal" style="margin-right:0.00773em;">R</span></span></span></span>.</li>
</ol>
<h3 id="_9-9-静電場のエネルギー" tabindex="-1">9.9: 静電場のエネルギー <a class="header-anchor" href="#_9-9-静電場のエネルギー" aria-label="Permalink to &quot;9.9: 静電場のエネルギー&quot;">&ZeroWidthSpace;</a></h3>
<ol start="9">
<li>静電場のエネルギー：<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mi>U</mi><mo>=</mo><mi>k</mi><munder><mo>∑</mo><mrow><mi>i</mi><mo>&lt;</mo><mi>j</mi></mrow></munder><mfrac><mrow><msub><mi>q</mi><mi>i</mi></msub><msub><mi>q</mi><mi>j</mi></msub></mrow><msub><mi>r</mi><mrow><mi>i</mi><mi>j</mi></mrow></msub></mfrac><mo>=</mo><mfrac><mn>1</mn><mn>2</mn></mfrac><mo>∫</mo><mi>ϕ</mi><mo stretchy="false">(</mo><mi mathvariant="bold-italic">r</mi><mo stretchy="false">)</mo><mi mathvariant="normal">d</mi><mi>q</mi><mo separator="true">,</mo><mrow><mtext> </mtext><mi mathvariant="normal">d</mi></mrow><mi>q</mi><mo>=</mo><mi>ρ</mi><mo stretchy="false">(</mo><mi mathvariant="bold-italic">r</mi><mo stretchy="false">)</mo><mi mathvariant="normal">d</mi><mi>V</mi></mrow><annotation encoding="application/x-tex">U=k \sum_{i&lt;j} \frac{q_i q_j}{r_{i j}}=\frac{1}{2} \int \phi(\boldsymbol{r}) \mathrm{d} q, \mathrm{~d} q=\rho(\boldsymbol{r}) \mathrm{d} V
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.10903em;">U</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:2.5213em;vertical-align:-1.4138em;"></span><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop op-limits"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.05em;"><span style="top:-1.8723em;margin-left:0em;"><span class="pstrut" style="height:3.05em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">i</span><span class="mrel mtight">&lt;</span><span class="mord mathnormal mtight" style="margin-right:0.05724em;">j</span></span></span></span><span style="top:-3.05em;"><span class="pstrut" style="height:3.05em;"></span><span><span class="mop op-symbol large-op">∑</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.4138em;"><span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1076em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"><span class="mord mathnormal" style="margin-right:0.02778em;">r</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:-0.0278em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.05724em;">ij</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">q</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">q</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.05724em;">j</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.9721em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:2.2222em;vertical-align:-0.8622em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.3214em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">2</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop op-symbol large-op" style="margin-right:0.44445em;position:relative;top:-0.0011em;">∫</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">ϕ</span><span class="mopen">(</span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03194em;">r</span></span></span><span class="mclose">)</span><span class="mord mathrm">d</span><span class="mord mathnormal" style="margin-right:0.03588em;">q</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">d</span></span><span class="mord mathnormal" style="margin-right:0.03588em;">q</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal">ρ</span><span class="mopen">(</span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03194em;">r</span></span></span><span class="mclose">)</span><span class="mord mathrm">d</span><span class="mord mathnormal" style="margin-right:0.22222em;">V</span></span></span></span></span></p>
</li>
</ol>
<h3 id="_9-10-一様に帯電した球面や円筒面の各部分の間に働く力" tabindex="-1">9.10: 一様に帯電した球面や円筒面の各部分の間に働く力 <a class="header-anchor" href="#_9-10-一様に帯電した球面や円筒面の各部分の間に働く力" aria-label="Permalink to &quot;9.10: 一様に帯電した球面や円筒面の各部分の間に働く力&quot;">&ZeroWidthSpace;</a></h3>
<ol start="10">
<li>一様に帯電した球面や円筒面の各部分の間に働く力 : 帯電による力を静水圧による力に置き換える.</li>
</ol>
<h3 id="_9-11-全ての電荷" tabindex="-1">9.11: 全ての電荷 <a class="header-anchor" href="#_9-11-全ての電荷" aria-label="Permalink to &quot;9.11: 全ての電荷&quot;">&ZeroWidthSpace;</a></h3>
<ol start="12">
<li>全ての電荷が距離 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>r</mi></mrow><annotation encoding="application/x-tex">r</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal" style="margin-right:0.02778em;">r</span></span></span></span> にある場合（例えば，不均一に帯 電した球やリングの中心） <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ϕ</mi><mi>ϕ</mi><mo>=</mo><mi>k</mi><mi>Q</mi><mi mathvariant="normal">/</mi><mi>r</mi></mrow><annotation encoding="application/x-tex">\phi \phi=k Q / r</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">ϕϕ</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="mord mathnormal">Q</span><span class="mord">/</span><span class="mord mathnormal" style="margin-right:0.02778em;">r</span></span></span></span></li>
</ol>
<h3 id="_9-12-外部電荷" tabindex="-1">9.12: 外部電荷 <a class="header-anchor" href="#_9-12-外部電荷" aria-label="Permalink to &quot;9.12: 外部電荷&quot;">&ZeroWidthSpace;</a></h3>
<ol start="13">
<li>外部電荷によって引き起こされる正味の電荷（又は電 位）を求めるには, 電荷を「出現」させて問題を対称的 にし，重ね合わせの原理を用いる.</li>
</ol>
<h3 id="_9-14-導体" tabindex="-1">9.14: 導体 <a class="header-anchor" href="#_9-14-導体" aria-label="Permalink to &quot;9.14: 導体&quot;">&ZeroWidthSpace;</a></h3>
<ol start="14">
<li>導体は電荷や電場を遮蔽する．例えば，中空の球体の 内部の電荷分布は外から見えない（あたかも <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>Q</mi></mrow><annotation encoding="application/x-tex">Q</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8778em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">Q</span></span></span></span> という 電荷を持った導電性の球があるように見える).</li>
</ol>
<h3 id="_9-15-静電容量" tabindex="-1">9.15: 静電容量 <a class="header-anchor" href="#_9-15-静電容量" aria-label="Permalink to &quot;9.15: 静電容量&quot;">&ZeroWidthSpace;</a></h3>
<ol start="15">
<li>静電容量: <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>C</mi><mo>=</mo><mi>ε</mi><mi>S</mi><mi mathvariant="normal">/</mi><mi>d</mi></mrow><annotation encoding="application/x-tex">C=\varepsilon S / d</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.07153em;">C</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.05764em;">εS</span><span class="mord">/</span><span class="mord mathnormal">d</span></span></span></span> (平板), <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>4</mn><mi>π</mi><mi>ε</mi><mi>r</mi></mrow><annotation encoding="application/x-tex">4 \pi \varepsilon r</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">4</span><span class="mord mathnormal" style="margin-right:0.03588em;">π</span><span class="mord mathnormal">ε</span><span class="mord mathnormal" style="margin-right:0.02778em;">r</span></span></span></span> (球), <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>2</mn><mi>π</mi><mi>ε</mi><mi>l</mi><mo stretchy="false">(</mo><mi>ln</mi><mo>⁡</mo><mi>R</mi><mi mathvariant="normal">/</mi><mi>r</mi><msup><mo stretchy="false">)</mo><mrow><mo>−</mo><mn>1</mn></mrow></msup></mrow><annotation encoding="application/x-tex">2 \pi \varepsilon l(\ln R / r)^{-1}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0641em;vertical-align:-0.25em;"></span><span class="mord">2</span><span class="mord mathnormal" style="margin-right:0.03588em;">π</span><span class="mord mathnormal" style="margin-right:0.01968em;">εl</span><span class="mopen">(</span><span class="mop">ln</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.00773em;">R</span><span class="mord">/</span><span class="mord mathnormal" style="margin-right:0.02778em;">r</span><span class="mclose"><span class="mclose">)</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">−</span><span class="mord mtight">1</span></span></span></span></span></span></span></span></span></span></span></span> (同軸円筒).</li>
</ol>
<h3 id="_9-16-双極子モーメント" tabindex="-1">9.16: 双極子モーメント <a class="header-anchor" href="#_9-16-双極子モーメント" aria-label="Permalink to &quot;9.16: 双極子モーメント&quot;">&ZeroWidthSpace;</a></h3>
<ol start="16">
<li>
<p>双極子モーメント：</p>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><msub><mi mathvariant="bold-italic">p</mi><mi>e</mi></msub><mo>=</mo><mo>∑</mo><msub><mi>q</mi><mi>i</mi></msub><msub><mi mathvariant="bold-italic">r</mi><mi>i</mi></msub><mo>=</mo><mi>q</mi><mi mathvariant="bold-italic">d</mi><mo separator="true">,</mo><msub><mi mathvariant="bold-italic">p</mi><mi>μ</mi></msub><mo>=</mo><mi>I</mi><mi mathvariant="bold-italic">S</mi></mrow><annotation encoding="application/x-tex">\boldsymbol{p}_e=\sum q_i \boldsymbol{r}_i=q \boldsymbol{d}, \boldsymbol{p}_\mu=I \boldsymbol{S}
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6886em;vertical-align:-0.2441em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol">p</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.0573em;"><span style="top:-2.4559em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">e</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2441em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.6em;vertical-align:-0.55em;"></span><span class="mop op-symbol large-op" style="position:relative;top:0em;">∑</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">q</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03194em;">r</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.0747em;vertical-align:-0.3802em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">q</span><span class="mord"><span class="mord"><span class="mord boldsymbol">d</span></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol">p</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.0573em;"><span style="top:-2.4559em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">μ</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.3802em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6861em;"></span><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.05382em;">S</span></span></span></span></span></span></span></p>
</li>
</ol>
<h3 id="_9-17-双極子場" tabindex="-1">9.17: 双極子場 <a class="header-anchor" href="#_9-17-双極子場" aria-label="Permalink to &quot;9.17: 双極子場&quot;">&ZeroWidthSpace;</a></h3>
<ol start="17">
<li>双極子場 : <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ϕ</mi><mo>=</mo><mi>k</mi><mi mathvariant="bold-italic">p</mi><mo>⋅</mo><msub><mi mathvariant="bold-italic">e</mi><mi>r</mi></msub><mi mathvariant="normal">/</mi><msup><mi>r</mi><mn>2</mn></msup><mo separator="true">,</mo><mi>E</mi><mo separator="true">,</mo><mi>B</mi><mo>∝</mo><msup><mi>r</mi><mrow><mo>−</mo><mn>3</mn></mrow></msup></mrow><annotation encoding="application/x-tex">\phi=k \boldsymbol{p} \cdot \boldsymbol{e}_r / r^2, E, B \propto r^{-3}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">ϕ</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="mord"><span class="mord"><span class="mord boldsymbol">p</span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">⋅</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1.0641em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol">e</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.02778em;">r</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord">/</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.02778em;">r</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.05764em;">E</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">∝</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8141em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.02778em;">r</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">−</span><span class="mord mtight">3</span></span></span></span></span></span></span></span></span></span></span></span></li>
</ol>
<h3 id="_9-18-双極子に働く力" tabindex="-1">9.18: 双極子に働く力 <a class="header-anchor" href="#_9-18-双極子に働く力" aria-label="Permalink to &quot;9.18: 双極子に働く力&quot;">&ZeroWidthSpace;</a></h3>
<ol start="19">
<li>双極子に働く力 : <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>F</mi><mo>=</mo><msup><mrow><mo fence="true">(</mo><msub><mi mathvariant="bold-italic">p</mi><mi>e</mi></msub><mo>⋅</mo><mi mathvariant="bold-italic">E</mi><mo fence="true">)</mo></mrow><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup><mo separator="true">,</mo><mi>F</mi><mo>=</mo><msup><mrow><mo fence="true">(</mo><msub><mi mathvariant="bold-italic">p</mi><mi>μ</mi></msub><mo>⋅</mo><mi mathvariant="bold-italic">B</mi><mo fence="true">)</mo></mrow><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup></mrow><annotation encoding="application/x-tex">F=\left(\boldsymbol{p}_e \cdot \boldsymbol{E}\right)^{\prime}, F=\left(\boldsymbol{p}_\mu \cdot \boldsymbol{B}\right)^{\prime}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.13889em;">F</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.1418em;vertical-align:-0.25em;"></span><span class="minner"><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol">p</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.0573em;"><span style="top:-2.4559em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">e</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2441em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">⋅</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.05451em;">E</span></span></span><span class="mclose delimcenter" style="top:0em;">)</span></span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8918em;"><span style="top:-3.2029em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.13889em;">F</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.372em;vertical-align:-0.3802em;"></span><span class="minner"><span class="minner"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size1">(</span></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol">p</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.0573em;"><span style="top:-2.4559em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">μ</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.3802em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">⋅</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.04835em;">B</span></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size1">)</span></span></span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.9918em;"><span style="top:-3.3029em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span></span></span></span> [訳 者注 : ここの微分はむしろ <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">grad</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\operatorname{grad}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mop"><span class="mord mathrm">grad</span></span></span></span></span> である]. 2 つの双極 子間の相互作用 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>:</mo><mi>F</mi><mo>∝</mo><msup><mi>r</mi><mrow><mo>−</mo><mn>4</mn></mrow></msup></mrow><annotation encoding="application/x-tex">: F \propto r^{-4}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mrel">:</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.13889em;">F</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">∝</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8141em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.02778em;">r</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">−</span><span class="mord mtight">4</span></span></span></span></span></span></span></span></span></span></span></span>.</li>
</ol>
<h3 id="_9-19-磁気双極子としての点電荷" tabindex="-1">9.19: 磁気双極子としての点電荷 <a class="header-anchor" href="#_9-19-磁気双極子としての点電荷" aria-label="Permalink to &quot;9.19: 磁気双極子としての点電荷&quot;">&ZeroWidthSpace;</a></h3>
<ol start="19">
<li>磁気双極子としての点電荷 : <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>p</mi><mi>μ</mi></msub><mo>∝</mo><mi mathvariant="normal">Φ</mi><mo>∝</mo><msubsup><mi>v</mi><mo lspace="0em" rspace="0em">⊥</mo><mn>2</mn></msubsup><mi mathvariant="normal">/</mi><mi>B</mi></mrow><annotation encoding="application/x-tex">p_\mu \propto \Phi \propto v_{\perp}^2 / B</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7167em;vertical-align:-0.2861em;"></span><span class="mord"><span class="mord mathnormal">p</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">μ</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">∝</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">Φ</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">∝</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.0972em;vertical-align:-0.2831em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-2.4169em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mrel mtight">⊥</span></span></span></span><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2831em;"><span></span></span></span></span></span></span><span class="mord">/</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span></span> は断熱 不変量 (<a href="./4.html#_4-22-断熱不変量">Section 4: #22</a> 参照).</li>
</ol>
<h3 id="_9-20-鏡像法" tabindex="-1">9.20: 鏡像法 <a class="header-anchor" href="#_9-20-鏡像法" aria-label="Permalink to &quot;9.20: 鏡像法&quot;">&ZeroWidthSpace;</a></h3>
<ol start="20">
<li>鏡像法 : 接地された（磁石の場合は超電導の）平面が鏡 の役割をする. 接地された（又は孤立した）球体の場 は, 球体の内部にある 1 つ（又は 2 つ）の架空の電荷 のつくる場として求められる. 平面導波管（金属板の 間のスリット）内の場は, 電磁平面波の重ね合わせと して求められる.</li>
</ol>
<h3 id="_9-21-一様-電-場中の球-円柱-の分極" tabindex="-1">9.21: 一様（電）場中の球 (円柱) の分極 <a class="header-anchor" href="#_9-21-一様-電-場中の球-円柱-の分極" aria-label="Permalink to &quot;9.21: 一様（電）場中の球 (円柱) の分極&quot;">&ZeroWidthSpace;</a></h3>
<ol start="21">
<li>一様（電）場中の球 (円柱) の分極 : <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">(</mo><mo>+</mo><mi>ρ</mi></mrow><annotation encoding="application/x-tex">(+\rho</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">(</span><span class="mord">+</span><span class="mord mathnormal">ρ</span></span></span></span> と <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>−</mo><mi>ρ</mi></mrow><annotation encoding="application/x-tex">-\rho</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7778em;vertical-align:-0.1944em;"></span><span class="mord">−</span><span class="mord mathnormal">ρ</span></span></span></span> に一 様に帯電した球 (円柱) の重ね合わせで， <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>d</mi><mo>∝</mo><mi>E</mi></mrow><annotation encoding="application/x-tex">d \propto E</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">d</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">∝</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.05764em;">E</span></span></span></span>.</li>
</ol>
<h3 id="_9-22-渦電流" tabindex="-1">9.22: 渦電流 <a class="header-anchor" href="#_9-22-渦電流" aria-label="Permalink to &quot;9.22: 渦電流&quot;">&ZeroWidthSpace;</a></h3>
<ol start="22">
<li>渦電流: 電流損失密度 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≈</mo><msup><mi>B</mi><mn>2</mn></msup><msup><mi>v</mi><mn>2</mn></msup><mi mathvariant="normal">/</mi><mi>ρ</mi><mi mathvariant="normal">.</mi><mn>1</mn></mrow><annotation encoding="application/x-tex">\approx B^2 v^2 / \rho .1</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4831em;"></span><span class="mrel">≈</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.0641em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.05017em;">B</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mord">/</span><span class="mord mathnormal">ρ</span><span class="mord">.1</span></span></span></span> 回の通過で与え られる運動量 : <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>F</mi><mi>τ</mi><mo>≈</mo><msup><mi>B</mi><mn>2</mn></msup><msup><mi>a</mi><mn>3</mn></msup><mi>d</mi><mi mathvariant="normal">/</mi><mi>ρ</mi></mrow><annotation encoding="application/x-tex">F \tau \approx B^2 a^3 d / \rho</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.13889em;">F</span><span class="mord mathnormal" style="margin-right:0.1132em;">τ</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≈</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.0641em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.05017em;">B</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">3</span></span></span></span></span></span></span></span><span class="mord mathnormal">d</span><span class="mord">/</span><span class="mord mathnormal">ρ</span></span></span></span> (ここで <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>d</mi></mrow><annotation encoding="application/x-tex">d</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">d</span></span></span></span> は厚さ, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi></mrow><annotation encoding="application/x-tex">a</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">a</span></span></span></span> は大きさ).</li>
</ol>
]]></description>
            <content:encoded><![CDATA[<h1 id="formulas-for-ipho-日本語版-section-9" tabindex="-1">Formulas for IPhO 日本語版: Section 9 <a class="header-anchor" href="#formulas-for-ipho-日本語版-section-9" aria-label="Permalink to &quot;Formulas for IPhO 日本語版: Section 9&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="_9-電磁気学" tabindex="-1">9: 電磁気学 <a class="header-anchor" href="#_9-電磁気学" aria-label="Permalink to &quot;9: 電磁気学&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="_9-1-coulomb-の法則" tabindex="-1">9.1: Coulomb の法則 <a class="header-anchor" href="#_9-1-coulomb-の法則" aria-label="Permalink to &quot;9.1: Coulomb の法則&quot;">&ZeroWidthSpace;</a></h3>
<ol>
<li><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>F</mi><mo>=</mo><mi>k</mi><msub><mi>q</mi><mn>1</mn></msub><msub><mi>q</mi><mn>2</mn></msub><mi mathvariant="normal">/</mi><msup><mi>r</mi><mn>2</mn></msup><mo separator="true">,</mo><mi>U</mi><mo>=</mo><mi>k</mi><msub><mi>q</mi><mn>1</mn></msub><msub><mi>q</mi><mn>2</mn></msub><mi mathvariant="normal">/</mi><mi>r</mi></mrow><annotation encoding="application/x-tex">F=k q_1 q_2 / r^2, U=k q_1 q_2 / r</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.13889em;">F</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.0641em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">q</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">q</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord">/</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.02778em;">r</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.10903em;">U</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">q</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">q</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord">/</span><span class="mord mathnormal" style="margin-right:0.02778em;">r</span></span></span></span> で, Kepler の法則が 使える (<a href="./12.html">Section 12 参照</a>).</li>
</ol>
<h3 id="_9-2-gauss-の法則" tabindex="-1">9.2: Gauss の法則 <a class="header-anchor" href="#_9-2-gauss-の法則" aria-label="Permalink to &quot;9.2: Gauss の法則&quot;">&ZeroWidthSpace;</a></h3>
<ol start="2">
<li>
<p>Gauss の法則 : <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∮</mo><mi mathvariant="bold-italic">B</mi><mo>⋅</mo><mi mathvariant="normal">d</mi><mi mathvariant="bold-italic">S</mi><mo>=</mo><mn>0</mn></mrow><annotation encoding="application/x-tex">\oint \boldsymbol{B} \cdot \mathrm{d} \boldsymbol{S}=0</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1111em;vertical-align:-0.3061em;"></span><span class="mop op-symbol small-op" style="margin-right:0.19445em;position:relative;top:-0.0006em;">∮</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.04835em;">B</span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">⋅</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathrm">d</span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.05382em;">S</span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">0</span></span></span></span>,</p>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mo>∮</mo><mi>ε</mi><mi mathvariant="bold-italic">E</mi><mo>⋅</mo><mi mathvariant="normal">d</mi><mi mathvariant="bold-italic">S</mi><mo>=</mo><mi>Q</mi><mo separator="true">,</mo><mo>∮</mo><mi mathvariant="bold-italic">g</mi><mo>⋅</mo><mi mathvariant="normal">d</mi><mi mathvariant="bold-italic">S</mi><mo>=</mo><mo>−</mo><mn>4</mn><mi>π</mi><mi>G</mi><mi>M</mi></mrow><annotation encoding="application/x-tex">\oint \varepsilon \boldsymbol{E} \cdot \mathrm{d} \boldsymbol{S}=Q, \oint \boldsymbol{g} \cdot \mathrm{d} \boldsymbol{S}=-4 \pi G M
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.2222em;vertical-align:-0.8622em;"></span><span class="mop op-symbol large-op" style="margin-right:0.44445em;position:relative;top:-0.0011em;">∮</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">ε</span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.05451em;">E</span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">⋅</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathrm">d</span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.05382em;">S</span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:2.2222em;vertical-align:-0.8622em;"></span><span class="mord mathnormal">Q</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop op-symbol large-op" style="margin-right:0.44445em;position:relative;top:-0.0011em;">∮</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03704em;">g</span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">⋅</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathrm">d</span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.05382em;">S</span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.7667em;vertical-align:-0.0833em;"></span><span class="mord">−</span><span class="mord">4</span><span class="mord mathnormal" style="margin-right:0.03588em;">π</span><span class="mord mathnormal" style="margin-right:0.10903em;">GM</span></span></span></span></span></p>
</li>
</ol>
<h3 id="_9-3-循環定理" tabindex="-1">9.3: 循環定理 <a class="header-anchor" href="#_9-3-循環定理" aria-label="Permalink to &quot;9.3: 循環定理&quot;">&ZeroWidthSpace;</a></h3>
<ol start="3">
<li>
<p>循環定理 :</p>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mo>∮</mo><mi mathvariant="bold-italic">E</mi><mo>⋅</mo><mi mathvariant="normal">d</mi><mi mathvariant="bold-italic">l</mi><mo>=</mo><mn>0</mn><mo stretchy="false">(</mo><mo>=</mo><mover accent="true"><mi mathvariant="normal">Φ</mi><mo>˙</mo></mover><mo stretchy="false">)</mo><mo separator="true">,</mo><mo>∮</mo><mfrac><mrow><mi mathvariant="bold-italic">B</mi><mo>⋅</mo><mi mathvariant="normal">d</mi><mi mathvariant="bold-italic">l</mi></mrow><mi>μ</mi></mfrac><mo>=</mo><mi>I</mi><mo separator="true">,</mo><mo>∮</mo><mi mathvariant="bold-italic">g</mi><mo>⋅</mo><mi mathvariant="normal">d</mi><mi mathvariant="bold-italic">l</mi><mo>=</mo><mn>0</mn></mrow><annotation encoding="application/x-tex">\oint \boldsymbol{E} \cdot \mathrm{d} \boldsymbol{l}=0(=\dot{\Phi}), \oint \frac{\boldsymbol{B} \cdot \mathrm{d} \boldsymbol{l}}{\mu}=I, \oint \boldsymbol{g} \cdot \mathrm{d} \boldsymbol{l}=0
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.2222em;vertical-align:-0.8622em;"></span><span class="mop op-symbol large-op" style="margin-right:0.44445em;position:relative;top:-0.0011em;">∮</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.05451em;">E</span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">⋅</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathrm">d</span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.0088em;">l</span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">0</span><span class="mopen">(</span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:2.2519em;vertical-align:-0.8804em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.9202em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord">Φ</span></span><span style="top:-3.2523em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.1389em;"><span class="mord">˙</span></span></span></span></span></span></span><span class="mclose">)</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop op-symbol large-op" style="margin-right:0.44445em;position:relative;top:-0.0011em;">∮</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.3714em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">μ</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.04835em;">B</span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">⋅</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathrm">d</span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.0088em;">l</span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.8804em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:2.2222em;vertical-align:-0.8622em;"></span><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop op-symbol large-op" style="margin-right:0.44445em;position:relative;top:-0.0011em;">∮</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03704em;">g</span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">⋅</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathrm">d</span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.0088em;">l</span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">0</span></span></span></span></span></p>
</li>
</ol>
<h3 id="_9-4-電流素片により生じる磁束密度" tabindex="-1">9.4: 電流素片により生じる磁束密度 <a class="header-anchor" href="#_9-4-電流素片により生じる磁束密度" aria-label="Permalink to &quot;9.4: 電流素片により生じる磁束密度&quot;">&ZeroWidthSpace;</a></h3>
<ol start="4">
<li>電流素片により生じる磁束密度 :<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mi mathvariant="normal">d</mi><mi mathvariant="bold-italic">B</mi><mo>=</mo><mfrac><mrow><mi>μ</mi><mi>I</mi></mrow><mrow><mn>4</mn><mi>π</mi></mrow></mfrac><mfrac><mrow><mi mathvariant="normal">d</mi><mi mathvariant="bold-italic">l</mi><mo>×</mo><msub><mi mathvariant="bold-italic">e</mi><mi>r</mi></msub></mrow><msup><mi>r</mi><mn>2</mn></msup></mfrac><mi mathvariant="normal">.</mi></mrow><annotation encoding="application/x-tex">\mathrm{d} \boldsymbol{B}=\frac{\mu I}{4 \pi} \frac{\mathrm{d} \boldsymbol{l} \times \boldsymbol{e}_r}{r^2} .
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathrm">d</span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.04835em;">B</span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:2.0574em;vertical-align:-0.686em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.3603em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">4</span><span class="mord mathnormal" style="margin-right:0.03588em;">π</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">μ</span><span class="mord mathnormal" style="margin-right:0.07847em;">I</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.3714em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"><span class="mord mathnormal" style="margin-right:0.02778em;">r</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7401em;"><span style="top:-2.989em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathrm">d</span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.0088em;">l</span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">×</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol">e</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.02778em;">r</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mord">.</span></span></span></span></span></p>
したがって電流 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>I</mi></mrow><annotation encoding="application/x-tex">I</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.07847em;">I</span></span></span></span> が流れる円形回路の中心では <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>B</mi><mo>=</mo><mfrac><mrow><msub><mi>μ</mi><mn>0</mn></msub><mi>I</mi></mrow><mrow><mn>2</mn><mi>r</mi></mrow></mfrac></mrow><annotation encoding="application/x-tex">B=\frac{\mu_0 I}{2 r}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.2694em;vertical-align:-0.345em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.9244em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span><span class="mord mathnormal mtight" style="margin-right:0.02778em;">r</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.4461em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight"><span class="mord mathnormal mtight">μ</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3173em;"><span style="top:-2.357em;margin-left:0em;margin-right:0.0714em;"><span class="pstrut" style="height:2.5em;"></span><span class="sizing reset-size3 size1 mtight"><span class="mord mtight">0</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.143em;"><span></span></span></span></span></span></span><span class="mord mathnormal mtight" style="margin-right:0.07847em;">I</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span>.</li>
</ol>
<h3 id="_9-5-ローレンツ力" tabindex="-1">9.5: ローレンツ力 <a class="header-anchor" href="#_9-5-ローレンツ力" aria-label="Permalink to &quot;9.5: ローレンツ力&quot;">&ZeroWidthSpace;</a></h3>
<ol start="5">
<li><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="bold-italic">F</mi><mo>=</mo><mi>e</mi><mo stretchy="false">(</mo><mi mathvariant="bold-italic">E</mi><mo>+</mo><mi mathvariant="bold-italic">v</mi><mo>×</mo><mi mathvariant="bold-italic">B</mi><mo stretchy="false">)</mo><mo separator="true">,</mo><mi mathvariant="bold-italic">F</mi><mo>=</mo><mi mathvariant="bold-italic">I</mi><mo>×</mo><mi mathvariant="bold-italic">B</mi><mi>l</mi></mrow><annotation encoding="application/x-tex">\boldsymbol{F}=e(\boldsymbol{E}+\boldsymbol{v} \times \boldsymbol{B}), \boldsymbol{F}=\boldsymbol{I} \times \boldsymbol{B} l</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6861em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.15972em;">F</span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal">e</span><span class="mopen">(</span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.05451em;">E</span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03704em;">v</span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">×</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.04835em;">B</span></span></span><span class="mclose">)</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.15972em;">F</span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.7694em;vertical-align:-0.0833em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.07778em;">I</span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">×</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.04835em;">B</span></span></span><span class="mord mathnormal" style="margin-right:0.01968em;">l</span></span></span></span>.</li>
</ol>
<h3 id="_9-6-gauss-の定理と循環定理より" tabindex="-1">9.6: Gauss の定理と循環定理より <a class="header-anchor" href="#_9-6-gauss-の定理と循環定理より" aria-label="Permalink to &quot;9.6: Gauss の定理と循環定理より&quot;">&ZeroWidthSpace;</a></h3>
<ol start="6">
<li>Gauss の定理と循環定理より：帯電した導線について <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>E</mi><mo>=</mo><mfrac><mi>σ</mi><mrow><mn>2</mn><mi>π</mi><msub><mi>ε</mi><mn>0</mn></msub><mi>r</mi></mrow></mfrac></mrow><annotation encoding="application/x-tex">E=\frac{\sigma}{2 \pi \varepsilon_0 r}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.05764em;">E</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.1405em;vertical-align:-0.4451em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6954em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span><span class="mord mathnormal mtight" style="margin-right:0.03588em;">π</span><span class="mord mtight"><span class="mord mathnormal mtight">ε</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3173em;"><span style="top:-2.357em;margin-left:0em;margin-right:0.0714em;"><span class="pstrut" style="height:2.5em;"></span><span class="sizing reset-size3 size1 mtight"><span class="mord mtight">0</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.143em;"><span></span></span></span></span></span></span><span class="mord mathnormal mtight" style="margin-right:0.02778em;">r</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.03588em;">σ</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.4451em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span>, 電流が流れる導線について <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>B</mi><mo>=</mo><mfrac><mrow><msub><mi>μ</mi><mn>0</mn></msub><mi>I</mi></mrow><mrow><mn>2</mn><mi>π</mi><mi>r</mi></mrow></mfrac></mrow><annotation encoding="application/x-tex">B=\frac{\mu_0 I}{2 \pi r}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.2694em;vertical-align:-0.345em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.9244em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span><span class="mord mathnormal mtight" style="margin-right:0.03588em;">π</span><span class="mord mathnormal mtight" style="margin-right:0.02778em;">r</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.4461em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight"><span class="mord mathnormal mtight">μ</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3173em;"><span style="top:-2.357em;margin-left:0em;margin-right:0.0714em;"><span class="pstrut" style="height:2.5em;"></span><span class="sizing reset-size3 size1 mtight"><span class="mord mtight">0</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.143em;"><span></span></span></span></span></span></span><span class="mord mathnormal mtight" style="margin-right:0.07847em;">I</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span>. 帯電した面について <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>E</mi><mo>=</mo><mfrac><mi>σ</mi><mrow><mn>2</mn><msub><mi>ε</mi><mn>0</mn></msub></mrow></mfrac></mrow><annotation encoding="application/x-tex">E=\frac{\sigma}{2 \varepsilon_0}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.05764em;">E</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.1405em;vertical-align:-0.4451em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6954em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span><span class="mord mtight"><span class="mord mathnormal mtight">ε</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3173em;"><span style="top:-2.357em;margin-left:0em;margin-right:0.0714em;"><span class="pstrut" style="height:2.5em;"></span><span class="sizing reset-size3 size1 mtight"><span class="mord mtight">0</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.143em;"><span></span></span></span></span></span></span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.03588em;">σ</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.4451em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span>, 電流が流れる面につい て <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>B</mi><mo>=</mo><mfrac><mrow><msub><mi>μ</mi><mn>0</mn></msub><mi>i</mi></mrow><mn>2</mn></mfrac></mrow><annotation encoding="application/x-tex">B=\frac{\mu_0 i}{2}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.2528em;vertical-align:-0.345em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.9078em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.4461em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight"><span class="mord mathnormal mtight">μ</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3173em;"><span style="top:-2.357em;margin-left:0em;margin-right:0.0714em;"><span class="pstrut" style="height:2.5em;"></span><span class="sizing reset-size3 size1 mtight"><span class="mord mtight">0</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.143em;"><span></span></span></span></span></span></span><span class="mord mathnormal mtight">i</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span>. 一様に帯電した球殼（又は無限に長い円 筒）の内部で <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>E</mi><mo>=</mo><mn>0</mn></mrow><annotation encoding="application/x-tex">E=0</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.05764em;">E</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">0</span></span></span></span>, 軸に沿って表面に電流が流れる 円筒の内部で <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>B</mi><mo>=</mo><mn>0</mn></mrow><annotation encoding="application/x-tex">B=0</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">0</span></span></span></span>. 密度 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ρ</mi></mrow><annotation encoding="application/x-tex">\rho</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">ρ</span></span></span></span> で一様に帯電, 又は一様 な電流 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="bold-italic">i</mi></mrow><annotation encoding="application/x-tex">\boldsymbol{i}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6933em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol">i</span></span></span></span></span></span> が流れる, 球 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">(</mo><mi>d</mi><mo>=</mo><mn>3</mn><mo stretchy="false">)</mo><mi mathvariant="normal">/</mi></mrow><annotation encoding="application/x-tex">(d=3) /</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">(</span><span class="mord mathnormal">d</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">3</span><span class="mclose">)</span><span class="mord">/</span></span></span></span> 円柱 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">(</mo><mi>d</mi><mo>−</mo><mn>2</mn><mo stretchy="false">)</mo><mi mathvariant="normal">/</mi></mrow><annotation encoding="application/x-tex">(d-2) /</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">(</span><span class="mord mathnormal">d</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">2</span><span class="mclose">)</span><span class="mord">/</span></span></span></span> 平面 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">(</mo><mi>d</mi><mo>=</mo><mn>1</mn><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">(d=1)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">(</span><span class="mord mathnormal">d</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">1</span><span class="mclose">)</span></span></span></span> の内部で,<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mi mathvariant="bold-italic">E</mi><mo>=</mo><mfrac><mi>ρ</mi><mrow><mi>ε</mi><mi>d</mi></mrow></mfrac><mi mathvariant="bold-italic">r</mi><mo separator="true">,</mo><mi mathvariant="bold-italic">B</mi><mo>=</mo><mfrac><mn>1</mn><mrow><mi>μ</mi><mi>d</mi></mrow></mfrac><mi mathvariant="bold-italic">i</mi><mo>×</mo><mi mathvariant="bold-italic">r</mi></mrow><annotation encoding="application/x-tex">\boldsymbol{E}=\frac{\rho}{\varepsilon d} \boldsymbol{r}, \boldsymbol{B}=\frac{1}{\mu d} \boldsymbol{i} \times \boldsymbol{r}
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6861em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.05451em;">E</span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.7936em;vertical-align:-0.686em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1076em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">ε</span><span class="mord mathnormal">d</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">ρ</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03194em;">r</span></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.04835em;">B</span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:2.2019em;vertical-align:-0.8804em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.3214em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">μ</span><span class="mord mathnormal">d</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.8804em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mord"><span class="mord"><span class="mord boldsymbol">i</span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">×</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.4444em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03194em;">r</span></span></span></span></span></span></span></p>
</li>
</ol>
<h3 id="_9-7-長いソレノイド" tabindex="-1">9.7: 長いソレノイド <a class="header-anchor" href="#_9-7-長いソレノイド" aria-label="Permalink to &quot;9.7: 長いソレノイド&quot;">&ZeroWidthSpace;</a></h3>
<ol start="7">
<li>長いソレノイド: 内部で <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>B</mi><mo>=</mo><mi>μ</mi><mi>n</mi><mi>I</mi></mrow><annotation encoding="application/x-tex">B=\mu n I</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8778em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">μ</span><span class="mord mathnormal">n</span><span class="mord mathnormal" style="margin-right:0.07847em;">I</span></span></span></span>, 外部で <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>B</mi><mo>=</mo><mn>0</mn></mrow><annotation encoding="application/x-tex">B=0</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">0</span></span></span></span>. 磁束 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Φ</mi><mo>=</mo><mi>N</mi><mi>B</mi><mi>S</mi><mrow><mo fence="true">(</mo><mi>n</mi><mo>=</mo><mfrac><mi>N</mi><mi>l</mi></mfrac><mo fence="true">)</mo></mrow></mrow><annotation encoding="application/x-tex">\Phi=N B S\left(n=\frac{N}{l}\right)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">Φ</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.2223em;vertical-align:-0.35em;"></span><span class="mord mathnormal" style="margin-right:0.05764em;">NBS</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size1">(</span></span><span class="mord mathnormal">n</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8723em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.01968em;">l</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.10903em;">N</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size1">)</span></span></span></span></span></span>. インダクタンス <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>L</mi><mo>=</mo></mrow><annotation encoding="application/x-tex">L=</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal">L</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span></span></span></span> <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Φ</mi><mi mathvariant="normal">/</mi><mi>I</mi><mo>=</mo><mi>μ</mi><msup><mi>n</mi><mn>2</mn></msup><mi>V</mi></mrow><annotation encoding="application/x-tex">\Phi / I=\mu n^2 V</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">Φ/</span><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.0085em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">μ</span><span class="mord"><span class="mord mathnormal">n</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mord mathnormal" style="margin-right:0.22222em;">V</span></span></span></span>. 短いソレノイド <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>:</mo><msub><mi>B</mi><mi mathvariant="normal">∥</mi></msub><mo>=</mo><mfrac><mrow><mi>μ</mi><mi>n</mi><mi>I</mi><mi mathvariant="normal">Ω</mi></mrow><mrow><mn>4</mn><mi>π</mi></mrow></mfrac><mo stretchy="false">(</mo><mi mathvariant="normal">Ω</mi></mrow><annotation encoding="application/x-tex">: B_{\|}=\frac{\mu n I \Omega}{4 \pi}(\Omega</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mrel">:</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.0385em;vertical-align:-0.3552em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.05017em;">B</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3448em;"><span style="top:-2.5198em;margin-left:-0.0502em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">∥</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.3552em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.2694em;vertical-align:-0.345em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.9244em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">4</span><span class="mord mathnormal mtight" style="margin-right:0.03588em;">π</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.4461em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">μ</span><span class="mord mathnormal mtight">n</span><span class="mord mathnormal mtight" style="margin-right:0.07847em;">I</span><span class="mord mtight">Ω</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mopen">(</span><span class="mord">Ω</span></span></span></span> は 立体角).</li>
</ol>
<h3 id="_9-8-磁場を小型コイルや衝撃検流計で測定する" tabindex="-1">9.8: 磁場を小型コイルや衝撃検流計で測定する <a class="header-anchor" href="#_9-8-磁場を小型コイルや衝撃検流計で測定する" aria-label="Permalink to &quot;9.8: 磁場を小型コイルや衝撃検流計で測定する&quot;">&ZeroWidthSpace;</a></h3>
<ol start="9">
<li>磁場を小型コイルや衝撃検流計で測定する： <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo>=</mo></mrow><annotation encoding="application/x-tex">q=</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">q</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span></span></span></span> <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∫</mo><mfrac><mi>V</mi><mi>R</mi></mfrac><mrow><mtext> </mtext><mi mathvariant="normal">d</mi></mrow><mi>t</mi><mo>=</mo><mi>N</mi><mi>S</mi><mi mathvariant="normal">Δ</mi><mi>B</mi><mi mathvariant="normal">/</mi><mi>R</mi></mrow><annotation encoding="application/x-tex">\int \frac{V}{R} \mathrm{~d} t=N S \Delta B / R</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2173em;vertical-align:-0.345em;"></span><span class="mop op-symbol small-op" style="margin-right:0.19445em;position:relative;top:-0.0006em;">∫</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8723em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.00773em;">R</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.22222em;">V</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">d</span></span><span class="mord mathnormal">t</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.05764em;">NS</span><span class="mord">Δ</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span><span class="mord">/</span><span class="mord mathnormal" style="margin-right:0.00773em;">R</span></span></span></span>.</li>
</ol>
<h3 id="_9-9-静電場のエネルギー" tabindex="-1">9.9: 静電場のエネルギー <a class="header-anchor" href="#_9-9-静電場のエネルギー" aria-label="Permalink to &quot;9.9: 静電場のエネルギー&quot;">&ZeroWidthSpace;</a></h3>
<ol start="9">
<li>静電場のエネルギー：<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mi>U</mi><mo>=</mo><mi>k</mi><munder><mo>∑</mo><mrow><mi>i</mi><mo>&lt;</mo><mi>j</mi></mrow></munder><mfrac><mrow><msub><mi>q</mi><mi>i</mi></msub><msub><mi>q</mi><mi>j</mi></msub></mrow><msub><mi>r</mi><mrow><mi>i</mi><mi>j</mi></mrow></msub></mfrac><mo>=</mo><mfrac><mn>1</mn><mn>2</mn></mfrac><mo>∫</mo><mi>ϕ</mi><mo stretchy="false">(</mo><mi mathvariant="bold-italic">r</mi><mo stretchy="false">)</mo><mi mathvariant="normal">d</mi><mi>q</mi><mo separator="true">,</mo><mrow><mtext> </mtext><mi mathvariant="normal">d</mi></mrow><mi>q</mi><mo>=</mo><mi>ρ</mi><mo stretchy="false">(</mo><mi mathvariant="bold-italic">r</mi><mo stretchy="false">)</mo><mi mathvariant="normal">d</mi><mi>V</mi></mrow><annotation encoding="application/x-tex">U=k \sum_{i&lt;j} \frac{q_i q_j}{r_{i j}}=\frac{1}{2} \int \phi(\boldsymbol{r}) \mathrm{d} q, \mathrm{~d} q=\rho(\boldsymbol{r}) \mathrm{d} V
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.10903em;">U</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:2.5213em;vertical-align:-1.4138em;"></span><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop op-limits"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.05em;"><span style="top:-1.8723em;margin-left:0em;"><span class="pstrut" style="height:3.05em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">i</span><span class="mrel mtight">&lt;</span><span class="mord mathnormal mtight" style="margin-right:0.05724em;">j</span></span></span></span><span style="top:-3.05em;"><span class="pstrut" style="height:3.05em;"></span><span><span class="mop op-symbol large-op">∑</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.4138em;"><span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1076em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"><span class="mord mathnormal" style="margin-right:0.02778em;">r</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:-0.0278em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.05724em;">ij</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">q</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">q</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.05724em;">j</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.9721em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:2.2222em;vertical-align:-0.8622em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.3214em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">2</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop op-symbol large-op" style="margin-right:0.44445em;position:relative;top:-0.0011em;">∫</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">ϕ</span><span class="mopen">(</span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03194em;">r</span></span></span><span class="mclose">)</span><span class="mord mathrm">d</span><span class="mord mathnormal" style="margin-right:0.03588em;">q</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mspace nobreak"> </span><span class="mord mathrm">d</span></span><span class="mord mathnormal" style="margin-right:0.03588em;">q</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal">ρ</span><span class="mopen">(</span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03194em;">r</span></span></span><span class="mclose">)</span><span class="mord mathrm">d</span><span class="mord mathnormal" style="margin-right:0.22222em;">V</span></span></span></span></span></p>
</li>
</ol>
<h3 id="_9-10-一様に帯電した球面や円筒面の各部分の間に働く力" tabindex="-1">9.10: 一様に帯電した球面や円筒面の各部分の間に働く力 <a class="header-anchor" href="#_9-10-一様に帯電した球面や円筒面の各部分の間に働く力" aria-label="Permalink to &quot;9.10: 一様に帯電した球面や円筒面の各部分の間に働く力&quot;">&ZeroWidthSpace;</a></h3>
<ol start="10">
<li>一様に帯電した球面や円筒面の各部分の間に働く力 : 帯電による力を静水圧による力に置き換える.</li>
</ol>
<h3 id="_9-11-全ての電荷" tabindex="-1">9.11: 全ての電荷 <a class="header-anchor" href="#_9-11-全ての電荷" aria-label="Permalink to &quot;9.11: 全ての電荷&quot;">&ZeroWidthSpace;</a></h3>
<ol start="12">
<li>全ての電荷が距離 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>r</mi></mrow><annotation encoding="application/x-tex">r</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal" style="margin-right:0.02778em;">r</span></span></span></span> にある場合（例えば，不均一に帯 電した球やリングの中心） <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ϕ</mi><mi>ϕ</mi><mo>=</mo><mi>k</mi><mi>Q</mi><mi mathvariant="normal">/</mi><mi>r</mi></mrow><annotation encoding="application/x-tex">\phi \phi=k Q / r</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">ϕϕ</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="mord mathnormal">Q</span><span class="mord">/</span><span class="mord mathnormal" style="margin-right:0.02778em;">r</span></span></span></span></li>
</ol>
<h3 id="_9-12-外部電荷" tabindex="-1">9.12: 外部電荷 <a class="header-anchor" href="#_9-12-外部電荷" aria-label="Permalink to &quot;9.12: 外部電荷&quot;">&ZeroWidthSpace;</a></h3>
<ol start="13">
<li>外部電荷によって引き起こされる正味の電荷（又は電 位）を求めるには, 電荷を「出現」させて問題を対称的 にし，重ね合わせの原理を用いる.</li>
</ol>
<h3 id="_9-14-導体" tabindex="-1">9.14: 導体 <a class="header-anchor" href="#_9-14-導体" aria-label="Permalink to &quot;9.14: 導体&quot;">&ZeroWidthSpace;</a></h3>
<ol start="14">
<li>導体は電荷や電場を遮蔽する．例えば，中空の球体の 内部の電荷分布は外から見えない（あたかも <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>Q</mi></mrow><annotation encoding="application/x-tex">Q</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8778em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">Q</span></span></span></span> という 電荷を持った導電性の球があるように見える).</li>
</ol>
<h3 id="_9-15-静電容量" tabindex="-1">9.15: 静電容量 <a class="header-anchor" href="#_9-15-静電容量" aria-label="Permalink to &quot;9.15: 静電容量&quot;">&ZeroWidthSpace;</a></h3>
<ol start="15">
<li>静電容量: <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>C</mi><mo>=</mo><mi>ε</mi><mi>S</mi><mi mathvariant="normal">/</mi><mi>d</mi></mrow><annotation encoding="application/x-tex">C=\varepsilon S / d</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.07153em;">C</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.05764em;">εS</span><span class="mord">/</span><span class="mord mathnormal">d</span></span></span></span> (平板), <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>4</mn><mi>π</mi><mi>ε</mi><mi>r</mi></mrow><annotation encoding="application/x-tex">4 \pi \varepsilon r</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">4</span><span class="mord mathnormal" style="margin-right:0.03588em;">π</span><span class="mord mathnormal">ε</span><span class="mord mathnormal" style="margin-right:0.02778em;">r</span></span></span></span> (球), <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>2</mn><mi>π</mi><mi>ε</mi><mi>l</mi><mo stretchy="false">(</mo><mi>ln</mi><mo>⁡</mo><mi>R</mi><mi mathvariant="normal">/</mi><mi>r</mi><msup><mo stretchy="false">)</mo><mrow><mo>−</mo><mn>1</mn></mrow></msup></mrow><annotation encoding="application/x-tex">2 \pi \varepsilon l(\ln R / r)^{-1}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0641em;vertical-align:-0.25em;"></span><span class="mord">2</span><span class="mord mathnormal" style="margin-right:0.03588em;">π</span><span class="mord mathnormal" style="margin-right:0.01968em;">εl</span><span class="mopen">(</span><span class="mop">ln</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.00773em;">R</span><span class="mord">/</span><span class="mord mathnormal" style="margin-right:0.02778em;">r</span><span class="mclose"><span class="mclose">)</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">−</span><span class="mord mtight">1</span></span></span></span></span></span></span></span></span></span></span></span> (同軸円筒).</li>
</ol>
<h3 id="_9-16-双極子モーメント" tabindex="-1">9.16: 双極子モーメント <a class="header-anchor" href="#_9-16-双極子モーメント" aria-label="Permalink to &quot;9.16: 双極子モーメント&quot;">&ZeroWidthSpace;</a></h3>
<ol start="16">
<li>
<p>双極子モーメント：</p>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><msub><mi mathvariant="bold-italic">p</mi><mi>e</mi></msub><mo>=</mo><mo>∑</mo><msub><mi>q</mi><mi>i</mi></msub><msub><mi mathvariant="bold-italic">r</mi><mi>i</mi></msub><mo>=</mo><mi>q</mi><mi mathvariant="bold-italic">d</mi><mo separator="true">,</mo><msub><mi mathvariant="bold-italic">p</mi><mi>μ</mi></msub><mo>=</mo><mi>I</mi><mi mathvariant="bold-italic">S</mi></mrow><annotation encoding="application/x-tex">\boldsymbol{p}_e=\sum q_i \boldsymbol{r}_i=q \boldsymbol{d}, \boldsymbol{p}_\mu=I \boldsymbol{S}
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6886em;vertical-align:-0.2441em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol">p</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.0573em;"><span style="top:-2.4559em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">e</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2441em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.6em;vertical-align:-0.55em;"></span><span class="mop op-symbol large-op" style="position:relative;top:0em;">∑</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">q</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.03194em;">r</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.0747em;vertical-align:-0.3802em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">q</span><span class="mord"><span class="mord"><span class="mord boldsymbol">d</span></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol">p</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.0573em;"><span style="top:-2.4559em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">μ</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.3802em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6861em;"></span><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.05382em;">S</span></span></span></span></span></span></span></p>
</li>
</ol>
<h3 id="_9-17-双極子場" tabindex="-1">9.17: 双極子場 <a class="header-anchor" href="#_9-17-双極子場" aria-label="Permalink to &quot;9.17: 双極子場&quot;">&ZeroWidthSpace;</a></h3>
<ol start="17">
<li>双極子場 : <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ϕ</mi><mo>=</mo><mi>k</mi><mi mathvariant="bold-italic">p</mi><mo>⋅</mo><msub><mi mathvariant="bold-italic">e</mi><mi>r</mi></msub><mi mathvariant="normal">/</mi><msup><mi>r</mi><mn>2</mn></msup><mo separator="true">,</mo><mi>E</mi><mo separator="true">,</mo><mi>B</mi><mo>∝</mo><msup><mi>r</mi><mrow><mo>−</mo><mn>3</mn></mrow></msup></mrow><annotation encoding="application/x-tex">\phi=k \boldsymbol{p} \cdot \boldsymbol{e}_r / r^2, E, B \propto r^{-3}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">ϕ</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="mord"><span class="mord"><span class="mord boldsymbol">p</span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">⋅</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1.0641em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol">e</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.02778em;">r</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord">/</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.02778em;">r</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.05764em;">E</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">∝</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8141em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.02778em;">r</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">−</span><span class="mord mtight">3</span></span></span></span></span></span></span></span></span></span></span></span></li>
</ol>
<h3 id="_9-18-双極子に働く力" tabindex="-1">9.18: 双極子に働く力 <a class="header-anchor" href="#_9-18-双極子に働く力" aria-label="Permalink to &quot;9.18: 双極子に働く力&quot;">&ZeroWidthSpace;</a></h3>
<ol start="19">
<li>双極子に働く力 : <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>F</mi><mo>=</mo><msup><mrow><mo fence="true">(</mo><msub><mi mathvariant="bold-italic">p</mi><mi>e</mi></msub><mo>⋅</mo><mi mathvariant="bold-italic">E</mi><mo fence="true">)</mo></mrow><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup><mo separator="true">,</mo><mi>F</mi><mo>=</mo><msup><mrow><mo fence="true">(</mo><msub><mi mathvariant="bold-italic">p</mi><mi>μ</mi></msub><mo>⋅</mo><mi mathvariant="bold-italic">B</mi><mo fence="true">)</mo></mrow><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup></mrow><annotation encoding="application/x-tex">F=\left(\boldsymbol{p}_e \cdot \boldsymbol{E}\right)^{\prime}, F=\left(\boldsymbol{p}_\mu \cdot \boldsymbol{B}\right)^{\prime}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.13889em;">F</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.1418em;vertical-align:-0.25em;"></span><span class="minner"><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol">p</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.0573em;"><span style="top:-2.4559em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">e</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2441em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">⋅</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.05451em;">E</span></span></span><span class="mclose delimcenter" style="top:0em;">)</span></span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8918em;"><span style="top:-3.2029em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.13889em;">F</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.372em;vertical-align:-0.3802em;"></span><span class="minner"><span class="minner"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size1">(</span></span><span class="mord"><span class="mord"><span class="mord"><span class="mord boldsymbol">p</span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.0573em;"><span style="top:-2.4559em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">μ</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.3802em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">⋅</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol" style="margin-right:0.04835em;">B</span></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size1">)</span></span></span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.9918em;"><span style="top:-3.3029em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span></span></span></span> [訳 者注 : ここの微分はむしろ <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">grad</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\operatorname{grad}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mop"><span class="mord mathrm">grad</span></span></span></span></span> である]. 2 つの双極 子間の相互作用 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>:</mo><mi>F</mi><mo>∝</mo><msup><mi>r</mi><mrow><mo>−</mo><mn>4</mn></mrow></msup></mrow><annotation encoding="application/x-tex">: F \propto r^{-4}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mrel">:</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.13889em;">F</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">∝</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8141em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.02778em;">r</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">−</span><span class="mord mtight">4</span></span></span></span></span></span></span></span></span></span></span></span>.</li>
</ol>
<h3 id="_9-19-磁気双極子としての点電荷" tabindex="-1">9.19: 磁気双極子としての点電荷 <a class="header-anchor" href="#_9-19-磁気双極子としての点電荷" aria-label="Permalink to &quot;9.19: 磁気双極子としての点電荷&quot;">&ZeroWidthSpace;</a></h3>
<ol start="19">
<li>磁気双極子としての点電荷 : <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>p</mi><mi>μ</mi></msub><mo>∝</mo><mi mathvariant="normal">Φ</mi><mo>∝</mo><msubsup><mi>v</mi><mo lspace="0em" rspace="0em">⊥</mo><mn>2</mn></msubsup><mi mathvariant="normal">/</mi><mi>B</mi></mrow><annotation encoding="application/x-tex">p_\mu \propto \Phi \propto v_{\perp}^2 / B</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7167em;vertical-align:-0.2861em;"></span><span class="mord"><span class="mord mathnormal">p</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">μ</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">∝</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">Φ</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">∝</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.0972em;vertical-align:-0.2831em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-2.4169em;margin-left:-0.0359em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mrel mtight">⊥</span></span></span></span><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2831em;"><span></span></span></span></span></span></span><span class="mord">/</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span></span> は断熱 不変量 (<a href="./4.html#_4-22-断熱不変量">Section 4: #22</a> 参照).</li>
</ol>
<h3 id="_9-20-鏡像法" tabindex="-1">9.20: 鏡像法 <a class="header-anchor" href="#_9-20-鏡像法" aria-label="Permalink to &quot;9.20: 鏡像法&quot;">&ZeroWidthSpace;</a></h3>
<ol start="20">
<li>鏡像法 : 接地された（磁石の場合は超電導の）平面が鏡 の役割をする. 接地された（又は孤立した）球体の場 は, 球体の内部にある 1 つ（又は 2 つ）の架空の電荷 のつくる場として求められる. 平面導波管（金属板の 間のスリット）内の場は, 電磁平面波の重ね合わせと して求められる.</li>
</ol>
<h3 id="_9-21-一様-電-場中の球-円柱-の分極" tabindex="-1">9.21: 一様（電）場中の球 (円柱) の分極 <a class="header-anchor" href="#_9-21-一様-電-場中の球-円柱-の分極" aria-label="Permalink to &quot;9.21: 一様（電）場中の球 (円柱) の分極&quot;">&ZeroWidthSpace;</a></h3>
<ol start="21">
<li>一様（電）場中の球 (円柱) の分極 : <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">(</mo><mo>+</mo><mi>ρ</mi></mrow><annotation encoding="application/x-tex">(+\rho</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">(</span><span class="mord">+</span><span class="mord mathnormal">ρ</span></span></span></span> と <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>−</mo><mi>ρ</mi></mrow><annotation encoding="application/x-tex">-\rho</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7778em;vertical-align:-0.1944em;"></span><span class="mord">−</span><span class="mord mathnormal">ρ</span></span></span></span> に一 様に帯電した球 (円柱) の重ね合わせで， <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>d</mi><mo>∝</mo><mi>E</mi></mrow><annotation encoding="application/x-tex">d \propto E</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">d</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">∝</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.05764em;">E</span></span></span></span>.</li>
</ol>
<h3 id="_9-22-渦電流" tabindex="-1">9.22: 渦電流 <a class="header-anchor" href="#_9-22-渦電流" aria-label="Permalink to &quot;9.22: 渦電流&quot;">&ZeroWidthSpace;</a></h3>
<ol start="22">
<li>渦電流: 電流損失密度 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≈</mo><msup><mi>B</mi><mn>2</mn></msup><msup><mi>v</mi><mn>2</mn></msup><mi mathvariant="normal">/</mi><mi>ρ</mi><mi mathvariant="normal">.</mi><mn>1</mn></mrow><annotation encoding="application/x-tex">\approx B^2 v^2 / \rho .1</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4831em;"></span><span class="mrel">≈</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.0641em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.05017em;">B</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mord">/</span><span class="mord mathnormal">ρ</span><span class="mord">.1</span></span></span></span> 回の通過で与え られる運動量 : <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>F</mi><mi>τ</mi><mo>≈</mo><msup><mi>B</mi><mn>2</mn></msup><msup><mi>a</mi><mn>3</mn></msup><mi>d</mi><mi mathvariant="normal">/</mi><mi>ρ</mi></mrow><annotation encoding="application/x-tex">F \tau \approx B^2 a^3 d / \rho</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.13889em;">F</span><span class="mord mathnormal" style="margin-right:0.1132em;">τ</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≈</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.0641em;vertical-align:-0.25em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.05017em;">B</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">3</span></span></span></span></span></span></span></span><span class="mord mathnormal">d</span><span class="mord">/</span><span class="mord mathnormal">ρ</span></span></span></span> (ここで <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>d</mi></mrow><annotation encoding="application/x-tex">d</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">d</span></span></span></span> は厚さ, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi></mrow><annotation encoding="application/x-tex">a</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">a</span></span></span></span> は大きさ).</li>
</ol>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[2023-2-27: Vocabulary]]></title>
            <link>https://note.toshiki.devacademic/vocabulary/2023/02/2023-02-27</link>
            <guid>https://note.toshiki.devacademic/vocabulary/2023/02/2023-02-27</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="_2023-2-27-vocabulary" tabindex="-1">2023-2-27: Vocabulary <a class="header-anchor" href="#_2023-2-27-vocabulary" aria-label="Permalink to &quot;2023-2-27: Vocabulary&quot;">&ZeroWidthSpace;</a></h1>
<blockquote>
<p>This table of vocabularies are from &quot;Sadlier Vocabulary Workshop-Level G (Unit 4)&quot; with their corresponding textbook definitions and part of speeches (from some of them) made into a collection.</p>
</blockquote>
<table>
<thead>
<tr>
<th>Vocabulary</th>
<th>Definition</th>
</tr>
</thead>
<tbody>
<tr>
<td>Atrophy</td>
<td>(n.) the wasting away of a body organ or tissue; any progressive decline or failure; (v.) to waste away</td>
</tr>
<tr>
<td>Bastion</td>
<td>A fortified place, stronghold</td>
</tr>
<tr>
<td>Concord</td>
<td>A state of agreement, harmony, unanimity; a treaty, pact, covenant</td>
</tr>
<tr>
<td>Consummate</td>
<td>(adj.) complete or perfect in the highest degree; (v.) to bring to a state of completion or perfection</td>
</tr>
<tr>
<td>Disarray</td>
<td>(n.) disorder, confusion; (v.) to throw into disorder</td>
</tr>
<tr>
<td>Exigency</td>
<td>Urgency, pressure; urgent demand, pressing need; an emergency</td>
</tr>
<tr>
<td>Flotsam</td>
<td>Floating debris; homeless, impoverished people</td>
</tr>
<tr>
<td>Frenetic</td>
<td>Frenzied, highly agitated</td>
</tr>
<tr>
<td>Glean</td>
<td>To gather bit by bit; to gather small quantities of grain left in a field by the reapers.</td>
</tr>
<tr>
<td>Grouse</td>
<td>(n.) A type of game bird; a complaint; (v.) to complain, grumble</td>
</tr>
<tr>
<td>Incarcerate</td>
<td>To imprison, confine, jail</td>
</tr>
<tr>
<td>Incumbent</td>
<td>(adj.) obligatory, required; (n.) one who holds a specific office at the time spoken of</td>
</tr>
<tr>
<td>Jocular</td>
<td>Humorous, jesting, jolly, joking</td>
</tr>
<tr>
<td>Ludicrous</td>
<td>Ridiculous, laughable, absurd</td>
</tr>
<tr>
<td>Mordant</td>
<td>Biting or caustic in thought, manner, or style; sharply or bitterly harsh.</td>
</tr>
<tr>
<td>Nettle</td>
<td>(n.) a prickly or stinging plant; (v.) to arouse displeasure, impatience, or anger; to vex or irritate severely</td>
</tr>
<tr>
<td>Pecuniary</td>
<td>Consisting of or measured in money; of or related to money</td>
</tr>
<tr>
<td>Pusillanimous</td>
<td>Contemptibly cowardly or mean-spirited</td>
</tr>
<tr>
<td>Recumbent</td>
<td>In a reclining position, lying down, in the posture of one sleeping or resting.</td>
</tr>
<tr>
<td>Stratagem</td>
<td>A scheme to outwit or deceive an opponent or to gain and end.</td>
</tr>
</tbody>
</table>
<div class="tip custom-block"><p class="custom-block-title">Reference</p>
<ul>
<li>&quot;Sadlier Vocabulary Workshop- Level G (Unit 4).&quot; kensiezoe. Quizlet, n.d. <a href="https://quizlet.com/cn/732875555/sadlier-vocabulary-workshop-level-g-unit-4-flash-cards/" target="_blank" rel="noreferrer">https://quizlet.com/cn/732875555/sadlier-vocabulary-workshop-level-g-unit-4-flash-cards/</a></li>
</ul>
</div>
]]></description>
            <content:encoded><![CDATA[<h1 id="_2023-2-27-vocabulary" tabindex="-1">2023-2-27: Vocabulary <a class="header-anchor" href="#_2023-2-27-vocabulary" aria-label="Permalink to &quot;2023-2-27: Vocabulary&quot;">&ZeroWidthSpace;</a></h1>
<blockquote>
<p>This table of vocabularies are from &quot;Sadlier Vocabulary Workshop-Level G (Unit 4)&quot; with their corresponding textbook definitions and part of speeches (from some of them) made into a collection.</p>
</blockquote>
<table>
<thead>
<tr>
<th>Vocabulary</th>
<th>Definition</th>
</tr>
</thead>
<tbody>
<tr>
<td>Atrophy</td>
<td>(n.) the wasting away of a body organ or tissue; any progressive decline or failure; (v.) to waste away</td>
</tr>
<tr>
<td>Bastion</td>
<td>A fortified place, stronghold</td>
</tr>
<tr>
<td>Concord</td>
<td>A state of agreement, harmony, unanimity; a treaty, pact, covenant</td>
</tr>
<tr>
<td>Consummate</td>
<td>(adj.) complete or perfect in the highest degree; (v.) to bring to a state of completion or perfection</td>
</tr>
<tr>
<td>Disarray</td>
<td>(n.) disorder, confusion; (v.) to throw into disorder</td>
</tr>
<tr>
<td>Exigency</td>
<td>Urgency, pressure; urgent demand, pressing need; an emergency</td>
</tr>
<tr>
<td>Flotsam</td>
<td>Floating debris; homeless, impoverished people</td>
</tr>
<tr>
<td>Frenetic</td>
<td>Frenzied, highly agitated</td>
</tr>
<tr>
<td>Glean</td>
<td>To gather bit by bit; to gather small quantities of grain left in a field by the reapers.</td>
</tr>
<tr>
<td>Grouse</td>
<td>(n.) A type of game bird; a complaint; (v.) to complain, grumble</td>
</tr>
<tr>
<td>Incarcerate</td>
<td>To imprison, confine, jail</td>
</tr>
<tr>
<td>Incumbent</td>
<td>(adj.) obligatory, required; (n.) one who holds a specific office at the time spoken of</td>
</tr>
<tr>
<td>Jocular</td>
<td>Humorous, jesting, jolly, joking</td>
</tr>
<tr>
<td>Ludicrous</td>
<td>Ridiculous, laughable, absurd</td>
</tr>
<tr>
<td>Mordant</td>
<td>Biting or caustic in thought, manner, or style; sharply or bitterly harsh.</td>
</tr>
<tr>
<td>Nettle</td>
<td>(n.) a prickly or stinging plant; (v.) to arouse displeasure, impatience, or anger; to vex or irritate severely</td>
</tr>
<tr>
<td>Pecuniary</td>
<td>Consisting of or measured in money; of or related to money</td>
</tr>
<tr>
<td>Pusillanimous</td>
<td>Contemptibly cowardly or mean-spirited</td>
</tr>
<tr>
<td>Recumbent</td>
<td>In a reclining position, lying down, in the posture of one sleeping or resting.</td>
</tr>
<tr>
<td>Stratagem</td>
<td>A scheme to outwit or deceive an opponent or to gain and end.</td>
</tr>
</tbody>
</table>
<div class="tip custom-block"><p class="custom-block-title">Reference</p>
<ul>
<li>&quot;Sadlier Vocabulary Workshop- Level G (Unit 4).&quot; kensiezoe. Quizlet, n.d. <a href="https://quizlet.com/cn/732875555/sadlier-vocabulary-workshop-level-g-unit-4-flash-cards/" target="_blank" rel="noreferrer">https://quizlet.com/cn/732875555/sadlier-vocabulary-workshop-level-g-unit-4-flash-cards/</a></li>
</ul>
</div>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Welcome to My Vocabulary List! ]]></title>
            <link>https://note.toshiki.devacademic/vocabulary/</link>
            <guid>https://note.toshiki.devacademic/vocabulary/</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="welcome-to-my-vocabulary-list" tabindex="-1">Welcome to My Vocabulary List! <a class="header-anchor" href="#welcome-to-my-vocabulary-list" aria-label="Permalink to &quot;Welcome to My Vocabulary List!&quot;">&ZeroWidthSpace;</a></h1>
]]></description>
            <content:encoded><![CDATA[<h1 id="welcome-to-my-vocabulary-list" tabindex="-1">Welcome to My Vocabulary List! <a class="header-anchor" href="#welcome-to-my-vocabulary-list" aria-label="Permalink to &quot;Welcome to My Vocabulary List!&quot;">&ZeroWidthSpace;</a></h1>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[@andatoshiki/markdown-it-katex]]></title>
            <link>https://note.toshiki.devapplication/markdown-it-katex/how-to-use</link>
            <guid>https://note.toshiki.devapplication/markdown-it-katex/how-to-use</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="andatoshiki-markdown-it-katex" tabindex="-1">@andatoshiki/markdown-it-katex <a class="header-anchor" href="#andatoshiki-markdown-it-katex" aria-label="Permalink to &quot;@andatoshiki/markdown-it-katex&quot;">&ZeroWidthSpace;</a></h1>
<blockquote>
<p>Add graceful <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>KaTeX</mtext></mrow><annotation encoding="application/x-tex">\KaTeX</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8988em;vertical-align:-0.2155em;"></span><span class="mord text"><span class="mord textrm">K</span><span class="mspace" style="margin-right:-0.17em;"></span><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6833em;"><span style="top:-2.905em;"><span class="pstrut" style="height:2.7em;"></span><span class="mord"><span class="mord textrm mtight sizing reset-size6 size3">A</span></span></span></span></span></span><span class="mspace" style="margin-right:-0.15em;"></span><span class="mord text"><span class="mord textrm">T</span><span class="mspace" style="margin-right:-0.1667em;"></span><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.4678em;"><span style="top:-2.7845em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord textrm">E</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2155em;"><span></span></span></span></span><span class="mspace" style="margin-right:-0.125em;"></span><span class="mord textrm">X</span></span></span></span></span></span> rendering to your Markdown like a charm with <code>markdown-it</code> plugin.</p>
</blockquote>
<h2 id="_1-installation" tabindex="-1">1: Installation <a class="header-anchor" href="#_1-installation" aria-label="Permalink to &quot;1: Installation&quot;">&ZeroWidthSpace;</a></h2>
<p>Before you start using this plugin, make sure you have already installed the default <code>markdown-it</code> parser; if not, please run the following command or refer to the official <a href="https://github.com/markdown-it/markdown-it#install" target="_blank" rel="noreferrer"><code>markdown-it</code></a> documentation.</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">npm</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">install</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">markdown-it</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--save</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">npm</span><span style="color: #24292E"> </span><span style="color: #032F62">install</span><span style="color: #24292E"> </span><span style="color: #032F62">markdown-it</span><span style="color: #24292E"> </span><span style="color: #005CC5">--save</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>First install package with your preferred package manager (npm, yarn, pnpm), or include javascript before the closing <code>&lt;/body&gt;</code> for markdown-it-katex's core utils to be loaded for the static page.</p>
<div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-BgkGl" id="tab-VcGTuGT" checked="checked"><label for="tab-VcGTuGT">npm</label><input type="radio" name="group-BgkGl" id="tab-NcZYFlK" ><label for="tab-NcZYFlK">yarn</label><input type="radio" name="group-BgkGl" id="tab-VqHGmfc" ><label for="tab-VqHGmfc">pnpm</label><input type="radio" name="group-BgkGl" id="tab-HNj5aB1" ><label for="tab-HNj5aB1">cdn</label></div><div class="blocks">
<div class="language-sh vp-adaptive-theme active line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">npm</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">install</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-D</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">@andatoshiki/markdown-it-katex</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">npm</span><span style="color: #24292E"> </span><span style="color: #032F62">install</span><span style="color: #24292E"> </span><span style="color: #005CC5">-D</span><span style="color: #24292E"> </span><span style="color: #032F62">@andatoshiki/markdown-it-katex</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">yarn</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">add</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--dev</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">@andatoshiki/markdown-it-katex</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">yarn</span><span style="color: #24292E"> </span><span style="color: #032F62">add</span><span style="color: #24292E"> </span><span style="color: #005CC5">--dev</span><span style="color: #24292E"> </span><span style="color: #032F62">@andatoshiki/markdown-it-katex</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">pnpm</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">add</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-D</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">@andatoshiki/markdown-it-katex</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">pnpm</span><span style="color: #24292E"> </span><span style="color: #032F62">add</span><span style="color: #24292E"> </span><span style="color: #005CC5">-D</span><span style="color: #24292E"> </span><span style="color: #032F62">@andatoshiki/markdown-it-katex</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="language-html vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">html</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390">&lt;!-- your other body contents ... --&gt;</span></span>
<span class="line"><span style="color: #ADBAC7">    &lt;</span><span style="color: #8DDB8C">script</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">src</span><span style="color: #ADBAC7">=</span><span style="color: #96D0FF">&quot;https://unpkg.com/@andatoshiki/markdown-it-katex@0.0.3/markdown-it-katex.min.js&quot;</span><span style="color: #ADBAC7">&gt;&lt;/</span><span style="color: #8DDB8C">script</span><span style="color: #ADBAC7">&gt;</span></span>
<span class="line"><span style="color: #ADBAC7">&lt;/</span><span style="color: #8DDB8C">body</span><span style="color: #ADBAC7">&gt;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D">&lt;!-- your other body contents ... --&gt;</span></span>
<span class="line"><span style="color: #24292E">    &lt;</span><span style="color: #22863A">script</span><span style="color: #24292E"> </span><span style="color: #6F42C1">src</span><span style="color: #24292E">=</span><span style="color: #032F62">&quot;https://unpkg.com/@andatoshiki/markdown-it-katex@0.0.3/markdown-it-katex.min.js&quot;</span><span style="color: #24292E">&gt;&lt;/</span><span style="color: #22863A">script</span><span style="color: #24292E">&gt;</span></span>
<span class="line"><span style="color: #24292E">&lt;/</span><span style="color: #22863A">body</span><span style="color: #24292E">&gt;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div></div></div>
<p>Including KaTeX CSS is necessary in the way you are convenient with, either link the stylesheet from a third party CDN into the local HTML <code>&lt;head&gt;</code> tag or import it into a currently linked CSS stylesheets to enable styles for KaTeX globally as follows,</p>
<p>Or, you could clone or download the entire repository source of <a href="https://github.com/katex/katex" target="_blank" rel="noreferrer">KaTeX</a> and self load the fonts/styles/scripts locally, but if you prefer loading from third-party CDN with faster load speed when deployed to save your server resources, the following CDN links might be your choice, you can always switch to other platforms based on your need.</p>
<div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-VQ-9n" id="tab-A74pdoF" checked="checked"><label for="tab-A74pdoF">jsdelivr</label><input type="radio" name="group-VQ-9n" id="tab-LCYlN37" ><label for="tab-LCYlN37">jsd-gcore</label><input type="radio" name="group-VQ-9n" id="tab-hWHyAQj" ><label for="tab-hWHyAQj">jsd-fastly</label><input type="radio" name="group-VQ-9n" id="tab-hI0H20X" ><label for="tab-hI0H20X">cdnjs</label><input type="radio" name="group-VQ-9n" id="tab-orzY0Eh" ><label for="tab-orzY0Eh">unpkg</label><input type="radio" name="group-VQ-9n" id="tab--uBozWx" ><label for="tab--uBozWx">scss or css</label></div><div class="blocks">
<div class="language-html vp-adaptive-theme active line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">html</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">&lt;</span><span style="color: #8DDB8C">link</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">rel</span><span style="color: #ADBAC7">=</span><span style="color: #96D0FF">&quot;stylesheet&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">href</span><span style="color: #ADBAC7">=</span><span style="color: #96D0FF">&quot;https://cdn.jsdelivr.net/npm/katex@0.16/dist/katex.min.css&quot;</span><span style="color: #ADBAC7"> /&gt;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">&lt;</span><span style="color: #22863A">link</span><span style="color: #24292E"> </span><span style="color: #6F42C1">rel</span><span style="color: #24292E">=</span><span style="color: #032F62">&quot;stylesheet&quot;</span><span style="color: #24292E"> </span><span style="color: #6F42C1">href</span><span style="color: #24292E">=</span><span style="color: #032F62">&quot;https://cdn.jsdelivr.net/npm/katex@0.16/dist/katex.min.css&quot;</span><span style="color: #24292E"> /&gt;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="language-html vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">html</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">&lt;</span><span style="color: #8DDB8C">link</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">rel</span><span style="color: #ADBAC7">=</span><span style="color: #96D0FF">&quot;stylesheet&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">href</span><span style="color: #ADBAC7">=</span><span style="color: #96D0FF">&quot;https://gcore.jsdelivr.net/npm/katex@0.16/dist/katex.min.css&quot;</span><span style="color: #ADBAC7"> /&gt;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">&lt;</span><span style="color: #22863A">link</span><span style="color: #24292E"> </span><span style="color: #6F42C1">rel</span><span style="color: #24292E">=</span><span style="color: #032F62">&quot;stylesheet&quot;</span><span style="color: #24292E"> </span><span style="color: #6F42C1">href</span><span style="color: #24292E">=</span><span style="color: #032F62">&quot;https://gcore.jsdelivr.net/npm/katex@0.16/dist/katex.min.css&quot;</span><span style="color: #24292E"> /&gt;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="language-html vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">html</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">&lt;</span><span style="color: #8DDB8C">link</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">rel</span><span style="color: #ADBAC7">=</span><span style="color: #96D0FF">&quot;stylesheet&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">href</span><span style="color: #ADBAC7">=</span><span style="color: #96D0FF">&quot;https://fastly.jsdelivr.net/npm/katex@0.16/dist/katex.min.css&quot;</span><span style="color: #ADBAC7"> /&gt;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">&lt;</span><span style="color: #22863A">link</span><span style="color: #24292E"> </span><span style="color: #6F42C1">rel</span><span style="color: #24292E">=</span><span style="color: #032F62">&quot;stylesheet&quot;</span><span style="color: #24292E"> </span><span style="color: #6F42C1">href</span><span style="color: #24292E">=</span><span style="color: #032F62">&quot;https://fastly.jsdelivr.net/npm/katex@0.16/dist/katex.min.css&quot;</span><span style="color: #24292E"> /&gt;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="language-html vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">html</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">&lt;</span><span style="color: #8DDB8C">link</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">rel</span><span style="color: #ADBAC7">=</span><span style="color: #96D0FF">&quot;stylesheet&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">href</span><span style="color: #ADBAC7">=</span><span style="color: #96D0FF">&quot;https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.16.0/katex.min.css&quot;</span><span style="color: #ADBAC7"> /&gt;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">&lt;</span><span style="color: #22863A">link</span><span style="color: #24292E"> </span><span style="color: #6F42C1">rel</span><span style="color: #24292E">=</span><span style="color: #032F62">&quot;stylesheet&quot;</span><span style="color: #24292E"> </span><span style="color: #6F42C1">href</span><span style="color: #24292E">=</span><span style="color: #032F62">&quot;https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.16.0/katex.min.css&quot;</span><span style="color: #24292E"> /&gt;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="language-html vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">html</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">&lt;</span><span style="color: #8DDB8C">link</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">rel</span><span style="color: #ADBAC7">=</span><span style="color: #96D0FF">&quot;stylesheet&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">href</span><span style="color: #ADBAC7">=</span><span style="color: #96D0FF">&quot;https://unpkg.com/katex@0.16.0/dist/katex.min.css&quot;</span><span style="color: #ADBAC7"> /&gt;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">&lt;</span><span style="color: #22863A">link</span><span style="color: #24292E"> </span><span style="color: #6F42C1">rel</span><span style="color: #24292E">=</span><span style="color: #032F62">&quot;stylesheet&quot;</span><span style="color: #24292E"> </span><span style="color: #6F42C1">href</span><span style="color: #24292E">=</span><span style="color: #032F62">&quot;https://unpkg.com/katex@0.16.0/dist/katex.min.css&quot;</span><span style="color: #24292E"> /&gt;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="language-scss vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">scss</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390">// ... your other styles</span></span>
<span class="line"><span style="color: #F47067">@import</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;https://cdnjs.toshiki.dev/ajax/libs/KaTeX/0.16.0/katex.min.css&#39;</span><span style="color: #ADBAC7">;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D">// ... your other styles</span></span>
<span class="line"><span style="color: #D73A49">@import</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;https://cdnjs.toshiki.dev/ajax/libs/KaTeX/0.16.0/katex.min.css&#39;</span><span style="color: #24292E">;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div></div></div>
<p>If you are using the default markdown-it parser, I personally recommend that you use the GitHub markdown CSS (<a href="https://github.com/sindresorhus/github-markdown-css/" target="_blank" rel="noreferrer">github-markdown-css</a>) for styling your HTML output with a similar style replica of GitHub's markdown styling to your familiarity.</p>
<div class="language-html vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">html</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">&lt;</span><span style="color: #8DDB8C">link</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">rel</span><span style="color: #ADBAC7">=</span><span style="color: #96D0FF">&quot;stylesheet&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">href</span><span style="color: #ADBAC7">=</span><span style="color: #96D0FF">&quot;https://cdn.jsdelivr.net/npm/github-markdown-css@5.2.0/github-markdown.min.css&quot;</span><span style="color: #ADBAC7"> /&gt;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">&lt;</span><span style="color: #22863A">link</span><span style="color: #24292E"> </span><span style="color: #6F42C1">rel</span><span style="color: #24292E">=</span><span style="color: #032F62">&quot;stylesheet&quot;</span><span style="color: #24292E"> </span><span style="color: #6F42C1">href</span><span style="color: #24292E">=</span><span style="color: #032F62">&quot;https://cdn.jsdelivr.net/npm/github-markdown-css@5.2.0/github-markdown.min.css&quot;</span><span style="color: #24292E"> /&gt;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>This forked project maintained by <a href="https://github.com/andatoshiki" target="_blank" rel="noreferrer">Anda Toshiki</a> comes with the update of KaTeX components with higher style version support (this documentation uses KaTeX version <code>16.0</code>, without hassels), later versions may works, but no guarantees are given by the developers, if you are not obsessed with the latest released version, <code>16.0</code> may fits your need for loading KaTeX on a personal blog site or small educational sites; yet it should work fully functionally.</p>
<div class="danger custom-block"><p class="custom-block-title">Warning</p>
<p>Since this project is a fork of the <a href="https://www.npmjs.com/package/markdown-it-katex" target="_blank" rel="noreferrer">original</a> markdown-it-katex project that hasn't been receiving any active updates of its code source for years, the latest katex style version supported is somewhere around <code>ver. 0.9.0</code> which clearly is outdated and results in broken styles with overflowing and other potential bug presents.</p>
</div>
<h2 id="_2-usage" tabindex="-1">2: Usage <a class="header-anchor" href="#_2-usage" aria-label="Permalink to &quot;2: Usage&quot;">&ZeroWidthSpace;</a></h2>
<p>RTo render equations, you need to include the <code>markdown-it-katex</code> plugin in the <code>markdown-it</code> components in your JavaScript or TypeScript file as follows,</p>
<div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-uI6kU" id="tab-BDPjrXO" checked="checked"><label for="tab-BDPjrXO">js</label><input type="radio" name="group-uI6kU" id="tab-tcO4ILE" ><label for="tab-tcO4ILE">ts</label></div><div class="blocks">
<div class="language-js vp-adaptive-theme active line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">js</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">var</span><span style="color: #ADBAC7"> md </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">require</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&#39;markdown-it&#39;</span><span style="color: #ADBAC7">)(),</span></span>
<span class="line"><span style="color: #ADBAC7">    mk </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">require</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&#39;andatoshiki/markdown-it-katex&#39;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">md.</span><span style="color: #DCBDFB">use</span><span style="color: #ADBAC7">(mk)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390">// double backslash is required for javascript strings, but not html input</span></span>
<span class="line"><span style="color: #F47067">var</span><span style="color: #ADBAC7"> result </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> md.</span><span style="color: #DCBDFB">render</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&#39;# Math Rulez! </span><span style="color: #F47067">\n</span><span style="color: #96D0FF">  $</span><span style="color: #F47067">\\</span><span style="color: #96D0FF">sqrt{3x-1}+(1+x)^2$&#39;</span><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">var</span><span style="color: #24292E"> md </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #6F42C1">require</span><span style="color: #24292E">(</span><span style="color: #032F62">&#39;markdown-it&#39;</span><span style="color: #24292E">)(),</span></span>
<span class="line"><span style="color: #24292E">    mk </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #6F42C1">require</span><span style="color: #24292E">(</span><span style="color: #032F62">&#39;andatoshiki/markdown-it-katex&#39;</span><span style="color: #24292E">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">md.</span><span style="color: #6F42C1">use</span><span style="color: #24292E">(mk)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D">// double backslash is required for javascript strings, but not html input</span></span>
<span class="line"><span style="color: #D73A49">var</span><span style="color: #24292E"> result </span><span style="color: #D73A49">=</span><span style="color: #24292E"> md.</span><span style="color: #6F42C1">render</span><span style="color: #24292E">(</span><span style="color: #032F62">&#39;# Math Rulez! </span><span style="color: #005CC5">\n</span><span style="color: #032F62">  $</span><span style="color: #005CC5">\\</span><span style="color: #032F62">sqrt{3x-1}+(1+x)^2$&#39;</span><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br></div></div><div class="language-ts vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">*</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">as</span><span style="color: #ADBAC7"> mk </span><span style="color: #F47067">from</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;markdown-it-katex&#39;</span></span>
<span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">*</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">as</span><span style="color: #ADBAC7"> MarkdownIt </span><span style="color: #F47067">from</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;@andatoshiki/markdown-it&#39;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F47067">const</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">md</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">new</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">MarkdownIt</span><span style="color: #ADBAC7">()</span></span>
<span class="line"><span style="color: #ADBAC7">md.</span><span style="color: #DCBDFB">use</span><span style="color: #ADBAC7">(mk)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390">// double backslash is not required for TypeScript strings or template literals</span></span>
<span class="line"><span style="color: #F47067">const</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">result</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> md.</span><span style="color: #DCBDFB">render</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&#39;# Math Rulez! </span><span style="color: #F47067">\n</span><span style="color: #96D0FF">  $</span><span style="color: #F47067">\\</span><span style="color: #96D0FF">sqrt{3x-1}+(1+x)^2$&#39;</span><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> </span><span style="color: #005CC5">*</span><span style="color: #24292E"> </span><span style="color: #D73A49">as</span><span style="color: #24292E"> mk </span><span style="color: #D73A49">from</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;markdown-it-katex&#39;</span></span>
<span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> </span><span style="color: #005CC5">*</span><span style="color: #24292E"> </span><span style="color: #D73A49">as</span><span style="color: #24292E"> MarkdownIt </span><span style="color: #D73A49">from</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;@andatoshiki/markdown-it&#39;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D73A49">const</span><span style="color: #24292E"> </span><span style="color: #005CC5">md</span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #D73A49">new</span><span style="color: #24292E"> </span><span style="color: #6F42C1">MarkdownIt</span><span style="color: #24292E">()</span></span>
<span class="line"><span style="color: #24292E">md.</span><span style="color: #6F42C1">use</span><span style="color: #24292E">(mk)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D">// double backslash is not required for TypeScript strings or template literals</span></span>
<span class="line"><span style="color: #D73A49">const</span><span style="color: #24292E"> </span><span style="color: #005CC5">result</span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> md.</span><span style="color: #6F42C1">render</span><span style="color: #24292E">(</span><span style="color: #032F62">&#39;# Math Rulez! </span><span style="color: #005CC5">\n</span><span style="color: #032F62">  $</span><span style="color: #005CC5">\\</span><span style="color: #032F62">sqrt{3x-1}+(1+x)^2$&#39;</span><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br></div></div></div></div>
<h3 id="_3-configuration" tabindex="-1">3: Configuration <a class="header-anchor" href="#_3-configuration" aria-label="Permalink to &quot;3: Configuration&quot;">&ZeroWidthSpace;</a></h3>
<p>The following list of variable are the customizable components of <code>markdown-it-katex</code>, adjust to your needs,</p>
<ul>
<li><code>katex</code>: You can change KaTeX version by passing the instance.</li>
<li><code>blockClass</code>: Class added to KaTeX block.</li>
<li>Apply any other <a href="https://katex.org/docs/options.html" target="_blank" rel="noreferrer">KaTeX options</a> if needed as a regard to the docs</li>
</ul>
<div class="language-js vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">js</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">md.</span><span style="color: #DCBDFB">use</span><span style="color: #ADBAC7">(mk, { blockClass: </span><span style="color: #96D0FF">&#39;math-block&#39;</span><span style="color: #ADBAC7">, errorColor: </span><span style="color: #96D0FF">&#39; #cc0000&#39;</span><span style="color: #ADBAC7"> })</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">md.</span><span style="color: #6F42C1">use</span><span style="color: #24292E">(mk, { blockClass: </span><span style="color: #032F62">&#39;math-block&#39;</span><span style="color: #24292E">, errorColor: </span><span style="color: #032F62">&#39; #cc0000&#39;</span><span style="color: #24292E"> })</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><h2 id="_4-examples" tabindex="-1">4: Examples <a class="header-anchor" href="#_4-examples" aria-label="Permalink to &quot;4: Examples&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="_4-1-inline-math" tabindex="-1">4.1: Inline math <a class="header-anchor" href="#_4-1-inline-math" aria-label="Permalink to &quot;4.1: Inline math&quot;">&ZeroWidthSpace;</a></h3>
<p>To render your LaTeX equations inline, enclose them with a single dollar sign <code>$</code> on each side of the equation as follows,</p>
<div class="language-tex vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">tex</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #6CB6FF">$</span><span style="color: #6CB6FF">\sqrt{3x-1}+(1+x)^2</span><span style="color: #6CB6FF">$</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #032F62">$</span><span style="color: #005CC5">\sqrt{3x-1}+(1+x)^2</span><span style="color: #032F62">$</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>rendered output equation as follows, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msqrt><mrow><mn>3</mn><mi>x</mi><mo>−</mo><mn>1</mn></mrow></msqrt><mo>+</mo><mo stretchy="false">(</mo><mn>1</mn><mo>+</mo><mi>x</mi><msup><mo stretchy="false">)</mo><mn>2</mn></msup></mrow><annotation encoding="application/x-tex">\sqrt{3x-1}+(1+x)^2</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.04em;vertical-align:-0.1744em;"></span><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8656em;"><span class="svg-align" style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord" style="padding-left:0.833em;"><span class="mord">3</span><span class="mord mathnormal">x</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord">1</span></span></span><span style="top:-2.8256em;"><span class="pstrut" style="height:3em;"></span><span class="hide-tail" style="min-width:0.853em;height:1.08em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='1.08em' viewBox='0 0 400000 1080' preserveAspectRatio='xMinYMin slice'><path d='M95,702
c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14
c0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54
c44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10
s173,378,173,378c0.7,0,35.3,-71,104,-213c68.7,-142,137.5,-285,206.5,-429
c69,-144,104.5,-217.7,106.5,-221
l0 -0
c5.3,-9.3,12,-14,20,-14
H400000v40H845.2724
s-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7
c-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z
M834 80h400000v40h-400000z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.1744em;"><span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">(</span><span class="mord">1</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1.0641em;vertical-align:-0.25em;"></span><span class="mord mathnormal">x</span><span class="mclose"><span class="mclose">)</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span></span>.</p>
<h3 id="_4-2-blocked-math" tabindex="-1">4.2: Blocked math <a class="header-anchor" href="#_4-2-blocked-math" aria-label="Permalink to &quot;4.2: Blocked math&quot;">&ZeroWidthSpace;</a></h3>
<p>To render blocks, use double dollar sign (<code>$$</code>). This mode utilizes larger symbols and centers the result as a block displayed as a <code>&lt;div&gt;</code> block in HTML output, as follows,</p>
<div class="language-tex vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">tex</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #6CB6FF">$$</span></span>
<span class="line"><span style="color: #6CB6FF">\frac {</span><span style="color: #F47067">\partial</span><span style="color: #6CB6FF">^r} {</span><span style="color: #F47067">\partial</span><span style="color: #6CB6FF"> </span><span style="color: #F47067">\omega</span><span style="color: #6CB6FF">^r} \left(\frac {y^{</span><span style="color: #F47067">\omega</span><span style="color: #6CB6FF">}} {</span><span style="color: #F47067">\omega</span><span style="color: #6CB6FF">}\right)</span></span>
<span class="line"><span style="color: #6CB6FF">= \left(\frac {y^{</span><span style="color: #F47067">\omega</span><span style="color: #6CB6FF">}} {</span><span style="color: #F47067">\omega</span><span style="color: #6CB6FF">}\right) \left\{(\log y)^r + </span><span style="color: #F47067">\sum</span><span style="color: #6CB6FF">_{i=1}^r \frac {(-1)^ Ir </span><span style="color: #F47067">\cdots</span><span style="color: #6CB6FF"> (r-i+1) (\log y)^{ri}} {</span><span style="color: #F47067">\omega</span><span style="color: #6CB6FF">^i} \right\}</span></span>
<span class="line"><span style="color: #6CB6FF">$$</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #032F62">$$</span></span>
<span class="line"><span style="color: #005CC5">\frac {\partial^r} {\partial \omega^r} \left(\frac {y^{\omega}} {\omega}\right)</span></span>
<span class="line"><span style="color: #005CC5">= \left(\frac {y^{\omega}} {\omega}\right) \left\{(\log y)^r + \sum_{i=1}^r \frac {(-1)^ Ir \cdots (r-i+1) (\log y)^{ri}} {\omega^i} \right\}</span></span>
<span class="line"><span style="color: #032F62">$$</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br></div></div><p>the above block equation renders the LaTeX equation as a block with output as follows,</p>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mfrac><msup><mi mathvariant="normal">∂</mi><mi>r</mi></msup><mrow><mi mathvariant="normal">∂</mi><msup><mi>ω</mi><mi>r</mi></msup></mrow></mfrac><mrow><mo fence="true">(</mo><mfrac><msup><mi>y</mi><mi>ω</mi></msup><mi>ω</mi></mfrac><mo fence="true">)</mo></mrow><mo>=</mo><mrow><mo fence="true">(</mo><mfrac><msup><mi>y</mi><mi>ω</mi></msup><mi>ω</mi></mfrac><mo fence="true">)</mo></mrow><mrow><mo fence="true">{</mo><mo stretchy="false">(</mo><mi>log</mi><mo>⁡</mo><mi>y</mi><msup><mo stretchy="false">)</mo><mi>r</mi></msup><mo>+</mo><munderover><mo>∑</mo><mrow><mi>i</mi><mo>=</mo><mn>1</mn></mrow><mi>r</mi></munderover><mfrac><mrow><mo stretchy="false">(</mo><mo>−</mo><mn>1</mn><msup><mo stretchy="false">)</mo><mi>I</mi></msup><mi>r</mi><mo>⋯</mo><mo stretchy="false">(</mo><mi>r</mi><mo>−</mo><mi>i</mi><mo>+</mo><mn>1</mn><mo stretchy="false">)</mo><mo stretchy="false">(</mo><mi>log</mi><mo>⁡</mo><mi>y</mi><msup><mo stretchy="false">)</mo><mrow><mi>r</mi><mi>i</mi></mrow></msup></mrow><msup><mi>ω</mi><mi>i</mi></msup></mfrac><mo fence="true">}</mo></mrow></mrow><annotation encoding="application/x-tex">\frac {\partial^r} {\partial \omega^r} \left(\frac {y^{\omega}} {\omega}\right)
= \left(\frac {y^{\omega}} {\omega}\right) \left\{(\log y)^r + \sum_{i=1}^r \frac {(-1)^ Ir \cdots (r-i+1) (\log y)^{ri}} {\omega^i} \right\}
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.4em;vertical-align:-0.95em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.3714em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord" style="margin-right:0.05556em;">∂</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">ω</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.5904em;"><span style="top:-2.989em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.02778em;">r</span></span></span></span></span></span></span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"><span class="mord" style="margin-right:0.05556em;">∂</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6644em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.02778em;">r</span></span></span></span></span></span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size3">(</span></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.3414em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">ω</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">y</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6644em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.03588em;">ω</span></span></span></span></span></span></span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size3">)</span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:3.0277em;vertical-align:-1.2777em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size3">(</span></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.3414em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">ω</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">y</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6644em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.03588em;">ω</span></span></span></span></span></span></span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size3">)</span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size4">{</span></span><span class="mopen">(</span><span class="mop">lo<span style="margin-right:0.01389em;">g</span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">y</span><span class="mclose"><span class="mclose">)</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7144em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.02778em;">r</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mop op-limits"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.6514em;"><span style="top:-1.8723em;margin-left:0em;"><span class="pstrut" style="height:3.05em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">i</span><span class="mrel mtight">=</span><span class="mord mtight">1</span></span></span></span><span style="top:-3.05em;"><span class="pstrut" style="height:3.05em;"></span><span><span class="mop op-symbol large-op">∑</span></span></span><span style="top:-4.3em;margin-left:0em;"><span class="pstrut" style="height:3.05em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.02778em;">r</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.2777em;"><span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.5183em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">ω</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7507em;"><span style="top:-2.989em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span></span></span></span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mopen">(</span><span class="mord">−</span><span class="mord">1</span><span class="mclose"><span class="mclose">)</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8413em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.07847em;">I</span></span></span></span></span></span></span></span><span class="mord mathnormal" style="margin-right:0.02778em;">r</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner">⋯</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.02778em;">r</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal">i</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord">1</span><span class="mclose">)</span><span class="mopen">(</span><span class="mop">lo<span style="margin-right:0.01389em;">g</span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">y</span><span class="mclose"><span class="mclose">)</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8247em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.02778em;">r</span><span class="mord mathnormal mtight">i</span></span></span></span></span></span></span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size4">}</span></span></span></span></span></span></span></p>
<h2 id="_5-syntax" tabindex="-1">5: Syntax <a class="header-anchor" href="#_5-syntax" aria-label="Permalink to &quot;5: Syntax&quot;">&ZeroWidthSpace;</a></h2>
<p>Math parsing in markdown is designed to comply with the &quot;latex-in-markdown&quot; conventions set by <a href="https://pandoc.org" target="_blank" rel="noreferrer">Pandoc</a>,</p>
<p>Anything between two <code>$</code> characters will be treated as TeX math. The opening <code>$</code> must have a non-space character immediately to its right, while the closing $ must have a non-space character immediately to its left, and must not be followed immediately by a digit. Thus, <code>$20,000</code> and <code>$30,000</code> won’t parse as math. If for some reason you need to enclose text in literal <code>$</code> characters, backslash-escape them and they won’t be treated as math delimiters.</p>
<blockquote>
<ul>
<li>Pandoc. “Pandoc - Pandoc User’s Guide.” Pandoc.org, pandoc.org/MANUAL.html#math. Accessed 2 Mar. 2023.</li>
</ul>
</blockquote>
<h2 id="_6-supported-math-syntax" tabindex="-1">6: Supported math syntax <a class="header-anchor" href="#_6-supported-math-syntax" aria-label="Permalink to &quot;6: Supported math syntax&quot;">&ZeroWidthSpace;</a></h2>
<p>KaTeX is a popular, open-source math typesetting library that is based on TeX and LaTeX. It is designed to be easy to use, and to provide high-quality mathematical typesetting for web applications, refer to the following pages of the document for the full list of function support in KaTeX.</p>
<div class="info custom-block"><p class="custom-block-title">Note</p>
<p>Due to the large number of equations rendered on the next following pages, it might takes time to entirely load the webpage, please be patient if the webpage seems to not respond; or it could be a result of slow network connection to correctly render all the equation that causes broken formulas, refresh the page to proceed.</p>
</div>
]]></description>
            <content:encoded><![CDATA[<h1 id="andatoshiki-markdown-it-katex" tabindex="-1">@andatoshiki/markdown-it-katex <a class="header-anchor" href="#andatoshiki-markdown-it-katex" aria-label="Permalink to &quot;@andatoshiki/markdown-it-katex&quot;">&ZeroWidthSpace;</a></h1>
<blockquote>
<p>Add graceful <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>KaTeX</mtext></mrow><annotation encoding="application/x-tex">\KaTeX</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8988em;vertical-align:-0.2155em;"></span><span class="mord text"><span class="mord textrm">K</span><span class="mspace" style="margin-right:-0.17em;"></span><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6833em;"><span style="top:-2.905em;"><span class="pstrut" style="height:2.7em;"></span><span class="mord"><span class="mord textrm mtight sizing reset-size6 size3">A</span></span></span></span></span></span><span class="mspace" style="margin-right:-0.15em;"></span><span class="mord text"><span class="mord textrm">T</span><span class="mspace" style="margin-right:-0.1667em;"></span><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.4678em;"><span style="top:-2.7845em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord textrm">E</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2155em;"><span></span></span></span></span><span class="mspace" style="margin-right:-0.125em;"></span><span class="mord textrm">X</span></span></span></span></span></span> rendering to your Markdown like a charm with <code>markdown-it</code> plugin.</p>
</blockquote>
<h2 id="_1-installation" tabindex="-1">1: Installation <a class="header-anchor" href="#_1-installation" aria-label="Permalink to &quot;1: Installation&quot;">&ZeroWidthSpace;</a></h2>
<p>Before you start using this plugin, make sure you have already installed the default <code>markdown-it</code> parser; if not, please run the following command or refer to the official <a href="https://github.com/markdown-it/markdown-it#install" target="_blank" rel="noreferrer"><code>markdown-it</code></a> documentation.</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">npm</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">install</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">markdown-it</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--save</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">npm</span><span style="color: #24292E"> </span><span style="color: #032F62">install</span><span style="color: #24292E"> </span><span style="color: #032F62">markdown-it</span><span style="color: #24292E"> </span><span style="color: #005CC5">--save</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>First install package with your preferred package manager (npm, yarn, pnpm), or include javascript before the closing <code>&lt;/body&gt;</code> for markdown-it-katex's core utils to be loaded for the static page.</p>
<div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-BgkGl" id="tab-VcGTuGT" checked="checked"><label for="tab-VcGTuGT">npm</label><input type="radio" name="group-BgkGl" id="tab-NcZYFlK" ><label for="tab-NcZYFlK">yarn</label><input type="radio" name="group-BgkGl" id="tab-VqHGmfc" ><label for="tab-VqHGmfc">pnpm</label><input type="radio" name="group-BgkGl" id="tab-HNj5aB1" ><label for="tab-HNj5aB1">cdn</label></div><div class="blocks">
<div class="language-sh vp-adaptive-theme active line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">npm</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">install</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-D</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">@andatoshiki/markdown-it-katex</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">npm</span><span style="color: #24292E"> </span><span style="color: #032F62">install</span><span style="color: #24292E"> </span><span style="color: #005CC5">-D</span><span style="color: #24292E"> </span><span style="color: #032F62">@andatoshiki/markdown-it-katex</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">yarn</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">add</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--dev</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">@andatoshiki/markdown-it-katex</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">yarn</span><span style="color: #24292E"> </span><span style="color: #032F62">add</span><span style="color: #24292E"> </span><span style="color: #005CC5">--dev</span><span style="color: #24292E"> </span><span style="color: #032F62">@andatoshiki/markdown-it-katex</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">pnpm</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">add</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-D</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">@andatoshiki/markdown-it-katex</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">pnpm</span><span style="color: #24292E"> </span><span style="color: #032F62">add</span><span style="color: #24292E"> </span><span style="color: #005CC5">-D</span><span style="color: #24292E"> </span><span style="color: #032F62">@andatoshiki/markdown-it-katex</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="language-html vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">html</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390">&lt;!-- your other body contents ... --&gt;</span></span>
<span class="line"><span style="color: #ADBAC7">    &lt;</span><span style="color: #8DDB8C">script</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">src</span><span style="color: #ADBAC7">=</span><span style="color: #96D0FF">&quot;https://unpkg.com/@andatoshiki/markdown-it-katex@0.0.3/markdown-it-katex.min.js&quot;</span><span style="color: #ADBAC7">&gt;&lt;/</span><span style="color: #8DDB8C">script</span><span style="color: #ADBAC7">&gt;</span></span>
<span class="line"><span style="color: #ADBAC7">&lt;/</span><span style="color: #8DDB8C">body</span><span style="color: #ADBAC7">&gt;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D">&lt;!-- your other body contents ... --&gt;</span></span>
<span class="line"><span style="color: #24292E">    &lt;</span><span style="color: #22863A">script</span><span style="color: #24292E"> </span><span style="color: #6F42C1">src</span><span style="color: #24292E">=</span><span style="color: #032F62">&quot;https://unpkg.com/@andatoshiki/markdown-it-katex@0.0.3/markdown-it-katex.min.js&quot;</span><span style="color: #24292E">&gt;&lt;/</span><span style="color: #22863A">script</span><span style="color: #24292E">&gt;</span></span>
<span class="line"><span style="color: #24292E">&lt;/</span><span style="color: #22863A">body</span><span style="color: #24292E">&gt;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div></div></div>
<p>Including KaTeX CSS is necessary in the way you are convenient with, either link the stylesheet from a third party CDN into the local HTML <code>&lt;head&gt;</code> tag or import it into a currently linked CSS stylesheets to enable styles for KaTeX globally as follows,</p>
<p>Or, you could clone or download the entire repository source of <a href="https://github.com/katex/katex" target="_blank" rel="noreferrer">KaTeX</a> and self load the fonts/styles/scripts locally, but if you prefer loading from third-party CDN with faster load speed when deployed to save your server resources, the following CDN links might be your choice, you can always switch to other platforms based on your need.</p>
<div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-VQ-9n" id="tab-A74pdoF" checked="checked"><label for="tab-A74pdoF">jsdelivr</label><input type="radio" name="group-VQ-9n" id="tab-LCYlN37" ><label for="tab-LCYlN37">jsd-gcore</label><input type="radio" name="group-VQ-9n" id="tab-hWHyAQj" ><label for="tab-hWHyAQj">jsd-fastly</label><input type="radio" name="group-VQ-9n" id="tab-hI0H20X" ><label for="tab-hI0H20X">cdnjs</label><input type="radio" name="group-VQ-9n" id="tab-orzY0Eh" ><label for="tab-orzY0Eh">unpkg</label><input type="radio" name="group-VQ-9n" id="tab--uBozWx" ><label for="tab--uBozWx">scss or css</label></div><div class="blocks">
<div class="language-html vp-adaptive-theme active line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">html</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">&lt;</span><span style="color: #8DDB8C">link</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">rel</span><span style="color: #ADBAC7">=</span><span style="color: #96D0FF">&quot;stylesheet&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">href</span><span style="color: #ADBAC7">=</span><span style="color: #96D0FF">&quot;https://cdn.jsdelivr.net/npm/katex@0.16/dist/katex.min.css&quot;</span><span style="color: #ADBAC7"> /&gt;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">&lt;</span><span style="color: #22863A">link</span><span style="color: #24292E"> </span><span style="color: #6F42C1">rel</span><span style="color: #24292E">=</span><span style="color: #032F62">&quot;stylesheet&quot;</span><span style="color: #24292E"> </span><span style="color: #6F42C1">href</span><span style="color: #24292E">=</span><span style="color: #032F62">&quot;https://cdn.jsdelivr.net/npm/katex@0.16/dist/katex.min.css&quot;</span><span style="color: #24292E"> /&gt;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="language-html vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">html</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">&lt;</span><span style="color: #8DDB8C">link</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">rel</span><span style="color: #ADBAC7">=</span><span style="color: #96D0FF">&quot;stylesheet&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">href</span><span style="color: #ADBAC7">=</span><span style="color: #96D0FF">&quot;https://gcore.jsdelivr.net/npm/katex@0.16/dist/katex.min.css&quot;</span><span style="color: #ADBAC7"> /&gt;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">&lt;</span><span style="color: #22863A">link</span><span style="color: #24292E"> </span><span style="color: #6F42C1">rel</span><span style="color: #24292E">=</span><span style="color: #032F62">&quot;stylesheet&quot;</span><span style="color: #24292E"> </span><span style="color: #6F42C1">href</span><span style="color: #24292E">=</span><span style="color: #032F62">&quot;https://gcore.jsdelivr.net/npm/katex@0.16/dist/katex.min.css&quot;</span><span style="color: #24292E"> /&gt;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="language-html vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">html</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">&lt;</span><span style="color: #8DDB8C">link</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">rel</span><span style="color: #ADBAC7">=</span><span style="color: #96D0FF">&quot;stylesheet&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">href</span><span style="color: #ADBAC7">=</span><span style="color: #96D0FF">&quot;https://fastly.jsdelivr.net/npm/katex@0.16/dist/katex.min.css&quot;</span><span style="color: #ADBAC7"> /&gt;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">&lt;</span><span style="color: #22863A">link</span><span style="color: #24292E"> </span><span style="color: #6F42C1">rel</span><span style="color: #24292E">=</span><span style="color: #032F62">&quot;stylesheet&quot;</span><span style="color: #24292E"> </span><span style="color: #6F42C1">href</span><span style="color: #24292E">=</span><span style="color: #032F62">&quot;https://fastly.jsdelivr.net/npm/katex@0.16/dist/katex.min.css&quot;</span><span style="color: #24292E"> /&gt;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="language-html vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">html</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">&lt;</span><span style="color: #8DDB8C">link</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">rel</span><span style="color: #ADBAC7">=</span><span style="color: #96D0FF">&quot;stylesheet&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">href</span><span style="color: #ADBAC7">=</span><span style="color: #96D0FF">&quot;https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.16.0/katex.min.css&quot;</span><span style="color: #ADBAC7"> /&gt;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">&lt;</span><span style="color: #22863A">link</span><span style="color: #24292E"> </span><span style="color: #6F42C1">rel</span><span style="color: #24292E">=</span><span style="color: #032F62">&quot;stylesheet&quot;</span><span style="color: #24292E"> </span><span style="color: #6F42C1">href</span><span style="color: #24292E">=</span><span style="color: #032F62">&quot;https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.16.0/katex.min.css&quot;</span><span style="color: #24292E"> /&gt;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="language-html vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">html</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">&lt;</span><span style="color: #8DDB8C">link</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">rel</span><span style="color: #ADBAC7">=</span><span style="color: #96D0FF">&quot;stylesheet&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">href</span><span style="color: #ADBAC7">=</span><span style="color: #96D0FF">&quot;https://unpkg.com/katex@0.16.0/dist/katex.min.css&quot;</span><span style="color: #ADBAC7"> /&gt;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">&lt;</span><span style="color: #22863A">link</span><span style="color: #24292E"> </span><span style="color: #6F42C1">rel</span><span style="color: #24292E">=</span><span style="color: #032F62">&quot;stylesheet&quot;</span><span style="color: #24292E"> </span><span style="color: #6F42C1">href</span><span style="color: #24292E">=</span><span style="color: #032F62">&quot;https://unpkg.com/katex@0.16.0/dist/katex.min.css&quot;</span><span style="color: #24292E"> /&gt;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="language-scss vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">scss</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390">// ... your other styles</span></span>
<span class="line"><span style="color: #F47067">@import</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;https://cdnjs.toshiki.dev/ajax/libs/KaTeX/0.16.0/katex.min.css&#39;</span><span style="color: #ADBAC7">;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D">// ... your other styles</span></span>
<span class="line"><span style="color: #D73A49">@import</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;https://cdnjs.toshiki.dev/ajax/libs/KaTeX/0.16.0/katex.min.css&#39;</span><span style="color: #24292E">;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div></div></div>
<p>If you are using the default markdown-it parser, I personally recommend that you use the GitHub markdown CSS (<a href="https://github.com/sindresorhus/github-markdown-css/" target="_blank" rel="noreferrer">github-markdown-css</a>) for styling your HTML output with a similar style replica of GitHub's markdown styling to your familiarity.</p>
<div class="language-html vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">html</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">&lt;</span><span style="color: #8DDB8C">link</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">rel</span><span style="color: #ADBAC7">=</span><span style="color: #96D0FF">&quot;stylesheet&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">href</span><span style="color: #ADBAC7">=</span><span style="color: #96D0FF">&quot;https://cdn.jsdelivr.net/npm/github-markdown-css@5.2.0/github-markdown.min.css&quot;</span><span style="color: #ADBAC7"> /&gt;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">&lt;</span><span style="color: #22863A">link</span><span style="color: #24292E"> </span><span style="color: #6F42C1">rel</span><span style="color: #24292E">=</span><span style="color: #032F62">&quot;stylesheet&quot;</span><span style="color: #24292E"> </span><span style="color: #6F42C1">href</span><span style="color: #24292E">=</span><span style="color: #032F62">&quot;https://cdn.jsdelivr.net/npm/github-markdown-css@5.2.0/github-markdown.min.css&quot;</span><span style="color: #24292E"> /&gt;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>This forked project maintained by <a href="https://github.com/andatoshiki" target="_blank" rel="noreferrer">Anda Toshiki</a> comes with the update of KaTeX components with higher style version support (this documentation uses KaTeX version <code>16.0</code>, without hassels), later versions may works, but no guarantees are given by the developers, if you are not obsessed with the latest released version, <code>16.0</code> may fits your need for loading KaTeX on a personal blog site or small educational sites; yet it should work fully functionally.</p>
<div class="danger custom-block"><p class="custom-block-title">Warning</p>
<p>Since this project is a fork of the <a href="https://www.npmjs.com/package/markdown-it-katex" target="_blank" rel="noreferrer">original</a> markdown-it-katex project that hasn't been receiving any active updates of its code source for years, the latest katex style version supported is somewhere around <code>ver. 0.9.0</code> which clearly is outdated and results in broken styles with overflowing and other potential bug presents.</p>
</div>
<h2 id="_2-usage" tabindex="-1">2: Usage <a class="header-anchor" href="#_2-usage" aria-label="Permalink to &quot;2: Usage&quot;">&ZeroWidthSpace;</a></h2>
<p>RTo render equations, you need to include the <code>markdown-it-katex</code> plugin in the <code>markdown-it</code> components in your JavaScript or TypeScript file as follows,</p>
<div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-uI6kU" id="tab-BDPjrXO" checked="checked"><label for="tab-BDPjrXO">js</label><input type="radio" name="group-uI6kU" id="tab-tcO4ILE" ><label for="tab-tcO4ILE">ts</label></div><div class="blocks">
<div class="language-js vp-adaptive-theme active line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">js</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">var</span><span style="color: #ADBAC7"> md </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">require</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&#39;markdown-it&#39;</span><span style="color: #ADBAC7">)(),</span></span>
<span class="line"><span style="color: #ADBAC7">    mk </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">require</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&#39;andatoshiki/markdown-it-katex&#39;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">md.</span><span style="color: #DCBDFB">use</span><span style="color: #ADBAC7">(mk)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390">// double backslash is required for javascript strings, but not html input</span></span>
<span class="line"><span style="color: #F47067">var</span><span style="color: #ADBAC7"> result </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> md.</span><span style="color: #DCBDFB">render</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&#39;# Math Rulez! </span><span style="color: #F47067">\n</span><span style="color: #96D0FF">  $</span><span style="color: #F47067">\\</span><span style="color: #96D0FF">sqrt{3x-1}+(1+x)^2$&#39;</span><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">var</span><span style="color: #24292E"> md </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #6F42C1">require</span><span style="color: #24292E">(</span><span style="color: #032F62">&#39;markdown-it&#39;</span><span style="color: #24292E">)(),</span></span>
<span class="line"><span style="color: #24292E">    mk </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #6F42C1">require</span><span style="color: #24292E">(</span><span style="color: #032F62">&#39;andatoshiki/markdown-it-katex&#39;</span><span style="color: #24292E">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">md.</span><span style="color: #6F42C1">use</span><span style="color: #24292E">(mk)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D">// double backslash is required for javascript strings, but not html input</span></span>
<span class="line"><span style="color: #D73A49">var</span><span style="color: #24292E"> result </span><span style="color: #D73A49">=</span><span style="color: #24292E"> md.</span><span style="color: #6F42C1">render</span><span style="color: #24292E">(</span><span style="color: #032F62">&#39;# Math Rulez! </span><span style="color: #005CC5">\n</span><span style="color: #032F62">  $</span><span style="color: #005CC5">\\</span><span style="color: #032F62">sqrt{3x-1}+(1+x)^2$&#39;</span><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br></div></div><div class="language-ts vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">*</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">as</span><span style="color: #ADBAC7"> mk </span><span style="color: #F47067">from</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;markdown-it-katex&#39;</span></span>
<span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">*</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">as</span><span style="color: #ADBAC7"> MarkdownIt </span><span style="color: #F47067">from</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;@andatoshiki/markdown-it&#39;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F47067">const</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">md</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">new</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">MarkdownIt</span><span style="color: #ADBAC7">()</span></span>
<span class="line"><span style="color: #ADBAC7">md.</span><span style="color: #DCBDFB">use</span><span style="color: #ADBAC7">(mk)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390">// double backslash is not required for TypeScript strings or template literals</span></span>
<span class="line"><span style="color: #F47067">const</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">result</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> md.</span><span style="color: #DCBDFB">render</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&#39;# Math Rulez! </span><span style="color: #F47067">\n</span><span style="color: #96D0FF">  $</span><span style="color: #F47067">\\</span><span style="color: #96D0FF">sqrt{3x-1}+(1+x)^2$&#39;</span><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> </span><span style="color: #005CC5">*</span><span style="color: #24292E"> </span><span style="color: #D73A49">as</span><span style="color: #24292E"> mk </span><span style="color: #D73A49">from</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;markdown-it-katex&#39;</span></span>
<span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> </span><span style="color: #005CC5">*</span><span style="color: #24292E"> </span><span style="color: #D73A49">as</span><span style="color: #24292E"> MarkdownIt </span><span style="color: #D73A49">from</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;@andatoshiki/markdown-it&#39;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D73A49">const</span><span style="color: #24292E"> </span><span style="color: #005CC5">md</span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #D73A49">new</span><span style="color: #24292E"> </span><span style="color: #6F42C1">MarkdownIt</span><span style="color: #24292E">()</span></span>
<span class="line"><span style="color: #24292E">md.</span><span style="color: #6F42C1">use</span><span style="color: #24292E">(mk)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D">// double backslash is not required for TypeScript strings or template literals</span></span>
<span class="line"><span style="color: #D73A49">const</span><span style="color: #24292E"> </span><span style="color: #005CC5">result</span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> md.</span><span style="color: #6F42C1">render</span><span style="color: #24292E">(</span><span style="color: #032F62">&#39;# Math Rulez! </span><span style="color: #005CC5">\n</span><span style="color: #032F62">  $</span><span style="color: #005CC5">\\</span><span style="color: #032F62">sqrt{3x-1}+(1+x)^2$&#39;</span><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br></div></div></div></div>
<h3 id="_3-configuration" tabindex="-1">3: Configuration <a class="header-anchor" href="#_3-configuration" aria-label="Permalink to &quot;3: Configuration&quot;">&ZeroWidthSpace;</a></h3>
<p>The following list of variable are the customizable components of <code>markdown-it-katex</code>, adjust to your needs,</p>
<ul>
<li><code>katex</code>: You can change KaTeX version by passing the instance.</li>
<li><code>blockClass</code>: Class added to KaTeX block.</li>
<li>Apply any other <a href="https://katex.org/docs/options.html" target="_blank" rel="noreferrer">KaTeX options</a> if needed as a regard to the docs</li>
</ul>
<div class="language-js vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">js</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">md.</span><span style="color: #DCBDFB">use</span><span style="color: #ADBAC7">(mk, { blockClass: </span><span style="color: #96D0FF">&#39;math-block&#39;</span><span style="color: #ADBAC7">, errorColor: </span><span style="color: #96D0FF">&#39; #cc0000&#39;</span><span style="color: #ADBAC7"> })</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">md.</span><span style="color: #6F42C1">use</span><span style="color: #24292E">(mk, { blockClass: </span><span style="color: #032F62">&#39;math-block&#39;</span><span style="color: #24292E">, errorColor: </span><span style="color: #032F62">&#39; #cc0000&#39;</span><span style="color: #24292E"> })</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><h2 id="_4-examples" tabindex="-1">4: Examples <a class="header-anchor" href="#_4-examples" aria-label="Permalink to &quot;4: Examples&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="_4-1-inline-math" tabindex="-1">4.1: Inline math <a class="header-anchor" href="#_4-1-inline-math" aria-label="Permalink to &quot;4.1: Inline math&quot;">&ZeroWidthSpace;</a></h3>
<p>To render your LaTeX equations inline, enclose them with a single dollar sign <code>$</code> on each side of the equation as follows,</p>
<div class="language-tex vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">tex</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #6CB6FF">$</span><span style="color: #6CB6FF">\sqrt{3x-1}+(1+x)^2</span><span style="color: #6CB6FF">$</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #032F62">$</span><span style="color: #005CC5">\sqrt{3x-1}+(1+x)^2</span><span style="color: #032F62">$</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>rendered output equation as follows, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msqrt><mrow><mn>3</mn><mi>x</mi><mo>−</mo><mn>1</mn></mrow></msqrt><mo>+</mo><mo stretchy="false">(</mo><mn>1</mn><mo>+</mo><mi>x</mi><msup><mo stretchy="false">)</mo><mn>2</mn></msup></mrow><annotation encoding="application/x-tex">\sqrt{3x-1}+(1+x)^2</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.04em;vertical-align:-0.1744em;"></span><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8656em;"><span class="svg-align" style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord" style="padding-left:0.833em;"><span class="mord">3</span><span class="mord mathnormal">x</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord">1</span></span></span><span style="top:-2.8256em;"><span class="pstrut" style="height:3em;"></span><span class="hide-tail" style="min-width:0.853em;height:1.08em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='1.08em' viewBox='0 0 400000 1080' preserveAspectRatio='xMinYMin slice'><path d='M95,702
c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14
c0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54
c44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10
s173,378,173,378c0.7,0,35.3,-71,104,-213c68.7,-142,137.5,-285,206.5,-429
c69,-144,104.5,-217.7,106.5,-221
l0 -0
c5.3,-9.3,12,-14,20,-14
H400000v40H845.2724
s-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7
c-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z
M834 80h400000v40h-400000z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.1744em;"><span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">(</span><span class="mord">1</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1.0641em;vertical-align:-0.25em;"></span><span class="mord mathnormal">x</span><span class="mclose"><span class="mclose">)</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span></span>.</p>
<h3 id="_4-2-blocked-math" tabindex="-1">4.2: Blocked math <a class="header-anchor" href="#_4-2-blocked-math" aria-label="Permalink to &quot;4.2: Blocked math&quot;">&ZeroWidthSpace;</a></h3>
<p>To render blocks, use double dollar sign (<code>$$</code>). This mode utilizes larger symbols and centers the result as a block displayed as a <code>&lt;div&gt;</code> block in HTML output, as follows,</p>
<div class="language-tex vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">tex</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #6CB6FF">$$</span></span>
<span class="line"><span style="color: #6CB6FF">\frac {</span><span style="color: #F47067">\partial</span><span style="color: #6CB6FF">^r} {</span><span style="color: #F47067">\partial</span><span style="color: #6CB6FF"> </span><span style="color: #F47067">\omega</span><span style="color: #6CB6FF">^r} \left(\frac {y^{</span><span style="color: #F47067">\omega</span><span style="color: #6CB6FF">}} {</span><span style="color: #F47067">\omega</span><span style="color: #6CB6FF">}\right)</span></span>
<span class="line"><span style="color: #6CB6FF">= \left(\frac {y^{</span><span style="color: #F47067">\omega</span><span style="color: #6CB6FF">}} {</span><span style="color: #F47067">\omega</span><span style="color: #6CB6FF">}\right) \left\{(\log y)^r + </span><span style="color: #F47067">\sum</span><span style="color: #6CB6FF">_{i=1}^r \frac {(-1)^ Ir </span><span style="color: #F47067">\cdots</span><span style="color: #6CB6FF"> (r-i+1) (\log y)^{ri}} {</span><span style="color: #F47067">\omega</span><span style="color: #6CB6FF">^i} \right\}</span></span>
<span class="line"><span style="color: #6CB6FF">$$</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #032F62">$$</span></span>
<span class="line"><span style="color: #005CC5">\frac {\partial^r} {\partial \omega^r} \left(\frac {y^{\omega}} {\omega}\right)</span></span>
<span class="line"><span style="color: #005CC5">= \left(\frac {y^{\omega}} {\omega}\right) \left\{(\log y)^r + \sum_{i=1}^r \frac {(-1)^ Ir \cdots (r-i+1) (\log y)^{ri}} {\omega^i} \right\}</span></span>
<span class="line"><span style="color: #032F62">$$</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br></div></div><p>the above block equation renders the LaTeX equation as a block with output as follows,</p>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mfrac><msup><mi mathvariant="normal">∂</mi><mi>r</mi></msup><mrow><mi mathvariant="normal">∂</mi><msup><mi>ω</mi><mi>r</mi></msup></mrow></mfrac><mrow><mo fence="true">(</mo><mfrac><msup><mi>y</mi><mi>ω</mi></msup><mi>ω</mi></mfrac><mo fence="true">)</mo></mrow><mo>=</mo><mrow><mo fence="true">(</mo><mfrac><msup><mi>y</mi><mi>ω</mi></msup><mi>ω</mi></mfrac><mo fence="true">)</mo></mrow><mrow><mo fence="true">{</mo><mo stretchy="false">(</mo><mi>log</mi><mo>⁡</mo><mi>y</mi><msup><mo stretchy="false">)</mo><mi>r</mi></msup><mo>+</mo><munderover><mo>∑</mo><mrow><mi>i</mi><mo>=</mo><mn>1</mn></mrow><mi>r</mi></munderover><mfrac><mrow><mo stretchy="false">(</mo><mo>−</mo><mn>1</mn><msup><mo stretchy="false">)</mo><mi>I</mi></msup><mi>r</mi><mo>⋯</mo><mo stretchy="false">(</mo><mi>r</mi><mo>−</mo><mi>i</mi><mo>+</mo><mn>1</mn><mo stretchy="false">)</mo><mo stretchy="false">(</mo><mi>log</mi><mo>⁡</mo><mi>y</mi><msup><mo stretchy="false">)</mo><mrow><mi>r</mi><mi>i</mi></mrow></msup></mrow><msup><mi>ω</mi><mi>i</mi></msup></mfrac><mo fence="true">}</mo></mrow></mrow><annotation encoding="application/x-tex">\frac {\partial^r} {\partial \omega^r} \left(\frac {y^{\omega}} {\omega}\right)
= \left(\frac {y^{\omega}} {\omega}\right) \left\{(\log y)^r + \sum_{i=1}^r \frac {(-1)^ Ir \cdots (r-i+1) (\log y)^{ri}} {\omega^i} \right\}
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.4em;vertical-align:-0.95em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.3714em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord" style="margin-right:0.05556em;">∂</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">ω</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.5904em;"><span style="top:-2.989em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.02778em;">r</span></span></span></span></span></span></span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"><span class="mord" style="margin-right:0.05556em;">∂</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6644em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.02778em;">r</span></span></span></span></span></span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size3">(</span></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.3414em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">ω</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">y</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6644em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.03588em;">ω</span></span></span></span></span></span></span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size3">)</span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:3.0277em;vertical-align:-1.2777em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size3">(</span></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.3414em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">ω</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">y</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6644em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.03588em;">ω</span></span></span></span></span></span></span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size3">)</span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size4">{</span></span><span class="mopen">(</span><span class="mop">lo<span style="margin-right:0.01389em;">g</span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">y</span><span class="mclose"><span class="mclose">)</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7144em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.02778em;">r</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mop op-limits"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.6514em;"><span style="top:-1.8723em;margin-left:0em;"><span class="pstrut" style="height:3.05em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">i</span><span class="mrel mtight">=</span><span class="mord mtight">1</span></span></span></span><span style="top:-3.05em;"><span class="pstrut" style="height:3.05em;"></span><span><span class="mop op-symbol large-op">∑</span></span></span><span style="top:-4.3em;margin-left:0em;"><span class="pstrut" style="height:3.05em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.02778em;">r</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.2777em;"><span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.5183em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">ω</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7507em;"><span style="top:-2.989em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span></span></span></span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mopen">(</span><span class="mord">−</span><span class="mord">1</span><span class="mclose"><span class="mclose">)</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8413em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.07847em;">I</span></span></span></span></span></span></span></span><span class="mord mathnormal" style="margin-right:0.02778em;">r</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner">⋯</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right:0.02778em;">r</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal">i</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord">1</span><span class="mclose">)</span><span class="mopen">(</span><span class="mop">lo<span style="margin-right:0.01389em;">g</span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">y</span><span class="mclose"><span class="mclose">)</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8247em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.02778em;">r</span><span class="mord mathnormal mtight">i</span></span></span></span></span></span></span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size4">}</span></span></span></span></span></span></span></p>
<h2 id="_5-syntax" tabindex="-1">5: Syntax <a class="header-anchor" href="#_5-syntax" aria-label="Permalink to &quot;5: Syntax&quot;">&ZeroWidthSpace;</a></h2>
<p>Math parsing in markdown is designed to comply with the &quot;latex-in-markdown&quot; conventions set by <a href="https://pandoc.org" target="_blank" rel="noreferrer">Pandoc</a>,</p>
<p>Anything between two <code>$</code> characters will be treated as TeX math. The opening <code>$</code> must have a non-space character immediately to its right, while the closing $ must have a non-space character immediately to its left, and must not be followed immediately by a digit. Thus, <code>$20,000</code> and <code>$30,000</code> won’t parse as math. If for some reason you need to enclose text in literal <code>$</code> characters, backslash-escape them and they won’t be treated as math delimiters.</p>
<blockquote>
<ul>
<li>Pandoc. “Pandoc - Pandoc User’s Guide.” Pandoc.org, pandoc.org/MANUAL.html#math. Accessed 2 Mar. 2023.</li>
</ul>
</blockquote>
<h2 id="_6-supported-math-syntax" tabindex="-1">6: Supported math syntax <a class="header-anchor" href="#_6-supported-math-syntax" aria-label="Permalink to &quot;6: Supported math syntax&quot;">&ZeroWidthSpace;</a></h2>
<p>KaTeX is a popular, open-source math typesetting library that is based on TeX and LaTeX. It is designed to be easy to use, and to provide high-quality mathematical typesetting for web applications, refer to the following pages of the document for the full list of function support in KaTeX.</p>
<div class="info custom-block"><p class="custom-block-title">Note</p>
<p>Due to the large number of equations rendered on the next following pages, it might takes time to entirely load the webpage, please be patient if the webpage seems to not respond; or it could be a result of slow network connection to correctly render all the equation that causes broken formulas, refresh the page to proceed.</p>
</div>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[KaTeX: Supported functions]]></title>
            <link>https://note.toshiki.devapplication/markdown-it-katex/support-function</link>
            <guid>https://note.toshiki.devapplication/markdown-it-katex/support-function</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="katex-supported-function" tabindex="-1">KaTeX: Supported function <a class="header-anchor" href="#katex-supported-function" aria-label="Permalink to &quot;KaTeX: Supported function&quot;">&ZeroWidthSpace;</a></h1>
<div class="tip custom-block"><p class="custom-block-title">note</p>
<p>This is an direct shameful copy of the documentation pulled from <a href="https://raw.githubusercontent.com/Khan/KaTeX/master/docs/supported.md" target="_blank" rel="noreferrer">KaTeX</a> documentation, <strong>I do not own any of the content below on behalf of this part of the documentation</strong>, the table might be outdated as versions migrates, please also refer to <a href="https://katex.org/docs/supported.html" target="_blank" rel="noreferrer">KaTeX's official documentation</a>.</p>
</div>
<p>This following is a list of TeX functions supported by KaTeX. It is sorted into logical groups.</p>
<p>There is a similar <a href="./support-table.html">Support Table</a> on the next page, sorted alphabetically in am more intuitive way with the lists both supported and un-supported functions, viewing both tables are suggested comprehensibly and interchangeably is highly suggested.</p>
<h2 id="_1-accents" tabindex="-1">1: Accents <a class="header-anchor" href="#_1-accents" aria-label="Permalink to &quot;1: Accents&quot;">&ZeroWidthSpace;</a></h2>
<table>
<thead>
<tr>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msup><mi>a</mi><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup></mrow><annotation encoding="application/x-tex">a&#x27;</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7519em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7519em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span></span></span></span> <code>a'</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mi>a</mi><mo>~</mo></mover></mrow><annotation encoding="application/x-tex">\tilde{a}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6679em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6679em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord mathnormal">a</span></span><span style="top:-3.35em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.25em;"><span class="mord">~</span></span></span></span></span></span></span></span></span></span> <code>\tilde{a}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mi>g</mi><mo>˚</mo></mover></mrow><annotation encoding="application/x-tex">\mathring{g}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord accent"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6944em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">g</span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.3472em;"><span class="mord">˚</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.1944em;"><span></span></span></span></span></span></span></span></span> <code>\mathring{g}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msup><mi>a</mi><mrow><mo mathvariant="normal">′</mo><mo mathvariant="normal">′</mo></mrow></msup></mrow><annotation encoding="application/x-tex">a&#x27;&#x27;</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7519em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7519em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′′</span></span></span></span></span></span></span></span></span></span></span></span> <code>a''</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mrow><mi>a</mi><mi>c</mi></mrow><mo stretchy="true">~</mo></mover></mrow><annotation encoding="application/x-tex">\widetilde{ac}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7166em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7166em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="mord mathnormal">c</span></span></span><span class="svg-align" style="top:-3.4306em;"><span class="pstrut" style="height:3em;"></span><span style="height:0.286em;"><svg xmlns="http://www.w3.org/2000/svg" width='100%' height='0.286em' viewBox='0 0 1033 286' preserveAspectRatio='none'><path d='M344 55.266c-142 0-300.638 81.316-311.5 86.418
-8.01 3.762-22.5 10.91-23.5 5.562L1 120c-1-2-1-3-1-4 0-5 3-9 8-10l18.4-9C160.9
 31.9 283 0 358 0c148 0 188 122 331 122s314-97 326-97c4 0 8 2 10 7l7 21.114
c1 2.14 1 3.21 1 4.28 0 5.347-3 9.626-7 10.696l-22.3 12.622C852.6 158.372 751
 181.476 676 181.476c-149 0-189-126.21-332-126.21z'/></svg></span></span></span></span></span></span></span></span></span> <code>\widetilde{ac}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mrow><mi>A</mi><mi>B</mi></mrow><mo stretchy="true">⏠</mo></mover></mrow><annotation encoding="application/x-tex">\overgroup{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0253em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:1.0253em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span><span class="svg-align" style="top:-3.6833em;"><span class="pstrut" style="height:3em;"></span><span class="stretchy" style="height:0.342em;min-width:0.888em;"><span class="halfarrow-left" style="height:0.342em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.342em' viewBox='0 0 400000 342' preserveAspectRatio='xMinYMin slice'><path d='M400000 80
H435C64 80 168.3 229.4 21 260c-5.9 1.2-18 0-18 0-2 0-3-1-3-3v-38C76 61 257 0
 435 0h399565z'/></svg></span><span class="halfarrow-right" style="height:0.342em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.342em' viewBox='0 0 400000 342' preserveAspectRatio='xMaxYMin slice'><path d='M0 80h399565c371 0 266.7 149.4 414 180 5.9 1.2 18 0 18 0 2 0
 3-1 3-3v-38c-76-158-257-219-435-219H0z'/></svg></span></span></span></span></span></span></span></span></span></span> <code>\overgroup{AB}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msup><mi>a</mi><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup></mrow><annotation encoding="application/x-tex">a^{\prime}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7519em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7519em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span></span></span></span> <code>a^{\prime}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><munder accentunder="true"><mrow><mi>A</mi><mi>B</mi></mrow><mo stretchy="true">~</mo></munder></mrow><annotation encoding="application/x-tex">\utilde{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0893em;vertical-align:-0.406em;"></span><span class="mord accentunder"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6833em;"><span class="svg-align" style="top:-2.594em;"><span class="pstrut" style="height:3em;"></span><span style="height:0.286em;"><svg xmlns="http://www.w3.org/2000/svg" width='100%' height='0.286em' viewBox='0 0 1033 286' preserveAspectRatio='none'><path d='M344 55.266c-142 0-300.638 81.316-311.5 86.418
-8.01 3.762-22.5 10.91-23.5 5.562L1 120c-1-2-1-3-1-4 0-5 3-9 8-10l18.4-9C160.9
 31.9 283 0 358 0c148 0 188 122 331 122s314-97 326-97c4 0 8 2 10 7l7 21.114
c1 2.14 1 3.21 1 4.28 0 5.347-3 9.626-7 10.696l-22.3 12.622C852.6 158.372 751
 181.476 676 181.476c-149 0-189-126.21-332-126.21z'/></svg></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.406em;"><span></span></span></span></span></span></span></span></span> <code>\utilde{AB}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><munder accentunder="true"><mrow><mi>A</mi><mi>B</mi></mrow><mo stretchy="true">⏡</mo></munder></mrow><annotation encoding="application/x-tex">\undergroup{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0253em;vertical-align:-0.342em;"></span><span class="mord accentunder"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6833em;"><span class="svg-align" style="top:-2.658em;"><span class="pstrut" style="height:3em;"></span><span class="stretchy" style="height:0.342em;min-width:0.888em;"><span class="halfarrow-left" style="height:0.342em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.342em' viewBox='0 0 400000 342' preserveAspectRatio='xMinYMin slice'><path d='M400000 262
H435C64 262 168.3 112.6 21 82c-5.9-1.2-18 0-18 0-2 0-3 1-3 3v38c76 158 257 219
 435 219h399565z'/></svg></span><span class="halfarrow-right" style="height:0.342em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.342em' viewBox='0 0 400000 342' preserveAspectRatio='xMaxYMin slice'><path d='M0 262h399565c371 0 266.7-149.4 414-180 5.9-1.2 18 0 18
 0 2 0 3 1 3 3v38c-76 158-257 219-435 219H0z'/></svg></span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.342em;"><span></span></span></span></span></span></span></span></span> <code>\undergroup{AB}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mi>a</mi><mo>ˊ</mo></mover></mrow><annotation encoding="application/x-tex">\acute{a}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6944em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord mathnormal">a</span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.25em;"><span class="mord">ˊ</span></span></span></span></span></span></span></span></span></span> <code>\acute{a}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mi>F</mi><mo>⃗</mo></mover></mrow><annotation encoding="application/x-tex">\vec{F}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9663em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.9663em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord mathnormal" style="margin-right:0.13889em;">F</span></span><span style="top:-3.2523em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.1522em;"><span class="overlay" style="height:0.714em;width:0.471em;"><svg xmlns="http://www.w3.org/2000/svg" width='0.471em' height='0.714em' style='width:0.471em' viewBox='0 0 471 714' preserveAspectRatio='xMinYMin'><path d='M377 20c0-5.333 1.833-10 5.5-14S391 0 397 0c4.667 0 8.667 1.667 12 5
3.333 2.667 6.667 9 10 19 6.667 24.667 20.333 43.667 41 57 7.333 4.667 11
10.667 11 18 0 6-1 10-3 12s-6.667 5-14 9c-28.667 14.667-53.667 35.667-75 63
-1.333 1.333-3.167 3.5-5.5 6.5s-4 4.833-5 5.5c-1 .667-2.5 1.333-4.5 2s-4.333 1
-7 1c-4.667 0-9.167-1.833-13.5-5.5S337 184 337 178c0-12.667 15.667-32.333 47-59
H213l-171-1c-8.667-6-13-12.333-13-19 0-4.667 4.333-11.333 13-20h359
c-16-25.333-24-45-24-59z'/></svg></span></span></span></span></span></span></span></span></span></span> <code>\vec{F}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mrow><mi>A</mi><mi>B</mi></mrow><mo stretchy="true">⇒</mo></mover></mrow><annotation encoding="application/x-tex">\Overrightarrow{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2433em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:1.2433em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span><span class="svg-align" style="top:-3.6833em;"><span class="pstrut" style="height:3em;"></span><span class="hide-tail" style="height:0.56em;min-width:0.888em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.56em' viewBox='0 0 400000 560' preserveAspectRatio='xMaxYMin slice'><path d='M399738 392l
-10 10c-34 36-62.7 77-86 123-3.3 8-5 13.3-5 16 0 5.3 6.7 8 20 8 7.3 0 12.2-.5
 14.5-1.5 2.3-1 4.8-4.5 7.5-10.5 49.3-97.3 121.7-169.3 217-216 28-14 57.3-25 88
-33 6.7-2 11-3.8 13-5.5 2-1.7 3-4.2 3-7.5s-1-5.8-3-7.5c-2-1.7-6.3-3.5-13-5.5-68
-17.3-128.2-47.8-180.5-91.5-52.3-43.7-93.8-96.2-124.5-157.5-9.3-8-15.3-12.3-18
-13h-6c-12 .7-18 4-18 10 0 2 1.7 7 5 15 23.3 46 52 87 86 123l10 10H0v40h399782
c-328 0 0 0 0 0l10 8c26.7 20 65.7 43 117 69-2.7 2-6 3.7-10 5-36.7 16-72.3 37.3
-107 64l-10 8H0v40zM0 157v40h399730v-40zm0 194v40h399730v-40z'/></svg></span></span></span></span></span></span></span></span></span> <code>\Overrightarrow{AB}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mi>y</mi><mo>ˉ</mo></mover></mrow><annotation encoding="application/x-tex">\bar{y}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7622em;vertical-align:-0.1944em;"></span><span class="mord accent"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.5678em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">y</span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.1944em;"><span class="mord">ˉ</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.1944em;"><span></span></span></span></span></span></span></span></span> <code>\bar{y}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mrow><mi>A</mi><mi>B</mi></mrow><mo stretchy="true">←</mo></mover></mrow><annotation encoding="application/x-tex">\overleftarrow{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2053em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:1.2053em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span><span class="svg-align" style="top:-3.6833em;"><span class="pstrut" style="height:3em;"></span><span class="hide-tail" style="height:0.522em;min-width:0.888em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMinYMin slice'><path d='M400000 241H110l3-3c68.7-52.7 113.7-120
 135-202 4-14.7 6-23 6-25 0-7.3-7-11-21-11-8 0-13.2.8-15.5 2.5-2.3 1.7-4.2 5.8
-5.5 12.5-1.3 4.7-2.7 10.3-4 17-12 48.7-34.8 92-68.5 130S65.3 228.3 18 247
c-10 4-16 7.7-18 11 0 8.7 6 14.3 18 17 47.3 18.7 87.8 47 121.5 85S196 441.3 208
 490c.7 2 1.3 5 2 9s1.2 6.7 1.5 8c.3 1.3 1 3.3 2 6s2.2 4.5 3.5 5.5c1.3 1 3.3
 1.8 6 2.5s6 1 10 1c14 0 21-3.7 21-11 0-2-2-10.3-6-25-20-79.3-65-146.7-135-202
 l-3-3h399890zM100 241v40h399900v-40z'/></svg></span></span></span></span></span></span></span></span></span> <code>\overleftarrow{AB}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mrow><mi>A</mi><mi>B</mi></mrow><mo stretchy="true">→</mo></mover></mrow><annotation encoding="application/x-tex">\overrightarrow{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2053em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:1.2053em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span><span class="svg-align" style="top:-3.6833em;"><span class="pstrut" style="height:3em;"></span><span class="hide-tail" style="height:0.522em;min-width:0.888em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMaxYMin slice'><path d='M0 241v40h399891c-47.3 35.3-84 78-110 128
-16.7 32-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20
 11 8 0 13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7
 39-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85
-40.5-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5
-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67
 151.7 139 205zm0 0v40h399900v-40z'/></svg></span></span></span></span></span></span></span></span></span> <code>\overrightarrow{AB}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mi>a</mi><mo>˘</mo></mover></mrow><annotation encoding="application/x-tex">\breve{a}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6944em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord mathnormal">a</span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.25em;"><span class="mord">˘</span></span></span></span></span></span></span></span></span></span> <code>\breve{a}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><munder accentunder="true"><mrow><mi>A</mi><mi>B</mi></mrow><mo stretchy="true">←</mo></munder></mrow><annotation encoding="application/x-tex">\underleftarrow{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2053em;vertical-align:-0.522em;"></span><span class="mord accentunder"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6833em;"><span class="svg-align" style="top:-2.478em;"><span class="pstrut" style="height:3em;"></span><span class="hide-tail" style="height:0.522em;min-width:0.888em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMinYMin slice'><path d='M400000 241H110l3-3c68.7-52.7 113.7-120
 135-202 4-14.7 6-23 6-25 0-7.3-7-11-21-11-8 0-13.2.8-15.5 2.5-2.3 1.7-4.2 5.8
-5.5 12.5-1.3 4.7-2.7 10.3-4 17-12 48.7-34.8 92-68.5 130S65.3 228.3 18 247
c-10 4-16 7.7-18 11 0 8.7 6 14.3 18 17 47.3 18.7 87.8 47 121.5 85S196 441.3 208
 490c.7 2 1.3 5 2 9s1.2 6.7 1.5 8c.3 1.3 1 3.3 2 6s2.2 4.5 3.5 5.5c1.3 1 3.3
 1.8 6 2.5s6 1 10 1c14 0 21-3.7 21-11 0-2-2-10.3-6-25-20-79.3-65-146.7-135-202
 l-3-3h399890zM100 241v40h399900v-40z'/></svg></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.522em;"><span></span></span></span></span></span></span></span></span> <code>\underleftarrow{AB}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><munder accentunder="true"><mrow><mi>A</mi><mi>B</mi></mrow><mo stretchy="true">→</mo></munder></mrow><annotation encoding="application/x-tex">\underrightarrow{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2053em;vertical-align:-0.522em;"></span><span class="mord accentunder"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6833em;"><span class="svg-align" style="top:-2.478em;"><span class="pstrut" style="height:3em;"></span><span class="hide-tail" style="height:0.522em;min-width:0.888em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMaxYMin slice'><path d='M0 241v40h399891c-47.3 35.3-84 78-110 128
-16.7 32-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20
 11 8 0 13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7
 39-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85
-40.5-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5
-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67
 151.7 139 205zm0 0v40h399900v-40z'/></svg></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.522em;"><span></span></span></span></span></span></span></span></span> <code>\underrightarrow{AB}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mi>a</mi><mo>ˇ</mo></mover></mrow><annotation encoding="application/x-tex">\check{a}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6285em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6285em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord mathnormal">a</span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.25em;"><span class="mord">ˇ</span></span></span></span></span></span></span></span></span></span> <code>\check{a}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mrow><mi>a</mi><mi>c</mi></mrow><mo stretchy="true">↼</mo></mover></mrow><annotation encoding="application/x-tex">\overleftharpoon{ac}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9526em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.9526em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="mord mathnormal">c</span></span></span><span class="svg-align" style="top:-3.4306em;"><span class="pstrut" style="height:3em;"></span><span class="hide-tail" style="height:0.522em;min-width:0.888em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMinYMin slice'><path d='M0 267c.7 5.3 3 10 7 14h399993v-40H93c3.3
-3.3 10.2-9.5 20.5-18.5s17.8-15.8 22.5-20.5c50.7-52 88-110.3 112-175 4-11.3 5
-18.3 3-21-1.3-4-7.3-6-18-6-8 0-13 .7-15 2s-4.7 6.7-8 16c-42 98.7-107.3 174.7
-196 228-6.7 4.7-10.7 8-12 10-1.3 2-2 5.7-2 11zm100-26v40h399900v-40z'/></svg></span></span></span></span></span></span></span></span></span> <code>\overleftharpoon{ac}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mrow><mi>a</mi><mi>c</mi></mrow><mo stretchy="true">⇀</mo></mover></mrow><annotation encoding="application/x-tex">\overrightharpoon{ac}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9526em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.9526em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="mord mathnormal">c</span></span></span><span class="svg-align" style="top:-3.4306em;"><span class="pstrut" style="height:3em;"></span><span class="hide-tail" style="height:0.522em;min-width:0.888em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMaxYMin slice'><path d='M0 241v40h399993c4.7-4.7 7-9.3 7-14 0-9.3
-3.7-15.3-11-18-92.7-56.7-159-133.7-199-231-3.3-9.3-6-14.7-8-16-2-1.3-7-2-15-2
-10.7 0-16.7 2-18 6-2 2.7-1 9.7 3 21 15.3 42 36.7 81.8 64 119.5 27.3 37.7 58
 69.2 92 94.5zm0 0v40h399900v-40z'/></svg></span></span></span></span></span></span></span></span></span> <code>\overrightharpoon{ac}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mi>a</mi><mo>˙</mo></mover></mrow><annotation encoding="application/x-tex">\dot{a}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6679em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6679em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord mathnormal">a</span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.1389em;"><span class="mord">˙</span></span></span></span></span></span></span></span></span></span> <code>\dot{a}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mrow><mi>A</mi><mi>B</mi></mrow><mo stretchy="true">↔</mo></mover></mrow><annotation encoding="application/x-tex">\overleftrightarrow{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2053em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:1.2053em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span><span class="svg-align" style="top:-3.6833em;"><span class="pstrut" style="height:3em;"></span><span class="stretchy" style="height:0.522em;min-width:0.888em;"><span class="halfarrow-left" style="height:0.522em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMinYMin slice'><path d='M400000 241H110l3-3c68.7-52.7 113.7-120
 135-202 4-14.7 6-23 6-25 0-7.3-7-11-21-11-8 0-13.2.8-15.5 2.5-2.3 1.7-4.2 5.8
-5.5 12.5-1.3 4.7-2.7 10.3-4 17-12 48.7-34.8 92-68.5 130S65.3 228.3 18 247
c-10 4-16 7.7-18 11 0 8.7 6 14.3 18 17 47.3 18.7 87.8 47 121.5 85S196 441.3 208
 490c.7 2 1.3 5 2 9s1.2 6.7 1.5 8c.3 1.3 1 3.3 2 6s2.2 4.5 3.5 5.5c1.3 1 3.3
 1.8 6 2.5s6 1 10 1c14 0 21-3.7 21-11 0-2-2-10.3-6-25-20-79.3-65-146.7-135-202
 l-3-3h399890zM100 241v40h399900v-40z'/></svg></span><span class="halfarrow-right" style="height:0.522em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMaxYMin slice'><path d='M0 241v40h399891c-47.3 35.3-84 78-110 128
-16.7 32-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20
 11 8 0 13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7
 39-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85
-40.5-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5
-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67
 151.7 139 205zm0 0v40h399900v-40z'/></svg></span></span></span></span></span></span></span></span></span></span> <code>\overleftrightarrow{AB}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mrow><mi>A</mi><mi>B</mi></mrow><mo stretchy="true">⏞</mo></mover></mrow><annotation encoding="application/x-tex">\overbrace{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.3313em;"></span><span class="mord mover"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:1.3313em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span><span class="svg-align" style="top:-3.7833em;"><span class="pstrut" style="height:3em;"></span><span class="stretchy" style="height:0.548em;min-width:1.6em;"><span class="brace-left" style="height:0.548em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.548em' viewBox='0 0 400000 548' preserveAspectRatio='xMinYMin slice'><path d='M6 548l-6-6v-35l6-11c56-104 135.3-181.3 238-232 57.3-28.7 117
-45 179-50h399577v120H403c-43.3 7-81 15-113 26-100.7 33-179.7 91-237 174-2.7
 5-6 9-10 13-.7 1-7.3 1-20 1H6z'/></svg></span><span class="brace-center" style="height:0.548em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.548em' viewBox='0 0 400000 548' preserveAspectRatio='xMidYMin slice'><path d='M200428 334
c-100.7-8.3-195.3-44-280-108-55.3-42-101.7-93-139-153l-9-14c-2.7 4-5.7 8.7-9 14
-53.3 86.7-123.7 153-211 199-66.7 36-137.3 56.3-212 62H0V214h199568c178.3-11.7
 311.7-78.3 403-201 6-8 9.7-12 11-12 .7-.7 6.7-1 18-1s17.3.3 18 1c1.3 0 5 4 11
 12 44.7 59.3 101.3 106.3 170 141s145.3 54.3 229 60h199572v120z'/></svg></span><span class="brace-right" style="height:0.548em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.548em' viewBox='0 0 400000 548' preserveAspectRatio='xMaxYMin slice'><path d='M400000 542l
-6 6h-17c-12.7 0-19.3-.3-20-1-4-4-7.3-8.3-10-13-35.3-51.3-80.8-93.8-136.5-127.5
s-117.2-55.8-184.5-66.5c-.7 0-2-.3-4-1-18.7-2.7-76-4.3-172-5H0V214h399571l6 1
c124.7 8 235 61.7 331 161 31.3 33.3 59.7 72.7 85 118l7 13v35z'/></svg></span></span></span></span></span></span></span></span></span></span> <code>\overbrace{AB}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mi>a</mi><mo>¨</mo></mover></mrow><annotation encoding="application/x-tex">\ddot{a}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6679em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6679em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord mathnormal">a</span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.25em;"><span class="mord">¨</span></span></span></span></span></span></span></span></span></span> <code>\ddot{a}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><munder accentunder="true"><mrow><mi>A</mi><mi>B</mi></mrow><mo stretchy="true">↔</mo></munder></mrow><annotation encoding="application/x-tex">\underleftrightarrow{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2053em;vertical-align:-0.522em;"></span><span class="mord accentunder"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6833em;"><span class="svg-align" style="top:-2.478em;"><span class="pstrut" style="height:3em;"></span><span class="stretchy" style="height:0.522em;min-width:0.888em;"><span class="halfarrow-left" style="height:0.522em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMinYMin slice'><path d='M400000 241H110l3-3c68.7-52.7 113.7-120
 135-202 4-14.7 6-23 6-25 0-7.3-7-11-21-11-8 0-13.2.8-15.5 2.5-2.3 1.7-4.2 5.8
-5.5 12.5-1.3 4.7-2.7 10.3-4 17-12 48.7-34.8 92-68.5 130S65.3 228.3 18 247
c-10 4-16 7.7-18 11 0 8.7 6 14.3 18 17 47.3 18.7 87.8 47 121.5 85S196 441.3 208
 490c.7 2 1.3 5 2 9s1.2 6.7 1.5 8c.3 1.3 1 3.3 2 6s2.2 4.5 3.5 5.5c1.3 1 3.3
 1.8 6 2.5s6 1 10 1c14 0 21-3.7 21-11 0-2-2-10.3-6-25-20-79.3-65-146.7-135-202
 l-3-3h399890zM100 241v40h399900v-40z'/></svg></span><span class="halfarrow-right" style="height:0.522em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMaxYMin slice'><path d='M0 241v40h399891c-47.3 35.3-84 78-110 128
-16.7 32-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20
 11 8 0 13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7
 39-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85
-40.5-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5
-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67
 151.7 139 205zm0 0v40h399900v-40z'/></svg></span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.522em;"><span></span></span></span></span></span></span></span></span> <code>\underleftrightarrow{AB}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><munder><mrow><mi>A</mi><mi>B</mi></mrow><mo stretchy="true">⏟</mo></munder></mrow><annotation encoding="application/x-tex">\underbrace{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.3313em;vertical-align:-0.648em;"></span><span class="mord munder"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6833em;"><span class="svg-align" style="top:-2.352em;"><span class="pstrut" style="height:3em;"></span><span class="stretchy" style="height:0.548em;min-width:1.6em;"><span class="brace-left" style="height:0.548em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.548em' viewBox='0 0 400000 548' preserveAspectRatio='xMinYMin slice'><path d='M0 6l6-6h17c12.688 0 19.313.3 20 1 4 4 7.313 8.3 10 13
 35.313 51.3 80.813 93.8 136.5 127.5 55.688 33.7 117.188 55.8 184.5 66.5.688
 0 2 .3 4 1 18.688 2.7 76 4.3 172 5h399450v120H429l-6-1c-124.688-8-235-61.7
-331-161C60.687 138.7 32.312 99.3 7 54L0 41V6z'/></svg></span><span class="brace-center" style="height:0.548em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.548em' viewBox='0 0 400000 548' preserveAspectRatio='xMidYMin slice'><path d='M199572 214
c100.7 8.3 195.3 44 280 108 55.3 42 101.7 93 139 153l9 14c2.7-4 5.7-8.7 9-14
 53.3-86.7 123.7-153 211-199 66.7-36 137.3-56.3 212-62h199568v120H200432c-178.3
 11.7-311.7 78.3-403 201-6 8-9.7 12-11 12-.7.7-6.7 1-18 1s-17.3-.3-18-1c-1.3 0
-5-4-11-12-44.7-59.3-101.3-106.3-170-141s-145.3-54.3-229-60H0V214z'/></svg></span><span class="brace-right" style="height:0.548em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.548em' viewBox='0 0 400000 548' preserveAspectRatio='xMaxYMin slice'><path d='M399994 0l6 6v35l-6 11c-56 104-135.3 181.3-238 232-57.3
 28.7-117 45-179 50H-300V214h399897c43.3-7 81-15 113-26 100.7-33 179.7-91 237
-174 2.7-5 6-9 10-13 .7-1 7.3-1 20-1h17z'/></svg></span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.648em;"><span></span></span></span></span></span></span></span></span> <code>\underbrace{AB}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mi>a</mi><mo>ˋ</mo></mover></mrow><annotation encoding="application/x-tex">\grave{a}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6944em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord mathnormal">a</span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.25em;"><span class="mord">ˋ</span></span></span></span></span></span></span></span></span></span> <code>\grave{a}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mrow><mi>A</mi><mi>B</mi></mrow><mo stretchy="true">‾</mo></mover></mrow><annotation encoding="application/x-tex">\overline{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8833em;"></span><span class="mord overline"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8833em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span><span style="top:-3.8033em;"><span class="pstrut" style="height:3em;"></span><span class="overline-line" style="border-bottom-width:0.04em;"></span></span></span></span></span></span></span></span></span> <code>\overline{AB}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mrow><mi>A</mi><mi>B</mi></mrow><mo stretchy="true">undefined</mo></mover></mrow><annotation encoding="application/x-tex">\overlinesegment{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2053em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:1.2053em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span><span class="svg-align" style="top:-3.6833em;"><span class="pstrut" style="height:3em;"></span><span class="stretchy" style="height:0.522em;min-width:0.888em;"><span class="halfarrow-left" style="height:0.522em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMinYMin slice'><path d='M40 281 V428 H0 V94 H40 V241 H400000 v40z
M40 281 V428 H0 V94 H40 V241 H400000 v40z'/></svg></span><span class="halfarrow-right" style="height:0.522em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMaxYMin slice'><path d='M399960 241 V94 h40 V428 h-40 V281 H0 v-40z
M399960 241 V94 h40 V428 h-40 V281 H0 v-40z'/></svg></span></span></span></span></span></span></span></span></span></span> <code>\overlinesegment{AB}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mi>θ</mi><mo>^</mo></mover></mrow><annotation encoding="application/x-tex">\hat{\theta}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9579em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.9579em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord mathnormal" style="margin-right:0.02778em;">θ</span></span><span style="top:-3.2634em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.1667em;"><span class="mord">^</span></span></span></span></span></span></span></span></span></span> <code>\hat{\theta}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><munder accentunder="true"><mrow><mi>A</mi><mi>B</mi></mrow><mo stretchy="true">‾</mo></munder></mrow><annotation encoding="application/x-tex">\underline{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8833em;vertical-align:-0.2em;"></span><span class="mord underline"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6833em;"><span style="top:-2.84em;"><span class="pstrut" style="height:3em;"></span><span class="underline-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2em;"><span></span></span></span></span></span></span></span></span> <code>\underline{AB}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><munder accentunder="true"><mrow><mi>A</mi><mi>B</mi></mrow><mo stretchy="true">undefined</mo></munder></mrow><annotation encoding="application/x-tex">\underlinesegment{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2053em;vertical-align:-0.522em;"></span><span class="mord accentunder"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6833em;"><span class="svg-align" style="top:-2.478em;"><span class="pstrut" style="height:3em;"></span><span class="stretchy" style="height:0.522em;min-width:0.888em;"><span class="halfarrow-left" style="height:0.522em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMinYMin slice'><path d='M40 281 V428 H0 V94 H40 V241 H400000 v40z
M40 281 V428 H0 V94 H40 V241 H400000 v40z'/></svg></span><span class="halfarrow-right" style="height:0.522em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMaxYMin slice'><path d='M399960 241 V94 h40 V428 h-40 V281 H0 v-40z
M399960 241 V94 h40 V428 h-40 V281 H0 v-40z'/></svg></span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.522em;"><span></span></span></span></span></span></span></span></span> <code>\underlinesegment{AB}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mrow><mi>a</mi><mi>c</mi></mrow><mo stretchy="true">^</mo></mover></mrow><annotation encoding="application/x-tex">\widehat{ac}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7306em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7306em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="mord mathnormal">c</span></span></span><span class="svg-align" style="top:-3.4306em;"><span class="pstrut" style="height:3em;"></span><span style="height:0.3em;"><svg xmlns="http://www.w3.org/2000/svg" width='100%' height='0.3em' viewBox='0 0 2364 300' preserveAspectRatio='none'><path d='M1181 0h2l1171 176c6 0 10 5 10 11l-2 23c-1 6-5 10
-11 10h-1L1182 67 15 220h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z'/></svg></span></span></span></span></span></span></span></span></span> <code>\widehat{ac}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mrow><mi>a</mi><mi>c</mi></mrow><mo stretchy="true">ˇ</mo></mover></mrow><annotation encoding="application/x-tex">\widecheck{ac}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7306em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7306em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="mord mathnormal">c</span></span></span><span class="svg-align" style="top:-3.4306em;"><span class="pstrut" style="height:3em;"></span><span style="height:0.3em;"><svg xmlns="http://www.w3.org/2000/svg" width='100%' height='0.3em' viewBox='0 0 2364 300' preserveAspectRatio='none'><path d='M1181,220h2l1171,-176c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,
-11,-10h-1l-1168,153l-1167,-153h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z'/></svg></span></span></span></span></span></span></span></span></span> <code>\widecheck{ac}</code></td>
<td style="text-align:left"></td>
</tr>
</tbody>
</table>
<p><strong><em>Accent functions inside \text{…}</em></strong></p>
<table>
<thead>
<tr>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mtext>a</mtext><mo>ˊ</mo></mover></mrow><annotation encoding="application/x-tex">\text{\&#x27;{a}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6944em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">a</span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.25em;"><span class="mord">ˊ</span></span></span></span></span></span></span></span></span></span></span> <code>\'{a}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mtext>a</mtext><mo>˜</mo></mover></mrow><annotation encoding="application/x-tex">\text{\~{a}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6679em;"></span><span class="mord text"><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6679em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">a</span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.25em;"><span class="mord">˜</span></span></span></span></span></span></span></span></span></span></span> <code>\~{a}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mtext>a</mtext><mo>˙</mo></mover></mrow><annotation encoding="application/x-tex">\text{\.{a}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6679em;"></span><span class="mord text"><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6679em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">a</span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.1389em;"><span class="mord">˙</span></span></span></span></span></span></span></span></span></span></span> <code>\.{a}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mtext>a</mtext><mo>˝</mo></mover></mrow><annotation encoding="application/x-tex">\text{\H{a}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6944em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">a</span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.25em;"><span class="mord">˝</span></span></span></span></span></span></span></span></span></span></span> <code>\H{a}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mtext>a</mtext><mo>ˋ</mo></mover></mrow><annotation encoding="application/x-tex">\text{\`{a}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6944em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">a</span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.25em;"><span class="mord">ˋ</span></span></span></span></span></span></span></span></span></span></span> <code>\`{a}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mtext>a</mtext><mo>ˉ</mo></mover></mrow><annotation encoding="application/x-tex">\text{\={a}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5678em;"></span><span class="mord text"><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.5678em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">a</span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.25em;"><span class="mord">ˉ</span></span></span></span></span></span></span></span></span></span></span> <code>\={a}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mtext>a</mtext><mo>¨</mo></mover></mrow><annotation encoding="application/x-tex">\text{\&quot;{a}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6679em;"></span><span class="mord text"><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6679em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">a</span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.25em;"><span class="mord">¨</span></span></span></span></span></span></span></span></span></span></span> <code>\&quot;{a}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mtext>a</mtext><mo>ˇ</mo></mover></mrow><annotation encoding="application/x-tex">\text{\v{a}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6285em;"></span><span class="mord text"><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6285em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">a</span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.25em;"><span class="mord">ˇ</span></span></span></span></span></span></span></span></span></span></span> <code>\v{a}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mtext>a</mtext><mo>ˆ</mo></mover></mrow><annotation encoding="application/x-tex">\text{\^{a}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6944em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">a</span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.25em;"><span class="mord">ˆ</span></span></span></span></span></span></span></span></span></span></span> <code>\^{a}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mtext>a</mtext><mo>˘</mo></mover></mrow><annotation encoding="application/x-tex">\text{\u{a}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6944em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">a</span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.25em;"><span class="mord">˘</span></span></span></span></span></span></span></span></span></span></span> <code>\u{a}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mtext>a</mtext><mo>˚</mo></mover></mrow><annotation encoding="application/x-tex">\text{\r{a}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6944em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">a</span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.375em;"><span class="mord">˚</span></span></span></span></span></span></span></span></span></span></span> <code>\r{a}</code></td>
<td style="text-align:left"></td>
</tr>
</tbody>
</table>
<p>See also <a href="#_5-letters-and-unicode">letters</a>.</p>
<h2 id="_2-delimiters" tabindex="-1">2: Delimiters <a class="header-anchor" href="#_2-delimiters" aria-label="Permalink to &quot;2: Delimiters&quot;">&ZeroWidthSpace;</a></h2>
<table>
<thead>
<tr>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">(</mo><mtext> </mtext><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">(~)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">(</span><span class="mspace nobreak"> </span><span class="mclose">)</span></span></span></span> <code>( )</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">(</mo><mtext> </mtext><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">\lparen~\rparen</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">(</span><span class="mspace nobreak"> </span><span class="mclose">)</span></span></span></span> <code>\lparen</code><br><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>    </mtext></mrow><annotation encoding="application/x-tex">~~~~</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0em;"></span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span></span></span></span><code>\rparen</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">⌈</mo><mtext> </mtext><mo stretchy="false">⌉</mo></mrow><annotation encoding="application/x-tex">⌈~⌉</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">⌈</span><span class="mspace nobreak"> </span><span class="mclose">⌉</span></span></span></span> <code>⌈ ⌉</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">⌈</mo><mtext> </mtext><mo stretchy="false">⌉</mo></mrow><annotation encoding="application/x-tex">\lceil~\rceil</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">⌈</span><span class="mspace nobreak"> </span><span class="mclose">⌉</span></span></span></span> <code>\lceil</code><br><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>     </mtext></mrow><annotation encoding="application/x-tex">~~~~~</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0em;"></span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span></span></span></span><code>\rceil</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↑</mo></mrow><annotation encoding="application/x-tex">\uparrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel">↑</span></span></span></span> <code>\uparrow</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">[</mo><mtext> </mtext><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">[~]</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">[</span><span class="mspace nobreak"> </span><span class="mclose">]</span></span></span></span> <code>[ ]</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">[</mo><mtext> </mtext><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">\lbrack~\rbrack</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">[</span><span class="mspace nobreak"> </span><span class="mclose">]</span></span></span></span> <code>\lbrack</code><br><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>    </mtext></mrow><annotation encoding="application/x-tex">~~~~</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0em;"></span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span></span></span></span><code>\rbrack</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">⌊</mo><mtext> </mtext><mo stretchy="false">⌋</mo></mrow><annotation encoding="application/x-tex">⌊~⌋</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">⌊</span><span class="mspace nobreak"> </span><span class="mclose">⌋</span></span></span></span> <code>⌊ ⌋</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">⌊</mo><mtext> </mtext><mo stretchy="false">⌋</mo></mrow><annotation encoding="application/x-tex">\lfloor~\rfloor</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">⌊</span><span class="mspace nobreak"> </span><span class="mclose">⌋</span></span></span></span> <code>\lfloor</code><br><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>     </mtext></mrow><annotation encoding="application/x-tex">~~~~~</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0em;"></span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span></span></span></span><code>\rfloor</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↓</mo></mrow><annotation encoding="application/x-tex">\downarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel">↓</span></span></span></span> <code>\downarrow</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">{</mo><mo stretchy="false">}</mo></mrow><annotation encoding="application/x-tex">\{ \}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">{</span><span class="mclose">}</span></span></span></span> <code>\{ \}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">{</mo><mo stretchy="false">}</mo></mrow><annotation encoding="application/x-tex">\lbrace \rbrace</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">{</span><span class="mclose">}</span></span></span></span> <code>\lbrace</code><br><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>    </mtext></mrow><annotation encoding="application/x-tex">~~~~</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0em;"></span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span></span></span></span><code>\rbrace</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">⎰</mo><mo stretchy="false">⎱</mo></mrow><annotation encoding="application/x-tex">⎰⎱</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.989em;vertical-align:-0.244em;"></span><span class="mopen">⎰</span><span class="mclose">⎱</span></span></span></span> <code>⎰⎱</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">⎰</mo><mo stretchy="false">⎱</mo></mrow><annotation encoding="application/x-tex">\lmoustache \rmoustache</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.989em;vertical-align:-0.244em;"></span><span class="mopen">⎰</span><span class="mclose">⎱</span></span></span></span> <code>\lmoustache</code><br><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>    </mtext></mrow><annotation encoding="application/x-tex">~~~~</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0em;"></span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span></span></span></span><code>\rmoustache</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↕</mo></mrow><annotation encoding="application/x-tex">\updownarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mrel">↕</span></span></span></span> <code>\updownarrow</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">⟨</mo><mtext> </mtext><mo stretchy="false">⟩</mo></mrow><annotation encoding="application/x-tex">⟨~⟩</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">⟨</span><span class="mspace nobreak"> </span><span class="mclose">⟩</span></span></span></span> <code>⟨ ⟩</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">⟨</mo><mtext> </mtext><mo stretchy="false">⟩</mo></mrow><annotation encoding="application/x-tex">\langle~\rangle</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">⟨</span><span class="mspace nobreak"> </span><span class="mclose">⟩</span></span></span></span> <code>\langle</code><br><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>    </mtext></mrow><annotation encoding="application/x-tex">~~~~</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0em;"></span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span></span></span></span><code>\rangle</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">⟮</mo><mtext> </mtext><mo stretchy="false">⟯</mo></mrow><annotation encoding="application/x-tex">⟮~⟯</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.989em;vertical-align:-0.244em;"></span><span class="mopen">⟮</span><span class="mspace nobreak"> </span><span class="mclose">⟯</span></span></span></span> <code>⟮ ⟯</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">⟮</mo><mtext> </mtext><mo stretchy="false">⟯</mo></mrow><annotation encoding="application/x-tex">\lgroup~\rgroup</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.989em;vertical-align:-0.244em;"></span><span class="mopen">⟮</span><span class="mspace nobreak"> </span><span class="mclose">⟯</span></span></span></span> <code>\lgroup</code><br><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>     </mtext></mrow><annotation encoding="application/x-tex">~~~~~</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0em;"></span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span></span></span></span><code>\rgroup</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇑</mo></mrow><annotation encoding="application/x-tex">\Uparrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel">⇑</span></span></span></span> <code>\Uparrow</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∣</mi></mrow><annotation encoding="application/x-tex">\vert</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">∣</span></span></span></span> <code>|</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∣</mi></mrow><annotation encoding="application/x-tex">\vert</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">∣</span></span></span></span> <code>\vert</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">┌</mo><mo stretchy="false">┐</mo></mrow><annotation encoding="application/x-tex">┌ ┐</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mopen amsrm">┌</span><span class="mclose amsrm">┐</span></span></span></span> <code>┌ ┐</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mi mathvariant="normal">⌜</mi></mo><mo><mi mathvariant="normal">⌝</mi></mo></mrow><annotation encoding="application/x-tex">\ulcorner \urcorner</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mopen amsrm">┌</span><span class="mclose amsrm">┐</span></span></span></span> <code>\ulcorner</code><br><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>    </mtext></mrow><annotation encoding="application/x-tex">~~~~</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0em;"></span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span></span></span></span><code>\urcorner</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇓</mo></mrow><annotation encoding="application/x-tex">\Downarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel">⇓</span></span></span></span> <code>\Downarrow</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∥</mi></mrow><annotation encoding="application/x-tex">\Vert</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">∥</span></span></span></span> <code>\|</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∥</mi></mrow><annotation encoding="application/x-tex">\Vert</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">∥</span></span></span></span> <code>\Vert</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">└</mo><mo stretchy="false">┘</mo></mrow><annotation encoding="application/x-tex">└ ┘</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3779em;"></span><span class="mopen amsrm">└</span><span class="mclose amsrm">┘</span></span></span></span> <code>└ ┘</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mi mathvariant="normal">⌞</mi></mo><mo><mi mathvariant="normal">⌟</mi></mo></mrow><annotation encoding="application/x-tex">\llcorner \lrcorner</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3779em;"></span><span class="mopen amsrm">└</span><span class="mclose amsrm">┘</span></span></span></span> <code>\llcorner</code><br><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>    </mtext></mrow><annotation encoding="application/x-tex">~~~~</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0em;"></span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span></span></span></span><code>\lrcorner</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇕</mo></mrow><annotation encoding="application/x-tex">\Updownarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mrel">⇕</span></span></span></span> <code>\Updownarrow</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">∣</mo><mtext> </mtext><mo stretchy="false">∣</mo></mrow><annotation encoding="application/x-tex">\lvert~\rvert</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">∣</span><span class="mspace nobreak"> </span><span class="mclose">∣</span></span></span></span> <code>\lvert</code><br><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>    </mtext></mrow><annotation encoding="application/x-tex">~~~~</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0em;"></span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span></span></span></span><code>\rvert</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">∥</mo><mtext> </mtext><mo stretchy="false">∥</mo></mrow><annotation encoding="application/x-tex">\lVert~\rVert</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">∥</span><span class="mspace nobreak"> </span><span class="mclose">∥</span></span></span></span> <code>\lVert</code><br><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>     </mtext></mrow><annotation encoding="application/x-tex">~~~~~</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0em;"></span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span></span></span></span><code>\rVert</code></td>
<td style="text-align:left"><code>\left.</code></td>
<td style="text-align:left"><code>\right.</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">\</mi></mrow><annotation encoding="application/x-tex">\backslash</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">\</span></span></span></span> <code>\backslash</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">⟨</mo><mtext> </mtext><mo stretchy="false">⟩</mo></mrow><annotation encoding="application/x-tex">\lang~\rang</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">⟨</span><span class="mspace nobreak"> </span><span class="mclose">⟩</span></span></span></span> <code>\lang</code><br><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>    </mtext></mrow><annotation encoding="application/x-tex">~~~~</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0em;"></span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span></span></span></span><code>\rang</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>&lt;</mo><mtext> </mtext><mo>&gt;</mo></mrow><annotation encoding="application/x-tex">\lt~\gt</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">&lt;</span><span class="mspace nobreak"> </span><span class="mrel">&gt;</span></span></span></span> <code>\lt \gt</code></td>
<td style="text-align:left"></td>
<td style="text-align:left"></td>
<td style="text-align:left"></td>
</tr>
</tbody>
</table>
<p><strong>Delimiter Sizing</strong></p>
<p><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true">(</mo><mstyle mathsize="1.728em"><mrow><mi>A</mi><mi>B</mi></mrow></mstyle><mo fence="true">)</mo></mrow><annotation encoding="application/x-tex">\left(\LARGE{AB}\right)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.8308em;vertical-align:-0.65em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size2">(</span></span><span class="mord sizing reset-size6 size9"><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size2">)</span></span></span></span></span></span> <code>\left(\LARGE{AB}\right)</code></p>
<p><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">(</mo><mo fence="false" stretchy="true" minsize="1.2em" maxsize="1.2em">(</mo><mo fence="false" stretchy="true" minsize="1.8em" maxsize="1.8em">(</mo><mo fence="false" stretchy="true" minsize="2.4em" maxsize="2.4em">(</mo><mo fence="false" stretchy="true" minsize="3em" maxsize="3em">(</mo></mrow><annotation encoding="application/x-tex">( \big( \Big( \bigg( \Bigg(</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:3em;vertical-align:-1.25em;"></span><span class="mopen">(</span><span class="mord"><span class="delimsizing size1">(</span></span><span class="mord"><span class="delimsizing size2">(</span></span><span class="mord"><span class="delimsizing size3">(</span></span><span class="mord"><span class="delimsizing size4">(</span></span></span></span></span> <code>( \big( \Big( \bigg( \Bigg(</code></p>
<table>
<thead>
<tr>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left"><code>\left</code></td>
<td style="text-align:left"><code>\big</code></td>
<td style="text-align:left"><code>\bigl</code></td>
<td style="text-align:left"><code>\bigm</code></td>
<td style="text-align:left"><code>\bigr</code></td>
</tr>
<tr>
<td style="text-align:left"><code>\middle</code></td>
<td style="text-align:left"><code>\Big</code></td>
<td style="text-align:left"><code>\Bigl</code></td>
<td style="text-align:left"><code>\Bigm</code></td>
<td style="text-align:left"><code>\Bigr</code></td>
</tr>
<tr>
<td style="text-align:left"><code>\right</code></td>
<td style="text-align:left"><code>\bigg</code></td>
<td style="text-align:left"><code>\biggl</code></td>
<td style="text-align:left"><code>\biggm</code></td>
<td style="text-align:left"><code>\biggr</code></td>
</tr>
<tr>
<td style="text-align:left"></td>
<td style="text-align:left"><code>\Bigg</code></td>
<td style="text-align:left"><code>\Biggl</code></td>
<td style="text-align:left"><code>\Biggm</code></td>
<td style="text-align:left"><code>\Biggr</code></td>
</tr>
</tbody>
</table>
<h2 id="_3-environments" tabindex="-1">3: Environments <a class="header-anchor" href="#_3-environments" aria-label="Permalink to &quot;3: Environments&quot;">&ZeroWidthSpace;</a></h2>
<table>
<thead>
<tr>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mtable rowspacing="0.16em" columnalign="center center" columnspacing="1em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>a</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>b</mi></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>c</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>d</mi></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{matrix} a &amp; b \\ c &amp; d \end{matrix}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.4em;vertical-align:-0.95em;"></span><span class="mord"><span class="mtable"><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:0.5em;"></span><span class="arraycolsep" style="width:0.5em;"></span><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">b</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">d</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\begin{matrix}</code><br>   <code>a &amp; b \\</code><br>   <code>c &amp; d</code><br><code>\end{matrix}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mtable rowspacing="0.16em" columnalign="center center" columnspacing="1em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>a</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>b</mi></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>c</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>d</mi></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{array}{cc}a &amp; b\\c &amp; d\end{array}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.4em;vertical-align:-0.95em;"></span><span class="mord"><span class="mtable"><span class="arraycolsep" style="width:0.5em;"></span><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:0.5em;"></span><span class="arraycolsep" style="width:0.5em;"></span><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">b</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">d</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:0.5em;"></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\begin{array}{cc}</code><br>   <code>a &amp; b \\</code><br>   <code>c &amp; d</code><br><code>\end{array}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true">(</mo><mtable rowspacing="0.16em" columnalign="center center" columnspacing="1em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>a</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>b</mi></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>c</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>d</mi></mstyle></mtd></mtr></mtable><mo fence="true">)</mo></mrow><annotation encoding="application/x-tex">\begin{pmatrix} a &amp; b \\ c &amp; d \end{pmatrix}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.4em;vertical-align:-0.95em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size3">(</span></span><span class="mord"><span class="mtable"><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:0.5em;"></span><span class="arraycolsep" style="width:0.5em;"></span><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">b</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">d</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size3">)</span></span></span></span></span></span></td>
<td style="text-align:left"><code>\begin{pmatrix}</code><br>   <code>a &amp; b \\</code><br>   <code>c &amp; d</code><br><code>\end{pmatrix}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true">[</mo><mtable rowspacing="0.16em" columnalign="center center" columnspacing="1em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>a</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>b</mi></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>c</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>d</mi></mstyle></mtd></mtr></mtable><mo fence="true">]</mo></mrow><annotation encoding="application/x-tex">\begin{bmatrix} a &amp; b \\ c &amp; d \end{bmatrix}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.4em;vertical-align:-0.95em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size3">[</span></span><span class="mord"><span class="mtable"><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:0.5em;"></span><span class="arraycolsep" style="width:0.5em;"></span><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">b</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">d</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size3">]</span></span></span></span></span></span></td>
<td style="text-align:left"><code>\begin{bmatrix}</code><br>   <code>a &amp; b \\</code><br>   <code>c &amp; d</code><br><code>\end{bmatrix}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true">∣</mo><mtable rowspacing="0.16em" columnalign="center center" columnspacing="1em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>a</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>b</mi></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>c</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>d</mi></mstyle></mtd></mtr></mtable><mo fence="true">∣</mo></mrow><annotation encoding="application/x-tex">\begin{vmatrix} a &amp; b \\ c &amp; d \end{vmatrix}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.4em;vertical-align:-0.95em;"></span><span class="minner"><span class="mopen"><span class="delimsizing mult"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.45em;"><span class="pstrut" style="height:4.4em;"></span><span style="width:0.333em;height:2.400em;"><svg xmlns="http://www.w3.org/2000/svg" width='0.333em' height='2.400em' viewBox='0 0 333 2400'><path d='M145 15 v585 v1200 v585 c2.667,10,9.667,15,21,15
c10,0,16.667,-5,20,-15 v-585 v-1200 v-585 c-2.667,-10,-9.667,-15,-21,-15
c-10,0,-16.667,5,-20,15z M188 15 H145 v585 v1200 v585 h43z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span></span><span class="mord"><span class="mtable"><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:0.5em;"></span><span class="arraycolsep" style="width:0.5em;"></span><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">b</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">d</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span></span></span><span class="mclose"><span class="delimsizing mult"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.45em;"><span class="pstrut" style="height:4.4em;"></span><span style="width:0.333em;height:2.400em;"><svg xmlns="http://www.w3.org/2000/svg" width='0.333em' height='2.400em' viewBox='0 0 333 2400'><path d='M145 15 v585 v1200 v585 c2.667,10,9.667,15,21,15
c10,0,16.667,-5,20,-15 v-585 v-1200 v-585 c-2.667,-10,-9.667,-15,-21,-15
c-10,0,-16.667,5,-20,15z M188 15 H145 v585 v1200 v585 h43z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\begin{vmatrix}</code><br>   <code>a &amp; b \\</code><br>   <code>c &amp; d</code><br><code>\end{vmatrix}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true">∥</mo><mtable rowspacing="0.16em" columnalign="center center" columnspacing="1em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>a</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>b</mi></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>c</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>d</mi></mstyle></mtd></mtr></mtable><mo fence="true">∥</mo></mrow><annotation encoding="application/x-tex">\begin{Vmatrix} a &amp; b \\ c &amp; d \end{Vmatrix}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.4em;vertical-align:-0.95em;"></span><span class="minner"><span class="mopen"><span class="delimsizing mult"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.45em;"><span class="pstrut" style="height:4.4em;"></span><span style="width:0.556em;height:2.400em;"><svg xmlns="http://www.w3.org/2000/svg" width='0.556em' height='2.400em' viewBox='0 0 556 2400'><path d='M145 15 v585 v1200 v585 c2.667,10,9.667,15,21,15
c10,0,16.667,-5,20,-15 v-585 v-1200 v-585 c-2.667,-10,-9.667,-15,-21,-15
c-10,0,-16.667,5,-20,15z M188 15 H145 v585 v1200 v585 h43z
M367 15 v585 v1200 v585 c2.667,10,9.667,15,21,15
c10,0,16.667,-5,20,-15 v-585 v-1200 v-585 c-2.667,-10,-9.667,-15,-21,-15
c-10,0,-16.667,5,-20,15z M410 15 H367 v585 v1200 v585 h43z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span></span><span class="mord"><span class="mtable"><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:0.5em;"></span><span class="arraycolsep" style="width:0.5em;"></span><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">b</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">d</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span></span></span><span class="mclose"><span class="delimsizing mult"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.45em;"><span class="pstrut" style="height:4.4em;"></span><span style="width:0.556em;height:2.400em;"><svg xmlns="http://www.w3.org/2000/svg" width='0.556em' height='2.400em' viewBox='0 0 556 2400'><path d='M145 15 v585 v1200 v585 c2.667,10,9.667,15,21,15
c10,0,16.667,-5,20,-15 v-585 v-1200 v-585 c-2.667,-10,-9.667,-15,-21,-15
c-10,0,-16.667,5,-20,15z M188 15 H145 v585 v1200 v585 h43z
M367 15 v585 v1200 v585 c2.667,10,9.667,15,21,15
c10,0,16.667,-5,20,-15 v-585 v-1200 v-585 c-2.667,-10,-9.667,-15,-21,-15
c-10,0,-16.667,5,-20,15z M410 15 H367 v585 v1200 v585 h43z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\begin{Vmatrix}</code><br>   <code>a &amp; b \\</code><br>   <code>c &amp; d</code><br><code>\end{Vmatrix}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true">{</mo><mtable rowspacing="0.16em" columnalign="center center" columnspacing="1em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>a</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>b</mi></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>c</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>d</mi></mstyle></mtd></mtr></mtable><mo fence="true">}</mo></mrow><annotation encoding="application/x-tex">\begin{Bmatrix} a &amp; b \\ c &amp; d \end{Bmatrix}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.4em;vertical-align:-0.95em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size3">{</span></span><span class="mord"><span class="mtable"><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:0.5em;"></span><span class="arraycolsep" style="width:0.5em;"></span><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">b</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">d</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size3">}</span></span></span></span></span></span></td>
<td style="text-align:left"><code>\begin{Bmatrix}</code><br>   <code>a &amp; b \\</code><br>   <code>c &amp; d</code><br><code>\end{Bmatrix}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mtable rowspacing="0.66em" columnalign="center center center" columnlines="dashed dashed" columnspacing="1em" rowlines="solid dashed"><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>a</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>b</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>c</mi></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>d</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>e</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>f</mi></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>g</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>h</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>i</mi></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\def\arraystretch{1.5}\begin{array}{c:c:c} a &amp; b &amp; c \\ \hline d &amp; e &amp; f \\ \hdashline g &amp; h &amp; i \end{array}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:5.4em;vertical-align:-2.45em;"></span><span class="mord"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:2.95em;"><span style="top:-4.95em;"><span class="pstrut" style="height:4.95em;"></span><span class="mtable"><span class="arraycolsep" style="width:0.5em;"></span><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:2.95em;"><span style="top:-4.95em;"><span class="pstrut" style="height:3.26em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span><span style="top:-3.15em;"><span class="pstrut" style="height:3.26em;"></span><span class="mord"><span class="mord mathnormal">d</span></span></span><span style="top:-1.35em;"><span class="pstrut" style="height:3.26em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">g</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:2.45em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:0.5em;"></span><span class="vertical-separator" style="height:5.4em;border-right-width:0.04em;border-right-style:dashed;margin:0 -0.02em;vertical-align:-2.45em;"></span><span class="arraycolsep" style="width:0.5em;"></span><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:2.95em;"><span style="top:-4.95em;"><span class="pstrut" style="height:3.26em;"></span><span class="mord"><span class="mord mathnormal">b</span></span></span><span style="top:-3.15em;"><span class="pstrut" style="height:3.26em;"></span><span class="mord"><span class="mord mathnormal">e</span></span></span><span style="top:-1.35em;"><span class="pstrut" style="height:3.26em;"></span><span class="mord"><span class="mord mathnormal">h</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:2.45em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:0.5em;"></span><span class="vertical-separator" style="height:5.4em;border-right-width:0.04em;border-right-style:dashed;margin:0 -0.02em;vertical-align:-2.45em;"></span><span class="arraycolsep" style="width:0.5em;"></span><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:2.95em;"><span style="top:-4.95em;"><span class="pstrut" style="height:3.26em;"></span><span class="mord"><span class="mord mathnormal">c</span></span></span><span style="top:-3.15em;"><span class="pstrut" style="height:3.26em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.10764em;">f</span></span></span><span style="top:-1.35em;"><span class="pstrut" style="height:3.26em;"></span><span class="mord"><span class="mord mathnormal">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:2.45em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:0.5em;"></span></span></span><span style="top:-4.3em;"><span class="pstrut" style="height:4.95em;"></span><span class="hdashline" style="border-bottom-width:0.04em;"></span></span><span style="top:-6.1em;"><span class="pstrut" style="height:4.95em;"></span><span class="hline" style="border-bottom-width:0.04em;"></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:2.45em;"><span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\def\arraystretch{1.5}</code><br>   <code>\begin{array}{c:c:c}</code><br>   <code>a &amp; b &amp; c \\ \hline</code><br>   <code>d &amp; e &amp; f \\</code><br>   <code>\hdashline</code><br>   <code>g &amp; h &amp; i</code><br><code>\end{array}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mtable rowspacing="0.25em" columnalign="right left" columnspacing="0em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mi>a</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mo>=</mo><mi>b</mi><mo>+</mo><mi>c</mi></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mi>d</mi><mo>+</mo><mi>e</mi></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mo>=</mo><mi>f</mi></mrow></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{aligned} a&amp;=b+c \\ d+e&amp;=f \end{aligned}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:3em;vertical-align:-1.25em;"></span><span class="mord"><span class="mtable"><span class="col-align-r"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.75em;"><span style="top:-3.91em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">d</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal">e</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.25em;"><span></span></span></span></span></span><span class="col-align-l"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.75em;"><span style="top:-3.91em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord mathnormal">b</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal">c</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord mathnormal" style="margin-right:0.10764em;">f</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.25em;"><span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\begin{aligned}</code><br>   <code>a&amp;=b+c \\</code><br>   <code>d+e&amp;=f</code><br><code>\end{aligned}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mtable rowspacing="0.25em" columnalign="right left right left" columnspacing="0em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mn>10</mn></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mi>x</mi><mo>+</mo></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mn>3</mn></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mi>y</mi><mo>=</mo><mn>2</mn></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mn>3</mn></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mi>x</mi><mo>+</mo></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mn>13</mn></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mi>y</mi><mo>=</mo><mn>4</mn></mrow></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{alignedat}{2}10&amp;x+&amp;3&amp;y=2\\3&amp;x+&amp;13&amp;y=4\end{alignedat}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:3em;vertical-align:-1.25em;"></span><span class="mord"><span class="mtable"><span class="col-align-r"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.75em;"><span style="top:-3.91em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">10</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">3</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.25em;"><span></span></span></span></span></span><span class="col-align-l"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.75em;"><span style="top:-3.91em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"></span><span class="mord mathnormal">x</span><span class="mord">+</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"></span><span class="mord mathnormal">x</span><span class="mord">+</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.25em;"><span></span></span></span></span></span><span class="col-align-r"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.75em;"><span style="top:-3.91em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">3</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">13</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.25em;"><span></span></span></span></span></span><span class="col-align-l"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.75em;"><span style="top:-3.91em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"></span><span class="mord mathnormal" style="margin-right:0.03588em;">y</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord">2</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"></span><span class="mord mathnormal" style="margin-right:0.03588em;">y</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord">4</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.25em;"><span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\begin{alignedat}{2}</code><br>   <code>10&amp;x+ &amp;3&amp;y = 2 \\</code><br>   <code> 3&amp;x+&amp;13&amp;y = 4</code><br><code>\end{alignedat}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mtable rowspacing="0.25em" columnalign="center" columnspacing="0em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mi>a</mi><mo>=</mo><mi>b</mi></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mi>e</mi><mo>=</mo><mi>b</mi><mo>+</mo><mi>c</mi></mrow></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{gathered} a=b \\ e=b+c \end{gathered}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:3em;vertical-align:-1.25em;"></span><span class="mord"><span class="mtable"><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.75em;"><span style="top:-3.91em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord mathnormal">b</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">e</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord mathnormal">b</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.25em;"><span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\begin{gathered}</code><br>   <code>a=b \\ </code><br>   <code>e=b+c</code><br><code>\end{gathered}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>x</mi><mo>=</mo><mrow><mo fence="true">{</mo><mtable rowspacing="0.36em" columnalign="left left" columnspacing="1em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>a</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mrow><mtext>if </mtext><mi>b</mi></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>c</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mrow><mtext>if </mtext><mi>d</mi></mrow></mstyle></mtd></mtr></mtable></mrow></mrow><annotation encoding="application/x-tex">x = \begin{cases} a &amp;\text{if } b \\ c &amp;\text{if } d \end{cases}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">x</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:3em;vertical-align:-1.25em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size4">{</span></span><span class="mord"><span class="mtable"><span class="col-align-l"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.69em;"><span style="top:-3.69em;"><span class="pstrut" style="height:3.008em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span><span style="top:-2.25em;"><span class="pstrut" style="height:3.008em;"></span><span class="mord"><span class="mord mathnormal">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.19em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:1em;"></span><span class="col-align-l"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.69em;"><span style="top:-3.69em;"><span class="pstrut" style="height:3.008em;"></span><span class="mord"><span class="mord text"><span class="mord">if </span></span><span class="mord mathnormal">b</span></span></span><span style="top:-2.25em;"><span class="pstrut" style="height:3.008em;"></span><span class="mord"><span class="mord text"><span class="mord">if </span></span><span class="mord mathnormal">d</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.19em;"><span></span></span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span></td>
<td style="text-align:left"><code>x = \begin{cases}</code><br>   <code>a &amp;\text{if } b  \\</code><br>   <code>c &amp;\text{if } d</code><br><code>\end{cases}</code></td>
</tr>
</tbody>
</table>
<p>KaTeX also supports <code>darray</code> and <code>dcases</code>.</p>
<p>Acceptable line separators include: <code>\\</code>, <code>\cr</code>, <code>\\[distance]</code>, and <code>\cr[distance]</code>. <em>Distance</em> can be written with any of the <a href="#units">KaTeX units</a>.</p>
<p>The <code>{array}</code> environment supports <code>|</code> and <code>:</code> vertical separators.</p>
<p>The <code>{array}</code> environment does not yet support <code>\cline</code> or <code>\multicolumn</code>.</p>
<h2 id="_4-html" tabindex="-1">4: HTML <a class="header-anchor" href="#_4-html" aria-label="Permalink to &quot;4: HTML&quot;">&ZeroWidthSpace;</a></h2>
<table>
<thead>
<tr>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathcolor="#cc0000"><mtext>\href</mtext></mstyle></mrow><annotation encoding="application/x-tex">\href{https://katex.org/}{\KaTeX}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\href</span></span></span></span></span></td>
<td style="text-align:left"><code>\href{https://katex.org/}{\KaTeX}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathcolor="#cc0000"><mtext>\url</mtext></mstyle></mrow><annotation encoding="application/x-tex">\url{https://katex.org/}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\url</span></span></span></span></span></td>
<td style="text-align:left"><code>\url{https://katex.org/}</code></td>
</tr>
</tbody>
</table>
<h2 id="_5-letters-and-unicode" tabindex="-1">5: Letters and Unicode <a class="header-anchor" href="#_5-letters-and-unicode" aria-label="Permalink to &quot;5: Letters and Unicode&quot;">&ZeroWidthSpace;</a></h2>
<p><strong>Greek Letters</strong></p>
<p>Direct Input: <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">A</mi><mi mathvariant="normal">B</mi><mi mathvariant="normal">Γ</mi><mi mathvariant="normal">Δ</mi><mi mathvariant="normal">E</mi><mi mathvariant="normal">Z</mi><mi mathvariant="normal">H</mi><mi mathvariant="normal">Θ</mi><mi mathvariant="normal">I</mi><mspace></mspace><mi mathvariant="normal">K</mi><mi mathvariant="normal">Λ</mi><mi mathvariant="normal">M</mi><mi mathvariant="normal">N</mi><mi mathvariant="normal">Ξ</mi><mi mathvariant="normal">O</mi><mi mathvariant="normal">Π</mi><mi mathvariant="normal">P</mi><mi mathvariant="normal">Σ</mi><mi mathvariant="normal">T</mi><mi mathvariant="normal">Υ</mi><mi mathvariant="normal">Φ</mi><mi mathvariant="normal">X</mi><mi mathvariant="normal">Ψ</mi><mi mathvariant="normal">Ω</mi></mrow><annotation encoding="application/x-tex">Α Β Γ Δ Ε Ζ Η Θ Ι \allowbreak Κ Λ Μ Ν Ξ Ο Π Ρ Σ Τ Υ Φ Χ Ψ Ω</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">ABΓΔEZHΘI</span><span class="mspace allowbreak"></span></span><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">KΛMNΞOΠPΣTΥΦXΨΩ</span></span></span></span>
<span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mspace></mspace><mi>α</mi><mi>β</mi><mi>γ</mi><mi>δ</mi><mi>ϵ</mi><mi>ζ</mi><mi>η</mi><mi>θ</mi><mi>ι</mi><mi>κ</mi><mi>λ</mi><mi>μ</mi><mi>ν</mi><mi>ξ</mi><mi>o</mi><mi>π</mi><mspace></mspace><mi>ρ</mi><mi>σ</mi><mi>τ</mi><mi>υ</mi><mi>ϕ</mi><mi>χ</mi><mi>ψ</mi><mi>ω</mi><mi>ε</mi><mi>ϑ</mi><mi>ϖ</mi><mi>ϱ</mi><mi>ς</mi><mi>φ</mi></mrow><annotation encoding="application/x-tex">\allowbreak α β γ δ ϵ ζ η θ ι κ λ μ ν ξ o π \allowbreak ρ σ τ υ ϕ χ ψ ω ε ϑ ϖ ϱ ς φ</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0em;"></span><span class="mspace allowbreak"></span></span><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.0037em;">α</span><span class="mord mathnormal" style="margin-right:0.05278em;">β</span><span class="mord mathnormal" style="margin-right:0.05556em;">γ</span><span class="mord mathnormal">δϵ</span><span class="mord mathnormal" style="margin-right:0.07378em;">ζ</span><span class="mord mathnormal" style="margin-right:0.03588em;">η</span><span class="mord mathnormal" style="margin-right:0.02778em;">θ</span><span class="mord mathnormal">ι</span><span class="mord mathnormal">κλ</span><span class="mord mathnormal" style="margin-right:0.06366em;">μν</span><span class="mord mathnormal" style="margin-right:0.04601em;">ξ</span><span class="mord mathnormal">o</span><span class="mord mathnormal" style="margin-right:0.03588em;">π</span><span class="mspace allowbreak"></span></span><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">ρ</span><span class="mord mathnormal" style="margin-right:0.03588em;">σ</span><span class="mord mathnormal" style="margin-right:0.03588em;">τυ</span><span class="mord mathnormal">ϕ</span><span class="mord mathnormal">χ</span><span class="mord mathnormal" style="margin-right:0.03588em;">ψ</span><span class="mord mathnormal" style="margin-right:0.03588em;">ω</span><span class="mord mathnormal">εϑ</span><span class="mord mathnormal" style="margin-right:0.02778em;">ϖ</span><span class="mord mathnormal">ϱςφ</span></span></span></span></p>
<table>
<thead>
<tr>
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">A</mi></mrow><annotation encoding="application/x-tex">\Alpha</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathrm">A</span></span></span></span> <code>\Alpha</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">B</mi></mrow><annotation encoding="application/x-tex">\Beta</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathrm">B</span></span></span></span> <code>\Beta</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Γ</mi></mrow><annotation encoding="application/x-tex">\Gamma</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">Γ</span></span></span></span> <code>\Gamma</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Δ</mi></mrow><annotation encoding="application/x-tex">\Delta</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">Δ</span></span></span></span> <code>\Delta</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">E</mi></mrow><annotation encoding="application/x-tex">\Epsilon</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathrm">E</span></span></span></span> <code>\Epsilon</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Z</mi></mrow><annotation encoding="application/x-tex">\Zeta</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathrm">Z</span></span></span></span> <code>\Zeta</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">H</mi></mrow><annotation encoding="application/x-tex">\Eta</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathrm">H</span></span></span></span> <code>\Eta</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Θ</mi></mrow><annotation encoding="application/x-tex">\Theta</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">Θ</span></span></span></span> <code>\Theta</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">I</mi></mrow><annotation encoding="application/x-tex">\Iota</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathrm">I</span></span></span></span> <code>\Iota</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">K</mi></mrow><annotation encoding="application/x-tex">\Kappa</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathrm">K</span></span></span></span> <code>\Kappa</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Λ</mi></mrow><annotation encoding="application/x-tex">\Lambda</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">Λ</span></span></span></span> <code>\Lambda</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">M</mi></mrow><annotation encoding="application/x-tex">\Mu</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathrm">M</span></span></span></span> <code>\Mu</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">N</mi></mrow><annotation encoding="application/x-tex">\Nu</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathrm">N</span></span></span></span> <code>\Nu</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Ξ</mi></mrow><annotation encoding="application/x-tex">\Xi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">Ξ</span></span></span></span> <code>\Xi</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">O</mi></mrow><annotation encoding="application/x-tex">\Omicron</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathrm">O</span></span></span></span> <code>\Omicron</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Π</mi></mrow><annotation encoding="application/x-tex">\Pi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">Π</span></span></span></span> <code>\Pi</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Σ</mi></mrow><annotation encoding="application/x-tex">\Sigma</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">Σ</span></span></span></span> <code>\Sigma</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">T</mi></mrow><annotation encoding="application/x-tex">\Tau</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathrm">T</span></span></span></span> <code>\Tau</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Υ</mi></mrow><annotation encoding="application/x-tex">\Upsilon</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">Υ</span></span></span></span> <code>\Upsilon</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Φ</mi></mrow><annotation encoding="application/x-tex">\Phi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">Φ</span></span></span></span> <code>\Phi</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">X</mi></mrow><annotation encoding="application/x-tex">\Chi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathrm">X</span></span></span></span> <code>\Chi</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Ψ</mi></mrow><annotation encoding="application/x-tex">\Psi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">Ψ</span></span></span></span> <code>\Psi</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Ω</mi></mrow><annotation encoding="application/x-tex">\Omega</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">Ω</span></span></span></span> <code>\Omega</code></td>
<td></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>Γ</mi></mrow><annotation encoding="application/x-tex">\varGamma</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathit">Γ</span></span></span></span> <code>\varGamma</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>Δ</mi></mrow><annotation encoding="application/x-tex">\varDelta</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathit">Δ</span></span></span></span> <code>\varDelta</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>Θ</mi></mrow><annotation encoding="application/x-tex">\varTheta</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathit">Θ</span></span></span></span> <code>\varTheta</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>Λ</mi></mrow><annotation encoding="application/x-tex">\varLambda</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathit">Λ</span></span></span></span> <code>\varLambda</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>Ξ</mi></mrow><annotation encoding="application/x-tex">\varXi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathit">Ξ</span></span></span></span> <code>\varXi</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>Π</mi></mrow><annotation encoding="application/x-tex">\varPi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathit">Π</span></span></span></span> <code>\varPi</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>Σ</mi></mrow><annotation encoding="application/x-tex">\varSigma</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathit">Σ</span></span></span></span> <code>\varSigma</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>Υ</mi></mrow><annotation encoding="application/x-tex">\varUpsilon</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathit">Υ</span></span></span></span> <code>\varUpsilon</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>Φ</mi></mrow><annotation encoding="application/x-tex">\varPhi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathit">Φ</span></span></span></span> <code>\varPhi</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>Ψ</mi></mrow><annotation encoding="application/x-tex">\varPsi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathit">Ψ</span></span></span></span> <code>\varPsi</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>Ω</mi></mrow><annotation encoding="application/x-tex">\varOmega</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathit">Ω</span></span></span></span> <code>\varOmega</code></td>
<td></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>α</mi></mrow><annotation encoding="application/x-tex">\alpha</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal" style="margin-right:0.0037em;">α</span></span></span></span> <code>\alpha</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>β</mi></mrow><annotation encoding="application/x-tex">\beta</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.05278em;">β</span></span></span></span> <code>\beta</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>γ</mi></mrow><annotation encoding="application/x-tex">\gamma</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.05556em;">γ</span></span></span></span> <code>\gamma</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>δ</mi></mrow><annotation encoding="application/x-tex">\delta</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal" style="margin-right:0.03785em;">δ</span></span></span></span> <code>\delta</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ϵ</mi></mrow><annotation encoding="application/x-tex">\epsilon</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">ϵ</span></span></span></span> <code>\epsilon</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ζ</mi></mrow><annotation encoding="application/x-tex">\zeta</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.07378em;">ζ</span></span></span></span> <code>\zeta</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>η</mi></mrow><annotation encoding="application/x-tex">\eta</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">η</span></span></span></span> <code>\eta</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>θ</mi></mrow><annotation encoding="application/x-tex">\theta</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal" style="margin-right:0.02778em;">θ</span></span></span></span> <code>\theta</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ι</mi></mrow><annotation encoding="application/x-tex">\iota</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">ι</span></span></span></span> <code>\iota</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>κ</mi></mrow><annotation encoding="application/x-tex">\kappa</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">κ</span></span></span></span> <code>\kappa</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>λ</mi></mrow><annotation encoding="application/x-tex">\lambda</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">λ</span></span></span></span> <code>\lambda</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>μ</mi></mrow><annotation encoding="application/x-tex">\mu</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">μ</span></span></span></span> <code>\mu</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ν</mi></mrow><annotation encoding="application/x-tex">\nu</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal" style="margin-right:0.06366em;">ν</span></span></span></span> <code>\nu</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ξ</mi></mrow><annotation encoding="application/x-tex">\xi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.04601em;">ξ</span></span></span></span> <code>\xi</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ο</mi></mrow><annotation encoding="application/x-tex">\omicron</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">ο</span></span></span></span> <code>\omicron</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>π</mi></mrow><annotation encoding="application/x-tex">\pi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">π</span></span></span></span> <code>\pi</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ρ</mi></mrow><annotation encoding="application/x-tex">\rho</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">ρ</span></span></span></span> <code>\rho</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>σ</mi></mrow><annotation encoding="application/x-tex">\sigma</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">σ</span></span></span></span> <code>\sigma</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>τ</mi></mrow><annotation encoding="application/x-tex">\tau</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal" style="margin-right:0.1132em;">τ</span></span></span></span> <code>\tau</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>υ</mi></mrow><annotation encoding="application/x-tex">\upsilon</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">υ</span></span></span></span> <code>\upsilon</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ϕ</mi></mrow><annotation encoding="application/x-tex">\phi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">ϕ</span></span></span></span> <code>\phi</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>χ</mi></mrow><annotation encoding="application/x-tex">\chi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">χ</span></span></span></span> <code>\chi</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ψ</mi></mrow><annotation encoding="application/x-tex">\psi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">ψ</span></span></span></span> <code>\psi</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ω</mi></mrow><annotation encoding="application/x-tex">\omega</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">ω</span></span></span></span> <code>\omega</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ε</mi></mrow><annotation encoding="application/x-tex">\varepsilon</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">ε</span></span></span></span> <code>\varepsilon</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">ϰ</mi></mrow><annotation encoding="application/x-tex">\varkappa</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord amsrm" style="margin-right:0.04028em;">ϰ</span></span></span></span> <code>\varkappa</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ϑ</mi></mrow><annotation encoding="application/x-tex">\vartheta</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">ϑ</span></span></span></span> <code>\vartheta</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ϑ</mi></mrow><annotation encoding="application/x-tex">\thetasym</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">ϑ</span></span></span></span> <code>\thetasym</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ϖ</mi></mrow><annotation encoding="application/x-tex">\varpi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal" style="margin-right:0.02778em;">ϖ</span></span></span></span> <code>\varpi</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ϱ</mi></mrow><annotation encoding="application/x-tex">\varrho</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">ϱ</span></span></span></span> <code>\varrho</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ς</mi></mrow><annotation encoding="application/x-tex">\varsigma</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5278em;vertical-align:-0.0972em;"></span><span class="mord mathnormal" style="margin-right:0.07986em;">ς</span></span></span></span> <code>\varsigma</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>φ</mi></mrow><annotation encoding="application/x-tex">\varphi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">φ</span></span></span></span> <code>\varphi</code></td>
</tr>
</tbody>
</table>
<p>| <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">ϝ</mi></mrow><annotation encoding="application/x-tex">\digamma</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6633em;vertical-align:-0.0817em;"></span><span class="mord amsrm">ϝ</span></span></span></span> <code>\digamma</code></p>
<p><strong>Other Letters</strong></p>
<table>
<thead>
<tr>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">ı</mi></mrow><annotation encoding="application/x-tex">\imath</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal"></span></span></span></span> <code>\imath</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∇</mi></mrow><annotation encoding="application/x-tex">\nabla</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">∇</span></span></span></span> <code>\nabla</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">ℑ</mi></mrow><annotation encoding="application/x-tex">\Im</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">ℑ</span></span></span></span> <code>\Im</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="double-struck">R</mi></mrow><annotation encoding="application/x-tex">\Reals</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord mathbb">R</span></span></span></span> <code>\Reals</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>Œ</mtext></mrow><annotation encoding="application/x-tex">\text{\OE}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord text"><span class="mord latin_fallback">Œ</span></span></span></span></span> <code>\text{\OE}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">ȷ</mi></mrow><annotation encoding="application/x-tex">\jmath</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal"></span></span></span></span> <code>\jmath</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∂</mi></mrow><annotation encoding="application/x-tex">\partial</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord" style="margin-right:0.05556em;">∂</span></span></span></span> <code>\partial</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">ℑ</mi></mrow><annotation encoding="application/x-tex">\image</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">ℑ</span></span></span></span> <code>\image</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">℘</mi></mrow><annotation encoding="application/x-tex">\wp</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord">℘</span></span></span></span> <code>\wp</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>ø</mtext></mrow><annotation encoding="application/x-tex">\text{\o}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.0972em;"></span><span class="mord text"><span class="mord">ø</span></span></span></span></span> <code>\text{\o}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">ℵ</mi></mrow><annotation encoding="application/x-tex">\aleph</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">ℵ</span></span></span></span> <code>\aleph</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">⅁</mi></mrow><annotation encoding="application/x-tex">\Game</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord amsrm">⅁</span></span></span></span> <code>\Game</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="double-struck">k</mi></mrow><annotation encoding="application/x-tex">\Bbbk</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord mathbb">k</span></span></span></span> <code>\Bbbk</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">℘</mi></mrow><annotation encoding="application/x-tex">\weierp</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord">℘</span></span></span></span> <code>\weierp</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>Ø</mtext></mrow><annotation encoding="application/x-tex">\text{\O}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7806em;vertical-align:-0.0486em;"></span><span class="mord text"><span class="mord">Ø</span></span></span></span></span> <code>\text{\O}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">ℵ</mi></mrow><annotation encoding="application/x-tex">\alef</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">ℵ</span></span></span></span> <code>\alef</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Ⅎ</mi></mrow><annotation encoding="application/x-tex">\Finv</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord amsrm">Ⅎ</span></span></span></span> <code>\Finv</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="double-struck">N</mi></mrow><annotation encoding="application/x-tex">\N</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord mathbb">N</span></span></span></span> <code>\N</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="double-struck">Z</mi></mrow><annotation encoding="application/x-tex">\Z</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord mathbb">Z</span></span></span></span> <code>\Z</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>ß</mtext></mrow><annotation encoding="application/x-tex">\text{\ss}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord">ß</span></span></span></span></span> <code>\text{\ss}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">ℵ</mi></mrow><annotation encoding="application/x-tex">\alefsym</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">ℵ</span></span></span></span> <code>\alefsym</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="double-struck">C</mi></mrow><annotation encoding="application/x-tex">\cnums</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord mathbb">C</span></span></span></span> <code>\cnums</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="double-struck">N</mi></mrow><annotation encoding="application/x-tex">\natnums</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord mathbb">N</span></span></span></span> <code>\natnums</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mtext>a</mtext><mo>˚</mo></mover></mrow><annotation encoding="application/x-tex">\text{\aa}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6944em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord">a</span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.375em;"><span class="mord">˚</span></span></span></span></span></span></span></span></span></span></span> <code>\text{\aa}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>ı</mtext></mrow><annotation encoding="application/x-tex">\text{\i}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord text"><span class="mord latin_fallback">ı</span></span></span></span></span> <code>\text{\i}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">ℶ</mi></mrow><annotation encoding="application/x-tex">\beth</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord amsrm">ℶ</span></span></span></span> <code>\beth</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="double-struck">C</mi></mrow><annotation encoding="application/x-tex">\Complex</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord mathbb">C</span></span></span></span> <code>\Complex</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="double-struck">R</mi></mrow><annotation encoding="application/x-tex">\R</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord mathbb">R</span></span></span></span> <code>\R</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mtext>A</mtext><mo>˚</mo></mover></mrow><annotation encoding="application/x-tex">\text{\AA}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9468em;"></span><span class="mord text"><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.9468em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord">A</span></span><span style="top:-3.2523em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.375em;"><span class="mord">˚</span></span></span></span></span></span></span></span></span></span></span> <code>\text{\AA}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>ȷ</mtext></mrow><annotation encoding="application/x-tex">\text{\j}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord text"><span class="mord latin_fallback">ȷ</span></span></span></span></span> <code>\text{\j}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">ℷ</mi></mrow><annotation encoding="application/x-tex">\gimel</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord amsrm">ℷ</span></span></span></span> <code>\gimel</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">ℓ</mi></mrow><annotation encoding="application/x-tex">\ell</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">ℓ</span></span></span></span> <code>\ell</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">ℜ</mi></mrow><annotation encoding="application/x-tex">\Re</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">ℜ</span></span></span></span> <code>\Re</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>æ</mtext></mrow><annotation encoding="application/x-tex">\text{\ae}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord text"><span class="mord">æ</span></span></span></span></span> <code>\text{\ae}</code></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">ℸ</mi></mrow><annotation encoding="application/x-tex">\daleth</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord amsrm">ℸ</span></span></span></span> <code>\daleth</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">ℏ</mi></mrow><annotation encoding="application/x-tex">\hbar</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord">ℏ</span></span></span></span> <code>\hbar</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">ℜ</mi></mrow><annotation encoding="application/x-tex">\real</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">ℜ</span></span></span></span> <code>\real</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>Æ</mtext></mrow><annotation encoding="application/x-tex">\text{\AE}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord text"><span class="mord">Æ</span></span></span></span></span> <code>\text{\AE}</code></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">ð</mi></mrow><annotation encoding="application/x-tex">\eth</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord amsrm">ð</span></span></span></span> <code>\eth</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">ℏ</mi></mrow><annotation encoding="application/x-tex">\hslash</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord amsrm">ℏ</span></span></span></span> <code>\hslash</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="double-struck">R</mi></mrow><annotation encoding="application/x-tex">\reals</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord mathbb">R</span></span></span></span> <code>\reals</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>œ</mtext></mrow><annotation encoding="application/x-tex">\text{\oe}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord text"><span class="mord latin_fallback">œ</span></span></span></span></span> <code>\text{\oe}</code></td>
<td style="text-align:left"></td>
</tr>
</tbody>
</table>
<p>Direct Input: <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∂</mi><mi mathvariant="normal">∇</mi><mi mathvariant="normal">ℑ</mi><mi mathvariant="normal">Ⅎ</mi><mi mathvariant="normal">ℵ</mi><mi mathvariant="normal">ℶ</mi><mi mathvariant="normal">ℷ</mi><mi mathvariant="normal">ℸ</mi><mi mathvariant="normal">⅁</mi><mi mathvariant="normal">ℏ</mi><mi mathvariant="normal">ð</mi></mrow><annotation encoding="application/x-tex">∂ ∇ ℑ Ⅎ ℵ ℶ ℷ ℸ ⅁ ℏ ð</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord" style="margin-right:0.05556em;">∂</span><span class="mord">∇ℑ</span><span class="mord amsrm">Ⅎ</span><span class="mord">ℵ</span><span class="mord amsrm">ℶℷℸ⅁</span><span class="mord">ℏ</span><span class="mord amsrm">ð</span></span></span></span>
ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖÙÚÛÜÝÞßàáâãäåçèéêëìíîïðñòóôöùúûüýþÿ</p>
<p><strong>Unicode Mathematical Alphanumeric Symbols</strong></p>
<table>
<thead>
<tr>
<th>Item</th>
<th>Range</th>
<th>Item</th>
<th>Range</th>
</tr>
</thead>
<tbody>
<tr>
<td>Bold</td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>𝐀-𝐙 𝐚-𝐳 𝟎-𝟗</mtext></mrow><annotation encoding="application/x-tex">\text{𝐀-𝐙 𝐚-𝐳 𝟎-𝟗}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6861em;"></span><span class="mord text"><span class="mord textbf">A</span><span class="mord">-</span><span class="mord textbf">Z</span><span class="mord"> </span><span class="mord textbf">a</span><span class="mord">-</span><span class="mord textbf">z</span><span class="mord"> </span><span class="mord textbf">0</span><span class="mord">-</span><span class="mord textbf">9</span></span></span></span></span></td>
<td>Double-struck</td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>𝔸-</mtext><mi mathvariant="normal">Z</mi><mtext> </mtext><mi>𝕜</mi></mrow><annotation encoding="application/x-tex">\text{𝔸-}ℤ\ 𝕜</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord text"><span class="mord textbb">A</span><span class="mord">-</span></span><span class="mord amsrm">Z</span><span class="mspace"> </span><span class="mord mathbb">k</span></span></span></span></td>
</tr>
<tr>
<td>Italic</td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>𝐴-𝑍 𝑎-𝑧</mtext></mrow><annotation encoding="application/x-tex">\text{𝐴-𝑍 𝑎-𝑧}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord text"><span class="mord textit">A</span><span class="mord">-</span><span class="mord textit">Z</span><span class="mord"> </span><span class="mord textit">a</span><span class="mord">-</span><span class="mord textit">z</span></span></span></span></span></td>
<td>Sans serif</td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>𝖠-𝖹 𝖺-𝗓 𝟢-𝟫</mtext></mrow><annotation encoding="application/x-tex">\text{𝖠-𝖹 𝖺-𝗓 𝟢-𝟫}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord textsf">A</span><span class="mord">-</span><span class="mord textsf">Z</span><span class="mord"> </span><span class="mord textsf">a</span><span class="mord">-</span><span class="mord textsf">z</span><span class="mord"> </span><span class="mord textsf">0</span><span class="mord">-</span><span class="mord textsf">9</span></span></span></span></span></td>
</tr>
<tr>
<td>Bold Italic</td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>𝑨-𝒁 𝒂-𝒛</mtext></mrow><annotation encoding="application/x-tex">\text{𝑨-𝒁 𝒂-𝒛}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6861em;"></span><span class="mord text"><span class="mord boldsymbol">A</span><span class="mord">-</span><span class="mord boldsymbol">Z</span><span class="mord"> </span><span class="mord boldsymbol">a</span><span class="mord">-</span><span class="mord boldsymbol">z</span></span></span></span></span></td>
<td>Sans serif bold</td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>𝗔-𝗭 𝗮-𝘇 𝟬-𝟵</mtext></mrow><annotation encoding="application/x-tex">\text{𝗔-𝗭 𝗮-𝘇 𝟬-𝟵}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord textboldsf">A</span><span class="mord">-</span><span class="mord textboldsf">Z</span><span class="mord"> </span><span class="mord textboldsf">a</span><span class="mord">-</span><span class="mord textboldsf">z</span><span class="mord"> </span><span class="mord textboldsf">0</span><span class="mord">-</span><span class="mord textboldsf">9</span></span></span></span></span></td>
</tr>
<tr>
<td>Script</td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>𝒜-𝒵</mtext></mrow><annotation encoding="application/x-tex">\text{𝒜-𝒵}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7em;"></span><span class="mord text"><span class="mord textscr">A</span><span class="mord">-</span><span class="mord textscr">Z</span></span></span></span></span></td>
<td>Sans serif italic</td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>𝘈-𝘡 𝘢-𝘻</mtext></mrow><annotation encoding="application/x-tex">\text{𝘈-𝘡 𝘢-𝘻}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord textitsf">A</span><span class="mord">-</span><span class="mord textitsf">Z</span><span class="mord"> </span><span class="mord textitsf">a</span><span class="mord">-</span><span class="mord textitsf">z</span></span></span></span></span></td>
</tr>
<tr>
<td>Fractur</td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>𝔄-</mtext><mi mathvariant="fraktur">Z</mi><mtext> 𝔞-𝔷</mtext></mrow><annotation encoding="application/x-tex">\text{𝔄-}ℨ\text{ 𝔞-𝔷}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8805em;vertical-align:-0.1891em;"></span><span class="mord text"><span class="mord textfrak">A</span><span class="mord">-</span></span><span class="mord mathfrak">Z</span><span class="mord text"><span class="mord"> </span><span class="mord textfrak">a</span><span class="mord">-</span><span class="mord textfrak">z</span></span></span></span></span></td>
<td>Monospace</td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>𝙰-𝚉 𝚊-𝚣 𝟶-𝟿</mtext></mrow><annotation encoding="application/x-tex">\text{𝙰-𝚉 𝚊-𝚣 𝟶-𝟿}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6111em;"></span><span class="mord text"><span class="mord texttt">A</span><span class="mord">-</span><span class="mord texttt">Z</span><span class="mord"> </span><span class="mord texttt">a</span><span class="mord">-</span><span class="mord texttt">z</span><span class="mord"> </span><span class="mord texttt">0</span><span class="mord">-</span><span class="mord texttt">9</span></span></span></span></span></td>
</tr>
</tbody>
</table>
<p><strong>Unicode</strong></p>
<p>The letters listed above will render in any KaTeX rendering mode.</p>
<p>If the KaTeX rendering mode is set to <code>strict: false</code> or <code>strict:&quot;warn&quot;</code> (default), then KaTeX will accept all Unicode letters. The letters not listed above will be rendered from system fonts, not KaTeX-supplied fonts, so their typography may clash. They may also cause small vertical alignment issues. KaTeX has detailed metrics for glyphs in Latin, Greek, and Cyrillic, but other glyphs are treated as if they are each as tall as the letter M.</p>
<p>For Persian composite characters, a user-supplied <a href="https://github.com/HosseinAgha/persian-katex-plugin" target="_blank" rel="noreferrer">plug-in</a> is under development.</p>
<h2 id="_6-layout" tabindex="-1">6: Layout <a class="header-anchor" href="#_6-layout" aria-label="Permalink to &quot;6: Layout&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="_6-1-annotation" tabindex="-1">6.1: Annotation <a class="header-anchor" href="#_6-1-annotation" aria-label="Permalink to &quot;6.1: Annotation&quot;">&ZeroWidthSpace;</a></h3>
<table>
<thead>
<tr>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><menclose notation="updiagonalstrike"><mn>5</mn></menclose></mrow><annotation encoding="application/x-tex">\cancel{5}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8444em;"><span style="top:-3.0444em;"><span class="pstrut" style="height:3.0444em;"></span><span class="mord"><span class="mord">5</span></span></span><span class="svg-align" style="top:-2.8444em;"><span class="pstrut" style="height:3.0444em;"></span><span style="height:1.0444em;"><svg xmlns="http://www.w3.org/2000/svg" width='100%' height='1.0444em'><line x1='0' y1='100%' x2='100%' y2='0' stroke-width='0.046em'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2em;"><span></span></span></span></span></span></span></span></span> <code>\cancel{5}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mover><mrow><mi>a</mi><mo>+</mo><mi>b</mi><mo>+</mo><mi>c</mi></mrow><mo stretchy="true">⏞</mo></mover><mtext>note</mtext></mover></mrow><annotation encoding="application/x-tex">\overbrace{a+b+c}^{\text{note}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.0563em;vertical-align:-0.0833em;"></span><span class="mord mover"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.973em;"><span style="top:-3.3424em;"><span class="pstrut" style="height:3.3424em;"></span><span class="mord mover"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.3424em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal">b</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal">c</span></span></span><span class="svg-align" style="top:-3.7944em;"><span class="pstrut" style="height:3em;"></span><span class="stretchy" style="height:0.548em;min-width:1.6em;"><span class="brace-left" style="height:0.548em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.548em' viewBox='0 0 400000 548' preserveAspectRatio='xMinYMin slice'><path d='M6 548l-6-6v-35l6-11c56-104 135.3-181.3 238-232 57.3-28.7 117
-45 179-50h399577v120H403c-43.3 7-81 15-113 26-100.7 33-179.7 91-237 174-2.7
 5-6 9-10 13-.7 1-7.3 1-20 1H6z'/></svg></span><span class="brace-center" style="height:0.548em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.548em' viewBox='0 0 400000 548' preserveAspectRatio='xMidYMin slice'><path d='M200428 334
c-100.7-8.3-195.3-44-280-108-55.3-42-101.7-93-139-153l-9-14c-2.7 4-5.7 8.7-9 14
-53.3 86.7-123.7 153-211 199-66.7 36-137.3 56.3-212 62H0V214h199568c178.3-11.7
 311.7-78.3 403-201 6-8 9.7-12 11-12 .7-.7 6.7-1 18-1s17.3.3 18 1c1.3 0 5 4 11
 12 44.7 59.3 101.3 106.3 170 141s145.3 54.3 229 60h199572v120z'/></svg></span><span class="brace-right" style="height:0.548em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.548em' viewBox='0 0 400000 548' preserveAspectRatio='xMaxYMin slice'><path d='M400000 542l
-6 6h-17c-12.7 0-19.3-.3-20-1-4-4-7.3-8.3-10-13-35.3-51.3-80.8-93.8-136.5-127.5
s-117.2-55.8-184.5-66.5c-.7 0-2-.3-4-1-18.7-2.7-76-4.3-172-5H0V214h399571l6 1
c124.7 8 235 61.7 331 161 31.3 33.3 59.7 72.7 85 118l7 13v35z'/></svg></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.0833em;"><span></span></span></span></span></span></span><span style="top:-4.8849em;"><span class="pstrut" style="height:3.3424em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord text mtight"><span class="mord mtight">note</span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.0833em;"><span></span></span></span></span></span></span></span></span> <code>\overbrace{a+b+c}^{\text{note}}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><menclose notation="downdiagonalstrike"><mn>5</mn></menclose></mrow><annotation encoding="application/x-tex">\bcancel{5}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8444em;"><span style="top:-3.0444em;"><span class="pstrut" style="height:3.0444em;"></span><span class="mord"><span class="mord">5</span></span></span><span class="svg-align" style="top:-2.8444em;"><span class="pstrut" style="height:3.0444em;"></span><span style="height:1.0444em;"><svg xmlns="http://www.w3.org/2000/svg" width='100%' height='1.0444em'><line x1='0' y1='0' x2='100%' y2='100%' stroke-width='0.046em'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2em;"><span></span></span></span></span></span></span></span></span> <code>\bcancel{5}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><munder><munder><mrow><mi>a</mi><mo>+</mo><mi>b</mi><mo>+</mo><mi>c</mi></mrow><mo stretchy="true">⏟</mo></munder><mtext>note</mtext></munder></mrow><annotation encoding="application/x-tex">\underbrace{a+b+c}_{\text{note}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.0563em;vertical-align:-1.3619em;"></span><span class="mord munder"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6944em;"><span style="top:-1.6381em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord text mtight"><span class="mord mtight">note</span></span></span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord munder"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6944em;"><span class="svg-align" style="top:-2.2687em;"><span class="pstrut" style="height:3em;"></span><span class="stretchy" style="height:0.548em;min-width:1.6em;"><span class="brace-left" style="height:0.548em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.548em' viewBox='0 0 400000 548' preserveAspectRatio='xMinYMin slice'><path d='M0 6l6-6h17c12.688 0 19.313.3 20 1 4 4 7.313 8.3 10 13
 35.313 51.3 80.813 93.8 136.5 127.5 55.688 33.7 117.188 55.8 184.5 66.5.688
 0 2 .3 4 1 18.688 2.7 76 4.3 172 5h399450v120H429l-6-1c-124.688-8-235-61.7
-331-161C60.687 138.7 32.312 99.3 7 54L0 41V6z'/></svg></span><span class="brace-center" style="height:0.548em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.548em' viewBox='0 0 400000 548' preserveAspectRatio='xMidYMin slice'><path d='M199572 214
c100.7 8.3 195.3 44 280 108 55.3 42 101.7 93 139 153l9 14c2.7-4 5.7-8.7 9-14
 53.3-86.7 123.7-153 211-199 66.7-36 137.3-56.3 212-62h199568v120H200432c-178.3
 11.7-311.7 78.3-403 201-6 8-9.7 12-11 12-.7.7-6.7 1-18 1s-17.3-.3-18-1c-1.3 0
-5-4-11-12-44.7-59.3-101.3-106.3-170-141s-145.3-54.3-229-60H0V214z'/></svg></span><span class="brace-right" style="height:0.548em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.548em' viewBox='0 0 400000 548' preserveAspectRatio='xMaxYMin slice'><path d='M399994 0l6 6v35l-6 11c-56 104-135.3 181.3-238 232-57.3
 28.7-117 45-179 50H-300V214h399897c43.3-7 81-15 113-26 100.7-33 179.7-91 237
-174 2.7-5 6-9 10-13 .7-1 7.3-1 20-1h17z'/></svg></span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal">b</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.7313em;"><span></span></span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.3619em;"><span></span></span></span></span></span></span></span></span> <code>\underbrace{a+b+c}_{\text{note}}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><menclose notation="updiagonalstrike downdiagonalstrike"><mrow><mi>A</mi><mi>B</mi><mi>C</mi></mrow></menclose></mrow><annotation encoding="application/x-tex">\xcancel{ABC}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord cancel-lap"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6833em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord cancel-pad"><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.07153em;">BC</span></span></span><span class="svg-align" style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span style="height:0.6833em;"><svg xmlns="http://www.w3.org/2000/svg" width='100%' height='0.6833em'><line x1='0' y1='0' x2='100%' y2='100%' stroke-width='0.046em'/><line x1='0' y1='100%' x2='100%' y2='0' stroke-width='0.046em'/></svg></span></span></span></span></span></span></span></span></span> <code>\xcancel{ABC}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≠</mo></mrow><annotation encoding="application/x-tex">\not =</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel"><span class="mord vbox"><span class="thinbox"><span class="rlap"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="inner"><span class="mord"><span class="mrel"></span></span></span><span class="fix"></span></span></span></span></span></span><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">=</span></span></span></span> <code>\not =</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><menclose notation="horizontalstrike"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></menclose></mrow><annotation encoding="application/x-tex">\sout{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6944em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">ab</span><span class="mord mathnormal">c</span></span></span><span style="top:-3.2155em;"><span class="pstrut" style="height:3em;"></span><span class="stretchy sout"></span></span></span></span></span></span></span></span></span> <code>\sout{abc}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><menclose notation="box"><mstyle scriptlevel="0" displaystyle="false"><mstyle scriptlevel="0" displaystyle="false"><mstyle scriptlevel="0" displaystyle="true"><mrow><mi>π</mi><mo>=</mo><mfrac><mi>c</mi><mi>d</mi></mfrac></mrow></mstyle></mstyle></mstyle></menclose></mrow><annotation encoding="application/x-tex">\boxed{\pi=\frac c d}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.4736em;vertical-align:-1.026em;"></span><span class="mord"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.4476em;"><span style="top:-4.4736em;"><span class="pstrut" style="height:4.4736em;"></span><span class="boxpad"><span class="mord"><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">π</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1076em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">d</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span></span><span style="top:-3.4476em;"><span class="pstrut" style="height:4.4736em;"></span><span class="stretchy fbox" style="height:2.4736em;border-style:solid;border-width:0.04em;"></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.026em;"><span></span></span></span></span></span></span></span></span> <code>\boxed{\pi=\frac c d}</code></td>
</tr>
</tbody>
</table>
<p><code>\tag{hi} x+y^{2x}</code></p>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mtable width="100%"><mtr><mtd width="50%"></mtd><mtd><mrow><mi>x</mi><mo>+</mo><msup><mi>y</mi><mrow><mn>2</mn><mi>x</mi></mrow></msup></mrow></mtd><mtd width="50%"></mtd><mtd><mtext>(hi)</mtext></mtd></mtr></mtable><annotation encoding="application/x-tex">\tag{hi} x+y^{2x}
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mord mathnormal">x</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1.0585em;vertical-align:-0.1944em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">y</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span><span class="mord mathnormal mtight">x</span></span></span></span></span></span></span></span></span></span><span class="tag"><span class="strut" style="height:1.1141em;vertical-align:-0.25em;"></span><span class="mord text"><span class="mord">(</span><span class="mord"><span class="mord">hi</span></span><span class="mord">)</span></span></span></span></span></span></p>
<p><code>\tag*{hi} x+y^{2x}</code></p>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mtable width="100%"><mtr><mtd width="50%"></mtd><mtd><mrow><mi>x</mi><mo>+</mo><msup><mi>y</mi><mrow><mn>2</mn><mi>x</mi></mrow></msup></mrow></mtd><mtd width="50%"></mtd><mtd><mtext>hi</mtext></mtd></mtr></mtable><annotation encoding="application/x-tex">\tag*{hi} x+y^{2x}
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mord mathnormal">x</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1.0585em;vertical-align:-0.1944em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">y</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span><span class="mord mathnormal mtight">x</span></span></span></span></span></span></span></span></span></span><span class="tag"><span class="strut" style="height:1.0585em;vertical-align:-0.1944em;"></span><span class="mord text"><span class="mord">hi</span></span></span></span></span></span></p>
<h3 id="_6-2-line-breaks" tabindex="-1">6.2: Line Breaks <a class="header-anchor" href="#_6-2-line-breaks" aria-label="Permalink to &quot;6.2: Line Breaks&quot;">&ZeroWidthSpace;</a></h3>
<p>KaTeX 0.10.0+ will insert automatic line breaks in inline math after relations or binary operators such as “=” or “+”. These can be suppressed by <code>\nobreak</code> or by placing math inside a pair of braces, as in <code>{F=ma}</code>. <code>\allowbreak</code> will allow automatic line breaks at locations other than relations or operators.</p>
<p>Hard line breaks are <code>\\</code> and <code>\newline</code>.</p>
<p>In display math, KaTeX does not insert automatic line breaks. It ignores display math hard line breaks when rendering option <code>strict: true</code>.</p>
<h3 id="_6-3-vertical-layout" tabindex="-1">6.3: Vertical Layout <a class="header-anchor" href="#_6-3-vertical-layout" aria-label="Permalink to &quot;6.3: Vertical Layout&quot;">&ZeroWidthSpace;</a></h3>
<table>
<thead>
<tr>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>x</mi><mi>n</mi></msub></mrow><annotation encoding="application/x-tex">x_n</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">n</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> <code>x_n</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mover><mo><mo>=</mo></mo><mo stretchy="false" lspace="0em" rspace="0em">!</mo></mover></mo></mrow><annotation encoding="application/x-tex">\stackrel{!}{=}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.153em;"></span><span class="mrel"><span class="mop op-limits"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:1.153em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span><span class="mop">=</span></span></span><span style="top:-3.5669em;margin-left:0em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mclose mtight">!</span></span></span></span></span></span></span></span></span></span></span></span> <code>\stackrel{!}{=}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mfrac linethickness="0px"><mi>a</mi><mi>b</mi></mfrac></mrow><annotation encoding="application/x-tex">a \atop b</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0904em;vertical-align:-0.345em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.7454em;"><span style="top:-2.355em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">b</span></span></span></span><span style="top:-3.144em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">a</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span> <code>a \atop b</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msup><mi>e</mi><mi>x</mi></msup></mrow><annotation encoding="application/x-tex">e^x</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6644em;"></span><span class="mord"><span class="mord mathnormal">e</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6644em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">x</span></span></span></span></span></span></span></span></span></span></span> <code>e^x</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mover><mo><mo>=</mo></mo><mo stretchy="false" lspace="0em" rspace="0em">!</mo></mover></mo></mrow><annotation encoding="application/x-tex">\overset{!}{=}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.153em;"></span><span class="mrel"><span class="mop op-limits"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:1.153em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span><span class="mop">=</span></span></span><span style="top:-3.5669em;margin-left:0em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mclose mtight">!</span></span></span></span></span></span></span></span></span></span></span></span> <code>\overset{!}{=}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mpadded voffset="0.25em"><mstyle scriptlevel="0" displaystyle="false"><mtext>b</mtext></mstyle></mpadded><mi>c</mi></mrow><annotation encoding="application/x-tex">a\raisebox{0.25em}{b}c</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9444em;"></span><span class="mord mathnormal">a</span><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.9444em;"><span style="top:-3.25em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">b</span></span></span></span></span></span><span class="mord mathnormal">c</span></span></span></span> <code>a\raisebox{0.25em}{b}c</code></td>
</tr>
<tr>
<td style="text-align:left">$_u^o $ <code>_u^o </code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><munder><mo><mo>=</mo></mo><mo stretchy="false" lspace="0em" rspace="0em">!</mo></munder></mo></mrow><annotation encoding="application/x-tex">\underset{!}{=}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.119em;vertical-align:-0.7521em;"></span><span class="mrel"><span class="mop op-limits"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3669em;"><span style="top:-2.3479em;margin-left:0em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mclose mtight">!</span></span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span><span class="mop">=</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.7521em;"><span></span></span></span></span></span></span></span></span></span> <code>\underset{!}{=}</code></td>
<td style="text-align:left"></td>
</tr>
</tbody>
</table>
<p>The second argument of <code>\raisebox</code> can contain math if it is nested within <code>$…$</code> delimiters, as in <code>\raisebox{0.25em}{$\frac a b$}</code></p>
<h3 id="_6-4-overlap-and-spacing" tabindex="-1">6.4: Overlap and Spacing <a class="header-anchor" href="#_6-4-overlap-and-spacing" aria-label="Permalink to &quot;6.4: Overlap and Spacing&quot;">&ZeroWidthSpace;</a></h3>
<table>
<thead>
<tr>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo lspace="0em" rspace="0em">=</mo><mpadded lspace="-1width" width="0px"><mrow><mi mathvariant="normal">/</mi><mtext> </mtext></mrow></mpadded></mrow><annotation encoding="application/x-tex">{=}\mathllap{/\,}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord"><span class="mrel">=</span></span><span class="mord vbox"><span class="thinbox"><span class="llap"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="inner"><span class="mord"><span class="mord">/</span><span class="mspace" style="margin-right:0.1667em;"></span></span></span><span class="fix"></span></span></span></span></span></span></span> <code>{=}\mathllap{/\,}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true">(</mo><msup><mi>x</mi><mpadded height="0px" depth="0px"><mn>2</mn></mpadded></msup><mo fence="true">)</mo></mrow><annotation encoding="application/x-tex">\left(x^{\smash{2}}\right)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.363em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0em;"><span style="top:-2.7em;"><span class="pstrut" style="height:2.7em;"></span><span><span class="mord mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">)</span></span></span></span></span> <code>\left(x^{\smash{2}}\right)</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mpadded width="0px"><mrow><mtext> </mtext><mi mathvariant="normal">/</mi></mrow></mpadded><mo lspace="0em" rspace="0em">=</mo></mrow><annotation encoding="application/x-tex">\mathrlap{\,/}{=}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord vbox"><span class="thinbox"><span class="rlap"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="inner"><span class="mord"><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord">/</span></span></span><span class="fix"></span></span></span></span><span class="mord"><span class="mrel">=</span></span></span></span></span> <code>\mathrlap{\,/}{=}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msqrt><mpadded depth="0px"><mi>y</mi></mpadded></msqrt></mrow><annotation encoding="application/x-tex">\sqrt{\smash[b]{y}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.04em;vertical-align:-0.2397em;"></span><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8003em;"><span class="svg-align" style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord" style="padding-left:0.833em;"><span class="mord"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.4306em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">y</span></span></span></span></span></span></span></span></span></span><span style="top:-2.7603em;"><span class="pstrut" style="height:3em;"></span><span class="hide-tail" style="min-width:0.853em;height:1.08em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='1.08em' viewBox='0 0 400000 1080' preserveAspectRatio='xMinYMin slice'><path d='M95,702
c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14
c0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54
c44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10
s173,378,173,378c0.7,0,35.3,-71,104,-213c68.7,-142,137.5,-285,206.5,-429
c69,-144,104.5,-217.7,106.5,-221
l0 -0
c5.3,-9.3,12,-14,20,-14
H400000v40H845.2724
s-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7
c-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z
M834 80h400000v40h-400000z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2397em;"><span></span></span></span></span></span></span></span></span> <code>\sqrt{\smash[b]{y}} </code></td>
</tr>
</tbody>
</table>
<p><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle scriptlevel="0" displaystyle="true"><munder><mo>∑</mo><mpadded lspace="-0.5width" width="0px"><mrow><mn>1</mn><mo>≤</mo><mi>i</mi><mo>≤</mo><mi>j</mi><mo>≤</mo><mi>n</mi></mrow></mpadded></munder><msub><mi>x</mi><mrow><mi>i</mi><mi>j</mi></mrow></msub></mstyle></mrow><annotation encoding="application/x-tex">\displaystyle\sum_{\mathclap{1\le i\le j\le n}} x_{ij}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.4638em;vertical-align:-1.4138em;"></span><span class="mop op-limits"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.05em;"><span style="top:-1.8723em;margin-left:0em;"><span class="pstrut" style="height:3.05em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord vbox mtight"><span class="thinbox mtight"><span class="clap mtight"><span class="strut" style="height:0.854em;vertical-align:-0.1944em;"></span><span class="inner mtight"><span><span class="mord mtight"><span class="mord mtight">1</span><span class="mrel mtight">≤</span><span class="mord mathnormal mtight">i</span><span class="mrel mtight">≤</span><span class="mord mathnormal mtight" style="margin-right:0.05724em;">j</span><span class="mrel mtight">≤</span><span class="mord mathnormal mtight">n</span></span></span></span><span class="fix"></span></span></span></span></span></span></span><span style="top:-3.05em;"><span class="pstrut" style="height:3.05em;"></span><span><span class="mop op-symbol large-op">∑</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.4138em;"><span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.05724em;">ij</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span></span></span></span> <code>\sum_{\mathclap{1\le i\le j\le n}} x_{ij}</code></p>
<p>KaTeX also supports <code>\llap</code>, <code>\rlap</code>, and <code>\clap</code>, but they will take only text, not math, as arguments.</p>
<p><strong>Spacing</strong></p>
<table>
<thead>
<tr>
<th style="text-align:left">Function</th>
<th style="text-align:left">Produces</th>
<th style="text-align:left">Function</th>
<th style="text-align:left">Produces</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left"><code>\,</code></td>
<td style="text-align:left">³∕₁₈ em space</td>
<td style="text-align:left"><code>\kern{distance}</code></td>
<td style="text-align:left">space, width = <em>distance</em></td>
</tr>
<tr>
<td style="text-align:left"><code>\thinspace</code></td>
<td style="text-align:left">³∕₁₈ em space</td>
<td style="text-align:left"><code>\mkern{distance}</code></td>
<td style="text-align:left">space, width = <em>distance</em></td>
</tr>
<tr>
<td style="text-align:left"><code>\:</code></td>
<td style="text-align:left">⁴∕₁₈ em space</td>
<td style="text-align:left"><code>\mskip{distance}</code></td>
<td style="text-align:left">space, width = <em>distance</em></td>
</tr>
<tr>
<td style="text-align:left"><code>\medspace</code></td>
<td style="text-align:left">⁴∕₁₈ em space</td>
<td style="text-align:left"><code>\hskip{distance}</code></td>
<td style="text-align:left">space, width = <em>distance</em></td>
</tr>
<tr>
<td style="text-align:left"><code>\;</code></td>
<td style="text-align:left">⁵∕₁₈ em space</td>
<td style="text-align:left"><code>\hspace{distance}</code></td>
<td style="text-align:left">space, width = <em>distance</em></td>
</tr>
<tr>
<td style="text-align:left"><code>\thickspace</code></td>
<td style="text-align:left">⁵∕₁₈ em space</td>
<td style="text-align:left"><code>\hspace*{distance}</code></td>
<td style="text-align:left">space, width = <em>distance</em></td>
</tr>
<tr>
<td style="text-align:left"><code>\enspace</code></td>
<td style="text-align:left">½ em space</td>
<td style="text-align:left"><code>\phantom{content}</code></td>
<td style="text-align:left">space the width and height of content</td>
</tr>
<tr>
<td style="text-align:left"><code>\quad</code></td>
<td style="text-align:left">1 em space</td>
<td style="text-align:left"><code>\hphantom{content}</code></td>
<td style="text-align:left">space the width of content</td>
</tr>
<tr>
<td style="text-align:left"><code>\qquad</code></td>
<td style="text-align:left">2 em space</td>
<td style="text-align:left"><code>\vphantom{content}</code></td>
<td style="text-align:left">a strut the height of content</td>
</tr>
<tr>
<td style="text-align:left"><code>~</code></td>
<td style="text-align:left">non-breaking space</td>
<td style="text-align:left"><code>\!</code></td>
<td style="text-align:left">– ³∕₁₈ em space</td>
</tr>
<tr>
<td style="text-align:left"><code>\&lt;space&gt;</code></td>
<td style="text-align:left">space</td>
<td style="text-align:left"><code>\negthinspace</code></td>
<td style="text-align:left">– ³∕₁₈ em space</td>
</tr>
<tr>
<td style="text-align:left"><code>\nobreakspace</code></td>
<td style="text-align:left">non-breaking space</td>
<td style="text-align:left"><code>\negmedspace</code></td>
<td style="text-align:left">– ⁴∕₁₈ em space</td>
</tr>
<tr>
<td style="text-align:left"><code>\space</code></td>
<td style="text-align:left">space</td>
<td style="text-align:left"><code>\negthickspace</code></td>
<td style="text-align:left">– ⁵∕₁₈ em space</td>
</tr>
</tbody>
</table>
<p><strong>Notes:</strong></p>
<p><code>distance</code> will accept any of the <a href="#units">KaTeX units</a>.</p>
<p><code>\kern</code>, <code>\mkern</code>, <code>\mskip</code>, and <code>\hspace</code> accept unbraced distances, as in: <code>\kern1em</code>.</p>
<p><code>\mkern</code> and <code>\mskip</code> will not work in text mode and both will write a console warning for any unit except <code>mu</code>.</p>
<h2 id="_7-logic-and-set-theory" tabindex="-1">7: Logic and Set Theory <a class="header-anchor" href="#_7-logic-and-set-theory" aria-label="Permalink to &quot;7: Logic and Set Theory&quot;">&ZeroWidthSpace;</a></h2>
<table>
<thead>
<tr>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∀</mi></mrow><annotation encoding="application/x-tex">\forall</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">∀</span></span></span></span> <code>\forall</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∁</mi></mrow><annotation encoding="application/x-tex">\complement</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.825em;"></span><span class="mord amsrm">∁</span></span></span></span> <code>\complement</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∴</mo></mrow><annotation encoding="application/x-tex">\therefore</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mrel amsrm">∴</span></span></span></span> <code>\therefore</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∅</mi></mrow><annotation encoding="application/x-tex">\emptyset</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8056em;vertical-align:-0.0556em;"></span><span class="mord">∅</span></span></span></span> <code>\emptyset</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∃</mi></mrow><annotation encoding="application/x-tex">\exists</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">∃</span></span></span></span> <code>\exists</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊂</mo></mrow><annotation encoding="application/x-tex">\subset</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">⊂</span></span></span></span> <code>\subset</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∵</mo></mrow><annotation encoding="application/x-tex">\because</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mrel amsrm">∵</span></span></span></span> <code>\because</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∅</mi></mrow><annotation encoding="application/x-tex">\empty</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8056em;vertical-align:-0.0556em;"></span><span class="mord">∅</span></span></span></span> <code>\empty</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∃</mi></mrow><annotation encoding="application/x-tex">\exist</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">∃</span></span></span></span> <code>\exist</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊃</mo></mrow><annotation encoding="application/x-tex">\supset</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">⊃</span></span></span></span> <code>\supset</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↦</mo></mrow><annotation encoding="application/x-tex">\mapsto</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.522em;vertical-align:-0.011em;"></span><span class="mrel">↦</span></span></span></span> <code>\mapsto</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∅</mi></mrow><annotation encoding="application/x-tex">\varnothing</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6633em;vertical-align:-0.0817em;"></span><span class="mord amsrm">∅</span></span></span></span> <code>\varnothing</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∄</mi></mrow><annotation encoding="application/x-tex">\nexists</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord amsrm">∄</span></span></span></span> <code>\nexists</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∣</mo></mrow><annotation encoding="application/x-tex">\mid</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mrel">∣</span></span></span></span> <code>\mid</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>→</mo></mrow><annotation encoding="application/x-tex">\to</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">→</span></span></span></span> <code>\to</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>  </mtext><mo>⟹</mo><mtext>  </mtext></mrow><annotation encoding="application/x-tex">\implies</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.549em;vertical-align:-0.024em;"></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">⟹</span><span class="mspace" style="margin-right:0.2778em;"></span></span></span></span> <code>\implies</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∈</mo></mrow><annotation encoding="application/x-tex">\in</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">∈</span></span></span></span> <code>\in</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∧</mo></mrow><annotation encoding="application/x-tex">\land</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5556em;"></span><span class="mord">∧</span></span></span></span> <code>\land</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>←</mo></mrow><annotation encoding="application/x-tex">\gets</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">←</span></span></span></span> <code>\gets</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>  </mtext><mo>⟸</mo><mtext>  </mtext></mrow><annotation encoding="application/x-tex">\impliedby</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.549em;vertical-align:-0.024em;"></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">⟸</span><span class="mspace" style="margin-right:0.2778em;"></span></span></span></span> <code>\impliedby</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∈</mo></mrow><annotation encoding="application/x-tex">\isin</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">∈</span></span></span></span> <code>\isin</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∨</mo></mrow><annotation encoding="application/x-tex">\lor</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5556em;"></span><span class="mord">∨</span></span></span></span> <code>\lor</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↔</mo></mrow><annotation encoding="application/x-tex">\leftrightarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">↔</span></span></span></span> <code>\leftrightarrow</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>  </mtext><mo>⟺</mo><mtext>  </mtext></mrow><annotation encoding="application/x-tex">\iff</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.549em;vertical-align:-0.024em;"></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">⟺</span><span class="mspace" style="margin-right:0.2778em;"></span></span></span></span> <code>\iff</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo mathvariant="normal">∉</mo></mrow><annotation encoding="application/x-tex">\notin</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mrel"><span class="mord"><span class="mrel">∈</span></span><span class="mord vbox"><span class="thinbox"><span class="llap"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="inner"><span class="mord"><span class="mord">/</span><span class="mspace" style="margin-right:0.0556em;"></span></span></span><span class="fix"></span></span></span></span></span></span></span></span> <code>\notin</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∋</mo></mrow><annotation encoding="application/x-tex">\ni</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">∋</span></span></span></span> <code>\ni</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo mathvariant="normal">∌</mo></mrow><annotation encoding="application/x-tex">\notni</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel"><span class="mord vbox"><span class="thinbox"><span class="rlap"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="inner"><span class="mord"><span class="mrel"></span></span></span><span class="fix"></span></span></span></span></span></span><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">∋</span></span></span></span> <code>\notni</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">¬</mi></mrow><annotation encoding="application/x-tex">\neg</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord">¬</span></span></span></span> <code>\neg</code> or <code>\lnot</code></td>
</tr>
</tbody>
</table>
<p>Direct Input: <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∀</mi><mo>∴</mo><mi mathvariant="normal">∁</mi><mo>∵</mo><mi mathvariant="normal">∃</mi><mo>∣</mo><mo>∈</mo><mo mathvariant="normal">∉</mo><mo>∋</mo><mo>⊂</mo><mo>⊃</mo><mo>∧</mo><mo>∨</mo><mo>↦</mo><mo>→</mo><mo>←</mo><mo>↔</mo><mi mathvariant="normal">¬</mi></mrow><annotation encoding="application/x-tex">∀ ∴ ∁ ∵ ∃ ∣ ∈ ∉ ∋ ⊂ ⊃ ∧ ∨ ↦ → ← ↔ ¬</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">∀</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel amsrm">∴</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.825em;"></span><span class="mord amsrm">∁</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel amsrm">∵</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">∃</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">∣∈</span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mrel"><span class="mord"><span class="mrel">∈</span></span><span class="mord vbox"><span class="thinbox"><span class="llap"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="inner"><span class="mord"><span class="mord">/</span><span class="mspace" style="margin-right:0.0556em;"></span></span></span><span class="fix"></span></span></span></span></span></span><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">∋⊂⊃</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.5666em;vertical-align:-0.011em;"></span><span class="mord">∧</span><span class="mord">∨</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">↦→←↔</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord">¬</span></span></span></span> ℂ ℍ ℕ ℙ ℚ ℝ</p>
<h2 id="_8-macros" tabindex="-1">8: Macros <a class="header-anchor" href="#_8-macros" aria-label="Permalink to &quot;8: Macros&quot;">&ZeroWidthSpace;</a></h2>
<table>
<thead>
<tr>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msup><mi>x</mi><mn>2</mn></msup><mo>+</mo><msup><mi>x</mi><mn>2</mn></msup></mrow><annotation encoding="application/x-tex">\def\foo{x^2} \foo + \foo</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8974em;vertical-align:-0.0833em;"></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.8141em;"></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\def\foo{x^2} \foo + \foo</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msup><mi>y</mi><mn>2</mn></msup><mo>+</mo><msup><mi>y</mi><mn>2</mn></msup></mrow><annotation encoding="application/x-tex">\gdef\bar#1{#1^2} \bar{y} + \bar{y}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0085em;vertical-align:-0.1944em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">y</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1.0085em;vertical-align:-0.1944em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">y</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\gdef\bar#1{#1^2} \bar{y} + \bar{y}</code></td>
</tr>
<tr>
<td style="text-align:left"></td>
<td style="text-align:left"><code>\global\def\macroname#1#2…{definition}</code></td>
</tr>
<tr>
<td style="text-align:left"></td>
<td style="text-align:left"><code>\newcommand\macroname[numargs]{definition}</code></td>
</tr>
<tr>
<td style="text-align:left"></td>
<td style="text-align:left"><code>\renewcommand\macroname[numargs]{definition}</code></td>
</tr>
<tr>
<td style="text-align:left"></td>
<td style="text-align:left"><code>\providecommand\macroname[numargs]{definition}</code></td>
</tr>
</tbody>
</table>
<p>Macros can also be defined in the KaTeX rendering options.</p>
<p>Macros accept up to nine arguments: #1, #2, etc.</p>
<p><code>\gdef</code> and <code>\global\def</code> macros will persist between math expressions.</p>
<p>Available functions include:</p>
<p><code>\char</code> <code>\mathchoice</code> <code>\TextOrMath</code> <code>\@ifstar</code> <code>\@ifnextchar</code> <code>\@firstoftwo</code> <code>\@secondoftwo</code> <code>\relax</code></p>
<p>@ is a valid character for commands, as if <code>\makeatletter</code> were in effect.</p>
<h2 id="_9-operators" tabindex="-1">9: Operators <a class="header-anchor" href="#_9-operators" aria-label="Permalink to &quot;9: Operators&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="_9-1-big-operators" tabindex="-1">9.1: Big Operators <a class="header-anchor" href="#_9-1-big-operators" aria-label="Permalink to &quot;9.1: Big Operators&quot;">&ZeroWidthSpace;</a></h3>
<table>
<thead>
<tr>
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∑</mo></mrow><annotation encoding="application/x-tex">\sum</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mop op-symbol small-op" style="position:relative;top:0em;">∑</span></span></span></span> <code>\sum</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∏</mo></mrow><annotation encoding="application/x-tex">\prod</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mop op-symbol small-op" style="position:relative;top:0em;">∏</span></span></span></span> <code>\prod</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⨂</mo></mrow><annotation encoding="application/x-tex">\bigotimes</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mop op-symbol small-op" style="position:relative;top:0em;">⨂</span></span></span></span> <code>\bigotimes</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋁</mo></mrow><annotation encoding="application/x-tex">\bigvee</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mop op-symbol small-op" style="position:relative;top:0em;">⋁</span></span></span></span> <code>\bigvee</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∫</mo></mrow><annotation encoding="application/x-tex">\int</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1111em;vertical-align:-0.3061em;"></span><span class="mop op-symbol small-op" style="margin-right:0.19445em;position:relative;top:-0.0006em;">∫</span></span></span></span> <code>\int</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∐</mo></mrow><annotation encoding="application/x-tex">\coprod</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mop op-symbol small-op" style="position:relative;top:0em;">∐</span></span></span></span> <code>\coprod</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⨁</mo></mrow><annotation encoding="application/x-tex">\bigoplus</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mop op-symbol small-op" style="position:relative;top:0em;">⨁</span></span></span></span> <code>\bigoplus</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋀</mo></mrow><annotation encoding="application/x-tex">\bigwedge</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mop op-symbol small-op" style="position:relative;top:0em;">⋀</span></span></span></span> <code>\bigwedge</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∬</mo></mrow><annotation encoding="application/x-tex">\iint</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.111em;vertical-align:-0.306em;"></span><span class="mop op-symbol small-op" style="margin-right:0.19445em;position:relative;top:-0.0005em;">∬</span></span></span></span> <code>\iint</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∫</mo></mrow><annotation encoding="application/x-tex">\intop</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1111em;vertical-align:-0.3061em;"></span><span class="mop op-symbol small-op" style="margin-right:0.19445em;position:relative;top:-0.0006em;">∫</span></span></span></span> <code>\intop</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⨀</mo></mrow><annotation encoding="application/x-tex">\bigodot</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mop op-symbol small-op" style="position:relative;top:0em;">⨀</span></span></span></span> <code>\bigodot</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋂</mo></mrow><annotation encoding="application/x-tex">\bigcap</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mop op-symbol small-op" style="position:relative;top:0em;">⋂</span></span></span></span> <code>\bigcap</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∭</mo></mrow><annotation encoding="application/x-tex">\iiint</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.111em;vertical-align:-0.306em;"></span><span class="mop op-symbol small-op" style="margin-right:0.19445em;position:relative;top:-0.0005em;">∭</span></span></span></span> <code>\iiint</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo largeop="false">∫</mo></mrow><annotation encoding="application/x-tex">\smallint</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1111em;vertical-align:-0.3061em;"></span><span class="mop op-symbol small-op" style="margin-right:0.19445em;position:relative;top:-0.0006em;">∫</span></span></span></span> <code>\smallint</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⨄</mo></mrow><annotation encoding="application/x-tex">\biguplus</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mop op-symbol small-op" style="position:relative;top:0em;">⨄</span></span></span></span> <code>\biguplus</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋃</mo></mrow><annotation encoding="application/x-tex">\bigcup</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mop op-symbol small-op" style="position:relative;top:0em;">⋃</span></span></span></span> <code>\bigcup</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∮</mo></mrow><annotation encoding="application/x-tex">\oint</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1111em;vertical-align:-0.3061em;"></span><span class="mop op-symbol small-op" style="margin-right:0.19445em;position:relative;top:-0.0006em;">∮</span></span></span></span> <code>\oint</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∯</mo></mrow><annotation encoding="application/x-tex">\oiint</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.111em;vertical-align:-0.306em;"></span><span class="mop vlist-t vlist-t2" style="position:relative;top:-0.0005em;"><span class="vlist-r"><span class="vlist" style="height:0.805em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mop op-symbol small-op" style="margin-right:0.19445em;">∬</span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="overlay" style="height:0.499em;width:0.957em;"><svg xmlns="http://www.w3.org/2000/svg" width='0.957em' height='0.499em' style='width:0.957em' viewBox='0 0 957 499' preserveAspectRatio='xMinYMin'><path d='M512.6 71.6c272.6 0 320.3 106.8 320.3 178.2 0 70.8-47.7 177.6
-320.3 177.6S193.1 320.6 193.1 249.8c0-71.4 46.9-178.2 319.5-178.2z
m368.1 178.2c0-86.4-60.9-215.4-368.1-215.4-306.4 0-367.3 129-367.3 215.4 0 85.8
60.9 214.8 367.3 214.8 307.2 0 368.1-129 368.1-214.8z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.306em;"><span></span></span></span></span></span></span></span> <code>\oiint</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∰</mo></mrow><annotation encoding="application/x-tex">\oiiint</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.111em;vertical-align:-0.306em;"></span><span class="mop vlist-t vlist-t2" style="position:relative;top:-0.0005em;"><span class="vlist-r"><span class="vlist" style="height:0.805em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mop op-symbol small-op" style="margin-right:0.19445em;">∭</span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="overlay" style="height:0.499em;width:1.304em;"><svg xmlns="http://www.w3.org/2000/svg" width='1.304em' height='0.499em' style='width:1.304em' viewBox='0 0 1304 499' preserveAspectRatio='xMinYMin'><path d='M681.4 71.6c408.9 0 480.5 106.8 480.5 178.2 0 70.8-71.6 177.6
-480.5 177.6S202.1 320.6 202.1 249.8c0-71.4 70.5-178.2 479.3-178.2z
m525.8 178.2c0-86.4-86.8-215.4-525.7-215.4-437.9 0-524.7 129-524.7 215.4 0
85.8 86.8 214.8 524.7 214.8 438.9 0 525.7-129 525.7-214.8z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.306em;"><span></span></span></span></span></span></span></span> <code>\oiiint</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⨆</mo></mrow><annotation encoding="application/x-tex">\bigsqcup</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mop op-symbol small-op" style="position:relative;top:0em;">⨆</span></span></span></span> <code>\bigsqcup</code></td>
</tr>
</tbody>
</table>
<p>Direct Input: <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∫</mo><mo>∬</mo><mo>∭</mo><mo>∮</mo><mo>∏</mo><mo>∐</mo><mo>∑</mo><mo>⋀</mo><mo>⋁</mo><mo>⋂</mo><mo>⋃</mo><mo>⨀</mo><mo>⨁</mo><mo>⨂</mo><mo>⨄</mo><mo>⨆</mo></mrow><annotation encoding="application/x-tex">∫ ∬ ∭ ∮ ∏ ∐ ∑ ⋀ ⋁ ⋂ ⋃ ⨀ ⨁ ⨂ ⨄ ⨆</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1111em;vertical-align:-0.3061em;"></span><span class="mop op-symbol small-op" style="margin-right:0.19445em;position:relative;top:-0.0006em;">∫</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop op-symbol small-op" style="margin-right:0.19445em;position:relative;top:-0.0005em;">∬∭</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop op-symbol small-op" style="margin-right:0.19445em;position:relative;top:-0.0006em;">∮</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop op-symbol small-op" style="position:relative;top:0em;">∏∐∑⋀⋁⋂⋃⨀⨁⨂⨄⨆</span></span></span></span></p>
<h3 id="_9-2-binary-operators" tabindex="-1">9.2: Binary Operators <a class="header-anchor" href="#_9-2-binary-operators" aria-label="Permalink to &quot;9.2: Binary Operators&quot;">&ZeroWidthSpace;</a></h3>
<table>
<thead>
<tr>
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>+</mo></mrow><annotation encoding="application/x-tex">+</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mord">+</span></span></span></span> <code>+</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋅</mo></mrow><annotation encoding="application/x-tex">\cdot</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4445em;"></span><span class="mord">⋅</span></span></span></span> <code>\cdot</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋗</mo></mrow><annotation encoding="application/x-tex">\gtrdot</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mord amsrm">⋗</span></span></span></span> <code>\gtrdot</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>x</mi><mspace></mspace><mspace width="0.4444em"/><mo stretchy="false">(</mo><mrow><mi mathvariant="normal">m</mi><mi mathvariant="normal">o</mi><mi mathvariant="normal">d</mi></mrow><mspace width="0.3333em"/><mi>a</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">x \pmod a</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">x</span><span class="mspace allowbreak"></span><span class="mspace" style="margin-right:0.4444em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">(</span><span class="mord"><span class="mord"><span class="mord mathrm">mod</span></span></span><span class="mspace" style="margin-right:0.3333em;"></span><span class="mord mathnormal">a</span><span class="mclose">)</span></span></span></span> <code>x \pmod a</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>−</mo></mrow><annotation encoding="application/x-tex">-</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mord">−</span></span></span></span> <code>-</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo separator="true">⋅</mo></mrow><annotation encoding="application/x-tex">\cdotp</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4445em;"></span><span class="mpunct">⋅</span></span></span></span> <code>\cdotp</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊺</mo></mrow><annotation encoding="application/x-tex">\intercal</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord amsrm">⊺</span></span></span></span> <code>\intercal</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>x</mi><mspace></mspace><mspace width="0.4444em"/><mo stretchy="false">(</mo><mi>a</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">x \pod a</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">x</span><span class="mspace allowbreak"></span><span class="mspace" style="margin-right:0.4444em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">(</span><span class="mord mathnormal">a</span><span class="mclose">)</span></span></span></span> <code>x \pod a</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">/</mi></mrow><annotation encoding="application/x-tex">/</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">/</span></span></span></span> <code>/</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋅</mo></mrow><annotation encoding="application/x-tex">\centerdot</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5499em;"></span><span class="mord amsrm">⋅</span></span></span></span> <code>\centerdot</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∧</mo></mrow><annotation encoding="application/x-tex">\land</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5556em;"></span><span class="mord">∧</span></span></span></span> <code>\land</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊳</mo></mrow><annotation encoding="application/x-tex">\rhd</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.585em;vertical-align:-0.0352em;"></span><span class="mord amsrm">⊳</span></span></span></span> <code>\rhd</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∗</mo></mrow><annotation encoding="application/x-tex">*</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4653em;"></span><span class="mord">∗</span></span></span></span> <code>*</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∘</mo></mrow><annotation encoding="application/x-tex">\circ</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4445em;"></span><span class="mord">∘</span></span></span></span> <code>\circ</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋋</mo></mrow><annotation encoding="application/x-tex">\leftthreetimes</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mord amsrm">⋋</span></span></span></span> <code>\leftthreetimes</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋌</mo></mrow><annotation encoding="application/x-tex">\rightthreetimes</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mord amsrm">⋌</span></span></span></span> <code>\rightthreetimes</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⨿</mo></mrow><annotation encoding="application/x-tex">\amalg</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">⨿</span></span></span></span> <code>\amalg</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊛</mo></mrow><annotation encoding="application/x-tex">\circledast</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.664em;vertical-align:-0.082em;"></span><span class="mord amsrm">⊛</span></span></span></span> <code>\circledast</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo separator="true">.</mo></mrow><annotation encoding="application/x-tex">\ldotp</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.1056em;"></span><span class="mpunct">.</span></span></span></span> <code>\ldotp</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋊</mo></mrow><annotation encoding="application/x-tex">\rtimes</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6633em;vertical-align:-0.0817em;"></span><span class="mord amsrm">⋊</span></span></span></span> <code>\rtimes</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>&amp;</mo></mrow><annotation encoding="application/x-tex">\And</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">&amp;</span></span></span></span> <code>\And</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊚</mo></mrow><annotation encoding="application/x-tex">\circledcirc</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.664em;vertical-align:-0.082em;"></span><span class="mord amsrm">⊚</span></span></span></span> <code>\circledcirc</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∨</mo></mrow><annotation encoding="application/x-tex">\lor</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5556em;"></span><span class="mord">∨</span></span></span></span> <code>\lor</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∖</mo></mrow><annotation encoding="application/x-tex">\setminus</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">∖</span></span></span></span> <code>\setminus</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∗</mo></mrow><annotation encoding="application/x-tex">\ast</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4653em;"></span><span class="mord">∗</span></span></span></span> <code>\ast</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊝</mo></mrow><annotation encoding="application/x-tex">\circleddash</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.664em;vertical-align:-0.082em;"></span><span class="mord amsrm">⊝</span></span></span></span> <code>\circleddash</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋖</mo></mrow><annotation encoding="application/x-tex">\lessdot</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mord amsrm">⋖</span></span></span></span> <code>\lessdot</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∖</mo></mrow><annotation encoding="application/x-tex">\smallsetminus</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6633em;vertical-align:-0.0817em;"></span><span class="mord amsrm">∖</span></span></span></span> <code>\smallsetminus</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊼</mo></mrow><annotation encoding="application/x-tex">\barwedge</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8867em;vertical-align:-0.1944em;"></span><span class="mord amsrm">⊼</span></span></span></span> <code>\barwedge</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋓</mo></mrow><annotation encoding="application/x-tex">\Cup</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5499em;"></span><span class="mord amsrm">⋓</span></span></span></span> <code>\Cup</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊲</mo></mrow><annotation encoding="application/x-tex">\lhd</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.585em;vertical-align:-0.0352em;"></span><span class="mord amsrm">⊲</span></span></span></span> <code>\lhd</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊓</mo></mrow><annotation encoding="application/x-tex">\sqcap</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5556em;"></span><span class="mord">⊓</span></span></span></span> <code>\sqcap</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>◯</mo></mrow><annotation encoding="application/x-tex">\bigcirc</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord">◯</span></span></span></span> <code>\bigcirc</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∪</mo></mrow><annotation encoding="application/x-tex">\cup</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5556em;"></span><span class="mord">∪</span></span></span></span> <code>\cup</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋉</mo></mrow><annotation encoding="application/x-tex">\ltimes</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6633em;vertical-align:-0.0817em;"></span><span class="mord amsrm">⋉</span></span></span></span> <code>\ltimes</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊔</mo></mrow><annotation encoding="application/x-tex">\sqcup</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5556em;"></span><span class="mord">⊔</span></span></span></span> <code>\sqcup</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext> </mtext><mo lspace="0.22em" rspace="0.22em"><mrow><mi mathvariant="normal">m</mi><mi mathvariant="normal">o</mi><mi mathvariant="normal">d</mi></mrow></mo><mtext> </mtext></mrow><annotation encoding="application/x-tex">\bmod</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mspace" style="margin-right:0.0556em;"></span><span class="mord"><span class="mord"><span class="mord mathrm">mod</span></span></span><span class="mspace" style="margin-right:0.0556em;"></span></span></span></span> <code>\bmod</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋎</mo></mrow><annotation encoding="application/x-tex">\curlyvee</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5499em;"></span><span class="mord amsrm">⋎</span></span></span></span> <code>\curlyvee</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>x</mi><mspace></mspace><mspace width="0.6667em"/><mrow><mi mathvariant="normal">m</mi><mi mathvariant="normal">o</mi><mi mathvariant="normal">d</mi></mrow><mtext> </mtext><mtext> </mtext><mi>a</mi></mrow><annotation encoding="application/x-tex">x \mod a</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">x</span><span class="mspace allowbreak"></span><span class="mspace" style="margin-right:0.6667em;"></span></span><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord"><span class="mord"><span class="mord mathrm">mod</span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">a</span></span></span></span> <code>x\mod a</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>×</mo></mrow><annotation encoding="application/x-tex">\times</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mord">×</span></span></span></span> <code>\times</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊡</mo></mrow><annotation encoding="application/x-tex">\boxdot</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.675em;"></span><span class="mord amsrm">⊡</span></span></span></span> <code>\boxdot</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋏</mo></mrow><annotation encoding="application/x-tex">\curlywedge</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5499em;"></span><span class="mord amsrm">⋏</span></span></span></span> <code>\curlywedge</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∓</mo></mrow><annotation encoding="application/x-tex">\mp</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mord">∓</span></span></span></span> <code>\mp</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊴</mo></mrow><annotation encoding="application/x-tex">\unlhd</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7733em;vertical-align:-0.1367em;"></span><span class="mord amsrm">⊴</span></span></span></span> <code>\unlhd</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊟</mo></mrow><annotation encoding="application/x-tex">\boxminus</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.675em;"></span><span class="mord amsrm">⊟</span></span></span></span> <code>\boxminus</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>÷</mo></mrow><annotation encoding="application/x-tex">\div</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mord">÷</span></span></span></span> <code>\div</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊙</mo></mrow><annotation encoding="application/x-tex">\odot</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mord">⊙</span></span></span></span> <code>\odot</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊵</mo></mrow><annotation encoding="application/x-tex">\unrhd</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7733em;vertical-align:-0.1367em;"></span><span class="mord amsrm">⊵</span></span></span></span> <code>\unrhd</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊞</mo></mrow><annotation encoding="application/x-tex">\boxplus</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.675em;"></span><span class="mord amsrm">⊞</span></span></span></span> <code>\boxplus</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋇</mo></mrow><annotation encoding="application/x-tex">\divideontimes</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6633em;vertical-align:-0.0817em;"></span><span class="mord amsrm">⋇</span></span></span></span> <code>\divideontimes</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊖</mo></mrow><annotation encoding="application/x-tex">\ominus</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mord">⊖</span></span></span></span> <code>\ominus</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊎</mo></mrow><annotation encoding="application/x-tex">\uplus</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5556em;"></span><span class="mord">⊎</span></span></span></span> <code>\uplus</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊠</mo></mrow><annotation encoding="application/x-tex">\boxtimes</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.675em;"></span><span class="mord amsrm">⊠</span></span></span></span> <code>\boxtimes</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∔</mo></mrow><annotation encoding="application/x-tex">\dotplus</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7742em;vertical-align:-0.082em;"></span><span class="mord amsrm">∔</span></span></span></span> <code>\dotplus</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊕</mo></mrow><annotation encoding="application/x-tex">\oplus</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mord">⊕</span></span></span></span> <code>\oplus</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∨</mo></mrow><annotation encoding="application/x-tex">\vee</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5556em;"></span><span class="mord">∨</span></span></span></span> <code>\vee</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∙</mo></mrow><annotation encoding="application/x-tex">\bullet</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4445em;"></span><span class="mord">∙</span></span></span></span> <code>\bullet</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⩞</mo></mrow><annotation encoding="application/x-tex">\doublebarwedge</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9503em;vertical-align:-0.1944em;"></span><span class="mord amsrm">⩞</span></span></span></span> <code>\doublebarwedge</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊗</mo></mrow><annotation encoding="application/x-tex">\otimes</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mord">⊗</span></span></span></span> <code>\otimes</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊻</mo></mrow><annotation encoding="application/x-tex">\veebar</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8867em;vertical-align:-0.1944em;"></span><span class="mord amsrm">⊻</span></span></span></span> <code>\veebar</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋒</mo></mrow><annotation encoding="application/x-tex">\Cap</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5499em;"></span><span class="mord amsrm">⋒</span></span></span></span> <code>\Cap</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋒</mo></mrow><annotation encoding="application/x-tex">\doublecap</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5499em;"></span><span class="mord amsrm">⋒</span></span></span></span> <code>\doublecap</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊘</mo></mrow><annotation encoding="application/x-tex">\oslash</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mord">⊘</span></span></span></span> <code>\oslash</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∧</mo></mrow><annotation encoding="application/x-tex">\wedge</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5556em;"></span><span class="mord">∧</span></span></span></span> <code>\wedge</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∩</mo></mrow><annotation encoding="application/x-tex">\cap</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5556em;"></span><span class="mord">∩</span></span></span></span> <code>\cap</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋓</mo></mrow><annotation encoding="application/x-tex">\doublecup</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5499em;"></span><span class="mord amsrm">⋓</span></span></span></span> <code>\doublecup</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>±</mo></mrow><annotation encoding="application/x-tex">\pm</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mord">±</span></span></span></span> <code>\pm</code> or <code>\plusmn</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≀</mo></mrow><annotation encoding="application/x-tex">\wr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord">≀</span></span></span></span> <code>\wr</code></td>
</tr>
</tbody>
</table>
<p>Direct Input: <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>+</mo><mo>−</mo><mi mathvariant="normal">/</mi><mo>∗</mo><mo>⋅</mo><mo>±</mo><mo>×</mo><mo>÷</mo><mo>∓</mo><mo>∔</mo><mo>∧</mo><mo>∨</mo><mo>∩</mo><mo>∪</mo><mo>≀</mo><mo>⊎</mo><mo>⊓</mo><mo>⊔</mo><mo>⊕</mo><mo>⊖</mo><mo>⊗</mo><mo>⊘</mo><mo>⊙</mo><mo>⊚</mo><mo>⊛</mo><mo>⊝</mo></mrow><annotation encoding="application/x-tex">+ - / * ⋅ ± × ÷ ∓ ∔ ∧ ∨ ∩ ∪ ≀ ⊎ ⊓ ⊔ ⊕ ⊖ ⊗ ⊘ ⊙ ⊚ ⊛ ⊝</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mord">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">/</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">∗</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mord">⋅</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">±</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mord">×</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">÷</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.7756em;vertical-align:-0.0833em;"></span><span class="mord">∓</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin amsrm">∔</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.5556em;"></span><span class="mord">∧</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">∨</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.5556em;"></span><span class="mord">∩</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">∪</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord">≀</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">⊎</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.5556em;"></span><span class="mord">⊓</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">⊔</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mord">⊕</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">⊖</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mord">⊗</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">⊘</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mord">⊙</span><span class="mord amsrm">⊚⊛⊝</span></span></span></span></p>
<h3 id="_9-3-fractions-and-binomials" tabindex="-1">9.3: Fractions and Binomials <a class="header-anchor" href="#_9-3-fractions-and-binomials" aria-label="Permalink to &quot;9.3: Fractions and Binomials&quot;">&ZeroWidthSpace;</a></h3>
<table>
<thead>
<tr>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mfrac><mi>a</mi><mi>b</mi></mfrac></mrow><annotation encoding="application/x-tex">\frac{a}{b}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0404em;vertical-align:-0.345em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6954em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">b</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">a</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span> <code>\frac{a}{b}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mfrac><mi>a</mi><mi>b</mi></mfrac></mrow><annotation encoding="application/x-tex">\tfrac{a}{b}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0404em;vertical-align:-0.345em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6954em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">b</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">a</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span> <code>\tfrac{a}{b}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true">(</mo><mfrac linethickness="0.2em"><mi>a</mi><mrow><mi>a</mi><mo>+</mo><mn>1</mn></mrow></mfrac><mo fence="true">]</mo></mrow><annotation encoding="application/x-tex">\genfrac ( ] {2pt}{1}a{a+1}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.4108em;vertical-align:-0.5594em;"></span><span class="mord"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size1">(</span></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8514em;"><span style="top:-2.4989em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">a</span><span class="mbin mtight">+</span><span class="mord mtight">1</span></span></span></span><span style="top:-3.15em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.2em;"></span></span><span style="top:-3.55em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">a</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.5594em;"><span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size1">]</span></span></span></span></span></span> <code>\genfrac ( ] {2pt}{1}a{a+1}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mfrac><mi>a</mi><mi>b</mi></mfrac></mrow><annotation encoding="application/x-tex">{a \over b}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0404em;vertical-align:-0.345em;"></span><span class="mord"><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6954em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">b</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">a</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span></span> <code>{a \over b}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle displaystyle="true" scriptlevel="0"><mfrac><mi>a</mi><mi>b</mi></mfrac></mstyle></mrow><annotation encoding="application/x-tex">\dfrac{a}{b}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.7936em;vertical-align:-0.686em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1076em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">b</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span> <code>\dfrac{a}{b}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mfrac linethickness="0.2em"><mi>a</mi><mrow><mi>b</mi><mo>+</mo><mn>1</mn></mrow></mfrac></mrow><annotation encoding="application/x-tex">{a \above{2pt} b+1}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.4458em;vertical-align:-0.5944em;"></span><span class="mord"><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8514em;"><span style="top:-2.4639em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">b</span><span class="mbin mtight">+</span><span class="mord mtight">1</span></span></span></span><span style="top:-3.15em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.2em;"></span></span><span style="top:-3.55em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">a</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.5944em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span></span> <code>{a \above{2pt} b+1}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mi mathvariant="normal">/</mi><mi>b</mi></mrow><annotation encoding="application/x-tex">a/b</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal">a</span><span class="mord">/</span><span class="mord mathnormal">b</span></span></span></span> <code>a/b</code></td>
<td style="text-align:left"></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle displaystyle="true" scriptlevel="0"><mfrac><mi>a</mi><mrow><mn>1</mn><mo>+</mo><mstyle displaystyle="true" scriptlevel="0"><mfrac><mn>1</mn><mi>b</mi></mfrac></mstyle></mrow></mfrac></mstyle></mrow><annotation encoding="application/x-tex">\cfrac{a}{1 + \cfrac{1}{b}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:3.756em;vertical-align:-2.166em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.59em;"><span style="top:-2.11em;"><span class="pstrut" style="height:3.59em;"></span><span class="mord"><span class="mord">1</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.59em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">b</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.74em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span></span></span></span></span><span style="top:-3.82em;"><span class="pstrut" style="height:3.59em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-4.33em;"><span class="pstrut" style="height:3.59em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:2.166em;"><span></span></span></span></span></span><span></span></span></span></span></span> <code>\cfrac{a}{1 + \cfrac{1}{b}}</code></td>
</tr>
</tbody>
</table>
<table>
<thead>
<tr>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true">(</mo><mfrac linethickness="0px"><mi>n</mi><mi>k</mi></mfrac><mo fence="true">)</mo></mrow><annotation encoding="application/x-tex">\binom{n}{k}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2em;vertical-align:-0.35em;"></span><span class="mord"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size1">(</span></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.7454em;"><span style="top:-2.355em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.03148em;">k</span></span></span></span><span style="top:-3.144em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">n</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size1">)</span></span></span></span></span></span> <code>\binom{n}{k}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true">(</mo><mstyle displaystyle="true" scriptlevel="0"><mfrac linethickness="0px"><mi>n</mi><mi>k</mi></mfrac></mstyle><mo fence="true">)</mo></mrow><annotation encoding="application/x-tex">\dbinom{n}{k}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.4em;vertical-align:-0.95em;"></span><span class="mord"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size3">(</span></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1076em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03148em;">k</span></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">n</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size3">)</span></span></span></span></span></span> <code>\dbinom{n}{k}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true">{</mo><mfrac linethickness="0px"><mi>n</mi><mi>k</mi></mfrac><mo fence="true">}</mo></mrow><annotation encoding="application/x-tex">{n\brace k}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2em;vertical-align:-0.35em;"></span><span class="mord"><span class="mord"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size1">{</span></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.7454em;"><span style="top:-2.355em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.03148em;">k</span></span></span></span><span style="top:-3.144em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">n</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size1">}</span></span></span></span></span></span></span> <code>{n\brace k}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true">(</mo><mfrac linethickness="0px"><mi>n</mi><mi>k</mi></mfrac><mo fence="true">)</mo></mrow><annotation encoding="application/x-tex">{n \choose k}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2em;vertical-align:-0.35em;"></span><span class="mord"><span class="mord"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size1">(</span></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.7454em;"><span style="top:-2.355em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.03148em;">k</span></span></span></span><span style="top:-3.144em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">n</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size1">)</span></span></span></span></span></span></span> <code>{n \choose k}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true">(</mo><mfrac linethickness="0px"><mi>n</mi><mi>k</mi></mfrac><mo fence="true">)</mo></mrow><annotation encoding="application/x-tex">\tbinom{n}{k}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2em;vertical-align:-0.35em;"></span><span class="mord"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size1">(</span></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.7454em;"><span style="top:-2.355em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.03148em;">k</span></span></span></span><span style="top:-3.144em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">n</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size1">)</span></span></span></span></span></span> <code>\tbinom{n}{k}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true">[</mo><mfrac linethickness="0px"><mi>n</mi><mi>k</mi></mfrac><mo fence="true">]</mo></mrow><annotation encoding="application/x-tex">{n\brack k}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2em;vertical-align:-0.35em;"></span><span class="mord"><span class="mord"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size1">[</span></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.7454em;"><span style="top:-2.355em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.03148em;">k</span></span></span></span><span style="top:-3.144em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">n</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size1">]</span></span></span></span></span></span></span> <code>{n\brack k}</code></td>
</tr>
</tbody>
</table>
<h3 id="_9-4-math-operators" tabindex="-1">9.4: Math Operators <a class="header-anchor" href="#_9-4-math-operators" aria-label="Permalink to &quot;9.4: Math Operators&quot;">&ZeroWidthSpace;</a></h3>
<table>
<thead>
<tr>
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>arcsin</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\arcsin</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6679em;"></span><span class="mop">arcsin</span></span></span></span> <code>\arcsin</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>cotg</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\cotg</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8095em;vertical-align:-0.1944em;"></span><span class="mop">cot<span style="margin-right:0.01389em;">g</span></span></span></span></span> <code>\cotg</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ln</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\ln</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mop">ln</span></span></span></span> <code>\ln</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>det</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\det</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mop">det</span></span></span></span> <code>\det</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>arccos</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\arccos</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mop">arccos</span></span></span></span> <code>\arccos</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>coth</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\coth</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mop">coth</span></span></span></span> <code>\coth</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>log</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\log</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mop">lo<span style="margin-right:0.01389em;">g</span></span></span></span></span> <code>\log</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>gcd</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\gcd</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mop"><span style="margin-right:0.01389em;">g</span>cd</span></span></span></span> <code>\gcd</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>arctan</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\arctan</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6151em;"></span><span class="mop">arctan</span></span></span></span> <code>\arctan</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>csc</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\csc</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mop">csc</span></span></span></span> <code>\csc</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>sec</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\sec</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mop">sec</span></span></span></span> <code>\sec</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>inf</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\inf</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mop">in<span style="margin-right:0.07778em;">f</span></span></span></span></span> <code>\inf</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>arctg</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\arctg</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8095em;vertical-align:-0.1944em;"></span><span class="mop">arct<span style="margin-right:0.01389em;">g</span></span></span></span></span> <code>\arctg</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ctg</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\ctg</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8095em;vertical-align:-0.1944em;"></span><span class="mop">ct<span style="margin-right:0.01389em;">g</span></span></span></span></span> <code>\ctg</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>sin</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\sin</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6679em;"></span><span class="mop">sin</span></span></span></span> <code>\sin</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>lim</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\lim</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mop">lim</span></span></span></span> <code>\lim</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>arcctg</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\arcctg</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8095em;vertical-align:-0.1944em;"></span><span class="mop">arcct<span style="margin-right:0.01389em;">g</span></span></span></span></span> <code>\arcctg</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>cth</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\cth</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mop">cth</span></span></span></span> <code>\cth</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>sinh</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\sinh</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mop">sinh</span></span></span></span> <code>\sinh</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">lim inf</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\liminf</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mop"><span class="mord mathrm">lim</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathrm" style="margin-right:0.07778em;">inf</span></span></span></span></span> <code>\liminf</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>arg</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\arg</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mop">ar<span style="margin-right:0.01389em;">g</span></span></span></span></span> <code>\arg</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>deg</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\deg</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mop">de<span style="margin-right:0.01389em;">g</span></span></span></span></span> <code>\deg</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>sh</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\sh</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mop">sh</span></span></span></span> <code>\sh</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">lim sup</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\limsup</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mop"><span class="mord mathrm">lim</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathrm">sup</span></span></span></span></span> <code>\limsup</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ch</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\ch</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mop">ch</span></span></span></span> <code>\ch</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>dim</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\dim</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mop">dim</span></span></span></span> <code>\dim</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>tan</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\tan</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6151em;"></span><span class="mop">tan</span></span></span></span> <code>\tan</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>max</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\max</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mop">max</span></span></span></span> <code>\max</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>cos</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\cos</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mop">cos</span></span></span></span> <code>\cos</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>exp</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\exp</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mop">exp</span></span></span></span> <code>\exp</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>tanh</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\tanh</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mop">tanh</span></span></span></span> <code>\tanh</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>min</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\min</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6679em;"></span><span class="mop">min</span></span></span></span> <code>\min</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>cosec</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\cosec</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mop">cosec</span></span></span></span> <code>\cosec</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>hom</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\hom</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mop">hom</span></span></span></span> <code>\hom</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>tg</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\tg</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8095em;vertical-align:-0.1944em;"></span><span class="mop">t<span style="margin-right:0.01389em;">g</span></span></span></span></span> <code>\tg</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>Pr</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\Pr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mop">Pr</span></span></span></span> <code>\Pr</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>cosh</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\cosh</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mop">cosh</span></span></span></span> <code>\cosh</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ker</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\ker</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mop">ker</span></span></span></span> <code>\ker</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>th</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\th</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mop">th</span></span></span></span> <code>\th</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>sup</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\sup</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mop">sup</span></span></span></span> <code>\sup</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>cot</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\cot</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6151em;"></span><span class="mop">cot</span></span></span></span> <code>\cot</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>lg</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\lg</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mop">l<span style="margin-right:0.01389em;">g</span></span></span></span></span> <code>\lg</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">f</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\operatorname{f}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mop"><span class="mord mathrm" style="margin-right:0.07778em;">f</span></span></span></span></span> <code>\operatorname{f}</code></td>
<td></td>
</tr>
</tbody>
</table>
<p>Functions on the right column of this table can take <code>\limits</code>.</p>
<h3 id="_9-5-sqrt" tabindex="-1">9.5: <code>\sqrt</code> <a class="header-anchor" href="#_9-5-sqrt" aria-label="Permalink to &quot;9.5: `\sqrt`&quot;">&ZeroWidthSpace;</a></h3>
<p><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msqrt><mi>x</mi></msqrt></mrow><annotation encoding="application/x-tex">\sqrt{x}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.04em;vertical-align:-0.2397em;"></span><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8003em;"><span class="svg-align" style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord" style="padding-left:0.833em;"><span class="mord mathnormal">x</span></span></span><span style="top:-2.7603em;"><span class="pstrut" style="height:3em;"></span><span class="hide-tail" style="min-width:0.853em;height:1.08em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='1.08em' viewBox='0 0 400000 1080' preserveAspectRatio='xMinYMin slice'><path d='M95,702
c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14
c0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54
c44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10
s173,378,173,378c0.7,0,35.3,-71,104,-213c68.7,-142,137.5,-285,206.5,-429
c69,-144,104.5,-217.7,106.5,-221
l0 -0
c5.3,-9.3,12,-14,20,-14
H400000v40H845.2724
s-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7
c-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z
M834 80h400000v40h-400000z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2397em;"><span></span></span></span></span></span></span></span></span> <code>\sqrt{x}</code></p>
<p><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mroot><mi>x</mi><mn>3</mn></mroot></mrow><annotation encoding="application/x-tex">\sqrt[3]{x}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.04em;vertical-align:-0.2397em;"></span><span class="mord sqrt"><span class="root"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6586em;"><span style="top:-2.8363em;"><span class="pstrut" style="height:2.5em;"></span><span class="sizing reset-size6 size1 mtight"><span class="mord mtight"><span class="mord mtight">3</span></span></span></span></span></span></span></span><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8003em;"><span class="svg-align" style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord" style="padding-left:0.833em;"><span class="mord mathnormal">x</span></span></span><span style="top:-2.7603em;"><span class="pstrut" style="height:3em;"></span><span class="hide-tail" style="min-width:0.853em;height:1.08em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='1.08em' viewBox='0 0 400000 1080' preserveAspectRatio='xMinYMin slice'><path d='M95,702
c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14
c0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54
c44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10
s173,378,173,378c0.7,0,35.3,-71,104,-213c68.7,-142,137.5,-285,206.5,-429
c69,-144,104.5,-217.7,106.5,-221
l0 -0
c5.3,-9.3,12,-14,20,-14
H400000v40H845.2724
s-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7
c-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z
M834 80h400000v40h-400000z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2397em;"><span></span></span></span></span></span></span></span></span> <code>\sqrt[3]{x}</code></p>
<h2 id="_10-relations" tabindex="-1">10: Relations <a class="header-anchor" href="#_10-relations" aria-label="Permalink to &quot;10: Relations&quot;">&ZeroWidthSpace;</a></h2>
<p><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mover><mo><mo>=</mo></mo><mo stretchy="false" lspace="0em" rspace="0em">!</mo></mover></mo></mrow><annotation encoding="application/x-tex">\stackrel{!}{=}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.153em;"></span><span class="mrel"><span class="mop op-limits"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:1.153em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span><span class="mop">=</span></span></span><span style="top:-3.5669em;margin-left:0em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mclose mtight">!</span></span></span></span></span></span></span></span></span></span></span></span> <code>\stackrel{!}{=}</code></p>
<table>
<thead>
<tr>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>=</mo></mrow><annotation encoding="application/x-tex">=</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">=</span></span></span></span> <code>=</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≖</mo></mrow><annotation encoding="application/x-tex">\eqcirc</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mrel amsrm">≖</span></span></span></span> <code>\eqcirc</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋚</mo></mrow><annotation encoding="application/x-tex">\lesseqgtr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2714em;vertical-align:-0.3857em;"></span><span class="mrel amsrm">⋚</span></span></span></span> <code>\lesseqgtr</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊐</mo></mrow><annotation encoding="application/x-tex">\sqsupset</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.585em;vertical-align:-0.0352em;"></span><span class="mrel amsrm">⊐</span></span></span></span> <code>\sqsupset</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>&lt;</mo></mrow><annotation encoding="application/x-tex">&lt;</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">&lt;</span></span></span></span> <code>&lt;</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mi mathvariant="normal">∹</mi></mo></mrow><annotation encoding="application/x-tex">\eqcolon</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mrel"><span class="mrel"><span class="mord">−</span></span><span class="mrel"><span class="mspace" style="margin-right:-0.0667em;"></span></span><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span></span></span></span></span> <code>\eqcolon</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⪋</mo></mrow><annotation encoding="application/x-tex">\lesseqqgtr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.4651em;vertical-align:-0.4826em;"></span><span class="mrel amsrm">⪋</span></span></span></span> <code>\lesseqqgtr</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊒</mo></mrow><annotation encoding="application/x-tex">\sqsupseteq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mrel">⊒</span></span></span></span> <code>\sqsupseteq</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>&gt;</mo></mrow><annotation encoding="application/x-tex">&gt;</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">&gt;</span></span></span></span> <code>&gt;</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mi mathvariant="normal">−</mi><mi mathvariant="normal">∷</mi></mo></mrow><annotation encoding="application/x-tex">\Eqcolon</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mrel"><span class="mrel"><span class="mord">−</span></span><span class="mrel"><span class="mspace" style="margin-right:-0.0667em;"></span></span><span class="mrel"><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span><span class="mrel"><span class="mspace" style="margin-right:-0.05em;"></span></span><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span></span></span></span></span></span> <code>\Eqcolon</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≶</mo></mrow><annotation encoding="application/x-tex">\lessgtr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8558em;vertical-align:-0.1808em;"></span><span class="mrel amsrm">≶</span></span></span></span> <code>\lessgtr</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋐</mo></mrow><annotation encoding="application/x-tex">\Subset</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.585em;vertical-align:-0.0352em;"></span><span class="mrel amsrm">⋐</span></span></span></span> <code>\Subset</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>:</mo></mrow><annotation encoding="application/x-tex">:</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mrel">:</span></span></span></span> <code>:</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mi mathvariant="normal">≕</mi></mo></mrow><annotation encoding="application/x-tex">\eqqcolon</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mrel"><span class="mrel">=</span><span class="mrel"><span class="mspace" style="margin-right:-0.0667em;"></span></span><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span></span></span></span></span> <code>\eqqcolon</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≲</mo></mrow><annotation encoding="application/x-tex">\lesssim</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9592em;vertical-align:-0.2296em;"></span><span class="mrel amsrm">≲</span></span></span></span> <code>\lesssim</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊂</mo></mrow><annotation encoding="application/x-tex">\subset</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">⊂</span></span></span></span> <code>\subset</code> or <code>\sub</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≈</mo></mrow><annotation encoding="application/x-tex">\approx</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4831em;"></span><span class="mrel">≈</span></span></span></span> <code>\approx</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mi mathvariant="normal">=</mi><mi mathvariant="normal">∷</mi></mo></mrow><annotation encoding="application/x-tex">\Eqqcolon</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mrel"><span class="mrel">=</span><span class="mrel"><span class="mspace" style="margin-right:-0.0667em;"></span></span><span class="mrel"><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span><span class="mrel"><span class="mspace" style="margin-right:-0.05em;"></span></span><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span></span></span></span></span></span> <code>\Eqqcolon</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≪</mo></mrow><annotation encoding="application/x-tex">\ll</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">≪</span></span></span></span> <code>\ll</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊆</mo></mrow><annotation encoding="application/x-tex">\subseteq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mrel">⊆</span></span></span></span> <code>\subseteq</code> or <code>\sube</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≊</mo></mrow><annotation encoding="application/x-tex">\approxeq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6633em;vertical-align:-0.0817em;"></span><span class="mrel amsrm">≊</span></span></span></span> <code>\approxeq</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≂</mo></mrow><annotation encoding="application/x-tex">\eqsim</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4637em;"></span><span class="mrel amsrm">≂</span></span></span></span> <code>\eqsim</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋘</mo></mrow><annotation encoding="application/x-tex">\lll</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.585em;vertical-align:-0.0352em;"></span><span class="mrel amsrm">⋘</span></span></span></span> <code>\lll</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⫅</mo></mrow><annotation encoding="application/x-tex">\subseteqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0117em;vertical-align:-0.2558em;"></span><span class="mrel amsrm">⫅</span></span></span></span> <code>\subseteqq</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≍</mo></mrow><annotation encoding="application/x-tex">\asymp</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4637em;"></span><span class="mrel">≍</span></span></span></span> <code>\asymp</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⪖</mo></mrow><annotation encoding="application/x-tex">\eqslantgtr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7733em;vertical-align:-0.1367em;"></span><span class="mrel amsrm">⪖</span></span></span></span> <code>\eqslantgtr</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋘</mo></mrow><annotation encoding="application/x-tex">\llless</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.585em;vertical-align:-0.0352em;"></span><span class="mrel amsrm">⋘</span></span></span></span> <code>\llless</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≻</mo></mrow><annotation encoding="application/x-tex">\succ</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">≻</span></span></span></span> <code>\succ</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∍</mo></mrow><annotation encoding="application/x-tex">\backepsilon</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mrel amsrm">∍</span></span></span></span> <code>\backepsilon</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⪕</mo></mrow><annotation encoding="application/x-tex">\eqslantless</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7733em;vertical-align:-0.1367em;"></span><span class="mrel amsrm">⪕</span></span></span></span> <code>\eqslantless</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>&lt;</mo></mrow><annotation encoding="application/x-tex">\lt</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">&lt;</span></span></span></span> <code>\lt</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⪸</mo></mrow><annotation encoding="application/x-tex">\succapprox</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0189em;vertical-align:-0.2617em;"></span><span class="mrel amsrm">⪸</span></span></span></span> <code>\succapprox</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∽</mo></mrow><annotation encoding="application/x-tex">\backsim</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3779em;"></span><span class="mrel amsrm">∽</span></span></span></span> <code>\backsim</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≡</mo></mrow><annotation encoding="application/x-tex">\equiv</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4637em;"></span><span class="mrel">≡</span></span></span></span> <code>\equiv</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∣</mo></mrow><annotation encoding="application/x-tex">\mid</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mrel">∣</span></span></span></span> <code>\mid</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≽</mo></mrow><annotation encoding="application/x-tex">\succcurlyeq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7733em;vertical-align:-0.1367em;"></span><span class="mrel amsrm">≽</span></span></span></span> <code>\succcurlyeq</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋍</mo></mrow><annotation encoding="application/x-tex">\backsimeq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.464em;"></span><span class="mrel amsrm">⋍</span></span></span></span> <code>\backsimeq</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≒</mo></mrow><annotation encoding="application/x-tex">\fallingdotseq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.664em;vertical-align:-0.082em;"></span><span class="mrel amsrm">≒</span></span></span></span> <code>\fallingdotseq</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊨</mo></mrow><annotation encoding="application/x-tex">\models</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.999em;vertical-align:-0.249em;"></span><span class="mrel">⊨</span></span></span></span> <code>\models</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⪰</mo></mrow><annotation encoding="application/x-tex">\succeq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mrel">⪰</span></span></span></span> <code>\succeq</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≬</mo></mrow><annotation encoding="application/x-tex">\between</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0117em;vertical-align:-0.2558em;"></span><span class="mrel amsrm">≬</span></span></span></span> <code>\between</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⌢</mo></mrow><annotation encoding="application/x-tex">\frown</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3576em;"></span><span class="mrel">⌢</span></span></span></span> <code>\frown</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊸</mo></mrow><annotation encoding="application/x-tex">\multimap</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5499em;"></span><span class="mrel amsrm">⊸</span></span></span></span> <code>\multimap</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≿</mo></mrow><annotation encoding="application/x-tex">\succsim</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9592em;vertical-align:-0.2296em;"></span><span class="mrel amsrm">≿</span></span></span></span> <code>\succsim</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋈</mo></mrow><annotation encoding="application/x-tex">\bowtie</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.51em;vertical-align:-0.005em;"></span><span class="mrel">⋈</span></span></span></span> <code>\bowtie</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≥</mo></mrow><annotation encoding="application/x-tex">\ge</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mrel">≥</span></span></span></span> <code>\ge</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∋</mo></mrow><annotation encoding="application/x-tex">\owns</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">∋</span></span></span></span> <code>\owns</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋑</mo></mrow><annotation encoding="application/x-tex">\Supset</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.585em;vertical-align:-0.0352em;"></span><span class="mrel amsrm">⋑</span></span></span></span> <code>\Supset</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≏</mo></mrow><annotation encoding="application/x-tex">\bumpeq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6105em;vertical-align:-0.0606em;"></span><span class="mrel amsrm">≏</span></span></span></span> <code>\bumpeq</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≥</mo></mrow><annotation encoding="application/x-tex">\geq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mrel">≥</span></span></span></span> <code>\geq</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∥</mo></mrow><annotation encoding="application/x-tex">\parallel</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mrel">∥</span></span></span></span> <code>\parallel</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊃</mo></mrow><annotation encoding="application/x-tex">\supset</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">⊃</span></span></span></span> <code>\supset</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≎</mo></mrow><annotation encoding="application/x-tex">\Bumpeq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6105em;vertical-align:-0.0606em;"></span><span class="mrel amsrm">≎</span></span></span></span> <code>\Bumpeq</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≧</mo></mrow><annotation encoding="application/x-tex">\geqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0117em;vertical-align:-0.2558em;"></span><span class="mrel amsrm">≧</span></span></span></span> <code>\geqq</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊥</mo></mrow><annotation encoding="application/x-tex">\perp</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mrel">⊥</span></span></span></span> <code>\perp</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊇</mo></mrow><annotation encoding="application/x-tex">\supseteq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mrel">⊇</span></span></span></span> <code>\supseteq</code> or <code>\supe</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≗</mo></mrow><annotation encoding="application/x-tex">\circeq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9592em;vertical-align:-0.2296em;"></span><span class="mrel amsrm">≗</span></span></span></span> <code>\circeq</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⩾</mo></mrow><annotation encoding="application/x-tex">\geqslant</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7733em;vertical-align:-0.1367em;"></span><span class="mrel amsrm">⩾</span></span></span></span> <code>\geqslant</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋔</mo></mrow><annotation encoding="application/x-tex">\pitchfork</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mrel amsrm">⋔</span></span></span></span> <code>\pitchfork</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⫆</mo></mrow><annotation encoding="application/x-tex">\supseteqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0117em;vertical-align:-0.2558em;"></span><span class="mrel amsrm">⫆</span></span></span></span> <code>\supseteqq</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mi mathvariant="normal">:</mi><mi mathvariant="normal">≈</mi></mo></mrow><annotation encoding="application/x-tex">\colonapprox</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4831em;"></span><span class="mrel"><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span><span class="mrel"><span class="mspace" style="margin-right:-0.0667em;"></span></span><span class="mrel">≈</span></span></span></span></span> <code>\colonapprox</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≫</mo></mrow><annotation encoding="application/x-tex">\gg</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">≫</span></span></span></span> <code>\gg</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≺</mo></mrow><annotation encoding="application/x-tex">\prec</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">≺</span></span></span></span> <code>\prec</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≈</mo></mrow><annotation encoding="application/x-tex">\thickapprox</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4831em;"></span><span class="mrel amsrm">≈</span></span></span></span> <code>\thickapprox</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mi mathvariant="normal">∷</mi><mi mathvariant="normal">≈</mi></mo></mrow><annotation encoding="application/x-tex">\Colonapprox</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4831em;"></span><span class="mrel"><span class="mrel"><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span><span class="mrel"><span class="mspace" style="margin-right:-0.05em;"></span></span><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span></span><span class="mrel"><span class="mspace" style="margin-right:-0.0667em;"></span></span><span class="mrel">≈</span></span></span></span></span> <code>\Colonapprox</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋙</mo></mrow><annotation encoding="application/x-tex">\ggg</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.585em;vertical-align:-0.0352em;"></span><span class="mrel amsrm">⋙</span></span></span></span> <code>\ggg</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⪷</mo></mrow><annotation encoding="application/x-tex">\precapprox</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0189em;vertical-align:-0.2617em;"></span><span class="mrel amsrm">⪷</span></span></span></span> <code>\precapprox</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∼</mo></mrow><annotation encoding="application/x-tex">\thicksim</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel amsrm">∼</span></span></span></span> <code>\thicksim</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mi mathvariant="normal">:</mi><mi mathvariant="normal">−</mi></mo></mrow><annotation encoding="application/x-tex">\coloneq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mrel"><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span><span class="mrel"><span class="mspace" style="margin-right:-0.0667em;"></span></span><span class="mrel"><span class="mord">−</span></span></span></span></span></span> <code>\coloneq</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋙</mo></mrow><annotation encoding="application/x-tex">\gggtr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.585em;vertical-align:-0.0352em;"></span><span class="mrel amsrm">⋙</span></span></span></span> <code>\gggtr</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≼</mo></mrow><annotation encoding="application/x-tex">\preccurlyeq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7733em;vertical-align:-0.1367em;"></span><span class="mrel amsrm">≼</span></span></span></span> <code>\preccurlyeq</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊴</mo></mrow><annotation encoding="application/x-tex">\trianglelefteq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7733em;vertical-align:-0.1367em;"></span><span class="mrel amsrm">⊴</span></span></span></span> <code>\trianglelefteq</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mi mathvariant="normal">∷</mi><mi mathvariant="normal">−</mi></mo></mrow><annotation encoding="application/x-tex">\Coloneq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mrel"><span class="mrel"><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span><span class="mrel"><span class="mspace" style="margin-right:-0.05em;"></span></span><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span></span><span class="mrel"><span class="mspace" style="margin-right:-0.0667em;"></span></span><span class="mrel"><span class="mord">−</span></span></span></span></span></span> <code>\Coloneq</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>&gt;</mo></mrow><annotation encoding="application/x-tex">\gt</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">&gt;</span></span></span></span> <code>\gt</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⪯</mo></mrow><annotation encoding="application/x-tex">\preceq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mrel">⪯</span></span></span></span> <code>\preceq</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≜</mo></mrow><annotation encoding="application/x-tex">\triangleq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9987em;vertical-align:-0.082em;"></span><span class="mrel amsrm">≜</span></span></span></span> <code>\triangleq</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mi mathvariant="normal">≔</mi></mo></mrow><annotation encoding="application/x-tex">\coloneqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mrel"><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span><span class="mrel"><span class="mspace" style="margin-right:-0.0667em;"></span></span><span class="mrel">=</span></span></span></span></span> <code>\coloneqq</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⪆</mo></mrow><annotation encoding="application/x-tex">\gtrapprox</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0117em;vertical-align:-0.2558em;"></span><span class="mrel amsrm">⪆</span></span></span></span> <code>\gtrapprox</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≾</mo></mrow><annotation encoding="application/x-tex">\precsim</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9592em;vertical-align:-0.2296em;"></span><span class="mrel amsrm">≾</span></span></span></span> <code>\precsim</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊵</mo></mrow><annotation encoding="application/x-tex">\trianglerighteq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7733em;vertical-align:-0.1367em;"></span><span class="mrel amsrm">⊵</span></span></span></span> <code>\trianglerighteq</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mi mathvariant="normal">∷</mi><mi mathvariant="normal">=</mi></mo></mrow><annotation encoding="application/x-tex">\Coloneqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mrel"><span class="mrel"><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span><span class="mrel"><span class="mspace" style="margin-right:-0.05em;"></span></span><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span></span><span class="mrel"><span class="mspace" style="margin-right:-0.0667em;"></span></span><span class="mrel">=</span></span></span></span></span> <code>\Coloneqq</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋛</mo></mrow><annotation encoding="application/x-tex">\gtreqless</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2714em;vertical-align:-0.3857em;"></span><span class="mrel amsrm">⋛</span></span></span></span> <code>\gtreqless</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∝</mo></mrow><annotation encoding="application/x-tex">\propto</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mrel">∝</span></span></span></span> <code>\propto</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∝</mo></mrow><annotation encoding="application/x-tex">\varpropto</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mrel amsrm">∝</span></span></span></span> <code>\varpropto</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mi mathvariant="normal">:</mi><mi mathvariant="normal">∼</mi></mo></mrow><annotation encoding="application/x-tex">\colonsim</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mrel"><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span><span class="mrel"><span class="mspace" style="margin-right:-0.0667em;"></span></span><span class="mrel">∼</span></span></span></span></span> <code>\colonsim</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⪌</mo></mrow><annotation encoding="application/x-tex">\gtreqqless</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.4651em;vertical-align:-0.4826em;"></span><span class="mrel amsrm">⪌</span></span></span></span> <code>\gtreqqless</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≓</mo></mrow><annotation encoding="application/x-tex">\risingdotseq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.664em;vertical-align:-0.082em;"></span><span class="mrel amsrm">≓</span></span></span></span> <code>\risingdotseq</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>△</mo></mrow><annotation encoding="application/x-tex">\vartriangle</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5499em;"></span><span class="mrel amsrm">△</span></span></span></span> <code>\vartriangle</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mi mathvariant="normal">∷</mi><mi mathvariant="normal">∼</mi></mo></mrow><annotation encoding="application/x-tex">\Colonsim</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mrel"><span class="mrel"><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span><span class="mrel"><span class="mspace" style="margin-right:-0.05em;"></span></span><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span></span><span class="mrel"><span class="mspace" style="margin-right:-0.0667em;"></span></span><span class="mrel">∼</span></span></span></span></span> <code>\Colonsim</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≷</mo></mrow><annotation encoding="application/x-tex">\gtrless</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8558em;vertical-align:-0.1808em;"></span><span class="mrel amsrm">≷</span></span></span></span> <code>\gtrless</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∣</mo></mrow><annotation encoding="application/x-tex">\shortmid</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6633em;vertical-align:-0.0817em;"></span><span class="mrel amsrm">∣</span></span></span></span> <code>\shortmid</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊲</mo></mrow><annotation encoding="application/x-tex">\vartriangleleft</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.585em;vertical-align:-0.0352em;"></span><span class="mrel amsrm">⊲</span></span></span></span> <code>\vartriangleleft</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≅</mo></mrow><annotation encoding="application/x-tex">\cong</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.589em;"></span><span class="mrel">≅</span></span></span></span> <code>\cong</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≳</mo></mrow><annotation encoding="application/x-tex">\gtrsim</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9592em;vertical-align:-0.2296em;"></span><span class="mrel amsrm">≳</span></span></span></span> <code>\gtrsim</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∥</mo></mrow><annotation encoding="application/x-tex">\shortparallel</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6633em;vertical-align:-0.0817em;"></span><span class="mrel amsrm">∥</span></span></span></span> <code>\shortparallel</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊳</mo></mrow><annotation encoding="application/x-tex">\vartriangleright</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.585em;vertical-align:-0.0352em;"></span><span class="mrel amsrm">⊳</span></span></span></span> <code>\vartriangleright</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋞</mo></mrow><annotation encoding="application/x-tex">\curlyeqprec</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7733em;vertical-align:-0.1367em;"></span><span class="mrel amsrm">⋞</span></span></span></span> <code>\curlyeqprec</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∈</mo></mrow><annotation encoding="application/x-tex">\in</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">∈</span></span></span></span> <code>\in</code> or <code>\isin</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∼</mo></mrow><annotation encoding="application/x-tex">\sim</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">∼</span></span></span></span> <code>\sim</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mo><mo>:</mo></mo></mo></mrow><annotation encoding="application/x-tex">\vcentcolon</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span></span></span></span> <code>\vcentcolon</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋟</mo></mrow><annotation encoding="application/x-tex">\curlyeqsucc</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7733em;vertical-align:-0.1367em;"></span><span class="mrel amsrm">⋟</span></span></span></span> <code>\curlyeqsucc</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋈</mo></mrow><annotation encoding="application/x-tex">\Join</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.51em;vertical-align:-0.005em;"></span><span class="mrel">⋈</span></span></span></span> <code>\Join</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≃</mo></mrow><annotation encoding="application/x-tex">\simeq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4637em;"></span><span class="mrel">≃</span></span></span></span> <code>\simeq</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊢</mo></mrow><annotation encoding="application/x-tex">\vdash</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mrel">⊢</span></span></span></span> <code>\vdash</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊣</mo></mrow><annotation encoding="application/x-tex">\dashv</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mrel">⊣</span></span></span></span> <code>\dashv</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≤</mo></mrow><annotation encoding="application/x-tex">\le</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mrel">≤</span></span></span></span> <code>\le</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⌢</mo></mrow><annotation encoding="application/x-tex">\smallfrown</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8867em;vertical-align:-0.1944em;"></span><span class="mrel amsrm">⌢</span></span></span></span> <code>\smallfrown</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊨</mo></mrow><annotation encoding="application/x-tex">\vDash</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mrel amsrm">⊨</span></span></span></span> <code>\vDash</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mi mathvariant="normal">∷</mi></mo></mrow><annotation encoding="application/x-tex">\dblcolon</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mrel"><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span><span class="mrel"><span class="mspace" style="margin-right:-0.05em;"></span></span><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span></span></span></span></span> <code>\dblcolon</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≤</mo></mrow><annotation encoding="application/x-tex">\leq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mrel">≤</span></span></span></span> <code>\leq</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⌣</mo></mrow><annotation encoding="application/x-tex">\smallsmile</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8867em;vertical-align:-0.1944em;"></span><span class="mrel amsrm">⌣</span></span></span></span> <code>\smallsmile</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊩</mo></mrow><annotation encoding="application/x-tex">\Vdash</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mrel amsrm">⊩</span></span></span></span> <code>\Vdash</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≐</mo></mrow><annotation encoding="application/x-tex">\doteq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.673em;"></span><span class="mrel">≐</span></span></span></span> <code>\doteq</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≦</mo></mrow><annotation encoding="application/x-tex">\leqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0117em;vertical-align:-0.2558em;"></span><span class="mrel amsrm">≦</span></span></span></span> <code>\leqq</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⌣</mo></mrow><annotation encoding="application/x-tex">\smile</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3576em;"></span><span class="mrel">⌣</span></span></span></span> <code>\smile</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊪</mo></mrow><annotation encoding="application/x-tex">\Vvdash</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mrel amsrm">⊪</span></span></span></span> <code>\Vvdash</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≑</mo></mrow><annotation encoding="application/x-tex">\Doteq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.664em;vertical-align:-0.082em;"></span><span class="mrel amsrm">≑</span></span></span></span> <code>\Doteq</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⩽</mo></mrow><annotation encoding="application/x-tex">\leqslant</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7733em;vertical-align:-0.1367em;"></span><span class="mrel amsrm">⩽</span></span></span></span> <code>\leqslant</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊏</mo></mrow><annotation encoding="application/x-tex">\sqsubset</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.585em;vertical-align:-0.0352em;"></span><span class="mrel amsrm">⊏</span></span></span></span> <code>\sqsubset</code></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≑</mo></mrow><annotation encoding="application/x-tex">\doteqdot</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.664em;vertical-align:-0.082em;"></span><span class="mrel amsrm">≑</span></span></span></span> <code>\doteqdot</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⪅</mo></mrow><annotation encoding="application/x-tex">\lessapprox</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0117em;vertical-align:-0.2558em;"></span><span class="mrel amsrm">⪅</span></span></span></span> <code>\lessapprox</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊑</mo></mrow><annotation encoding="application/x-tex">\sqsubseteq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mrel">⊑</span></span></span></span> <code>\sqsubseteq</code></td>
<td style="text-align:left"></td>
</tr>
</tbody>
</table>
<p>Direct Input: <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>=</mo><mo>&lt;</mo><mo>&gt;</mo><mo>:</mo><mo>∈</mo><mo>∋</mo><mo>∝</mo><mo>∼</mo><mo>∽</mo><mo>≂</mo><mo>≃</mo><mo>≅</mo><mo>≈</mo><mo>≊</mo><mo>≍</mo><mo>≎</mo><mo>≏</mo><mo>≐</mo><mo>≑</mo><mo>≒</mo><mo>≓</mo><mo>≖</mo><mo>≗</mo><mo>≜</mo><mo>≡</mo><mo>≤</mo><mo>≥</mo><mo>≦</mo><mo>≧</mo><mo>≫</mo><mo>≬</mo><mo>≳</mo><mo>≷</mo><mo>≺</mo><mo>≻</mo><mo>≼</mo><mo>≽</mo><mo>≾</mo><mo>≿</mo><mo>⊂</mo><mo>⊃</mo><mo>⊆</mo><mo>⊇</mo><mo>⊏</mo><mo>⊐</mo><mo>⊑</mo><mo>⊒</mo><mo>⊢</mo><mo>⊣</mo><mo>⊩</mo><mo>⊪</mo><mo>⊸</mo><mo>⋈</mo><mo>⋍</mo><mo>⋐</mo><mo>⋑</mo><mo>⋔</mo><mo>⋙</mo><mo>⋛</mo><mo>⋞</mo><mo>⋟</mo><mo>⌢</mo><mo>⌣</mo><mo>⩾</mo><mo>⪆</mo><mo>⪌</mo><mo>⪕</mo><mo>⪖</mo><mo>⪯</mo><mo>⪰</mo><mo>⪷</mo><mo>⪸</mo><mo>⫅</mo><mo>⫆</mo><mo>≲</mo><mo>⩽</mo><mo>⪅</mo><mo>≶</mo><mo>⋚</mo><mo>⪋</mo><mo>⊥</mo><mo>⊨</mo></mrow><annotation encoding="application/x-tex">= &lt; &gt; : ∈ ∋ ∝ ∼ ∽ ≂ ≃ ≅ ≈ ≊ ≍ ≎ ≏ ≐ ≑ ≒ ≓ ≖ ≗ ≜ ≡ ≤ ≥ ≦ ≧ ≫ ≬ ≳ ≷ ≺ ≻ ≼ ≽ ≾ ≿ ⊂ ⊃ ⊆ ⊇ ⊏ ⊐ ⊑ ⊒ ⊢ ⊣ ⊩ ⊪ ⊸ ⋈ ⋍ ⋐ ⋑ ⋔ ⋙ ⋛ ⋞ ⋟ ⌢ ⌣ ⩾ ⪆ ⪌ ⪕ ⪖ ⪯ ⪰ ⪷ ⪸ ⫅ ⫆ ≲ ⩽ ⪅ ≶ ⋚ ⪋ ⟂ ⊨</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">=&lt;&gt;:∈∋∝∼</span></span><span class="base"><span class="strut" style="height:0.4637em;"></span><span class="mrel amsrm">∽≂</span></span><span class="base"><span class="strut" style="height:0.589em;"></span><span class="mrel">≃≅≈</span></span><span class="base"><span class="strut" style="height:0.6633em;vertical-align:-0.0817em;"></span><span class="mrel amsrm">≊</span></span><span class="base"><span class="strut" style="height:0.4637em;"></span><span class="mrel">≍</span></span><span class="base"><span class="strut" style="height:0.6105em;vertical-align:-0.0606em;"></span><span class="mrel amsrm">≎≏</span></span><span class="base"><span class="strut" style="height:0.673em;"></span><span class="mrel">≐</span></span><span class="base"><span class="strut" style="height:1.1462em;vertical-align:-0.2296em;"></span><span class="mrel amsrm">≑≒≓≖≗≜</span></span><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mrel">≡≤≥</span></span><span class="base"><span class="strut" style="height:1.0117em;vertical-align:-0.2558em;"></span><span class="mrel amsrm">≦≧</span></span><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">≫</span></span><span class="base"><span class="strut" style="height:1.0117em;vertical-align:-0.2558em;"></span><span class="mrel amsrm">≬≳≷</span></span><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">≺≻</span></span><span class="base"><span class="strut" style="height:0.9592em;vertical-align:-0.2296em;"></span><span class="mrel amsrm">≼≽≾≿</span></span><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mrel">⊂⊃⊆⊇</span></span><span class="base"><span class="strut" style="height:0.585em;vertical-align:-0.0352em;"></span><span class="mrel amsrm">⊏⊐</span></span><span class="base"><span class="strut" style="height:0.8304em;vertical-align:-0.136em;"></span><span class="mrel">⊑⊒⊢⊣</span></span><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mrel amsrm">⊩⊪⊸</span></span><span class="base"><span class="strut" style="height:0.51em;vertical-align:-0.005em;"></span><span class="mrel">⋈</span></span><span class="base"><span class="strut" style="height:1.2714em;vertical-align:-0.3857em;"></span><span class="mrel amsrm">⋍⋐⋑⋔⋙⋛⋞⋟</span></span><span class="base"><span class="strut" style="height:0.3576em;"></span><span class="mrel">⌢⌣</span></span><span class="base"><span class="strut" style="height:1.4651em;vertical-align:-0.4826em;"></span><span class="mrel amsrm">⩾⪆⪌⪕⪖</span></span><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mrel">⪯⪰</span></span><span class="base"><span class="strut" style="height:1.4651em;vertical-align:-0.4826em;"></span><span class="mrel amsrm">⪷⪸⫅⫆≲⩽⪅≶⋚⪋</span></span><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mrel">⊥</span></span><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mrel amsrm">⊨</span></span></span></span> <code>≔ ≕ ⩴</code></p>
<h3 id="_10-1-negated-relations" tabindex="-1">10.1: Negated Relations <a class="header-anchor" href="#_10-1-negated-relations" aria-label="Permalink to &quot;10.1: Negated Relations&quot;">&ZeroWidthSpace;</a></h3>
<p><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≠</mo></mrow><annotation encoding="application/x-tex">\not =</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel"><span class="mord vbox"><span class="thinbox"><span class="rlap"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="inner"><span class="mord"><span class="mrel"></span></span></span><span class="fix"></span></span></span></span></span></span><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">=</span></span></span></span> <code>\not =</code></p>
<table>
<thead>
<tr>
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⪊</mo></mrow><annotation encoding="application/x-tex">\gnapprox</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0189em;vertical-align:-0.2617em;"></span><span class="mrel amsrm">⪊</span></span></span></span> <code>\gnapprox</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≱</mo></mrow><annotation encoding="application/x-tex">\ngeqslant</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0966em;vertical-align:-0.3027em;"></span><span class="mrel amsrm"></span></span></span></span> <code>\ngeqslant</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊈</mo></mrow><annotation encoding="application/x-tex">\nsubseteq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0966em;vertical-align:-0.3027em;"></span><span class="mrel amsrm">⊈</span></span></span></span> <code>\nsubseteq</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⪵</mo></mrow><annotation encoding="application/x-tex">\precneqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0087em;vertical-align:-0.2514em;"></span><span class="mrel amsrm">⪵</span></span></span></span> <code>\precneqq</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⪈</mo></mrow><annotation encoding="application/x-tex">\gneq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mrel amsrm">⪈</span></span></span></span> <code>\gneq</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≯</mo></mrow><annotation encoding="application/x-tex">\ngtr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9115em;vertical-align:-0.2058em;"></span><span class="mrel amsrm">≯</span></span></span></span> <code>\ngtr</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊈</mo></mrow><annotation encoding="application/x-tex">\nsubseteqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0087em;vertical-align:-0.2514em;"></span><span class="mrel amsrm"></span></span></span></span> <code>\nsubseteqq</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋨</mo></mrow><annotation encoding="application/x-tex">\precnsim</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9733em;vertical-align:-0.2322em;"></span><span class="mrel amsrm">⋨</span></span></span></span> <code>\precnsim</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≩</mo></mrow><annotation encoding="application/x-tex">\gneqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0087em;vertical-align:-0.2514em;"></span><span class="mrel amsrm">≩</span></span></span></span> <code>\gneqq</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≰</mo></mrow><annotation encoding="application/x-tex">\nleq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0966em;vertical-align:-0.3027em;"></span><span class="mrel amsrm">≰</span></span></span></span> <code>\nleq</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊁</mo></mrow><annotation encoding="application/x-tex">\nsucc</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9115em;vertical-align:-0.2058em;"></span><span class="mrel amsrm">⊁</span></span></span></span> <code>\nsucc</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊊</mo></mrow><annotation encoding="application/x-tex">\subsetneq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mrel amsrm">⊊</span></span></span></span> <code>\subsetneq</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋧</mo></mrow><annotation encoding="application/x-tex">\gnsim</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9733em;vertical-align:-0.2322em;"></span><span class="mrel amsrm">⋧</span></span></span></span> <code>\gnsim</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≰</mo></mrow><annotation encoding="application/x-tex">\nleqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.339em;vertical-align:-0.4195em;"></span><span class="mrel amsrm"></span></span></span></span> <code>\nleqq</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋡</mo></mrow><annotation encoding="application/x-tex">\nsucceq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0966em;vertical-align:-0.3027em;"></span><span class="mrel amsrm">⋡</span></span></span></span> <code>\nsucceq</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⫋</mo></mrow><annotation encoding="application/x-tex">\subsetneqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0786em;vertical-align:-0.2848em;"></span><span class="mrel amsrm">⫋</span></span></span></span> <code>\subsetneqq</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≩</mo></mrow><annotation encoding="application/x-tex">\gvertneqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0087em;vertical-align:-0.2514em;"></span><span class="mrel amsrm"></span></span></span></span> <code>\gvertneqq</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≰</mo></mrow><annotation encoding="application/x-tex">\nleqslant</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0966em;vertical-align:-0.3027em;"></span><span class="mrel amsrm"></span></span></span></span> <code>\nleqslant</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊉</mo></mrow><annotation encoding="application/x-tex">\nsupseteq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0966em;vertical-align:-0.3027em;"></span><span class="mrel amsrm">⊉</span></span></span></span> <code>\nsupseteq</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⪺</mo></mrow><annotation encoding="application/x-tex">\succnapprox</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0189em;vertical-align:-0.2617em;"></span><span class="mrel amsrm">⪺</span></span></span></span> <code>\succnapprox</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⪉</mo></mrow><annotation encoding="application/x-tex">\lnapprox</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0189em;vertical-align:-0.2617em;"></span><span class="mrel amsrm">⪉</span></span></span></span> <code>\lnapprox</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≮</mo></mrow><annotation encoding="application/x-tex">\nless</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9115em;vertical-align:-0.2058em;"></span><span class="mrel amsrm">≮</span></span></span></span> <code>\nless</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊉</mo></mrow><annotation encoding="application/x-tex">\nsupseteqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0087em;vertical-align:-0.2514em;"></span><span class="mrel amsrm"></span></span></span></span> <code>\nsupseteqq</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⪶</mo></mrow><annotation encoding="application/x-tex">\succneqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0087em;vertical-align:-0.2514em;"></span><span class="mrel amsrm">⪶</span></span></span></span> <code>\succneqq</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⪇</mo></mrow><annotation encoding="application/x-tex">\lneq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mrel amsrm">⪇</span></span></span></span> <code>\lneq</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∤</mo></mrow><annotation encoding="application/x-tex">\nmid</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9925em;vertical-align:-0.2514em;"></span><span class="mrel amsrm">∤</span></span></span></span> <code>\nmid</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋪</mo></mrow><annotation encoding="application/x-tex">\ntriangleleft</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9115em;vertical-align:-0.2058em;"></span><span class="mrel amsrm">⋪</span></span></span></span> <code>\ntriangleleft</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋩</mo></mrow><annotation encoding="application/x-tex">\succnsim</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9733em;vertical-align:-0.2322em;"></span><span class="mrel amsrm">⋩</span></span></span></span> <code>\succnsim</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≨</mo></mrow><annotation encoding="application/x-tex">\lneqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0087em;vertical-align:-0.2514em;"></span><span class="mrel amsrm">≨</span></span></span></span> <code>\lneqq</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo mathvariant="normal">∉</mo></mrow><annotation encoding="application/x-tex">\notin</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mrel"><span class="mord"><span class="mrel">∈</span></span><span class="mord vbox"><span class="thinbox"><span class="llap"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="inner"><span class="mord"><span class="mord">/</span><span class="mspace" style="margin-right:0.0556em;"></span></span></span><span class="fix"></span></span></span></span></span></span></span></span> <code>\notin</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋬</mo></mrow><annotation encoding="application/x-tex">\ntrianglelefteq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0966em;vertical-align:-0.3027em;"></span><span class="mrel amsrm">⋬</span></span></span></span> <code>\ntrianglelefteq</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊋</mo></mrow><annotation encoding="application/x-tex">\supsetneq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mrel amsrm">⊋</span></span></span></span> <code>\supsetneq</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋦</mo></mrow><annotation encoding="application/x-tex">\lnsim</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9733em;vertical-align:-0.2322em;"></span><span class="mrel amsrm">⋦</span></span></span></span> <code>\lnsim</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo mathvariant="normal">∌</mo></mrow><annotation encoding="application/x-tex">\notni</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel"><span class="mord vbox"><span class="thinbox"><span class="rlap"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="inner"><span class="mord"><span class="mrel"></span></span></span><span class="fix"></span></span></span></span></span></span><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">∋</span></span></span></span> <code>\notni</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋫</mo></mrow><annotation encoding="application/x-tex">\ntriangleright</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9115em;vertical-align:-0.2058em;"></span><span class="mrel amsrm">⋫</span></span></span></span> <code>\ntriangleright</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⫌</mo></mrow><annotation encoding="application/x-tex">\supsetneqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0786em;vertical-align:-0.2848em;"></span><span class="mrel amsrm">⫌</span></span></span></span> <code>\supsetneqq</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≨</mo></mrow><annotation encoding="application/x-tex">\lvertneqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0087em;vertical-align:-0.2514em;"></span><span class="mrel amsrm"></span></span></span></span> <code>\lvertneqq</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∦</mo></mrow><annotation encoding="application/x-tex">\nparallel</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9925em;vertical-align:-0.2514em;"></span><span class="mrel amsrm">∦</span></span></span></span> <code>\nparallel</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋭</mo></mrow><annotation encoding="application/x-tex">\ntrianglerighteq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0966em;vertical-align:-0.3027em;"></span><span class="mrel amsrm">⋭</span></span></span></span> <code>\ntrianglerighteq</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊊</mo></mrow><annotation encoding="application/x-tex">\varsubsetneq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mrel amsrm"></span></span></span></span> <code>\varsubsetneq</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≆</mo></mrow><annotation encoding="application/x-tex">\ncong</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0966em;vertical-align:-0.3027em;"></span><span class="mrel amsrm">≆</span></span></span></span> <code>\ncong</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊀</mo></mrow><annotation encoding="application/x-tex">\nprec</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9115em;vertical-align:-0.2058em;"></span><span class="mrel amsrm">⊀</span></span></span></span> <code>\nprec</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊬</mo></mrow><annotation encoding="application/x-tex">\nvdash</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mrel amsrm">⊬</span></span></span></span> <code>\nvdash</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⫋</mo></mrow><annotation encoding="application/x-tex">\varsubsetneqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0087em;vertical-align:-0.2514em;"></span><span class="mrel amsrm"></span></span></span></span> <code>\varsubsetneqq</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo mathvariant="normal">≠</mo></mrow><annotation encoding="application/x-tex">\ne</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel"><span class="mrel"><span class="mord vbox"><span class="thinbox"><span class="rlap"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="inner"><span class="mord"><span class="mrel"></span></span></span><span class="fix"></span></span></span></span></span><span class="mrel">=</span></span></span></span></span> <code>\ne</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋠</mo></mrow><annotation encoding="application/x-tex">\npreceq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0966em;vertical-align:-0.3027em;"></span><span class="mrel amsrm">⋠</span></span></span></span> <code>\npreceq</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊭</mo></mrow><annotation encoding="application/x-tex">\nvDash</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mrel amsrm">⊭</span></span></span></span> <code>\nvDash</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊋</mo></mrow><annotation encoding="application/x-tex">\varsupsetneq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mrel amsrm"></span></span></span></span> <code>\varsupsetneq</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo mathvariant="normal">≠</mo></mrow><annotation encoding="application/x-tex">\neq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel"><span class="mrel"><span class="mord vbox"><span class="thinbox"><span class="rlap"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="inner"><span class="mord"><span class="mrel"></span></span></span><span class="fix"></span></span></span></span></span><span class="mrel">=</span></span></span></span></span> <code>\neq</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∤</mo></mrow><annotation encoding="application/x-tex">\nshortmid</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6633em;vertical-align:-0.0817em;"></span><span class="mrel amsrm"></span></span></span></span> <code>\nshortmid</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊯</mo></mrow><annotation encoding="application/x-tex">\nVDash</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mrel amsrm">⊯</span></span></span></span> <code>\nVDash</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⫌</mo></mrow><annotation encoding="application/x-tex">\varsupsetneqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0087em;vertical-align:-0.2514em;"></span><span class="mrel amsrm"></span></span></span></span> <code>\varsupsetneqq</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≱</mo></mrow><annotation encoding="application/x-tex">\ngeq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0966em;vertical-align:-0.3027em;"></span><span class="mrel amsrm">≱</span></span></span></span> <code>\ngeq</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∦</mo></mrow><annotation encoding="application/x-tex">\nshortparallel</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6633em;vertical-align:-0.0817em;"></span><span class="mrel amsrm"></span></span></span></span> <code>\nshortparallel</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊮</mo></mrow><annotation encoding="application/x-tex">\nVdash</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mrel amsrm">⊮</span></span></span></span> <code>\nVdash</code></td>
<td></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≱</mo></mrow><annotation encoding="application/x-tex">\ngeqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.339em;vertical-align:-0.4195em;"></span><span class="mrel amsrm"></span></span></span></span> <code>\ngeqq</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≁</mo></mrow><annotation encoding="application/x-tex">\nsim</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel amsrm">≁</span></span></span></span> <code>\nsim</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⪹</mo></mrow><annotation encoding="application/x-tex">\precnapprox</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0189em;vertical-align:-0.2617em;"></span><span class="mrel amsrm">⪹</span></span></span></span> <code>\precnapprox</code></td>
<td></td>
</tr>
</tbody>
</table>
<p>Direct Input:</p>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mo mathvariant="normal">∉</mo><mo mathvariant="normal">∌</mo><mo>∤</mo><mo>∦</mo><mo>≁</mo><mo>≆</mo><mo mathvariant="normal">≠</mo><mo>≨</mo><mo>≩</mo><mo>≮</mo><mo>≯</mo><mo>≰</mo><mo>≱</mo><mo>⊀</mo><mo>⊁</mo><mo>⊈</mo><mo>⊉</mo><mo>⊊</mo><mo>⊋</mo><mo>⊬</mo><mo>⊭</mo><mo>⊮</mo><mo>⊯</mo><mo>⋠</mo><mo>⋡</mo><mo>⋦</mo><mo>⋧</mo><mo>⋨</mo><mo>⋩</mo><mo>⋬</mo><mo>⋭</mo><mo>⪇</mo><mo>⪈</mo><mo>⪉</mo><mo>⪊</mo><mo>⪵</mo><mo>⪶</mo><mo>⪹</mo><mo>⪺</mo><mo>⫋</mo><mo>⫌</mo></mrow><annotation encoding="application/x-tex">∉ ∌ ∤ ∦ ≁ ≆ ≠ ≨ ≩ ≮ ≯ ≰ ≱ ⊀ ⊁ ⊈ ⊉ ⊊ ⊋ ⊬ ⊭ ⊮ ⊯ ⋠ ⋡ ⋦ ⋧ ⋨ ⋩ ⋬ ⋭ ⪇ ⪈ ⪉ ⪊ ⪵ ⪶ ⪹ ⪺ ⫋ ⫌
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mrel"><span class="mord"><span class="mrel">∈</span></span><span class="mord vbox"><span class="thinbox"><span class="llap"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="inner"><span class="mord"><span class="mord">/</span><span class="mspace" style="margin-right:0.0556em;"></span></span></span><span class="fix"></span></span></span></span></span></span><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel"><span class="mord vbox"><span class="thinbox"><span class="rlap"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="inner"><span class="mord"><span class="mrel"></span></span></span><span class="fix"></span></span></span></span></span></span><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">∋</span></span><span class="base"><span class="strut" style="height:1.0966em;vertical-align:-0.3027em;"></span><span class="mrel amsrm">∤∦≁≆</span></span><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel"><span class="mrel"><span class="mord vbox"><span class="thinbox"><span class="rlap"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="inner"><span class="mord"><span class="mrel"></span></span></span><span class="fix"></span></span></span></span></span><span class="mrel">=</span></span></span><span class="base"><span class="strut" style="height:1.0966em;vertical-align:-0.3027em;"></span><span class="mrel amsrm">≨≩≮≯≰≱⊀⊁⊈⊉⊊⊋⊬⊭⊮⊯⋠⋡⋦⋧⋨⋩⋬⋭⪇⪈⪉⪊⪵⪶⪹⪺⫋⫌</span></span></span></span></span></p>
<h3 id="_10-2-arrows" tabindex="-1">10.2: Arrows <a class="header-anchor" href="#_10-2-arrows" aria-label="Permalink to &quot;10.2: Arrows&quot;">&ZeroWidthSpace;</a></h3>
<table>
<thead>
<tr>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↺</mo></mrow><annotation encoding="application/x-tex">\circlearrowleft</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.664em;vertical-align:-0.082em;"></span><span class="mrel amsrm">↺</span></span></span></span> <code>\circlearrowleft</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↼</mo></mrow><annotation encoding="application/x-tex">\leftharpoonup</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">↼</span></span></span></span> <code>\leftharpoonup</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇒</mo></mrow><annotation encoding="application/x-tex">\rArr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">⇒</span></span></span></span> <code>\rArr</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↻</mo></mrow><annotation encoding="application/x-tex">\circlearrowright</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.664em;vertical-align:-0.082em;"></span><span class="mrel amsrm">↻</span></span></span></span> <code>\circlearrowright</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇇</mo></mrow><annotation encoding="application/x-tex">\leftleftarrows</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8558em;vertical-align:-0.1808em;"></span><span class="mrel amsrm">⇇</span></span></span></span> <code>\leftleftarrows</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>→</mo></mrow><annotation encoding="application/x-tex">\rarr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">→</span></span></span></span> <code>\rarr</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↶</mo></mrow><annotation encoding="application/x-tex">\curvearrowleft</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mrel amsrm">↶</span></span></span></span> <code>\curvearrowleft</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↔</mo></mrow><annotation encoding="application/x-tex">\leftrightarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">↔</span></span></span></span> <code>\leftrightarrow</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↾</mo></mrow><annotation encoding="application/x-tex">\restriction</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8867em;vertical-align:-0.1944em;"></span><span class="mrel amsrm">↾</span></span></span></span> <code>\restriction</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↷</mo></mrow><annotation encoding="application/x-tex">\curvearrowright</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mrel amsrm">↷</span></span></span></span> <code>\curvearrowright</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇔</mo></mrow><annotation encoding="application/x-tex">\Leftrightarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">⇔</span></span></span></span> <code>\Leftrightarrow</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>→</mo></mrow><annotation encoding="application/x-tex">\rightarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">→</span></span></span></span> <code>\rightarrow</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇓</mo></mrow><annotation encoding="application/x-tex">\Darr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel">⇓</span></span></span></span> <code>\Darr</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇆</mo></mrow><annotation encoding="application/x-tex">\leftrightarrows</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8558em;vertical-align:-0.1808em;"></span><span class="mrel amsrm">⇆</span></span></span></span> <code>\leftrightarrows</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇒</mo></mrow><annotation encoding="application/x-tex">\Rightarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">⇒</span></span></span></span> <code>\Rightarrow</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇓</mo></mrow><annotation encoding="application/x-tex">\dArr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel">⇓</span></span></span></span> <code>\dArr</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇋</mo></mrow><annotation encoding="application/x-tex">\leftrightharpoons</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5359em;vertical-align:-0.0135em;"></span><span class="mrel amsrm">⇋</span></span></span></span> <code>\leftrightharpoons</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↣</mo></mrow><annotation encoding="application/x-tex">\rightarrowtail</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5359em;vertical-align:-0.0135em;"></span><span class="mrel amsrm">↣</span></span></span></span> <code>\rightarrowtail</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↓</mo></mrow><annotation encoding="application/x-tex">\darr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel">↓</span></span></span></span> <code>\darr</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↭</mo></mrow><annotation encoding="application/x-tex">\leftrightsquigarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3779em;"></span><span class="mrel amsrm">↭</span></span></span></span> <code>\leftrightsquigarrow</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇁</mo></mrow><annotation encoding="application/x-tex">\rightharpoondown</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">⇁</span></span></span></span> <code>\rightharpoondown</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇠</mo></mrow><annotation encoding="application/x-tex">\dashleftarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.437em;"></span><span class="mrel amsrm">⇠</span></span></span></span> <code>\dashleftarrow</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇚</mo></mrow><annotation encoding="application/x-tex">\Lleftarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7733em;vertical-align:-0.1367em;"></span><span class="mrel amsrm">⇚</span></span></span></span> <code>\Lleftarrow</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇀</mo></mrow><annotation encoding="application/x-tex">\rightharpoonup</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">⇀</span></span></span></span> <code>\rightharpoonup</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇢</mo></mrow><annotation encoding="application/x-tex">\dashrightarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.437em;"></span><span class="mrel amsrm">⇢</span></span></span></span> <code>\dashrightarrow</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⟵</mo></mrow><annotation encoding="application/x-tex">\longleftarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.522em;vertical-align:-0.011em;"></span><span class="mrel">⟵</span></span></span></span> <code>\longleftarrow</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇄</mo></mrow><annotation encoding="application/x-tex">\rightleftarrows</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8558em;vertical-align:-0.1808em;"></span><span class="mrel amsrm">⇄</span></span></span></span> <code>\rightleftarrows</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↓</mo></mrow><annotation encoding="application/x-tex">\downarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel">↓</span></span></span></span> <code>\downarrow</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⟸</mo></mrow><annotation encoding="application/x-tex">\Longleftarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.549em;vertical-align:-0.024em;"></span><span class="mrel">⟸</span></span></span></span> <code>\Longleftarrow</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇌</mo></mrow><annotation encoding="application/x-tex">\rightleftharpoons</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.682em;vertical-align:-0.011em;"></span><span class="mrel">⇌</span></span></span></span> <code>\rightleftharpoons</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇓</mo></mrow><annotation encoding="application/x-tex">\Downarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel">⇓</span></span></span></span> <code>\Downarrow</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⟷</mo></mrow><annotation encoding="application/x-tex">\longleftrightarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.522em;vertical-align:-0.011em;"></span><span class="mrel">⟷</span></span></span></span> <code>\longleftrightarrow</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇉</mo></mrow><annotation encoding="application/x-tex">\rightrightarrows</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8558em;vertical-align:-0.1808em;"></span><span class="mrel amsrm">⇉</span></span></span></span> <code>\rightrightarrows</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇊</mo></mrow><annotation encoding="application/x-tex">\downdownarrows</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8867em;vertical-align:-0.1944em;"></span><span class="mrel amsrm">⇊</span></span></span></span> <code>\downdownarrows</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⟺</mo></mrow><annotation encoding="application/x-tex">\Longleftrightarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.549em;vertical-align:-0.024em;"></span><span class="mrel">⟺</span></span></span></span> <code>\Longleftrightarrow</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇝</mo></mrow><annotation encoding="application/x-tex">\rightsquigarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3779em;"></span><span class="mrel amsrm">⇝</span></span></span></span> <code>\rightsquigarrow</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇃</mo></mrow><annotation encoding="application/x-tex">\downharpoonleft</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8867em;vertical-align:-0.1944em;"></span><span class="mrel amsrm">⇃</span></span></span></span> <code>\downharpoonleft</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⟼</mo></mrow><annotation encoding="application/x-tex">\longmapsto</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.522em;vertical-align:-0.011em;"></span><span class="mrel">⟼</span></span></span></span> <code>\longmapsto</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇛</mo></mrow><annotation encoding="application/x-tex">\Rrightarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7733em;vertical-align:-0.1367em;"></span><span class="mrel amsrm">⇛</span></span></span></span> <code>\Rrightarrow</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇂</mo></mrow><annotation encoding="application/x-tex">\downharpoonright</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8867em;vertical-align:-0.1944em;"></span><span class="mrel amsrm">⇂</span></span></span></span> <code>\downharpoonright</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⟶</mo></mrow><annotation encoding="application/x-tex">\longrightarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.522em;vertical-align:-0.011em;"></span><span class="mrel">⟶</span></span></span></span> <code>\longrightarrow</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↱</mo></mrow><annotation encoding="application/x-tex">\Rsh</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mrel amsrm">↱</span></span></span></span> <code>\Rsh</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>←</mo></mrow><annotation encoding="application/x-tex">\gets</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">←</span></span></span></span> <code>\gets</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⟹</mo></mrow><annotation encoding="application/x-tex">\Longrightarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.549em;vertical-align:-0.024em;"></span><span class="mrel">⟹</span></span></span></span> <code>\Longrightarrow</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↘</mo></mrow><annotation encoding="application/x-tex">\searrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel">↘</span></span></span></span> <code>\searrow</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇔</mo></mrow><annotation encoding="application/x-tex">\Harr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">⇔</span></span></span></span> <code>\Harr</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↫</mo></mrow><annotation encoding="application/x-tex">\looparrowleft</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5499em;"></span><span class="mrel amsrm">↫</span></span></span></span> <code>\looparrowleft</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↙</mo></mrow><annotation encoding="application/x-tex">\swarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel">↙</span></span></span></span> <code>\swarrow</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇔</mo></mrow><annotation encoding="application/x-tex">\hArr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">⇔</span></span></span></span> <code>\hArr</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↬</mo></mrow><annotation encoding="application/x-tex">\looparrowright</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5499em;"></span><span class="mrel amsrm">↬</span></span></span></span> <code>\looparrowright</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>→</mo></mrow><annotation encoding="application/x-tex">\to</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">→</span></span></span></span> <code>\to</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↔</mo></mrow><annotation encoding="application/x-tex">\harr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">↔</span></span></span></span> <code>\harr</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇔</mo></mrow><annotation encoding="application/x-tex">\Lrarr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">⇔</span></span></span></span> <code>\Lrarr</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↞</mo></mrow><annotation encoding="application/x-tex">\twoheadleftarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5359em;vertical-align:-0.0135em;"></span><span class="mrel amsrm">↞</span></span></span></span> <code>\twoheadleftarrow</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↩</mo></mrow><annotation encoding="application/x-tex">\hookleftarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.522em;vertical-align:-0.011em;"></span><span class="mrel">↩</span></span></span></span> <code>\hookleftarrow</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇔</mo></mrow><annotation encoding="application/x-tex">\lrArr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">⇔</span></span></span></span> <code>\lrArr</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↠</mo></mrow><annotation encoding="application/x-tex">\twoheadrightarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5359em;vertical-align:-0.0135em;"></span><span class="mrel amsrm">↠</span></span></span></span> <code>\twoheadrightarrow</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↪</mo></mrow><annotation encoding="application/x-tex">\hookrightarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.522em;vertical-align:-0.011em;"></span><span class="mrel">↪</span></span></span></span> <code>\hookrightarrow</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↔</mo></mrow><annotation encoding="application/x-tex">\lrarr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">↔</span></span></span></span> <code>\lrarr</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇑</mo></mrow><annotation encoding="application/x-tex">\Uarr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel">⇑</span></span></span></span> <code>\Uarr</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>  </mtext><mo>⟺</mo><mtext>  </mtext></mrow><annotation encoding="application/x-tex">\iff</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.549em;vertical-align:-0.024em;"></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">⟺</span><span class="mspace" style="margin-right:0.2778em;"></span></span></span></span> <code>\iff</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↰</mo></mrow><annotation encoding="application/x-tex">\Lsh</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mrel amsrm">↰</span></span></span></span> <code>\Lsh</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇑</mo></mrow><annotation encoding="application/x-tex">\uArr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel">⇑</span></span></span></span> <code>\uArr</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>  </mtext><mo>⟸</mo><mtext>  </mtext></mrow><annotation encoding="application/x-tex">\impliedby</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.549em;vertical-align:-0.024em;"></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">⟸</span><span class="mspace" style="margin-right:0.2778em;"></span></span></span></span> <code>\impliedby</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↦</mo></mrow><annotation encoding="application/x-tex">\mapsto</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.522em;vertical-align:-0.011em;"></span><span class="mrel">↦</span></span></span></span> <code>\mapsto</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↑</mo></mrow><annotation encoding="application/x-tex">\uarr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel">↑</span></span></span></span> <code>\uarr</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>  </mtext><mo>⟹</mo><mtext>  </mtext></mrow><annotation encoding="application/x-tex">\implies</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.549em;vertical-align:-0.024em;"></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">⟹</span><span class="mspace" style="margin-right:0.2778em;"></span></span></span></span> <code>\implies</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↗</mo></mrow><annotation encoding="application/x-tex">\nearrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel">↗</span></span></span></span> <code>\nearrow</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↑</mo></mrow><annotation encoding="application/x-tex">\uparrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel">↑</span></span></span></span> <code>\uparrow</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇐</mo></mrow><annotation encoding="application/x-tex">\Larr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">⇐</span></span></span></span> <code>\Larr</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↚</mo></mrow><annotation encoding="application/x-tex">\nleftarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel amsrm">↚</span></span></span></span> <code>\nleftarrow</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇑</mo></mrow><annotation encoding="application/x-tex">\Uparrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel">⇑</span></span></span></span> <code>\Uparrow</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇐</mo></mrow><annotation encoding="application/x-tex">\lArr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">⇐</span></span></span></span> <code>\lArr</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇍</mo></mrow><annotation encoding="application/x-tex">\nLeftarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel amsrm">⇍</span></span></span></span> <code>\nLeftarrow</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↕</mo></mrow><annotation encoding="application/x-tex">\updownarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mrel">↕</span></span></span></span> <code>\updownarrow</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>←</mo></mrow><annotation encoding="application/x-tex">\larr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">←</span></span></span></span> <code>\larr</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↮</mo></mrow><annotation encoding="application/x-tex">\nleftrightarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel amsrm">↮</span></span></span></span> <code>\nleftrightarrow</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇕</mo></mrow><annotation encoding="application/x-tex">\Updownarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mrel">⇕</span></span></span></span> <code>\Updownarrow</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇝</mo></mrow><annotation encoding="application/x-tex">\leadsto</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3779em;"></span><span class="mrel amsrm">⇝</span></span></span></span> <code>\leadsto</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇎</mo></mrow><annotation encoding="application/x-tex">\nLeftrightarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel amsrm">⇎</span></span></span></span> <code>\nLeftrightarrow</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↿</mo></mrow><annotation encoding="application/x-tex">\upharpoonleft</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8867em;vertical-align:-0.1944em;"></span><span class="mrel amsrm">↿</span></span></span></span> <code>\upharpoonleft</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>←</mo></mrow><annotation encoding="application/x-tex">\leftarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">←</span></span></span></span> <code>\leftarrow</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↛</mo></mrow><annotation encoding="application/x-tex">\nrightarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel amsrm">↛</span></span></span></span> <code>\nrightarrow</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↾</mo></mrow><annotation encoding="application/x-tex">\upharpoonright</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8867em;vertical-align:-0.1944em;"></span><span class="mrel amsrm">↾</span></span></span></span> <code>\upharpoonright</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇐</mo></mrow><annotation encoding="application/x-tex">\Leftarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">⇐</span></span></span></span> <code>\Leftarrow</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇏</mo></mrow><annotation encoding="application/x-tex">\nRightarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel amsrm">⇏</span></span></span></span> <code>\nRightarrow</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇈</mo></mrow><annotation encoding="application/x-tex">\upuparrows</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8867em;vertical-align:-0.1944em;"></span><span class="mrel amsrm">⇈</span></span></span></span> <code>\upuparrows</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↢</mo></mrow><annotation encoding="application/x-tex">\leftarrowtail</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5359em;vertical-align:-0.0135em;"></span><span class="mrel amsrm">↢</span></span></span></span> <code>\leftarrowtail</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↖</mo></mrow><annotation encoding="application/x-tex">\nwarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel">↖</span></span></span></span> <code>\nwarrow</code></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↽</mo></mrow><annotation encoding="application/x-tex">\leftharpoondown</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">↽</span></span></span></span> <code>\leftharpoondown</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇒</mo></mrow><annotation encoding="application/x-tex">\Rarr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">⇒</span></span></span></span> <code>\Rarr</code></td>
<td style="text-align:left"></td>
</tr>
</tbody>
</table>
<p>Direct Input: <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>←</mo><mo>↑</mo><mo>→</mo><mo>↓</mo><mo>↔</mo><mo>↕</mo><mo>↖</mo><mo>↗</mo><mo>↘</mo><mo>↙</mo><mo>↚</mo><mo>↛</mo><mo>↞</mo><mo>↠</mo><mo>↢</mo><mo>↣</mo><mo>↦</mo><mo>↩</mo><mo>↪</mo><mo>↫</mo><mo>↬</mo><mo>↭</mo><mo>↮</mo><mo>↰</mo><mo>↱</mo><mo>↶</mo><mo>↷</mo><mo>↺</mo><mo>↻</mo><mo>↼</mo><mo>↽</mo><mo>↾</mo><mo>↾</mo><mo>↿</mo><mo>⇀</mo><mo>⇁</mo><mo>⇂</mo><mo>⇃</mo><mo>⇄</mo><mo>⇆</mo><mo>⇇</mo><mo>⇈</mo><mo>⇉</mo><mo>⇊</mo><mo>⇋</mo><mo>⇌</mo><mo>⇍</mo><mo>⇎</mo><mo>⇏</mo><mo>⇐</mo><mo>⇑</mo><mo>⇒</mo><mo>⇓</mo><mo>⇔</mo><mo>⇕</mo><mo>⇚</mo><mo>⇛</mo><mo>⇝</mo><mo>⇠</mo><mo>⇢</mo><mo>⟵</mo><mo>⟶</mo><mo>⟷</mo><mo>⟸</mo><mo>⟹</mo><mo>⟺</mo><mo>⟼</mo></mrow><annotation encoding="application/x-tex">← ↑ → ↓ ↔ ↕ ↖ ↗ ↘ ↙ ↚ ↛ ↞ ↠ ↢ ↣ ↦ ↩ ↪ ↫ ↬ ↭ ↮ ↰ ↱↶ ↷ ↺ ↻ ↼ ↽ ↾ ↾ ↿ ⇀ ⇁ ⇂ ⇃ ⇄ ⇆ ⇇ ⇈ ⇉ ⇊ ⇋ ⇌⇍ ⇎ ⇏ ⇐ ⇑ ⇒ ⇓ ⇔ ⇕ ⇚ ⇛ ⇝ ⇠ ⇢ ⟵ ⟶ ⟷ ⟸ ⟹ ⟺ ⟼</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mrel">←↑→↓↔↕↖↗↘↙</span></span><span class="base"><span class="strut" style="height:0.5359em;vertical-align:-0.0135em;"></span><span class="mrel amsrm">↚↛↞↠↢↣</span></span><span class="base"><span class="strut" style="height:0.522em;vertical-align:-0.011em;"></span><span class="mrel">↦↩↪</span></span><span class="base"><span class="strut" style="height:0.7742em;vertical-align:-0.082em;"></span><span class="mrel amsrm">↫↬↭↮↰↱↶↷↺↻</span></span><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">↼↽</span></span><span class="base"><span class="strut" style="height:0.8867em;vertical-align:-0.1944em;"></span><span class="mrel amsrm">↾↾↿</span></span><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">⇀⇁</span></span><span class="base"><span class="strut" style="height:0.8867em;vertical-align:-0.1944em;"></span><span class="mrel amsrm">⇂⇃⇄⇆⇇⇈⇉⇊⇋</span></span><span class="base"><span class="strut" style="height:0.682em;vertical-align:-0.011em;"></span><span class="mrel">⇌</span></span><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel amsrm">⇍⇎⇏</span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mrel">⇐⇑⇒⇓⇔⇕</span></span><span class="base"><span class="strut" style="height:0.7733em;vertical-align:-0.1367em;"></span><span class="mrel amsrm">⇚⇛⇝⇠⇢</span></span><span class="base"><span class="strut" style="height:0.549em;vertical-align:-0.024em;"></span><span class="mrel">⟵⟶⟷⟸⟹⟺⟼</span></span></span></span> ↽</p>
<p><strong>Extensible Arrows</strong></p>
<table>
<thead>
<tr>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mo stretchy="true" minsize="3.0em">←</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></mpadded></mover></mrow><annotation encoding="application/x-tex">\xleftarrow{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1191em;vertical-align:-0.011em;"></span><span class="mrel x-arrow"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1081em;"><span style="top:-3.322em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">ab</span><span class="mord mathnormal mtight">c</span></span></span></span><span class="svg-align" style="top:-2.689em;"><span class="pstrut" style="height:2.7em;"></span><span class="hide-tail" style="height:0.522em;min-width:1.469em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMinYMin slice'><path d='M400000 241H110l3-3c68.7-52.7 113.7-120
 135-202 4-14.7 6-23 6-25 0-7.3-7-11-21-11-8 0-13.2.8-15.5 2.5-2.3 1.7-4.2 5.8
-5.5 12.5-1.3 4.7-2.7 10.3-4 17-12 48.7-34.8 92-68.5 130S65.3 228.3 18 247
c-10 4-16 7.7-18 11 0 8.7 6 14.3 18 17 47.3 18.7 87.8 47 121.5 85S196 441.3 208
 490c.7 2 1.3 5 2 9s1.2 6.7 1.5 8c.3 1.3 1 3.3 2 6s2.2 4.5 3.5 5.5c1.3 1 3.3
 1.8 6 2.5s6 1 10 1c14 0 21-3.7 21-11 0-2-2-10.3-6-25-20-79.3-65-146.7-135-202
 l-3-3h399890zM100 241v40h399900v-40z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.011em;"><span></span></span></span></span></span></span></span></span> <code>\xleftarrow{abc}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><munderover><mo stretchy="true" minsize="3.0em">→</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>u</mi><mi>n</mi><mi>d</mi><mi>e</mi><mi>r</mi></mrow></mpadded><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>o</mi><mi>v</mi><mi>e</mi><mi>r</mi></mrow></mpadded></munderover></mrow><annotation encoding="application/x-tex">\xrightarrow[under]{over}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.5315em;vertical-align:-0.6081em;"></span><span class="mrel x-arrow"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.9234em;"><span style="top:-3.322em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">o</span><span class="mord mathnormal mtight" style="margin-right:0.03588em;">v</span><span class="mord mathnormal mtight" style="margin-right:0.02778em;">er</span></span></span></span><span class="svg-align" style="top:-2.689em;"><span class="pstrut" style="height:2.7em;"></span><span class="hide-tail" style="height:0.522em;min-width:1.469em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMaxYMin slice'><path d='M0 241v40h399891c-47.3 35.3-84 78-110 128
-16.7 32-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20
 11 8 0 13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7
 39-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85
-40.5-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5
-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67
 151.7 139 205zm0 0v40h399900v-40z'/></svg></span></span><span style="top:-2.0919em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">u</span><span class="mord mathnormal mtight">n</span><span class="mord mathnormal mtight">d</span><span class="mord mathnormal mtight" style="margin-right:0.02778em;">er</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.6081em;"><span></span></span></span></span></span></span></span></span> <code>\xrightarrow[under]{over}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mo stretchy="true" minsize="3.0em">⇐</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></mpadded></mover></mrow><annotation encoding="application/x-tex">\xLeftarrow{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1571em;vertical-align:-0.03em;"></span><span class="mrel x-arrow"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1271em;"><span style="top:-3.341em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">ab</span><span class="mord mathnormal mtight">c</span></span></span></span><span class="svg-align" style="top:-2.67em;"><span class="pstrut" style="height:2.7em;"></span><span class="hide-tail" style="height:0.56em;min-width:1.526em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.56em' viewBox='0 0 400000 560' preserveAspectRatio='xMinYMin slice'><path d='M262 157
l10-10c34-36 62.7-77 86-123 3.3-8 5-13.3 5-16 0-5.3-6.7-8-20-8-7.3
 0-12.2.5-14.5 1.5-2.3 1-4.8 4.5-7.5 10.5-49.3 97.3-121.7 169.3-217 216-28
 14-57.3 25-88 33-6.7 2-11 3.8-13 5.5-2 1.7-3 4.2-3 7.5s1 5.8 3 7.5
c2 1.7 6.3 3.5 13 5.5 68 17.3 128.2 47.8 180.5 91.5 52.3 43.7 93.8 96.2 124.5
 157.5 9.3 8 15.3 12.3 18 13h6c12-.7 18-4 18-10 0-2-1.7-7-5-15-23.3-46-52-87
-86-123l-10-10h399738v-40H218c328 0 0 0 0 0l-10-8c-26.7-20-65.7-43-117-69 2.7
-2 6-3.7 10-5 36.7-16 72.3-37.3 107-64l10-8h399782v-40z
m8 0v40h399730v-40zm0 194v40h399730v-40z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.03em;"><span></span></span></span></span></span></span></span></span> <code>\xLeftarrow{abc}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mo stretchy="true" minsize="3.0em">⇒</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></mpadded></mover></mrow><annotation encoding="application/x-tex">\xRightarrow{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1571em;vertical-align:-0.03em;"></span><span class="mrel x-arrow"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1271em;"><span style="top:-3.341em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">ab</span><span class="mord mathnormal mtight">c</span></span></span></span><span class="svg-align" style="top:-2.67em;"><span class="pstrut" style="height:2.7em;"></span><span class="hide-tail" style="height:0.56em;min-width:1.526em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.56em' viewBox='0 0 400000 560' preserveAspectRatio='xMaxYMin slice'><path d='M399738 392l
-10 10c-34 36-62.7 77-86 123-3.3 8-5 13.3-5 16 0 5.3 6.7 8 20 8 7.3 0 12.2-.5
 14.5-1.5 2.3-1 4.8-4.5 7.5-10.5 49.3-97.3 121.7-169.3 217-216 28-14 57.3-25 88
-33 6.7-2 11-3.8 13-5.5 2-1.7 3-4.2 3-7.5s-1-5.8-3-7.5c-2-1.7-6.3-3.5-13-5.5-68
-17.3-128.2-47.8-180.5-91.5-52.3-43.7-93.8-96.2-124.5-157.5-9.3-8-15.3-12.3-18
-13h-6c-12 .7-18 4-18 10 0 2 1.7 7 5 15 23.3 46 52 87 86 123l10 10H0v40h399782
c-328 0 0 0 0 0l10 8c26.7 20 65.7 43 117 69-2.7 2-6 3.7-10 5-36.7 16-72.3 37.3
-107 64l-10 8H0v40zM0 157v40h399730v-40zm0 194v40h399730v-40z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.03em;"><span></span></span></span></span></span></span></span></span> <code>\xRightarrow{abc}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mo stretchy="true" minsize="3.0em">↔</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></mpadded></mover></mrow><annotation encoding="application/x-tex">\xleftrightarrow{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1191em;vertical-align:-0.011em;"></span><span class="mrel x-arrow"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1081em;"><span style="top:-3.322em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">ab</span><span class="mord mathnormal mtight">c</span></span></span></span><span class="svg-align" style="top:-2.689em;"><span class="pstrut" style="height:2.7em;"></span><span class="stretchy" style="height:0.522em;min-width:1.75em;"><span class="halfarrow-left" style="height:0.522em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMinYMin slice'><path d='M400000 241H110l3-3c68.7-52.7 113.7-120
 135-202 4-14.7 6-23 6-25 0-7.3-7-11-21-11-8 0-13.2.8-15.5 2.5-2.3 1.7-4.2 5.8
-5.5 12.5-1.3 4.7-2.7 10.3-4 17-12 48.7-34.8 92-68.5 130S65.3 228.3 18 247
c-10 4-16 7.7-18 11 0 8.7 6 14.3 18 17 47.3 18.7 87.8 47 121.5 85S196 441.3 208
 490c.7 2 1.3 5 2 9s1.2 6.7 1.5 8c.3 1.3 1 3.3 2 6s2.2 4.5 3.5 5.5c1.3 1 3.3
 1.8 6 2.5s6 1 10 1c14 0 21-3.7 21-11 0-2-2-10.3-6-25-20-79.3-65-146.7-135-202
 l-3-3h399890zM100 241v40h399900v-40z'/></svg></span><span class="halfarrow-right" style="height:0.522em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMaxYMin slice'><path d='M0 241v40h399891c-47.3 35.3-84 78-110 128
-16.7 32-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20
 11 8 0 13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7
 39-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85
-40.5-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5
-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67
 151.7 139 205zm0 0v40h399900v-40z'/></svg></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.011em;"><span></span></span></span></span></span></span></span></span> <code>\xleftrightarrow{abc}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mo stretchy="true" minsize="3.0em">⇔</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></mpadded></mover></mrow><annotation encoding="application/x-tex">\xLeftrightarrow{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1571em;vertical-align:-0.03em;"></span><span class="mrel x-arrow"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1271em;"><span style="top:-3.341em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">ab</span><span class="mord mathnormal mtight">c</span></span></span></span><span class="svg-align" style="top:-2.67em;"><span class="pstrut" style="height:2.7em;"></span><span class="stretchy" style="height:0.56em;min-width:1.75em;"><span class="halfarrow-left" style="height:0.56em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.56em' viewBox='0 0 400000 560' preserveAspectRatio='xMinYMin slice'><path d='M262 157
l10-10c34-36 62.7-77 86-123 3.3-8 5-13.3 5-16 0-5.3-6.7-8-20-8-7.3
 0-12.2.5-14.5 1.5-2.3 1-4.8 4.5-7.5 10.5-49.3 97.3-121.7 169.3-217 216-28
 14-57.3 25-88 33-6.7 2-11 3.8-13 5.5-2 1.7-3 4.2-3 7.5s1 5.8 3 7.5
c2 1.7 6.3 3.5 13 5.5 68 17.3 128.2 47.8 180.5 91.5 52.3 43.7 93.8 96.2 124.5
 157.5 9.3 8 15.3 12.3 18 13h6c12-.7 18-4 18-10 0-2-1.7-7-5-15-23.3-46-52-87
-86-123l-10-10h399738v-40H218c328 0 0 0 0 0l-10-8c-26.7-20-65.7-43-117-69 2.7
-2 6-3.7 10-5 36.7-16 72.3-37.3 107-64l10-8h399782v-40z
m8 0v40h399730v-40zm0 194v40h399730v-40z'/></svg></span><span class="halfarrow-right" style="height:0.56em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.56em' viewBox='0 0 400000 560' preserveAspectRatio='xMaxYMin slice'><path d='M399738 392l
-10 10c-34 36-62.7 77-86 123-3.3 8-5 13.3-5 16 0 5.3 6.7 8 20 8 7.3 0 12.2-.5
 14.5-1.5 2.3-1 4.8-4.5 7.5-10.5 49.3-97.3 121.7-169.3 217-216 28-14 57.3-25 88
-33 6.7-2 11-3.8 13-5.5 2-1.7 3-4.2 3-7.5s-1-5.8-3-7.5c-2-1.7-6.3-3.5-13-5.5-68
-17.3-128.2-47.8-180.5-91.5-52.3-43.7-93.8-96.2-124.5-157.5-9.3-8-15.3-12.3-18
-13h-6c-12 .7-18 4-18 10 0 2 1.7 7 5 15 23.3 46 52 87 86 123l10 10H0v40h399782
c-328 0 0 0 0 0l10 8c26.7 20 65.7 43 117 69-2.7 2-6 3.7-10 5-36.7 16-72.3 37.3
-107 64l-10 8H0v40zM0 157v40h399730v-40zm0 194v40h399730v-40z'/></svg></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.03em;"><span></span></span></span></span></span></span></span></span> <code>\xLeftrightarrow{abc}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mo stretchy="true" minsize="3.0em">↩</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></mpadded></mover></mrow><annotation encoding="application/x-tex">\xhookleftarrow{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1191em;vertical-align:-0.011em;"></span><span class="mrel x-arrow"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1081em;"><span style="top:-3.322em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">ab</span><span class="mord mathnormal mtight">c</span></span></span></span><span class="svg-align" style="top:-2.689em;"><span class="pstrut" style="height:2.7em;"></span><span class="stretchy" style="height:0.522em;min-width:1.08em;"><span class="halfarrow-left" style="height:0.522em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMinYMin slice'><path d='M400000 241H110l3-3c68.7-52.7 113.7-120
 135-202 4-14.7 6-23 6-25 0-7.3-7-11-21-11-8 0-13.2.8-15.5 2.5-2.3 1.7-4.2 5.8
-5.5 12.5-1.3 4.7-2.7 10.3-4 17-12 48.7-34.8 92-68.5 130S65.3 228.3 18 247
c-10 4-16 7.7-18 11 0 8.7 6 14.3 18 17 47.3 18.7 87.8 47 121.5 85S196 441.3 208
 490c.7 2 1.3 5 2 9s1.2 6.7 1.5 8c.3 1.3 1 3.3 2 6s2.2 4.5 3.5 5.5c1.3 1 3.3
 1.8 6 2.5s6 1 10 1c14 0 21-3.7 21-11 0-2-2-10.3-6-25-20-79.3-65-146.7-135-202
 l-3-3h399890zM100 241v40h399900v-40z'/></svg></span><span class="halfarrow-right" style="height:0.522em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMaxYMin slice'><path d='M399859 241c-764 0 0 0 0 0 40-3.3 68.7-15.7 86-37 10-12 15-25.3
 15-40 0-22.7-9.8-40.7-29.5-54-19.7-13.3-43.5-21-71.5-23-17.3-1.3-26-8-26-20 0
-13.3 8.7-20 26-20 38 0 71 11.2 99 33.5 0 0 7 5.6 21 16.7 14 11.2 21 33.5 21
 66.8s-14 61.2-42 83.5c-28 22.3-61 33.5-99 33.5L0 241z M0 281v-40h399859v40z'/></svg></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.011em;"><span></span></span></span></span></span></span></span></span> <code>\xhookleftarrow{abc}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mo stretchy="true" minsize="3.0em">↪</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></mpadded></mover></mrow><annotation encoding="application/x-tex">\xhookrightarrow{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1191em;vertical-align:-0.011em;"></span><span class="mrel x-arrow"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1081em;"><span style="top:-3.322em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">ab</span><span class="mord mathnormal mtight">c</span></span></span></span><span class="svg-align" style="top:-2.689em;"><span class="pstrut" style="height:2.7em;"></span><span class="stretchy" style="height:0.522em;min-width:1.08em;"><span class="halfarrow-left" style="height:0.522em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMinYMin slice'><path d='M400000 281 H103s-33-11.2-61-33.5S0 197.3 0 164s14.2-61.2 42.5
-83.5C70.8 58.2 104 47 142 47 c16.7 0 25 6.7 25 20 0 12-8.7 18.7-26 20-40 3.3
-68.7 15.7-86 37-10 12-15 25.3-15 40 0 22.7 9.8 40.7 29.5 54 19.7 13.3 43.5 21
 71.5 23h399859zM103 281v-40h399897v40z'/></svg></span><span class="halfarrow-right" style="height:0.522em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMaxYMin slice'><path d='M0 241v40h399891c-47.3 35.3-84 78-110 128
-16.7 32-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20
 11 8 0 13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7
 39-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85
-40.5-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5
-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67
 151.7 139 205zm0 0v40h399900v-40z'/></svg></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.011em;"><span></span></span></span></span></span></span></span></span> <code>\xhookrightarrow{abc}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mo stretchy="true" minsize="3.0em">↞</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></mpadded></mover></mrow><annotation encoding="application/x-tex">\xtwoheadleftarrow{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0141em;"></span><span class="mrel x-arrow"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:1.0141em;"><span style="top:-3.228em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">ab</span><span class="mord mathnormal mtight">c</span></span></span></span><span class="svg-align" style="top:-2.783em;"><span class="pstrut" style="height:2.7em;"></span><span class="hide-tail" style="height:0.334em;min-width:0.888em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.334em' viewBox='0 0 400000 334' preserveAspectRatio='xMinYMin slice'><path d='M0 167c68 40
 115.7 95.7 143 167h22c15.3 0 23-.3 23-1 0-1.3-5.3-13.7-16-37-18-35.3-41.3-69
-70-101l-7-8h125l9 7c50.7 39.3 85 86 103 140h46c0-4.7-6.3-18.7-19-42-18-35.3
-40-67.3-66-96l-9-9h399716v-40H284l9-9c26-28.7 48-60.7 66-96 12.7-23.333 19
-37.333 19-42h-46c-18 54-52.3 100.7-103 140l-9 7H95l7-8c28.7-32 52-65.7 70-101
 10.7-23.333 16-35.7 16-37 0-.7-7.7-1-23-1h-22C115.7 71.3 68 127 0 167z'/></svg></span></span></span></span></span></span></span></span></span> <code>\xtwoheadleftarrow{abc}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mo stretchy="true" minsize="3.0em">↠</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></mpadded></mover></mrow><annotation encoding="application/x-tex">\xtwoheadrightarrow{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0141em;"></span><span class="mrel x-arrow"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:1.0141em;"><span style="top:-3.228em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">ab</span><span class="mord mathnormal mtight">c</span></span></span></span><span class="svg-align" style="top:-2.783em;"><span class="pstrut" style="height:2.7em;"></span><span class="hide-tail" style="height:0.334em;min-width:0.888em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.334em' viewBox='0 0 400000 334' preserveAspectRatio='xMaxYMin slice'><path d='M400000 167
c-68-40-115.7-95.7-143-167h-22c-15.3 0-23 .3-23 1 0 1.3 5.3 13.7 16 37 18 35.3
 41.3 69 70 101l7 8h-125l-9-7c-50.7-39.3-85-86-103-140h-46c0 4.7 6.3 18.7 19 42
 18 35.3 40 67.3 66 96l9 9H0v40h399716l-9 9c-26 28.7-48 60.7-66 96-12.7 23.333
-19 37.333-19 42h46c18-54 52.3-100.7 103-140l9-7h125l-7 8c-28.7 32-52 65.7-70
 101-10.7 23.333-16 35.7-16 37 0 .7 7.7 1 23 1h22c27.3-71.3 75-127 143-167z'/></svg></span></span></span></span></span></span></span></span></span> <code>\xtwoheadrightarrow{abc}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mo stretchy="true" minsize="3.0em">↼</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></mpadded></mover></mrow><annotation encoding="application/x-tex">\xleftharpoonup{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1191em;vertical-align:-0.011em;"></span><span class="mrel x-arrow"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1081em;"><span style="top:-3.322em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">ab</span><span class="mord mathnormal mtight">c</span></span></span></span><span class="svg-align" style="top:-2.689em;"><span class="pstrut" style="height:2.7em;"></span><span class="hide-tail" style="height:0.522em;min-width:0.888em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMinYMin slice'><path d='M0 267c.7 5.3 3 10 7 14h399993v-40H93c3.3
-3.3 10.2-9.5 20.5-18.5s17.8-15.8 22.5-20.5c50.7-52 88-110.3 112-175 4-11.3 5
-18.3 3-21-1.3-4-7.3-6-18-6-8 0-13 .7-15 2s-4.7 6.7-8 16c-42 98.7-107.3 174.7
-196 228-6.7 4.7-10.7 8-12 10-1.3 2-2 5.7-2 11zm100-26v40h399900v-40z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.011em;"><span></span></span></span></span></span></span></span></span> <code>\xleftharpoonup{abc}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mo stretchy="true" minsize="3.0em">⇀</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></mpadded></mover></mrow><annotation encoding="application/x-tex">\xrightharpoonup{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1191em;vertical-align:-0.011em;"></span><span class="mrel x-arrow"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1081em;"><span style="top:-3.322em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">ab</span><span class="mord mathnormal mtight">c</span></span></span></span><span class="svg-align" style="top:-2.689em;"><span class="pstrut" style="height:2.7em;"></span><span class="hide-tail" style="height:0.522em;min-width:0.888em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMaxYMin slice'><path d='M0 241v40h399993c4.7-4.7 7-9.3 7-14 0-9.3
-3.7-15.3-11-18-92.7-56.7-159-133.7-199-231-3.3-9.3-6-14.7-8-16-2-1.3-7-2-15-2
-10.7 0-16.7 2-18 6-2 2.7-1 9.7 3 21 15.3 42 36.7 81.8 64 119.5 27.3 37.7 58
 69.2 92 94.5zm0 0v40h399900v-40z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.011em;"><span></span></span></span></span></span></span></span></span> <code>\xrightharpoonup{abc}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mo stretchy="true" minsize="3.0em">↽</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></mpadded></mover></mrow><annotation encoding="application/x-tex">\xleftharpoondown{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1191em;vertical-align:-0.011em;"></span><span class="mrel x-arrow"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1081em;"><span style="top:-3.322em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">ab</span><span class="mord mathnormal mtight">c</span></span></span></span><span class="svg-align" style="top:-2.689em;"><span class="pstrut" style="height:2.7em;"></span><span class="hide-tail" style="height:0.522em;min-width:0.888em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMinYMin slice'><path d='M7 241c-4 4-6.333 8.667-7 14 0 5.333.667 9 2 11s5.333
 5.333 12 10c90.667 54 156 130 196 228 3.333 10.667 6.333 16.333 9 17 2 .667 5
 1 9 1h5c10.667 0 16.667-2 18-6 2-2.667 1-9.667-3-21-32-87.333-82.667-157.667
-152-211l-3-3h399907v-40zM93 281 H400000 v-40L7 241z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.011em;"><span></span></span></span></span></span></span></span></span> <code>\xleftharpoondown{abc}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mo stretchy="true" minsize="3.0em">⇁</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></mpadded></mover></mrow><annotation encoding="application/x-tex">\xrightharpoondown{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1191em;vertical-align:-0.011em;"></span><span class="mrel x-arrow"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1081em;"><span style="top:-3.322em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">ab</span><span class="mord mathnormal mtight">c</span></span></span></span><span class="svg-align" style="top:-2.689em;"><span class="pstrut" style="height:2.7em;"></span><span class="hide-tail" style="height:0.522em;min-width:0.888em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMaxYMin slice'><path d='M399747 511c0 7.3 6.7 11 20 11 8 0 13-.8 15-2.5s4.7-6.8
 8-15.5c40-94 99.3-166.3 178-217 13.3-8 20.3-12.3 21-13 5.3-3.3 8.5-5.8 9.5
-7.5 1-1.7 1.5-5.2 1.5-10.5s-2.3-10.3-7-15H0v40h399908c-34 25.3-64.7 57-92 95
-27.3 38-48.7 77.7-64 119-3.3 8.7-5 14-5 16zM0 241v40h399900v-40z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.011em;"><span></span></span></span></span></span></span></span></span> <code>\xrightharpoondown{abc}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mo stretchy="true" minsize="3.0em">⇋</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></mpadded></mover></mrow><annotation encoding="application/x-tex">\xleftrightharpoons{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.3131em;vertical-align:-0.108em;"></span><span class="mrel x-arrow"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.2051em;"><span style="top:-3.435em;"><span class="pstrut" style="height:2.716em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">ab</span><span class="mord mathnormal mtight">c</span></span></span></span><span class="svg-align" style="top:-2.608em;"><span class="pstrut" style="height:2.716em;"></span><span class="stretchy" style="height:0.716em;min-width:1.75em;"><span class="halfarrow-left" style="height:0.716em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.716em' viewBox='0 0 400000 716' preserveAspectRatio='xMinYMin slice'><path d='M0 267c.7 5.3 3 10 7 14h399993v-40H93c3.3-3.3 10.2-9.5
 20.5-18.5s17.8-15.8 22.5-20.5c50.7-52 88-110.3 112-175 4-11.3 5-18.3 3-21-1.3
-4-7.3-6-18-6-8 0-13 .7-15 2s-4.7 6.7-8 16c-42 98.7-107.3 174.7-196 228-6.7 4.7
-10.7 8-12 10-1.3 2-2 5.7-2 11zm100-26v40h399900v-40zM0 435v40h400000v-40z
m0 0v40h400000v-40z'/></svg></span><span class="halfarrow-right" style="height:0.716em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.716em' viewBox='0 0 400000 716' preserveAspectRatio='xMaxYMin slice'><path d='M399747 705c0 7.3 6.7 11 20 11 8 0 13-.8
 15-2.5s4.7-6.8 8-15.5c40-94 99.3-166.3 178-217 13.3-8 20.3-12.3 21-13 5.3-3.3
 8.5-5.8 9.5-7.5 1-1.7 1.5-5.2 1.5-10.5s-2.3-10.3-7-15H0v40h399908c-34 25.3
-64.7 57-92 95-27.3 38-48.7 77.7-64 119-3.3 8.7-5 14-5 16zM0 435v40h399900v-40z
m0-194v40h400000v-40zm0 0v40h400000v-40z'/></svg></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.108em;"><span></span></span></span></span></span></span></span></span> <code>\xleftrightharpoons{abc}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mo stretchy="true" minsize="3.0em">⇌</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></mpadded></mover></mrow><annotation encoding="application/x-tex">\xrightleftharpoons{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.3131em;vertical-align:-0.108em;"></span><span class="mrel x-arrow"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.2051em;"><span style="top:-3.435em;"><span class="pstrut" style="height:2.716em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">ab</span><span class="mord mathnormal mtight">c</span></span></span></span><span class="svg-align" style="top:-2.608em;"><span class="pstrut" style="height:2.716em;"></span><span class="stretchy" style="height:0.716em;min-width:1.75em;"><span class="halfarrow-left" style="height:0.716em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.716em' viewBox='0 0 400000 716' preserveAspectRatio='xMinYMin slice'><path d='M7 435c-4 4-6.3 8.7-7 14 0 5.3.7 9 2 11s5.3 5.3 12
 10c90.7 54 156 130 196 228 3.3 10.7 6.3 16.3 9 17 2 .7 5 1 9 1h5c10.7 0 16.7
-2 18-6 2-2.7 1-9.7-3-21-32-87.3-82.7-157.7-152-211l-3-3h399907v-40H7zm93 0
v40h399900v-40zM0 241v40h399900v-40zm0 0v40h399900v-40z'/></svg></span><span class="halfarrow-right" style="height:0.716em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.716em' viewBox='0 0 400000 716' preserveAspectRatio='xMaxYMin slice'><path d='M0 241v40h399993c4.7-4.7 7-9.3 7-14 0-9.3-3.7-15.3-11
-18-92.7-56.7-159-133.7-199-231-3.3-9.3-6-14.7-8-16-2-1.3-7-2-15-2-10.7 0-16.7
 2-18 6-2 2.7-1 9.7 3 21 15.3 42 36.7 81.8 64 119.5 27.3 37.7 58 69.2 92 94.5z
m0 0v40h399900v-40z m100 194v40h399900v-40zm0 0v40h399900v-40z'/></svg></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.108em;"><span></span></span></span></span></span></span></span></span> <code>\xrightleftharpoons{abc}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mo stretchy="true" minsize="3.0em">⇄</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></mpadded></mover></mrow><annotation encoding="application/x-tex">\xtofrom{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1251em;vertical-align:-0.014em;"></span><span class="mrel x-arrow"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1111em;"><span style="top:-3.325em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">ab</span><span class="mord mathnormal mtight">c</span></span></span></span><span class="svg-align" style="top:-2.686em;"><span class="pstrut" style="height:2.7em;"></span><span class="stretchy" style="height:0.528em;min-width:1.75em;"><span class="halfarrow-left" style="height:0.528em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.528em' viewBox='0 0 400000 528' preserveAspectRatio='xMinYMin slice'><path d='M0 147h400000v40H0zm0 214c68 40 115.7 95.7 143 167h22c15.3 0 23
-.3 23-1 0-1.3-5.3-13.7-16-37-18-35.3-41.3-69-70-101l-7-8h399905v-40H95l7-8
c28.7-32 52-65.7 70-101 10.7-23.3 16-35.7 16-37 0-.7-7.7-1-23-1h-22C115.7 265.3
 68 321 0 361zm0-174v-40h399900v40zm100 154v40h399900v-40z'/></svg></span><span class="halfarrow-right" style="height:0.528em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.528em' viewBox='0 0 400000 528' preserveAspectRatio='xMaxYMin slice'><path d='M400000 167c-70.7-42-118-97.7-142-167h-23c-15.3 0-23 .3-23
 1 0 1.3 5.3 13.7 16 37 18 35.3 41.3 69 70 101l7 8H0v40h399905l-7 8c-28.7 32
-52 65.7-70 101-10.7 23.3-16 35.7-16 37 0 .7 7.7 1 23 1h23c24-69.3 71.3-125 142
-167z M100 147v40h399900v-40zM0 341v40h399900v-40z'/></svg></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.014em;"><span></span></span></span></span></span></span></span></span> <code>\xtofrom{abc}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mo stretchy="true" minsize="3.0em">↦</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></mpadded></mover></mrow><annotation encoding="application/x-tex">\xmapsto{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1191em;vertical-align:-0.011em;"></span><span class="mrel x-arrow"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1081em;"><span style="top:-3.322em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">ab</span><span class="mord mathnormal mtight">c</span></span></span></span><span class="svg-align" style="top:-2.689em;"><span class="pstrut" style="height:2.7em;"></span><span class="stretchy" style="height:0.522em;min-width:1.5em;"><span class="halfarrow-left" style="height:0.522em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMinYMin slice'><path d='M40 281 V448H0V74H40V241H400000v40z
M40 281 V448H0V74H40V241H400000v40z'/></svg></span><span class="halfarrow-right" style="height:0.522em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMaxYMin slice'><path d='M0 241v40h399891c-47.3 35.3-84 78-110 128
-16.7 32-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20
 11 8 0 13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7
 39-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85
-40.5-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5
-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67
 151.7 139 205zm0 0v40h399900v-40z'/></svg></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.011em;"><span></span></span></span></span></span></span></span></span> <code>\xmapsto{abc}</code></td>
</tr>
</tbody>
</table>
<p>|<span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mo stretchy="true" minsize="3.0em">=</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></mpadded></mover></mrow><annotation encoding="application/x-tex">\xlongequal{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0141em;"></span><span class="mrel x-arrow"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:1.0141em;"><span style="top:-3.228em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">ab</span><span class="mord mathnormal mtight">c</span></span></span></span><span class="svg-align" style="top:-2.783em;"><span class="pstrut" style="height:2.7em;"></span><span class="hide-tail" style="height:0.334em;min-width:0.888em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.334em' viewBox='0 0 400000 334' preserveAspectRatio='xMinYMin slice'><path d='M0 50 h400000 v40H0z m0 194h40000v40H0z
M0 50 h400000 v40H0z m0 194h40000v40H0z'/></svg></span></span></span></span></span></span></span></span></span> <code>\xlongequal{abc}</code></p>
<p>Extensible arrows all can take an optional argument in the same manner, as <code>\xrightarrow[under]{over}</code>.</p>
<h2 id="_11-style-color-size-and-font" tabindex="-1">11: Style, Color, Size, and Font <a class="header-anchor" href="#_11-style-color-size-and-font" aria-label="Permalink to &quot;11: Style, Color, Size, and Font&quot;">&ZeroWidthSpace;</a></h2>
<p><strong>Class Assignment</strong></p>
<ul>
<li>
<p><code>\mathbin</code> <code>\mathclose</code> <code>\mathinner</code> <code>\mathop</code></p>
</li>
<li>
<p><code>\mathopen</code> <code>\mathord</code> <code>\mathpunct</code> <code>\mathrel</code></p>
</li>
</ul>
<p><strong>Color</strong></p>
<p><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathcolor="blue"><mi>F</mi><mo>=</mo><mi>m</mi><mi>a</mi></mstyle></mrow><annotation encoding="application/x-tex">\color{blue} F=ma</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.13889em;color:blue;">F</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel" style="color:blue;">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal" style="color:blue;">ma</span></span></span></span> <code>\color{blue} F=ma</code></p>
<p>Note that KaTeX <code>\color</code> acts like a switch. This aligns with LaTeX and differs from MathJax.
Other KaTeX color functions expect the content to be a function argument:</p>
<ul>
<li><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathcolor="blue"><mi>F</mi><mo>=</mo><mi>m</mi><mi>a</mi></mstyle></mrow><annotation encoding="application/x-tex">\textcolor{blue}{F=ma}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.13889em;color:blue;">F</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel" style="color:blue;">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal" style="color:blue;">ma</span></span></span></span> <code>\textcolor{blue}{F=ma}</code></li>
<li><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathcolor="#228B22"><mi>F</mi><mo>=</mo><mi>m</mi><mi>a</mi></mstyle></mrow><annotation encoding="application/x-tex">\textcolor{#228B22}{F=ma}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.13889em;color:#228B22;">F</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel" style="color:#228B22;">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal" style="color:#228B22;">ma</span></span></span></span> <code>\textcolor{#228B22}{F=ma}</code></li>
<li><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mpadded width="+6pt" height="+6pt" lspace="3pt" voffset="3pt" mathbackground="aqua"><mtext>A</mtext></mpadded></mrow><annotation encoding="application/x-tex">\colorbox{aqua}{A}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2833em;vertical-align:-0.3em;"></span><span class="mord"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.9833em;"><span style="top:-2.9833em;"><span class="pstrut" style="height:3.2833em;"></span><span class="stretchy colorbox" style="height:1.2833em;background-color:aqua;"></span></span><span style="top:-3.2833em;"><span class="pstrut" style="height:3.2833em;"></span><span class="mord boxpad"><span class="mord">A</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.3em;"><span></span></span></span></span></span></span></span></span> <code>\colorbox{aqua}{A}</code></li>
<li><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mpadded width="+6pt" height="+6pt" lspace="3pt" voffset="3pt" style="border: 0.04em solid red" mathbackground="aqua"><mtext>A</mtext></mpadded></mrow><annotation encoding="application/x-tex">\fcolorbox{red}{aqua}{A}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.3633em;vertical-align:-0.34em;"></span><span class="mord"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.0233em;"><span style="top:-3.0233em;"><span class="pstrut" style="height:3.3633em;"></span><span class="stretchy fcolorbox" style="height:1.3633em;border-style:solid;border-width:0.04em;background-color:aqua;border-color:red;"></span></span><span style="top:-3.3633em;"><span class="pstrut" style="height:3.3633em;"></span><span class="mord boxpad"><span class="mord">A</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.34em;"><span></span></span></span></span></span></span></span></span> <code>\fcolorbox{red}{aqua}{A}</code></li>
</ul>
<p>For color definition, KaTeX color functions will accept the standard HTML <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/color_value#Color_keywords" target="_blank" rel="noreferrer">predefined color names</a>. They will also accept an RGB argument in CSS hexa­decimal style. The &quot;#&quot; is optional before a six-digit specification.</p>
<p><strong>Font</strong></p>
<table>
<thead>
<tr>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">A</mi><mi mathvariant="normal">b</mi><mn>0</mn></mrow><annotation encoding="application/x-tex">\mathrm{Ab0}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord"><span class="mord mathrm">Ab0</span></span></span></span></span> <code>\mathrm{Ab0}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="bold">A</mi><mi mathvariant="bold">b</mi><mn mathvariant="bold">0</mn></mrow><annotation encoding="application/x-tex">\mathbf{Ab0}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord"><span class="mord mathbf">Ab0</span></span></span></span></span> <code>\mathbf{Ab0}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>A</mi><mi>b</mi></mrow><annotation encoding="application/x-tex">\mathit{Ab}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord"><span class="mord mathit">Ab</span></span></span></span></span> <code>\mathit{Ab}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>A</mi><mi>b</mi><mn>0</mn></mrow><annotation encoding="application/x-tex">\mathnormal{Ab0}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord"><span class="mord mathnormal">A</span><span class="mord mathnormal">b0</span></span></span></span></span> <code>\mathnormal{Ab0}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext mathvariant="bold">Ab0</mtext></mrow><annotation encoding="application/x-tex">\textbf{Ab0}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord textbf">Ab0</span></span></span></span></span> <code>\textbf{Ab0}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext mathvariant="italic">Ab</mtext></mrow><annotation encoding="application/x-tex">\textit{Ab}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord textit">Ab</span></span></span></span></span> <code>\textit{Ab}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>Ab0</mtext></mrow><annotation encoding="application/x-tex">\textrm{Ab0}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord textrm">Ab0</span></span></span></span></span> <code>\textrm{Ab0}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="bold">A</mi><mi mathvariant="bold">b</mi><mn mathvariant="bold">0</mn></mrow><annotation encoding="application/x-tex">\bf Ab0</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord"><span class="mord mathbf">Ab0</span></span></span></span></span> <code>\bf Ab0</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>A</mi><mi>b</mi></mrow><annotation encoding="application/x-tex">\it Ab</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord"><span class="mord mathit">Ab</span></span></span></span></span> <code>\it Ab</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">A</mi><mi mathvariant="normal">b</mi><mn>0</mn></mrow><annotation encoding="application/x-tex">\rm Ab0</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord"><span class="mord mathrm">Ab0</span></span></span></span></span> <code>\rm Ab0</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="bold">A</mi><mi mathvariant="bold">b</mi><mn mathvariant="bold">0</mn></mrow><annotation encoding="application/x-tex">\bold{Ab0}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord"><span class="mord mathbf">Ab0</span></span></span></span></span> <code>\bold{Ab0}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="double-struck">A</mi><mi mathvariant="double-struck">B</mi></mrow><annotation encoding="application/x-tex">\Bbb{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord"><span class="mord mathbb">AB</span></span></span></span></span> <code>\Bbb{AB}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>Ab0</mtext></mrow><annotation encoding="application/x-tex">\textnormal{Ab0}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord textrm">Ab0</span></span></span></span></span> <code>\textnormal{Ab0}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi><mrow><mi mathvariant="bold-italic">A</mi><mi mathvariant="bold-italic">b</mi></mrow></mi></mrow><annotation encoding="application/x-tex">\boldsymbol{Ab}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol">Ab</span></span></span></span></span></span> <code>\boldsymbol{Ab}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="double-struck">A</mi><mi mathvariant="double-struck">B</mi></mrow><annotation encoding="application/x-tex">\mathbb{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord"><span class="mord mathbb">AB</span></span></span></span></span> <code>\mathbb{AB}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>Ab0</mtext></mrow><annotation encoding="application/x-tex">\text{Ab0}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord">Ab0</span></span></span></span></span> <code>\text{Ab0}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi><mrow><mi mathvariant="bold-italic">A</mi><mi mathvariant="bold-italic">b</mi></mrow></mi></mrow><annotation encoding="application/x-tex">\bm{Ab}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol">Ab</span></span></span></span></span></span> <code>\bm{Ab}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="fraktur">A</mi><mi mathvariant="fraktur">b</mi><mn mathvariant="fraktur">0</mn></mrow><annotation encoding="application/x-tex">\frak{Ab0}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6914em;"></span><span class="mord"><span class="mord mathfrak">Ab0</span></span></span></span></span> <code>\frak{Ab0}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="sans-serif">A</mi><mi mathvariant="sans-serif">b</mi><mn mathvariant="sans-serif">0</mn></mrow><annotation encoding="application/x-tex">\mathsf{Ab0}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord"><span class="mord mathsf">Ab0</span></span></span></span></span> <code>\mathsf{Ab0}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="monospace">A</mi><mi mathvariant="monospace">b</mi><mn mathvariant="monospace">0</mn></mrow><annotation encoding="application/x-tex">\mathtt{Ab0}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6111em;"></span><span class="mord"><span class="mord mathtt">Ab0</span></span></span></span></span> <code>\mathtt{Ab0}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="fraktur">A</mi><mi mathvariant="fraktur">b</mi><mn mathvariant="fraktur">0</mn></mrow><annotation encoding="application/x-tex">\mathfrak{Ab0}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6914em;"></span><span class="mord"><span class="mord mathfrak">Ab0</span></span></span></span></span> <code>\mathfrak{Ab0}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext mathvariant="sans-serif">Ab0</mtext></mrow><annotation encoding="application/x-tex">\textsf{Ab0}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord textsf">Ab0</span></span></span></span></span> <code>\textsf{Ab0}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext mathvariant="monospace">Ab0</mtext></mrow><annotation encoding="application/x-tex">\texttt{Ab0}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6111em;"></span><span class="mord text"><span class="mord texttt">Ab0</span></span></span></span></span> <code>\texttt{Ab0}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="script">A</mi><mi mathvariant="script">B</mi><mn mathvariant="script">0</mn></mrow><annotation encoding="application/x-tex">\mathcal{AB0}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord"><span class="mord mathcal">A</span><span class="mord mathcal" style="margin-right:0.03041em;">B</span><span class="mord">0</span></span></span></span></span> <code>\mathcal{AB0}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="sans-serif">A</mi><mi mathvariant="sans-serif">b</mi><mn mathvariant="sans-serif">0</mn></mrow><annotation encoding="application/x-tex">\sf Ab0</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord"><span class="mord mathsf">Ab0</span></span></span></span></span> <code>\sf Ab0</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="monospace">A</mi><mi mathvariant="monospace">b</mi><mn mathvariant="monospace">0</mn></mrow><annotation encoding="application/x-tex">\tt Ab0</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6111em;"></span><span class="mord"><span class="mord mathtt">Ab0</span></span></span></span></span> <code>\tt Ab0</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="script">A</mi><mi mathvariant="script">B</mi></mrow><annotation encoding="application/x-tex">\mathscr{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7em;"></span><span class="mord"><span class="mord mathscr" style="margin-right:0.04087em;">AB</span></span></span></span></span> <code>\mathscr{AB}</code></td>
</tr>
</tbody>
</table>
<p>One can stack font family, font weight, and font shape by using the <code>\textXX</code> versions of the font functions. So <code>\textsf{\textbf{H}}</code> will produce <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext mathvariant="bold-sans-serif">H</mtext></mrow><annotation encoding="application/x-tex">\textsf{\textbf{H}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord text"><span class="mord textsf textbf">H</span></span></span></span></span></span>. The other versions do not stack, e.g., <code>\mathsf{\mathbf{H}}</code> will produce <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="bold">H</mi></mrow><annotation encoding="application/x-tex">\mathsf{\mathbf{H}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6861em;"></span><span class="mord mathbf">H</span></span></span></span>.</p>
<p>In cases where KaTeX fonts do not have a bold glyph, <code>\pmb</code> can simulate one. For example, <code>\pmb{\mu}</code> renders as : <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle style="text-shadow: 0.02em 0.01em 0.04px"><mi>μ</mi></mstyle></mrow><annotation encoding="application/x-tex">\pmb{\mu}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord" style="text-shadow:0.02em 0.01em 0.04px;"><span class="mord mathnormal">μ</span></span></span></span></span></p>
<p><strong>Size</strong></p>
<table>
<thead>
<tr>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathsize="2.488em"><mi>A</mi><mi>B</mi></mstyle></mrow><annotation encoding="application/x-tex">\Huge AB</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.7001em;"></span><span class="mord mathnormal sizing reset-size6 size11">A</span><span class="mord mathnormal sizing reset-size6 size11" style="margin-right:0.05017em;">B</span></span></span></span> <code>\Huge AB</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathsize="1em"><mi>A</mi><mi>B</mi></mstyle></mrow><annotation encoding="application/x-tex">\normalsize AB</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span></span> <code>\normalsize AB</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathsize="2.074em"><mi>A</mi><mi>B</mi></mstyle></mrow><annotation encoding="application/x-tex">\huge AB</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.4172em;"></span><span class="mord mathnormal sizing reset-size6 size10">A</span><span class="mord mathnormal sizing reset-size6 size10" style="margin-right:0.05017em;">B</span></span></span></span> <code>\huge AB</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathsize="0.9em"><mi>A</mi><mi>B</mi></mstyle></mrow><annotation encoding="application/x-tex">\small AB</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.615em;"></span><span class="mord mathnormal sizing reset-size6 size5">A</span><span class="mord mathnormal sizing reset-size6 size5" style="margin-right:0.05017em;">B</span></span></span></span> <code>\small AB</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathsize="1.728em"><mi>A</mi><mi>B</mi></mstyle></mrow><annotation encoding="application/x-tex">\LARGE AB</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1808em;"></span><span class="mord mathnormal sizing reset-size6 size9">A</span><span class="mord mathnormal sizing reset-size6 size9" style="margin-right:0.05017em;">B</span></span></span></span> <code>\LARGE AB</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathsize="0.8em"><mi>A</mi><mi>B</mi></mstyle></mrow><annotation encoding="application/x-tex">\footnotesize AB</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5467em;"></span><span class="mord mathnormal sizing reset-size6 size4">A</span><span class="mord mathnormal sizing reset-size6 size4" style="margin-right:0.05017em;">B</span></span></span></span> <code>\footnotesize AB</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathsize="1.44em"><mi>A</mi><mi>B</mi></mstyle></mrow><annotation encoding="application/x-tex">\Large AB</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.984em;"></span><span class="mord mathnormal sizing reset-size6 size8">A</span><span class="mord mathnormal sizing reset-size6 size8" style="margin-right:0.05017em;">B</span></span></span></span> <code>\Large AB</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathsize="0.7em"><mi>A</mi><mi>B</mi></mstyle></mrow><annotation encoding="application/x-tex">\scriptsize AB</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4783em;"></span><span class="mord mathnormal sizing reset-size6 size3">A</span><span class="mord mathnormal sizing reset-size6 size3" style="margin-right:0.05017em;">B</span></span></span></span> <code>\scriptsize AB</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathsize="1.2em"><mi>A</mi><mi>B</mi></mstyle></mrow><annotation encoding="application/x-tex">\large AB</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.82em;"></span><span class="mord mathnormal sizing reset-size6 size7">A</span><span class="mord mathnormal sizing reset-size6 size7" style="margin-right:0.05017em;">B</span></span></span></span> <code>\large AB</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathsize="0.5em"><mi>A</mi><mi>B</mi></mstyle></mrow><annotation encoding="application/x-tex">\tiny AB</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3417em;"></span><span class="mord mathnormal sizing reset-size6 size1">A</span><span class="mord mathnormal sizing reset-size6 size1" style="margin-right:0.05017em;">B</span></span></span></span> <code>\tiny AB</code></td>
</tr>
</tbody>
</table>
<p><strong>Style</strong></p>
<table>
<thead>
<tr>
<th style="text-align:left"></th>
</tr>
</thead>
</table>
<p>|<span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle scriptlevel="0" displaystyle="true"><munderover><mo>∑</mo><mrow><mi>i</mi><mo>=</mo><mn>1</mn></mrow><mi>n</mi></munderover></mstyle></mrow><annotation encoding="application/x-tex">\displaystyle\sum_{i=1}^n</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.9291em;vertical-align:-1.2777em;"></span><span class="mop op-limits"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.6514em;"><span style="top:-1.8723em;margin-left:0em;"><span class="pstrut" style="height:3.05em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">i</span><span class="mrel mtight">=</span><span class="mord mtight">1</span></span></span></span><span style="top:-3.05em;"><span class="pstrut" style="height:3.05em;"></span><span><span class="mop op-symbol large-op">∑</span></span></span><span style="top:-4.3em;margin-left:0em;"><span class="pstrut" style="height:3.05em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">n</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.2777em;"><span></span></span></span></span></span></span></span></span> <code>\displaystyle\sum_{i=1}^n</code>
|<span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle scriptlevel="0" displaystyle="false"><msubsup><mo>∑</mo><mrow><mi>i</mi><mo>=</mo><mn>1</mn></mrow><mi>n</mi></msubsup></mstyle></mrow><annotation encoding="application/x-tex">\textstyle\sum_{i=1}^n</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.104em;vertical-align:-0.2997em;"></span><span class="mop"><span class="mop op-symbol small-op" style="position:relative;top:0em;">∑</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8043em;"><span style="top:-2.4003em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">i</span><span class="mrel mtight">=</span><span class="mord mtight">1</span></span></span></span><span style="top:-3.2029em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">n</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2997em;"><span></span></span></span></span></span></span></span></span></span> <code>\textstyle\sum_{i=1}^n</code>
|<span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle scriptlevel="1" displaystyle="false"><mi>x</mi></mstyle></mrow><annotation encoding="application/x-tex">\scriptstyle x</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3014em;"></span><span class="mord mathnormal mtight sizing reset-size6 size3">x</span></span></span></span> <code>\scriptstyle x</code>         (The size of a first sub/superscript)
|<span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle scriptlevel="2" displaystyle="false"><mi>x</mi></mstyle></mrow><annotation encoding="application/x-tex">\scriptscriptstyle x</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.2153em;"></span><span class="mord mathnormal mtight sizing reset-size6 size1">x</span></span></span></span> <code>\scriptscriptstyle x</code> (The size of subsequent sub/superscripts)
|<span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><munder><mrow><mi>lim</mi><mo>⁡</mo></mrow><mi>x</mi></munder></mrow><annotation encoding="application/x-tex">\lim\limits_x</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.3944em;vertical-align:-0.7em;"></span><span class="mop op-limits"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6944em;"><span style="top:-2.4em;margin-left:0em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">x</span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span><span class="mop">lim</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.7em;"><span></span></span></span></span></span></span></span></span> <code>\lim\limits_x</code>
|<span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mrow><mi>lim</mi><mo>⁡</mo></mrow><mi>x</mi></msub></mrow><annotation encoding="application/x-tex">\lim\nolimits_x</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8444em;vertical-align:-0.15em;"></span><span class="mop"><span class="mop">lim</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">x</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> <code>\lim\nolimits_x</code>
|<span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext mathvariant="monospace">x^2</mtext></mrow><annotation encoding="application/x-tex">\verb!x^2!</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6111em;"></span><span class="mord text"><span class="mord texttt">x^2</span></span></span></span></span> <code>\verb!x^2!</code></p>
<p><code>\text{…}</code> will accept nested <code>$…$</code> fragments and render them in math mode.</p>
<h2 id="_12-symbols-and-punctuation" tabindex="-1">12: Symbols and Punctuation <a class="header-anchor" href="#_12-symbols-and-punctuation" aria-label="Permalink to &quot;12: Symbols and Punctuation&quot;">&ZeroWidthSpace;</a></h2>
<table>
<thead>
<tr>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left"><code>% comment</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>…</mo></mrow><annotation encoding="application/x-tex">\dots</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.123em;"></span><span class="minner">…</span></span></span></span> <code>\dots</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>KaTeX</mtext></mrow><annotation encoding="application/x-tex">\KaTeX</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8988em;vertical-align:-0.2155em;"></span><span class="mord text"><span class="mord textrm">K</span><span class="mspace" style="margin-right:-0.17em;"></span><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6833em;"><span style="top:-2.905em;"><span class="pstrut" style="height:2.7em;"></span><span class="mord"><span class="mord textrm mtight sizing reset-size6 size3">A</span></span></span></span></span></span><span class="mspace" style="margin-right:-0.15em;"></span><span class="mord text"><span class="mord textrm">T</span><span class="mspace" style="margin-right:-0.1667em;"></span><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.4678em;"><span style="top:-2.7845em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord textrm">E</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2155em;"><span></span></span></span></span><span class="mspace" style="margin-right:-0.125em;"></span><span class="mord textrm">X</span></span></span></span></span></span> <code>\KaTeX</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">%</mi></mrow><annotation encoding="application/x-tex">\%</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8056em;vertical-align:-0.0556em;"></span><span class="mord">%</span></span></span></span> <code>\%</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋯</mo></mrow><annotation encoding="application/x-tex">\cdots</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.313em;"></span><span class="minner">⋯</span></span></span></span> <code>\cdots</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>LaTeX</mtext></mrow><annotation encoding="application/x-tex">\LaTeX</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8988em;vertical-align:-0.2155em;"></span><span class="mord text"><span class="mord textrm">L</span><span class="mspace" style="margin-right:-0.36em;"></span><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6833em;"><span style="top:-2.905em;"><span class="pstrut" style="height:2.7em;"></span><span class="mord"><span class="mord textrm mtight sizing reset-size6 size3">A</span></span></span></span></span></span><span class="mspace" style="margin-right:-0.15em;"></span><span class="mord text"><span class="mord textrm">T</span><span class="mspace" style="margin-right:-0.1667em;"></span><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.4678em;"><span style="top:-2.7845em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord textrm">E</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2155em;"><span></span></span></span></span><span class="mspace" style="margin-right:-0.125em;"></span><span class="mord textrm">X</span></span></span></span></span></span> <code>\LaTeX</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">#</mi></mrow><annotation encoding="application/x-tex">\#</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord">#</span></span></span></span> <code>\#</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋱</mo></mrow><annotation encoding="application/x-tex">\ddots</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.823em;"></span><span class="minner">⋱</span></span></span></span> <code>\ddots</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>TeX</mtext></mrow><annotation encoding="application/x-tex">\TeX</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8988em;vertical-align:-0.2155em;"></span><span class="mord text"><span class="mord textrm">T</span><span class="mspace" style="margin-right:-0.1667em;"></span><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.4678em;"><span style="top:-2.7845em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord textrm">E</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2155em;"><span></span></span></span></span><span class="mspace" style="margin-right:-0.125em;"></span><span class="mord textrm">X</span></span></span></span></span> <code>\TeX</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">&amp;</mi></mrow><annotation encoding="application/x-tex">\&amp;</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">&amp;</span></span></span></span> <code>\&amp;</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>…</mo></mrow><annotation encoding="application/x-tex">\ldots</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.123em;"></span><span class="minner">…</span></span></span></span> <code>\ldots</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∇</mi></mrow><annotation encoding="application/x-tex">\nabla</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">∇</span></span></span></span> <code>\nabla</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">_</mi></mrow><annotation encoding="application/x-tex">\_</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;vertical-align:-0.31em;"></span><span class="mord" style="margin-right:0.02778em;">_</span></span></span></span> <code>\_</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi><mi mathvariant="normal">⋮</mi><mpadded height="0em" voffset="0em"><mspace mathbackground="black" width="0em" height="1.5em"></mspace></mpadded></mi></mrow><annotation encoding="application/x-tex">\vdots</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.53em;vertical-align:-0.03em;"></span><span class="mord"><span class="mord">⋮</span><span class="mord rule" style="border-right-width:0em;border-top-width:1.5em;bottom:0em;"></span></span></span></span></span> <code>\vdots</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∞</mi></mrow><annotation encoding="application/x-tex">\infty</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord">∞</span></span></span></span> <code>\infty</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>_</mtext></mrow><annotation encoding="application/x-tex">\text{\textunderscore}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;vertical-align:-0.31em;"></span><span class="mord text"><span class="mord">_</span></span></span></span></span> <code>\text{\textunderscore}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋯</mo></mrow><annotation encoding="application/x-tex">\dotsb</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.313em;"></span><span class="minner">⋯</span></span></span></span> <code>\dotsb</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∞</mi></mrow><annotation encoding="application/x-tex">\infin</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord">∞</span></span></span></span> <code>\infin</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>–</mtext></mrow><annotation encoding="application/x-tex">\text{--}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord text"><span class="mord">–</span></span></span></span></span> <code>\text{--}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>…</mo></mrow><annotation encoding="application/x-tex">\dotsc</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.123em;"></span><span class="minner">…</span></span></span></span> <code>\dotsc</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">✓</mi></mrow><annotation encoding="application/x-tex">\checkmark</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mord amsrm">✓</span></span></span></span> <code>\checkmark</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>–</mtext></mrow><annotation encoding="application/x-tex">\text{\textendash}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord text"><span class="mord">–</span></span></span></span></span> <code>\text{\textendash}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext> ⁣</mtext><mo>⋯</mo></mrow><annotation encoding="application/x-tex">\dotsi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.313em;"></span><span class="mspace" style="margin-right:-0.1667em;"></span><span class="minner">⋯</span></span></span></span> <code>\dotsi</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">†</mi></mrow><annotation encoding="application/x-tex">\dag</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord">†</span></span></span></span> <code>\dag</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>—</mtext></mrow><annotation encoding="application/x-tex">\text{---}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord text"><span class="mord">—</span></span></span></span></span> <code>\text{---}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋯</mo></mrow><annotation encoding="application/x-tex">\dotsm</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.313em;"></span><span class="minner">⋯</span></span></span></span> <code>\dotsm</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>†</mo></mrow><annotation encoding="application/x-tex">\dagger</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord">†</span></span></span></span> <code>\dagger</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>—</mtext></mrow><annotation encoding="application/x-tex">\text{\textemdash}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord text"><span class="mord">—</span></span></span></span></span> <code>\text{\textemdash}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>…</mo></mrow><annotation encoding="application/x-tex">\dotso</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.123em;"></span><span class="minner">…</span></span></span></span> <code>\dotso</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>†</mtext></mrow><annotation encoding="application/x-tex">\text{\textdagger}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord text"><span class="mord">†</span></span></span></span></span> <code>\text{\textdagger}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>~</mtext></mrow><annotation encoding="application/x-tex">\text{\textasciitilde}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6679em;vertical-align:-0.35em;"></span><span class="mord text"><span class="mord">~</span></span></span></span></span> <code>\text{\textasciitilde}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋅</mo></mrow><annotation encoding="application/x-tex">\sdot</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4445em;"></span><span class="mord">⋅</span></span></span></span> <code>\sdot</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">‡</mi></mrow><annotation encoding="application/x-tex">\ddag</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord">‡</span></span></span></span> <code>\ddag</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">‘</mi></mrow><annotation encoding="application/x-tex">`</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">‘</span></span></span></span> <code>`</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>…</mo></mrow><annotation encoding="application/x-tex">\mathellipsis</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.123em;"></span><span class="minner">…</span></span></span></span> <code>\mathellipsis</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>‡</mo></mrow><annotation encoding="application/x-tex">\ddagger</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord">‡</span></span></span></span> <code>\ddagger</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>‘</mtext></mrow><annotation encoding="application/x-tex">\text{\textquoteleft}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord">‘</span></span></span></span></span> <code>text{\textquoteleft}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>…</mo></mrow><annotation encoding="application/x-tex">\text{\textellipsis}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.123em;"></span><span class="mord text"><span class="minner">…</span></span></span></span></span> <code>\text{\textellipsis}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>‡</mtext></mrow><annotation encoding="application/x-tex">\text{\textdaggerdbl}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord text"><span class="mord">‡</span></span></span></span></span> <code>\text{\textdaggerdbl}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">‘</mi></mrow><annotation encoding="application/x-tex">\lq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">‘</span></span></span></span> <code>\lq</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">□</mi></mrow><annotation encoding="application/x-tex">\Box</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.675em;"></span><span class="mord amsrm">□</span></span></span></span> <code>\Box</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>‡</mo></mrow><annotation encoding="application/x-tex">\Dagger</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord">‡</span></span></span></span> <code>\Dagger</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>’</mtext></mrow><annotation encoding="application/x-tex">\text{\textquoteright}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord">’</span></span></span></span></span> <code>\text{\textquoteright}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">□</mi></mrow><annotation encoding="application/x-tex">\square</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.675em;"></span><span class="mord amsrm">□</span></span></span></span> <code>\square</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∠</mi></mrow><annotation encoding="application/x-tex">\angle</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mord">∠</span></span></span></span> <code>\angle</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msup><mrow></mrow><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup></mrow><annotation encoding="application/x-tex">\rq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7519em;"></span><span class="mord"><span></span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7519em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span></span></span></span> <code>\rq</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">■</mi></mrow><annotation encoding="application/x-tex">\blacksquare</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.675em;"></span><span class="mord amsrm">■</span></span></span></span> <code>\blacksquare</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∡</mi></mrow><annotation encoding="application/x-tex">\measuredangle</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mord amsrm">∡</span></span></span></span> <code>\measuredangle</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>“</mtext></mrow><annotation encoding="application/x-tex">\text{\textquotedblleft}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord">“</span></span></span></span></span> <code>\text{\textquotedblleft}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">△</mi></mrow><annotation encoding="application/x-tex">\triangle</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord">△</span></span></span></span> <code>\triangle</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∢</mi></mrow><annotation encoding="application/x-tex">\sphericalangle</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5576em;vertical-align:-0.0352em;"></span><span class="mord amsrm">∢</span></span></span></span> <code>\sphericalangle</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">&quot;</mi></mrow><annotation encoding="application/x-tex">&quot;</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">&quot;</span></span></span></span> <code>&quot;</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">▽</mi></mrow><annotation encoding="application/x-tex">\triangledown</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5499em;"></span><span class="mord amsrm">▽</span></span></span></span> <code>\triangledown</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">⊤</mi></mrow><annotation encoding="application/x-tex">\top</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">⊤</span></span></span></span> <code>\top</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>”</mtext></mrow><annotation encoding="application/x-tex">\text{\textquotedblright}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord">”</span></span></span></span></span> <code>\text{\textquotedblright}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>◃</mo></mrow><annotation encoding="application/x-tex">\triangleleft</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4653em;"></span><span class="mord">◃</span></span></span></span> <code>\triangleleft</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">⊥</mi></mrow><annotation encoding="application/x-tex">\bot</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">⊥</span></span></span></span> <code>\bot</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mspace></mspace><mspace width="0.1111em"/><mo lspace="0em" rspace="0.17em"></mo><mtext> ⁣</mtext><mo lspace="0em" rspace="0em">:</mo><mspace width="0.3333em"/></mrow><annotation encoding="application/x-tex">\colon</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mspace nobreak"></span><span class="mspace" style="margin-right:0.1111em;"></span><span class="mpunct"></span><span class="mspace" style="margin-right:-0.1667em;"></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mrel">:</span></span><span class="mspace" style="margin-right:0.3333em;"></span></span></span></span> <code>\colon</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>▹</mo></mrow><annotation encoding="application/x-tex">\triangleright</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4653em;"></span><span class="mord">▹</span></span></span></span> <code>\triangleright</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">$</mi></mrow><annotation encoding="application/x-tex">\$</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8056em;vertical-align:-0.0556em;"></span><span class="mord">$</span></span></span></span> <code>\$</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">‵</mi></mrow><annotation encoding="application/x-tex">\backprime</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5499em;"></span><span class="mord amsrm">‵</span></span></span></span> <code>\backprime</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>▽</mo></mrow><annotation encoding="application/x-tex">\bigtriangledown</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord">▽</span></span></span></span> <code>\bigtriangledown</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>$</mtext></mrow><annotation encoding="application/x-tex">\text{\textdollar}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8056em;vertical-align:-0.0556em;"></span><span class="mord text"><span class="mord">$</span></span></span></span></span> <code>\text{\textdollar}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo mathvariant="normal">′</mo></mrow><annotation encoding="application/x-tex">\prime</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5556em;"></span><span class="mord">′</span></span></span></span> <code>\prime</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>△</mo></mrow><annotation encoding="application/x-tex">\bigtriangleup</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord">△</span></span></span></span> <code>\bigtriangleup</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">£</mi></mrow><annotation encoding="application/x-tex">\pounds</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">£</span></span></span></span> <code>\pounds</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>&lt;</mtext></mrow><annotation encoding="application/x-tex">\text{\textless}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mord text"><span class="mord">&lt;</span></span></span></span></span> <code>\text{\textless}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">▲</mi></mrow><annotation encoding="application/x-tex">\blacktriangle</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5499em;"></span><span class="mord amsrm">▲</span></span></span></span> <code>\blacktriangle</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">£</mi></mrow><annotation encoding="application/x-tex">\mathsterling</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">£</span></span></span></span> <code>\mathsterling</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>&gt;</mtext></mrow><annotation encoding="application/x-tex">\text{\textgreater}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mord text"><span class="mord">&gt;</span></span></span></span></span> <code>\text{\textgreater}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">▼</mi></mrow><annotation encoding="application/x-tex">\blacktriangledown</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5499em;"></span><span class="mord amsrm">▼</span></span></span></span> <code>\blacktriangledown</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>£</mtext></mrow><annotation encoding="application/x-tex">\text{\textsterling}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord">£</span></span></span></span></span> <code>\text{\textsterling}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>|</mtext></mrow><annotation encoding="application/x-tex">\text{\textbar}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord text"><span class="mord">|</span></span></span></span></span> <code>\text{\textbar}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>◀</mo></mrow><annotation encoding="application/x-tex">\blacktriangleleft</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.585em;vertical-align:-0.0352em;"></span><span class="mrel amsrm">◀</span></span></span></span> <code>\blacktriangleleft</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">¥</mi></mrow><annotation encoding="application/x-tex">\yen</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.675em;"></span><span class="mord amsrm" style="margin-right:0.025em;">¥</span></span></span></span> <code>\yen</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>∥</mtext></mrow><annotation encoding="application/x-tex">\text{\textbardbl}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord text"><span class="mord">∥</span></span></span></span></span> <code>\text{\textbardbl}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>▶</mo></mrow><annotation encoding="application/x-tex">\blacktriangleright</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.585em;vertical-align:-0.0352em;"></span><span class="mrel amsrm">▶</span></span></span></span> <code>\blacktriangleright</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">√</mi></mrow><annotation encoding="application/x-tex">\surd</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.2em;"></span><span class="mord">√</span></span></span></span> <code>\surd</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>{</mtext></mrow><annotation encoding="application/x-tex">\text{\textbraceleft}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord text"><span class="mord">{</span></span></span></span></span> <code>\text{\textbraceleft}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋄</mo></mrow><annotation encoding="application/x-tex">\diamond</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4445em;"></span><span class="mord">⋄</span></span></span></span> <code>\diamond</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">°</mi></mrow><annotation encoding="application/x-tex">\degree</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">°</span></span></span></span> <code>\degree</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>}</mtext></mrow><annotation encoding="application/x-tex">\text{\textbraceright}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord text"><span class="mord">}</span></span></span></span></span> <code>\text{\textbraceright}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">◊</mi></mrow><annotation encoding="application/x-tex">\Diamond</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8034em;vertical-align:-0.1111em;"></span><span class="mord amsrm">◊</span></span></span></span> <code>\Diamond</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>°</mtext></mrow><annotation encoding="application/x-tex">\text{\textdegree}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord">°</span></span></span></span></span> <code>\text{\textdegree}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>¶</mtext></mrow><annotation encoding="application/x-tex">\text{\P}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord text"><span class="mord">¶</span></span></span></span></span> <code>\text{\P}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">◊</mi></mrow><annotation encoding="application/x-tex">\lozenge</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8034em;vertical-align:-0.1111em;"></span><span class="mord amsrm">◊</span></span></span></span> <code>\lozenge</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">℧</mi></mrow><annotation encoding="application/x-tex">\mho</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord amsrm">℧</span></span></span></span> <code>\mho</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>§</mtext></mrow><annotation encoding="application/x-tex">\text{\S}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord text"><span class="mord">§</span></span></span></span></span> <code>\text{\S}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">⧫</mi></mrow><annotation encoding="application/x-tex">\blacklozenge</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8034em;vertical-align:-0.1111em;"></span><span class="mord amsrm">⧫</span></span></span></span> <code>\blacklozenge</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">╲</mi></mrow><annotation encoding="application/x-tex">\diagdown</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9356em;vertical-align:-0.1944em;"></span><span class="mord amsrm">╲</span></span></span></span> <code>\diagdown</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>§</mtext></mrow><annotation encoding="application/x-tex">\text{\sect}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord text"><span class="mord">§</span></span></span></span></span> <code>\text{\sect}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋆</mo></mrow><annotation encoding="application/x-tex">\star</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4653em;"></span><span class="mord">⋆</span></span></span></span> <code>\star</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">╱</mi></mrow><annotation encoding="application/x-tex">\diagup</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8833em;vertical-align:-0.1944em;"></span><span class="mord amsrm">╱</span></span></span></span> <code>\diagup</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>©</mtext></mrow><annotation encoding="application/x-tex">\copyright</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;"></span><span class="mord text"><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8889em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">c</span></span></span><span style="top:-3.1944em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body accent-full" style="left:0em;top:.2em;"><span class="mord">◯</span></span></span></span></span></span></span></span></span></span></span> <code>\copyright</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">★</mi></mrow><annotation encoding="application/x-tex">\bigstar</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8867em;vertical-align:-0.1944em;"></span><span class="mord amsrm">★</span></span></span></span> <code>\bigstar</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">♭</mi></mrow><annotation encoding="application/x-tex">\flat</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.75em;"></span><span class="mord">♭</span></span></span></span> <code>\flat</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">®</mi></mrow><annotation encoding="application/x-tex">\circledR</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8478em;vertical-align:-0.1556em;"></span><span class="mord amsrm">®</span></span></span></span> <code>\circledR</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">♣</mi></mrow><annotation encoding="application/x-tex">\clubsuit</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8241em;vertical-align:-0.1296em;"></span><span class="mord">♣</span></span></span></span> <code>\clubsuit</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">♮</mi></mrow><annotation encoding="application/x-tex">\natural</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord">♮</span></span></span></span> <code>\natural</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>®</mtext></mrow><annotation encoding="application/x-tex">\text{\textregistered}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;"></span><span class="mord text"><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8889em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord sizing reset-size6 size3">R</span></span></span><span style="top:-3.1944em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body accent-full" style="left:0em;top:.2em;"><span class="mord">◯</span></span></span></span></span></span></span></span></span></span></span> <code>\text{\textregistered}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">♣</mi></mrow><annotation encoding="application/x-tex">\clubs</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8241em;vertical-align:-0.1296em;"></span><span class="mord">♣</span></span></span></span> <code>\clubs</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">♯</mi></mrow><annotation encoding="application/x-tex">\sharp</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord">♯</span></span></span></span> <code>\sharp</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Ⓢ</mi></mrow><annotation encoding="application/x-tex">\circledS</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8478em;vertical-align:-0.1556em;"></span><span class="mord amsrm">Ⓢ</span></span></span></span> <code>\circledS</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">♢</mi></mrow><annotation encoding="application/x-tex">\diamondsuit</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8241em;vertical-align:-0.1296em;"></span><span class="mord">♢</span></span></span></span> <code>\diamondsuit</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">♡</mi></mrow><annotation encoding="application/x-tex">\heartsuit</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8241em;vertical-align:-0.1296em;"></span><span class="mord">♡</span></span></span></span> <code>\heartsuit</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mtext>a</mtext><mo>◯</mo></mover></mrow><annotation encoding="application/x-tex">\text{\textcircled a}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;"></span><span class="mord text"><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8889em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord">a</span></span><span style="top:-3.1944em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body accent-full" style="left:0em;top:.2em;"><span class="mord">◯</span></span></span></span></span></span></span></span></span></span></span> <code>\text{\textcircled a}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">♢</mi></mrow><annotation encoding="application/x-tex">\diamonds</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8241em;vertical-align:-0.1296em;"></span><span class="mord">♢</span></span></span></span> <code>\diamonds</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">♡</mi></mrow><annotation encoding="application/x-tex">\hearts</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8241em;vertical-align:-0.1296em;"></span><span class="mord">♡</span></span></span></span> <code>\hearts</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">✠</mi></mrow><annotation encoding="application/x-tex">\maltese</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mord amsrm">✠</span></span></span></span> <code>\maltese</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">♠</mi></mrow><annotation encoding="application/x-tex">\spadesuit</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8241em;vertical-align:-0.1296em;"></span><span class="mord">♠</span></span></span></span> <code>\spadesuit</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">♠</mi></mrow><annotation encoding="application/x-tex">\spades</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8241em;vertical-align:-0.1296em;"></span><span class="mord">♠</span></span></span></span> <code>\spades</code></td>
</tr>
</tbody>
</table>
<p>Direct Input: <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">£</mi><mi mathvariant="normal">¥</mi><mi mathvariant="normal">∇</mi><mi mathvariant="normal">∞</mi><mo separator="true">⋅</mo><mi mathvariant="normal">∠</mi><mi mathvariant="normal">∡</mi><mi mathvariant="normal">∢</mi><mi mathvariant="normal">♠</mi><mi mathvariant="normal">♡</mi><mi mathvariant="normal">♢</mi><mi mathvariant="normal">♣</mi><mi mathvariant="normal">♭</mi><mi mathvariant="normal">♮</mi><mi mathvariant="normal">♯</mi><mi mathvariant="normal">✓</mi><mo>…</mo><mi><mi mathvariant="normal">⋮</mi><mpadded height="0em" voffset="0em"><mspace mathbackground="black" width="0em" height="1.5em"></mspace></mpadded></mi><mo>⋯</mo><mo>⋱</mo><mo stretchy="false">!</mo></mrow><annotation encoding="application/x-tex">£ ¥ ∇ ∞ · ∠ ∡ ∢ ♠ ♡ ♢ ♣ ♭ ♮ ♯ ✓ …  ⋮  ⋯  ⋱  !</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.6944em;vertical-align:-0.1944em;"></span><span class="mord">£</span><span class="mord amsrm" style="margin-right:0.025em;">¥</span><span class="mord">∇∞</span><span class="mpunct">⋅</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord">∠</span><span class="mord amsrm">∡∢</span><span class="mord">♠♡♢♣♭♮♯</span><span class="mord amsrm">✓</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner">…</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord">⋮</span><span class="mord rule" style="border-right-width:0em;border-top-width:1.5em;bottom:0em;"></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner">⋯⋱</span><span class="mclose">!</span></span></span></span> ‼</p>
<h2 id="_13-units" tabindex="-1">13: Units <a class="header-anchor" href="#_13-units" aria-label="Permalink to &quot;13: Units&quot;">&ZeroWidthSpace;</a></h2>
<p>In KaTeX, units are proportioned as they are in TeX. KaTeX units are different than CSS units.</p>
<table>
<thead>
<tr>
<th style="text-align:left">KaTeX Unit</th>
<th style="text-align:left">Value</th>
<th style="text-align:left">KaTeX Unit</th>
<th style="text-align:left">Value</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">em</td>
<td style="text-align:left">CSS em</td>
<td style="text-align:left">bp</td>
<td style="text-align:left">1/72​ inch × F × G</td>
</tr>
<tr>
<td style="text-align:left">ex</td>
<td style="text-align:left">CSS ex</td>
<td style="text-align:left">pc</td>
<td style="text-align:left">12 KaTeX pt</td>
</tr>
<tr>
<td style="text-align:left">mu</td>
<td style="text-align:left">1/18 CSS em</td>
<td style="text-align:left">dd</td>
<td style="text-align:left">1238/1157​ KaTeX pt</td>
</tr>
<tr>
<td style="text-align:left">pt</td>
<td style="text-align:left">1/72.27 inch × F × G</td>
<td style="text-align:left">cc</td>
<td style="text-align:left">14856/1157 KaTeX pt</td>
</tr>
<tr>
<td style="text-align:left">mm</td>
<td style="text-align:left">1 mm × F × G</td>
<td style="text-align:left">nd</td>
<td style="text-align:left">685/642 KaTeX pt</td>
</tr>
<tr>
<td style="text-align:left">cm</td>
<td style="text-align:left">1 cm × F × G</td>
<td style="text-align:left">nc</td>
<td style="text-align:left">1370/107​ KaTeX pt</td>
</tr>
<tr>
<td style="text-align:left">in</td>
<td style="text-align:left">1 inch × F × G</td>
<td style="text-align:left">sp</td>
<td style="text-align:left">1/65536 KaTeX pt</td>
</tr>
</tbody>
</table>
<p>where:</p>
<ul>
<li>
<p>F = (font size of surrounding HTML text)/(10 pt)</p>
</li>
<li>
<p>G = 1.21 by default, because KaTeX font-size is normally 1.21 × the surrounding font size. This value can be overridden by the CSS of an HTML page.</p>
</li>
</ul>
<p>The effect of style and size:</p>
<table>
<thead>
<tr>
<th style="text-align:center">Unit</th>
<th style="text-align:center">textstyle</th>
<th style="text-align:center">scriptscript</th>
<th style="text-align:center">huge</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:center">em or ex</td>
<td style="text-align:center"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mpadded height="0em" voffset="0em"><mspace mathbackground="black" width="1em" height="1em"></mspace></mpadded></mrow><annotation encoding="application/x-tex">\rule{1em}{1em}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;"></span><span class="mord rule" style="border-right-width:1em;border-top-width:1em;bottom:0em;"></span></span></span></span></td>
<td style="text-align:center"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle scriptlevel="2" displaystyle="false"><mpadded height="0em" voffset="0em"><mspace mathbackground="black" width="2em" height="2em"></mspace></mpadded></mstyle></mrow><annotation encoding="application/x-tex">\scriptscriptstyle\rule{1em}{1em}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;"></span><span class="mord rule mtight sizing reset-size6 size1" style="border-right-width:2em;border-top-width:2em;bottom:0em;"></span></span></span></span></td>
<td style="text-align:center"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathsize="2.074em"><mpadded height="0em" voffset="0em"><mspace mathbackground="black" width="1em" height="1em"></mspace></mpadded></mstyle></mrow><annotation encoding="application/x-tex">\huge\rule{1em}{1em}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.074em;"></span><span class="mord rule sizing reset-size6 size10" style="border-right-width:1em;border-top-width:1em;bottom:0em;"></span></span></span></span></td>
</tr>
<tr>
<td style="text-align:center">mu</td>
<td style="text-align:center"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mpadded height="0em" voffset="0em"><mspace mathbackground="black" width="1em" height="1em"></mspace></mpadded></mrow><annotation encoding="application/x-tex">\rule{18mu}{18mu}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;"></span><span class="mord rule" style="border-right-width:1em;border-top-width:1em;bottom:0em;"></span></span></span></span></td>
<td style="text-align:center"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle scriptlevel="2" displaystyle="false"><mpadded height="0em" voffset="0em"><mspace mathbackground="black" width="1.472em" height="1.472em"></mspace></mpadded></mstyle></mrow><annotation encoding="application/x-tex">\scriptscriptstyle\rule{18mu}{18mu}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.736em;"></span><span class="mord rule mtight sizing reset-size6 size1" style="border-right-width:1.472em;border-top-width:1.472em;bottom:0em;"></span></span></span></span></td>
<td style="text-align:center"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathsize="2.074em"><mpadded height="0em" voffset="0em"><mspace mathbackground="black" width="1em" height="1em"></mspace></mpadded></mstyle></mrow><annotation encoding="application/x-tex">\huge\rule{18mu}{18mu}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.074em;"></span><span class="mord rule sizing reset-size6 size10" style="border-right-width:1em;border-top-width:1em;bottom:0em;"></span></span></span></span></td>
</tr>
<tr>
<td style="text-align:center">others</td>
<td style="text-align:center"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mpadded height="0em" voffset="0em"><mspace mathbackground="black" width="1em" height="1em"></mspace></mpadded></mrow><annotation encoding="application/x-tex">\rule{10pt}{10pt}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;"></span><span class="mord rule" style="border-right-width:1em;border-top-width:1em;bottom:0em;"></span></span></span></span></td>
<td style="text-align:center"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle scriptlevel="2" displaystyle="false"><mpadded height="0em" voffset="0em"><mspace mathbackground="black" width="2em" height="2em"></mspace></mpadded></mstyle></mrow><annotation encoding="application/x-tex">\scriptscriptstyle\rule{10pt}{10pt}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;"></span><span class="mord rule mtight sizing reset-size6 size1" style="border-right-width:2em;border-top-width:2em;bottom:0em;"></span></span></span></span></td>
<td style="text-align:center"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathsize="2.074em"><mpadded height="0em" voffset="0em"><mspace mathbackground="black" width="0.4822em" height="0.4822em"></mspace></mpadded></mstyle></mrow><annotation encoding="application/x-tex">\huge\rule{10pt}{10pt}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;"></span><span class="mord rule sizing reset-size6 size10" style="border-right-width:0.4822em;border-top-width:0.4822em;bottom:0em;"></span></span></span></span></td>
</tr>
</tbody>
</table>
]]></description>
            <content:encoded><![CDATA[<h1 id="katex-supported-function" tabindex="-1">KaTeX: Supported function <a class="header-anchor" href="#katex-supported-function" aria-label="Permalink to &quot;KaTeX: Supported function&quot;">&ZeroWidthSpace;</a></h1>
<div class="tip custom-block"><p class="custom-block-title">note</p>
<p>This is an direct shameful copy of the documentation pulled from <a href="https://raw.githubusercontent.com/Khan/KaTeX/master/docs/supported.md" target="_blank" rel="noreferrer">KaTeX</a> documentation, <strong>I do not own any of the content below on behalf of this part of the documentation</strong>, the table might be outdated as versions migrates, please also refer to <a href="https://katex.org/docs/supported.html" target="_blank" rel="noreferrer">KaTeX's official documentation</a>.</p>
</div>
<p>This following is a list of TeX functions supported by KaTeX. It is sorted into logical groups.</p>
<p>There is a similar <a href="./support-table.html">Support Table</a> on the next page, sorted alphabetically in am more intuitive way with the lists both supported and un-supported functions, viewing both tables are suggested comprehensibly and interchangeably is highly suggested.</p>
<h2 id="_1-accents" tabindex="-1">1: Accents <a class="header-anchor" href="#_1-accents" aria-label="Permalink to &quot;1: Accents&quot;">&ZeroWidthSpace;</a></h2>
<table>
<thead>
<tr>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msup><mi>a</mi><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup></mrow><annotation encoding="application/x-tex">a&#x27;</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7519em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7519em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span></span></span></span> <code>a'</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mi>a</mi><mo>~</mo></mover></mrow><annotation encoding="application/x-tex">\tilde{a}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6679em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6679em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord mathnormal">a</span></span><span style="top:-3.35em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.25em;"><span class="mord">~</span></span></span></span></span></span></span></span></span></span> <code>\tilde{a}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mi>g</mi><mo>˚</mo></mover></mrow><annotation encoding="application/x-tex">\mathring{g}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord accent"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6944em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">g</span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.3472em;"><span class="mord">˚</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.1944em;"><span></span></span></span></span></span></span></span></span> <code>\mathring{g}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msup><mi>a</mi><mrow><mo mathvariant="normal">′</mo><mo mathvariant="normal">′</mo></mrow></msup></mrow><annotation encoding="application/x-tex">a&#x27;&#x27;</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7519em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7519em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′′</span></span></span></span></span></span></span></span></span></span></span></span> <code>a''</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mrow><mi>a</mi><mi>c</mi></mrow><mo stretchy="true">~</mo></mover></mrow><annotation encoding="application/x-tex">\widetilde{ac}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7166em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7166em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="mord mathnormal">c</span></span></span><span class="svg-align" style="top:-3.4306em;"><span class="pstrut" style="height:3em;"></span><span style="height:0.286em;"><svg xmlns="http://www.w3.org/2000/svg" width='100%' height='0.286em' viewBox='0 0 1033 286' preserveAspectRatio='none'><path d='M344 55.266c-142 0-300.638 81.316-311.5 86.418
-8.01 3.762-22.5 10.91-23.5 5.562L1 120c-1-2-1-3-1-4 0-5 3-9 8-10l18.4-9C160.9
 31.9 283 0 358 0c148 0 188 122 331 122s314-97 326-97c4 0 8 2 10 7l7 21.114
c1 2.14 1 3.21 1 4.28 0 5.347-3 9.626-7 10.696l-22.3 12.622C852.6 158.372 751
 181.476 676 181.476c-149 0-189-126.21-332-126.21z'/></svg></span></span></span></span></span></span></span></span></span> <code>\widetilde{ac}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mrow><mi>A</mi><mi>B</mi></mrow><mo stretchy="true">⏠</mo></mover></mrow><annotation encoding="application/x-tex">\overgroup{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0253em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:1.0253em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span><span class="svg-align" style="top:-3.6833em;"><span class="pstrut" style="height:3em;"></span><span class="stretchy" style="height:0.342em;min-width:0.888em;"><span class="halfarrow-left" style="height:0.342em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.342em' viewBox='0 0 400000 342' preserveAspectRatio='xMinYMin slice'><path d='M400000 80
H435C64 80 168.3 229.4 21 260c-5.9 1.2-18 0-18 0-2 0-3-1-3-3v-38C76 61 257 0
 435 0h399565z'/></svg></span><span class="halfarrow-right" style="height:0.342em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.342em' viewBox='0 0 400000 342' preserveAspectRatio='xMaxYMin slice'><path d='M0 80h399565c371 0 266.7 149.4 414 180 5.9 1.2 18 0 18 0 2 0
 3-1 3-3v-38c-76-158-257-219-435-219H0z'/></svg></span></span></span></span></span></span></span></span></span></span> <code>\overgroup{AB}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msup><mi>a</mi><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup></mrow><annotation encoding="application/x-tex">a^{\prime}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7519em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7519em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span></span></span></span> <code>a^{\prime}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><munder accentunder="true"><mrow><mi>A</mi><mi>B</mi></mrow><mo stretchy="true">~</mo></munder></mrow><annotation encoding="application/x-tex">\utilde{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0893em;vertical-align:-0.406em;"></span><span class="mord accentunder"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6833em;"><span class="svg-align" style="top:-2.594em;"><span class="pstrut" style="height:3em;"></span><span style="height:0.286em;"><svg xmlns="http://www.w3.org/2000/svg" width='100%' height='0.286em' viewBox='0 0 1033 286' preserveAspectRatio='none'><path d='M344 55.266c-142 0-300.638 81.316-311.5 86.418
-8.01 3.762-22.5 10.91-23.5 5.562L1 120c-1-2-1-3-1-4 0-5 3-9 8-10l18.4-9C160.9
 31.9 283 0 358 0c148 0 188 122 331 122s314-97 326-97c4 0 8 2 10 7l7 21.114
c1 2.14 1 3.21 1 4.28 0 5.347-3 9.626-7 10.696l-22.3 12.622C852.6 158.372 751
 181.476 676 181.476c-149 0-189-126.21-332-126.21z'/></svg></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.406em;"><span></span></span></span></span></span></span></span></span> <code>\utilde{AB}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><munder accentunder="true"><mrow><mi>A</mi><mi>B</mi></mrow><mo stretchy="true">⏡</mo></munder></mrow><annotation encoding="application/x-tex">\undergroup{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0253em;vertical-align:-0.342em;"></span><span class="mord accentunder"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6833em;"><span class="svg-align" style="top:-2.658em;"><span class="pstrut" style="height:3em;"></span><span class="stretchy" style="height:0.342em;min-width:0.888em;"><span class="halfarrow-left" style="height:0.342em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.342em' viewBox='0 0 400000 342' preserveAspectRatio='xMinYMin slice'><path d='M400000 262
H435C64 262 168.3 112.6 21 82c-5.9-1.2-18 0-18 0-2 0-3 1-3 3v38c76 158 257 219
 435 219h399565z'/></svg></span><span class="halfarrow-right" style="height:0.342em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.342em' viewBox='0 0 400000 342' preserveAspectRatio='xMaxYMin slice'><path d='M0 262h399565c371 0 266.7-149.4 414-180 5.9-1.2 18 0 18
 0 2 0 3 1 3 3v38c-76 158-257 219-435 219H0z'/></svg></span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.342em;"><span></span></span></span></span></span></span></span></span> <code>\undergroup{AB}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mi>a</mi><mo>ˊ</mo></mover></mrow><annotation encoding="application/x-tex">\acute{a}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6944em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord mathnormal">a</span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.25em;"><span class="mord">ˊ</span></span></span></span></span></span></span></span></span></span> <code>\acute{a}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mi>F</mi><mo>⃗</mo></mover></mrow><annotation encoding="application/x-tex">\vec{F}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9663em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.9663em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord mathnormal" style="margin-right:0.13889em;">F</span></span><span style="top:-3.2523em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.1522em;"><span class="overlay" style="height:0.714em;width:0.471em;"><svg xmlns="http://www.w3.org/2000/svg" width='0.471em' height='0.714em' style='width:0.471em' viewBox='0 0 471 714' preserveAspectRatio='xMinYMin'><path d='M377 20c0-5.333 1.833-10 5.5-14S391 0 397 0c4.667 0 8.667 1.667 12 5
3.333 2.667 6.667 9 10 19 6.667 24.667 20.333 43.667 41 57 7.333 4.667 11
10.667 11 18 0 6-1 10-3 12s-6.667 5-14 9c-28.667 14.667-53.667 35.667-75 63
-1.333 1.333-3.167 3.5-5.5 6.5s-4 4.833-5 5.5c-1 .667-2.5 1.333-4.5 2s-4.333 1
-7 1c-4.667 0-9.167-1.833-13.5-5.5S337 184 337 178c0-12.667 15.667-32.333 47-59
H213l-171-1c-8.667-6-13-12.333-13-19 0-4.667 4.333-11.333 13-20h359
c-16-25.333-24-45-24-59z'/></svg></span></span></span></span></span></span></span></span></span></span> <code>\vec{F}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mrow><mi>A</mi><mi>B</mi></mrow><mo stretchy="true">⇒</mo></mover></mrow><annotation encoding="application/x-tex">\Overrightarrow{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2433em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:1.2433em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span><span class="svg-align" style="top:-3.6833em;"><span class="pstrut" style="height:3em;"></span><span class="hide-tail" style="height:0.56em;min-width:0.888em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.56em' viewBox='0 0 400000 560' preserveAspectRatio='xMaxYMin slice'><path d='M399738 392l
-10 10c-34 36-62.7 77-86 123-3.3 8-5 13.3-5 16 0 5.3 6.7 8 20 8 7.3 0 12.2-.5
 14.5-1.5 2.3-1 4.8-4.5 7.5-10.5 49.3-97.3 121.7-169.3 217-216 28-14 57.3-25 88
-33 6.7-2 11-3.8 13-5.5 2-1.7 3-4.2 3-7.5s-1-5.8-3-7.5c-2-1.7-6.3-3.5-13-5.5-68
-17.3-128.2-47.8-180.5-91.5-52.3-43.7-93.8-96.2-124.5-157.5-9.3-8-15.3-12.3-18
-13h-6c-12 .7-18 4-18 10 0 2 1.7 7 5 15 23.3 46 52 87 86 123l10 10H0v40h399782
c-328 0 0 0 0 0l10 8c26.7 20 65.7 43 117 69-2.7 2-6 3.7-10 5-36.7 16-72.3 37.3
-107 64l-10 8H0v40zM0 157v40h399730v-40zm0 194v40h399730v-40z'/></svg></span></span></span></span></span></span></span></span></span> <code>\Overrightarrow{AB}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mi>y</mi><mo>ˉ</mo></mover></mrow><annotation encoding="application/x-tex">\bar{y}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7622em;vertical-align:-0.1944em;"></span><span class="mord accent"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.5678em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">y</span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.1944em;"><span class="mord">ˉ</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.1944em;"><span></span></span></span></span></span></span></span></span> <code>\bar{y}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mrow><mi>A</mi><mi>B</mi></mrow><mo stretchy="true">←</mo></mover></mrow><annotation encoding="application/x-tex">\overleftarrow{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2053em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:1.2053em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span><span class="svg-align" style="top:-3.6833em;"><span class="pstrut" style="height:3em;"></span><span class="hide-tail" style="height:0.522em;min-width:0.888em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMinYMin slice'><path d='M400000 241H110l3-3c68.7-52.7 113.7-120
 135-202 4-14.7 6-23 6-25 0-7.3-7-11-21-11-8 0-13.2.8-15.5 2.5-2.3 1.7-4.2 5.8
-5.5 12.5-1.3 4.7-2.7 10.3-4 17-12 48.7-34.8 92-68.5 130S65.3 228.3 18 247
c-10 4-16 7.7-18 11 0 8.7 6 14.3 18 17 47.3 18.7 87.8 47 121.5 85S196 441.3 208
 490c.7 2 1.3 5 2 9s1.2 6.7 1.5 8c.3 1.3 1 3.3 2 6s2.2 4.5 3.5 5.5c1.3 1 3.3
 1.8 6 2.5s6 1 10 1c14 0 21-3.7 21-11 0-2-2-10.3-6-25-20-79.3-65-146.7-135-202
 l-3-3h399890zM100 241v40h399900v-40z'/></svg></span></span></span></span></span></span></span></span></span> <code>\overleftarrow{AB}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mrow><mi>A</mi><mi>B</mi></mrow><mo stretchy="true">→</mo></mover></mrow><annotation encoding="application/x-tex">\overrightarrow{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2053em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:1.2053em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span><span class="svg-align" style="top:-3.6833em;"><span class="pstrut" style="height:3em;"></span><span class="hide-tail" style="height:0.522em;min-width:0.888em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMaxYMin slice'><path d='M0 241v40h399891c-47.3 35.3-84 78-110 128
-16.7 32-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20
 11 8 0 13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7
 39-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85
-40.5-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5
-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67
 151.7 139 205zm0 0v40h399900v-40z'/></svg></span></span></span></span></span></span></span></span></span> <code>\overrightarrow{AB}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mi>a</mi><mo>˘</mo></mover></mrow><annotation encoding="application/x-tex">\breve{a}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6944em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord mathnormal">a</span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.25em;"><span class="mord">˘</span></span></span></span></span></span></span></span></span></span> <code>\breve{a}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><munder accentunder="true"><mrow><mi>A</mi><mi>B</mi></mrow><mo stretchy="true">←</mo></munder></mrow><annotation encoding="application/x-tex">\underleftarrow{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2053em;vertical-align:-0.522em;"></span><span class="mord accentunder"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6833em;"><span class="svg-align" style="top:-2.478em;"><span class="pstrut" style="height:3em;"></span><span class="hide-tail" style="height:0.522em;min-width:0.888em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMinYMin slice'><path d='M400000 241H110l3-3c68.7-52.7 113.7-120
 135-202 4-14.7 6-23 6-25 0-7.3-7-11-21-11-8 0-13.2.8-15.5 2.5-2.3 1.7-4.2 5.8
-5.5 12.5-1.3 4.7-2.7 10.3-4 17-12 48.7-34.8 92-68.5 130S65.3 228.3 18 247
c-10 4-16 7.7-18 11 0 8.7 6 14.3 18 17 47.3 18.7 87.8 47 121.5 85S196 441.3 208
 490c.7 2 1.3 5 2 9s1.2 6.7 1.5 8c.3 1.3 1 3.3 2 6s2.2 4.5 3.5 5.5c1.3 1 3.3
 1.8 6 2.5s6 1 10 1c14 0 21-3.7 21-11 0-2-2-10.3-6-25-20-79.3-65-146.7-135-202
 l-3-3h399890zM100 241v40h399900v-40z'/></svg></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.522em;"><span></span></span></span></span></span></span></span></span> <code>\underleftarrow{AB}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><munder accentunder="true"><mrow><mi>A</mi><mi>B</mi></mrow><mo stretchy="true">→</mo></munder></mrow><annotation encoding="application/x-tex">\underrightarrow{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2053em;vertical-align:-0.522em;"></span><span class="mord accentunder"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6833em;"><span class="svg-align" style="top:-2.478em;"><span class="pstrut" style="height:3em;"></span><span class="hide-tail" style="height:0.522em;min-width:0.888em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMaxYMin slice'><path d='M0 241v40h399891c-47.3 35.3-84 78-110 128
-16.7 32-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20
 11 8 0 13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7
 39-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85
-40.5-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5
-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67
 151.7 139 205zm0 0v40h399900v-40z'/></svg></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.522em;"><span></span></span></span></span></span></span></span></span> <code>\underrightarrow{AB}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mi>a</mi><mo>ˇ</mo></mover></mrow><annotation encoding="application/x-tex">\check{a}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6285em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6285em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord mathnormal">a</span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.25em;"><span class="mord">ˇ</span></span></span></span></span></span></span></span></span></span> <code>\check{a}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mrow><mi>a</mi><mi>c</mi></mrow><mo stretchy="true">↼</mo></mover></mrow><annotation encoding="application/x-tex">\overleftharpoon{ac}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9526em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.9526em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="mord mathnormal">c</span></span></span><span class="svg-align" style="top:-3.4306em;"><span class="pstrut" style="height:3em;"></span><span class="hide-tail" style="height:0.522em;min-width:0.888em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMinYMin slice'><path d='M0 267c.7 5.3 3 10 7 14h399993v-40H93c3.3
-3.3 10.2-9.5 20.5-18.5s17.8-15.8 22.5-20.5c50.7-52 88-110.3 112-175 4-11.3 5
-18.3 3-21-1.3-4-7.3-6-18-6-8 0-13 .7-15 2s-4.7 6.7-8 16c-42 98.7-107.3 174.7
-196 228-6.7 4.7-10.7 8-12 10-1.3 2-2 5.7-2 11zm100-26v40h399900v-40z'/></svg></span></span></span></span></span></span></span></span></span> <code>\overleftharpoon{ac}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mrow><mi>a</mi><mi>c</mi></mrow><mo stretchy="true">⇀</mo></mover></mrow><annotation encoding="application/x-tex">\overrightharpoon{ac}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9526em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.9526em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="mord mathnormal">c</span></span></span><span class="svg-align" style="top:-3.4306em;"><span class="pstrut" style="height:3em;"></span><span class="hide-tail" style="height:0.522em;min-width:0.888em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMaxYMin slice'><path d='M0 241v40h399993c4.7-4.7 7-9.3 7-14 0-9.3
-3.7-15.3-11-18-92.7-56.7-159-133.7-199-231-3.3-9.3-6-14.7-8-16-2-1.3-7-2-15-2
-10.7 0-16.7 2-18 6-2 2.7-1 9.7 3 21 15.3 42 36.7 81.8 64 119.5 27.3 37.7 58
 69.2 92 94.5zm0 0v40h399900v-40z'/></svg></span></span></span></span></span></span></span></span></span> <code>\overrightharpoon{ac}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mi>a</mi><mo>˙</mo></mover></mrow><annotation encoding="application/x-tex">\dot{a}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6679em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6679em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord mathnormal">a</span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.1389em;"><span class="mord">˙</span></span></span></span></span></span></span></span></span></span> <code>\dot{a}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mrow><mi>A</mi><mi>B</mi></mrow><mo stretchy="true">↔</mo></mover></mrow><annotation encoding="application/x-tex">\overleftrightarrow{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2053em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:1.2053em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span><span class="svg-align" style="top:-3.6833em;"><span class="pstrut" style="height:3em;"></span><span class="stretchy" style="height:0.522em;min-width:0.888em;"><span class="halfarrow-left" style="height:0.522em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMinYMin slice'><path d='M400000 241H110l3-3c68.7-52.7 113.7-120
 135-202 4-14.7 6-23 6-25 0-7.3-7-11-21-11-8 0-13.2.8-15.5 2.5-2.3 1.7-4.2 5.8
-5.5 12.5-1.3 4.7-2.7 10.3-4 17-12 48.7-34.8 92-68.5 130S65.3 228.3 18 247
c-10 4-16 7.7-18 11 0 8.7 6 14.3 18 17 47.3 18.7 87.8 47 121.5 85S196 441.3 208
 490c.7 2 1.3 5 2 9s1.2 6.7 1.5 8c.3 1.3 1 3.3 2 6s2.2 4.5 3.5 5.5c1.3 1 3.3
 1.8 6 2.5s6 1 10 1c14 0 21-3.7 21-11 0-2-2-10.3-6-25-20-79.3-65-146.7-135-202
 l-3-3h399890zM100 241v40h399900v-40z'/></svg></span><span class="halfarrow-right" style="height:0.522em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMaxYMin slice'><path d='M0 241v40h399891c-47.3 35.3-84 78-110 128
-16.7 32-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20
 11 8 0 13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7
 39-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85
-40.5-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5
-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67
 151.7 139 205zm0 0v40h399900v-40z'/></svg></span></span></span></span></span></span></span></span></span></span> <code>\overleftrightarrow{AB}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mrow><mi>A</mi><mi>B</mi></mrow><mo stretchy="true">⏞</mo></mover></mrow><annotation encoding="application/x-tex">\overbrace{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.3313em;"></span><span class="mord mover"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:1.3313em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span><span class="svg-align" style="top:-3.7833em;"><span class="pstrut" style="height:3em;"></span><span class="stretchy" style="height:0.548em;min-width:1.6em;"><span class="brace-left" style="height:0.548em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.548em' viewBox='0 0 400000 548' preserveAspectRatio='xMinYMin slice'><path d='M6 548l-6-6v-35l6-11c56-104 135.3-181.3 238-232 57.3-28.7 117
-45 179-50h399577v120H403c-43.3 7-81 15-113 26-100.7 33-179.7 91-237 174-2.7
 5-6 9-10 13-.7 1-7.3 1-20 1H6z'/></svg></span><span class="brace-center" style="height:0.548em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.548em' viewBox='0 0 400000 548' preserveAspectRatio='xMidYMin slice'><path d='M200428 334
c-100.7-8.3-195.3-44-280-108-55.3-42-101.7-93-139-153l-9-14c-2.7 4-5.7 8.7-9 14
-53.3 86.7-123.7 153-211 199-66.7 36-137.3 56.3-212 62H0V214h199568c178.3-11.7
 311.7-78.3 403-201 6-8 9.7-12 11-12 .7-.7 6.7-1 18-1s17.3.3 18 1c1.3 0 5 4 11
 12 44.7 59.3 101.3 106.3 170 141s145.3 54.3 229 60h199572v120z'/></svg></span><span class="brace-right" style="height:0.548em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.548em' viewBox='0 0 400000 548' preserveAspectRatio='xMaxYMin slice'><path d='M400000 542l
-6 6h-17c-12.7 0-19.3-.3-20-1-4-4-7.3-8.3-10-13-35.3-51.3-80.8-93.8-136.5-127.5
s-117.2-55.8-184.5-66.5c-.7 0-2-.3-4-1-18.7-2.7-76-4.3-172-5H0V214h399571l6 1
c124.7 8 235 61.7 331 161 31.3 33.3 59.7 72.7 85 118l7 13v35z'/></svg></span></span></span></span></span></span></span></span></span></span> <code>\overbrace{AB}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mi>a</mi><mo>¨</mo></mover></mrow><annotation encoding="application/x-tex">\ddot{a}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6679em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6679em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord mathnormal">a</span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.25em;"><span class="mord">¨</span></span></span></span></span></span></span></span></span></span> <code>\ddot{a}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><munder accentunder="true"><mrow><mi>A</mi><mi>B</mi></mrow><mo stretchy="true">↔</mo></munder></mrow><annotation encoding="application/x-tex">\underleftrightarrow{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2053em;vertical-align:-0.522em;"></span><span class="mord accentunder"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6833em;"><span class="svg-align" style="top:-2.478em;"><span class="pstrut" style="height:3em;"></span><span class="stretchy" style="height:0.522em;min-width:0.888em;"><span class="halfarrow-left" style="height:0.522em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMinYMin slice'><path d='M400000 241H110l3-3c68.7-52.7 113.7-120
 135-202 4-14.7 6-23 6-25 0-7.3-7-11-21-11-8 0-13.2.8-15.5 2.5-2.3 1.7-4.2 5.8
-5.5 12.5-1.3 4.7-2.7 10.3-4 17-12 48.7-34.8 92-68.5 130S65.3 228.3 18 247
c-10 4-16 7.7-18 11 0 8.7 6 14.3 18 17 47.3 18.7 87.8 47 121.5 85S196 441.3 208
 490c.7 2 1.3 5 2 9s1.2 6.7 1.5 8c.3 1.3 1 3.3 2 6s2.2 4.5 3.5 5.5c1.3 1 3.3
 1.8 6 2.5s6 1 10 1c14 0 21-3.7 21-11 0-2-2-10.3-6-25-20-79.3-65-146.7-135-202
 l-3-3h399890zM100 241v40h399900v-40z'/></svg></span><span class="halfarrow-right" style="height:0.522em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMaxYMin slice'><path d='M0 241v40h399891c-47.3 35.3-84 78-110 128
-16.7 32-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20
 11 8 0 13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7
 39-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85
-40.5-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5
-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67
 151.7 139 205zm0 0v40h399900v-40z'/></svg></span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.522em;"><span></span></span></span></span></span></span></span></span> <code>\underleftrightarrow{AB}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><munder><mrow><mi>A</mi><mi>B</mi></mrow><mo stretchy="true">⏟</mo></munder></mrow><annotation encoding="application/x-tex">\underbrace{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.3313em;vertical-align:-0.648em;"></span><span class="mord munder"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6833em;"><span class="svg-align" style="top:-2.352em;"><span class="pstrut" style="height:3em;"></span><span class="stretchy" style="height:0.548em;min-width:1.6em;"><span class="brace-left" style="height:0.548em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.548em' viewBox='0 0 400000 548' preserveAspectRatio='xMinYMin slice'><path d='M0 6l6-6h17c12.688 0 19.313.3 20 1 4 4 7.313 8.3 10 13
 35.313 51.3 80.813 93.8 136.5 127.5 55.688 33.7 117.188 55.8 184.5 66.5.688
 0 2 .3 4 1 18.688 2.7 76 4.3 172 5h399450v120H429l-6-1c-124.688-8-235-61.7
-331-161C60.687 138.7 32.312 99.3 7 54L0 41V6z'/></svg></span><span class="brace-center" style="height:0.548em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.548em' viewBox='0 0 400000 548' preserveAspectRatio='xMidYMin slice'><path d='M199572 214
c100.7 8.3 195.3 44 280 108 55.3 42 101.7 93 139 153l9 14c2.7-4 5.7-8.7 9-14
 53.3-86.7 123.7-153 211-199 66.7-36 137.3-56.3 212-62h199568v120H200432c-178.3
 11.7-311.7 78.3-403 201-6 8-9.7 12-11 12-.7.7-6.7 1-18 1s-17.3-.3-18-1c-1.3 0
-5-4-11-12-44.7-59.3-101.3-106.3-170-141s-145.3-54.3-229-60H0V214z'/></svg></span><span class="brace-right" style="height:0.548em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.548em' viewBox='0 0 400000 548' preserveAspectRatio='xMaxYMin slice'><path d='M399994 0l6 6v35l-6 11c-56 104-135.3 181.3-238 232-57.3
 28.7-117 45-179 50H-300V214h399897c43.3-7 81-15 113-26 100.7-33 179.7-91 237
-174 2.7-5 6-9 10-13 .7-1 7.3-1 20-1h17z'/></svg></span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.648em;"><span></span></span></span></span></span></span></span></span> <code>\underbrace{AB}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mi>a</mi><mo>ˋ</mo></mover></mrow><annotation encoding="application/x-tex">\grave{a}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6944em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord mathnormal">a</span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.25em;"><span class="mord">ˋ</span></span></span></span></span></span></span></span></span></span> <code>\grave{a}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mrow><mi>A</mi><mi>B</mi></mrow><mo stretchy="true">‾</mo></mover></mrow><annotation encoding="application/x-tex">\overline{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8833em;"></span><span class="mord overline"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8833em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span><span style="top:-3.8033em;"><span class="pstrut" style="height:3em;"></span><span class="overline-line" style="border-bottom-width:0.04em;"></span></span></span></span></span></span></span></span></span> <code>\overline{AB}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mrow><mi>A</mi><mi>B</mi></mrow><mo stretchy="true">undefined</mo></mover></mrow><annotation encoding="application/x-tex">\overlinesegment{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2053em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:1.2053em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span><span class="svg-align" style="top:-3.6833em;"><span class="pstrut" style="height:3em;"></span><span class="stretchy" style="height:0.522em;min-width:0.888em;"><span class="halfarrow-left" style="height:0.522em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMinYMin slice'><path d='M40 281 V428 H0 V94 H40 V241 H400000 v40z
M40 281 V428 H0 V94 H40 V241 H400000 v40z'/></svg></span><span class="halfarrow-right" style="height:0.522em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMaxYMin slice'><path d='M399960 241 V94 h40 V428 h-40 V281 H0 v-40z
M399960 241 V94 h40 V428 h-40 V281 H0 v-40z'/></svg></span></span></span></span></span></span></span></span></span></span> <code>\overlinesegment{AB}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mi>θ</mi><mo>^</mo></mover></mrow><annotation encoding="application/x-tex">\hat{\theta}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9579em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.9579em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord mathnormal" style="margin-right:0.02778em;">θ</span></span><span style="top:-3.2634em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.1667em;"><span class="mord">^</span></span></span></span></span></span></span></span></span></span> <code>\hat{\theta}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><munder accentunder="true"><mrow><mi>A</mi><mi>B</mi></mrow><mo stretchy="true">‾</mo></munder></mrow><annotation encoding="application/x-tex">\underline{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8833em;vertical-align:-0.2em;"></span><span class="mord underline"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6833em;"><span style="top:-2.84em;"><span class="pstrut" style="height:3em;"></span><span class="underline-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2em;"><span></span></span></span></span></span></span></span></span> <code>\underline{AB}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><munder accentunder="true"><mrow><mi>A</mi><mi>B</mi></mrow><mo stretchy="true">undefined</mo></munder></mrow><annotation encoding="application/x-tex">\underlinesegment{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2053em;vertical-align:-0.522em;"></span><span class="mord accentunder"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6833em;"><span class="svg-align" style="top:-2.478em;"><span class="pstrut" style="height:3em;"></span><span class="stretchy" style="height:0.522em;min-width:0.888em;"><span class="halfarrow-left" style="height:0.522em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMinYMin slice'><path d='M40 281 V428 H0 V94 H40 V241 H400000 v40z
M40 281 V428 H0 V94 H40 V241 H400000 v40z'/></svg></span><span class="halfarrow-right" style="height:0.522em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMaxYMin slice'><path d='M399960 241 V94 h40 V428 h-40 V281 H0 v-40z
M399960 241 V94 h40 V428 h-40 V281 H0 v-40z'/></svg></span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.522em;"><span></span></span></span></span></span></span></span></span> <code>\underlinesegment{AB}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mrow><mi>a</mi><mi>c</mi></mrow><mo stretchy="true">^</mo></mover></mrow><annotation encoding="application/x-tex">\widehat{ac}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7306em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7306em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="mord mathnormal">c</span></span></span><span class="svg-align" style="top:-3.4306em;"><span class="pstrut" style="height:3em;"></span><span style="height:0.3em;"><svg xmlns="http://www.w3.org/2000/svg" width='100%' height='0.3em' viewBox='0 0 2364 300' preserveAspectRatio='none'><path d='M1181 0h2l1171 176c6 0 10 5 10 11l-2 23c-1 6-5 10
-11 10h-1L1182 67 15 220h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z'/></svg></span></span></span></span></span></span></span></span></span> <code>\widehat{ac}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mrow><mi>a</mi><mi>c</mi></mrow><mo stretchy="true">ˇ</mo></mover></mrow><annotation encoding="application/x-tex">\widecheck{ac}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7306em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7306em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="mord mathnormal">c</span></span></span><span class="svg-align" style="top:-3.4306em;"><span class="pstrut" style="height:3em;"></span><span style="height:0.3em;"><svg xmlns="http://www.w3.org/2000/svg" width='100%' height='0.3em' viewBox='0 0 2364 300' preserveAspectRatio='none'><path d='M1181,220h2l1171,-176c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,
-11,-10h-1l-1168,153l-1167,-153h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z'/></svg></span></span></span></span></span></span></span></span></span> <code>\widecheck{ac}</code></td>
<td style="text-align:left"></td>
</tr>
</tbody>
</table>
<p><strong><em>Accent functions inside \text{…}</em></strong></p>
<table>
<thead>
<tr>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mtext>a</mtext><mo>ˊ</mo></mover></mrow><annotation encoding="application/x-tex">\text{\&#x27;{a}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6944em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">a</span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.25em;"><span class="mord">ˊ</span></span></span></span></span></span></span></span></span></span></span> <code>\'{a}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mtext>a</mtext><mo>˜</mo></mover></mrow><annotation encoding="application/x-tex">\text{\~{a}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6679em;"></span><span class="mord text"><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6679em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">a</span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.25em;"><span class="mord">˜</span></span></span></span></span></span></span></span></span></span></span> <code>\~{a}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mtext>a</mtext><mo>˙</mo></mover></mrow><annotation encoding="application/x-tex">\text{\.{a}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6679em;"></span><span class="mord text"><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6679em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">a</span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.1389em;"><span class="mord">˙</span></span></span></span></span></span></span></span></span></span></span> <code>\.{a}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mtext>a</mtext><mo>˝</mo></mover></mrow><annotation encoding="application/x-tex">\text{\H{a}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6944em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">a</span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.25em;"><span class="mord">˝</span></span></span></span></span></span></span></span></span></span></span> <code>\H{a}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mtext>a</mtext><mo>ˋ</mo></mover></mrow><annotation encoding="application/x-tex">\text{\`{a}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6944em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">a</span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.25em;"><span class="mord">ˋ</span></span></span></span></span></span></span></span></span></span></span> <code>\`{a}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mtext>a</mtext><mo>ˉ</mo></mover></mrow><annotation encoding="application/x-tex">\text{\={a}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5678em;"></span><span class="mord text"><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.5678em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">a</span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.25em;"><span class="mord">ˉ</span></span></span></span></span></span></span></span></span></span></span> <code>\={a}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mtext>a</mtext><mo>¨</mo></mover></mrow><annotation encoding="application/x-tex">\text{\&quot;{a}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6679em;"></span><span class="mord text"><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6679em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">a</span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.25em;"><span class="mord">¨</span></span></span></span></span></span></span></span></span></span></span> <code>\&quot;{a}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mtext>a</mtext><mo>ˇ</mo></mover></mrow><annotation encoding="application/x-tex">\text{\v{a}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6285em;"></span><span class="mord text"><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6285em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">a</span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.25em;"><span class="mord">ˇ</span></span></span></span></span></span></span></span></span></span></span> <code>\v{a}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mtext>a</mtext><mo>ˆ</mo></mover></mrow><annotation encoding="application/x-tex">\text{\^{a}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6944em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">a</span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.25em;"><span class="mord">ˆ</span></span></span></span></span></span></span></span></span></span></span> <code>\^{a}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mtext>a</mtext><mo>˘</mo></mover></mrow><annotation encoding="application/x-tex">\text{\u{a}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6944em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">a</span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.25em;"><span class="mord">˘</span></span></span></span></span></span></span></span></span></span></span> <code>\u{a}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mtext>a</mtext><mo>˚</mo></mover></mrow><annotation encoding="application/x-tex">\text{\r{a}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6944em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">a</span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.375em;"><span class="mord">˚</span></span></span></span></span></span></span></span></span></span></span> <code>\r{a}</code></td>
<td style="text-align:left"></td>
</tr>
</tbody>
</table>
<p>See also <a href="#_5-letters-and-unicode">letters</a>.</p>
<h2 id="_2-delimiters" tabindex="-1">2: Delimiters <a class="header-anchor" href="#_2-delimiters" aria-label="Permalink to &quot;2: Delimiters&quot;">&ZeroWidthSpace;</a></h2>
<table>
<thead>
<tr>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">(</mo><mtext> </mtext><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">(~)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">(</span><span class="mspace nobreak"> </span><span class="mclose">)</span></span></span></span> <code>( )</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">(</mo><mtext> </mtext><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">\lparen~\rparen</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">(</span><span class="mspace nobreak"> </span><span class="mclose">)</span></span></span></span> <code>\lparen</code><br><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>    </mtext></mrow><annotation encoding="application/x-tex">~~~~</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0em;"></span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span></span></span></span><code>\rparen</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">⌈</mo><mtext> </mtext><mo stretchy="false">⌉</mo></mrow><annotation encoding="application/x-tex">⌈~⌉</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">⌈</span><span class="mspace nobreak"> </span><span class="mclose">⌉</span></span></span></span> <code>⌈ ⌉</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">⌈</mo><mtext> </mtext><mo stretchy="false">⌉</mo></mrow><annotation encoding="application/x-tex">\lceil~\rceil</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">⌈</span><span class="mspace nobreak"> </span><span class="mclose">⌉</span></span></span></span> <code>\lceil</code><br><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>     </mtext></mrow><annotation encoding="application/x-tex">~~~~~</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0em;"></span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span></span></span></span><code>\rceil</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↑</mo></mrow><annotation encoding="application/x-tex">\uparrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel">↑</span></span></span></span> <code>\uparrow</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">[</mo><mtext> </mtext><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">[~]</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">[</span><span class="mspace nobreak"> </span><span class="mclose">]</span></span></span></span> <code>[ ]</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">[</mo><mtext> </mtext><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">\lbrack~\rbrack</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">[</span><span class="mspace nobreak"> </span><span class="mclose">]</span></span></span></span> <code>\lbrack</code><br><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>    </mtext></mrow><annotation encoding="application/x-tex">~~~~</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0em;"></span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span></span></span></span><code>\rbrack</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">⌊</mo><mtext> </mtext><mo stretchy="false">⌋</mo></mrow><annotation encoding="application/x-tex">⌊~⌋</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">⌊</span><span class="mspace nobreak"> </span><span class="mclose">⌋</span></span></span></span> <code>⌊ ⌋</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">⌊</mo><mtext> </mtext><mo stretchy="false">⌋</mo></mrow><annotation encoding="application/x-tex">\lfloor~\rfloor</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">⌊</span><span class="mspace nobreak"> </span><span class="mclose">⌋</span></span></span></span> <code>\lfloor</code><br><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>     </mtext></mrow><annotation encoding="application/x-tex">~~~~~</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0em;"></span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span></span></span></span><code>\rfloor</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↓</mo></mrow><annotation encoding="application/x-tex">\downarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel">↓</span></span></span></span> <code>\downarrow</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">{</mo><mo stretchy="false">}</mo></mrow><annotation encoding="application/x-tex">\{ \}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">{</span><span class="mclose">}</span></span></span></span> <code>\{ \}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">{</mo><mo stretchy="false">}</mo></mrow><annotation encoding="application/x-tex">\lbrace \rbrace</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">{</span><span class="mclose">}</span></span></span></span> <code>\lbrace</code><br><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>    </mtext></mrow><annotation encoding="application/x-tex">~~~~</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0em;"></span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span></span></span></span><code>\rbrace</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">⎰</mo><mo stretchy="false">⎱</mo></mrow><annotation encoding="application/x-tex">⎰⎱</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.989em;vertical-align:-0.244em;"></span><span class="mopen">⎰</span><span class="mclose">⎱</span></span></span></span> <code>⎰⎱</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">⎰</mo><mo stretchy="false">⎱</mo></mrow><annotation encoding="application/x-tex">\lmoustache \rmoustache</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.989em;vertical-align:-0.244em;"></span><span class="mopen">⎰</span><span class="mclose">⎱</span></span></span></span> <code>\lmoustache</code><br><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>    </mtext></mrow><annotation encoding="application/x-tex">~~~~</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0em;"></span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span></span></span></span><code>\rmoustache</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↕</mo></mrow><annotation encoding="application/x-tex">\updownarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mrel">↕</span></span></span></span> <code>\updownarrow</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">⟨</mo><mtext> </mtext><mo stretchy="false">⟩</mo></mrow><annotation encoding="application/x-tex">⟨~⟩</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">⟨</span><span class="mspace nobreak"> </span><span class="mclose">⟩</span></span></span></span> <code>⟨ ⟩</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">⟨</mo><mtext> </mtext><mo stretchy="false">⟩</mo></mrow><annotation encoding="application/x-tex">\langle~\rangle</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">⟨</span><span class="mspace nobreak"> </span><span class="mclose">⟩</span></span></span></span> <code>\langle</code><br><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>    </mtext></mrow><annotation encoding="application/x-tex">~~~~</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0em;"></span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span></span></span></span><code>\rangle</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">⟮</mo><mtext> </mtext><mo stretchy="false">⟯</mo></mrow><annotation encoding="application/x-tex">⟮~⟯</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.989em;vertical-align:-0.244em;"></span><span class="mopen">⟮</span><span class="mspace nobreak"> </span><span class="mclose">⟯</span></span></span></span> <code>⟮ ⟯</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">⟮</mo><mtext> </mtext><mo stretchy="false">⟯</mo></mrow><annotation encoding="application/x-tex">\lgroup~\rgroup</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.989em;vertical-align:-0.244em;"></span><span class="mopen">⟮</span><span class="mspace nobreak"> </span><span class="mclose">⟯</span></span></span></span> <code>\lgroup</code><br><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>     </mtext></mrow><annotation encoding="application/x-tex">~~~~~</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0em;"></span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span></span></span></span><code>\rgroup</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇑</mo></mrow><annotation encoding="application/x-tex">\Uparrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel">⇑</span></span></span></span> <code>\Uparrow</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∣</mi></mrow><annotation encoding="application/x-tex">\vert</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">∣</span></span></span></span> <code>|</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∣</mi></mrow><annotation encoding="application/x-tex">\vert</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">∣</span></span></span></span> <code>\vert</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">┌</mo><mo stretchy="false">┐</mo></mrow><annotation encoding="application/x-tex">┌ ┐</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mopen amsrm">┌</span><span class="mclose amsrm">┐</span></span></span></span> <code>┌ ┐</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mi mathvariant="normal">⌜</mi></mo><mo><mi mathvariant="normal">⌝</mi></mo></mrow><annotation encoding="application/x-tex">\ulcorner \urcorner</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mopen amsrm">┌</span><span class="mclose amsrm">┐</span></span></span></span> <code>\ulcorner</code><br><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>    </mtext></mrow><annotation encoding="application/x-tex">~~~~</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0em;"></span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span></span></span></span><code>\urcorner</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇓</mo></mrow><annotation encoding="application/x-tex">\Downarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel">⇓</span></span></span></span> <code>\Downarrow</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∥</mi></mrow><annotation encoding="application/x-tex">\Vert</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">∥</span></span></span></span> <code>\|</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∥</mi></mrow><annotation encoding="application/x-tex">\Vert</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">∥</span></span></span></span> <code>\Vert</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">└</mo><mo stretchy="false">┘</mo></mrow><annotation encoding="application/x-tex">└ ┘</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3779em;"></span><span class="mopen amsrm">└</span><span class="mclose amsrm">┘</span></span></span></span> <code>└ ┘</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mi mathvariant="normal">⌞</mi></mo><mo><mi mathvariant="normal">⌟</mi></mo></mrow><annotation encoding="application/x-tex">\llcorner \lrcorner</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3779em;"></span><span class="mopen amsrm">└</span><span class="mclose amsrm">┘</span></span></span></span> <code>\llcorner</code><br><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>    </mtext></mrow><annotation encoding="application/x-tex">~~~~</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0em;"></span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span></span></span></span><code>\lrcorner</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇕</mo></mrow><annotation encoding="application/x-tex">\Updownarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mrel">⇕</span></span></span></span> <code>\Updownarrow</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">∣</mo><mtext> </mtext><mo stretchy="false">∣</mo></mrow><annotation encoding="application/x-tex">\lvert~\rvert</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">∣</span><span class="mspace nobreak"> </span><span class="mclose">∣</span></span></span></span> <code>\lvert</code><br><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>    </mtext></mrow><annotation encoding="application/x-tex">~~~~</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0em;"></span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span></span></span></span><code>\rvert</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">∥</mo><mtext> </mtext><mo stretchy="false">∥</mo></mrow><annotation encoding="application/x-tex">\lVert~\rVert</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">∥</span><span class="mspace nobreak"> </span><span class="mclose">∥</span></span></span></span> <code>\lVert</code><br><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>     </mtext></mrow><annotation encoding="application/x-tex">~~~~~</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0em;"></span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span></span></span></span><code>\rVert</code></td>
<td style="text-align:left"><code>\left.</code></td>
<td style="text-align:left"><code>\right.</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">\</mi></mrow><annotation encoding="application/x-tex">\backslash</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">\</span></span></span></span> <code>\backslash</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">⟨</mo><mtext> </mtext><mo stretchy="false">⟩</mo></mrow><annotation encoding="application/x-tex">\lang~\rang</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">⟨</span><span class="mspace nobreak"> </span><span class="mclose">⟩</span></span></span></span> <code>\lang</code><br><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>    </mtext></mrow><annotation encoding="application/x-tex">~~~~</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0em;"></span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span><span class="mspace nobreak"> </span></span></span></span><code>\rang</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>&lt;</mo><mtext> </mtext><mo>&gt;</mo></mrow><annotation encoding="application/x-tex">\lt~\gt</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">&lt;</span><span class="mspace nobreak"> </span><span class="mrel">&gt;</span></span></span></span> <code>\lt \gt</code></td>
<td style="text-align:left"></td>
<td style="text-align:left"></td>
<td style="text-align:left"></td>
</tr>
</tbody>
</table>
<p><strong>Delimiter Sizing</strong></p>
<p><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true">(</mo><mstyle mathsize="1.728em"><mrow><mi>A</mi><mi>B</mi></mrow></mstyle><mo fence="true">)</mo></mrow><annotation encoding="application/x-tex">\left(\LARGE{AB}\right)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.8308em;vertical-align:-0.65em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size2">(</span></span><span class="mord sizing reset-size6 size9"><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size2">)</span></span></span></span></span></span> <code>\left(\LARGE{AB}\right)</code></p>
<p><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">(</mo><mo fence="false" stretchy="true" minsize="1.2em" maxsize="1.2em">(</mo><mo fence="false" stretchy="true" minsize="1.8em" maxsize="1.8em">(</mo><mo fence="false" stretchy="true" minsize="2.4em" maxsize="2.4em">(</mo><mo fence="false" stretchy="true" minsize="3em" maxsize="3em">(</mo></mrow><annotation encoding="application/x-tex">( \big( \Big( \bigg( \Bigg(</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:3em;vertical-align:-1.25em;"></span><span class="mopen">(</span><span class="mord"><span class="delimsizing size1">(</span></span><span class="mord"><span class="delimsizing size2">(</span></span><span class="mord"><span class="delimsizing size3">(</span></span><span class="mord"><span class="delimsizing size4">(</span></span></span></span></span> <code>( \big( \Big( \bigg( \Bigg(</code></p>
<table>
<thead>
<tr>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left"><code>\left</code></td>
<td style="text-align:left"><code>\big</code></td>
<td style="text-align:left"><code>\bigl</code></td>
<td style="text-align:left"><code>\bigm</code></td>
<td style="text-align:left"><code>\bigr</code></td>
</tr>
<tr>
<td style="text-align:left"><code>\middle</code></td>
<td style="text-align:left"><code>\Big</code></td>
<td style="text-align:left"><code>\Bigl</code></td>
<td style="text-align:left"><code>\Bigm</code></td>
<td style="text-align:left"><code>\Bigr</code></td>
</tr>
<tr>
<td style="text-align:left"><code>\right</code></td>
<td style="text-align:left"><code>\bigg</code></td>
<td style="text-align:left"><code>\biggl</code></td>
<td style="text-align:left"><code>\biggm</code></td>
<td style="text-align:left"><code>\biggr</code></td>
</tr>
<tr>
<td style="text-align:left"></td>
<td style="text-align:left"><code>\Bigg</code></td>
<td style="text-align:left"><code>\Biggl</code></td>
<td style="text-align:left"><code>\Biggm</code></td>
<td style="text-align:left"><code>\Biggr</code></td>
</tr>
</tbody>
</table>
<h2 id="_3-environments" tabindex="-1">3: Environments <a class="header-anchor" href="#_3-environments" aria-label="Permalink to &quot;3: Environments&quot;">&ZeroWidthSpace;</a></h2>
<table>
<thead>
<tr>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mtable rowspacing="0.16em" columnalign="center center" columnspacing="1em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>a</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>b</mi></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>c</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>d</mi></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{matrix} a &amp; b \\ c &amp; d \end{matrix}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.4em;vertical-align:-0.95em;"></span><span class="mord"><span class="mtable"><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:0.5em;"></span><span class="arraycolsep" style="width:0.5em;"></span><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">b</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">d</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\begin{matrix}</code><br>   <code>a &amp; b \\</code><br>   <code>c &amp; d</code><br><code>\end{matrix}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mtable rowspacing="0.16em" columnalign="center center" columnspacing="1em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>a</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>b</mi></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>c</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>d</mi></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{array}{cc}a &amp; b\\c &amp; d\end{array}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.4em;vertical-align:-0.95em;"></span><span class="mord"><span class="mtable"><span class="arraycolsep" style="width:0.5em;"></span><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:0.5em;"></span><span class="arraycolsep" style="width:0.5em;"></span><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">b</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">d</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:0.5em;"></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\begin{array}{cc}</code><br>   <code>a &amp; b \\</code><br>   <code>c &amp; d</code><br><code>\end{array}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true">(</mo><mtable rowspacing="0.16em" columnalign="center center" columnspacing="1em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>a</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>b</mi></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>c</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>d</mi></mstyle></mtd></mtr></mtable><mo fence="true">)</mo></mrow><annotation encoding="application/x-tex">\begin{pmatrix} a &amp; b \\ c &amp; d \end{pmatrix}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.4em;vertical-align:-0.95em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size3">(</span></span><span class="mord"><span class="mtable"><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:0.5em;"></span><span class="arraycolsep" style="width:0.5em;"></span><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">b</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">d</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size3">)</span></span></span></span></span></span></td>
<td style="text-align:left"><code>\begin{pmatrix}</code><br>   <code>a &amp; b \\</code><br>   <code>c &amp; d</code><br><code>\end{pmatrix}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true">[</mo><mtable rowspacing="0.16em" columnalign="center center" columnspacing="1em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>a</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>b</mi></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>c</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>d</mi></mstyle></mtd></mtr></mtable><mo fence="true">]</mo></mrow><annotation encoding="application/x-tex">\begin{bmatrix} a &amp; b \\ c &amp; d \end{bmatrix}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.4em;vertical-align:-0.95em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size3">[</span></span><span class="mord"><span class="mtable"><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:0.5em;"></span><span class="arraycolsep" style="width:0.5em;"></span><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">b</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">d</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size3">]</span></span></span></span></span></span></td>
<td style="text-align:left"><code>\begin{bmatrix}</code><br>   <code>a &amp; b \\</code><br>   <code>c &amp; d</code><br><code>\end{bmatrix}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true">∣</mo><mtable rowspacing="0.16em" columnalign="center center" columnspacing="1em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>a</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>b</mi></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>c</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>d</mi></mstyle></mtd></mtr></mtable><mo fence="true">∣</mo></mrow><annotation encoding="application/x-tex">\begin{vmatrix} a &amp; b \\ c &amp; d \end{vmatrix}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.4em;vertical-align:-0.95em;"></span><span class="minner"><span class="mopen"><span class="delimsizing mult"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.45em;"><span class="pstrut" style="height:4.4em;"></span><span style="width:0.333em;height:2.400em;"><svg xmlns="http://www.w3.org/2000/svg" width='0.333em' height='2.400em' viewBox='0 0 333 2400'><path d='M145 15 v585 v1200 v585 c2.667,10,9.667,15,21,15
c10,0,16.667,-5,20,-15 v-585 v-1200 v-585 c-2.667,-10,-9.667,-15,-21,-15
c-10,0,-16.667,5,-20,15z M188 15 H145 v585 v1200 v585 h43z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span></span><span class="mord"><span class="mtable"><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:0.5em;"></span><span class="arraycolsep" style="width:0.5em;"></span><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">b</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">d</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span></span></span><span class="mclose"><span class="delimsizing mult"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.45em;"><span class="pstrut" style="height:4.4em;"></span><span style="width:0.333em;height:2.400em;"><svg xmlns="http://www.w3.org/2000/svg" width='0.333em' height='2.400em' viewBox='0 0 333 2400'><path d='M145 15 v585 v1200 v585 c2.667,10,9.667,15,21,15
c10,0,16.667,-5,20,-15 v-585 v-1200 v-585 c-2.667,-10,-9.667,-15,-21,-15
c-10,0,-16.667,5,-20,15z M188 15 H145 v585 v1200 v585 h43z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\begin{vmatrix}</code><br>   <code>a &amp; b \\</code><br>   <code>c &amp; d</code><br><code>\end{vmatrix}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true">∥</mo><mtable rowspacing="0.16em" columnalign="center center" columnspacing="1em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>a</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>b</mi></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>c</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>d</mi></mstyle></mtd></mtr></mtable><mo fence="true">∥</mo></mrow><annotation encoding="application/x-tex">\begin{Vmatrix} a &amp; b \\ c &amp; d \end{Vmatrix}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.4em;vertical-align:-0.95em;"></span><span class="minner"><span class="mopen"><span class="delimsizing mult"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.45em;"><span class="pstrut" style="height:4.4em;"></span><span style="width:0.556em;height:2.400em;"><svg xmlns="http://www.w3.org/2000/svg" width='0.556em' height='2.400em' viewBox='0 0 556 2400'><path d='M145 15 v585 v1200 v585 c2.667,10,9.667,15,21,15
c10,0,16.667,-5,20,-15 v-585 v-1200 v-585 c-2.667,-10,-9.667,-15,-21,-15
c-10,0,-16.667,5,-20,15z M188 15 H145 v585 v1200 v585 h43z
M367 15 v585 v1200 v585 c2.667,10,9.667,15,21,15
c10,0,16.667,-5,20,-15 v-585 v-1200 v-585 c-2.667,-10,-9.667,-15,-21,-15
c-10,0,-16.667,5,-20,15z M410 15 H367 v585 v1200 v585 h43z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span></span><span class="mord"><span class="mtable"><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:0.5em;"></span><span class="arraycolsep" style="width:0.5em;"></span><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">b</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">d</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span></span></span><span class="mclose"><span class="delimsizing mult"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.45em;"><span class="pstrut" style="height:4.4em;"></span><span style="width:0.556em;height:2.400em;"><svg xmlns="http://www.w3.org/2000/svg" width='0.556em' height='2.400em' viewBox='0 0 556 2400'><path d='M145 15 v585 v1200 v585 c2.667,10,9.667,15,21,15
c10,0,16.667,-5,20,-15 v-585 v-1200 v-585 c-2.667,-10,-9.667,-15,-21,-15
c-10,0,-16.667,5,-20,15z M188 15 H145 v585 v1200 v585 h43z
M367 15 v585 v1200 v585 c2.667,10,9.667,15,21,15
c10,0,16.667,-5,20,-15 v-585 v-1200 v-585 c-2.667,-10,-9.667,-15,-21,-15
c-10,0,-16.667,5,-20,15z M410 15 H367 v585 v1200 v585 h43z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\begin{Vmatrix}</code><br>   <code>a &amp; b \\</code><br>   <code>c &amp; d</code><br><code>\end{Vmatrix}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true">{</mo><mtable rowspacing="0.16em" columnalign="center center" columnspacing="1em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>a</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>b</mi></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>c</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>d</mi></mstyle></mtd></mtr></mtable><mo fence="true">}</mo></mrow><annotation encoding="application/x-tex">\begin{Bmatrix} a &amp; b \\ c &amp; d \end{Bmatrix}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.4em;vertical-align:-0.95em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size3">{</span></span><span class="mord"><span class="mtable"><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:0.5em;"></span><span class="arraycolsep" style="width:0.5em;"></span><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">b</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">d</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size3">}</span></span></span></span></span></span></td>
<td style="text-align:left"><code>\begin{Bmatrix}</code><br>   <code>a &amp; b \\</code><br>   <code>c &amp; d</code><br><code>\end{Bmatrix}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mtable rowspacing="0.66em" columnalign="center center center" columnlines="dashed dashed" columnspacing="1em" rowlines="solid dashed"><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>a</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>b</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>c</mi></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>d</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>e</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>f</mi></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>g</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>h</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>i</mi></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\def\arraystretch{1.5}\begin{array}{c:c:c} a &amp; b &amp; c \\ \hline d &amp; e &amp; f \\ \hdashline g &amp; h &amp; i \end{array}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:5.4em;vertical-align:-2.45em;"></span><span class="mord"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:2.95em;"><span style="top:-4.95em;"><span class="pstrut" style="height:4.95em;"></span><span class="mtable"><span class="arraycolsep" style="width:0.5em;"></span><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:2.95em;"><span style="top:-4.95em;"><span class="pstrut" style="height:3.26em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span><span style="top:-3.15em;"><span class="pstrut" style="height:3.26em;"></span><span class="mord"><span class="mord mathnormal">d</span></span></span><span style="top:-1.35em;"><span class="pstrut" style="height:3.26em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">g</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:2.45em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:0.5em;"></span><span class="vertical-separator" style="height:5.4em;border-right-width:0.04em;border-right-style:dashed;margin:0 -0.02em;vertical-align:-2.45em;"></span><span class="arraycolsep" style="width:0.5em;"></span><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:2.95em;"><span style="top:-4.95em;"><span class="pstrut" style="height:3.26em;"></span><span class="mord"><span class="mord mathnormal">b</span></span></span><span style="top:-3.15em;"><span class="pstrut" style="height:3.26em;"></span><span class="mord"><span class="mord mathnormal">e</span></span></span><span style="top:-1.35em;"><span class="pstrut" style="height:3.26em;"></span><span class="mord"><span class="mord mathnormal">h</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:2.45em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:0.5em;"></span><span class="vertical-separator" style="height:5.4em;border-right-width:0.04em;border-right-style:dashed;margin:0 -0.02em;vertical-align:-2.45em;"></span><span class="arraycolsep" style="width:0.5em;"></span><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:2.95em;"><span style="top:-4.95em;"><span class="pstrut" style="height:3.26em;"></span><span class="mord"><span class="mord mathnormal">c</span></span></span><span style="top:-3.15em;"><span class="pstrut" style="height:3.26em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.10764em;">f</span></span></span><span style="top:-1.35em;"><span class="pstrut" style="height:3.26em;"></span><span class="mord"><span class="mord mathnormal">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:2.45em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:0.5em;"></span></span></span><span style="top:-4.3em;"><span class="pstrut" style="height:4.95em;"></span><span class="hdashline" style="border-bottom-width:0.04em;"></span></span><span style="top:-6.1em;"><span class="pstrut" style="height:4.95em;"></span><span class="hline" style="border-bottom-width:0.04em;"></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:2.45em;"><span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\def\arraystretch{1.5}</code><br>   <code>\begin{array}{c:c:c}</code><br>   <code>a &amp; b &amp; c \\ \hline</code><br>   <code>d &amp; e &amp; f \\</code><br>   <code>\hdashline</code><br>   <code>g &amp; h &amp; i</code><br><code>\end{array}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mtable rowspacing="0.25em" columnalign="right left" columnspacing="0em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mi>a</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mo>=</mo><mi>b</mi><mo>+</mo><mi>c</mi></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mi>d</mi><mo>+</mo><mi>e</mi></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mo>=</mo><mi>f</mi></mrow></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{aligned} a&amp;=b+c \\ d+e&amp;=f \end{aligned}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:3em;vertical-align:-1.25em;"></span><span class="mord"><span class="mtable"><span class="col-align-r"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.75em;"><span style="top:-3.91em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">d</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal">e</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.25em;"><span></span></span></span></span></span><span class="col-align-l"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.75em;"><span style="top:-3.91em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord mathnormal">b</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal">c</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord mathnormal" style="margin-right:0.10764em;">f</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.25em;"><span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\begin{aligned}</code><br>   <code>a&amp;=b+c \\</code><br>   <code>d+e&amp;=f</code><br><code>\end{aligned}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mtable rowspacing="0.25em" columnalign="right left right left" columnspacing="0em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mn>10</mn></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mi>x</mi><mo>+</mo></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mn>3</mn></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mi>y</mi><mo>=</mo><mn>2</mn></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mn>3</mn></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mi>x</mi><mo>+</mo></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mn>13</mn></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mi>y</mi><mo>=</mo><mn>4</mn></mrow></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{alignedat}{2}10&amp;x+&amp;3&amp;y=2\\3&amp;x+&amp;13&amp;y=4\end{alignedat}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:3em;vertical-align:-1.25em;"></span><span class="mord"><span class="mtable"><span class="col-align-r"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.75em;"><span style="top:-3.91em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">10</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">3</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.25em;"><span></span></span></span></span></span><span class="col-align-l"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.75em;"><span style="top:-3.91em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"></span><span class="mord mathnormal">x</span><span class="mord">+</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"></span><span class="mord mathnormal">x</span><span class="mord">+</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.25em;"><span></span></span></span></span></span><span class="col-align-r"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.75em;"><span style="top:-3.91em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">3</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">13</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.25em;"><span></span></span></span></span></span><span class="col-align-l"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.75em;"><span style="top:-3.91em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"></span><span class="mord mathnormal" style="margin-right:0.03588em;">y</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord">2</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"></span><span class="mord mathnormal" style="margin-right:0.03588em;">y</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord">4</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.25em;"><span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\begin{alignedat}{2}</code><br>   <code>10&amp;x+ &amp;3&amp;y = 2 \\</code><br>   <code> 3&amp;x+&amp;13&amp;y = 4</code><br><code>\end{alignedat}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mtable rowspacing="0.25em" columnalign="center" columnspacing="0em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mi>a</mi><mo>=</mo><mi>b</mi></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mi>e</mi><mo>=</mo><mi>b</mi><mo>+</mo><mi>c</mi></mrow></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{gathered} a=b \\ e=b+c \end{gathered}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:3em;vertical-align:-1.25em;"></span><span class="mord"><span class="mtable"><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.75em;"><span style="top:-3.91em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord mathnormal">b</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">e</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord mathnormal">b</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.25em;"><span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\begin{gathered}</code><br>   <code>a=b \\ </code><br>   <code>e=b+c</code><br><code>\end{gathered}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>x</mi><mo>=</mo><mrow><mo fence="true">{</mo><mtable rowspacing="0.36em" columnalign="left left" columnspacing="1em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>a</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mrow><mtext>if </mtext><mi>b</mi></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>c</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mrow><mtext>if </mtext><mi>d</mi></mrow></mstyle></mtd></mtr></mtable></mrow></mrow><annotation encoding="application/x-tex">x = \begin{cases} a &amp;\text{if } b \\ c &amp;\text{if } d \end{cases}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">x</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:3em;vertical-align:-1.25em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size4">{</span></span><span class="mord"><span class="mtable"><span class="col-align-l"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.69em;"><span style="top:-3.69em;"><span class="pstrut" style="height:3.008em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span><span style="top:-2.25em;"><span class="pstrut" style="height:3.008em;"></span><span class="mord"><span class="mord mathnormal">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.19em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:1em;"></span><span class="col-align-l"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.69em;"><span style="top:-3.69em;"><span class="pstrut" style="height:3.008em;"></span><span class="mord"><span class="mord text"><span class="mord">if </span></span><span class="mord mathnormal">b</span></span></span><span style="top:-2.25em;"><span class="pstrut" style="height:3.008em;"></span><span class="mord"><span class="mord text"><span class="mord">if </span></span><span class="mord mathnormal">d</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.19em;"><span></span></span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span></td>
<td style="text-align:left"><code>x = \begin{cases}</code><br>   <code>a &amp;\text{if } b  \\</code><br>   <code>c &amp;\text{if } d</code><br><code>\end{cases}</code></td>
</tr>
</tbody>
</table>
<p>KaTeX also supports <code>darray</code> and <code>dcases</code>.</p>
<p>Acceptable line separators include: <code>\\</code>, <code>\cr</code>, <code>\\[distance]</code>, and <code>\cr[distance]</code>. <em>Distance</em> can be written with any of the <a href="#units">KaTeX units</a>.</p>
<p>The <code>{array}</code> environment supports <code>|</code> and <code>:</code> vertical separators.</p>
<p>The <code>{array}</code> environment does not yet support <code>\cline</code> or <code>\multicolumn</code>.</p>
<h2 id="_4-html" tabindex="-1">4: HTML <a class="header-anchor" href="#_4-html" aria-label="Permalink to &quot;4: HTML&quot;">&ZeroWidthSpace;</a></h2>
<table>
<thead>
<tr>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathcolor="#cc0000"><mtext>\href</mtext></mstyle></mrow><annotation encoding="application/x-tex">\href{https://katex.org/}{\KaTeX}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\href</span></span></span></span></span></td>
<td style="text-align:left"><code>\href{https://katex.org/}{\KaTeX}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathcolor="#cc0000"><mtext>\url</mtext></mstyle></mrow><annotation encoding="application/x-tex">\url{https://katex.org/}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\url</span></span></span></span></span></td>
<td style="text-align:left"><code>\url{https://katex.org/}</code></td>
</tr>
</tbody>
</table>
<h2 id="_5-letters-and-unicode" tabindex="-1">5: Letters and Unicode <a class="header-anchor" href="#_5-letters-and-unicode" aria-label="Permalink to &quot;5: Letters and Unicode&quot;">&ZeroWidthSpace;</a></h2>
<p><strong>Greek Letters</strong></p>
<p>Direct Input: <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">A</mi><mi mathvariant="normal">B</mi><mi mathvariant="normal">Γ</mi><mi mathvariant="normal">Δ</mi><mi mathvariant="normal">E</mi><mi mathvariant="normal">Z</mi><mi mathvariant="normal">H</mi><mi mathvariant="normal">Θ</mi><mi mathvariant="normal">I</mi><mspace></mspace><mi mathvariant="normal">K</mi><mi mathvariant="normal">Λ</mi><mi mathvariant="normal">M</mi><mi mathvariant="normal">N</mi><mi mathvariant="normal">Ξ</mi><mi mathvariant="normal">O</mi><mi mathvariant="normal">Π</mi><mi mathvariant="normal">P</mi><mi mathvariant="normal">Σ</mi><mi mathvariant="normal">T</mi><mi mathvariant="normal">Υ</mi><mi mathvariant="normal">Φ</mi><mi mathvariant="normal">X</mi><mi mathvariant="normal">Ψ</mi><mi mathvariant="normal">Ω</mi></mrow><annotation encoding="application/x-tex">Α Β Γ Δ Ε Ζ Η Θ Ι \allowbreak Κ Λ Μ Ν Ξ Ο Π Ρ Σ Τ Υ Φ Χ Ψ Ω</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">ABΓΔEZHΘI</span><span class="mspace allowbreak"></span></span><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">KΛMNΞOΠPΣTΥΦXΨΩ</span></span></span></span>
<span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mspace></mspace><mi>α</mi><mi>β</mi><mi>γ</mi><mi>δ</mi><mi>ϵ</mi><mi>ζ</mi><mi>η</mi><mi>θ</mi><mi>ι</mi><mi>κ</mi><mi>λ</mi><mi>μ</mi><mi>ν</mi><mi>ξ</mi><mi>o</mi><mi>π</mi><mspace></mspace><mi>ρ</mi><mi>σ</mi><mi>τ</mi><mi>υ</mi><mi>ϕ</mi><mi>χ</mi><mi>ψ</mi><mi>ω</mi><mi>ε</mi><mi>ϑ</mi><mi>ϖ</mi><mi>ϱ</mi><mi>ς</mi><mi>φ</mi></mrow><annotation encoding="application/x-tex">\allowbreak α β γ δ ϵ ζ η θ ι κ λ μ ν ξ o π \allowbreak ρ σ τ υ ϕ χ ψ ω ε ϑ ϖ ϱ ς φ</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0em;"></span><span class="mspace allowbreak"></span></span><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.0037em;">α</span><span class="mord mathnormal" style="margin-right:0.05278em;">β</span><span class="mord mathnormal" style="margin-right:0.05556em;">γ</span><span class="mord mathnormal">δϵ</span><span class="mord mathnormal" style="margin-right:0.07378em;">ζ</span><span class="mord mathnormal" style="margin-right:0.03588em;">η</span><span class="mord mathnormal" style="margin-right:0.02778em;">θ</span><span class="mord mathnormal">ι</span><span class="mord mathnormal">κλ</span><span class="mord mathnormal" style="margin-right:0.06366em;">μν</span><span class="mord mathnormal" style="margin-right:0.04601em;">ξ</span><span class="mord mathnormal">o</span><span class="mord mathnormal" style="margin-right:0.03588em;">π</span><span class="mspace allowbreak"></span></span><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">ρ</span><span class="mord mathnormal" style="margin-right:0.03588em;">σ</span><span class="mord mathnormal" style="margin-right:0.03588em;">τυ</span><span class="mord mathnormal">ϕ</span><span class="mord mathnormal">χ</span><span class="mord mathnormal" style="margin-right:0.03588em;">ψ</span><span class="mord mathnormal" style="margin-right:0.03588em;">ω</span><span class="mord mathnormal">εϑ</span><span class="mord mathnormal" style="margin-right:0.02778em;">ϖ</span><span class="mord mathnormal">ϱςφ</span></span></span></span></p>
<table>
<thead>
<tr>
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">A</mi></mrow><annotation encoding="application/x-tex">\Alpha</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathrm">A</span></span></span></span> <code>\Alpha</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">B</mi></mrow><annotation encoding="application/x-tex">\Beta</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathrm">B</span></span></span></span> <code>\Beta</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Γ</mi></mrow><annotation encoding="application/x-tex">\Gamma</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">Γ</span></span></span></span> <code>\Gamma</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Δ</mi></mrow><annotation encoding="application/x-tex">\Delta</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">Δ</span></span></span></span> <code>\Delta</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">E</mi></mrow><annotation encoding="application/x-tex">\Epsilon</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathrm">E</span></span></span></span> <code>\Epsilon</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Z</mi></mrow><annotation encoding="application/x-tex">\Zeta</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathrm">Z</span></span></span></span> <code>\Zeta</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">H</mi></mrow><annotation encoding="application/x-tex">\Eta</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathrm">H</span></span></span></span> <code>\Eta</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Θ</mi></mrow><annotation encoding="application/x-tex">\Theta</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">Θ</span></span></span></span> <code>\Theta</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">I</mi></mrow><annotation encoding="application/x-tex">\Iota</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathrm">I</span></span></span></span> <code>\Iota</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">K</mi></mrow><annotation encoding="application/x-tex">\Kappa</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathrm">K</span></span></span></span> <code>\Kappa</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Λ</mi></mrow><annotation encoding="application/x-tex">\Lambda</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">Λ</span></span></span></span> <code>\Lambda</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">M</mi></mrow><annotation encoding="application/x-tex">\Mu</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathrm">M</span></span></span></span> <code>\Mu</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">N</mi></mrow><annotation encoding="application/x-tex">\Nu</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathrm">N</span></span></span></span> <code>\Nu</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Ξ</mi></mrow><annotation encoding="application/x-tex">\Xi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">Ξ</span></span></span></span> <code>\Xi</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">O</mi></mrow><annotation encoding="application/x-tex">\Omicron</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathrm">O</span></span></span></span> <code>\Omicron</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Π</mi></mrow><annotation encoding="application/x-tex">\Pi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">Π</span></span></span></span> <code>\Pi</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Σ</mi></mrow><annotation encoding="application/x-tex">\Sigma</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">Σ</span></span></span></span> <code>\Sigma</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">T</mi></mrow><annotation encoding="application/x-tex">\Tau</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathrm">T</span></span></span></span> <code>\Tau</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Υ</mi></mrow><annotation encoding="application/x-tex">\Upsilon</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">Υ</span></span></span></span> <code>\Upsilon</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Φ</mi></mrow><annotation encoding="application/x-tex">\Phi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">Φ</span></span></span></span> <code>\Phi</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">X</mi></mrow><annotation encoding="application/x-tex">\Chi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathrm">X</span></span></span></span> <code>\Chi</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Ψ</mi></mrow><annotation encoding="application/x-tex">\Psi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">Ψ</span></span></span></span> <code>\Psi</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Ω</mi></mrow><annotation encoding="application/x-tex">\Omega</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">Ω</span></span></span></span> <code>\Omega</code></td>
<td></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>Γ</mi></mrow><annotation encoding="application/x-tex">\varGamma</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathit">Γ</span></span></span></span> <code>\varGamma</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>Δ</mi></mrow><annotation encoding="application/x-tex">\varDelta</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathit">Δ</span></span></span></span> <code>\varDelta</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>Θ</mi></mrow><annotation encoding="application/x-tex">\varTheta</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathit">Θ</span></span></span></span> <code>\varTheta</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>Λ</mi></mrow><annotation encoding="application/x-tex">\varLambda</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathit">Λ</span></span></span></span> <code>\varLambda</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>Ξ</mi></mrow><annotation encoding="application/x-tex">\varXi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathit">Ξ</span></span></span></span> <code>\varXi</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>Π</mi></mrow><annotation encoding="application/x-tex">\varPi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathit">Π</span></span></span></span> <code>\varPi</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>Σ</mi></mrow><annotation encoding="application/x-tex">\varSigma</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathit">Σ</span></span></span></span> <code>\varSigma</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>Υ</mi></mrow><annotation encoding="application/x-tex">\varUpsilon</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathit">Υ</span></span></span></span> <code>\varUpsilon</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>Φ</mi></mrow><annotation encoding="application/x-tex">\varPhi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathit">Φ</span></span></span></span> <code>\varPhi</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>Ψ</mi></mrow><annotation encoding="application/x-tex">\varPsi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathit">Ψ</span></span></span></span> <code>\varPsi</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>Ω</mi></mrow><annotation encoding="application/x-tex">\varOmega</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathit">Ω</span></span></span></span> <code>\varOmega</code></td>
<td></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>α</mi></mrow><annotation encoding="application/x-tex">\alpha</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal" style="margin-right:0.0037em;">α</span></span></span></span> <code>\alpha</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>β</mi></mrow><annotation encoding="application/x-tex">\beta</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.05278em;">β</span></span></span></span> <code>\beta</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>γ</mi></mrow><annotation encoding="application/x-tex">\gamma</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.05556em;">γ</span></span></span></span> <code>\gamma</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>δ</mi></mrow><annotation encoding="application/x-tex">\delta</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal" style="margin-right:0.03785em;">δ</span></span></span></span> <code>\delta</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ϵ</mi></mrow><annotation encoding="application/x-tex">\epsilon</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">ϵ</span></span></span></span> <code>\epsilon</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ζ</mi></mrow><annotation encoding="application/x-tex">\zeta</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.07378em;">ζ</span></span></span></span> <code>\zeta</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>η</mi></mrow><annotation encoding="application/x-tex">\eta</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">η</span></span></span></span> <code>\eta</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>θ</mi></mrow><annotation encoding="application/x-tex">\theta</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal" style="margin-right:0.02778em;">θ</span></span></span></span> <code>\theta</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ι</mi></mrow><annotation encoding="application/x-tex">\iota</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">ι</span></span></span></span> <code>\iota</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>κ</mi></mrow><annotation encoding="application/x-tex">\kappa</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">κ</span></span></span></span> <code>\kappa</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>λ</mi></mrow><annotation encoding="application/x-tex">\lambda</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">λ</span></span></span></span> <code>\lambda</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>μ</mi></mrow><annotation encoding="application/x-tex">\mu</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">μ</span></span></span></span> <code>\mu</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ν</mi></mrow><annotation encoding="application/x-tex">\nu</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal" style="margin-right:0.06366em;">ν</span></span></span></span> <code>\nu</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ξ</mi></mrow><annotation encoding="application/x-tex">\xi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.04601em;">ξ</span></span></span></span> <code>\xi</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ο</mi></mrow><annotation encoding="application/x-tex">\omicron</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">ο</span></span></span></span> <code>\omicron</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>π</mi></mrow><annotation encoding="application/x-tex">\pi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">π</span></span></span></span> <code>\pi</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ρ</mi></mrow><annotation encoding="application/x-tex">\rho</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">ρ</span></span></span></span> <code>\rho</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>σ</mi></mrow><annotation encoding="application/x-tex">\sigma</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">σ</span></span></span></span> <code>\sigma</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>τ</mi></mrow><annotation encoding="application/x-tex">\tau</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal" style="margin-right:0.1132em;">τ</span></span></span></span> <code>\tau</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>υ</mi></mrow><annotation encoding="application/x-tex">\upsilon</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">υ</span></span></span></span> <code>\upsilon</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ϕ</mi></mrow><annotation encoding="application/x-tex">\phi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">ϕ</span></span></span></span> <code>\phi</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>χ</mi></mrow><annotation encoding="application/x-tex">\chi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">χ</span></span></span></span> <code>\chi</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ψ</mi></mrow><annotation encoding="application/x-tex">\psi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">ψ</span></span></span></span> <code>\psi</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ω</mi></mrow><annotation encoding="application/x-tex">\omega</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">ω</span></span></span></span> <code>\omega</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ε</mi></mrow><annotation encoding="application/x-tex">\varepsilon</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">ε</span></span></span></span> <code>\varepsilon</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">ϰ</mi></mrow><annotation encoding="application/x-tex">\varkappa</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord amsrm" style="margin-right:0.04028em;">ϰ</span></span></span></span> <code>\varkappa</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ϑ</mi></mrow><annotation encoding="application/x-tex">\vartheta</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">ϑ</span></span></span></span> <code>\vartheta</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ϑ</mi></mrow><annotation encoding="application/x-tex">\thetasym</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">ϑ</span></span></span></span> <code>\thetasym</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ϖ</mi></mrow><annotation encoding="application/x-tex">\varpi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal" style="margin-right:0.02778em;">ϖ</span></span></span></span> <code>\varpi</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ϱ</mi></mrow><annotation encoding="application/x-tex">\varrho</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">ϱ</span></span></span></span> <code>\varrho</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ς</mi></mrow><annotation encoding="application/x-tex">\varsigma</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5278em;vertical-align:-0.0972em;"></span><span class="mord mathnormal" style="margin-right:0.07986em;">ς</span></span></span></span> <code>\varsigma</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>φ</mi></mrow><annotation encoding="application/x-tex">\varphi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">φ</span></span></span></span> <code>\varphi</code></td>
</tr>
</tbody>
</table>
<p>| <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">ϝ</mi></mrow><annotation encoding="application/x-tex">\digamma</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6633em;vertical-align:-0.0817em;"></span><span class="mord amsrm">ϝ</span></span></span></span> <code>\digamma</code></p>
<p><strong>Other Letters</strong></p>
<table>
<thead>
<tr>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">ı</mi></mrow><annotation encoding="application/x-tex">\imath</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal"></span></span></span></span> <code>\imath</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∇</mi></mrow><annotation encoding="application/x-tex">\nabla</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">∇</span></span></span></span> <code>\nabla</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">ℑ</mi></mrow><annotation encoding="application/x-tex">\Im</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">ℑ</span></span></span></span> <code>\Im</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="double-struck">R</mi></mrow><annotation encoding="application/x-tex">\Reals</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord mathbb">R</span></span></span></span> <code>\Reals</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>Œ</mtext></mrow><annotation encoding="application/x-tex">\text{\OE}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord text"><span class="mord latin_fallback">Œ</span></span></span></span></span> <code>\text{\OE}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">ȷ</mi></mrow><annotation encoding="application/x-tex">\jmath</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal"></span></span></span></span> <code>\jmath</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∂</mi></mrow><annotation encoding="application/x-tex">\partial</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord" style="margin-right:0.05556em;">∂</span></span></span></span> <code>\partial</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">ℑ</mi></mrow><annotation encoding="application/x-tex">\image</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">ℑ</span></span></span></span> <code>\image</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">℘</mi></mrow><annotation encoding="application/x-tex">\wp</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord">℘</span></span></span></span> <code>\wp</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>ø</mtext></mrow><annotation encoding="application/x-tex">\text{\o}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.0972em;"></span><span class="mord text"><span class="mord">ø</span></span></span></span></span> <code>\text{\o}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">ℵ</mi></mrow><annotation encoding="application/x-tex">\aleph</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">ℵ</span></span></span></span> <code>\aleph</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">⅁</mi></mrow><annotation encoding="application/x-tex">\Game</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord amsrm">⅁</span></span></span></span> <code>\Game</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="double-struck">k</mi></mrow><annotation encoding="application/x-tex">\Bbbk</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord mathbb">k</span></span></span></span> <code>\Bbbk</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">℘</mi></mrow><annotation encoding="application/x-tex">\weierp</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord">℘</span></span></span></span> <code>\weierp</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>Ø</mtext></mrow><annotation encoding="application/x-tex">\text{\O}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7806em;vertical-align:-0.0486em;"></span><span class="mord text"><span class="mord">Ø</span></span></span></span></span> <code>\text{\O}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">ℵ</mi></mrow><annotation encoding="application/x-tex">\alef</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">ℵ</span></span></span></span> <code>\alef</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Ⅎ</mi></mrow><annotation encoding="application/x-tex">\Finv</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord amsrm">Ⅎ</span></span></span></span> <code>\Finv</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="double-struck">N</mi></mrow><annotation encoding="application/x-tex">\N</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord mathbb">N</span></span></span></span> <code>\N</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="double-struck">Z</mi></mrow><annotation encoding="application/x-tex">\Z</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord mathbb">Z</span></span></span></span> <code>\Z</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>ß</mtext></mrow><annotation encoding="application/x-tex">\text{\ss}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord">ß</span></span></span></span></span> <code>\text{\ss}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">ℵ</mi></mrow><annotation encoding="application/x-tex">\alefsym</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">ℵ</span></span></span></span> <code>\alefsym</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="double-struck">C</mi></mrow><annotation encoding="application/x-tex">\cnums</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord mathbb">C</span></span></span></span> <code>\cnums</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="double-struck">N</mi></mrow><annotation encoding="application/x-tex">\natnums</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord mathbb">N</span></span></span></span> <code>\natnums</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mtext>a</mtext><mo>˚</mo></mover></mrow><annotation encoding="application/x-tex">\text{\aa}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6944em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord">a</span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.375em;"><span class="mord">˚</span></span></span></span></span></span></span></span></span></span></span> <code>\text{\aa}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>ı</mtext></mrow><annotation encoding="application/x-tex">\text{\i}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord text"><span class="mord latin_fallback">ı</span></span></span></span></span> <code>\text{\i}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">ℶ</mi></mrow><annotation encoding="application/x-tex">\beth</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord amsrm">ℶ</span></span></span></span> <code>\beth</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="double-struck">C</mi></mrow><annotation encoding="application/x-tex">\Complex</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord mathbb">C</span></span></span></span> <code>\Complex</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="double-struck">R</mi></mrow><annotation encoding="application/x-tex">\R</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord mathbb">R</span></span></span></span> <code>\R</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mtext>A</mtext><mo>˚</mo></mover></mrow><annotation encoding="application/x-tex">\text{\AA}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9468em;"></span><span class="mord text"><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.9468em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord">A</span></span><span style="top:-3.2523em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.375em;"><span class="mord">˚</span></span></span></span></span></span></span></span></span></span></span> <code>\text{\AA}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>ȷ</mtext></mrow><annotation encoding="application/x-tex">\text{\j}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord text"><span class="mord latin_fallback">ȷ</span></span></span></span></span> <code>\text{\j}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">ℷ</mi></mrow><annotation encoding="application/x-tex">\gimel</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord amsrm">ℷ</span></span></span></span> <code>\gimel</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">ℓ</mi></mrow><annotation encoding="application/x-tex">\ell</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">ℓ</span></span></span></span> <code>\ell</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">ℜ</mi></mrow><annotation encoding="application/x-tex">\Re</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">ℜ</span></span></span></span> <code>\Re</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>æ</mtext></mrow><annotation encoding="application/x-tex">\text{\ae}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord text"><span class="mord">æ</span></span></span></span></span> <code>\text{\ae}</code></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">ℸ</mi></mrow><annotation encoding="application/x-tex">\daleth</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord amsrm">ℸ</span></span></span></span> <code>\daleth</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">ℏ</mi></mrow><annotation encoding="application/x-tex">\hbar</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord">ℏ</span></span></span></span> <code>\hbar</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">ℜ</mi></mrow><annotation encoding="application/x-tex">\real</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">ℜ</span></span></span></span> <code>\real</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>Æ</mtext></mrow><annotation encoding="application/x-tex">\text{\AE}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord text"><span class="mord">Æ</span></span></span></span></span> <code>\text{\AE}</code></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">ð</mi></mrow><annotation encoding="application/x-tex">\eth</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord amsrm">ð</span></span></span></span> <code>\eth</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">ℏ</mi></mrow><annotation encoding="application/x-tex">\hslash</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord amsrm">ℏ</span></span></span></span> <code>\hslash</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="double-struck">R</mi></mrow><annotation encoding="application/x-tex">\reals</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord mathbb">R</span></span></span></span> <code>\reals</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>œ</mtext></mrow><annotation encoding="application/x-tex">\text{\oe}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord text"><span class="mord latin_fallback">œ</span></span></span></span></span> <code>\text{\oe}</code></td>
<td style="text-align:left"></td>
</tr>
</tbody>
</table>
<p>Direct Input: <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∂</mi><mi mathvariant="normal">∇</mi><mi mathvariant="normal">ℑ</mi><mi mathvariant="normal">Ⅎ</mi><mi mathvariant="normal">ℵ</mi><mi mathvariant="normal">ℶ</mi><mi mathvariant="normal">ℷ</mi><mi mathvariant="normal">ℸ</mi><mi mathvariant="normal">⅁</mi><mi mathvariant="normal">ℏ</mi><mi mathvariant="normal">ð</mi></mrow><annotation encoding="application/x-tex">∂ ∇ ℑ Ⅎ ℵ ℶ ℷ ℸ ⅁ ℏ ð</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord" style="margin-right:0.05556em;">∂</span><span class="mord">∇ℑ</span><span class="mord amsrm">Ⅎ</span><span class="mord">ℵ</span><span class="mord amsrm">ℶℷℸ⅁</span><span class="mord">ℏ</span><span class="mord amsrm">ð</span></span></span></span>
ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖÙÚÛÜÝÞßàáâãäåçèéêëìíîïðñòóôöùúûüýþÿ</p>
<p><strong>Unicode Mathematical Alphanumeric Symbols</strong></p>
<table>
<thead>
<tr>
<th>Item</th>
<th>Range</th>
<th>Item</th>
<th>Range</th>
</tr>
</thead>
<tbody>
<tr>
<td>Bold</td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>𝐀-𝐙 𝐚-𝐳 𝟎-𝟗</mtext></mrow><annotation encoding="application/x-tex">\text{𝐀-𝐙 𝐚-𝐳 𝟎-𝟗}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6861em;"></span><span class="mord text"><span class="mord textbf">A</span><span class="mord">-</span><span class="mord textbf">Z</span><span class="mord"> </span><span class="mord textbf">a</span><span class="mord">-</span><span class="mord textbf">z</span><span class="mord"> </span><span class="mord textbf">0</span><span class="mord">-</span><span class="mord textbf">9</span></span></span></span></span></td>
<td>Double-struck</td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>𝔸-</mtext><mi mathvariant="normal">Z</mi><mtext> </mtext><mi>𝕜</mi></mrow><annotation encoding="application/x-tex">\text{𝔸-}ℤ\ 𝕜</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord text"><span class="mord textbb">A</span><span class="mord">-</span></span><span class="mord amsrm">Z</span><span class="mspace"> </span><span class="mord mathbb">k</span></span></span></span></td>
</tr>
<tr>
<td>Italic</td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>𝐴-𝑍 𝑎-𝑧</mtext></mrow><annotation encoding="application/x-tex">\text{𝐴-𝑍 𝑎-𝑧}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord text"><span class="mord textit">A</span><span class="mord">-</span><span class="mord textit">Z</span><span class="mord"> </span><span class="mord textit">a</span><span class="mord">-</span><span class="mord textit">z</span></span></span></span></span></td>
<td>Sans serif</td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>𝖠-𝖹 𝖺-𝗓 𝟢-𝟫</mtext></mrow><annotation encoding="application/x-tex">\text{𝖠-𝖹 𝖺-𝗓 𝟢-𝟫}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord textsf">A</span><span class="mord">-</span><span class="mord textsf">Z</span><span class="mord"> </span><span class="mord textsf">a</span><span class="mord">-</span><span class="mord textsf">z</span><span class="mord"> </span><span class="mord textsf">0</span><span class="mord">-</span><span class="mord textsf">9</span></span></span></span></span></td>
</tr>
<tr>
<td>Bold Italic</td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>𝑨-𝒁 𝒂-𝒛</mtext></mrow><annotation encoding="application/x-tex">\text{𝑨-𝒁 𝒂-𝒛}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6861em;"></span><span class="mord text"><span class="mord boldsymbol">A</span><span class="mord">-</span><span class="mord boldsymbol">Z</span><span class="mord"> </span><span class="mord boldsymbol">a</span><span class="mord">-</span><span class="mord boldsymbol">z</span></span></span></span></span></td>
<td>Sans serif bold</td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>𝗔-𝗭 𝗮-𝘇 𝟬-𝟵</mtext></mrow><annotation encoding="application/x-tex">\text{𝗔-𝗭 𝗮-𝘇 𝟬-𝟵}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord textboldsf">A</span><span class="mord">-</span><span class="mord textboldsf">Z</span><span class="mord"> </span><span class="mord textboldsf">a</span><span class="mord">-</span><span class="mord textboldsf">z</span><span class="mord"> </span><span class="mord textboldsf">0</span><span class="mord">-</span><span class="mord textboldsf">9</span></span></span></span></span></td>
</tr>
<tr>
<td>Script</td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>𝒜-𝒵</mtext></mrow><annotation encoding="application/x-tex">\text{𝒜-𝒵}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7em;"></span><span class="mord text"><span class="mord textscr">A</span><span class="mord">-</span><span class="mord textscr">Z</span></span></span></span></span></td>
<td>Sans serif italic</td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>𝘈-𝘡 𝘢-𝘻</mtext></mrow><annotation encoding="application/x-tex">\text{𝘈-𝘡 𝘢-𝘻}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord textitsf">A</span><span class="mord">-</span><span class="mord textitsf">Z</span><span class="mord"> </span><span class="mord textitsf">a</span><span class="mord">-</span><span class="mord textitsf">z</span></span></span></span></span></td>
</tr>
<tr>
<td>Fractur</td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>𝔄-</mtext><mi mathvariant="fraktur">Z</mi><mtext> 𝔞-𝔷</mtext></mrow><annotation encoding="application/x-tex">\text{𝔄-}ℨ\text{ 𝔞-𝔷}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8805em;vertical-align:-0.1891em;"></span><span class="mord text"><span class="mord textfrak">A</span><span class="mord">-</span></span><span class="mord mathfrak">Z</span><span class="mord text"><span class="mord"> </span><span class="mord textfrak">a</span><span class="mord">-</span><span class="mord textfrak">z</span></span></span></span></span></td>
<td>Monospace</td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>𝙰-𝚉 𝚊-𝚣 𝟶-𝟿</mtext></mrow><annotation encoding="application/x-tex">\text{𝙰-𝚉 𝚊-𝚣 𝟶-𝟿}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6111em;"></span><span class="mord text"><span class="mord texttt">A</span><span class="mord">-</span><span class="mord texttt">Z</span><span class="mord"> </span><span class="mord texttt">a</span><span class="mord">-</span><span class="mord texttt">z</span><span class="mord"> </span><span class="mord texttt">0</span><span class="mord">-</span><span class="mord texttt">9</span></span></span></span></span></td>
</tr>
</tbody>
</table>
<p><strong>Unicode</strong></p>
<p>The letters listed above will render in any KaTeX rendering mode.</p>
<p>If the KaTeX rendering mode is set to <code>strict: false</code> or <code>strict:&quot;warn&quot;</code> (default), then KaTeX will accept all Unicode letters. The letters not listed above will be rendered from system fonts, not KaTeX-supplied fonts, so their typography may clash. They may also cause small vertical alignment issues. KaTeX has detailed metrics for glyphs in Latin, Greek, and Cyrillic, but other glyphs are treated as if they are each as tall as the letter M.</p>
<p>For Persian composite characters, a user-supplied <a href="https://github.com/HosseinAgha/persian-katex-plugin" target="_blank" rel="noreferrer">plug-in</a> is under development.</p>
<h2 id="_6-layout" tabindex="-1">6: Layout <a class="header-anchor" href="#_6-layout" aria-label="Permalink to &quot;6: Layout&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="_6-1-annotation" tabindex="-1">6.1: Annotation <a class="header-anchor" href="#_6-1-annotation" aria-label="Permalink to &quot;6.1: Annotation&quot;">&ZeroWidthSpace;</a></h3>
<table>
<thead>
<tr>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><menclose notation="updiagonalstrike"><mn>5</mn></menclose></mrow><annotation encoding="application/x-tex">\cancel{5}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8444em;"><span style="top:-3.0444em;"><span class="pstrut" style="height:3.0444em;"></span><span class="mord"><span class="mord">5</span></span></span><span class="svg-align" style="top:-2.8444em;"><span class="pstrut" style="height:3.0444em;"></span><span style="height:1.0444em;"><svg xmlns="http://www.w3.org/2000/svg" width='100%' height='1.0444em'><line x1='0' y1='100%' x2='100%' y2='0' stroke-width='0.046em'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2em;"><span></span></span></span></span></span></span></span></span> <code>\cancel{5}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mover><mrow><mi>a</mi><mo>+</mo><mi>b</mi><mo>+</mo><mi>c</mi></mrow><mo stretchy="true">⏞</mo></mover><mtext>note</mtext></mover></mrow><annotation encoding="application/x-tex">\overbrace{a+b+c}^{\text{note}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.0563em;vertical-align:-0.0833em;"></span><span class="mord mover"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.973em;"><span style="top:-3.3424em;"><span class="pstrut" style="height:3.3424em;"></span><span class="mord mover"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.3424em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal">b</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal">c</span></span></span><span class="svg-align" style="top:-3.7944em;"><span class="pstrut" style="height:3em;"></span><span class="stretchy" style="height:0.548em;min-width:1.6em;"><span class="brace-left" style="height:0.548em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.548em' viewBox='0 0 400000 548' preserveAspectRatio='xMinYMin slice'><path d='M6 548l-6-6v-35l6-11c56-104 135.3-181.3 238-232 57.3-28.7 117
-45 179-50h399577v120H403c-43.3 7-81 15-113 26-100.7 33-179.7 91-237 174-2.7
 5-6 9-10 13-.7 1-7.3 1-20 1H6z'/></svg></span><span class="brace-center" style="height:0.548em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.548em' viewBox='0 0 400000 548' preserveAspectRatio='xMidYMin slice'><path d='M200428 334
c-100.7-8.3-195.3-44-280-108-55.3-42-101.7-93-139-153l-9-14c-2.7 4-5.7 8.7-9 14
-53.3 86.7-123.7 153-211 199-66.7 36-137.3 56.3-212 62H0V214h199568c178.3-11.7
 311.7-78.3 403-201 6-8 9.7-12 11-12 .7-.7 6.7-1 18-1s17.3.3 18 1c1.3 0 5 4 11
 12 44.7 59.3 101.3 106.3 170 141s145.3 54.3 229 60h199572v120z'/></svg></span><span class="brace-right" style="height:0.548em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.548em' viewBox='0 0 400000 548' preserveAspectRatio='xMaxYMin slice'><path d='M400000 542l
-6 6h-17c-12.7 0-19.3-.3-20-1-4-4-7.3-8.3-10-13-35.3-51.3-80.8-93.8-136.5-127.5
s-117.2-55.8-184.5-66.5c-.7 0-2-.3-4-1-18.7-2.7-76-4.3-172-5H0V214h399571l6 1
c124.7 8 235 61.7 331 161 31.3 33.3 59.7 72.7 85 118l7 13v35z'/></svg></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.0833em;"><span></span></span></span></span></span></span><span style="top:-4.8849em;"><span class="pstrut" style="height:3.3424em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord text mtight"><span class="mord mtight">note</span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.0833em;"><span></span></span></span></span></span></span></span></span> <code>\overbrace{a+b+c}^{\text{note}}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><menclose notation="downdiagonalstrike"><mn>5</mn></menclose></mrow><annotation encoding="application/x-tex">\bcancel{5}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8444em;"><span style="top:-3.0444em;"><span class="pstrut" style="height:3.0444em;"></span><span class="mord"><span class="mord">5</span></span></span><span class="svg-align" style="top:-2.8444em;"><span class="pstrut" style="height:3.0444em;"></span><span style="height:1.0444em;"><svg xmlns="http://www.w3.org/2000/svg" width='100%' height='1.0444em'><line x1='0' y1='0' x2='100%' y2='100%' stroke-width='0.046em'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2em;"><span></span></span></span></span></span></span></span></span> <code>\bcancel{5}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><munder><munder><mrow><mi>a</mi><mo>+</mo><mi>b</mi><mo>+</mo><mi>c</mi></mrow><mo stretchy="true">⏟</mo></munder><mtext>note</mtext></munder></mrow><annotation encoding="application/x-tex">\underbrace{a+b+c}_{\text{note}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.0563em;vertical-align:-1.3619em;"></span><span class="mord munder"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6944em;"><span style="top:-1.6381em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord text mtight"><span class="mord mtight">note</span></span></span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord munder"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6944em;"><span class="svg-align" style="top:-2.2687em;"><span class="pstrut" style="height:3em;"></span><span class="stretchy" style="height:0.548em;min-width:1.6em;"><span class="brace-left" style="height:0.548em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.548em' viewBox='0 0 400000 548' preserveAspectRatio='xMinYMin slice'><path d='M0 6l6-6h17c12.688 0 19.313.3 20 1 4 4 7.313 8.3 10 13
 35.313 51.3 80.813 93.8 136.5 127.5 55.688 33.7 117.188 55.8 184.5 66.5.688
 0 2 .3 4 1 18.688 2.7 76 4.3 172 5h399450v120H429l-6-1c-124.688-8-235-61.7
-331-161C60.687 138.7 32.312 99.3 7 54L0 41V6z'/></svg></span><span class="brace-center" style="height:0.548em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.548em' viewBox='0 0 400000 548' preserveAspectRatio='xMidYMin slice'><path d='M199572 214
c100.7 8.3 195.3 44 280 108 55.3 42 101.7 93 139 153l9 14c2.7-4 5.7-8.7 9-14
 53.3-86.7 123.7-153 211-199 66.7-36 137.3-56.3 212-62h199568v120H200432c-178.3
 11.7-311.7 78.3-403 201-6 8-9.7 12-11 12-.7.7-6.7 1-18 1s-17.3-.3-18-1c-1.3 0
-5-4-11-12-44.7-59.3-101.3-106.3-170-141s-145.3-54.3-229-60H0V214z'/></svg></span><span class="brace-right" style="height:0.548em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.548em' viewBox='0 0 400000 548' preserveAspectRatio='xMaxYMin slice'><path d='M399994 0l6 6v35l-6 11c-56 104-135.3 181.3-238 232-57.3
 28.7-117 45-179 50H-300V214h399897c43.3-7 81-15 113-26 100.7-33 179.7-91 237
-174 2.7-5 6-9 10-13 .7-1 7.3-1 20-1h17z'/></svg></span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal">b</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.7313em;"><span></span></span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.3619em;"><span></span></span></span></span></span></span></span></span> <code>\underbrace{a+b+c}_{\text{note}}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><menclose notation="updiagonalstrike downdiagonalstrike"><mrow><mi>A</mi><mi>B</mi><mi>C</mi></mrow></menclose></mrow><annotation encoding="application/x-tex">\xcancel{ABC}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord cancel-lap"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6833em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord cancel-pad"><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.07153em;">BC</span></span></span><span class="svg-align" style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span style="height:0.6833em;"><svg xmlns="http://www.w3.org/2000/svg" width='100%' height='0.6833em'><line x1='0' y1='0' x2='100%' y2='100%' stroke-width='0.046em'/><line x1='0' y1='100%' x2='100%' y2='0' stroke-width='0.046em'/></svg></span></span></span></span></span></span></span></span></span> <code>\xcancel{ABC}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≠</mo></mrow><annotation encoding="application/x-tex">\not =</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel"><span class="mord vbox"><span class="thinbox"><span class="rlap"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="inner"><span class="mord"><span class="mrel"></span></span></span><span class="fix"></span></span></span></span></span></span><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">=</span></span></span></span> <code>\not =</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><menclose notation="horizontalstrike"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></menclose></mrow><annotation encoding="application/x-tex">\sout{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6944em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">ab</span><span class="mord mathnormal">c</span></span></span><span style="top:-3.2155em;"><span class="pstrut" style="height:3em;"></span><span class="stretchy sout"></span></span></span></span></span></span></span></span></span> <code>\sout{abc}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><menclose notation="box"><mstyle scriptlevel="0" displaystyle="false"><mstyle scriptlevel="0" displaystyle="false"><mstyle scriptlevel="0" displaystyle="true"><mrow><mi>π</mi><mo>=</mo><mfrac><mi>c</mi><mi>d</mi></mfrac></mrow></mstyle></mstyle></mstyle></menclose></mrow><annotation encoding="application/x-tex">\boxed{\pi=\frac c d}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.4736em;vertical-align:-1.026em;"></span><span class="mord"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.4476em;"><span style="top:-4.4736em;"><span class="pstrut" style="height:4.4736em;"></span><span class="boxpad"><span class="mord"><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">π</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1076em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">d</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span></span><span style="top:-3.4476em;"><span class="pstrut" style="height:4.4736em;"></span><span class="stretchy fbox" style="height:2.4736em;border-style:solid;border-width:0.04em;"></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.026em;"><span></span></span></span></span></span></span></span></span> <code>\boxed{\pi=\frac c d}</code></td>
</tr>
</tbody>
</table>
<p><code>\tag{hi} x+y^{2x}</code></p>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mtable width="100%"><mtr><mtd width="50%"></mtd><mtd><mrow><mi>x</mi><mo>+</mo><msup><mi>y</mi><mrow><mn>2</mn><mi>x</mi></mrow></msup></mrow></mtd><mtd width="50%"></mtd><mtd><mtext>(hi)</mtext></mtd></mtr></mtable><annotation encoding="application/x-tex">\tag{hi} x+y^{2x}
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mord mathnormal">x</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1.0585em;vertical-align:-0.1944em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">y</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span><span class="mord mathnormal mtight">x</span></span></span></span></span></span></span></span></span></span><span class="tag"><span class="strut" style="height:1.1141em;vertical-align:-0.25em;"></span><span class="mord text"><span class="mord">(</span><span class="mord"><span class="mord">hi</span></span><span class="mord">)</span></span></span></span></span></span></p>
<p><code>\tag*{hi} x+y^{2x}</code></p>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mtable width="100%"><mtr><mtd width="50%"></mtd><mtd><mrow><mi>x</mi><mo>+</mo><msup><mi>y</mi><mrow><mn>2</mn><mi>x</mi></mrow></msup></mrow></mtd><mtd width="50%"></mtd><mtd><mtext>hi</mtext></mtd></mtr></mtable><annotation encoding="application/x-tex">\tag*{hi} x+y^{2x}
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mord mathnormal">x</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1.0585em;vertical-align:-0.1944em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">y</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8641em;"><span style="top:-3.113em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">2</span><span class="mord mathnormal mtight">x</span></span></span></span></span></span></span></span></span></span><span class="tag"><span class="strut" style="height:1.0585em;vertical-align:-0.1944em;"></span><span class="mord text"><span class="mord">hi</span></span></span></span></span></span></p>
<h3 id="_6-2-line-breaks" tabindex="-1">6.2: Line Breaks <a class="header-anchor" href="#_6-2-line-breaks" aria-label="Permalink to &quot;6.2: Line Breaks&quot;">&ZeroWidthSpace;</a></h3>
<p>KaTeX 0.10.0+ will insert automatic line breaks in inline math after relations or binary operators such as “=” or “+”. These can be suppressed by <code>\nobreak</code> or by placing math inside a pair of braces, as in <code>{F=ma}</code>. <code>\allowbreak</code> will allow automatic line breaks at locations other than relations or operators.</p>
<p>Hard line breaks are <code>\\</code> and <code>\newline</code>.</p>
<p>In display math, KaTeX does not insert automatic line breaks. It ignores display math hard line breaks when rendering option <code>strict: true</code>.</p>
<h3 id="_6-3-vertical-layout" tabindex="-1">6.3: Vertical Layout <a class="header-anchor" href="#_6-3-vertical-layout" aria-label="Permalink to &quot;6.3: Vertical Layout&quot;">&ZeroWidthSpace;</a></h3>
<table>
<thead>
<tr>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>x</mi><mi>n</mi></msub></mrow><annotation encoding="application/x-tex">x_n</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">n</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> <code>x_n</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mover><mo><mo>=</mo></mo><mo stretchy="false" lspace="0em" rspace="0em">!</mo></mover></mo></mrow><annotation encoding="application/x-tex">\stackrel{!}{=}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.153em;"></span><span class="mrel"><span class="mop op-limits"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:1.153em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span><span class="mop">=</span></span></span><span style="top:-3.5669em;margin-left:0em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mclose mtight">!</span></span></span></span></span></span></span></span></span></span></span></span> <code>\stackrel{!}{=}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mfrac linethickness="0px"><mi>a</mi><mi>b</mi></mfrac></mrow><annotation encoding="application/x-tex">a \atop b</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0904em;vertical-align:-0.345em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.7454em;"><span style="top:-2.355em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">b</span></span></span></span><span style="top:-3.144em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">a</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span> <code>a \atop b</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msup><mi>e</mi><mi>x</mi></msup></mrow><annotation encoding="application/x-tex">e^x</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6644em;"></span><span class="mord"><span class="mord mathnormal">e</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6644em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">x</span></span></span></span></span></span></span></span></span></span></span> <code>e^x</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mover><mo><mo>=</mo></mo><mo stretchy="false" lspace="0em" rspace="0em">!</mo></mover></mo></mrow><annotation encoding="application/x-tex">\overset{!}{=}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.153em;"></span><span class="mrel"><span class="mop op-limits"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:1.153em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span><span class="mop">=</span></span></span><span style="top:-3.5669em;margin-left:0em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mclose mtight">!</span></span></span></span></span></span></span></span></span></span></span></span> <code>\overset{!}{=}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mpadded voffset="0.25em"><mstyle scriptlevel="0" displaystyle="false"><mtext>b</mtext></mstyle></mpadded><mi>c</mi></mrow><annotation encoding="application/x-tex">a\raisebox{0.25em}{b}c</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9444em;"></span><span class="mord mathnormal">a</span><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.9444em;"><span style="top:-3.25em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">b</span></span></span></span></span></span><span class="mord mathnormal">c</span></span></span></span> <code>a\raisebox{0.25em}{b}c</code></td>
</tr>
<tr>
<td style="text-align:left">$_u^o $ <code>_u^o </code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><munder><mo><mo>=</mo></mo><mo stretchy="false" lspace="0em" rspace="0em">!</mo></munder></mo></mrow><annotation encoding="application/x-tex">\underset{!}{=}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.119em;vertical-align:-0.7521em;"></span><span class="mrel"><span class="mop op-limits"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3669em;"><span style="top:-2.3479em;margin-left:0em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mclose mtight">!</span></span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span><span class="mop">=</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.7521em;"><span></span></span></span></span></span></span></span></span></span> <code>\underset{!}{=}</code></td>
<td style="text-align:left"></td>
</tr>
</tbody>
</table>
<p>The second argument of <code>\raisebox</code> can contain math if it is nested within <code>$…$</code> delimiters, as in <code>\raisebox{0.25em}{$\frac a b$}</code></p>
<h3 id="_6-4-overlap-and-spacing" tabindex="-1">6.4: Overlap and Spacing <a class="header-anchor" href="#_6-4-overlap-and-spacing" aria-label="Permalink to &quot;6.4: Overlap and Spacing&quot;">&ZeroWidthSpace;</a></h3>
<table>
<thead>
<tr>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo lspace="0em" rspace="0em">=</mo><mpadded lspace="-1width" width="0px"><mrow><mi mathvariant="normal">/</mi><mtext> </mtext></mrow></mpadded></mrow><annotation encoding="application/x-tex">{=}\mathllap{/\,}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord"><span class="mrel">=</span></span><span class="mord vbox"><span class="thinbox"><span class="llap"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="inner"><span class="mord"><span class="mord">/</span><span class="mspace" style="margin-right:0.1667em;"></span></span></span><span class="fix"></span></span></span></span></span></span></span> <code>{=}\mathllap{/\,}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true">(</mo><msup><mi>x</mi><mpadded height="0px" depth="0px"><mn>2</mn></mpadded></msup><mo fence="true">)</mo></mrow><annotation encoding="application/x-tex">\left(x^{\smash{2}}\right)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.363em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0em;"><span style="top:-2.7em;"><span class="pstrut" style="height:2.7em;"></span><span><span class="mord mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">)</span></span></span></span></span> <code>\left(x^{\smash{2}}\right)</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mpadded width="0px"><mrow><mtext> </mtext><mi mathvariant="normal">/</mi></mrow></mpadded><mo lspace="0em" rspace="0em">=</mo></mrow><annotation encoding="application/x-tex">\mathrlap{\,/}{=}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord vbox"><span class="thinbox"><span class="rlap"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="inner"><span class="mord"><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord">/</span></span></span><span class="fix"></span></span></span></span><span class="mord"><span class="mrel">=</span></span></span></span></span> <code>\mathrlap{\,/}{=}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msqrt><mpadded depth="0px"><mi>y</mi></mpadded></msqrt></mrow><annotation encoding="application/x-tex">\sqrt{\smash[b]{y}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.04em;vertical-align:-0.2397em;"></span><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8003em;"><span class="svg-align" style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord" style="padding-left:0.833em;"><span class="mord"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.4306em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">y</span></span></span></span></span></span></span></span></span></span><span style="top:-2.7603em;"><span class="pstrut" style="height:3em;"></span><span class="hide-tail" style="min-width:0.853em;height:1.08em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='1.08em' viewBox='0 0 400000 1080' preserveAspectRatio='xMinYMin slice'><path d='M95,702
c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14
c0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54
c44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10
s173,378,173,378c0.7,0,35.3,-71,104,-213c68.7,-142,137.5,-285,206.5,-429
c69,-144,104.5,-217.7,106.5,-221
l0 -0
c5.3,-9.3,12,-14,20,-14
H400000v40H845.2724
s-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7
c-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z
M834 80h400000v40h-400000z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2397em;"><span></span></span></span></span></span></span></span></span> <code>\sqrt{\smash[b]{y}} </code></td>
</tr>
</tbody>
</table>
<p><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle scriptlevel="0" displaystyle="true"><munder><mo>∑</mo><mpadded lspace="-0.5width" width="0px"><mrow><mn>1</mn><mo>≤</mo><mi>i</mi><mo>≤</mo><mi>j</mi><mo>≤</mo><mi>n</mi></mrow></mpadded></munder><msub><mi>x</mi><mrow><mi>i</mi><mi>j</mi></mrow></msub></mstyle></mrow><annotation encoding="application/x-tex">\displaystyle\sum_{\mathclap{1\le i\le j\le n}} x_{ij}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.4638em;vertical-align:-1.4138em;"></span><span class="mop op-limits"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.05em;"><span style="top:-1.8723em;margin-left:0em;"><span class="pstrut" style="height:3.05em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord vbox mtight"><span class="thinbox mtight"><span class="clap mtight"><span class="strut" style="height:0.854em;vertical-align:-0.1944em;"></span><span class="inner mtight"><span><span class="mord mtight"><span class="mord mtight">1</span><span class="mrel mtight">≤</span><span class="mord mathnormal mtight">i</span><span class="mrel mtight">≤</span><span class="mord mathnormal mtight" style="margin-right:0.05724em;">j</span><span class="mrel mtight">≤</span><span class="mord mathnormal mtight">n</span></span></span></span><span class="fix"></span></span></span></span></span></span></span><span style="top:-3.05em;"><span class="pstrut" style="height:3.05em;"></span><span><span class="mop op-symbol large-op">∑</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.4138em;"><span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.05724em;">ij</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span></span></span></span> <code>\sum_{\mathclap{1\le i\le j\le n}} x_{ij}</code></p>
<p>KaTeX also supports <code>\llap</code>, <code>\rlap</code>, and <code>\clap</code>, but they will take only text, not math, as arguments.</p>
<p><strong>Spacing</strong></p>
<table>
<thead>
<tr>
<th style="text-align:left">Function</th>
<th style="text-align:left">Produces</th>
<th style="text-align:left">Function</th>
<th style="text-align:left">Produces</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left"><code>\,</code></td>
<td style="text-align:left">³∕₁₈ em space</td>
<td style="text-align:left"><code>\kern{distance}</code></td>
<td style="text-align:left">space, width = <em>distance</em></td>
</tr>
<tr>
<td style="text-align:left"><code>\thinspace</code></td>
<td style="text-align:left">³∕₁₈ em space</td>
<td style="text-align:left"><code>\mkern{distance}</code></td>
<td style="text-align:left">space, width = <em>distance</em></td>
</tr>
<tr>
<td style="text-align:left"><code>\:</code></td>
<td style="text-align:left">⁴∕₁₈ em space</td>
<td style="text-align:left"><code>\mskip{distance}</code></td>
<td style="text-align:left">space, width = <em>distance</em></td>
</tr>
<tr>
<td style="text-align:left"><code>\medspace</code></td>
<td style="text-align:left">⁴∕₁₈ em space</td>
<td style="text-align:left"><code>\hskip{distance}</code></td>
<td style="text-align:left">space, width = <em>distance</em></td>
</tr>
<tr>
<td style="text-align:left"><code>\;</code></td>
<td style="text-align:left">⁵∕₁₈ em space</td>
<td style="text-align:left"><code>\hspace{distance}</code></td>
<td style="text-align:left">space, width = <em>distance</em></td>
</tr>
<tr>
<td style="text-align:left"><code>\thickspace</code></td>
<td style="text-align:left">⁵∕₁₈ em space</td>
<td style="text-align:left"><code>\hspace*{distance}</code></td>
<td style="text-align:left">space, width = <em>distance</em></td>
</tr>
<tr>
<td style="text-align:left"><code>\enspace</code></td>
<td style="text-align:left">½ em space</td>
<td style="text-align:left"><code>\phantom{content}</code></td>
<td style="text-align:left">space the width and height of content</td>
</tr>
<tr>
<td style="text-align:left"><code>\quad</code></td>
<td style="text-align:left">1 em space</td>
<td style="text-align:left"><code>\hphantom{content}</code></td>
<td style="text-align:left">space the width of content</td>
</tr>
<tr>
<td style="text-align:left"><code>\qquad</code></td>
<td style="text-align:left">2 em space</td>
<td style="text-align:left"><code>\vphantom{content}</code></td>
<td style="text-align:left">a strut the height of content</td>
</tr>
<tr>
<td style="text-align:left"><code>~</code></td>
<td style="text-align:left">non-breaking space</td>
<td style="text-align:left"><code>\!</code></td>
<td style="text-align:left">– ³∕₁₈ em space</td>
</tr>
<tr>
<td style="text-align:left"><code>\&lt;space&gt;</code></td>
<td style="text-align:left">space</td>
<td style="text-align:left"><code>\negthinspace</code></td>
<td style="text-align:left">– ³∕₁₈ em space</td>
</tr>
<tr>
<td style="text-align:left"><code>\nobreakspace</code></td>
<td style="text-align:left">non-breaking space</td>
<td style="text-align:left"><code>\negmedspace</code></td>
<td style="text-align:left">– ⁴∕₁₈ em space</td>
</tr>
<tr>
<td style="text-align:left"><code>\space</code></td>
<td style="text-align:left">space</td>
<td style="text-align:left"><code>\negthickspace</code></td>
<td style="text-align:left">– ⁵∕₁₈ em space</td>
</tr>
</tbody>
</table>
<p><strong>Notes:</strong></p>
<p><code>distance</code> will accept any of the <a href="#units">KaTeX units</a>.</p>
<p><code>\kern</code>, <code>\mkern</code>, <code>\mskip</code>, and <code>\hspace</code> accept unbraced distances, as in: <code>\kern1em</code>.</p>
<p><code>\mkern</code> and <code>\mskip</code> will not work in text mode and both will write a console warning for any unit except <code>mu</code>.</p>
<h2 id="_7-logic-and-set-theory" tabindex="-1">7: Logic and Set Theory <a class="header-anchor" href="#_7-logic-and-set-theory" aria-label="Permalink to &quot;7: Logic and Set Theory&quot;">&ZeroWidthSpace;</a></h2>
<table>
<thead>
<tr>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∀</mi></mrow><annotation encoding="application/x-tex">\forall</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">∀</span></span></span></span> <code>\forall</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∁</mi></mrow><annotation encoding="application/x-tex">\complement</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.825em;"></span><span class="mord amsrm">∁</span></span></span></span> <code>\complement</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∴</mo></mrow><annotation encoding="application/x-tex">\therefore</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mrel amsrm">∴</span></span></span></span> <code>\therefore</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∅</mi></mrow><annotation encoding="application/x-tex">\emptyset</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8056em;vertical-align:-0.0556em;"></span><span class="mord">∅</span></span></span></span> <code>\emptyset</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∃</mi></mrow><annotation encoding="application/x-tex">\exists</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">∃</span></span></span></span> <code>\exists</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊂</mo></mrow><annotation encoding="application/x-tex">\subset</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">⊂</span></span></span></span> <code>\subset</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∵</mo></mrow><annotation encoding="application/x-tex">\because</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mrel amsrm">∵</span></span></span></span> <code>\because</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∅</mi></mrow><annotation encoding="application/x-tex">\empty</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8056em;vertical-align:-0.0556em;"></span><span class="mord">∅</span></span></span></span> <code>\empty</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∃</mi></mrow><annotation encoding="application/x-tex">\exist</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">∃</span></span></span></span> <code>\exist</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊃</mo></mrow><annotation encoding="application/x-tex">\supset</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">⊃</span></span></span></span> <code>\supset</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↦</mo></mrow><annotation encoding="application/x-tex">\mapsto</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.522em;vertical-align:-0.011em;"></span><span class="mrel">↦</span></span></span></span> <code>\mapsto</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∅</mi></mrow><annotation encoding="application/x-tex">\varnothing</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6633em;vertical-align:-0.0817em;"></span><span class="mord amsrm">∅</span></span></span></span> <code>\varnothing</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∄</mi></mrow><annotation encoding="application/x-tex">\nexists</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord amsrm">∄</span></span></span></span> <code>\nexists</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∣</mo></mrow><annotation encoding="application/x-tex">\mid</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mrel">∣</span></span></span></span> <code>\mid</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>→</mo></mrow><annotation encoding="application/x-tex">\to</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">→</span></span></span></span> <code>\to</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>  </mtext><mo>⟹</mo><mtext>  </mtext></mrow><annotation encoding="application/x-tex">\implies</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.549em;vertical-align:-0.024em;"></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">⟹</span><span class="mspace" style="margin-right:0.2778em;"></span></span></span></span> <code>\implies</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∈</mo></mrow><annotation encoding="application/x-tex">\in</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">∈</span></span></span></span> <code>\in</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∧</mo></mrow><annotation encoding="application/x-tex">\land</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5556em;"></span><span class="mord">∧</span></span></span></span> <code>\land</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>←</mo></mrow><annotation encoding="application/x-tex">\gets</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">←</span></span></span></span> <code>\gets</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>  </mtext><mo>⟸</mo><mtext>  </mtext></mrow><annotation encoding="application/x-tex">\impliedby</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.549em;vertical-align:-0.024em;"></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">⟸</span><span class="mspace" style="margin-right:0.2778em;"></span></span></span></span> <code>\impliedby</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∈</mo></mrow><annotation encoding="application/x-tex">\isin</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">∈</span></span></span></span> <code>\isin</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∨</mo></mrow><annotation encoding="application/x-tex">\lor</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5556em;"></span><span class="mord">∨</span></span></span></span> <code>\lor</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↔</mo></mrow><annotation encoding="application/x-tex">\leftrightarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">↔</span></span></span></span> <code>\leftrightarrow</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>  </mtext><mo>⟺</mo><mtext>  </mtext></mrow><annotation encoding="application/x-tex">\iff</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.549em;vertical-align:-0.024em;"></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">⟺</span><span class="mspace" style="margin-right:0.2778em;"></span></span></span></span> <code>\iff</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo mathvariant="normal">∉</mo></mrow><annotation encoding="application/x-tex">\notin</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mrel"><span class="mord"><span class="mrel">∈</span></span><span class="mord vbox"><span class="thinbox"><span class="llap"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="inner"><span class="mord"><span class="mord">/</span><span class="mspace" style="margin-right:0.0556em;"></span></span></span><span class="fix"></span></span></span></span></span></span></span></span> <code>\notin</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∋</mo></mrow><annotation encoding="application/x-tex">\ni</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">∋</span></span></span></span> <code>\ni</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo mathvariant="normal">∌</mo></mrow><annotation encoding="application/x-tex">\notni</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel"><span class="mord vbox"><span class="thinbox"><span class="rlap"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="inner"><span class="mord"><span class="mrel"></span></span></span><span class="fix"></span></span></span></span></span></span><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">∋</span></span></span></span> <code>\notni</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">¬</mi></mrow><annotation encoding="application/x-tex">\neg</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord">¬</span></span></span></span> <code>\neg</code> or <code>\lnot</code></td>
</tr>
</tbody>
</table>
<p>Direct Input: <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∀</mi><mo>∴</mo><mi mathvariant="normal">∁</mi><mo>∵</mo><mi mathvariant="normal">∃</mi><mo>∣</mo><mo>∈</mo><mo mathvariant="normal">∉</mo><mo>∋</mo><mo>⊂</mo><mo>⊃</mo><mo>∧</mo><mo>∨</mo><mo>↦</mo><mo>→</mo><mo>←</mo><mo>↔</mo><mi mathvariant="normal">¬</mi></mrow><annotation encoding="application/x-tex">∀ ∴ ∁ ∵ ∃ ∣ ∈ ∉ ∋ ⊂ ⊃ ∧ ∨ ↦ → ← ↔ ¬</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">∀</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel amsrm">∴</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.825em;"></span><span class="mord amsrm">∁</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel amsrm">∵</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">∃</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">∣∈</span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mrel"><span class="mord"><span class="mrel">∈</span></span><span class="mord vbox"><span class="thinbox"><span class="llap"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="inner"><span class="mord"><span class="mord">/</span><span class="mspace" style="margin-right:0.0556em;"></span></span></span><span class="fix"></span></span></span></span></span></span><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">∋⊂⊃</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.5666em;vertical-align:-0.011em;"></span><span class="mord">∧</span><span class="mord">∨</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">↦→←↔</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord">¬</span></span></span></span> ℂ ℍ ℕ ℙ ℚ ℝ</p>
<h2 id="_8-macros" tabindex="-1">8: Macros <a class="header-anchor" href="#_8-macros" aria-label="Permalink to &quot;8: Macros&quot;">&ZeroWidthSpace;</a></h2>
<table>
<thead>
<tr>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msup><mi>x</mi><mn>2</mn></msup><mo>+</mo><msup><mi>x</mi><mn>2</mn></msup></mrow><annotation encoding="application/x-tex">\def\foo{x^2} \foo + \foo</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8974em;vertical-align:-0.0833em;"></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.8141em;"></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\def\foo{x^2} \foo + \foo</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msup><mi>y</mi><mn>2</mn></msup><mo>+</mo><msup><mi>y</mi><mn>2</mn></msup></mrow><annotation encoding="application/x-tex">\gdef\bar#1{#1^2} \bar{y} + \bar{y}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0085em;vertical-align:-0.1944em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">y</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1.0085em;vertical-align:-0.1944em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">y</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\gdef\bar#1{#1^2} \bar{y} + \bar{y}</code></td>
</tr>
<tr>
<td style="text-align:left"></td>
<td style="text-align:left"><code>\global\def\macroname#1#2…{definition}</code></td>
</tr>
<tr>
<td style="text-align:left"></td>
<td style="text-align:left"><code>\newcommand\macroname[numargs]{definition}</code></td>
</tr>
<tr>
<td style="text-align:left"></td>
<td style="text-align:left"><code>\renewcommand\macroname[numargs]{definition}</code></td>
</tr>
<tr>
<td style="text-align:left"></td>
<td style="text-align:left"><code>\providecommand\macroname[numargs]{definition}</code></td>
</tr>
</tbody>
</table>
<p>Macros can also be defined in the KaTeX rendering options.</p>
<p>Macros accept up to nine arguments: #1, #2, etc.</p>
<p><code>\gdef</code> and <code>\global\def</code> macros will persist between math expressions.</p>
<p>Available functions include:</p>
<p><code>\char</code> <code>\mathchoice</code> <code>\TextOrMath</code> <code>\@ifstar</code> <code>\@ifnextchar</code> <code>\@firstoftwo</code> <code>\@secondoftwo</code> <code>\relax</code></p>
<p>@ is a valid character for commands, as if <code>\makeatletter</code> were in effect.</p>
<h2 id="_9-operators" tabindex="-1">9: Operators <a class="header-anchor" href="#_9-operators" aria-label="Permalink to &quot;9: Operators&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="_9-1-big-operators" tabindex="-1">9.1: Big Operators <a class="header-anchor" href="#_9-1-big-operators" aria-label="Permalink to &quot;9.1: Big Operators&quot;">&ZeroWidthSpace;</a></h3>
<table>
<thead>
<tr>
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∑</mo></mrow><annotation encoding="application/x-tex">\sum</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mop op-symbol small-op" style="position:relative;top:0em;">∑</span></span></span></span> <code>\sum</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∏</mo></mrow><annotation encoding="application/x-tex">\prod</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mop op-symbol small-op" style="position:relative;top:0em;">∏</span></span></span></span> <code>\prod</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⨂</mo></mrow><annotation encoding="application/x-tex">\bigotimes</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mop op-symbol small-op" style="position:relative;top:0em;">⨂</span></span></span></span> <code>\bigotimes</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋁</mo></mrow><annotation encoding="application/x-tex">\bigvee</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mop op-symbol small-op" style="position:relative;top:0em;">⋁</span></span></span></span> <code>\bigvee</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∫</mo></mrow><annotation encoding="application/x-tex">\int</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1111em;vertical-align:-0.3061em;"></span><span class="mop op-symbol small-op" style="margin-right:0.19445em;position:relative;top:-0.0006em;">∫</span></span></span></span> <code>\int</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∐</mo></mrow><annotation encoding="application/x-tex">\coprod</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mop op-symbol small-op" style="position:relative;top:0em;">∐</span></span></span></span> <code>\coprod</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⨁</mo></mrow><annotation encoding="application/x-tex">\bigoplus</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mop op-symbol small-op" style="position:relative;top:0em;">⨁</span></span></span></span> <code>\bigoplus</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋀</mo></mrow><annotation encoding="application/x-tex">\bigwedge</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mop op-symbol small-op" style="position:relative;top:0em;">⋀</span></span></span></span> <code>\bigwedge</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∬</mo></mrow><annotation encoding="application/x-tex">\iint</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.111em;vertical-align:-0.306em;"></span><span class="mop op-symbol small-op" style="margin-right:0.19445em;position:relative;top:-0.0005em;">∬</span></span></span></span> <code>\iint</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∫</mo></mrow><annotation encoding="application/x-tex">\intop</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1111em;vertical-align:-0.3061em;"></span><span class="mop op-symbol small-op" style="margin-right:0.19445em;position:relative;top:-0.0006em;">∫</span></span></span></span> <code>\intop</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⨀</mo></mrow><annotation encoding="application/x-tex">\bigodot</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mop op-symbol small-op" style="position:relative;top:0em;">⨀</span></span></span></span> <code>\bigodot</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋂</mo></mrow><annotation encoding="application/x-tex">\bigcap</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mop op-symbol small-op" style="position:relative;top:0em;">⋂</span></span></span></span> <code>\bigcap</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∭</mo></mrow><annotation encoding="application/x-tex">\iiint</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.111em;vertical-align:-0.306em;"></span><span class="mop op-symbol small-op" style="margin-right:0.19445em;position:relative;top:-0.0005em;">∭</span></span></span></span> <code>\iiint</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo largeop="false">∫</mo></mrow><annotation encoding="application/x-tex">\smallint</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1111em;vertical-align:-0.3061em;"></span><span class="mop op-symbol small-op" style="margin-right:0.19445em;position:relative;top:-0.0006em;">∫</span></span></span></span> <code>\smallint</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⨄</mo></mrow><annotation encoding="application/x-tex">\biguplus</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mop op-symbol small-op" style="position:relative;top:0em;">⨄</span></span></span></span> <code>\biguplus</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋃</mo></mrow><annotation encoding="application/x-tex">\bigcup</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mop op-symbol small-op" style="position:relative;top:0em;">⋃</span></span></span></span> <code>\bigcup</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∮</mo></mrow><annotation encoding="application/x-tex">\oint</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1111em;vertical-align:-0.3061em;"></span><span class="mop op-symbol small-op" style="margin-right:0.19445em;position:relative;top:-0.0006em;">∮</span></span></span></span> <code>\oint</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∯</mo></mrow><annotation encoding="application/x-tex">\oiint</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.111em;vertical-align:-0.306em;"></span><span class="mop vlist-t vlist-t2" style="position:relative;top:-0.0005em;"><span class="vlist-r"><span class="vlist" style="height:0.805em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mop op-symbol small-op" style="margin-right:0.19445em;">∬</span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="overlay" style="height:0.499em;width:0.957em;"><svg xmlns="http://www.w3.org/2000/svg" width='0.957em' height='0.499em' style='width:0.957em' viewBox='0 0 957 499' preserveAspectRatio='xMinYMin'><path d='M512.6 71.6c272.6 0 320.3 106.8 320.3 178.2 0 70.8-47.7 177.6
-320.3 177.6S193.1 320.6 193.1 249.8c0-71.4 46.9-178.2 319.5-178.2z
m368.1 178.2c0-86.4-60.9-215.4-368.1-215.4-306.4 0-367.3 129-367.3 215.4 0 85.8
60.9 214.8 367.3 214.8 307.2 0 368.1-129 368.1-214.8z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.306em;"><span></span></span></span></span></span></span></span> <code>\oiint</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∰</mo></mrow><annotation encoding="application/x-tex">\oiiint</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.111em;vertical-align:-0.306em;"></span><span class="mop vlist-t vlist-t2" style="position:relative;top:-0.0005em;"><span class="vlist-r"><span class="vlist" style="height:0.805em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mop op-symbol small-op" style="margin-right:0.19445em;">∭</span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="overlay" style="height:0.499em;width:1.304em;"><svg xmlns="http://www.w3.org/2000/svg" width='1.304em' height='0.499em' style='width:1.304em' viewBox='0 0 1304 499' preserveAspectRatio='xMinYMin'><path d='M681.4 71.6c408.9 0 480.5 106.8 480.5 178.2 0 70.8-71.6 177.6
-480.5 177.6S202.1 320.6 202.1 249.8c0-71.4 70.5-178.2 479.3-178.2z
m525.8 178.2c0-86.4-86.8-215.4-525.7-215.4-437.9 0-524.7 129-524.7 215.4 0
85.8 86.8 214.8 524.7 214.8 438.9 0 525.7-129 525.7-214.8z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.306em;"><span></span></span></span></span></span></span></span> <code>\oiiint</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⨆</mo></mrow><annotation encoding="application/x-tex">\bigsqcup</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mop op-symbol small-op" style="position:relative;top:0em;">⨆</span></span></span></span> <code>\bigsqcup</code></td>
</tr>
</tbody>
</table>
<p>Direct Input: <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∫</mo><mo>∬</mo><mo>∭</mo><mo>∮</mo><mo>∏</mo><mo>∐</mo><mo>∑</mo><mo>⋀</mo><mo>⋁</mo><mo>⋂</mo><mo>⋃</mo><mo>⨀</mo><mo>⨁</mo><mo>⨂</mo><mo>⨄</mo><mo>⨆</mo></mrow><annotation encoding="application/x-tex">∫ ∬ ∭ ∮ ∏ ∐ ∑ ⋀ ⋁ ⋂ ⋃ ⨀ ⨁ ⨂ ⨄ ⨆</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1111em;vertical-align:-0.3061em;"></span><span class="mop op-symbol small-op" style="margin-right:0.19445em;position:relative;top:-0.0006em;">∫</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop op-symbol small-op" style="margin-right:0.19445em;position:relative;top:-0.0005em;">∬∭</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop op-symbol small-op" style="margin-right:0.19445em;position:relative;top:-0.0006em;">∮</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mop op-symbol small-op" style="position:relative;top:0em;">∏∐∑⋀⋁⋂⋃⨀⨁⨂⨄⨆</span></span></span></span></p>
<h3 id="_9-2-binary-operators" tabindex="-1">9.2: Binary Operators <a class="header-anchor" href="#_9-2-binary-operators" aria-label="Permalink to &quot;9.2: Binary Operators&quot;">&ZeroWidthSpace;</a></h3>
<table>
<thead>
<tr>
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>+</mo></mrow><annotation encoding="application/x-tex">+</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mord">+</span></span></span></span> <code>+</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋅</mo></mrow><annotation encoding="application/x-tex">\cdot</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4445em;"></span><span class="mord">⋅</span></span></span></span> <code>\cdot</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋗</mo></mrow><annotation encoding="application/x-tex">\gtrdot</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mord amsrm">⋗</span></span></span></span> <code>\gtrdot</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>x</mi><mspace></mspace><mspace width="0.4444em"/><mo stretchy="false">(</mo><mrow><mi mathvariant="normal">m</mi><mi mathvariant="normal">o</mi><mi mathvariant="normal">d</mi></mrow><mspace width="0.3333em"/><mi>a</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">x \pmod a</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">x</span><span class="mspace allowbreak"></span><span class="mspace" style="margin-right:0.4444em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">(</span><span class="mord"><span class="mord"><span class="mord mathrm">mod</span></span></span><span class="mspace" style="margin-right:0.3333em;"></span><span class="mord mathnormal">a</span><span class="mclose">)</span></span></span></span> <code>x \pmod a</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>−</mo></mrow><annotation encoding="application/x-tex">-</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mord">−</span></span></span></span> <code>-</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo separator="true">⋅</mo></mrow><annotation encoding="application/x-tex">\cdotp</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4445em;"></span><span class="mpunct">⋅</span></span></span></span> <code>\cdotp</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊺</mo></mrow><annotation encoding="application/x-tex">\intercal</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord amsrm">⊺</span></span></span></span> <code>\intercal</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>x</mi><mspace></mspace><mspace width="0.4444em"/><mo stretchy="false">(</mo><mi>a</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">x \pod a</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">x</span><span class="mspace allowbreak"></span><span class="mspace" style="margin-right:0.4444em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">(</span><span class="mord mathnormal">a</span><span class="mclose">)</span></span></span></span> <code>x \pod a</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">/</mi></mrow><annotation encoding="application/x-tex">/</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">/</span></span></span></span> <code>/</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋅</mo></mrow><annotation encoding="application/x-tex">\centerdot</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5499em;"></span><span class="mord amsrm">⋅</span></span></span></span> <code>\centerdot</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∧</mo></mrow><annotation encoding="application/x-tex">\land</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5556em;"></span><span class="mord">∧</span></span></span></span> <code>\land</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊳</mo></mrow><annotation encoding="application/x-tex">\rhd</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.585em;vertical-align:-0.0352em;"></span><span class="mord amsrm">⊳</span></span></span></span> <code>\rhd</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∗</mo></mrow><annotation encoding="application/x-tex">*</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4653em;"></span><span class="mord">∗</span></span></span></span> <code>*</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∘</mo></mrow><annotation encoding="application/x-tex">\circ</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4445em;"></span><span class="mord">∘</span></span></span></span> <code>\circ</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋋</mo></mrow><annotation encoding="application/x-tex">\leftthreetimes</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mord amsrm">⋋</span></span></span></span> <code>\leftthreetimes</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋌</mo></mrow><annotation encoding="application/x-tex">\rightthreetimes</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mord amsrm">⋌</span></span></span></span> <code>\rightthreetimes</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⨿</mo></mrow><annotation encoding="application/x-tex">\amalg</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">⨿</span></span></span></span> <code>\amalg</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊛</mo></mrow><annotation encoding="application/x-tex">\circledast</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.664em;vertical-align:-0.082em;"></span><span class="mord amsrm">⊛</span></span></span></span> <code>\circledast</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo separator="true">.</mo></mrow><annotation encoding="application/x-tex">\ldotp</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.1056em;"></span><span class="mpunct">.</span></span></span></span> <code>\ldotp</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋊</mo></mrow><annotation encoding="application/x-tex">\rtimes</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6633em;vertical-align:-0.0817em;"></span><span class="mord amsrm">⋊</span></span></span></span> <code>\rtimes</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>&amp;</mo></mrow><annotation encoding="application/x-tex">\And</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">&amp;</span></span></span></span> <code>\And</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊚</mo></mrow><annotation encoding="application/x-tex">\circledcirc</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.664em;vertical-align:-0.082em;"></span><span class="mord amsrm">⊚</span></span></span></span> <code>\circledcirc</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∨</mo></mrow><annotation encoding="application/x-tex">\lor</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5556em;"></span><span class="mord">∨</span></span></span></span> <code>\lor</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∖</mo></mrow><annotation encoding="application/x-tex">\setminus</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">∖</span></span></span></span> <code>\setminus</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∗</mo></mrow><annotation encoding="application/x-tex">\ast</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4653em;"></span><span class="mord">∗</span></span></span></span> <code>\ast</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊝</mo></mrow><annotation encoding="application/x-tex">\circleddash</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.664em;vertical-align:-0.082em;"></span><span class="mord amsrm">⊝</span></span></span></span> <code>\circleddash</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋖</mo></mrow><annotation encoding="application/x-tex">\lessdot</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mord amsrm">⋖</span></span></span></span> <code>\lessdot</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∖</mo></mrow><annotation encoding="application/x-tex">\smallsetminus</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6633em;vertical-align:-0.0817em;"></span><span class="mord amsrm">∖</span></span></span></span> <code>\smallsetminus</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊼</mo></mrow><annotation encoding="application/x-tex">\barwedge</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8867em;vertical-align:-0.1944em;"></span><span class="mord amsrm">⊼</span></span></span></span> <code>\barwedge</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋓</mo></mrow><annotation encoding="application/x-tex">\Cup</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5499em;"></span><span class="mord amsrm">⋓</span></span></span></span> <code>\Cup</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊲</mo></mrow><annotation encoding="application/x-tex">\lhd</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.585em;vertical-align:-0.0352em;"></span><span class="mord amsrm">⊲</span></span></span></span> <code>\lhd</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊓</mo></mrow><annotation encoding="application/x-tex">\sqcap</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5556em;"></span><span class="mord">⊓</span></span></span></span> <code>\sqcap</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>◯</mo></mrow><annotation encoding="application/x-tex">\bigcirc</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord">◯</span></span></span></span> <code>\bigcirc</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∪</mo></mrow><annotation encoding="application/x-tex">\cup</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5556em;"></span><span class="mord">∪</span></span></span></span> <code>\cup</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋉</mo></mrow><annotation encoding="application/x-tex">\ltimes</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6633em;vertical-align:-0.0817em;"></span><span class="mord amsrm">⋉</span></span></span></span> <code>\ltimes</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊔</mo></mrow><annotation encoding="application/x-tex">\sqcup</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5556em;"></span><span class="mord">⊔</span></span></span></span> <code>\sqcup</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext> </mtext><mo lspace="0.22em" rspace="0.22em"><mrow><mi mathvariant="normal">m</mi><mi mathvariant="normal">o</mi><mi mathvariant="normal">d</mi></mrow></mo><mtext> </mtext></mrow><annotation encoding="application/x-tex">\bmod</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mspace" style="margin-right:0.0556em;"></span><span class="mord"><span class="mord"><span class="mord mathrm">mod</span></span></span><span class="mspace" style="margin-right:0.0556em;"></span></span></span></span> <code>\bmod</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋎</mo></mrow><annotation encoding="application/x-tex">\curlyvee</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5499em;"></span><span class="mord amsrm">⋎</span></span></span></span> <code>\curlyvee</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>x</mi><mspace></mspace><mspace width="0.6667em"/><mrow><mi mathvariant="normal">m</mi><mi mathvariant="normal">o</mi><mi mathvariant="normal">d</mi></mrow><mtext> </mtext><mtext> </mtext><mi>a</mi></mrow><annotation encoding="application/x-tex">x \mod a</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">x</span><span class="mspace allowbreak"></span><span class="mspace" style="margin-right:0.6667em;"></span></span><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord"><span class="mord"><span class="mord mathrm">mod</span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">a</span></span></span></span> <code>x\mod a</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>×</mo></mrow><annotation encoding="application/x-tex">\times</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mord">×</span></span></span></span> <code>\times</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊡</mo></mrow><annotation encoding="application/x-tex">\boxdot</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.675em;"></span><span class="mord amsrm">⊡</span></span></span></span> <code>\boxdot</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋏</mo></mrow><annotation encoding="application/x-tex">\curlywedge</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5499em;"></span><span class="mord amsrm">⋏</span></span></span></span> <code>\curlywedge</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∓</mo></mrow><annotation encoding="application/x-tex">\mp</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mord">∓</span></span></span></span> <code>\mp</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊴</mo></mrow><annotation encoding="application/x-tex">\unlhd</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7733em;vertical-align:-0.1367em;"></span><span class="mord amsrm">⊴</span></span></span></span> <code>\unlhd</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊟</mo></mrow><annotation encoding="application/x-tex">\boxminus</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.675em;"></span><span class="mord amsrm">⊟</span></span></span></span> <code>\boxminus</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>÷</mo></mrow><annotation encoding="application/x-tex">\div</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mord">÷</span></span></span></span> <code>\div</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊙</mo></mrow><annotation encoding="application/x-tex">\odot</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mord">⊙</span></span></span></span> <code>\odot</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊵</mo></mrow><annotation encoding="application/x-tex">\unrhd</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7733em;vertical-align:-0.1367em;"></span><span class="mord amsrm">⊵</span></span></span></span> <code>\unrhd</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊞</mo></mrow><annotation encoding="application/x-tex">\boxplus</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.675em;"></span><span class="mord amsrm">⊞</span></span></span></span> <code>\boxplus</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋇</mo></mrow><annotation encoding="application/x-tex">\divideontimes</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6633em;vertical-align:-0.0817em;"></span><span class="mord amsrm">⋇</span></span></span></span> <code>\divideontimes</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊖</mo></mrow><annotation encoding="application/x-tex">\ominus</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mord">⊖</span></span></span></span> <code>\ominus</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊎</mo></mrow><annotation encoding="application/x-tex">\uplus</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5556em;"></span><span class="mord">⊎</span></span></span></span> <code>\uplus</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊠</mo></mrow><annotation encoding="application/x-tex">\boxtimes</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.675em;"></span><span class="mord amsrm">⊠</span></span></span></span> <code>\boxtimes</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∔</mo></mrow><annotation encoding="application/x-tex">\dotplus</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7742em;vertical-align:-0.082em;"></span><span class="mord amsrm">∔</span></span></span></span> <code>\dotplus</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊕</mo></mrow><annotation encoding="application/x-tex">\oplus</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mord">⊕</span></span></span></span> <code>\oplus</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∨</mo></mrow><annotation encoding="application/x-tex">\vee</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5556em;"></span><span class="mord">∨</span></span></span></span> <code>\vee</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∙</mo></mrow><annotation encoding="application/x-tex">\bullet</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4445em;"></span><span class="mord">∙</span></span></span></span> <code>\bullet</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⩞</mo></mrow><annotation encoding="application/x-tex">\doublebarwedge</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9503em;vertical-align:-0.1944em;"></span><span class="mord amsrm">⩞</span></span></span></span> <code>\doublebarwedge</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊗</mo></mrow><annotation encoding="application/x-tex">\otimes</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mord">⊗</span></span></span></span> <code>\otimes</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊻</mo></mrow><annotation encoding="application/x-tex">\veebar</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8867em;vertical-align:-0.1944em;"></span><span class="mord amsrm">⊻</span></span></span></span> <code>\veebar</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋒</mo></mrow><annotation encoding="application/x-tex">\Cap</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5499em;"></span><span class="mord amsrm">⋒</span></span></span></span> <code>\Cap</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋒</mo></mrow><annotation encoding="application/x-tex">\doublecap</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5499em;"></span><span class="mord amsrm">⋒</span></span></span></span> <code>\doublecap</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊘</mo></mrow><annotation encoding="application/x-tex">\oslash</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mord">⊘</span></span></span></span> <code>\oslash</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∧</mo></mrow><annotation encoding="application/x-tex">\wedge</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5556em;"></span><span class="mord">∧</span></span></span></span> <code>\wedge</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∩</mo></mrow><annotation encoding="application/x-tex">\cap</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5556em;"></span><span class="mord">∩</span></span></span></span> <code>\cap</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋓</mo></mrow><annotation encoding="application/x-tex">\doublecup</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5499em;"></span><span class="mord amsrm">⋓</span></span></span></span> <code>\doublecup</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>±</mo></mrow><annotation encoding="application/x-tex">\pm</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mord">±</span></span></span></span> <code>\pm</code> or <code>\plusmn</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≀</mo></mrow><annotation encoding="application/x-tex">\wr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord">≀</span></span></span></span> <code>\wr</code></td>
</tr>
</tbody>
</table>
<p>Direct Input: <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>+</mo><mo>−</mo><mi mathvariant="normal">/</mi><mo>∗</mo><mo>⋅</mo><mo>±</mo><mo>×</mo><mo>÷</mo><mo>∓</mo><mo>∔</mo><mo>∧</mo><mo>∨</mo><mo>∩</mo><mo>∪</mo><mo>≀</mo><mo>⊎</mo><mo>⊓</mo><mo>⊔</mo><mo>⊕</mo><mo>⊖</mo><mo>⊗</mo><mo>⊘</mo><mo>⊙</mo><mo>⊚</mo><mo>⊛</mo><mo>⊝</mo></mrow><annotation encoding="application/x-tex">+ - / * ⋅ ± × ÷ ∓ ∔ ∧ ∨ ∩ ∪ ≀ ⊎ ⊓ ⊔ ⊕ ⊖ ⊗ ⊘ ⊙ ⊚ ⊛ ⊝</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mord">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">/</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">∗</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mord">⋅</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">±</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mord">×</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">÷</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.7756em;vertical-align:-0.0833em;"></span><span class="mord">∓</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin amsrm">∔</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.5556em;"></span><span class="mord">∧</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">∨</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.5556em;"></span><span class="mord">∩</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">∪</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord">≀</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">⊎</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.5556em;"></span><span class="mord">⊓</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">⊔</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mord">⊕</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">⊖</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mord">⊗</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">⊘</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mord">⊙</span><span class="mord amsrm">⊚⊛⊝</span></span></span></span></p>
<h3 id="_9-3-fractions-and-binomials" tabindex="-1">9.3: Fractions and Binomials <a class="header-anchor" href="#_9-3-fractions-and-binomials" aria-label="Permalink to &quot;9.3: Fractions and Binomials&quot;">&ZeroWidthSpace;</a></h3>
<table>
<thead>
<tr>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mfrac><mi>a</mi><mi>b</mi></mfrac></mrow><annotation encoding="application/x-tex">\frac{a}{b}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0404em;vertical-align:-0.345em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6954em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">b</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">a</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span> <code>\frac{a}{b}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mfrac><mi>a</mi><mi>b</mi></mfrac></mrow><annotation encoding="application/x-tex">\tfrac{a}{b}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0404em;vertical-align:-0.345em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6954em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">b</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">a</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span> <code>\tfrac{a}{b}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true">(</mo><mfrac linethickness="0.2em"><mi>a</mi><mrow><mi>a</mi><mo>+</mo><mn>1</mn></mrow></mfrac><mo fence="true">]</mo></mrow><annotation encoding="application/x-tex">\genfrac ( ] {2pt}{1}a{a+1}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.4108em;vertical-align:-0.5594em;"></span><span class="mord"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size1">(</span></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8514em;"><span style="top:-2.4989em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">a</span><span class="mbin mtight">+</span><span class="mord mtight">1</span></span></span></span><span style="top:-3.15em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.2em;"></span></span><span style="top:-3.55em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">a</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.5594em;"><span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size1">]</span></span></span></span></span></span> <code>\genfrac ( ] {2pt}{1}a{a+1}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mfrac><mi>a</mi><mi>b</mi></mfrac></mrow><annotation encoding="application/x-tex">{a \over b}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0404em;vertical-align:-0.345em;"></span><span class="mord"><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6954em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">b</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">a</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span></span> <code>{a \over b}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle displaystyle="true" scriptlevel="0"><mfrac><mi>a</mi><mi>b</mi></mfrac></mstyle></mrow><annotation encoding="application/x-tex">\dfrac{a}{b}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.7936em;vertical-align:-0.686em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1076em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">b</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span> <code>\dfrac{a}{b}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mfrac linethickness="0.2em"><mi>a</mi><mrow><mi>b</mi><mo>+</mo><mn>1</mn></mrow></mfrac></mrow><annotation encoding="application/x-tex">{a \above{2pt} b+1}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.4458em;vertical-align:-0.5944em;"></span><span class="mord"><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8514em;"><span style="top:-2.4639em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">b</span><span class="mbin mtight">+</span><span class="mord mtight">1</span></span></span></span><span style="top:-3.15em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.2em;"></span></span><span style="top:-3.55em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">a</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.5944em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span></span> <code>{a \above{2pt} b+1}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mi mathvariant="normal">/</mi><mi>b</mi></mrow><annotation encoding="application/x-tex">a/b</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal">a</span><span class="mord">/</span><span class="mord mathnormal">b</span></span></span></span> <code>a/b</code></td>
<td style="text-align:left"></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle displaystyle="true" scriptlevel="0"><mfrac><mi>a</mi><mrow><mn>1</mn><mo>+</mo><mstyle displaystyle="true" scriptlevel="0"><mfrac><mn>1</mn><mi>b</mi></mfrac></mstyle></mrow></mfrac></mstyle></mrow><annotation encoding="application/x-tex">\cfrac{a}{1 + \cfrac{1}{b}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:3.756em;vertical-align:-2.166em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.59em;"><span style="top:-2.11em;"><span class="pstrut" style="height:3.59em;"></span><span class="mord"><span class="mord">1</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.59em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">b</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.74em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span></span></span></span></span><span style="top:-3.82em;"><span class="pstrut" style="height:3.59em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-4.33em;"><span class="pstrut" style="height:3.59em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:2.166em;"><span></span></span></span></span></span><span></span></span></span></span></span> <code>\cfrac{a}{1 + \cfrac{1}{b}}</code></td>
</tr>
</tbody>
</table>
<table>
<thead>
<tr>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true">(</mo><mfrac linethickness="0px"><mi>n</mi><mi>k</mi></mfrac><mo fence="true">)</mo></mrow><annotation encoding="application/x-tex">\binom{n}{k}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2em;vertical-align:-0.35em;"></span><span class="mord"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size1">(</span></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.7454em;"><span style="top:-2.355em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.03148em;">k</span></span></span></span><span style="top:-3.144em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">n</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size1">)</span></span></span></span></span></span> <code>\binom{n}{k}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true">(</mo><mstyle displaystyle="true" scriptlevel="0"><mfrac linethickness="0px"><mi>n</mi><mi>k</mi></mfrac></mstyle><mo fence="true">)</mo></mrow><annotation encoding="application/x-tex">\dbinom{n}{k}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.4em;vertical-align:-0.95em;"></span><span class="mord"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size3">(</span></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1076em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03148em;">k</span></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">n</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size3">)</span></span></span></span></span></span> <code>\dbinom{n}{k}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true">{</mo><mfrac linethickness="0px"><mi>n</mi><mi>k</mi></mfrac><mo fence="true">}</mo></mrow><annotation encoding="application/x-tex">{n\brace k}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2em;vertical-align:-0.35em;"></span><span class="mord"><span class="mord"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size1">{</span></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.7454em;"><span style="top:-2.355em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.03148em;">k</span></span></span></span><span style="top:-3.144em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">n</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size1">}</span></span></span></span></span></span></span> <code>{n\brace k}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true">(</mo><mfrac linethickness="0px"><mi>n</mi><mi>k</mi></mfrac><mo fence="true">)</mo></mrow><annotation encoding="application/x-tex">{n \choose k}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2em;vertical-align:-0.35em;"></span><span class="mord"><span class="mord"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size1">(</span></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.7454em;"><span style="top:-2.355em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.03148em;">k</span></span></span></span><span style="top:-3.144em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">n</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size1">)</span></span></span></span></span></span></span> <code>{n \choose k}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true">(</mo><mfrac linethickness="0px"><mi>n</mi><mi>k</mi></mfrac><mo fence="true">)</mo></mrow><annotation encoding="application/x-tex">\tbinom{n}{k}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2em;vertical-align:-0.35em;"></span><span class="mord"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size1">(</span></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.7454em;"><span style="top:-2.355em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.03148em;">k</span></span></span></span><span style="top:-3.144em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">n</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size1">)</span></span></span></span></span></span> <code>\tbinom{n}{k}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true">[</mo><mfrac linethickness="0px"><mi>n</mi><mi>k</mi></mfrac><mo fence="true">]</mo></mrow><annotation encoding="application/x-tex">{n\brack k}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2em;vertical-align:-0.35em;"></span><span class="mord"><span class="mord"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size1">[</span></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.7454em;"><span style="top:-2.355em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.03148em;">k</span></span></span></span><span style="top:-3.144em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">n</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size1">]</span></span></span></span></span></span></span> <code>{n\brack k}</code></td>
</tr>
</tbody>
</table>
<h3 id="_9-4-math-operators" tabindex="-1">9.4: Math Operators <a class="header-anchor" href="#_9-4-math-operators" aria-label="Permalink to &quot;9.4: Math Operators&quot;">&ZeroWidthSpace;</a></h3>
<table>
<thead>
<tr>
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>arcsin</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\arcsin</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6679em;"></span><span class="mop">arcsin</span></span></span></span> <code>\arcsin</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>cotg</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\cotg</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8095em;vertical-align:-0.1944em;"></span><span class="mop">cot<span style="margin-right:0.01389em;">g</span></span></span></span></span> <code>\cotg</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ln</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\ln</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mop">ln</span></span></span></span> <code>\ln</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>det</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\det</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mop">det</span></span></span></span> <code>\det</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>arccos</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\arccos</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mop">arccos</span></span></span></span> <code>\arccos</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>coth</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\coth</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mop">coth</span></span></span></span> <code>\coth</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>log</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\log</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mop">lo<span style="margin-right:0.01389em;">g</span></span></span></span></span> <code>\log</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>gcd</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\gcd</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mop"><span style="margin-right:0.01389em;">g</span>cd</span></span></span></span> <code>\gcd</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>arctan</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\arctan</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6151em;"></span><span class="mop">arctan</span></span></span></span> <code>\arctan</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>csc</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\csc</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mop">csc</span></span></span></span> <code>\csc</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>sec</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\sec</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mop">sec</span></span></span></span> <code>\sec</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>inf</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\inf</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mop">in<span style="margin-right:0.07778em;">f</span></span></span></span></span> <code>\inf</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>arctg</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\arctg</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8095em;vertical-align:-0.1944em;"></span><span class="mop">arct<span style="margin-right:0.01389em;">g</span></span></span></span></span> <code>\arctg</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ctg</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\ctg</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8095em;vertical-align:-0.1944em;"></span><span class="mop">ct<span style="margin-right:0.01389em;">g</span></span></span></span></span> <code>\ctg</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>sin</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\sin</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6679em;"></span><span class="mop">sin</span></span></span></span> <code>\sin</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>lim</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\lim</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mop">lim</span></span></span></span> <code>\lim</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>arcctg</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\arcctg</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8095em;vertical-align:-0.1944em;"></span><span class="mop">arcct<span style="margin-right:0.01389em;">g</span></span></span></span></span> <code>\arcctg</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>cth</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\cth</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mop">cth</span></span></span></span> <code>\cth</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>sinh</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\sinh</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mop">sinh</span></span></span></span> <code>\sinh</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">lim inf</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\liminf</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mop"><span class="mord mathrm">lim</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathrm" style="margin-right:0.07778em;">inf</span></span></span></span></span> <code>\liminf</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>arg</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\arg</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mop">ar<span style="margin-right:0.01389em;">g</span></span></span></span></span> <code>\arg</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>deg</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\deg</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mop">de<span style="margin-right:0.01389em;">g</span></span></span></span></span> <code>\deg</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>sh</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\sh</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mop">sh</span></span></span></span> <code>\sh</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">lim sup</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\limsup</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mop"><span class="mord mathrm">lim</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathrm">sup</span></span></span></span></span> <code>\limsup</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ch</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\ch</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mop">ch</span></span></span></span> <code>\ch</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>dim</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\dim</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mop">dim</span></span></span></span> <code>\dim</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>tan</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\tan</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6151em;"></span><span class="mop">tan</span></span></span></span> <code>\tan</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>max</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\max</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mop">max</span></span></span></span> <code>\max</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>cos</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\cos</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mop">cos</span></span></span></span> <code>\cos</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>exp</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\exp</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mop">exp</span></span></span></span> <code>\exp</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>tanh</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\tanh</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mop">tanh</span></span></span></span> <code>\tanh</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>min</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\min</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6679em;"></span><span class="mop">min</span></span></span></span> <code>\min</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>cosec</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\cosec</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mop">cosec</span></span></span></span> <code>\cosec</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>hom</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\hom</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mop">hom</span></span></span></span> <code>\hom</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>tg</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\tg</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8095em;vertical-align:-0.1944em;"></span><span class="mop">t<span style="margin-right:0.01389em;">g</span></span></span></span></span> <code>\tg</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>Pr</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\Pr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mop">Pr</span></span></span></span> <code>\Pr</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>cosh</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\cosh</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mop">cosh</span></span></span></span> <code>\cosh</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ker</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\ker</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mop">ker</span></span></span></span> <code>\ker</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>th</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\th</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mop">th</span></span></span></span> <code>\th</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>sup</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\sup</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mop">sup</span></span></span></span> <code>\sup</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>cot</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\cot</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6151em;"></span><span class="mop">cot</span></span></span></span> <code>\cot</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>lg</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\lg</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mop">l<span style="margin-right:0.01389em;">g</span></span></span></span></span> <code>\lg</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">f</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\operatorname{f}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mop"><span class="mord mathrm" style="margin-right:0.07778em;">f</span></span></span></span></span> <code>\operatorname{f}</code></td>
<td></td>
</tr>
</tbody>
</table>
<p>Functions on the right column of this table can take <code>\limits</code>.</p>
<h3 id="_9-5-sqrt" tabindex="-1">9.5: <code>\sqrt</code> <a class="header-anchor" href="#_9-5-sqrt" aria-label="Permalink to &quot;9.5: `\sqrt`&quot;">&ZeroWidthSpace;</a></h3>
<p><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msqrt><mi>x</mi></msqrt></mrow><annotation encoding="application/x-tex">\sqrt{x}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.04em;vertical-align:-0.2397em;"></span><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8003em;"><span class="svg-align" style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord" style="padding-left:0.833em;"><span class="mord mathnormal">x</span></span></span><span style="top:-2.7603em;"><span class="pstrut" style="height:3em;"></span><span class="hide-tail" style="min-width:0.853em;height:1.08em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='1.08em' viewBox='0 0 400000 1080' preserveAspectRatio='xMinYMin slice'><path d='M95,702
c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14
c0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54
c44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10
s173,378,173,378c0.7,0,35.3,-71,104,-213c68.7,-142,137.5,-285,206.5,-429
c69,-144,104.5,-217.7,106.5,-221
l0 -0
c5.3,-9.3,12,-14,20,-14
H400000v40H845.2724
s-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7
c-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z
M834 80h400000v40h-400000z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2397em;"><span></span></span></span></span></span></span></span></span> <code>\sqrt{x}</code></p>
<p><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mroot><mi>x</mi><mn>3</mn></mroot></mrow><annotation encoding="application/x-tex">\sqrt[3]{x}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.04em;vertical-align:-0.2397em;"></span><span class="mord sqrt"><span class="root"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6586em;"><span style="top:-2.8363em;"><span class="pstrut" style="height:2.5em;"></span><span class="sizing reset-size6 size1 mtight"><span class="mord mtight"><span class="mord mtight">3</span></span></span></span></span></span></span></span><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8003em;"><span class="svg-align" style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord" style="padding-left:0.833em;"><span class="mord mathnormal">x</span></span></span><span style="top:-2.7603em;"><span class="pstrut" style="height:3em;"></span><span class="hide-tail" style="min-width:0.853em;height:1.08em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='1.08em' viewBox='0 0 400000 1080' preserveAspectRatio='xMinYMin slice'><path d='M95,702
c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14
c0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54
c44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10
s173,378,173,378c0.7,0,35.3,-71,104,-213c68.7,-142,137.5,-285,206.5,-429
c69,-144,104.5,-217.7,106.5,-221
l0 -0
c5.3,-9.3,12,-14,20,-14
H400000v40H845.2724
s-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7
c-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z
M834 80h400000v40h-400000z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2397em;"><span></span></span></span></span></span></span></span></span> <code>\sqrt[3]{x}</code></p>
<h2 id="_10-relations" tabindex="-1">10: Relations <a class="header-anchor" href="#_10-relations" aria-label="Permalink to &quot;10: Relations&quot;">&ZeroWidthSpace;</a></h2>
<p><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mover><mo><mo>=</mo></mo><mo stretchy="false" lspace="0em" rspace="0em">!</mo></mover></mo></mrow><annotation encoding="application/x-tex">\stackrel{!}{=}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.153em;"></span><span class="mrel"><span class="mop op-limits"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:1.153em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span><span class="mop">=</span></span></span><span style="top:-3.5669em;margin-left:0em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mclose mtight">!</span></span></span></span></span></span></span></span></span></span></span></span> <code>\stackrel{!}{=}</code></p>
<table>
<thead>
<tr>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>=</mo></mrow><annotation encoding="application/x-tex">=</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">=</span></span></span></span> <code>=</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≖</mo></mrow><annotation encoding="application/x-tex">\eqcirc</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mrel amsrm">≖</span></span></span></span> <code>\eqcirc</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋚</mo></mrow><annotation encoding="application/x-tex">\lesseqgtr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2714em;vertical-align:-0.3857em;"></span><span class="mrel amsrm">⋚</span></span></span></span> <code>\lesseqgtr</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊐</mo></mrow><annotation encoding="application/x-tex">\sqsupset</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.585em;vertical-align:-0.0352em;"></span><span class="mrel amsrm">⊐</span></span></span></span> <code>\sqsupset</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>&lt;</mo></mrow><annotation encoding="application/x-tex">&lt;</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">&lt;</span></span></span></span> <code>&lt;</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mi mathvariant="normal">∹</mi></mo></mrow><annotation encoding="application/x-tex">\eqcolon</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mrel"><span class="mrel"><span class="mord">−</span></span><span class="mrel"><span class="mspace" style="margin-right:-0.0667em;"></span></span><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span></span></span></span></span> <code>\eqcolon</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⪋</mo></mrow><annotation encoding="application/x-tex">\lesseqqgtr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.4651em;vertical-align:-0.4826em;"></span><span class="mrel amsrm">⪋</span></span></span></span> <code>\lesseqqgtr</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊒</mo></mrow><annotation encoding="application/x-tex">\sqsupseteq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mrel">⊒</span></span></span></span> <code>\sqsupseteq</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>&gt;</mo></mrow><annotation encoding="application/x-tex">&gt;</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">&gt;</span></span></span></span> <code>&gt;</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mi mathvariant="normal">−</mi><mi mathvariant="normal">∷</mi></mo></mrow><annotation encoding="application/x-tex">\Eqcolon</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mrel"><span class="mrel"><span class="mord">−</span></span><span class="mrel"><span class="mspace" style="margin-right:-0.0667em;"></span></span><span class="mrel"><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span><span class="mrel"><span class="mspace" style="margin-right:-0.05em;"></span></span><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span></span></span></span></span></span> <code>\Eqcolon</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≶</mo></mrow><annotation encoding="application/x-tex">\lessgtr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8558em;vertical-align:-0.1808em;"></span><span class="mrel amsrm">≶</span></span></span></span> <code>\lessgtr</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋐</mo></mrow><annotation encoding="application/x-tex">\Subset</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.585em;vertical-align:-0.0352em;"></span><span class="mrel amsrm">⋐</span></span></span></span> <code>\Subset</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>:</mo></mrow><annotation encoding="application/x-tex">:</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mrel">:</span></span></span></span> <code>:</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mi mathvariant="normal">≕</mi></mo></mrow><annotation encoding="application/x-tex">\eqqcolon</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mrel"><span class="mrel">=</span><span class="mrel"><span class="mspace" style="margin-right:-0.0667em;"></span></span><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span></span></span></span></span> <code>\eqqcolon</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≲</mo></mrow><annotation encoding="application/x-tex">\lesssim</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9592em;vertical-align:-0.2296em;"></span><span class="mrel amsrm">≲</span></span></span></span> <code>\lesssim</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊂</mo></mrow><annotation encoding="application/x-tex">\subset</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">⊂</span></span></span></span> <code>\subset</code> or <code>\sub</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≈</mo></mrow><annotation encoding="application/x-tex">\approx</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4831em;"></span><span class="mrel">≈</span></span></span></span> <code>\approx</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mi mathvariant="normal">=</mi><mi mathvariant="normal">∷</mi></mo></mrow><annotation encoding="application/x-tex">\Eqqcolon</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mrel"><span class="mrel">=</span><span class="mrel"><span class="mspace" style="margin-right:-0.0667em;"></span></span><span class="mrel"><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span><span class="mrel"><span class="mspace" style="margin-right:-0.05em;"></span></span><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span></span></span></span></span></span> <code>\Eqqcolon</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≪</mo></mrow><annotation encoding="application/x-tex">\ll</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">≪</span></span></span></span> <code>\ll</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊆</mo></mrow><annotation encoding="application/x-tex">\subseteq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mrel">⊆</span></span></span></span> <code>\subseteq</code> or <code>\sube</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≊</mo></mrow><annotation encoding="application/x-tex">\approxeq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6633em;vertical-align:-0.0817em;"></span><span class="mrel amsrm">≊</span></span></span></span> <code>\approxeq</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≂</mo></mrow><annotation encoding="application/x-tex">\eqsim</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4637em;"></span><span class="mrel amsrm">≂</span></span></span></span> <code>\eqsim</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋘</mo></mrow><annotation encoding="application/x-tex">\lll</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.585em;vertical-align:-0.0352em;"></span><span class="mrel amsrm">⋘</span></span></span></span> <code>\lll</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⫅</mo></mrow><annotation encoding="application/x-tex">\subseteqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0117em;vertical-align:-0.2558em;"></span><span class="mrel amsrm">⫅</span></span></span></span> <code>\subseteqq</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≍</mo></mrow><annotation encoding="application/x-tex">\asymp</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4637em;"></span><span class="mrel">≍</span></span></span></span> <code>\asymp</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⪖</mo></mrow><annotation encoding="application/x-tex">\eqslantgtr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7733em;vertical-align:-0.1367em;"></span><span class="mrel amsrm">⪖</span></span></span></span> <code>\eqslantgtr</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋘</mo></mrow><annotation encoding="application/x-tex">\llless</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.585em;vertical-align:-0.0352em;"></span><span class="mrel amsrm">⋘</span></span></span></span> <code>\llless</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≻</mo></mrow><annotation encoding="application/x-tex">\succ</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">≻</span></span></span></span> <code>\succ</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∍</mo></mrow><annotation encoding="application/x-tex">\backepsilon</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mrel amsrm">∍</span></span></span></span> <code>\backepsilon</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⪕</mo></mrow><annotation encoding="application/x-tex">\eqslantless</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7733em;vertical-align:-0.1367em;"></span><span class="mrel amsrm">⪕</span></span></span></span> <code>\eqslantless</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>&lt;</mo></mrow><annotation encoding="application/x-tex">\lt</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">&lt;</span></span></span></span> <code>\lt</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⪸</mo></mrow><annotation encoding="application/x-tex">\succapprox</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0189em;vertical-align:-0.2617em;"></span><span class="mrel amsrm">⪸</span></span></span></span> <code>\succapprox</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∽</mo></mrow><annotation encoding="application/x-tex">\backsim</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3779em;"></span><span class="mrel amsrm">∽</span></span></span></span> <code>\backsim</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≡</mo></mrow><annotation encoding="application/x-tex">\equiv</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4637em;"></span><span class="mrel">≡</span></span></span></span> <code>\equiv</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∣</mo></mrow><annotation encoding="application/x-tex">\mid</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mrel">∣</span></span></span></span> <code>\mid</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≽</mo></mrow><annotation encoding="application/x-tex">\succcurlyeq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7733em;vertical-align:-0.1367em;"></span><span class="mrel amsrm">≽</span></span></span></span> <code>\succcurlyeq</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋍</mo></mrow><annotation encoding="application/x-tex">\backsimeq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.464em;"></span><span class="mrel amsrm">⋍</span></span></span></span> <code>\backsimeq</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≒</mo></mrow><annotation encoding="application/x-tex">\fallingdotseq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.664em;vertical-align:-0.082em;"></span><span class="mrel amsrm">≒</span></span></span></span> <code>\fallingdotseq</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊨</mo></mrow><annotation encoding="application/x-tex">\models</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.999em;vertical-align:-0.249em;"></span><span class="mrel">⊨</span></span></span></span> <code>\models</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⪰</mo></mrow><annotation encoding="application/x-tex">\succeq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mrel">⪰</span></span></span></span> <code>\succeq</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≬</mo></mrow><annotation encoding="application/x-tex">\between</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0117em;vertical-align:-0.2558em;"></span><span class="mrel amsrm">≬</span></span></span></span> <code>\between</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⌢</mo></mrow><annotation encoding="application/x-tex">\frown</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3576em;"></span><span class="mrel">⌢</span></span></span></span> <code>\frown</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊸</mo></mrow><annotation encoding="application/x-tex">\multimap</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5499em;"></span><span class="mrel amsrm">⊸</span></span></span></span> <code>\multimap</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≿</mo></mrow><annotation encoding="application/x-tex">\succsim</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9592em;vertical-align:-0.2296em;"></span><span class="mrel amsrm">≿</span></span></span></span> <code>\succsim</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋈</mo></mrow><annotation encoding="application/x-tex">\bowtie</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.51em;vertical-align:-0.005em;"></span><span class="mrel">⋈</span></span></span></span> <code>\bowtie</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≥</mo></mrow><annotation encoding="application/x-tex">\ge</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mrel">≥</span></span></span></span> <code>\ge</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∋</mo></mrow><annotation encoding="application/x-tex">\owns</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">∋</span></span></span></span> <code>\owns</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋑</mo></mrow><annotation encoding="application/x-tex">\Supset</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.585em;vertical-align:-0.0352em;"></span><span class="mrel amsrm">⋑</span></span></span></span> <code>\Supset</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≏</mo></mrow><annotation encoding="application/x-tex">\bumpeq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6105em;vertical-align:-0.0606em;"></span><span class="mrel amsrm">≏</span></span></span></span> <code>\bumpeq</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≥</mo></mrow><annotation encoding="application/x-tex">\geq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mrel">≥</span></span></span></span> <code>\geq</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∥</mo></mrow><annotation encoding="application/x-tex">\parallel</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mrel">∥</span></span></span></span> <code>\parallel</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊃</mo></mrow><annotation encoding="application/x-tex">\supset</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">⊃</span></span></span></span> <code>\supset</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≎</mo></mrow><annotation encoding="application/x-tex">\Bumpeq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6105em;vertical-align:-0.0606em;"></span><span class="mrel amsrm">≎</span></span></span></span> <code>\Bumpeq</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≧</mo></mrow><annotation encoding="application/x-tex">\geqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0117em;vertical-align:-0.2558em;"></span><span class="mrel amsrm">≧</span></span></span></span> <code>\geqq</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊥</mo></mrow><annotation encoding="application/x-tex">\perp</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mrel">⊥</span></span></span></span> <code>\perp</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊇</mo></mrow><annotation encoding="application/x-tex">\supseteq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mrel">⊇</span></span></span></span> <code>\supseteq</code> or <code>\supe</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≗</mo></mrow><annotation encoding="application/x-tex">\circeq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9592em;vertical-align:-0.2296em;"></span><span class="mrel amsrm">≗</span></span></span></span> <code>\circeq</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⩾</mo></mrow><annotation encoding="application/x-tex">\geqslant</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7733em;vertical-align:-0.1367em;"></span><span class="mrel amsrm">⩾</span></span></span></span> <code>\geqslant</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋔</mo></mrow><annotation encoding="application/x-tex">\pitchfork</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mrel amsrm">⋔</span></span></span></span> <code>\pitchfork</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⫆</mo></mrow><annotation encoding="application/x-tex">\supseteqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0117em;vertical-align:-0.2558em;"></span><span class="mrel amsrm">⫆</span></span></span></span> <code>\supseteqq</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mi mathvariant="normal">:</mi><mi mathvariant="normal">≈</mi></mo></mrow><annotation encoding="application/x-tex">\colonapprox</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4831em;"></span><span class="mrel"><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span><span class="mrel"><span class="mspace" style="margin-right:-0.0667em;"></span></span><span class="mrel">≈</span></span></span></span></span> <code>\colonapprox</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≫</mo></mrow><annotation encoding="application/x-tex">\gg</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">≫</span></span></span></span> <code>\gg</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≺</mo></mrow><annotation encoding="application/x-tex">\prec</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">≺</span></span></span></span> <code>\prec</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≈</mo></mrow><annotation encoding="application/x-tex">\thickapprox</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4831em;"></span><span class="mrel amsrm">≈</span></span></span></span> <code>\thickapprox</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mi mathvariant="normal">∷</mi><mi mathvariant="normal">≈</mi></mo></mrow><annotation encoding="application/x-tex">\Colonapprox</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4831em;"></span><span class="mrel"><span class="mrel"><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span><span class="mrel"><span class="mspace" style="margin-right:-0.05em;"></span></span><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span></span><span class="mrel"><span class="mspace" style="margin-right:-0.0667em;"></span></span><span class="mrel">≈</span></span></span></span></span> <code>\Colonapprox</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋙</mo></mrow><annotation encoding="application/x-tex">\ggg</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.585em;vertical-align:-0.0352em;"></span><span class="mrel amsrm">⋙</span></span></span></span> <code>\ggg</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⪷</mo></mrow><annotation encoding="application/x-tex">\precapprox</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0189em;vertical-align:-0.2617em;"></span><span class="mrel amsrm">⪷</span></span></span></span> <code>\precapprox</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∼</mo></mrow><annotation encoding="application/x-tex">\thicksim</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel amsrm">∼</span></span></span></span> <code>\thicksim</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mi mathvariant="normal">:</mi><mi mathvariant="normal">−</mi></mo></mrow><annotation encoding="application/x-tex">\coloneq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mrel"><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span><span class="mrel"><span class="mspace" style="margin-right:-0.0667em;"></span></span><span class="mrel"><span class="mord">−</span></span></span></span></span></span> <code>\coloneq</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋙</mo></mrow><annotation encoding="application/x-tex">\gggtr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.585em;vertical-align:-0.0352em;"></span><span class="mrel amsrm">⋙</span></span></span></span> <code>\gggtr</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≼</mo></mrow><annotation encoding="application/x-tex">\preccurlyeq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7733em;vertical-align:-0.1367em;"></span><span class="mrel amsrm">≼</span></span></span></span> <code>\preccurlyeq</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊴</mo></mrow><annotation encoding="application/x-tex">\trianglelefteq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7733em;vertical-align:-0.1367em;"></span><span class="mrel amsrm">⊴</span></span></span></span> <code>\trianglelefteq</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mi mathvariant="normal">∷</mi><mi mathvariant="normal">−</mi></mo></mrow><annotation encoding="application/x-tex">\Coloneq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mrel"><span class="mrel"><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span><span class="mrel"><span class="mspace" style="margin-right:-0.05em;"></span></span><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span></span><span class="mrel"><span class="mspace" style="margin-right:-0.0667em;"></span></span><span class="mrel"><span class="mord">−</span></span></span></span></span></span> <code>\Coloneq</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>&gt;</mo></mrow><annotation encoding="application/x-tex">\gt</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">&gt;</span></span></span></span> <code>\gt</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⪯</mo></mrow><annotation encoding="application/x-tex">\preceq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mrel">⪯</span></span></span></span> <code>\preceq</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≜</mo></mrow><annotation encoding="application/x-tex">\triangleq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9987em;vertical-align:-0.082em;"></span><span class="mrel amsrm">≜</span></span></span></span> <code>\triangleq</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mi mathvariant="normal">≔</mi></mo></mrow><annotation encoding="application/x-tex">\coloneqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mrel"><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span><span class="mrel"><span class="mspace" style="margin-right:-0.0667em;"></span></span><span class="mrel">=</span></span></span></span></span> <code>\coloneqq</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⪆</mo></mrow><annotation encoding="application/x-tex">\gtrapprox</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0117em;vertical-align:-0.2558em;"></span><span class="mrel amsrm">⪆</span></span></span></span> <code>\gtrapprox</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≾</mo></mrow><annotation encoding="application/x-tex">\precsim</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9592em;vertical-align:-0.2296em;"></span><span class="mrel amsrm">≾</span></span></span></span> <code>\precsim</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊵</mo></mrow><annotation encoding="application/x-tex">\trianglerighteq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7733em;vertical-align:-0.1367em;"></span><span class="mrel amsrm">⊵</span></span></span></span> <code>\trianglerighteq</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mi mathvariant="normal">∷</mi><mi mathvariant="normal">=</mi></mo></mrow><annotation encoding="application/x-tex">\Coloneqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mrel"><span class="mrel"><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span><span class="mrel"><span class="mspace" style="margin-right:-0.05em;"></span></span><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span></span><span class="mrel"><span class="mspace" style="margin-right:-0.0667em;"></span></span><span class="mrel">=</span></span></span></span></span> <code>\Coloneqq</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋛</mo></mrow><annotation encoding="application/x-tex">\gtreqless</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2714em;vertical-align:-0.3857em;"></span><span class="mrel amsrm">⋛</span></span></span></span> <code>\gtreqless</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∝</mo></mrow><annotation encoding="application/x-tex">\propto</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mrel">∝</span></span></span></span> <code>\propto</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∝</mo></mrow><annotation encoding="application/x-tex">\varpropto</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mrel amsrm">∝</span></span></span></span> <code>\varpropto</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mi mathvariant="normal">:</mi><mi mathvariant="normal">∼</mi></mo></mrow><annotation encoding="application/x-tex">\colonsim</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mrel"><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span><span class="mrel"><span class="mspace" style="margin-right:-0.0667em;"></span></span><span class="mrel">∼</span></span></span></span></span> <code>\colonsim</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⪌</mo></mrow><annotation encoding="application/x-tex">\gtreqqless</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.4651em;vertical-align:-0.4826em;"></span><span class="mrel amsrm">⪌</span></span></span></span> <code>\gtreqqless</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≓</mo></mrow><annotation encoding="application/x-tex">\risingdotseq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.664em;vertical-align:-0.082em;"></span><span class="mrel amsrm">≓</span></span></span></span> <code>\risingdotseq</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>△</mo></mrow><annotation encoding="application/x-tex">\vartriangle</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5499em;"></span><span class="mrel amsrm">△</span></span></span></span> <code>\vartriangle</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mi mathvariant="normal">∷</mi><mi mathvariant="normal">∼</mi></mo></mrow><annotation encoding="application/x-tex">\Colonsim</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mrel"><span class="mrel"><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span><span class="mrel"><span class="mspace" style="margin-right:-0.05em;"></span></span><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span></span><span class="mrel"><span class="mspace" style="margin-right:-0.0667em;"></span></span><span class="mrel">∼</span></span></span></span></span> <code>\Colonsim</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≷</mo></mrow><annotation encoding="application/x-tex">\gtrless</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8558em;vertical-align:-0.1808em;"></span><span class="mrel amsrm">≷</span></span></span></span> <code>\gtrless</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∣</mo></mrow><annotation encoding="application/x-tex">\shortmid</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6633em;vertical-align:-0.0817em;"></span><span class="mrel amsrm">∣</span></span></span></span> <code>\shortmid</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊲</mo></mrow><annotation encoding="application/x-tex">\vartriangleleft</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.585em;vertical-align:-0.0352em;"></span><span class="mrel amsrm">⊲</span></span></span></span> <code>\vartriangleleft</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≅</mo></mrow><annotation encoding="application/x-tex">\cong</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.589em;"></span><span class="mrel">≅</span></span></span></span> <code>\cong</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≳</mo></mrow><annotation encoding="application/x-tex">\gtrsim</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9592em;vertical-align:-0.2296em;"></span><span class="mrel amsrm">≳</span></span></span></span> <code>\gtrsim</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∥</mo></mrow><annotation encoding="application/x-tex">\shortparallel</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6633em;vertical-align:-0.0817em;"></span><span class="mrel amsrm">∥</span></span></span></span> <code>\shortparallel</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊳</mo></mrow><annotation encoding="application/x-tex">\vartriangleright</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.585em;vertical-align:-0.0352em;"></span><span class="mrel amsrm">⊳</span></span></span></span> <code>\vartriangleright</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋞</mo></mrow><annotation encoding="application/x-tex">\curlyeqprec</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7733em;vertical-align:-0.1367em;"></span><span class="mrel amsrm">⋞</span></span></span></span> <code>\curlyeqprec</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∈</mo></mrow><annotation encoding="application/x-tex">\in</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">∈</span></span></span></span> <code>\in</code> or <code>\isin</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∼</mo></mrow><annotation encoding="application/x-tex">\sim</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">∼</span></span></span></span> <code>\sim</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mo><mo>:</mo></mo></mo></mrow><annotation encoding="application/x-tex">\vcentcolon</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span></span></span></span> <code>\vcentcolon</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋟</mo></mrow><annotation encoding="application/x-tex">\curlyeqsucc</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7733em;vertical-align:-0.1367em;"></span><span class="mrel amsrm">⋟</span></span></span></span> <code>\curlyeqsucc</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋈</mo></mrow><annotation encoding="application/x-tex">\Join</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.51em;vertical-align:-0.005em;"></span><span class="mrel">⋈</span></span></span></span> <code>\Join</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≃</mo></mrow><annotation encoding="application/x-tex">\simeq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4637em;"></span><span class="mrel">≃</span></span></span></span> <code>\simeq</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊢</mo></mrow><annotation encoding="application/x-tex">\vdash</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mrel">⊢</span></span></span></span> <code>\vdash</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊣</mo></mrow><annotation encoding="application/x-tex">\dashv</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mrel">⊣</span></span></span></span> <code>\dashv</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≤</mo></mrow><annotation encoding="application/x-tex">\le</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mrel">≤</span></span></span></span> <code>\le</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⌢</mo></mrow><annotation encoding="application/x-tex">\smallfrown</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8867em;vertical-align:-0.1944em;"></span><span class="mrel amsrm">⌢</span></span></span></span> <code>\smallfrown</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊨</mo></mrow><annotation encoding="application/x-tex">\vDash</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mrel amsrm">⊨</span></span></span></span> <code>\vDash</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mi mathvariant="normal">∷</mi></mo></mrow><annotation encoding="application/x-tex">\dblcolon</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mrel"><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span><span class="mrel"><span class="mspace" style="margin-right:-0.05em;"></span></span><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span></span></span></span></span> <code>\dblcolon</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≤</mo></mrow><annotation encoding="application/x-tex">\leq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mrel">≤</span></span></span></span> <code>\leq</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⌣</mo></mrow><annotation encoding="application/x-tex">\smallsmile</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8867em;vertical-align:-0.1944em;"></span><span class="mrel amsrm">⌣</span></span></span></span> <code>\smallsmile</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊩</mo></mrow><annotation encoding="application/x-tex">\Vdash</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mrel amsrm">⊩</span></span></span></span> <code>\Vdash</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≐</mo></mrow><annotation encoding="application/x-tex">\doteq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.673em;"></span><span class="mrel">≐</span></span></span></span> <code>\doteq</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≦</mo></mrow><annotation encoding="application/x-tex">\leqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0117em;vertical-align:-0.2558em;"></span><span class="mrel amsrm">≦</span></span></span></span> <code>\leqq</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⌣</mo></mrow><annotation encoding="application/x-tex">\smile</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3576em;"></span><span class="mrel">⌣</span></span></span></span> <code>\smile</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊪</mo></mrow><annotation encoding="application/x-tex">\Vvdash</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mrel amsrm">⊪</span></span></span></span> <code>\Vvdash</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≑</mo></mrow><annotation encoding="application/x-tex">\Doteq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.664em;vertical-align:-0.082em;"></span><span class="mrel amsrm">≑</span></span></span></span> <code>\Doteq</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⩽</mo></mrow><annotation encoding="application/x-tex">\leqslant</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7733em;vertical-align:-0.1367em;"></span><span class="mrel amsrm">⩽</span></span></span></span> <code>\leqslant</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊏</mo></mrow><annotation encoding="application/x-tex">\sqsubset</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.585em;vertical-align:-0.0352em;"></span><span class="mrel amsrm">⊏</span></span></span></span> <code>\sqsubset</code></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≑</mo></mrow><annotation encoding="application/x-tex">\doteqdot</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.664em;vertical-align:-0.082em;"></span><span class="mrel amsrm">≑</span></span></span></span> <code>\doteqdot</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⪅</mo></mrow><annotation encoding="application/x-tex">\lessapprox</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0117em;vertical-align:-0.2558em;"></span><span class="mrel amsrm">⪅</span></span></span></span> <code>\lessapprox</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊑</mo></mrow><annotation encoding="application/x-tex">\sqsubseteq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mrel">⊑</span></span></span></span> <code>\sqsubseteq</code></td>
<td style="text-align:left"></td>
</tr>
</tbody>
</table>
<p>Direct Input: <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>=</mo><mo>&lt;</mo><mo>&gt;</mo><mo>:</mo><mo>∈</mo><mo>∋</mo><mo>∝</mo><mo>∼</mo><mo>∽</mo><mo>≂</mo><mo>≃</mo><mo>≅</mo><mo>≈</mo><mo>≊</mo><mo>≍</mo><mo>≎</mo><mo>≏</mo><mo>≐</mo><mo>≑</mo><mo>≒</mo><mo>≓</mo><mo>≖</mo><mo>≗</mo><mo>≜</mo><mo>≡</mo><mo>≤</mo><mo>≥</mo><mo>≦</mo><mo>≧</mo><mo>≫</mo><mo>≬</mo><mo>≳</mo><mo>≷</mo><mo>≺</mo><mo>≻</mo><mo>≼</mo><mo>≽</mo><mo>≾</mo><mo>≿</mo><mo>⊂</mo><mo>⊃</mo><mo>⊆</mo><mo>⊇</mo><mo>⊏</mo><mo>⊐</mo><mo>⊑</mo><mo>⊒</mo><mo>⊢</mo><mo>⊣</mo><mo>⊩</mo><mo>⊪</mo><mo>⊸</mo><mo>⋈</mo><mo>⋍</mo><mo>⋐</mo><mo>⋑</mo><mo>⋔</mo><mo>⋙</mo><mo>⋛</mo><mo>⋞</mo><mo>⋟</mo><mo>⌢</mo><mo>⌣</mo><mo>⩾</mo><mo>⪆</mo><mo>⪌</mo><mo>⪕</mo><mo>⪖</mo><mo>⪯</mo><mo>⪰</mo><mo>⪷</mo><mo>⪸</mo><mo>⫅</mo><mo>⫆</mo><mo>≲</mo><mo>⩽</mo><mo>⪅</mo><mo>≶</mo><mo>⋚</mo><mo>⪋</mo><mo>⊥</mo><mo>⊨</mo></mrow><annotation encoding="application/x-tex">= &lt; &gt; : ∈ ∋ ∝ ∼ ∽ ≂ ≃ ≅ ≈ ≊ ≍ ≎ ≏ ≐ ≑ ≒ ≓ ≖ ≗ ≜ ≡ ≤ ≥ ≦ ≧ ≫ ≬ ≳ ≷ ≺ ≻ ≼ ≽ ≾ ≿ ⊂ ⊃ ⊆ ⊇ ⊏ ⊐ ⊑ ⊒ ⊢ ⊣ ⊩ ⊪ ⊸ ⋈ ⋍ ⋐ ⋑ ⋔ ⋙ ⋛ ⋞ ⋟ ⌢ ⌣ ⩾ ⪆ ⪌ ⪕ ⪖ ⪯ ⪰ ⪷ ⪸ ⫅ ⫆ ≲ ⩽ ⪅ ≶ ⋚ ⪋ ⟂ ⊨</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">=&lt;&gt;:∈∋∝∼</span></span><span class="base"><span class="strut" style="height:0.4637em;"></span><span class="mrel amsrm">∽≂</span></span><span class="base"><span class="strut" style="height:0.589em;"></span><span class="mrel">≃≅≈</span></span><span class="base"><span class="strut" style="height:0.6633em;vertical-align:-0.0817em;"></span><span class="mrel amsrm">≊</span></span><span class="base"><span class="strut" style="height:0.4637em;"></span><span class="mrel">≍</span></span><span class="base"><span class="strut" style="height:0.6105em;vertical-align:-0.0606em;"></span><span class="mrel amsrm">≎≏</span></span><span class="base"><span class="strut" style="height:0.673em;"></span><span class="mrel">≐</span></span><span class="base"><span class="strut" style="height:1.1462em;vertical-align:-0.2296em;"></span><span class="mrel amsrm">≑≒≓≖≗≜</span></span><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mrel">≡≤≥</span></span><span class="base"><span class="strut" style="height:1.0117em;vertical-align:-0.2558em;"></span><span class="mrel amsrm">≦≧</span></span><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">≫</span></span><span class="base"><span class="strut" style="height:1.0117em;vertical-align:-0.2558em;"></span><span class="mrel amsrm">≬≳≷</span></span><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">≺≻</span></span><span class="base"><span class="strut" style="height:0.9592em;vertical-align:-0.2296em;"></span><span class="mrel amsrm">≼≽≾≿</span></span><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mrel">⊂⊃⊆⊇</span></span><span class="base"><span class="strut" style="height:0.585em;vertical-align:-0.0352em;"></span><span class="mrel amsrm">⊏⊐</span></span><span class="base"><span class="strut" style="height:0.8304em;vertical-align:-0.136em;"></span><span class="mrel">⊑⊒⊢⊣</span></span><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mrel amsrm">⊩⊪⊸</span></span><span class="base"><span class="strut" style="height:0.51em;vertical-align:-0.005em;"></span><span class="mrel">⋈</span></span><span class="base"><span class="strut" style="height:1.2714em;vertical-align:-0.3857em;"></span><span class="mrel amsrm">⋍⋐⋑⋔⋙⋛⋞⋟</span></span><span class="base"><span class="strut" style="height:0.3576em;"></span><span class="mrel">⌢⌣</span></span><span class="base"><span class="strut" style="height:1.4651em;vertical-align:-0.4826em;"></span><span class="mrel amsrm">⩾⪆⪌⪕⪖</span></span><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mrel">⪯⪰</span></span><span class="base"><span class="strut" style="height:1.4651em;vertical-align:-0.4826em;"></span><span class="mrel amsrm">⪷⪸⫅⫆≲⩽⪅≶⋚⪋</span></span><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mrel">⊥</span></span><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mrel amsrm">⊨</span></span></span></span> <code>≔ ≕ ⩴</code></p>
<h3 id="_10-1-negated-relations" tabindex="-1">10.1: Negated Relations <a class="header-anchor" href="#_10-1-negated-relations" aria-label="Permalink to &quot;10.1: Negated Relations&quot;">&ZeroWidthSpace;</a></h3>
<p><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≠</mo></mrow><annotation encoding="application/x-tex">\not =</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel"><span class="mord vbox"><span class="thinbox"><span class="rlap"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="inner"><span class="mord"><span class="mrel"></span></span></span><span class="fix"></span></span></span></span></span></span><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">=</span></span></span></span> <code>\not =</code></p>
<table>
<thead>
<tr>
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⪊</mo></mrow><annotation encoding="application/x-tex">\gnapprox</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0189em;vertical-align:-0.2617em;"></span><span class="mrel amsrm">⪊</span></span></span></span> <code>\gnapprox</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≱</mo></mrow><annotation encoding="application/x-tex">\ngeqslant</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0966em;vertical-align:-0.3027em;"></span><span class="mrel amsrm"></span></span></span></span> <code>\ngeqslant</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊈</mo></mrow><annotation encoding="application/x-tex">\nsubseteq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0966em;vertical-align:-0.3027em;"></span><span class="mrel amsrm">⊈</span></span></span></span> <code>\nsubseteq</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⪵</mo></mrow><annotation encoding="application/x-tex">\precneqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0087em;vertical-align:-0.2514em;"></span><span class="mrel amsrm">⪵</span></span></span></span> <code>\precneqq</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⪈</mo></mrow><annotation encoding="application/x-tex">\gneq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mrel amsrm">⪈</span></span></span></span> <code>\gneq</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≯</mo></mrow><annotation encoding="application/x-tex">\ngtr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9115em;vertical-align:-0.2058em;"></span><span class="mrel amsrm">≯</span></span></span></span> <code>\ngtr</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊈</mo></mrow><annotation encoding="application/x-tex">\nsubseteqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0087em;vertical-align:-0.2514em;"></span><span class="mrel amsrm"></span></span></span></span> <code>\nsubseteqq</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋨</mo></mrow><annotation encoding="application/x-tex">\precnsim</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9733em;vertical-align:-0.2322em;"></span><span class="mrel amsrm">⋨</span></span></span></span> <code>\precnsim</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≩</mo></mrow><annotation encoding="application/x-tex">\gneqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0087em;vertical-align:-0.2514em;"></span><span class="mrel amsrm">≩</span></span></span></span> <code>\gneqq</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≰</mo></mrow><annotation encoding="application/x-tex">\nleq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0966em;vertical-align:-0.3027em;"></span><span class="mrel amsrm">≰</span></span></span></span> <code>\nleq</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊁</mo></mrow><annotation encoding="application/x-tex">\nsucc</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9115em;vertical-align:-0.2058em;"></span><span class="mrel amsrm">⊁</span></span></span></span> <code>\nsucc</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊊</mo></mrow><annotation encoding="application/x-tex">\subsetneq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mrel amsrm">⊊</span></span></span></span> <code>\subsetneq</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋧</mo></mrow><annotation encoding="application/x-tex">\gnsim</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9733em;vertical-align:-0.2322em;"></span><span class="mrel amsrm">⋧</span></span></span></span> <code>\gnsim</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≰</mo></mrow><annotation encoding="application/x-tex">\nleqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.339em;vertical-align:-0.4195em;"></span><span class="mrel amsrm"></span></span></span></span> <code>\nleqq</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋡</mo></mrow><annotation encoding="application/x-tex">\nsucceq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0966em;vertical-align:-0.3027em;"></span><span class="mrel amsrm">⋡</span></span></span></span> <code>\nsucceq</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⫋</mo></mrow><annotation encoding="application/x-tex">\subsetneqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0786em;vertical-align:-0.2848em;"></span><span class="mrel amsrm">⫋</span></span></span></span> <code>\subsetneqq</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≩</mo></mrow><annotation encoding="application/x-tex">\gvertneqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0087em;vertical-align:-0.2514em;"></span><span class="mrel amsrm"></span></span></span></span> <code>\gvertneqq</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≰</mo></mrow><annotation encoding="application/x-tex">\nleqslant</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0966em;vertical-align:-0.3027em;"></span><span class="mrel amsrm"></span></span></span></span> <code>\nleqslant</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊉</mo></mrow><annotation encoding="application/x-tex">\nsupseteq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0966em;vertical-align:-0.3027em;"></span><span class="mrel amsrm">⊉</span></span></span></span> <code>\nsupseteq</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⪺</mo></mrow><annotation encoding="application/x-tex">\succnapprox</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0189em;vertical-align:-0.2617em;"></span><span class="mrel amsrm">⪺</span></span></span></span> <code>\succnapprox</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⪉</mo></mrow><annotation encoding="application/x-tex">\lnapprox</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0189em;vertical-align:-0.2617em;"></span><span class="mrel amsrm">⪉</span></span></span></span> <code>\lnapprox</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≮</mo></mrow><annotation encoding="application/x-tex">\nless</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9115em;vertical-align:-0.2058em;"></span><span class="mrel amsrm">≮</span></span></span></span> <code>\nless</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊉</mo></mrow><annotation encoding="application/x-tex">\nsupseteqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0087em;vertical-align:-0.2514em;"></span><span class="mrel amsrm"></span></span></span></span> <code>\nsupseteqq</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⪶</mo></mrow><annotation encoding="application/x-tex">\succneqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0087em;vertical-align:-0.2514em;"></span><span class="mrel amsrm">⪶</span></span></span></span> <code>\succneqq</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⪇</mo></mrow><annotation encoding="application/x-tex">\lneq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mrel amsrm">⪇</span></span></span></span> <code>\lneq</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∤</mo></mrow><annotation encoding="application/x-tex">\nmid</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9925em;vertical-align:-0.2514em;"></span><span class="mrel amsrm">∤</span></span></span></span> <code>\nmid</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋪</mo></mrow><annotation encoding="application/x-tex">\ntriangleleft</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9115em;vertical-align:-0.2058em;"></span><span class="mrel amsrm">⋪</span></span></span></span> <code>\ntriangleleft</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋩</mo></mrow><annotation encoding="application/x-tex">\succnsim</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9733em;vertical-align:-0.2322em;"></span><span class="mrel amsrm">⋩</span></span></span></span> <code>\succnsim</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≨</mo></mrow><annotation encoding="application/x-tex">\lneqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0087em;vertical-align:-0.2514em;"></span><span class="mrel amsrm">≨</span></span></span></span> <code>\lneqq</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo mathvariant="normal">∉</mo></mrow><annotation encoding="application/x-tex">\notin</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mrel"><span class="mord"><span class="mrel">∈</span></span><span class="mord vbox"><span class="thinbox"><span class="llap"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="inner"><span class="mord"><span class="mord">/</span><span class="mspace" style="margin-right:0.0556em;"></span></span></span><span class="fix"></span></span></span></span></span></span></span></span> <code>\notin</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋬</mo></mrow><annotation encoding="application/x-tex">\ntrianglelefteq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0966em;vertical-align:-0.3027em;"></span><span class="mrel amsrm">⋬</span></span></span></span> <code>\ntrianglelefteq</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊋</mo></mrow><annotation encoding="application/x-tex">\supsetneq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mrel amsrm">⊋</span></span></span></span> <code>\supsetneq</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋦</mo></mrow><annotation encoding="application/x-tex">\lnsim</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9733em;vertical-align:-0.2322em;"></span><span class="mrel amsrm">⋦</span></span></span></span> <code>\lnsim</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo mathvariant="normal">∌</mo></mrow><annotation encoding="application/x-tex">\notni</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel"><span class="mord vbox"><span class="thinbox"><span class="rlap"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="inner"><span class="mord"><span class="mrel"></span></span></span><span class="fix"></span></span></span></span></span></span><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">∋</span></span></span></span> <code>\notni</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋫</mo></mrow><annotation encoding="application/x-tex">\ntriangleright</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9115em;vertical-align:-0.2058em;"></span><span class="mrel amsrm">⋫</span></span></span></span> <code>\ntriangleright</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⫌</mo></mrow><annotation encoding="application/x-tex">\supsetneqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0786em;vertical-align:-0.2848em;"></span><span class="mrel amsrm">⫌</span></span></span></span> <code>\supsetneqq</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≨</mo></mrow><annotation encoding="application/x-tex">\lvertneqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0087em;vertical-align:-0.2514em;"></span><span class="mrel amsrm"></span></span></span></span> <code>\lvertneqq</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∦</mo></mrow><annotation encoding="application/x-tex">\nparallel</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9925em;vertical-align:-0.2514em;"></span><span class="mrel amsrm">∦</span></span></span></span> <code>\nparallel</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋭</mo></mrow><annotation encoding="application/x-tex">\ntrianglerighteq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0966em;vertical-align:-0.3027em;"></span><span class="mrel amsrm">⋭</span></span></span></span> <code>\ntrianglerighteq</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊊</mo></mrow><annotation encoding="application/x-tex">\varsubsetneq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mrel amsrm"></span></span></span></span> <code>\varsubsetneq</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≆</mo></mrow><annotation encoding="application/x-tex">\ncong</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0966em;vertical-align:-0.3027em;"></span><span class="mrel amsrm">≆</span></span></span></span> <code>\ncong</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊀</mo></mrow><annotation encoding="application/x-tex">\nprec</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9115em;vertical-align:-0.2058em;"></span><span class="mrel amsrm">⊀</span></span></span></span> <code>\nprec</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊬</mo></mrow><annotation encoding="application/x-tex">\nvdash</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mrel amsrm">⊬</span></span></span></span> <code>\nvdash</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⫋</mo></mrow><annotation encoding="application/x-tex">\varsubsetneqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0087em;vertical-align:-0.2514em;"></span><span class="mrel amsrm"></span></span></span></span> <code>\varsubsetneqq</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo mathvariant="normal">≠</mo></mrow><annotation encoding="application/x-tex">\ne</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel"><span class="mrel"><span class="mord vbox"><span class="thinbox"><span class="rlap"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="inner"><span class="mord"><span class="mrel"></span></span></span><span class="fix"></span></span></span></span></span><span class="mrel">=</span></span></span></span></span> <code>\ne</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋠</mo></mrow><annotation encoding="application/x-tex">\npreceq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0966em;vertical-align:-0.3027em;"></span><span class="mrel amsrm">⋠</span></span></span></span> <code>\npreceq</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊭</mo></mrow><annotation encoding="application/x-tex">\nvDash</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mrel amsrm">⊭</span></span></span></span> <code>\nvDash</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊋</mo></mrow><annotation encoding="application/x-tex">\varsupsetneq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mrel amsrm"></span></span></span></span> <code>\varsupsetneq</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo mathvariant="normal">≠</mo></mrow><annotation encoding="application/x-tex">\neq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel"><span class="mrel"><span class="mord vbox"><span class="thinbox"><span class="rlap"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="inner"><span class="mord"><span class="mrel"></span></span></span><span class="fix"></span></span></span></span></span><span class="mrel">=</span></span></span></span></span> <code>\neq</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∤</mo></mrow><annotation encoding="application/x-tex">\nshortmid</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6633em;vertical-align:-0.0817em;"></span><span class="mrel amsrm"></span></span></span></span> <code>\nshortmid</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊯</mo></mrow><annotation encoding="application/x-tex">\nVDash</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mrel amsrm">⊯</span></span></span></span> <code>\nVDash</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⫌</mo></mrow><annotation encoding="application/x-tex">\varsupsetneqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0087em;vertical-align:-0.2514em;"></span><span class="mrel amsrm"></span></span></span></span> <code>\varsupsetneqq</code></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≱</mo></mrow><annotation encoding="application/x-tex">\ngeq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0966em;vertical-align:-0.3027em;"></span><span class="mrel amsrm">≱</span></span></span></span> <code>\ngeq</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∦</mo></mrow><annotation encoding="application/x-tex">\nshortparallel</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6633em;vertical-align:-0.0817em;"></span><span class="mrel amsrm"></span></span></span></span> <code>\nshortparallel</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊮</mo></mrow><annotation encoding="application/x-tex">\nVdash</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mrel amsrm">⊮</span></span></span></span> <code>\nVdash</code></td>
<td></td>
</tr>
<tr>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≱</mo></mrow><annotation encoding="application/x-tex">\ngeqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.339em;vertical-align:-0.4195em;"></span><span class="mrel amsrm"></span></span></span></span> <code>\ngeqq</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≁</mo></mrow><annotation encoding="application/x-tex">\nsim</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel amsrm">≁</span></span></span></span> <code>\nsim</code></td>
<td><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⪹</mo></mrow><annotation encoding="application/x-tex">\precnapprox</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0189em;vertical-align:-0.2617em;"></span><span class="mrel amsrm">⪹</span></span></span></span> <code>\precnapprox</code></td>
<td></td>
</tr>
</tbody>
</table>
<p>Direct Input:</p>
<p class='katex-block'><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mo mathvariant="normal">∉</mo><mo mathvariant="normal">∌</mo><mo>∤</mo><mo>∦</mo><mo>≁</mo><mo>≆</mo><mo mathvariant="normal">≠</mo><mo>≨</mo><mo>≩</mo><mo>≮</mo><mo>≯</mo><mo>≰</mo><mo>≱</mo><mo>⊀</mo><mo>⊁</mo><mo>⊈</mo><mo>⊉</mo><mo>⊊</mo><mo>⊋</mo><mo>⊬</mo><mo>⊭</mo><mo>⊮</mo><mo>⊯</mo><mo>⋠</mo><mo>⋡</mo><mo>⋦</mo><mo>⋧</mo><mo>⋨</mo><mo>⋩</mo><mo>⋬</mo><mo>⋭</mo><mo>⪇</mo><mo>⪈</mo><mo>⪉</mo><mo>⪊</mo><mo>⪵</mo><mo>⪶</mo><mo>⪹</mo><mo>⪺</mo><mo>⫋</mo><mo>⫌</mo></mrow><annotation encoding="application/x-tex">∉ ∌ ∤ ∦ ≁ ≆ ≠ ≨ ≩ ≮ ≯ ≰ ≱ ⊀ ⊁ ⊈ ⊉ ⊊ ⊋ ⊬ ⊭ ⊮ ⊯ ⋠ ⋡ ⋦ ⋧ ⋨ ⋩ ⋬ ⋭ ⪇ ⪈ ⪉ ⪊ ⪵ ⪶ ⪹ ⪺ ⫋ ⫌
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mrel"><span class="mord"><span class="mrel">∈</span></span><span class="mord vbox"><span class="thinbox"><span class="llap"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="inner"><span class="mord"><span class="mord">/</span><span class="mspace" style="margin-right:0.0556em;"></span></span></span><span class="fix"></span></span></span></span></span></span><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel"><span class="mord vbox"><span class="thinbox"><span class="rlap"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="inner"><span class="mord"><span class="mrel"></span></span></span><span class="fix"></span></span></span></span></span></span><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">∋</span></span><span class="base"><span class="strut" style="height:1.0966em;vertical-align:-0.3027em;"></span><span class="mrel amsrm">∤∦≁≆</span></span><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel"><span class="mrel"><span class="mord vbox"><span class="thinbox"><span class="rlap"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="inner"><span class="mord"><span class="mrel"></span></span></span><span class="fix"></span></span></span></span></span><span class="mrel">=</span></span></span><span class="base"><span class="strut" style="height:1.0966em;vertical-align:-0.3027em;"></span><span class="mrel amsrm">≨≩≮≯≰≱⊀⊁⊈⊉⊊⊋⊬⊭⊮⊯⋠⋡⋦⋧⋨⋩⋬⋭⪇⪈⪉⪊⪵⪶⪹⪺⫋⫌</span></span></span></span></span></p>
<h3 id="_10-2-arrows" tabindex="-1">10.2: Arrows <a class="header-anchor" href="#_10-2-arrows" aria-label="Permalink to &quot;10.2: Arrows&quot;">&ZeroWidthSpace;</a></h3>
<table>
<thead>
<tr>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↺</mo></mrow><annotation encoding="application/x-tex">\circlearrowleft</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.664em;vertical-align:-0.082em;"></span><span class="mrel amsrm">↺</span></span></span></span> <code>\circlearrowleft</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↼</mo></mrow><annotation encoding="application/x-tex">\leftharpoonup</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">↼</span></span></span></span> <code>\leftharpoonup</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇒</mo></mrow><annotation encoding="application/x-tex">\rArr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">⇒</span></span></span></span> <code>\rArr</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↻</mo></mrow><annotation encoding="application/x-tex">\circlearrowright</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.664em;vertical-align:-0.082em;"></span><span class="mrel amsrm">↻</span></span></span></span> <code>\circlearrowright</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇇</mo></mrow><annotation encoding="application/x-tex">\leftleftarrows</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8558em;vertical-align:-0.1808em;"></span><span class="mrel amsrm">⇇</span></span></span></span> <code>\leftleftarrows</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>→</mo></mrow><annotation encoding="application/x-tex">\rarr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">→</span></span></span></span> <code>\rarr</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↶</mo></mrow><annotation encoding="application/x-tex">\curvearrowleft</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mrel amsrm">↶</span></span></span></span> <code>\curvearrowleft</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↔</mo></mrow><annotation encoding="application/x-tex">\leftrightarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">↔</span></span></span></span> <code>\leftrightarrow</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↾</mo></mrow><annotation encoding="application/x-tex">\restriction</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8867em;vertical-align:-0.1944em;"></span><span class="mrel amsrm">↾</span></span></span></span> <code>\restriction</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↷</mo></mrow><annotation encoding="application/x-tex">\curvearrowright</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mrel amsrm">↷</span></span></span></span> <code>\curvearrowright</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇔</mo></mrow><annotation encoding="application/x-tex">\Leftrightarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">⇔</span></span></span></span> <code>\Leftrightarrow</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>→</mo></mrow><annotation encoding="application/x-tex">\rightarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">→</span></span></span></span> <code>\rightarrow</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇓</mo></mrow><annotation encoding="application/x-tex">\Darr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel">⇓</span></span></span></span> <code>\Darr</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇆</mo></mrow><annotation encoding="application/x-tex">\leftrightarrows</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8558em;vertical-align:-0.1808em;"></span><span class="mrel amsrm">⇆</span></span></span></span> <code>\leftrightarrows</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇒</mo></mrow><annotation encoding="application/x-tex">\Rightarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">⇒</span></span></span></span> <code>\Rightarrow</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇓</mo></mrow><annotation encoding="application/x-tex">\dArr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel">⇓</span></span></span></span> <code>\dArr</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇋</mo></mrow><annotation encoding="application/x-tex">\leftrightharpoons</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5359em;vertical-align:-0.0135em;"></span><span class="mrel amsrm">⇋</span></span></span></span> <code>\leftrightharpoons</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↣</mo></mrow><annotation encoding="application/x-tex">\rightarrowtail</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5359em;vertical-align:-0.0135em;"></span><span class="mrel amsrm">↣</span></span></span></span> <code>\rightarrowtail</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↓</mo></mrow><annotation encoding="application/x-tex">\darr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel">↓</span></span></span></span> <code>\darr</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↭</mo></mrow><annotation encoding="application/x-tex">\leftrightsquigarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3779em;"></span><span class="mrel amsrm">↭</span></span></span></span> <code>\leftrightsquigarrow</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇁</mo></mrow><annotation encoding="application/x-tex">\rightharpoondown</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">⇁</span></span></span></span> <code>\rightharpoondown</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇠</mo></mrow><annotation encoding="application/x-tex">\dashleftarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.437em;"></span><span class="mrel amsrm">⇠</span></span></span></span> <code>\dashleftarrow</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇚</mo></mrow><annotation encoding="application/x-tex">\Lleftarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7733em;vertical-align:-0.1367em;"></span><span class="mrel amsrm">⇚</span></span></span></span> <code>\Lleftarrow</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇀</mo></mrow><annotation encoding="application/x-tex">\rightharpoonup</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">⇀</span></span></span></span> <code>\rightharpoonup</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇢</mo></mrow><annotation encoding="application/x-tex">\dashrightarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.437em;"></span><span class="mrel amsrm">⇢</span></span></span></span> <code>\dashrightarrow</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⟵</mo></mrow><annotation encoding="application/x-tex">\longleftarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.522em;vertical-align:-0.011em;"></span><span class="mrel">⟵</span></span></span></span> <code>\longleftarrow</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇄</mo></mrow><annotation encoding="application/x-tex">\rightleftarrows</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8558em;vertical-align:-0.1808em;"></span><span class="mrel amsrm">⇄</span></span></span></span> <code>\rightleftarrows</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↓</mo></mrow><annotation encoding="application/x-tex">\downarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel">↓</span></span></span></span> <code>\downarrow</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⟸</mo></mrow><annotation encoding="application/x-tex">\Longleftarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.549em;vertical-align:-0.024em;"></span><span class="mrel">⟸</span></span></span></span> <code>\Longleftarrow</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇌</mo></mrow><annotation encoding="application/x-tex">\rightleftharpoons</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.682em;vertical-align:-0.011em;"></span><span class="mrel">⇌</span></span></span></span> <code>\rightleftharpoons</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇓</mo></mrow><annotation encoding="application/x-tex">\Downarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel">⇓</span></span></span></span> <code>\Downarrow</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⟷</mo></mrow><annotation encoding="application/x-tex">\longleftrightarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.522em;vertical-align:-0.011em;"></span><span class="mrel">⟷</span></span></span></span> <code>\longleftrightarrow</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇉</mo></mrow><annotation encoding="application/x-tex">\rightrightarrows</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8558em;vertical-align:-0.1808em;"></span><span class="mrel amsrm">⇉</span></span></span></span> <code>\rightrightarrows</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇊</mo></mrow><annotation encoding="application/x-tex">\downdownarrows</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8867em;vertical-align:-0.1944em;"></span><span class="mrel amsrm">⇊</span></span></span></span> <code>\downdownarrows</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⟺</mo></mrow><annotation encoding="application/x-tex">\Longleftrightarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.549em;vertical-align:-0.024em;"></span><span class="mrel">⟺</span></span></span></span> <code>\Longleftrightarrow</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇝</mo></mrow><annotation encoding="application/x-tex">\rightsquigarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3779em;"></span><span class="mrel amsrm">⇝</span></span></span></span> <code>\rightsquigarrow</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇃</mo></mrow><annotation encoding="application/x-tex">\downharpoonleft</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8867em;vertical-align:-0.1944em;"></span><span class="mrel amsrm">⇃</span></span></span></span> <code>\downharpoonleft</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⟼</mo></mrow><annotation encoding="application/x-tex">\longmapsto</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.522em;vertical-align:-0.011em;"></span><span class="mrel">⟼</span></span></span></span> <code>\longmapsto</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇛</mo></mrow><annotation encoding="application/x-tex">\Rrightarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7733em;vertical-align:-0.1367em;"></span><span class="mrel amsrm">⇛</span></span></span></span> <code>\Rrightarrow</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇂</mo></mrow><annotation encoding="application/x-tex">\downharpoonright</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8867em;vertical-align:-0.1944em;"></span><span class="mrel amsrm">⇂</span></span></span></span> <code>\downharpoonright</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⟶</mo></mrow><annotation encoding="application/x-tex">\longrightarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.522em;vertical-align:-0.011em;"></span><span class="mrel">⟶</span></span></span></span> <code>\longrightarrow</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↱</mo></mrow><annotation encoding="application/x-tex">\Rsh</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mrel amsrm">↱</span></span></span></span> <code>\Rsh</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>←</mo></mrow><annotation encoding="application/x-tex">\gets</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">←</span></span></span></span> <code>\gets</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⟹</mo></mrow><annotation encoding="application/x-tex">\Longrightarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.549em;vertical-align:-0.024em;"></span><span class="mrel">⟹</span></span></span></span> <code>\Longrightarrow</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↘</mo></mrow><annotation encoding="application/x-tex">\searrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel">↘</span></span></span></span> <code>\searrow</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇔</mo></mrow><annotation encoding="application/x-tex">\Harr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">⇔</span></span></span></span> <code>\Harr</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↫</mo></mrow><annotation encoding="application/x-tex">\looparrowleft</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5499em;"></span><span class="mrel amsrm">↫</span></span></span></span> <code>\looparrowleft</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↙</mo></mrow><annotation encoding="application/x-tex">\swarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel">↙</span></span></span></span> <code>\swarrow</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇔</mo></mrow><annotation encoding="application/x-tex">\hArr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">⇔</span></span></span></span> <code>\hArr</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↬</mo></mrow><annotation encoding="application/x-tex">\looparrowright</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5499em;"></span><span class="mrel amsrm">↬</span></span></span></span> <code>\looparrowright</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>→</mo></mrow><annotation encoding="application/x-tex">\to</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">→</span></span></span></span> <code>\to</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↔</mo></mrow><annotation encoding="application/x-tex">\harr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">↔</span></span></span></span> <code>\harr</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇔</mo></mrow><annotation encoding="application/x-tex">\Lrarr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">⇔</span></span></span></span> <code>\Lrarr</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↞</mo></mrow><annotation encoding="application/x-tex">\twoheadleftarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5359em;vertical-align:-0.0135em;"></span><span class="mrel amsrm">↞</span></span></span></span> <code>\twoheadleftarrow</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↩</mo></mrow><annotation encoding="application/x-tex">\hookleftarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.522em;vertical-align:-0.011em;"></span><span class="mrel">↩</span></span></span></span> <code>\hookleftarrow</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇔</mo></mrow><annotation encoding="application/x-tex">\lrArr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">⇔</span></span></span></span> <code>\lrArr</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↠</mo></mrow><annotation encoding="application/x-tex">\twoheadrightarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5359em;vertical-align:-0.0135em;"></span><span class="mrel amsrm">↠</span></span></span></span> <code>\twoheadrightarrow</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↪</mo></mrow><annotation encoding="application/x-tex">\hookrightarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.522em;vertical-align:-0.011em;"></span><span class="mrel">↪</span></span></span></span> <code>\hookrightarrow</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↔</mo></mrow><annotation encoding="application/x-tex">\lrarr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">↔</span></span></span></span> <code>\lrarr</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇑</mo></mrow><annotation encoding="application/x-tex">\Uarr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel">⇑</span></span></span></span> <code>\Uarr</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>  </mtext><mo>⟺</mo><mtext>  </mtext></mrow><annotation encoding="application/x-tex">\iff</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.549em;vertical-align:-0.024em;"></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">⟺</span><span class="mspace" style="margin-right:0.2778em;"></span></span></span></span> <code>\iff</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↰</mo></mrow><annotation encoding="application/x-tex">\Lsh</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mrel amsrm">↰</span></span></span></span> <code>\Lsh</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇑</mo></mrow><annotation encoding="application/x-tex">\uArr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel">⇑</span></span></span></span> <code>\uArr</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>  </mtext><mo>⟸</mo><mtext>  </mtext></mrow><annotation encoding="application/x-tex">\impliedby</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.549em;vertical-align:-0.024em;"></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">⟸</span><span class="mspace" style="margin-right:0.2778em;"></span></span></span></span> <code>\impliedby</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↦</mo></mrow><annotation encoding="application/x-tex">\mapsto</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.522em;vertical-align:-0.011em;"></span><span class="mrel">↦</span></span></span></span> <code>\mapsto</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↑</mo></mrow><annotation encoding="application/x-tex">\uarr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel">↑</span></span></span></span> <code>\uarr</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>  </mtext><mo>⟹</mo><mtext>  </mtext></mrow><annotation encoding="application/x-tex">\implies</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.549em;vertical-align:-0.024em;"></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">⟹</span><span class="mspace" style="margin-right:0.2778em;"></span></span></span></span> <code>\implies</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↗</mo></mrow><annotation encoding="application/x-tex">\nearrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel">↗</span></span></span></span> <code>\nearrow</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↑</mo></mrow><annotation encoding="application/x-tex">\uparrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel">↑</span></span></span></span> <code>\uparrow</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇐</mo></mrow><annotation encoding="application/x-tex">\Larr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">⇐</span></span></span></span> <code>\Larr</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↚</mo></mrow><annotation encoding="application/x-tex">\nleftarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel amsrm">↚</span></span></span></span> <code>\nleftarrow</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇑</mo></mrow><annotation encoding="application/x-tex">\Uparrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel">⇑</span></span></span></span> <code>\Uparrow</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇐</mo></mrow><annotation encoding="application/x-tex">\lArr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">⇐</span></span></span></span> <code>\lArr</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇍</mo></mrow><annotation encoding="application/x-tex">\nLeftarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel amsrm">⇍</span></span></span></span> <code>\nLeftarrow</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↕</mo></mrow><annotation encoding="application/x-tex">\updownarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mrel">↕</span></span></span></span> <code>\updownarrow</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>←</mo></mrow><annotation encoding="application/x-tex">\larr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">←</span></span></span></span> <code>\larr</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↮</mo></mrow><annotation encoding="application/x-tex">\nleftrightarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel amsrm">↮</span></span></span></span> <code>\nleftrightarrow</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇕</mo></mrow><annotation encoding="application/x-tex">\Updownarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mrel">⇕</span></span></span></span> <code>\Updownarrow</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇝</mo></mrow><annotation encoding="application/x-tex">\leadsto</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3779em;"></span><span class="mrel amsrm">⇝</span></span></span></span> <code>\leadsto</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇎</mo></mrow><annotation encoding="application/x-tex">\nLeftrightarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel amsrm">⇎</span></span></span></span> <code>\nLeftrightarrow</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↿</mo></mrow><annotation encoding="application/x-tex">\upharpoonleft</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8867em;vertical-align:-0.1944em;"></span><span class="mrel amsrm">↿</span></span></span></span> <code>\upharpoonleft</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>←</mo></mrow><annotation encoding="application/x-tex">\leftarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">←</span></span></span></span> <code>\leftarrow</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↛</mo></mrow><annotation encoding="application/x-tex">\nrightarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel amsrm">↛</span></span></span></span> <code>\nrightarrow</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↾</mo></mrow><annotation encoding="application/x-tex">\upharpoonright</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8867em;vertical-align:-0.1944em;"></span><span class="mrel amsrm">↾</span></span></span></span> <code>\upharpoonright</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇐</mo></mrow><annotation encoding="application/x-tex">\Leftarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">⇐</span></span></span></span> <code>\Leftarrow</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇏</mo></mrow><annotation encoding="application/x-tex">\nRightarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel amsrm">⇏</span></span></span></span> <code>\nRightarrow</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇈</mo></mrow><annotation encoding="application/x-tex">\upuparrows</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8867em;vertical-align:-0.1944em;"></span><span class="mrel amsrm">⇈</span></span></span></span> <code>\upuparrows</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↢</mo></mrow><annotation encoding="application/x-tex">\leftarrowtail</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5359em;vertical-align:-0.0135em;"></span><span class="mrel amsrm">↢</span></span></span></span> <code>\leftarrowtail</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↖</mo></mrow><annotation encoding="application/x-tex">\nwarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel">↖</span></span></span></span> <code>\nwarrow</code></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↽</mo></mrow><annotation encoding="application/x-tex">\leftharpoondown</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">↽</span></span></span></span> <code>\leftharpoondown</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇒</mo></mrow><annotation encoding="application/x-tex">\Rarr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">⇒</span></span></span></span> <code>\Rarr</code></td>
<td style="text-align:left"></td>
</tr>
</tbody>
</table>
<p>Direct Input: <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>←</mo><mo>↑</mo><mo>→</mo><mo>↓</mo><mo>↔</mo><mo>↕</mo><mo>↖</mo><mo>↗</mo><mo>↘</mo><mo>↙</mo><mo>↚</mo><mo>↛</mo><mo>↞</mo><mo>↠</mo><mo>↢</mo><mo>↣</mo><mo>↦</mo><mo>↩</mo><mo>↪</mo><mo>↫</mo><mo>↬</mo><mo>↭</mo><mo>↮</mo><mo>↰</mo><mo>↱</mo><mo>↶</mo><mo>↷</mo><mo>↺</mo><mo>↻</mo><mo>↼</mo><mo>↽</mo><mo>↾</mo><mo>↾</mo><mo>↿</mo><mo>⇀</mo><mo>⇁</mo><mo>⇂</mo><mo>⇃</mo><mo>⇄</mo><mo>⇆</mo><mo>⇇</mo><mo>⇈</mo><mo>⇉</mo><mo>⇊</mo><mo>⇋</mo><mo>⇌</mo><mo>⇍</mo><mo>⇎</mo><mo>⇏</mo><mo>⇐</mo><mo>⇑</mo><mo>⇒</mo><mo>⇓</mo><mo>⇔</mo><mo>⇕</mo><mo>⇚</mo><mo>⇛</mo><mo>⇝</mo><mo>⇠</mo><mo>⇢</mo><mo>⟵</mo><mo>⟶</mo><mo>⟷</mo><mo>⟸</mo><mo>⟹</mo><mo>⟺</mo><mo>⟼</mo></mrow><annotation encoding="application/x-tex">← ↑ → ↓ ↔ ↕ ↖ ↗ ↘ ↙ ↚ ↛ ↞ ↠ ↢ ↣ ↦ ↩ ↪ ↫ ↬ ↭ ↮ ↰ ↱↶ ↷ ↺ ↻ ↼ ↽ ↾ ↾ ↿ ⇀ ⇁ ⇂ ⇃ ⇄ ⇆ ⇇ ⇈ ⇉ ⇊ ⇋ ⇌⇍ ⇎ ⇏ ⇐ ⇑ ⇒ ⇓ ⇔ ⇕ ⇚ ⇛ ⇝ ⇠ ⇢ ⟵ ⟶ ⟷ ⟸ ⟹ ⟺ ⟼</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mrel">←↑→↓↔↕↖↗↘↙</span></span><span class="base"><span class="strut" style="height:0.5359em;vertical-align:-0.0135em;"></span><span class="mrel amsrm">↚↛↞↠↢↣</span></span><span class="base"><span class="strut" style="height:0.522em;vertical-align:-0.011em;"></span><span class="mrel">↦↩↪</span></span><span class="base"><span class="strut" style="height:0.7742em;vertical-align:-0.082em;"></span><span class="mrel amsrm">↫↬↭↮↰↱↶↷↺↻</span></span><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">↼↽</span></span><span class="base"><span class="strut" style="height:0.8867em;vertical-align:-0.1944em;"></span><span class="mrel amsrm">↾↾↿</span></span><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">⇀⇁</span></span><span class="base"><span class="strut" style="height:0.8867em;vertical-align:-0.1944em;"></span><span class="mrel amsrm">⇂⇃⇄⇆⇇⇈⇉⇊⇋</span></span><span class="base"><span class="strut" style="height:0.682em;vertical-align:-0.011em;"></span><span class="mrel">⇌</span></span><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel amsrm">⇍⇎⇏</span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mrel">⇐⇑⇒⇓⇔⇕</span></span><span class="base"><span class="strut" style="height:0.7733em;vertical-align:-0.1367em;"></span><span class="mrel amsrm">⇚⇛⇝⇠⇢</span></span><span class="base"><span class="strut" style="height:0.549em;vertical-align:-0.024em;"></span><span class="mrel">⟵⟶⟷⟸⟹⟺⟼</span></span></span></span> ↽</p>
<p><strong>Extensible Arrows</strong></p>
<table>
<thead>
<tr>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mo stretchy="true" minsize="3.0em">←</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></mpadded></mover></mrow><annotation encoding="application/x-tex">\xleftarrow{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1191em;vertical-align:-0.011em;"></span><span class="mrel x-arrow"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1081em;"><span style="top:-3.322em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">ab</span><span class="mord mathnormal mtight">c</span></span></span></span><span class="svg-align" style="top:-2.689em;"><span class="pstrut" style="height:2.7em;"></span><span class="hide-tail" style="height:0.522em;min-width:1.469em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMinYMin slice'><path d='M400000 241H110l3-3c68.7-52.7 113.7-120
 135-202 4-14.7 6-23 6-25 0-7.3-7-11-21-11-8 0-13.2.8-15.5 2.5-2.3 1.7-4.2 5.8
-5.5 12.5-1.3 4.7-2.7 10.3-4 17-12 48.7-34.8 92-68.5 130S65.3 228.3 18 247
c-10 4-16 7.7-18 11 0 8.7 6 14.3 18 17 47.3 18.7 87.8 47 121.5 85S196 441.3 208
 490c.7 2 1.3 5 2 9s1.2 6.7 1.5 8c.3 1.3 1 3.3 2 6s2.2 4.5 3.5 5.5c1.3 1 3.3
 1.8 6 2.5s6 1 10 1c14 0 21-3.7 21-11 0-2-2-10.3-6-25-20-79.3-65-146.7-135-202
 l-3-3h399890zM100 241v40h399900v-40z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.011em;"><span></span></span></span></span></span></span></span></span> <code>\xleftarrow{abc}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><munderover><mo stretchy="true" minsize="3.0em">→</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>u</mi><mi>n</mi><mi>d</mi><mi>e</mi><mi>r</mi></mrow></mpadded><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>o</mi><mi>v</mi><mi>e</mi><mi>r</mi></mrow></mpadded></munderover></mrow><annotation encoding="application/x-tex">\xrightarrow[under]{over}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.5315em;vertical-align:-0.6081em;"></span><span class="mrel x-arrow"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.9234em;"><span style="top:-3.322em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">o</span><span class="mord mathnormal mtight" style="margin-right:0.03588em;">v</span><span class="mord mathnormal mtight" style="margin-right:0.02778em;">er</span></span></span></span><span class="svg-align" style="top:-2.689em;"><span class="pstrut" style="height:2.7em;"></span><span class="hide-tail" style="height:0.522em;min-width:1.469em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMaxYMin slice'><path d='M0 241v40h399891c-47.3 35.3-84 78-110 128
-16.7 32-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20
 11 8 0 13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7
 39-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85
-40.5-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5
-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67
 151.7 139 205zm0 0v40h399900v-40z'/></svg></span></span><span style="top:-2.0919em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">u</span><span class="mord mathnormal mtight">n</span><span class="mord mathnormal mtight">d</span><span class="mord mathnormal mtight" style="margin-right:0.02778em;">er</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.6081em;"><span></span></span></span></span></span></span></span></span> <code>\xrightarrow[under]{over}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mo stretchy="true" minsize="3.0em">⇐</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></mpadded></mover></mrow><annotation encoding="application/x-tex">\xLeftarrow{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1571em;vertical-align:-0.03em;"></span><span class="mrel x-arrow"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1271em;"><span style="top:-3.341em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">ab</span><span class="mord mathnormal mtight">c</span></span></span></span><span class="svg-align" style="top:-2.67em;"><span class="pstrut" style="height:2.7em;"></span><span class="hide-tail" style="height:0.56em;min-width:1.526em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.56em' viewBox='0 0 400000 560' preserveAspectRatio='xMinYMin slice'><path d='M262 157
l10-10c34-36 62.7-77 86-123 3.3-8 5-13.3 5-16 0-5.3-6.7-8-20-8-7.3
 0-12.2.5-14.5 1.5-2.3 1-4.8 4.5-7.5 10.5-49.3 97.3-121.7 169.3-217 216-28
 14-57.3 25-88 33-6.7 2-11 3.8-13 5.5-2 1.7-3 4.2-3 7.5s1 5.8 3 7.5
c2 1.7 6.3 3.5 13 5.5 68 17.3 128.2 47.8 180.5 91.5 52.3 43.7 93.8 96.2 124.5
 157.5 9.3 8 15.3 12.3 18 13h6c12-.7 18-4 18-10 0-2-1.7-7-5-15-23.3-46-52-87
-86-123l-10-10h399738v-40H218c328 0 0 0 0 0l-10-8c-26.7-20-65.7-43-117-69 2.7
-2 6-3.7 10-5 36.7-16 72.3-37.3 107-64l10-8h399782v-40z
m8 0v40h399730v-40zm0 194v40h399730v-40z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.03em;"><span></span></span></span></span></span></span></span></span> <code>\xLeftarrow{abc}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mo stretchy="true" minsize="3.0em">⇒</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></mpadded></mover></mrow><annotation encoding="application/x-tex">\xRightarrow{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1571em;vertical-align:-0.03em;"></span><span class="mrel x-arrow"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1271em;"><span style="top:-3.341em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">ab</span><span class="mord mathnormal mtight">c</span></span></span></span><span class="svg-align" style="top:-2.67em;"><span class="pstrut" style="height:2.7em;"></span><span class="hide-tail" style="height:0.56em;min-width:1.526em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.56em' viewBox='0 0 400000 560' preserveAspectRatio='xMaxYMin slice'><path d='M399738 392l
-10 10c-34 36-62.7 77-86 123-3.3 8-5 13.3-5 16 0 5.3 6.7 8 20 8 7.3 0 12.2-.5
 14.5-1.5 2.3-1 4.8-4.5 7.5-10.5 49.3-97.3 121.7-169.3 217-216 28-14 57.3-25 88
-33 6.7-2 11-3.8 13-5.5 2-1.7 3-4.2 3-7.5s-1-5.8-3-7.5c-2-1.7-6.3-3.5-13-5.5-68
-17.3-128.2-47.8-180.5-91.5-52.3-43.7-93.8-96.2-124.5-157.5-9.3-8-15.3-12.3-18
-13h-6c-12 .7-18 4-18 10 0 2 1.7 7 5 15 23.3 46 52 87 86 123l10 10H0v40h399782
c-328 0 0 0 0 0l10 8c26.7 20 65.7 43 117 69-2.7 2-6 3.7-10 5-36.7 16-72.3 37.3
-107 64l-10 8H0v40zM0 157v40h399730v-40zm0 194v40h399730v-40z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.03em;"><span></span></span></span></span></span></span></span></span> <code>\xRightarrow{abc}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mo stretchy="true" minsize="3.0em">↔</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></mpadded></mover></mrow><annotation encoding="application/x-tex">\xleftrightarrow{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1191em;vertical-align:-0.011em;"></span><span class="mrel x-arrow"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1081em;"><span style="top:-3.322em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">ab</span><span class="mord mathnormal mtight">c</span></span></span></span><span class="svg-align" style="top:-2.689em;"><span class="pstrut" style="height:2.7em;"></span><span class="stretchy" style="height:0.522em;min-width:1.75em;"><span class="halfarrow-left" style="height:0.522em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMinYMin slice'><path d='M400000 241H110l3-3c68.7-52.7 113.7-120
 135-202 4-14.7 6-23 6-25 0-7.3-7-11-21-11-8 0-13.2.8-15.5 2.5-2.3 1.7-4.2 5.8
-5.5 12.5-1.3 4.7-2.7 10.3-4 17-12 48.7-34.8 92-68.5 130S65.3 228.3 18 247
c-10 4-16 7.7-18 11 0 8.7 6 14.3 18 17 47.3 18.7 87.8 47 121.5 85S196 441.3 208
 490c.7 2 1.3 5 2 9s1.2 6.7 1.5 8c.3 1.3 1 3.3 2 6s2.2 4.5 3.5 5.5c1.3 1 3.3
 1.8 6 2.5s6 1 10 1c14 0 21-3.7 21-11 0-2-2-10.3-6-25-20-79.3-65-146.7-135-202
 l-3-3h399890zM100 241v40h399900v-40z'/></svg></span><span class="halfarrow-right" style="height:0.522em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMaxYMin slice'><path d='M0 241v40h399891c-47.3 35.3-84 78-110 128
-16.7 32-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20
 11 8 0 13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7
 39-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85
-40.5-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5
-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67
 151.7 139 205zm0 0v40h399900v-40z'/></svg></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.011em;"><span></span></span></span></span></span></span></span></span> <code>\xleftrightarrow{abc}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mo stretchy="true" minsize="3.0em">⇔</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></mpadded></mover></mrow><annotation encoding="application/x-tex">\xLeftrightarrow{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1571em;vertical-align:-0.03em;"></span><span class="mrel x-arrow"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1271em;"><span style="top:-3.341em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">ab</span><span class="mord mathnormal mtight">c</span></span></span></span><span class="svg-align" style="top:-2.67em;"><span class="pstrut" style="height:2.7em;"></span><span class="stretchy" style="height:0.56em;min-width:1.75em;"><span class="halfarrow-left" style="height:0.56em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.56em' viewBox='0 0 400000 560' preserveAspectRatio='xMinYMin slice'><path d='M262 157
l10-10c34-36 62.7-77 86-123 3.3-8 5-13.3 5-16 0-5.3-6.7-8-20-8-7.3
 0-12.2.5-14.5 1.5-2.3 1-4.8 4.5-7.5 10.5-49.3 97.3-121.7 169.3-217 216-28
 14-57.3 25-88 33-6.7 2-11 3.8-13 5.5-2 1.7-3 4.2-3 7.5s1 5.8 3 7.5
c2 1.7 6.3 3.5 13 5.5 68 17.3 128.2 47.8 180.5 91.5 52.3 43.7 93.8 96.2 124.5
 157.5 9.3 8 15.3 12.3 18 13h6c12-.7 18-4 18-10 0-2-1.7-7-5-15-23.3-46-52-87
-86-123l-10-10h399738v-40H218c328 0 0 0 0 0l-10-8c-26.7-20-65.7-43-117-69 2.7
-2 6-3.7 10-5 36.7-16 72.3-37.3 107-64l10-8h399782v-40z
m8 0v40h399730v-40zm0 194v40h399730v-40z'/></svg></span><span class="halfarrow-right" style="height:0.56em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.56em' viewBox='0 0 400000 560' preserveAspectRatio='xMaxYMin slice'><path d='M399738 392l
-10 10c-34 36-62.7 77-86 123-3.3 8-5 13.3-5 16 0 5.3 6.7 8 20 8 7.3 0 12.2-.5
 14.5-1.5 2.3-1 4.8-4.5 7.5-10.5 49.3-97.3 121.7-169.3 217-216 28-14 57.3-25 88
-33 6.7-2 11-3.8 13-5.5 2-1.7 3-4.2 3-7.5s-1-5.8-3-7.5c-2-1.7-6.3-3.5-13-5.5-68
-17.3-128.2-47.8-180.5-91.5-52.3-43.7-93.8-96.2-124.5-157.5-9.3-8-15.3-12.3-18
-13h-6c-12 .7-18 4-18 10 0 2 1.7 7 5 15 23.3 46 52 87 86 123l10 10H0v40h399782
c-328 0 0 0 0 0l10 8c26.7 20 65.7 43 117 69-2.7 2-6 3.7-10 5-36.7 16-72.3 37.3
-107 64l-10 8H0v40zM0 157v40h399730v-40zm0 194v40h399730v-40z'/></svg></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.03em;"><span></span></span></span></span></span></span></span></span> <code>\xLeftrightarrow{abc}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mo stretchy="true" minsize="3.0em">↩</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></mpadded></mover></mrow><annotation encoding="application/x-tex">\xhookleftarrow{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1191em;vertical-align:-0.011em;"></span><span class="mrel x-arrow"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1081em;"><span style="top:-3.322em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">ab</span><span class="mord mathnormal mtight">c</span></span></span></span><span class="svg-align" style="top:-2.689em;"><span class="pstrut" style="height:2.7em;"></span><span class="stretchy" style="height:0.522em;min-width:1.08em;"><span class="halfarrow-left" style="height:0.522em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMinYMin slice'><path d='M400000 241H110l3-3c68.7-52.7 113.7-120
 135-202 4-14.7 6-23 6-25 0-7.3-7-11-21-11-8 0-13.2.8-15.5 2.5-2.3 1.7-4.2 5.8
-5.5 12.5-1.3 4.7-2.7 10.3-4 17-12 48.7-34.8 92-68.5 130S65.3 228.3 18 247
c-10 4-16 7.7-18 11 0 8.7 6 14.3 18 17 47.3 18.7 87.8 47 121.5 85S196 441.3 208
 490c.7 2 1.3 5 2 9s1.2 6.7 1.5 8c.3 1.3 1 3.3 2 6s2.2 4.5 3.5 5.5c1.3 1 3.3
 1.8 6 2.5s6 1 10 1c14 0 21-3.7 21-11 0-2-2-10.3-6-25-20-79.3-65-146.7-135-202
 l-3-3h399890zM100 241v40h399900v-40z'/></svg></span><span class="halfarrow-right" style="height:0.522em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMaxYMin slice'><path d='M399859 241c-764 0 0 0 0 0 40-3.3 68.7-15.7 86-37 10-12 15-25.3
 15-40 0-22.7-9.8-40.7-29.5-54-19.7-13.3-43.5-21-71.5-23-17.3-1.3-26-8-26-20 0
-13.3 8.7-20 26-20 38 0 71 11.2 99 33.5 0 0 7 5.6 21 16.7 14 11.2 21 33.5 21
 66.8s-14 61.2-42 83.5c-28 22.3-61 33.5-99 33.5L0 241z M0 281v-40h399859v40z'/></svg></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.011em;"><span></span></span></span></span></span></span></span></span> <code>\xhookleftarrow{abc}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mo stretchy="true" minsize="3.0em">↪</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></mpadded></mover></mrow><annotation encoding="application/x-tex">\xhookrightarrow{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1191em;vertical-align:-0.011em;"></span><span class="mrel x-arrow"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1081em;"><span style="top:-3.322em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">ab</span><span class="mord mathnormal mtight">c</span></span></span></span><span class="svg-align" style="top:-2.689em;"><span class="pstrut" style="height:2.7em;"></span><span class="stretchy" style="height:0.522em;min-width:1.08em;"><span class="halfarrow-left" style="height:0.522em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMinYMin slice'><path d='M400000 281 H103s-33-11.2-61-33.5S0 197.3 0 164s14.2-61.2 42.5
-83.5C70.8 58.2 104 47 142 47 c16.7 0 25 6.7 25 20 0 12-8.7 18.7-26 20-40 3.3
-68.7 15.7-86 37-10 12-15 25.3-15 40 0 22.7 9.8 40.7 29.5 54 19.7 13.3 43.5 21
 71.5 23h399859zM103 281v-40h399897v40z'/></svg></span><span class="halfarrow-right" style="height:0.522em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMaxYMin slice'><path d='M0 241v40h399891c-47.3 35.3-84 78-110 128
-16.7 32-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20
 11 8 0 13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7
 39-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85
-40.5-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5
-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67
 151.7 139 205zm0 0v40h399900v-40z'/></svg></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.011em;"><span></span></span></span></span></span></span></span></span> <code>\xhookrightarrow{abc}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mo stretchy="true" minsize="3.0em">↞</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></mpadded></mover></mrow><annotation encoding="application/x-tex">\xtwoheadleftarrow{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0141em;"></span><span class="mrel x-arrow"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:1.0141em;"><span style="top:-3.228em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">ab</span><span class="mord mathnormal mtight">c</span></span></span></span><span class="svg-align" style="top:-2.783em;"><span class="pstrut" style="height:2.7em;"></span><span class="hide-tail" style="height:0.334em;min-width:0.888em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.334em' viewBox='0 0 400000 334' preserveAspectRatio='xMinYMin slice'><path d='M0 167c68 40
 115.7 95.7 143 167h22c15.3 0 23-.3 23-1 0-1.3-5.3-13.7-16-37-18-35.3-41.3-69
-70-101l-7-8h125l9 7c50.7 39.3 85 86 103 140h46c0-4.7-6.3-18.7-19-42-18-35.3
-40-67.3-66-96l-9-9h399716v-40H284l9-9c26-28.7 48-60.7 66-96 12.7-23.333 19
-37.333 19-42h-46c-18 54-52.3 100.7-103 140l-9 7H95l7-8c28.7-32 52-65.7 70-101
 10.7-23.333 16-35.7 16-37 0-.7-7.7-1-23-1h-22C115.7 71.3 68 127 0 167z'/></svg></span></span></span></span></span></span></span></span></span> <code>\xtwoheadleftarrow{abc}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mo stretchy="true" minsize="3.0em">↠</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></mpadded></mover></mrow><annotation encoding="application/x-tex">\xtwoheadrightarrow{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0141em;"></span><span class="mrel x-arrow"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:1.0141em;"><span style="top:-3.228em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">ab</span><span class="mord mathnormal mtight">c</span></span></span></span><span class="svg-align" style="top:-2.783em;"><span class="pstrut" style="height:2.7em;"></span><span class="hide-tail" style="height:0.334em;min-width:0.888em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.334em' viewBox='0 0 400000 334' preserveAspectRatio='xMaxYMin slice'><path d='M400000 167
c-68-40-115.7-95.7-143-167h-22c-15.3 0-23 .3-23 1 0 1.3 5.3 13.7 16 37 18 35.3
 41.3 69 70 101l7 8h-125l-9-7c-50.7-39.3-85-86-103-140h-46c0 4.7 6.3 18.7 19 42
 18 35.3 40 67.3 66 96l9 9H0v40h399716l-9 9c-26 28.7-48 60.7-66 96-12.7 23.333
-19 37.333-19 42h46c18-54 52.3-100.7 103-140l9-7h125l-7 8c-28.7 32-52 65.7-70
 101-10.7 23.333-16 35.7-16 37 0 .7 7.7 1 23 1h22c27.3-71.3 75-127 143-167z'/></svg></span></span></span></span></span></span></span></span></span> <code>\xtwoheadrightarrow{abc}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mo stretchy="true" minsize="3.0em">↼</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></mpadded></mover></mrow><annotation encoding="application/x-tex">\xleftharpoonup{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1191em;vertical-align:-0.011em;"></span><span class="mrel x-arrow"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1081em;"><span style="top:-3.322em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">ab</span><span class="mord mathnormal mtight">c</span></span></span></span><span class="svg-align" style="top:-2.689em;"><span class="pstrut" style="height:2.7em;"></span><span class="hide-tail" style="height:0.522em;min-width:0.888em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMinYMin slice'><path d='M0 267c.7 5.3 3 10 7 14h399993v-40H93c3.3
-3.3 10.2-9.5 20.5-18.5s17.8-15.8 22.5-20.5c50.7-52 88-110.3 112-175 4-11.3 5
-18.3 3-21-1.3-4-7.3-6-18-6-8 0-13 .7-15 2s-4.7 6.7-8 16c-42 98.7-107.3 174.7
-196 228-6.7 4.7-10.7 8-12 10-1.3 2-2 5.7-2 11zm100-26v40h399900v-40z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.011em;"><span></span></span></span></span></span></span></span></span> <code>\xleftharpoonup{abc}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mo stretchy="true" minsize="3.0em">⇀</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></mpadded></mover></mrow><annotation encoding="application/x-tex">\xrightharpoonup{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1191em;vertical-align:-0.011em;"></span><span class="mrel x-arrow"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1081em;"><span style="top:-3.322em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">ab</span><span class="mord mathnormal mtight">c</span></span></span></span><span class="svg-align" style="top:-2.689em;"><span class="pstrut" style="height:2.7em;"></span><span class="hide-tail" style="height:0.522em;min-width:0.888em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMaxYMin slice'><path d='M0 241v40h399993c4.7-4.7 7-9.3 7-14 0-9.3
-3.7-15.3-11-18-92.7-56.7-159-133.7-199-231-3.3-9.3-6-14.7-8-16-2-1.3-7-2-15-2
-10.7 0-16.7 2-18 6-2 2.7-1 9.7 3 21 15.3 42 36.7 81.8 64 119.5 27.3 37.7 58
 69.2 92 94.5zm0 0v40h399900v-40z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.011em;"><span></span></span></span></span></span></span></span></span> <code>\xrightharpoonup{abc}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mo stretchy="true" minsize="3.0em">↽</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></mpadded></mover></mrow><annotation encoding="application/x-tex">\xleftharpoondown{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1191em;vertical-align:-0.011em;"></span><span class="mrel x-arrow"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1081em;"><span style="top:-3.322em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">ab</span><span class="mord mathnormal mtight">c</span></span></span></span><span class="svg-align" style="top:-2.689em;"><span class="pstrut" style="height:2.7em;"></span><span class="hide-tail" style="height:0.522em;min-width:0.888em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMinYMin slice'><path d='M7 241c-4 4-6.333 8.667-7 14 0 5.333.667 9 2 11s5.333
 5.333 12 10c90.667 54 156 130 196 228 3.333 10.667 6.333 16.333 9 17 2 .667 5
 1 9 1h5c10.667 0 16.667-2 18-6 2-2.667 1-9.667-3-21-32-87.333-82.667-157.667
-152-211l-3-3h399907v-40zM93 281 H400000 v-40L7 241z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.011em;"><span></span></span></span></span></span></span></span></span> <code>\xleftharpoondown{abc}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mo stretchy="true" minsize="3.0em">⇁</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></mpadded></mover></mrow><annotation encoding="application/x-tex">\xrightharpoondown{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1191em;vertical-align:-0.011em;"></span><span class="mrel x-arrow"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1081em;"><span style="top:-3.322em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">ab</span><span class="mord mathnormal mtight">c</span></span></span></span><span class="svg-align" style="top:-2.689em;"><span class="pstrut" style="height:2.7em;"></span><span class="hide-tail" style="height:0.522em;min-width:0.888em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMaxYMin slice'><path d='M399747 511c0 7.3 6.7 11 20 11 8 0 13-.8 15-2.5s4.7-6.8
 8-15.5c40-94 99.3-166.3 178-217 13.3-8 20.3-12.3 21-13 5.3-3.3 8.5-5.8 9.5
-7.5 1-1.7 1.5-5.2 1.5-10.5s-2.3-10.3-7-15H0v40h399908c-34 25.3-64.7 57-92 95
-27.3 38-48.7 77.7-64 119-3.3 8.7-5 14-5 16zM0 241v40h399900v-40z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.011em;"><span></span></span></span></span></span></span></span></span> <code>\xrightharpoondown{abc}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mo stretchy="true" minsize="3.0em">⇋</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></mpadded></mover></mrow><annotation encoding="application/x-tex">\xleftrightharpoons{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.3131em;vertical-align:-0.108em;"></span><span class="mrel x-arrow"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.2051em;"><span style="top:-3.435em;"><span class="pstrut" style="height:2.716em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">ab</span><span class="mord mathnormal mtight">c</span></span></span></span><span class="svg-align" style="top:-2.608em;"><span class="pstrut" style="height:2.716em;"></span><span class="stretchy" style="height:0.716em;min-width:1.75em;"><span class="halfarrow-left" style="height:0.716em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.716em' viewBox='0 0 400000 716' preserveAspectRatio='xMinYMin slice'><path d='M0 267c.7 5.3 3 10 7 14h399993v-40H93c3.3-3.3 10.2-9.5
 20.5-18.5s17.8-15.8 22.5-20.5c50.7-52 88-110.3 112-175 4-11.3 5-18.3 3-21-1.3
-4-7.3-6-18-6-8 0-13 .7-15 2s-4.7 6.7-8 16c-42 98.7-107.3 174.7-196 228-6.7 4.7
-10.7 8-12 10-1.3 2-2 5.7-2 11zm100-26v40h399900v-40zM0 435v40h400000v-40z
m0 0v40h400000v-40z'/></svg></span><span class="halfarrow-right" style="height:0.716em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.716em' viewBox='0 0 400000 716' preserveAspectRatio='xMaxYMin slice'><path d='M399747 705c0 7.3 6.7 11 20 11 8 0 13-.8
 15-2.5s4.7-6.8 8-15.5c40-94 99.3-166.3 178-217 13.3-8 20.3-12.3 21-13 5.3-3.3
 8.5-5.8 9.5-7.5 1-1.7 1.5-5.2 1.5-10.5s-2.3-10.3-7-15H0v40h399908c-34 25.3
-64.7 57-92 95-27.3 38-48.7 77.7-64 119-3.3 8.7-5 14-5 16zM0 435v40h399900v-40z
m0-194v40h400000v-40zm0 0v40h400000v-40z'/></svg></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.108em;"><span></span></span></span></span></span></span></span></span> <code>\xleftrightharpoons{abc}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mo stretchy="true" minsize="3.0em">⇌</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></mpadded></mover></mrow><annotation encoding="application/x-tex">\xrightleftharpoons{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.3131em;vertical-align:-0.108em;"></span><span class="mrel x-arrow"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.2051em;"><span style="top:-3.435em;"><span class="pstrut" style="height:2.716em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">ab</span><span class="mord mathnormal mtight">c</span></span></span></span><span class="svg-align" style="top:-2.608em;"><span class="pstrut" style="height:2.716em;"></span><span class="stretchy" style="height:0.716em;min-width:1.75em;"><span class="halfarrow-left" style="height:0.716em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.716em' viewBox='0 0 400000 716' preserveAspectRatio='xMinYMin slice'><path d='M7 435c-4 4-6.3 8.7-7 14 0 5.3.7 9 2 11s5.3 5.3 12
 10c90.7 54 156 130 196 228 3.3 10.7 6.3 16.3 9 17 2 .7 5 1 9 1h5c10.7 0 16.7
-2 18-6 2-2.7 1-9.7-3-21-32-87.3-82.7-157.7-152-211l-3-3h399907v-40H7zm93 0
v40h399900v-40zM0 241v40h399900v-40zm0 0v40h399900v-40z'/></svg></span><span class="halfarrow-right" style="height:0.716em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.716em' viewBox='0 0 400000 716' preserveAspectRatio='xMaxYMin slice'><path d='M0 241v40h399993c4.7-4.7 7-9.3 7-14 0-9.3-3.7-15.3-11
-18-92.7-56.7-159-133.7-199-231-3.3-9.3-6-14.7-8-16-2-1.3-7-2-15-2-10.7 0-16.7
 2-18 6-2 2.7-1 9.7 3 21 15.3 42 36.7 81.8 64 119.5 27.3 37.7 58 69.2 92 94.5z
m0 0v40h399900v-40z m100 194v40h399900v-40zm0 0v40h399900v-40z'/></svg></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.108em;"><span></span></span></span></span></span></span></span></span> <code>\xrightleftharpoons{abc}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mo stretchy="true" minsize="3.0em">⇄</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></mpadded></mover></mrow><annotation encoding="application/x-tex">\xtofrom{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1251em;vertical-align:-0.014em;"></span><span class="mrel x-arrow"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1111em;"><span style="top:-3.325em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">ab</span><span class="mord mathnormal mtight">c</span></span></span></span><span class="svg-align" style="top:-2.686em;"><span class="pstrut" style="height:2.7em;"></span><span class="stretchy" style="height:0.528em;min-width:1.75em;"><span class="halfarrow-left" style="height:0.528em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.528em' viewBox='0 0 400000 528' preserveAspectRatio='xMinYMin slice'><path d='M0 147h400000v40H0zm0 214c68 40 115.7 95.7 143 167h22c15.3 0 23
-.3 23-1 0-1.3-5.3-13.7-16-37-18-35.3-41.3-69-70-101l-7-8h399905v-40H95l7-8
c28.7-32 52-65.7 70-101 10.7-23.3 16-35.7 16-37 0-.7-7.7-1-23-1h-22C115.7 265.3
 68 321 0 361zm0-174v-40h399900v40zm100 154v40h399900v-40z'/></svg></span><span class="halfarrow-right" style="height:0.528em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.528em' viewBox='0 0 400000 528' preserveAspectRatio='xMaxYMin slice'><path d='M400000 167c-70.7-42-118-97.7-142-167h-23c-15.3 0-23 .3-23
 1 0 1.3 5.3 13.7 16 37 18 35.3 41.3 69 70 101l7 8H0v40h399905l-7 8c-28.7 32
-52 65.7-70 101-10.7 23.3-16 35.7-16 37 0 .7 7.7 1 23 1h23c24-69.3 71.3-125 142
-167z M100 147v40h399900v-40zM0 341v40h399900v-40z'/></svg></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.014em;"><span></span></span></span></span></span></span></span></span> <code>\xtofrom{abc}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mo stretchy="true" minsize="3.0em">↦</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></mpadded></mover></mrow><annotation encoding="application/x-tex">\xmapsto{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1191em;vertical-align:-0.011em;"></span><span class="mrel x-arrow"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1081em;"><span style="top:-3.322em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">ab</span><span class="mord mathnormal mtight">c</span></span></span></span><span class="svg-align" style="top:-2.689em;"><span class="pstrut" style="height:2.7em;"></span><span class="stretchy" style="height:0.522em;min-width:1.5em;"><span class="halfarrow-left" style="height:0.522em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMinYMin slice'><path d='M40 281 V448H0V74H40V241H400000v40z
M40 281 V448H0V74H40V241H400000v40z'/></svg></span><span class="halfarrow-right" style="height:0.522em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMaxYMin slice'><path d='M0 241v40h399891c-47.3 35.3-84 78-110 128
-16.7 32-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20
 11 8 0 13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7
 39-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85
-40.5-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5
-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67
 151.7 139 205zm0 0v40h399900v-40z'/></svg></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.011em;"><span></span></span></span></span></span></span></span></span> <code>\xmapsto{abc}</code></td>
</tr>
</tbody>
</table>
<p>|<span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mo stretchy="true" minsize="3.0em">=</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></mpadded></mover></mrow><annotation encoding="application/x-tex">\xlongequal{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0141em;"></span><span class="mrel x-arrow"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:1.0141em;"><span style="top:-3.228em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">ab</span><span class="mord mathnormal mtight">c</span></span></span></span><span class="svg-align" style="top:-2.783em;"><span class="pstrut" style="height:2.7em;"></span><span class="hide-tail" style="height:0.334em;min-width:0.888em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.334em' viewBox='0 0 400000 334' preserveAspectRatio='xMinYMin slice'><path d='M0 50 h400000 v40H0z m0 194h40000v40H0z
M0 50 h400000 v40H0z m0 194h40000v40H0z'/></svg></span></span></span></span></span></span></span></span></span> <code>\xlongequal{abc}</code></p>
<p>Extensible arrows all can take an optional argument in the same manner, as <code>\xrightarrow[under]{over}</code>.</p>
<h2 id="_11-style-color-size-and-font" tabindex="-1">11: Style, Color, Size, and Font <a class="header-anchor" href="#_11-style-color-size-and-font" aria-label="Permalink to &quot;11: Style, Color, Size, and Font&quot;">&ZeroWidthSpace;</a></h2>
<p><strong>Class Assignment</strong></p>
<ul>
<li>
<p><code>\mathbin</code> <code>\mathclose</code> <code>\mathinner</code> <code>\mathop</code></p>
</li>
<li>
<p><code>\mathopen</code> <code>\mathord</code> <code>\mathpunct</code> <code>\mathrel</code></p>
</li>
</ul>
<p><strong>Color</strong></p>
<p><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathcolor="blue"><mi>F</mi><mo>=</mo><mi>m</mi><mi>a</mi></mstyle></mrow><annotation encoding="application/x-tex">\color{blue} F=ma</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.13889em;color:blue;">F</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel" style="color:blue;">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal" style="color:blue;">ma</span></span></span></span> <code>\color{blue} F=ma</code></p>
<p>Note that KaTeX <code>\color</code> acts like a switch. This aligns with LaTeX and differs from MathJax.
Other KaTeX color functions expect the content to be a function argument:</p>
<ul>
<li><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathcolor="blue"><mi>F</mi><mo>=</mo><mi>m</mi><mi>a</mi></mstyle></mrow><annotation encoding="application/x-tex">\textcolor{blue}{F=ma}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.13889em;color:blue;">F</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel" style="color:blue;">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal" style="color:blue;">ma</span></span></span></span> <code>\textcolor{blue}{F=ma}</code></li>
<li><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathcolor="#228B22"><mi>F</mi><mo>=</mo><mi>m</mi><mi>a</mi></mstyle></mrow><annotation encoding="application/x-tex">\textcolor{#228B22}{F=ma}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.13889em;color:#228B22;">F</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel" style="color:#228B22;">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal" style="color:#228B22;">ma</span></span></span></span> <code>\textcolor{#228B22}{F=ma}</code></li>
<li><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mpadded width="+6pt" height="+6pt" lspace="3pt" voffset="3pt" mathbackground="aqua"><mtext>A</mtext></mpadded></mrow><annotation encoding="application/x-tex">\colorbox{aqua}{A}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2833em;vertical-align:-0.3em;"></span><span class="mord"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.9833em;"><span style="top:-2.9833em;"><span class="pstrut" style="height:3.2833em;"></span><span class="stretchy colorbox" style="height:1.2833em;background-color:aqua;"></span></span><span style="top:-3.2833em;"><span class="pstrut" style="height:3.2833em;"></span><span class="mord boxpad"><span class="mord">A</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.3em;"><span></span></span></span></span></span></span></span></span> <code>\colorbox{aqua}{A}</code></li>
<li><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mpadded width="+6pt" height="+6pt" lspace="3pt" voffset="3pt" style="border: 0.04em solid red" mathbackground="aqua"><mtext>A</mtext></mpadded></mrow><annotation encoding="application/x-tex">\fcolorbox{red}{aqua}{A}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.3633em;vertical-align:-0.34em;"></span><span class="mord"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.0233em;"><span style="top:-3.0233em;"><span class="pstrut" style="height:3.3633em;"></span><span class="stretchy fcolorbox" style="height:1.3633em;border-style:solid;border-width:0.04em;background-color:aqua;border-color:red;"></span></span><span style="top:-3.3633em;"><span class="pstrut" style="height:3.3633em;"></span><span class="mord boxpad"><span class="mord">A</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.34em;"><span></span></span></span></span></span></span></span></span> <code>\fcolorbox{red}{aqua}{A}</code></li>
</ul>
<p>For color definition, KaTeX color functions will accept the standard HTML <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/color_value#Color_keywords" target="_blank" rel="noreferrer">predefined color names</a>. They will also accept an RGB argument in CSS hexa­decimal style. The &quot;#&quot; is optional before a six-digit specification.</p>
<p><strong>Font</strong></p>
<table>
<thead>
<tr>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">A</mi><mi mathvariant="normal">b</mi><mn>0</mn></mrow><annotation encoding="application/x-tex">\mathrm{Ab0}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord"><span class="mord mathrm">Ab0</span></span></span></span></span> <code>\mathrm{Ab0}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="bold">A</mi><mi mathvariant="bold">b</mi><mn mathvariant="bold">0</mn></mrow><annotation encoding="application/x-tex">\mathbf{Ab0}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord"><span class="mord mathbf">Ab0</span></span></span></span></span> <code>\mathbf{Ab0}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>A</mi><mi>b</mi></mrow><annotation encoding="application/x-tex">\mathit{Ab}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord"><span class="mord mathit">Ab</span></span></span></span></span> <code>\mathit{Ab}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>A</mi><mi>b</mi><mn>0</mn></mrow><annotation encoding="application/x-tex">\mathnormal{Ab0}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord"><span class="mord mathnormal">A</span><span class="mord mathnormal">b0</span></span></span></span></span> <code>\mathnormal{Ab0}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext mathvariant="bold">Ab0</mtext></mrow><annotation encoding="application/x-tex">\textbf{Ab0}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord textbf">Ab0</span></span></span></span></span> <code>\textbf{Ab0}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext mathvariant="italic">Ab</mtext></mrow><annotation encoding="application/x-tex">\textit{Ab}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord textit">Ab</span></span></span></span></span> <code>\textit{Ab}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>Ab0</mtext></mrow><annotation encoding="application/x-tex">\textrm{Ab0}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord textrm">Ab0</span></span></span></span></span> <code>\textrm{Ab0}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="bold">A</mi><mi mathvariant="bold">b</mi><mn mathvariant="bold">0</mn></mrow><annotation encoding="application/x-tex">\bf Ab0</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord"><span class="mord mathbf">Ab0</span></span></span></span></span> <code>\bf Ab0</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>A</mi><mi>b</mi></mrow><annotation encoding="application/x-tex">\it Ab</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord"><span class="mord mathit">Ab</span></span></span></span></span> <code>\it Ab</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">A</mi><mi mathvariant="normal">b</mi><mn>0</mn></mrow><annotation encoding="application/x-tex">\rm Ab0</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord"><span class="mord mathrm">Ab0</span></span></span></span></span> <code>\rm Ab0</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="bold">A</mi><mi mathvariant="bold">b</mi><mn mathvariant="bold">0</mn></mrow><annotation encoding="application/x-tex">\bold{Ab0}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord"><span class="mord mathbf">Ab0</span></span></span></span></span> <code>\bold{Ab0}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="double-struck">A</mi><mi mathvariant="double-struck">B</mi></mrow><annotation encoding="application/x-tex">\Bbb{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord"><span class="mord mathbb">AB</span></span></span></span></span> <code>\Bbb{AB}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>Ab0</mtext></mrow><annotation encoding="application/x-tex">\textnormal{Ab0}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord textrm">Ab0</span></span></span></span></span> <code>\textnormal{Ab0}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi><mrow><mi mathvariant="bold-italic">A</mi><mi mathvariant="bold-italic">b</mi></mrow></mi></mrow><annotation encoding="application/x-tex">\boldsymbol{Ab}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol">Ab</span></span></span></span></span></span> <code>\boldsymbol{Ab}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="double-struck">A</mi><mi mathvariant="double-struck">B</mi></mrow><annotation encoding="application/x-tex">\mathbb{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord"><span class="mord mathbb">AB</span></span></span></span></span> <code>\mathbb{AB}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>Ab0</mtext></mrow><annotation encoding="application/x-tex">\text{Ab0}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord">Ab0</span></span></span></span></span> <code>\text{Ab0}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi><mrow><mi mathvariant="bold-italic">A</mi><mi mathvariant="bold-italic">b</mi></mrow></mi></mrow><annotation encoding="application/x-tex">\bm{Ab}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol">Ab</span></span></span></span></span></span> <code>\bm{Ab}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="fraktur">A</mi><mi mathvariant="fraktur">b</mi><mn mathvariant="fraktur">0</mn></mrow><annotation encoding="application/x-tex">\frak{Ab0}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6914em;"></span><span class="mord"><span class="mord mathfrak">Ab0</span></span></span></span></span> <code>\frak{Ab0}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="sans-serif">A</mi><mi mathvariant="sans-serif">b</mi><mn mathvariant="sans-serif">0</mn></mrow><annotation encoding="application/x-tex">\mathsf{Ab0}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord"><span class="mord mathsf">Ab0</span></span></span></span></span> <code>\mathsf{Ab0}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="monospace">A</mi><mi mathvariant="monospace">b</mi><mn mathvariant="monospace">0</mn></mrow><annotation encoding="application/x-tex">\mathtt{Ab0}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6111em;"></span><span class="mord"><span class="mord mathtt">Ab0</span></span></span></span></span> <code>\mathtt{Ab0}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="fraktur">A</mi><mi mathvariant="fraktur">b</mi><mn mathvariant="fraktur">0</mn></mrow><annotation encoding="application/x-tex">\mathfrak{Ab0}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6914em;"></span><span class="mord"><span class="mord mathfrak">Ab0</span></span></span></span></span> <code>\mathfrak{Ab0}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext mathvariant="sans-serif">Ab0</mtext></mrow><annotation encoding="application/x-tex">\textsf{Ab0}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord textsf">Ab0</span></span></span></span></span> <code>\textsf{Ab0}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext mathvariant="monospace">Ab0</mtext></mrow><annotation encoding="application/x-tex">\texttt{Ab0}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6111em;"></span><span class="mord text"><span class="mord texttt">Ab0</span></span></span></span></span> <code>\texttt{Ab0}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="script">A</mi><mi mathvariant="script">B</mi><mn mathvariant="script">0</mn></mrow><annotation encoding="application/x-tex">\mathcal{AB0}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord"><span class="mord mathcal">A</span><span class="mord mathcal" style="margin-right:0.03041em;">B</span><span class="mord">0</span></span></span></span></span> <code>\mathcal{AB0}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="sans-serif">A</mi><mi mathvariant="sans-serif">b</mi><mn mathvariant="sans-serif">0</mn></mrow><annotation encoding="application/x-tex">\sf Ab0</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord"><span class="mord mathsf">Ab0</span></span></span></span></span> <code>\sf Ab0</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="monospace">A</mi><mi mathvariant="monospace">b</mi><mn mathvariant="monospace">0</mn></mrow><annotation encoding="application/x-tex">\tt Ab0</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6111em;"></span><span class="mord"><span class="mord mathtt">Ab0</span></span></span></span></span> <code>\tt Ab0</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="script">A</mi><mi mathvariant="script">B</mi></mrow><annotation encoding="application/x-tex">\mathscr{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7em;"></span><span class="mord"><span class="mord mathscr" style="margin-right:0.04087em;">AB</span></span></span></span></span> <code>\mathscr{AB}</code></td>
</tr>
</tbody>
</table>
<p>One can stack font family, font weight, and font shape by using the <code>\textXX</code> versions of the font functions. So <code>\textsf{\textbf{H}}</code> will produce <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext mathvariant="bold-sans-serif">H</mtext></mrow><annotation encoding="application/x-tex">\textsf{\textbf{H}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord text"><span class="mord textsf textbf">H</span></span></span></span></span></span>. The other versions do not stack, e.g., <code>\mathsf{\mathbf{H}}</code> will produce <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="bold">H</mi></mrow><annotation encoding="application/x-tex">\mathsf{\mathbf{H}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6861em;"></span><span class="mord mathbf">H</span></span></span></span>.</p>
<p>In cases where KaTeX fonts do not have a bold glyph, <code>\pmb</code> can simulate one. For example, <code>\pmb{\mu}</code> renders as : <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle style="text-shadow: 0.02em 0.01em 0.04px"><mi>μ</mi></mstyle></mrow><annotation encoding="application/x-tex">\pmb{\mu}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord" style="text-shadow:0.02em 0.01em 0.04px;"><span class="mord mathnormal">μ</span></span></span></span></span></p>
<p><strong>Size</strong></p>
<table>
<thead>
<tr>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathsize="2.488em"><mi>A</mi><mi>B</mi></mstyle></mrow><annotation encoding="application/x-tex">\Huge AB</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.7001em;"></span><span class="mord mathnormal sizing reset-size6 size11">A</span><span class="mord mathnormal sizing reset-size6 size11" style="margin-right:0.05017em;">B</span></span></span></span> <code>\Huge AB</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathsize="1em"><mi>A</mi><mi>B</mi></mstyle></mrow><annotation encoding="application/x-tex">\normalsize AB</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span></span> <code>\normalsize AB</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathsize="2.074em"><mi>A</mi><mi>B</mi></mstyle></mrow><annotation encoding="application/x-tex">\huge AB</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.4172em;"></span><span class="mord mathnormal sizing reset-size6 size10">A</span><span class="mord mathnormal sizing reset-size6 size10" style="margin-right:0.05017em;">B</span></span></span></span> <code>\huge AB</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathsize="0.9em"><mi>A</mi><mi>B</mi></mstyle></mrow><annotation encoding="application/x-tex">\small AB</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.615em;"></span><span class="mord mathnormal sizing reset-size6 size5">A</span><span class="mord mathnormal sizing reset-size6 size5" style="margin-right:0.05017em;">B</span></span></span></span> <code>\small AB</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathsize="1.728em"><mi>A</mi><mi>B</mi></mstyle></mrow><annotation encoding="application/x-tex">\LARGE AB</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1808em;"></span><span class="mord mathnormal sizing reset-size6 size9">A</span><span class="mord mathnormal sizing reset-size6 size9" style="margin-right:0.05017em;">B</span></span></span></span> <code>\LARGE AB</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathsize="0.8em"><mi>A</mi><mi>B</mi></mstyle></mrow><annotation encoding="application/x-tex">\footnotesize AB</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5467em;"></span><span class="mord mathnormal sizing reset-size6 size4">A</span><span class="mord mathnormal sizing reset-size6 size4" style="margin-right:0.05017em;">B</span></span></span></span> <code>\footnotesize AB</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathsize="1.44em"><mi>A</mi><mi>B</mi></mstyle></mrow><annotation encoding="application/x-tex">\Large AB</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.984em;"></span><span class="mord mathnormal sizing reset-size6 size8">A</span><span class="mord mathnormal sizing reset-size6 size8" style="margin-right:0.05017em;">B</span></span></span></span> <code>\Large AB</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathsize="0.7em"><mi>A</mi><mi>B</mi></mstyle></mrow><annotation encoding="application/x-tex">\scriptsize AB</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4783em;"></span><span class="mord mathnormal sizing reset-size6 size3">A</span><span class="mord mathnormal sizing reset-size6 size3" style="margin-right:0.05017em;">B</span></span></span></span> <code>\scriptsize AB</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathsize="1.2em"><mi>A</mi><mi>B</mi></mstyle></mrow><annotation encoding="application/x-tex">\large AB</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.82em;"></span><span class="mord mathnormal sizing reset-size6 size7">A</span><span class="mord mathnormal sizing reset-size6 size7" style="margin-right:0.05017em;">B</span></span></span></span> <code>\large AB</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathsize="0.5em"><mi>A</mi><mi>B</mi></mstyle></mrow><annotation encoding="application/x-tex">\tiny AB</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3417em;"></span><span class="mord mathnormal sizing reset-size6 size1">A</span><span class="mord mathnormal sizing reset-size6 size1" style="margin-right:0.05017em;">B</span></span></span></span> <code>\tiny AB</code></td>
</tr>
</tbody>
</table>
<p><strong>Style</strong></p>
<table>
<thead>
<tr>
<th style="text-align:left"></th>
</tr>
</thead>
</table>
<p>|<span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle scriptlevel="0" displaystyle="true"><munderover><mo>∑</mo><mrow><mi>i</mi><mo>=</mo><mn>1</mn></mrow><mi>n</mi></munderover></mstyle></mrow><annotation encoding="application/x-tex">\displaystyle\sum_{i=1}^n</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.9291em;vertical-align:-1.2777em;"></span><span class="mop op-limits"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.6514em;"><span style="top:-1.8723em;margin-left:0em;"><span class="pstrut" style="height:3.05em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">i</span><span class="mrel mtight">=</span><span class="mord mtight">1</span></span></span></span><span style="top:-3.05em;"><span class="pstrut" style="height:3.05em;"></span><span><span class="mop op-symbol large-op">∑</span></span></span><span style="top:-4.3em;margin-left:0em;"><span class="pstrut" style="height:3.05em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">n</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.2777em;"><span></span></span></span></span></span></span></span></span> <code>\displaystyle\sum_{i=1}^n</code>
|<span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle scriptlevel="0" displaystyle="false"><msubsup><mo>∑</mo><mrow><mi>i</mi><mo>=</mo><mn>1</mn></mrow><mi>n</mi></msubsup></mstyle></mrow><annotation encoding="application/x-tex">\textstyle\sum_{i=1}^n</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.104em;vertical-align:-0.2997em;"></span><span class="mop"><span class="mop op-symbol small-op" style="position:relative;top:0em;">∑</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8043em;"><span style="top:-2.4003em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">i</span><span class="mrel mtight">=</span><span class="mord mtight">1</span></span></span></span><span style="top:-3.2029em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">n</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2997em;"><span></span></span></span></span></span></span></span></span></span> <code>\textstyle\sum_{i=1}^n</code>
|<span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle scriptlevel="1" displaystyle="false"><mi>x</mi></mstyle></mrow><annotation encoding="application/x-tex">\scriptstyle x</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3014em;"></span><span class="mord mathnormal mtight sizing reset-size6 size3">x</span></span></span></span> <code>\scriptstyle x</code>         (The size of a first sub/superscript)
|<span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle scriptlevel="2" displaystyle="false"><mi>x</mi></mstyle></mrow><annotation encoding="application/x-tex">\scriptscriptstyle x</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.2153em;"></span><span class="mord mathnormal mtight sizing reset-size6 size1">x</span></span></span></span> <code>\scriptscriptstyle x</code> (The size of subsequent sub/superscripts)
|<span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><munder><mrow><mi>lim</mi><mo>⁡</mo></mrow><mi>x</mi></munder></mrow><annotation encoding="application/x-tex">\lim\limits_x</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.3944em;vertical-align:-0.7em;"></span><span class="mop op-limits"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6944em;"><span style="top:-2.4em;margin-left:0em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">x</span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span><span class="mop">lim</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.7em;"><span></span></span></span></span></span></span></span></span> <code>\lim\limits_x</code>
|<span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mrow><mi>lim</mi><mo>⁡</mo></mrow><mi>x</mi></msub></mrow><annotation encoding="application/x-tex">\lim\nolimits_x</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8444em;vertical-align:-0.15em;"></span><span class="mop"><span class="mop">lim</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">x</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> <code>\lim\nolimits_x</code>
|<span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext mathvariant="monospace">x^2</mtext></mrow><annotation encoding="application/x-tex">\verb!x^2!</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6111em;"></span><span class="mord text"><span class="mord texttt">x^2</span></span></span></span></span> <code>\verb!x^2!</code></p>
<p><code>\text{…}</code> will accept nested <code>$…$</code> fragments and render them in math mode.</p>
<h2 id="_12-symbols-and-punctuation" tabindex="-1">12: Symbols and Punctuation <a class="header-anchor" href="#_12-symbols-and-punctuation" aria-label="Permalink to &quot;12: Symbols and Punctuation&quot;">&ZeroWidthSpace;</a></h2>
<table>
<thead>
<tr>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
<th style="text-align:left"></th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left"><code>% comment</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>…</mo></mrow><annotation encoding="application/x-tex">\dots</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.123em;"></span><span class="minner">…</span></span></span></span> <code>\dots</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>KaTeX</mtext></mrow><annotation encoding="application/x-tex">\KaTeX</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8988em;vertical-align:-0.2155em;"></span><span class="mord text"><span class="mord textrm">K</span><span class="mspace" style="margin-right:-0.17em;"></span><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6833em;"><span style="top:-2.905em;"><span class="pstrut" style="height:2.7em;"></span><span class="mord"><span class="mord textrm mtight sizing reset-size6 size3">A</span></span></span></span></span></span><span class="mspace" style="margin-right:-0.15em;"></span><span class="mord text"><span class="mord textrm">T</span><span class="mspace" style="margin-right:-0.1667em;"></span><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.4678em;"><span style="top:-2.7845em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord textrm">E</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2155em;"><span></span></span></span></span><span class="mspace" style="margin-right:-0.125em;"></span><span class="mord textrm">X</span></span></span></span></span></span> <code>\KaTeX</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">%</mi></mrow><annotation encoding="application/x-tex">\%</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8056em;vertical-align:-0.0556em;"></span><span class="mord">%</span></span></span></span> <code>\%</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋯</mo></mrow><annotation encoding="application/x-tex">\cdots</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.313em;"></span><span class="minner">⋯</span></span></span></span> <code>\cdots</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>LaTeX</mtext></mrow><annotation encoding="application/x-tex">\LaTeX</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8988em;vertical-align:-0.2155em;"></span><span class="mord text"><span class="mord textrm">L</span><span class="mspace" style="margin-right:-0.36em;"></span><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6833em;"><span style="top:-2.905em;"><span class="pstrut" style="height:2.7em;"></span><span class="mord"><span class="mord textrm mtight sizing reset-size6 size3">A</span></span></span></span></span></span><span class="mspace" style="margin-right:-0.15em;"></span><span class="mord text"><span class="mord textrm">T</span><span class="mspace" style="margin-right:-0.1667em;"></span><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.4678em;"><span style="top:-2.7845em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord textrm">E</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2155em;"><span></span></span></span></span><span class="mspace" style="margin-right:-0.125em;"></span><span class="mord textrm">X</span></span></span></span></span></span> <code>\LaTeX</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">#</mi></mrow><annotation encoding="application/x-tex">\#</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord">#</span></span></span></span> <code>\#</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋱</mo></mrow><annotation encoding="application/x-tex">\ddots</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.823em;"></span><span class="minner">⋱</span></span></span></span> <code>\ddots</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>TeX</mtext></mrow><annotation encoding="application/x-tex">\TeX</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8988em;vertical-align:-0.2155em;"></span><span class="mord text"><span class="mord textrm">T</span><span class="mspace" style="margin-right:-0.1667em;"></span><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.4678em;"><span style="top:-2.7845em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord textrm">E</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2155em;"><span></span></span></span></span><span class="mspace" style="margin-right:-0.125em;"></span><span class="mord textrm">X</span></span></span></span></span> <code>\TeX</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">&amp;</mi></mrow><annotation encoding="application/x-tex">\&amp;</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">&amp;</span></span></span></span> <code>\&amp;</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>…</mo></mrow><annotation encoding="application/x-tex">\ldots</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.123em;"></span><span class="minner">…</span></span></span></span> <code>\ldots</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∇</mi></mrow><annotation encoding="application/x-tex">\nabla</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">∇</span></span></span></span> <code>\nabla</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">_</mi></mrow><annotation encoding="application/x-tex">\_</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;vertical-align:-0.31em;"></span><span class="mord" style="margin-right:0.02778em;">_</span></span></span></span> <code>\_</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi><mi mathvariant="normal">⋮</mi><mpadded height="0em" voffset="0em"><mspace mathbackground="black" width="0em" height="1.5em"></mspace></mpadded></mi></mrow><annotation encoding="application/x-tex">\vdots</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.53em;vertical-align:-0.03em;"></span><span class="mord"><span class="mord">⋮</span><span class="mord rule" style="border-right-width:0em;border-top-width:1.5em;bottom:0em;"></span></span></span></span></span> <code>\vdots</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∞</mi></mrow><annotation encoding="application/x-tex">\infty</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord">∞</span></span></span></span> <code>\infty</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>_</mtext></mrow><annotation encoding="application/x-tex">\text{\textunderscore}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;vertical-align:-0.31em;"></span><span class="mord text"><span class="mord">_</span></span></span></span></span> <code>\text{\textunderscore}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋯</mo></mrow><annotation encoding="application/x-tex">\dotsb</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.313em;"></span><span class="minner">⋯</span></span></span></span> <code>\dotsb</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∞</mi></mrow><annotation encoding="application/x-tex">\infin</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord">∞</span></span></span></span> <code>\infin</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>–</mtext></mrow><annotation encoding="application/x-tex">\text{--}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord text"><span class="mord">–</span></span></span></span></span> <code>\text{--}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>…</mo></mrow><annotation encoding="application/x-tex">\dotsc</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.123em;"></span><span class="minner">…</span></span></span></span> <code>\dotsc</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">✓</mi></mrow><annotation encoding="application/x-tex">\checkmark</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mord amsrm">✓</span></span></span></span> <code>\checkmark</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>–</mtext></mrow><annotation encoding="application/x-tex">\text{\textendash}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord text"><span class="mord">–</span></span></span></span></span> <code>\text{\textendash}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext> ⁣</mtext><mo>⋯</mo></mrow><annotation encoding="application/x-tex">\dotsi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.313em;"></span><span class="mspace" style="margin-right:-0.1667em;"></span><span class="minner">⋯</span></span></span></span> <code>\dotsi</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">†</mi></mrow><annotation encoding="application/x-tex">\dag</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord">†</span></span></span></span> <code>\dag</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>—</mtext></mrow><annotation encoding="application/x-tex">\text{---}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord text"><span class="mord">—</span></span></span></span></span> <code>\text{---}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋯</mo></mrow><annotation encoding="application/x-tex">\dotsm</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.313em;"></span><span class="minner">⋯</span></span></span></span> <code>\dotsm</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>†</mo></mrow><annotation encoding="application/x-tex">\dagger</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord">†</span></span></span></span> <code>\dagger</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>—</mtext></mrow><annotation encoding="application/x-tex">\text{\textemdash}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord text"><span class="mord">—</span></span></span></span></span> <code>\text{\textemdash}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>…</mo></mrow><annotation encoding="application/x-tex">\dotso</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.123em;"></span><span class="minner">…</span></span></span></span> <code>\dotso</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>†</mtext></mrow><annotation encoding="application/x-tex">\text{\textdagger}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord text"><span class="mord">†</span></span></span></span></span> <code>\text{\textdagger}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>~</mtext></mrow><annotation encoding="application/x-tex">\text{\textasciitilde}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6679em;vertical-align:-0.35em;"></span><span class="mord text"><span class="mord">~</span></span></span></span></span> <code>\text{\textasciitilde}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋅</mo></mrow><annotation encoding="application/x-tex">\sdot</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4445em;"></span><span class="mord">⋅</span></span></span></span> <code>\sdot</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">‡</mi></mrow><annotation encoding="application/x-tex">\ddag</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord">‡</span></span></span></span> <code>\ddag</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">‘</mi></mrow><annotation encoding="application/x-tex">`</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">‘</span></span></span></span> <code>`</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>…</mo></mrow><annotation encoding="application/x-tex">\mathellipsis</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.123em;"></span><span class="minner">…</span></span></span></span> <code>\mathellipsis</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>‡</mo></mrow><annotation encoding="application/x-tex">\ddagger</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord">‡</span></span></span></span> <code>\ddagger</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>‘</mtext></mrow><annotation encoding="application/x-tex">\text{\textquoteleft}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord">‘</span></span></span></span></span> <code>text{\textquoteleft}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>…</mo></mrow><annotation encoding="application/x-tex">\text{\textellipsis}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.123em;"></span><span class="mord text"><span class="minner">…</span></span></span></span></span> <code>\text{\textellipsis}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>‡</mtext></mrow><annotation encoding="application/x-tex">\text{\textdaggerdbl}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord text"><span class="mord">‡</span></span></span></span></span> <code>\text{\textdaggerdbl}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">‘</mi></mrow><annotation encoding="application/x-tex">\lq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">‘</span></span></span></span> <code>\lq</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">□</mi></mrow><annotation encoding="application/x-tex">\Box</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.675em;"></span><span class="mord amsrm">□</span></span></span></span> <code>\Box</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>‡</mo></mrow><annotation encoding="application/x-tex">\Dagger</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord">‡</span></span></span></span> <code>\Dagger</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>’</mtext></mrow><annotation encoding="application/x-tex">\text{\textquoteright}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord">’</span></span></span></span></span> <code>\text{\textquoteright}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">□</mi></mrow><annotation encoding="application/x-tex">\square</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.675em;"></span><span class="mord amsrm">□</span></span></span></span> <code>\square</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∠</mi></mrow><annotation encoding="application/x-tex">\angle</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mord">∠</span></span></span></span> <code>\angle</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msup><mrow></mrow><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup></mrow><annotation encoding="application/x-tex">\rq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7519em;"></span><span class="mord"><span></span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7519em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span></span></span></span> <code>\rq</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">■</mi></mrow><annotation encoding="application/x-tex">\blacksquare</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.675em;"></span><span class="mord amsrm">■</span></span></span></span> <code>\blacksquare</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∡</mi></mrow><annotation encoding="application/x-tex">\measuredangle</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mord amsrm">∡</span></span></span></span> <code>\measuredangle</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>“</mtext></mrow><annotation encoding="application/x-tex">\text{\textquotedblleft}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord">“</span></span></span></span></span> <code>\text{\textquotedblleft}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">△</mi></mrow><annotation encoding="application/x-tex">\triangle</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord">△</span></span></span></span> <code>\triangle</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∢</mi></mrow><annotation encoding="application/x-tex">\sphericalangle</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5576em;vertical-align:-0.0352em;"></span><span class="mord amsrm">∢</span></span></span></span> <code>\sphericalangle</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">&quot;</mi></mrow><annotation encoding="application/x-tex">&quot;</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">&quot;</span></span></span></span> <code>&quot;</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">▽</mi></mrow><annotation encoding="application/x-tex">\triangledown</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5499em;"></span><span class="mord amsrm">▽</span></span></span></span> <code>\triangledown</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">⊤</mi></mrow><annotation encoding="application/x-tex">\top</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">⊤</span></span></span></span> <code>\top</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>”</mtext></mrow><annotation encoding="application/x-tex">\text{\textquotedblright}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord">”</span></span></span></span></span> <code>\text{\textquotedblright}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>◃</mo></mrow><annotation encoding="application/x-tex">\triangleleft</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4653em;"></span><span class="mord">◃</span></span></span></span> <code>\triangleleft</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">⊥</mi></mrow><annotation encoding="application/x-tex">\bot</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">⊥</span></span></span></span> <code>\bot</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mspace></mspace><mspace width="0.1111em"/><mo lspace="0em" rspace="0.17em"></mo><mtext> ⁣</mtext><mo lspace="0em" rspace="0em">:</mo><mspace width="0.3333em"/></mrow><annotation encoding="application/x-tex">\colon</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mspace nobreak"></span><span class="mspace" style="margin-right:0.1111em;"></span><span class="mpunct"></span><span class="mspace" style="margin-right:-0.1667em;"></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mrel">:</span></span><span class="mspace" style="margin-right:0.3333em;"></span></span></span></span> <code>\colon</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>▹</mo></mrow><annotation encoding="application/x-tex">\triangleright</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4653em;"></span><span class="mord">▹</span></span></span></span> <code>\triangleright</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">$</mi></mrow><annotation encoding="application/x-tex">\$</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8056em;vertical-align:-0.0556em;"></span><span class="mord">$</span></span></span></span> <code>\$</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">‵</mi></mrow><annotation encoding="application/x-tex">\backprime</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5499em;"></span><span class="mord amsrm">‵</span></span></span></span> <code>\backprime</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>▽</mo></mrow><annotation encoding="application/x-tex">\bigtriangledown</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord">▽</span></span></span></span> <code>\bigtriangledown</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>$</mtext></mrow><annotation encoding="application/x-tex">\text{\textdollar}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8056em;vertical-align:-0.0556em;"></span><span class="mord text"><span class="mord">$</span></span></span></span></span> <code>\text{\textdollar}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo mathvariant="normal">′</mo></mrow><annotation encoding="application/x-tex">\prime</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5556em;"></span><span class="mord">′</span></span></span></span> <code>\prime</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>△</mo></mrow><annotation encoding="application/x-tex">\bigtriangleup</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord">△</span></span></span></span> <code>\bigtriangleup</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">£</mi></mrow><annotation encoding="application/x-tex">\pounds</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">£</span></span></span></span> <code>\pounds</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>&lt;</mtext></mrow><annotation encoding="application/x-tex">\text{\textless}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mord text"><span class="mord">&lt;</span></span></span></span></span> <code>\text{\textless}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">▲</mi></mrow><annotation encoding="application/x-tex">\blacktriangle</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5499em;"></span><span class="mord amsrm">▲</span></span></span></span> <code>\blacktriangle</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">£</mi></mrow><annotation encoding="application/x-tex">\mathsterling</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">£</span></span></span></span> <code>\mathsterling</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>&gt;</mtext></mrow><annotation encoding="application/x-tex">\text{\textgreater}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mord text"><span class="mord">&gt;</span></span></span></span></span> <code>\text{\textgreater}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">▼</mi></mrow><annotation encoding="application/x-tex">\blacktriangledown</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5499em;"></span><span class="mord amsrm">▼</span></span></span></span> <code>\blacktriangledown</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>£</mtext></mrow><annotation encoding="application/x-tex">\text{\textsterling}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord">£</span></span></span></span></span> <code>\text{\textsterling}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>|</mtext></mrow><annotation encoding="application/x-tex">\text{\textbar}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord text"><span class="mord">|</span></span></span></span></span> <code>\text{\textbar}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>◀</mo></mrow><annotation encoding="application/x-tex">\blacktriangleleft</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.585em;vertical-align:-0.0352em;"></span><span class="mrel amsrm">◀</span></span></span></span> <code>\blacktriangleleft</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">¥</mi></mrow><annotation encoding="application/x-tex">\yen</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.675em;"></span><span class="mord amsrm" style="margin-right:0.025em;">¥</span></span></span></span> <code>\yen</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>∥</mtext></mrow><annotation encoding="application/x-tex">\text{\textbardbl}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord text"><span class="mord">∥</span></span></span></span></span> <code>\text{\textbardbl}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>▶</mo></mrow><annotation encoding="application/x-tex">\blacktriangleright</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.585em;vertical-align:-0.0352em;"></span><span class="mrel amsrm">▶</span></span></span></span> <code>\blacktriangleright</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">√</mi></mrow><annotation encoding="application/x-tex">\surd</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.2em;"></span><span class="mord">√</span></span></span></span> <code>\surd</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>{</mtext></mrow><annotation encoding="application/x-tex">\text{\textbraceleft}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord text"><span class="mord">{</span></span></span></span></span> <code>\text{\textbraceleft}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋄</mo></mrow><annotation encoding="application/x-tex">\diamond</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4445em;"></span><span class="mord">⋄</span></span></span></span> <code>\diamond</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">°</mi></mrow><annotation encoding="application/x-tex">\degree</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">°</span></span></span></span> <code>\degree</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>}</mtext></mrow><annotation encoding="application/x-tex">\text{\textbraceright}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord text"><span class="mord">}</span></span></span></span></span> <code>\text{\textbraceright}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">◊</mi></mrow><annotation encoding="application/x-tex">\Diamond</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8034em;vertical-align:-0.1111em;"></span><span class="mord amsrm">◊</span></span></span></span> <code>\Diamond</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>°</mtext></mrow><annotation encoding="application/x-tex">\text{\textdegree}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord">°</span></span></span></span></span> <code>\text{\textdegree}</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>¶</mtext></mrow><annotation encoding="application/x-tex">\text{\P}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord text"><span class="mord">¶</span></span></span></span></span> <code>\text{\P}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">◊</mi></mrow><annotation encoding="application/x-tex">\lozenge</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8034em;vertical-align:-0.1111em;"></span><span class="mord amsrm">◊</span></span></span></span> <code>\lozenge</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">℧</mi></mrow><annotation encoding="application/x-tex">\mho</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord amsrm">℧</span></span></span></span> <code>\mho</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>§</mtext></mrow><annotation encoding="application/x-tex">\text{\S}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord text"><span class="mord">§</span></span></span></span></span> <code>\text{\S}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">⧫</mi></mrow><annotation encoding="application/x-tex">\blacklozenge</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8034em;vertical-align:-0.1111em;"></span><span class="mord amsrm">⧫</span></span></span></span> <code>\blacklozenge</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">╲</mi></mrow><annotation encoding="application/x-tex">\diagdown</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9356em;vertical-align:-0.1944em;"></span><span class="mord amsrm">╲</span></span></span></span> <code>\diagdown</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>§</mtext></mrow><annotation encoding="application/x-tex">\text{\sect}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord text"><span class="mord">§</span></span></span></span></span> <code>\text{\sect}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋆</mo></mrow><annotation encoding="application/x-tex">\star</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4653em;"></span><span class="mord">⋆</span></span></span></span> <code>\star</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">╱</mi></mrow><annotation encoding="application/x-tex">\diagup</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8833em;vertical-align:-0.1944em;"></span><span class="mord amsrm">╱</span></span></span></span> <code>\diagup</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>©</mtext></mrow><annotation encoding="application/x-tex">\copyright</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;"></span><span class="mord text"><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8889em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">c</span></span></span><span style="top:-3.1944em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body accent-full" style="left:0em;top:.2em;"><span class="mord">◯</span></span></span></span></span></span></span></span></span></span></span> <code>\copyright</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">★</mi></mrow><annotation encoding="application/x-tex">\bigstar</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8867em;vertical-align:-0.1944em;"></span><span class="mord amsrm">★</span></span></span></span> <code>\bigstar</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">♭</mi></mrow><annotation encoding="application/x-tex">\flat</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.75em;"></span><span class="mord">♭</span></span></span></span> <code>\flat</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">®</mi></mrow><annotation encoding="application/x-tex">\circledR</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8478em;vertical-align:-0.1556em;"></span><span class="mord amsrm">®</span></span></span></span> <code>\circledR</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">♣</mi></mrow><annotation encoding="application/x-tex">\clubsuit</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8241em;vertical-align:-0.1296em;"></span><span class="mord">♣</span></span></span></span> <code>\clubsuit</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">♮</mi></mrow><annotation encoding="application/x-tex">\natural</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord">♮</span></span></span></span> <code>\natural</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>®</mtext></mrow><annotation encoding="application/x-tex">\text{\textregistered}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;"></span><span class="mord text"><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8889em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord sizing reset-size6 size3">R</span></span></span><span style="top:-3.1944em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body accent-full" style="left:0em;top:.2em;"><span class="mord">◯</span></span></span></span></span></span></span></span></span></span></span> <code>\text{\textregistered}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">♣</mi></mrow><annotation encoding="application/x-tex">\clubs</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8241em;vertical-align:-0.1296em;"></span><span class="mord">♣</span></span></span></span> <code>\clubs</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">♯</mi></mrow><annotation encoding="application/x-tex">\sharp</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord">♯</span></span></span></span> <code>\sharp</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Ⓢ</mi></mrow><annotation encoding="application/x-tex">\circledS</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8478em;vertical-align:-0.1556em;"></span><span class="mord amsrm">Ⓢ</span></span></span></span> <code>\circledS</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">♢</mi></mrow><annotation encoding="application/x-tex">\diamondsuit</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8241em;vertical-align:-0.1296em;"></span><span class="mord">♢</span></span></span></span> <code>\diamondsuit</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">♡</mi></mrow><annotation encoding="application/x-tex">\heartsuit</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8241em;vertical-align:-0.1296em;"></span><span class="mord">♡</span></span></span></span> <code>\heartsuit</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mtext>a</mtext><mo>◯</mo></mover></mrow><annotation encoding="application/x-tex">\text{\textcircled a}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;"></span><span class="mord text"><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8889em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord">a</span></span><span style="top:-3.1944em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body accent-full" style="left:0em;top:.2em;"><span class="mord">◯</span></span></span></span></span></span></span></span></span></span></span> <code>\text{\textcircled a}</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">♢</mi></mrow><annotation encoding="application/x-tex">\diamonds</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8241em;vertical-align:-0.1296em;"></span><span class="mord">♢</span></span></span></span> <code>\diamonds</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">♡</mi></mrow><annotation encoding="application/x-tex">\hearts</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8241em;vertical-align:-0.1296em;"></span><span class="mord">♡</span></span></span></span> <code>\hearts</code></td>
</tr>
<tr>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">✠</mi></mrow><annotation encoding="application/x-tex">\maltese</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mord amsrm">✠</span></span></span></span> <code>\maltese</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">♠</mi></mrow><annotation encoding="application/x-tex">\spadesuit</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8241em;vertical-align:-0.1296em;"></span><span class="mord">♠</span></span></span></span> <code>\spadesuit</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">♠</mi></mrow><annotation encoding="application/x-tex">\spades</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8241em;vertical-align:-0.1296em;"></span><span class="mord">♠</span></span></span></span> <code>\spades</code></td>
</tr>
</tbody>
</table>
<p>Direct Input: <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">£</mi><mi mathvariant="normal">¥</mi><mi mathvariant="normal">∇</mi><mi mathvariant="normal">∞</mi><mo separator="true">⋅</mo><mi mathvariant="normal">∠</mi><mi mathvariant="normal">∡</mi><mi mathvariant="normal">∢</mi><mi mathvariant="normal">♠</mi><mi mathvariant="normal">♡</mi><mi mathvariant="normal">♢</mi><mi mathvariant="normal">♣</mi><mi mathvariant="normal">♭</mi><mi mathvariant="normal">♮</mi><mi mathvariant="normal">♯</mi><mi mathvariant="normal">✓</mi><mo>…</mo><mi><mi mathvariant="normal">⋮</mi><mpadded height="0em" voffset="0em"><mspace mathbackground="black" width="0em" height="1.5em"></mspace></mpadded></mi><mo>⋯</mo><mo>⋱</mo><mo stretchy="false">!</mo></mrow><annotation encoding="application/x-tex">£ ¥ ∇ ∞ · ∠ ∡ ∢ ♠ ♡ ♢ ♣ ♭ ♮ ♯ ✓ …  ⋮  ⋯  ⋱  !</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.6944em;vertical-align:-0.1944em;"></span><span class="mord">£</span><span class="mord amsrm" style="margin-right:0.025em;">¥</span><span class="mord">∇∞</span><span class="mpunct">⋅</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord">∠</span><span class="mord amsrm">∡∢</span><span class="mord">♠♡♢♣♭♮♯</span><span class="mord amsrm">✓</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner">…</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord">⋮</span><span class="mord rule" style="border-right-width:0em;border-top-width:1.5em;bottom:0em;"></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner">⋯⋱</span><span class="mclose">!</span></span></span></span> ‼</p>
<h2 id="_13-units" tabindex="-1">13: Units <a class="header-anchor" href="#_13-units" aria-label="Permalink to &quot;13: Units&quot;">&ZeroWidthSpace;</a></h2>
<p>In KaTeX, units are proportioned as they are in TeX. KaTeX units are different than CSS units.</p>
<table>
<thead>
<tr>
<th style="text-align:left">KaTeX Unit</th>
<th style="text-align:left">Value</th>
<th style="text-align:left">KaTeX Unit</th>
<th style="text-align:left">Value</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">em</td>
<td style="text-align:left">CSS em</td>
<td style="text-align:left">bp</td>
<td style="text-align:left">1/72​ inch × F × G</td>
</tr>
<tr>
<td style="text-align:left">ex</td>
<td style="text-align:left">CSS ex</td>
<td style="text-align:left">pc</td>
<td style="text-align:left">12 KaTeX pt</td>
</tr>
<tr>
<td style="text-align:left">mu</td>
<td style="text-align:left">1/18 CSS em</td>
<td style="text-align:left">dd</td>
<td style="text-align:left">1238/1157​ KaTeX pt</td>
</tr>
<tr>
<td style="text-align:left">pt</td>
<td style="text-align:left">1/72.27 inch × F × G</td>
<td style="text-align:left">cc</td>
<td style="text-align:left">14856/1157 KaTeX pt</td>
</tr>
<tr>
<td style="text-align:left">mm</td>
<td style="text-align:left">1 mm × F × G</td>
<td style="text-align:left">nd</td>
<td style="text-align:left">685/642 KaTeX pt</td>
</tr>
<tr>
<td style="text-align:left">cm</td>
<td style="text-align:left">1 cm × F × G</td>
<td style="text-align:left">nc</td>
<td style="text-align:left">1370/107​ KaTeX pt</td>
</tr>
<tr>
<td style="text-align:left">in</td>
<td style="text-align:left">1 inch × F × G</td>
<td style="text-align:left">sp</td>
<td style="text-align:left">1/65536 KaTeX pt</td>
</tr>
</tbody>
</table>
<p>where:</p>
<ul>
<li>
<p>F = (font size of surrounding HTML text)/(10 pt)</p>
</li>
<li>
<p>G = 1.21 by default, because KaTeX font-size is normally 1.21 × the surrounding font size. This value can be overridden by the CSS of an HTML page.</p>
</li>
</ul>
<p>The effect of style and size:</p>
<table>
<thead>
<tr>
<th style="text-align:center">Unit</th>
<th style="text-align:center">textstyle</th>
<th style="text-align:center">scriptscript</th>
<th style="text-align:center">huge</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:center">em or ex</td>
<td style="text-align:center"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mpadded height="0em" voffset="0em"><mspace mathbackground="black" width="1em" height="1em"></mspace></mpadded></mrow><annotation encoding="application/x-tex">\rule{1em}{1em}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;"></span><span class="mord rule" style="border-right-width:1em;border-top-width:1em;bottom:0em;"></span></span></span></span></td>
<td style="text-align:center"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle scriptlevel="2" displaystyle="false"><mpadded height="0em" voffset="0em"><mspace mathbackground="black" width="2em" height="2em"></mspace></mpadded></mstyle></mrow><annotation encoding="application/x-tex">\scriptscriptstyle\rule{1em}{1em}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;"></span><span class="mord rule mtight sizing reset-size6 size1" style="border-right-width:2em;border-top-width:2em;bottom:0em;"></span></span></span></span></td>
<td style="text-align:center"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathsize="2.074em"><mpadded height="0em" voffset="0em"><mspace mathbackground="black" width="1em" height="1em"></mspace></mpadded></mstyle></mrow><annotation encoding="application/x-tex">\huge\rule{1em}{1em}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.074em;"></span><span class="mord rule sizing reset-size6 size10" style="border-right-width:1em;border-top-width:1em;bottom:0em;"></span></span></span></span></td>
</tr>
<tr>
<td style="text-align:center">mu</td>
<td style="text-align:center"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mpadded height="0em" voffset="0em"><mspace mathbackground="black" width="1em" height="1em"></mspace></mpadded></mrow><annotation encoding="application/x-tex">\rule{18mu}{18mu}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;"></span><span class="mord rule" style="border-right-width:1em;border-top-width:1em;bottom:0em;"></span></span></span></span></td>
<td style="text-align:center"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle scriptlevel="2" displaystyle="false"><mpadded height="0em" voffset="0em"><mspace mathbackground="black" width="1.472em" height="1.472em"></mspace></mpadded></mstyle></mrow><annotation encoding="application/x-tex">\scriptscriptstyle\rule{18mu}{18mu}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.736em;"></span><span class="mord rule mtight sizing reset-size6 size1" style="border-right-width:1.472em;border-top-width:1.472em;bottom:0em;"></span></span></span></span></td>
<td style="text-align:center"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathsize="2.074em"><mpadded height="0em" voffset="0em"><mspace mathbackground="black" width="1em" height="1em"></mspace></mpadded></mstyle></mrow><annotation encoding="application/x-tex">\huge\rule{18mu}{18mu}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.074em;"></span><span class="mord rule sizing reset-size6 size10" style="border-right-width:1em;border-top-width:1em;bottom:0em;"></span></span></span></span></td>
</tr>
<tr>
<td style="text-align:center">others</td>
<td style="text-align:center"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mpadded height="0em" voffset="0em"><mspace mathbackground="black" width="1em" height="1em"></mspace></mpadded></mrow><annotation encoding="application/x-tex">\rule{10pt}{10pt}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;"></span><span class="mord rule" style="border-right-width:1em;border-top-width:1em;bottom:0em;"></span></span></span></span></td>
<td style="text-align:center"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle scriptlevel="2" displaystyle="false"><mpadded height="0em" voffset="0em"><mspace mathbackground="black" width="2em" height="2em"></mspace></mpadded></mstyle></mrow><annotation encoding="application/x-tex">\scriptscriptstyle\rule{10pt}{10pt}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;"></span><span class="mord rule mtight sizing reset-size6 size1" style="border-right-width:2em;border-top-width:2em;bottom:0em;"></span></span></span></span></td>
<td style="text-align:center"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathsize="2.074em"><mpadded height="0em" voffset="0em"><mspace mathbackground="black" width="0.4822em" height="0.4822em"></mspace></mpadded></mstyle></mrow><annotation encoding="application/x-tex">\huge\rule{10pt}{10pt}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;"></span><span class="mord rule sizing reset-size6 size10" style="border-right-width:0.4822em;border-top-width:0.4822em;bottom:0em;"></span></span></span></span></td>
</tr>
</tbody>
</table>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[KaTeX: Support table]]></title>
            <link>https://note.toshiki.devapplication/markdown-it-katex/support-table</link>
            <guid>https://note.toshiki.devapplication/markdown-it-katex/support-table</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="katex-support-table" tabindex="-1">KaTeX: Support table <a class="header-anchor" href="#katex-support-table" aria-label="Permalink to &quot;KaTeX: Support table&quot;">&ZeroWidthSpace;</a></h1>
<div class="tip custom-block"><p class="custom-block-title">note</p>
<p>This is an direct shameful copy of the documentation pulled from <a href="https://raw.githubusercontent.com/Khan/KaTeX/master/docs/supported.md" target="_blank" rel="noreferrer">KaTeX</a> documentation, <strong>I do not own any of the content below on behalf of this part of the documentation</strong>, the table might be outdated as versions migrates, please also refer to <a href="https://katex.org/docs/supported.html" target="_blank" rel="noreferrer">KaTeX's official documentation</a>.</p>
</div>
<h2 id="symbols" tabindex="-1">Symbols <a class="header-anchor" href="#symbols" aria-label="Permalink to &quot;Symbols&quot;">&ZeroWidthSpace;</a></h2>
<table>
<thead>
<tr>
<th style="text-align:left">Symbol/Function</th>
<th style="text-align:left">Rendered</th>
<th style="text-align:left">Source or Comment</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">!</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>n</mi><mo stretchy="false">!</mo></mrow><annotation encoding="application/x-tex">n!</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">n</span><span class="mclose">!</span></span></span></span></td>
<td style="text-align:left"><code>n!</code></td>
</tr>
<tr>
<td style="text-align:left">\!</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mtext> ⁣</mtext><mi>b</mi></mrow><annotation encoding="application/x-tex">a\!b</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">a</span><span class="mspace" style="margin-right:-0.1667em;"></span><span class="mord mathnormal">b</span></span></span></span></td>
<td style="text-align:left"><code>a\!b</code></td>
</tr>
<tr>
<td style="text-align:left">#</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msup><mi>y</mi><mn>2</mn></msup></mrow><annotation encoding="application/x-tex">\def\bar#1{#1^2} \bar{y}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0085em;vertical-align:-0.1944em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">y</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\def\bar#1{#1^2} \bar{y}</code></td>
</tr>
<tr>
<td style="text-align:left">\#</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">#</mi></mrow><annotation encoding="application/x-tex">\#</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord">#</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">%</td>
<td style="text-align:left"></td>
<td style="text-align:left"><code>%this is a comment</code></td>
</tr>
<tr>
<td style="text-align:left">\%</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">%</mi></mrow><annotation encoding="application/x-tex">\%</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8056em;vertical-align:-0.0556em;"></span><span class="mord">%</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">&amp;</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mtable rowspacing="0.16em" columnalign="center center" columnspacing="1em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>a</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>b</mi></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>c</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>d</mi></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{matrix} a &amp; b\cr c &amp; d \end{matrix}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.4em;vertical-align:-0.95em;"></span><span class="mord"><span class="mtable"><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:0.5em;"></span><span class="arraycolsep" style="width:0.5em;"></span><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">b</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">d</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\begin{matrix}</code><br>   <code>a &amp; b \\</code><br>   <code>c &amp; d</code><br><code>\end{matrix}</code></td>
</tr>
<tr>
<td style="text-align:left">\&amp;</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">&amp;</mi></mrow><annotation encoding="application/x-tex">\&amp;</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">&amp;</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">'</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msup><mrow></mrow><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup></mrow><annotation encoding="application/x-tex">&#x27;</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7519em;"></span><span class="mord"><span></span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7519em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\'</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mtext>a</mtext><mo>ˊ</mo></mover></mrow><annotation encoding="application/x-tex">\text{\&#x27;{a}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6944em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">a</span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.25em;"><span class="mord">ˊ</span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\'{a}}</code></td>
</tr>
<tr>
<td style="text-align:left">(</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">(</mo></mrow><annotation encoding="application/x-tex">(</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">(</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">)</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mclose">)</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\(…\)</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle scriptlevel="0" displaystyle="false"><mfrac><mi>a</mi><mi>b</mi></mfrac></mstyle></mrow><annotation encoding="application/x-tex">\text{\(\frac a b\)}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0404em;vertical-align:-0.345em;"></span><span class="mord text"><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6954em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">b</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">a</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\(\frac a b\)}</code></td>
</tr>
<tr>
<td style="text-align:left">\</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mtext> </mtext><mi>b</mi></mrow><annotation encoding="application/x-tex">a\ b</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">a</span><span class="mspace"> </span><span class="mord mathnormal">b</span></span></span></span></td>
<td style="text-align:left"><code>a\ b</code></td>
</tr>
<tr>
<td style="text-align:left">\&quot;</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mtext>a</mtext><mo>¨</mo></mover></mrow><annotation encoding="application/x-tex">\text{\&quot;{a}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6679em;"></span><span class="mord text"><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6679em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">a</span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.25em;"><span class="mord">¨</span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\&quot;{a}}</code></td>
</tr>
<tr>
<td style="text-align:left">\$</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>$</mtext></mrow><annotation encoding="application/x-tex">\text{\textdollar}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8056em;vertical-align:-0.0556em;"></span><span class="mord text"><span class="mord">$</span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\,</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mtext> </mtext><mtext> </mtext><mi>b</mi></mrow><annotation encoding="application/x-tex">a\,\,{b}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">a</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal">b</span></span></span></span></span></td>
<td style="text-align:left"><code>a\,\,{b}</code></td>
</tr>
<tr>
<td style="text-align:left">\.</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mtext>a</mtext><mo>˙</mo></mover></mrow><annotation encoding="application/x-tex">\text{\.{a}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6679em;"></span><span class="mord text"><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6679em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">a</span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.1389em;"><span class="mord">˙</span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\.{a}}</code></td>
</tr>
<tr>
<td style="text-align:left">\:</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mtext> </mtext><mtext> </mtext><mi>b</mi></mrow><annotation encoding="application/x-tex">a\:\:{b}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">a</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal">b</span></span></span></span></span></td>
<td style="text-align:left"><code>a\:\:{b}</code></td>
</tr>
<tr>
<td style="text-align:left">\;</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mtext>  </mtext><mtext>  </mtext><mi>b</mi></mrow><annotation encoding="application/x-tex">a\;\;{b}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">a</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mord mathnormal">b</span></span></span></span></span></td>
<td style="text-align:left">a<code>\;\;{b}</code></td>
</tr>
<tr>
<td style="text-align:left">_</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>x</mi><mi>i</mi></msub></mrow><annotation encoding="application/x-tex">x_i</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>x_i</code></td>
</tr>
<tr>
<td style="text-align:left">\_</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">_</mi></mrow><annotation encoding="application/x-tex">\_</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;vertical-align:-0.31em;"></span><span class="mord" style="margin-right:0.02778em;">_</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\<code>`</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mtext>a</mtext><mo>ˋ</mo></mover></mrow><annotation encoding="application/x-tex">\text{\`{a}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6944em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">a</span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.25em;"><span class="mord">ˋ</span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\'{a}}</code></td>
</tr>
<tr>
<td style="text-align:left">&lt;</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>&lt;</mo></mrow><annotation encoding="application/x-tex">&lt;</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">&lt;</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\=</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mtext>a</mtext><mo>ˉ</mo></mover></mrow><annotation encoding="application/x-tex">\text{\={a}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5678em;"></span><span class="mord text"><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.5678em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">a</span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.25em;"><span class="mord">ˉ</span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\\={a}}</code></td>
</tr>
<tr>
<td style="text-align:left">&gt;</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>&gt;</mo></mrow><annotation encoding="application/x-tex">&gt;</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">&gt;</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\&gt;</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mtext> </mtext><mtext> </mtext><mi>b</mi></mrow><annotation encoding="application/x-tex">a\&gt;\&gt;{b}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">a</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal">b</span></span></span></span></span></td>
<td style="text-align:left"><code>a\&gt;\&gt;{b}</code></td>
</tr>
<tr>
<td style="text-align:left">[</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">[</mo></mrow><annotation encoding="application/x-tex">[</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">[</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">]</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">]</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mclose">]</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">{</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi></mrow><annotation encoding="application/x-tex">{a}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span></span></span></td>
<td style="text-align:left"><code>{a}</code></td>
</tr>
<tr>
<td style="text-align:left">}</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi></mrow><annotation encoding="application/x-tex">{a}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span></span></span></td>
<td style="text-align:left"><code>{a}</code></td>
</tr>
<tr>
<td style="text-align:left">\{</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">{</mo></mrow><annotation encoding="application/x-tex">\{</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">{</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\}</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">}</mo></mrow><annotation encoding="application/x-tex">\}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mclose">}</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">|</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∣</mi></mrow><annotation encoding="application/x-tex">\vert</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">∣</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\|</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∥</mi></mrow><annotation encoding="application/x-tex">\Vert</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">∥</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">~</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>no no no breaks</mtext></mrow><annotation encoding="application/x-tex">\text{no~no~no~breaks}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord">no</span><span class="mord nobreak"> </span><span class="mord">no</span><span class="mord nobreak"> </span><span class="mord">no</span><span class="mord nobreak"> </span><span class="mord">breaks</span></span></span></span></span></td>
<td style="text-align:left"><code>\text{no~no~no~breaks}</code></td>
</tr>
<tr>
<td style="text-align:left">\~</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mtext>a</mtext><mo>˜</mo></mover></mrow><annotation encoding="application/x-tex">\text{\~{a}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6679em;"></span><span class="mord text"><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6679em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">a</span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.25em;"><span class="mord">˜</span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\\~{a}}</code></td>
</tr>
<tr>
<td style="text-align:left">\\</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mtable rowspacing="0.16em" columnalign="center center" columnspacing="1em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>a</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>b</mi></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>c</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>d</mi></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{matrix} a &amp; b\\ c &amp; d\end{matrix}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.4em;vertical-align:-0.95em;"></span><span class="mord"><span class="mtable"><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:0.5em;"></span><span class="arraycolsep" style="width:0.5em;"></span><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">b</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">d</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\begin{matrix}</code><br>   <code>a &amp; b \\</code><br>   <code>c &amp; d</code><br><code>\end{matrix}</code></td>
</tr>
<tr>
<td style="text-align:left">^</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msup><mi>x</mi><mi>i</mi></msup></mrow><annotation encoding="application/x-tex">x^i</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8247em;"></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8247em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>x^i</code></td>
</tr>
<tr>
<td style="text-align:left">\^</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mtext>a</mtext><mo>ˆ</mo></mover></mrow><annotation encoding="application/x-tex">\text{\^{a}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6944em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">a</span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.25em;"><span class="mord">ˆ</span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\\^{a}}</code></td>
</tr>
</tbody>
</table>
<h2 id="a" tabindex="-1">A <a class="header-anchor" href="#a" aria-label="Permalink to &quot;A&quot;">&ZeroWidthSpace;</a></h2>
<table>
<thead>
<tr>
<th style="text-align:left">Symbol/Function</th>
<th style="text-align:left">Rendered</th>
<th style="text-align:left">Source or Comment</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">\AA</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mtext>A</mtext><mo>˚</mo></mover></mrow><annotation encoding="application/x-tex">\text{\AA}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9468em;"></span><span class="mord text"><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.9468em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord">A</span></span><span style="top:-3.2523em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.375em;"><span class="mord">˚</span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\AA}</code></td>
</tr>
<tr>
<td style="text-align:left">\aa</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mtext>a</mtext><mo>˚</mo></mover></mrow><annotation encoding="application/x-tex">\text{\aa}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6944em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord">a</span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.375em;"><span class="mord">˚</span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\aa}</code></td>
</tr>
<tr>
<td style="text-align:left">\above</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mfrac linethickness="0.2em"><mi>a</mi><mrow><mi>b</mi><mo>+</mo><mn>1</mn></mrow></mfrac></mrow><annotation encoding="application/x-tex">{a \above{2pt} b+1}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.4458em;vertical-align:-0.5944em;"></span><span class="mord"><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8514em;"><span style="top:-2.4639em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">b</span><span class="mbin mtight">+</span><span class="mord mtight">1</span></span></span></span><span style="top:-3.15em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.2em;"></span></span><span style="top:-3.55em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">a</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.5944em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span></span></td>
<td style="text-align:left"><code>{a \above{2pt} b+1}</code></td>
</tr>
<tr>
<td style="text-align:left">\abovewithdelims</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\acute</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mi>e</mi><mo>ˊ</mo></mover></mrow><annotation encoding="application/x-tex">\acute e</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6944em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord mathnormal">e</span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.1944em;"><span class="mord">ˊ</span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\acute e</code></td>
</tr>
<tr>
<td style="text-align:left">\AE</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>Æ</mtext></mrow><annotation encoding="application/x-tex">\text{\AE}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord text"><span class="mord">Æ</span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\AE}</code></td>
</tr>
<tr>
<td style="text-align:left">\ae</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>æ</mtext></mrow><annotation encoding="application/x-tex">\text{\ae}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord text"><span class="mord">æ</span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\ae}</code></td>
</tr>
<tr>
<td style="text-align:left">\alef</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">ℵ</mi></mrow><annotation encoding="application/x-tex">\alef</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">ℵ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\alefsym</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">ℵ</mi></mrow><annotation encoding="application/x-tex">\alefsym</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">ℵ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\aleph</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">ℵ</mi></mrow><annotation encoding="application/x-tex">\aleph</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">ℵ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left" align=""></td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left">see <code>{aligned}</code></td>
</tr>
<tr>
<td style="text-align:left" aligned=""></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mtable rowspacing="0.25em" columnalign="right left" columnspacing="0em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mi>a</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mo>=</mo><mi>b</mi><mo>+</mo><mi>c</mi></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mi>d</mi><mo>+</mo><mi>e</mi></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mo>=</mo><mi>f</mi></mrow></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{aligned}a&amp;=b+c\\d+e&amp;=f\end{aligned}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:3em;vertical-align:-1.25em;"></span><span class="mord"><span class="mtable"><span class="col-align-r"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.75em;"><span style="top:-3.91em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">d</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal">e</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.25em;"><span></span></span></span></span></span><span class="col-align-l"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.75em;"><span style="top:-3.91em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord mathnormal">b</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal">c</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord mathnormal" style="margin-right:0.10764em;">f</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.25em;"><span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\begin{aligned}</code><br>   <code>a&amp;=b+c \\</code><br>   <code>d+e&amp;=f</code><br><code>\end{aligned}</code></td>
</tr>
<tr>
<td style="text-align:left" alignat=""></td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left">see <code>{alignedat}</code></td>
</tr>
<tr>
<td style="text-align:left" alignedat=""></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mtable rowspacing="0.25em" columnalign="right left right left" columnspacing="0em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mn>10</mn></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mi>x</mi><mo>+</mo></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mn>3</mn></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mi>y</mi><mo>=</mo><mn>2</mn></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mn>3</mn></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mi>x</mi><mo>+</mo></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mn>13</mn></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mi>y</mi><mo>=</mo><mn>4</mn></mrow></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{alignedat}{2}10&amp;x+&amp;3&amp;y=2\\3&amp;x+&amp;13&amp;y=4\end{alignedat}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:3em;vertical-align:-1.25em;"></span><span class="mord"><span class="mtable"><span class="col-align-r"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.75em;"><span style="top:-3.91em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">10</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">3</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.25em;"><span></span></span></span></span></span><span class="col-align-l"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.75em;"><span style="top:-3.91em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"></span><span class="mord mathnormal">x</span><span class="mord">+</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"></span><span class="mord mathnormal">x</span><span class="mord">+</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.25em;"><span></span></span></span></span></span><span class="col-align-r"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.75em;"><span style="top:-3.91em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">3</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">13</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.25em;"><span></span></span></span></span></span><span class="col-align-l"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.75em;"><span style="top:-3.91em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"></span><span class="mord mathnormal" style="margin-right:0.03588em;">y</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord">2</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"></span><span class="mord mathnormal" style="margin-right:0.03588em;">y</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord">4</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.25em;"><span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\begin{alignedat}{2}</code><br>   <code>10&amp;x+ &amp;3&amp;y = 2 \\</code><br>   <code> 3&amp;x+&amp;13&amp;y = 4</code><br><code>\end{alignedat}</code></td>
</tr>
<tr>
<td style="text-align:left">\allowbreak</td>
<td style="text-align:left"></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Alpha</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">A</mi></mrow><annotation encoding="application/x-tex">\Alpha</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathrm">A</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\alpha</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>α</mi></mrow><annotation encoding="application/x-tex">\alpha</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal" style="margin-right:0.0037em;">α</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\amalg</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⨿</mo></mrow><annotation encoding="application/x-tex">\amalg</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">⨿</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\And</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>&amp;</mo></mrow><annotation encoding="application/x-tex">\And</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">&amp;</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\and</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"><a href="https://en.wikipedia.org/wiki/Help:Displaying_a_formula#Deprecated_syntax" target="_blank" rel="noreferrer">Deprecated</a></td>
</tr>
<tr>
<td style="text-align:left">\ang</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"><a href="https://en.wikipedia.org/wiki/Help:Displaying_a_formula#Deprecated_syntax" target="_blank" rel="noreferrer">Deprecated</a></td>
</tr>
<tr>
<td style="text-align:left">\angl</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\angle</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∠</mi></mrow><annotation encoding="application/x-tex">\angle</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mord">∠</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\approx</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≈</mo></mrow><annotation encoding="application/x-tex">\approx</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4831em;"></span><span class="mrel">≈</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\approxeq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≊</mo></mrow><annotation encoding="application/x-tex">\approxeq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6633em;vertical-align:-0.0817em;"></span><span class="mrel amsrm">≊</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\arccos</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>arccos</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\arccos</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mop">arccos</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\arcctg</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>arcctg</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\arcctg</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8095em;vertical-align:-0.1944em;"></span><span class="mop">arcct<span style="margin-right:0.01389em;">g</span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\arcsin</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>arcsin</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\arcsin</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6679em;"></span><span class="mop">arcsin</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\arctan</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>arctan</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\arctan</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6151em;"></span><span class="mop">arctan</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\arctg</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>arctg</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\arctg</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8095em;vertical-align:-0.1944em;"></span><span class="mop">arct<span style="margin-right:0.01389em;">g</span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\arg</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>arg</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\arg</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mop">ar<span style="margin-right:0.01389em;">g</span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\argmax</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">arg max</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\argmax</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mop"><span class="mord mathrm" style="margin-right:0.01389em;">arg</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathrm">max</span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\argmin</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">arg min</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\argmin</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8623em;vertical-align:-0.1944em;"></span><span class="mop"><span class="mord mathrm" style="margin-right:0.01389em;">arg</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathrm">min</span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left" array=""></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mtable rowspacing="0.16em" columnalign="center center" columnspacing="1em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>a</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>b</mi></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>c</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>d</mi></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{array}{cc}a&amp;b\\c&amp;d\end{array}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.4em;vertical-align:-0.95em;"></span><span class="mord"><span class="mtable"><span class="arraycolsep" style="width:0.5em;"></span><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:0.5em;"></span><span class="arraycolsep" style="width:0.5em;"></span><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">b</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">d</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:0.5em;"></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\begin{array}{cc}</code><br>   <code>a &amp; b \\</code><br>   <code>c &amp; d</code><br><code>\end{array}</code></td>
</tr>
<tr>
<td style="text-align:left">\array</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left">see <code>{array}</code></td>
</tr>
<tr>
<td style="text-align:left">\arraystretch</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mtable rowspacing="0.66em" columnalign="center center" columnspacing="1em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>a</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>b</mi></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>c</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>d</mi></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\def\arraystretch{1.5}\begin{array}{cc}a&amp;b\\c&amp;d\end{array}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:3.6em;vertical-align:-1.55em;"></span><span class="mord"><span class="mtable"><span class="arraycolsep" style="width:0.5em;"></span><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:2.05em;"><span style="top:-4.05em;"><span class="pstrut" style="height:3.26em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span><span style="top:-2.25em;"><span class="pstrut" style="height:3.26em;"></span><span class="mord"><span class="mord mathnormal">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.55em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:0.5em;"></span><span class="arraycolsep" style="width:0.5em;"></span><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:2.05em;"><span style="top:-4.05em;"><span class="pstrut" style="height:3.26em;"></span><span class="mord"><span class="mord mathnormal">b</span></span></span><span style="top:-2.25em;"><span class="pstrut" style="height:3.26em;"></span><span class="mord"><span class="mord mathnormal">d</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.55em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:0.5em;"></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\def\arraystretch{1.5}</code><br><code>\begin{array}{cc}</code><br>   <code>a &amp; b \\</code><br>   <code>c &amp; d</code><br><code>\end{array}</code></td>
</tr>
<tr>
<td style="text-align:left">\Arrowvert</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\arrowvert</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\ast</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∗</mo></mrow><annotation encoding="application/x-tex">\ast</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4653em;"></span><span class="mord">∗</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\asymp</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≍</mo></mrow><annotation encoding="application/x-tex">\asymp</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4637em;"></span><span class="mrel">≍</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\atop</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mfrac linethickness="0px"><mi>a</mi><mi>b</mi></mfrac></mrow><annotation encoding="application/x-tex">{a \atop b}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0904em;vertical-align:-0.345em;"></span><span class="mord"><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.7454em;"><span style="top:-2.355em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">b</span></span></span></span><span style="top:-3.144em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">a</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span></span></td>
<td style="text-align:left"><code>{a \atop b}</code></td>
</tr>
<tr>
<td style="text-align:left">\atopwithdelims</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
</tbody>
</table>
<h2 id="b" tabindex="-1">B <a class="header-anchor" href="#b" aria-label="Permalink to &quot;B&quot;">&ZeroWidthSpace;</a></h2>
<p>| Symbol/Function     | Rendered                                            | Source or Comment                                                                                 |
| :------------------ | :-------------------------------------------------- | :------------------------------------------------------------------------------------------------ | ------ |
| \backepsilon        | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∍</mo></mrow><annotation encoding="application/x-tex">\backepsilon</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mrel amsrm">∍</span></span></span></span>                                      |                                                                                                   |
| \backprime          | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">‵</mi></mrow><annotation encoding="application/x-tex">\backprime</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5499em;"></span><span class="mord amsrm">‵</span></span></span></span>                                        |                                                                                                   |
| \backsim            | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∽</mo></mrow><annotation encoding="application/x-tex">\backsim</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3779em;"></span><span class="mrel amsrm">∽</span></span></span></span>                                          |                                                                                                   |
| \backsimeq          | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋍</mo></mrow><annotation encoding="application/x-tex">\backsimeq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.464em;"></span><span class="mrel amsrm">⋍</span></span></span></span>                                        |                                                                                                   |
| \backslash          | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">\</mi></mrow><annotation encoding="application/x-tex">\backslash</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">\</span></span></span></span>                                        |                                                                                                   |
| \bar                | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mi>y</mi><mo>ˉ</mo></mover></mrow><annotation encoding="application/x-tex">\bar{y}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7622em;vertical-align:-0.1944em;"></span><span class="mord accent"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.5678em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">y</span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.1944em;"><span class="mord">ˉ</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.1944em;"><span></span></span></span></span></span></span></span></span>                                           | <code>\bar{y}</code>                                                                                         |
| \barwedge           | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊼</mo></mrow><annotation encoding="application/x-tex">\barwedge</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8867em;vertical-align:-0.1944em;"></span><span class="mord amsrm">⊼</span></span></span></span>                                         |                                                                                                   |
| \Bbb                | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="double-struck">A</mi><mi mathvariant="double-struck">B</mi><mi mathvariant="double-struck">C</mi></mrow><annotation encoding="application/x-tex">\Bbb{ABC}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord"><span class="mord mathbb">ABC</span></span></span></span></span>                                         | <code>\Bbb{ABC}</code><br>KaTeX supports A-Z &amp; k                                                             |
| \Bbbk               | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="double-struck">k</mi></mrow><annotation encoding="application/x-tex">\Bbbk</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord mathbb">k</span></span></span></span>                                             |                                                                                                   |
| \bbox               | <span style="color:firebrick;">Not supported</span> |                                                                                                   |
| \bcancel            | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><menclose notation="downdiagonalstrike"><mn>5</mn></menclose></mrow><annotation encoding="application/x-tex">\bcancel{5}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8444em;"><span style="top:-3.0444em;"><span class="pstrut" style="height:3.0444em;"></span><span class="mord"><span class="mord">5</span></span></span><span class="svg-align" style="top:-2.8444em;"><span class="pstrut" style="height:3.0444em;"></span><span style="height:1.0444em;"><svg xmlns="http://www.w3.org/2000/svg" width='100%' height='1.0444em'><line x1='0' y1='0' x2='100%' y2='100%' stroke-width='0.046em'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2em;"><span></span></span></span></span></span></span></span></span>                                       | <code>\bcancel{5}</code>                                                                                     |
| \because            | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∵</mo></mrow><annotation encoding="application/x-tex">\because</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mrel amsrm">∵</span></span></span></span>                                          |                                                                                                   |
| \begin              | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mtable rowspacing="0.16em" columnalign="center center" columnspacing="1em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>a</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>b</mi></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>c</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>d</mi></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{matrix} a &amp; b\\ c &amp; d\end{matrix}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.4em;vertical-align:-0.95em;"></span><span class="mord"><span class="mtable"><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:0.5em;"></span><span class="arraycolsep" style="width:0.5em;"></span><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">b</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">d</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span></span></span></span></span></span>          | <code>\begin{matrix}</code><br>   <code>a &amp; b \\</code><br>   <code>c &amp; d</code><br><code>\end{matrix}</code>   |
| \begingroup         | <span class='katex-error' title='ParseError: KaTeX parse error: Expected &#039;\endgroup&#039;, got &#039;}&#039; at position 14: \begingroup a}̲'>\begingroup a}</span>                                    | <code>\begingroup a}</code>                                                                                  |
| \Beta               | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">B</mi></mrow><annotation encoding="application/x-tex">\Beta</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathrm">B</span></span></span></span>                                             |                                                                                                   |
| \beta               | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>β</mi></mrow><annotation encoding="application/x-tex">\beta</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.05278em;">β</span></span></span></span>                                             |                                                                                                   |
| \beth               | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">ℶ</mi></mrow><annotation encoding="application/x-tex">\beth</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord amsrm">ℶ</span></span></span></span>                                             |                                                                                                   |
| \between            | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≬</mo></mrow><annotation encoding="application/x-tex">\between</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0117em;vertical-align:-0.2558em;"></span><span class="mrel amsrm">≬</span></span></span></span>                                          |                                                                                                   |
| \bf                 | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="bold">A</mi><mi mathvariant="bold">a</mi><mi mathvariant="bold">B</mi><mi mathvariant="bold">b</mi><mn mathvariant="bold">12</mn></mrow><annotation encoding="application/x-tex">\bf AaBb12</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord"><span class="mord mathbf">AaBb12</span></span></span></span></span>                                        | <code>\bf AaBb12</code>                                                                                      |
| \bfseries           | <span style="color:firebrick;">Not supported</span> |                                                                                                   |
| \big                | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="false" stretchy="true" minsize="1.2em" maxsize="1.2em">(</mo><mo fence="false" stretchy="true" minsize="1.2em" maxsize="1.2em">)</mo></mrow><annotation encoding="application/x-tex">\big(\big)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2em;vertical-align:-0.35em;"></span><span class="mord"><span class="delimsizing size1">(</span></span><span class="mord"><span class="delimsizing size1">)</span></span></span></span></span>                                        | <code>\big(\big)</code>                                                                                      |
| \Big                | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="false" stretchy="true" minsize="1.8em" maxsize="1.8em">(</mo><mo fence="false" stretchy="true" minsize="1.8em" maxsize="1.8em">)</mo></mrow><annotation encoding="application/x-tex">\Big(\Big)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.8em;vertical-align:-0.65em;"></span><span class="mord"><span class="delimsizing size2">(</span></span><span class="mord"><span class="delimsizing size2">)</span></span></span></span></span>                                        | <code>\Big(\Big)</code>                                                                                      |
| \bigcap             | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋂</mo></mrow><annotation encoding="application/x-tex">\bigcap</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mop op-symbol small-op" style="position:relative;top:0em;">⋂</span></span></span></span>                                           |                                                                                                   |
| \bigcirc            | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>◯</mo></mrow><annotation encoding="application/x-tex">\bigcirc</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord">◯</span></span></span></span>                                          |                                                                                                   |
| \bigcup             | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋃</mo></mrow><annotation encoding="application/x-tex">\bigcup</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mop op-symbol small-op" style="position:relative;top:0em;">⋃</span></span></span></span>                                           |                                                                                                   |
| \bigg               | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="false" stretchy="true" minsize="2.4em" maxsize="2.4em">(</mo><mo fence="false" stretchy="true" minsize="2.4em" maxsize="2.4em">)</mo></mrow><annotation encoding="application/x-tex">\bigg(\bigg)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.4em;vertical-align:-0.95em;"></span><span class="mord"><span class="delimsizing size3">(</span></span><span class="mord"><span class="delimsizing size3">)</span></span></span></span></span>                                      | <code>\bigg(\bigg)</code>                                                                                    |
| \Bigg               | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="false" stretchy="true" minsize="3em" maxsize="3em">(</mo><mo fence="false" stretchy="true" minsize="3em" maxsize="3em">)</mo></mrow><annotation encoding="application/x-tex">\Bigg(\Bigg)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:3em;vertical-align:-1.25em;"></span><span class="mord"><span class="delimsizing size4">(</span></span><span class="mord"><span class="delimsizing size4">)</span></span></span></span></span>                                      | <code>\Bigg(\Bigg)</code>                                                                                    |
| \biggl              | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true" stretchy="true" minsize="2.4em" maxsize="2.4em">(</mo></mrow><annotation encoding="application/x-tex">\biggl(</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.4em;vertical-align:-0.95em;"></span><span class="mopen"><span class="delimsizing size3">(</span></span></span></span></span>                                           | <code>\biggl(</code>                                                                                         |
| \Biggl              | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true" stretchy="true" minsize="3em" maxsize="3em">(</mo></mrow><annotation encoding="application/x-tex">\Biggl(</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:3em;vertical-align:-1.25em;"></span><span class="mopen"><span class="delimsizing size4">(</span></span></span></span></span>                                           | <code>\Biggl(</code>                                                                                         |
| \biggm              | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="false" stretchy="true" minsize="2.4em" maxsize="2.4em">∣</mo></mrow><annotation encoding="application/x-tex">\biggm\vert</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.4em;vertical-align:-0.95em;"></span><span class="mrel"><span class="delimsizing mult"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.45em;"><span class="pstrut" style="height:4.4em;"></span><span style="width:0.333em;height:2.400em;"><svg xmlns="http://www.w3.org/2000/svg" width='0.333em' height='2.400em' viewBox='0 0 333 2400'><path d='M145 15 v585 v1200 v585 c2.667,10,9.667,15,21,15
c10,0,16.667,-5,20,-15 v-585 v-1200 v-585 c-2.667,-10,-9.667,-15,-21,-15
c-10,0,-16.667,5,-20,15z M188 15 H145 v585 v1200 v585 h43z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span></span></span></span></span>                                       | <code>\biggm\vert</code>                                                                                     |
| \Biggm              | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="false" stretchy="true" minsize="3em" maxsize="3em">∣</mo></mrow><annotation encoding="application/x-tex">\Biggm\vert</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:3em;vertical-align:-1.25em;"></span><span class="mrel"><span class="delimsizing mult"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.75em;"><span style="top:-3.75em;"><span class="pstrut" style="height:5em;"></span><span style="width:0.333em;height:3.000em;"><svg xmlns="http://www.w3.org/2000/svg" width='0.333em' height='3.000em' viewBox='0 0 333 3000'><path d='M145 15 v585 v1800 v585 c2.667,10,9.667,15,21,15
c10,0,16.667,-5,20,-15 v-585 v-1800 v-585 c-2.667,-10,-9.667,-15,-21,-15
c-10,0,-16.667,5,-20,15z M188 15 H145 v585 v1800 v585 h43z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.25em;"><span></span></span></span></span></span></span></span></span></span>                                       | <code>\Biggm\vert</code>                                                                                     |
| \biggr              | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true" stretchy="true" minsize="2.4em" maxsize="2.4em">)</mo></mrow><annotation encoding="application/x-tex">\biggr)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.4em;vertical-align:-0.95em;"></span><span class="mclose"><span class="delimsizing size3">)</span></span></span></span></span>                                           | <code>\biggr)</code>                                                                                         |
| \Biggr              | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true" stretchy="true" minsize="3em" maxsize="3em">)</mo></mrow><annotation encoding="application/x-tex">\Biggr)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:3em;vertical-align:-1.25em;"></span><span class="mclose"><span class="delimsizing size4">)</span></span></span></span></span>                                           | <code>\Biggr)</code>                                                                                         |
| \bigl               | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true" stretchy="true" minsize="1.2em" maxsize="1.2em">(</mo></mrow><annotation encoding="application/x-tex">\bigl(</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2em;vertical-align:-0.35em;"></span><span class="mopen"><span class="delimsizing size1">(</span></span></span></span></span>                                            | <code>\bigl(</code>                                                                                          |
| \Bigl               | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true" stretchy="true" minsize="1.8em" maxsize="1.8em">(</mo></mrow><annotation encoding="application/x-tex">\Bigl(</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.8em;vertical-align:-0.65em;"></span><span class="mopen"><span class="delimsizing size2">(</span></span></span></span></span>                                            | <code>\Bigl(</code>                                                                                          |
| \bigm               | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="false" stretchy="true" minsize="1.2em" maxsize="1.2em">∣</mo></mrow><annotation encoding="application/x-tex">\bigm\vert</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2em;vertical-align:-0.35em;"></span><span class="mrel"><span class="delimsizing mult"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.85em;"><span style="top:-2.85em;"><span class="pstrut" style="height:3.2em;"></span><span style="width:0.333em;height:1.200em;"><svg xmlns="http://www.w3.org/2000/svg" width='0.333em' height='1.200em' viewBox='0 0 333 1200'><path d='M145 15 v585 v0 v585 c2.667,10,9.667,15,21,15
c10,0,16.667,-5,20,-15 v-585 v0 v-585 c-2.667,-10,-9.667,-15,-21,-15
c-10,0,-16.667,5,-20,15z M188 15 H145 v585 v0 v585 h43z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.35em;"><span></span></span></span></span></span></span></span></span></span>                                        | <code>\bigm\vert</code>                                                                                      |
| \Bigm               | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="false" stretchy="true" minsize="1.8em" maxsize="1.8em">∣</mo></mrow><annotation encoding="application/x-tex">\Bigm\vert</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.8em;vertical-align:-0.65em;"></span><span class="mrel"><span class="delimsizing mult"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.15em;"><span style="top:-3.15em;"><span class="pstrut" style="height:3.8em;"></span><span style="width:0.333em;height:1.800em;"><svg xmlns="http://www.w3.org/2000/svg" width='0.333em' height='1.800em' viewBox='0 0 333 1800'><path d='M145 15 v585 v600 v585 c2.667,10,9.667,15,21,15
c10,0,16.667,-5,20,-15 v-585 v-600 v-585 c-2.667,-10,-9.667,-15,-21,-15
c-10,0,-16.667,5,-20,15z M188 15 H145 v585 v600 v585 h43z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.65em;"><span></span></span></span></span></span></span></span></span></span>                                        | <code>\Bigm\vert</code>                                                                                      |
| \bigodot            | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⨀</mo></mrow><annotation encoding="application/x-tex">\bigodot</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mop op-symbol small-op" style="position:relative;top:0em;">⨀</span></span></span></span>                                          |                                                                                                   |
| \bigominus          | <span style="color:firebrick;">Not supported</span> | <a href="https://github.com/KaTeX/KaTeX/issues/1222" target="_blank" rel="noreferrer">Issue #1222</a>                                         |
| \bigoplus           | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⨁</mo></mrow><annotation encoding="application/x-tex">\bigoplus</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mop op-symbol small-op" style="position:relative;top:0em;">⨁</span></span></span></span>                                         |                                                                                                   |
| \bigoslash          | <span style="color:firebrick;">Not supported</span> | <a href="https://github.com/KaTeX/KaTeX/issues/1222" target="_blank" rel="noreferrer">Issue #1222</a>                                         |
| \bigotimes          | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⨂</mo></mrow><annotation encoding="application/x-tex">\bigotimes</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mop op-symbol small-op" style="position:relative;top:0em;">⨂</span></span></span></span>                                        |                                                                                                   |
| \bigr               | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true" stretchy="true" minsize="1.2em" maxsize="1.2em">)</mo></mrow><annotation encoding="application/x-tex">\bigr)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2em;vertical-align:-0.35em;"></span><span class="mclose"><span class="delimsizing size1">)</span></span></span></span></span>                                            | <code>\bigr)</code>                                                                                          |
| \Bigr               | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true" stretchy="true" minsize="1.8em" maxsize="1.8em">)</mo></mrow><annotation encoding="application/x-tex">\Bigr)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.8em;vertical-align:-0.65em;"></span><span class="mclose"><span class="delimsizing size2">)</span></span></span></span></span>                                            | <code>\Bigr)</code>                                                                                          |
| \bigsqcap           | <span style="color:firebrick;">Not supported</span> | <a href="https://github.com/KaTeX/KaTeX/issues/1222" target="_blank" rel="noreferrer">Issue #1222</a>                                         |
| \bigsqcup           | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⨆</mo></mrow><annotation encoding="application/x-tex">\bigsqcup</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mop op-symbol small-op" style="position:relative;top:0em;">⨆</span></span></span></span>                                         |                                                                                                   |
| \bigstar            | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">★</mi></mrow><annotation encoding="application/x-tex">\bigstar</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8867em;vertical-align:-0.1944em;"></span><span class="mord amsrm">★</span></span></span></span>                                          |                                                                                                   |
| \bigtriangledown    | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>▽</mo></mrow><annotation encoding="application/x-tex">\bigtriangledown</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord">▽</span></span></span></span>                                  |                                                                                                   |
| \bigtriangleup      | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>△</mo></mrow><annotation encoding="application/x-tex">\bigtriangleup</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord">△</span></span></span></span>                                    |                                                                                                   |
| \biguplus           | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⨄</mo></mrow><annotation encoding="application/x-tex">\biguplus</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mop op-symbol small-op" style="position:relative;top:0em;">⨄</span></span></span></span>                                         |                                                                                                   |
| \bigvee             | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋁</mo></mrow><annotation encoding="application/x-tex">\bigvee</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mop op-symbol small-op" style="position:relative;top:0em;">⋁</span></span></span></span>                                           |                                                                                                   |
| \bigwedge           | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋀</mo></mrow><annotation encoding="application/x-tex">\bigwedge</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mop op-symbol small-op" style="position:relative;top:0em;">⋀</span></span></span></span>                                         |                                                                                                   |
| \binom              | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true">(</mo><mfrac linethickness="0px"><mi>n</mi><mi>k</mi></mfrac><mo fence="true">)</mo></mrow><annotation encoding="application/x-tex">\binom n k</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2em;vertical-align:-0.35em;"></span><span class="mord"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size1">(</span></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.7454em;"><span style="top:-2.355em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.03148em;">k</span></span></span></span><span style="top:-3.144em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">n</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size1">)</span></span></span></span></span></span>                                        | <code>\binom n k</code>                                                                                      |
| \blacklozenge       | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">⧫</mi></mrow><annotation encoding="application/x-tex">\blacklozenge</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8034em;vertical-align:-0.1111em;"></span><span class="mord amsrm">⧫</span></span></span></span>                                     |                                                                                                   |
| \blacksquare        | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">■</mi></mrow><annotation encoding="application/x-tex">\blacksquare</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.675em;"></span><span class="mord amsrm">■</span></span></span></span>                                      |                                                                                                   |
| \blacktriangle      | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">▲</mi></mrow><annotation encoding="application/x-tex">\blacktriangle</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5499em;"></span><span class="mord amsrm">▲</span></span></span></span>                                    |                                                                                                   |
| \blacktriangledown  | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">▼</mi></mrow><annotation encoding="application/x-tex">\blacktriangledown</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5499em;"></span><span class="mord amsrm">▼</span></span></span></span>                                |                                                                                                   |
| \blacktriangleleft  | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>◀</mo></mrow><annotation encoding="application/x-tex">\blacktriangleleft</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.585em;vertical-align:-0.0352em;"></span><span class="mrel amsrm">◀</span></span></span></span>                                |                                                                                                   |
| \blacktriangleright | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>▶</mo></mrow><annotation encoding="application/x-tex">\blacktriangleright</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.585em;vertical-align:-0.0352em;"></span><span class="mrel amsrm">▶</span></span></span></span>                               |                                                                                                   |
| \bm                 | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi><mrow><mi mathvariant="bold-italic">A</mi><mi mathvariant="bold-italic">a</mi><mi mathvariant="bold-italic">B</mi><mi mathvariant="bold-italic">b</mi></mrow></mi></mrow><annotation encoding="application/x-tex">\bm{AaBb}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol">AaBb</span></span></span></span></span></span>                                         | <code>\bm{AaBb}</code>                                                                                       |
| {Bmatrix}           | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true">{</mo><mtable rowspacing="0.16em" columnalign="center center" columnspacing="1em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>a</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>b</mi></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>c</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>d</mi></mstyle></mtd></mtr></mtable><mo fence="true">}</mo></mrow><annotation encoding="application/x-tex">\begin{Bmatrix}a&amp;b\\c&amp;d\end{Bmatrix}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.4em;vertical-align:-0.95em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size3">{</span></span><span class="mord"><span class="mtable"><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:0.5em;"></span><span class="arraycolsep" style="width:0.5em;"></span><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">b</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">d</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size3">}</span></span></span></span></span></span>              | <code>\begin{Bmatrix}</code><br>   <code>a &amp; b \\</code><br>   <code>c &amp; d</code><br><code>\end{Bmatrix}</code> |
| {bmatrix}           | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true">[</mo><mtable rowspacing="0.16em" columnalign="center center" columnspacing="1em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>a</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>b</mi></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>c</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>d</mi></mstyle></mtd></mtr></mtable><mo fence="true">]</mo></mrow><annotation encoding="application/x-tex">\begin{bmatrix}a&amp;b\\c&amp;d\end{bmatrix}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.4em;vertical-align:-0.95em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size3">[</span></span><span class="mord"><span class="mtable"><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:0.5em;"></span><span class="arraycolsep" style="width:0.5em;"></span><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">b</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">d</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size3">]</span></span></span></span></span></span>              | <code>\begin{bmatrix}</code><br>   <code>a &amp; b \\</code><br>   <code>c &amp; d</code><br><code>\end{bmatrix}</code> |
| \bmod               | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mtext> </mtext><mo lspace="0.22em" rspace="0.22em"><mrow><mi mathvariant="normal">m</mi><mi mathvariant="normal">o</mi><mi mathvariant="normal">d</mi></mrow></mo><mtext> </mtext><mi>b</mi></mrow><annotation encoding="application/x-tex">a \bmod b</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">a</span><span class="mspace" style="margin-right:0.0556em;"></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin"><span class="mord"><span class="mord mathrm">mod</span></span></span><span class="mspace" style="margin-right:0.0556em;"></span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">b</span></span></span></span>                                         | <code>a \bmod b</code>                                                                                       |
| \bold               | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="bold">A</mi><mi mathvariant="bold">a</mi><mi mathvariant="bold">B</mi><mi mathvariant="bold">b</mi><mn mathvariant="bold">123</mn></mrow><annotation encoding="application/x-tex">\bold{AaBb123}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord"><span class="mord mathbf">AaBb123</span></span></span></span></span>                                    | <code>\bold{AaBb123}</code>                                                                                  |
| \boldsymbol         | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi><mrow><mi mathvariant="bold-italic">A</mi><mi mathvariant="bold-italic">a</mi><mi mathvariant="bold-italic">B</mi><mi mathvariant="bold-italic">b</mi></mrow></mi></mrow><annotation encoding="application/x-tex">\boldsymbol{AaBb}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol">AaBb</span></span></span></span></span></span>                                 | <code>\boldsymbol{AaBb}</code>                                                                               |
| \bot                | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">⊥</mi></mrow><annotation encoding="application/x-tex">\bot</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">⊥</span></span></span></span>                                              |                                                                                                   |
| \bowtie             | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋈</mo></mrow><annotation encoding="application/x-tex">\bowtie</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.51em;vertical-align:-0.005em;"></span><span class="mrel">⋈</span></span></span></span>                                           |                                                                                                   |
| \Box                | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">□</mi></mrow><annotation encoding="application/x-tex">\Box</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.675em;"></span><span class="mord amsrm">□</span></span></span></span>                                              |                                                                                                   |
| \boxdot             | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊡</mo></mrow><annotation encoding="application/x-tex">\boxdot</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.675em;"></span><span class="mord amsrm">⊡</span></span></span></span>                                           |                                                                                                   |
| \boxed              | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><menclose notation="box"><mstyle scriptlevel="0" displaystyle="false"><mstyle scriptlevel="0" displaystyle="false"><mstyle scriptlevel="0" displaystyle="true"><mrow><mi>a</mi><mi>b</mi></mrow></mstyle></mstyle></mstyle></menclose></mrow><annotation encoding="application/x-tex">\boxed{ab}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.3744em;vertical-align:-0.34em;"></span><span class="mord"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.0344em;"><span style="top:-3.3744em;"><span class="pstrut" style="height:3.3744em;"></span><span class="boxpad"><span class="mord"><span class="mord"><span class="mord mathnormal">ab</span></span></span></span></span><span style="top:-3.0344em;"><span class="pstrut" style="height:3.3744em;"></span><span class="stretchy fbox" style="height:1.3744em;border-style:solid;border-width:0.04em;"></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.34em;"><span></span></span></span></span></span></span></span></span>                                        | <code>\boxed{ab}</code>                                                                                      |
| \boxminus           | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊟</mo></mrow><annotation encoding="application/x-tex">\boxminus</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.675em;"></span><span class="mord amsrm">⊟</span></span></span></span>                                         |                                                                                                   |
| \boxplus            | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊞</mo></mrow><annotation encoding="application/x-tex">\boxplus</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.675em;"></span><span class="mord amsrm">⊞</span></span></span></span>                                          |                                                                                                   |
| \boxtimes           | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊠</mo></mrow><annotation encoding="application/x-tex">\boxtimes</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.675em;"></span><span class="mord amsrm">⊠</span></span></span></span>                                         |                                                                                                   |
| \Bra                | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true">⟨</mo><mi>ψ</mi><mo fence="true">∥</mo></mrow><annotation encoding="application/x-tex">\left\langle\psi\right\|</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">⟨</span><span class="mord mathnormal" style="margin-right:0.03588em;">ψ</span><span class="mclose delimcenter" style="top:0em;">∥</span></span></span></span></span>                          | <code>\Bra{\psi}</code>                                                                                      |
| \bra                | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mpadded><mo stretchy="false">⟨</mo><mi>ψ</mi><mi mathvariant="normal">∥</mi></mpadded></mrow><annotation encoding="application/x-tex">\mathinner{\langle{\psi}\|}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="minner"><span class="mopen">⟨</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">ψ</span></span><span class="mord">∥</span></span></span></span></span>                       | <code>\bra{\psi}</code>                                                                                      |
| \braket             | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mpadded><mo stretchy="false">⟨</mo><mrow><mi>ϕ</mi><mi mathvariant="normal">∥</mi><mi>ψ</mi></mrow><mo stretchy="false">⟩</mo></mpadded></mrow><annotation encoding="application/x-tex">\mathinner{\langle{\phi\|\psi}\rangle}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="minner"><span class="mopen">⟨</span><span class="mord"><span class="mord mathnormal">ϕ</span><span class="mord">∥</span><span class="mord mathnormal" style="margin-right:0.03588em;">ψ</span></span><span class="mclose">⟩</span></span></span></span></span>            | <code>\braket{\phi                                                                                     | \psi}</code> |
| \brace              | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true">{</mo><mfrac linethickness="0px"><mi>n</mi><mi>k</mi></mfrac><mo fence="true">}</mo></mrow><annotation encoding="application/x-tex">{n\brace k}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2em;vertical-align:-0.35em;"></span><span class="mord"><span class="mord"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size1">{</span></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.7454em;"><span style="top:-2.355em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.03148em;">k</span></span></span></span><span style="top:-3.144em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">n</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size1">}</span></span></span></span></span></span></span>                                       | <code>{n\brace k}</code>                                                                                     |
| \bracevert          | <span style="color:firebrick;">Not supported</span> |                                                                                                   |
| \brack              | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true">[</mo><mfrac linethickness="0px"><mi>n</mi><mi>k</mi></mfrac><mo fence="true">]</mo></mrow><annotation encoding="application/x-tex">{n\brack k}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2em;vertical-align:-0.35em;"></span><span class="mord"><span class="mord"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size1">[</span></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.7454em;"><span style="top:-2.355em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.03148em;">k</span></span></span></span><span style="top:-3.144em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">n</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size1">]</span></span></span></span></span></span></span>                                       | <code>{n\brack k}</code>                                                                                     |
| \breve              | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mrow><mi>e</mi><mi>u</mi></mrow><mo>˘</mo></mover></mrow><annotation encoding="application/x-tex">\breve{eu}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6944em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">e</span><span class="mord mathnormal">u</span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.25em;"><span class="mord">˘</span></span></span></span></span></span></span></span></span></span>                                        | <code>\breve{eu}</code>                                                                                      |
| \buildrel           | <span style="color:firebrick;">Not supported</span> |                                                                                                   |
| \bull               | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∙</mo></mrow><annotation encoding="application/x-tex">\bull</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4445em;"></span><span class="mord">∙</span></span></span></span>                                             |                                                                                                   |
| \bullet             | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∙</mo></mrow><annotation encoding="application/x-tex">\bullet</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4445em;"></span><span class="mord">∙</span></span></span></span>                                           |                                                                                                   |
| \Bumpeq             | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≎</mo></mrow><annotation encoding="application/x-tex">\Bumpeq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6105em;vertical-align:-0.0606em;"></span><span class="mrel amsrm">≎</span></span></span></span>                                           |                                                                                                   |
| \bumpeq             | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≏</mo></mrow><annotation encoding="application/x-tex">\bumpeq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6105em;vertical-align:-0.0606em;"></span><span class="mrel amsrm">≏</span></span></span></span>                                           |                                                                                                   |</p>
<h2 id="c" tabindex="-1">C <a class="header-anchor" href="#c" aria-label="Permalink to &quot;C&quot;">&ZeroWidthSpace;</a></h2>
<table>
<thead>
<tr>
<th style="text-align:left">Symbol/Function</th>
<th style="text-align:left">Rendered</th>
<th style="text-align:left">Source or Comment</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">\C</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"><a href="https://en.wikipedia.org/wiki/Help:Displaying_a_formula#Deprecated_syntax" target="_blank" rel="noreferrer">Deprecated</a></td>
</tr>
<tr>
<td style="text-align:left">\cal</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="script">A</mi><mi mathvariant="script">a</mi><mi mathvariant="script">B</mi><mi mathvariant="script">b</mi><mn mathvariant="script">123</mn></mrow><annotation encoding="application/x-tex">\cal AaBb123</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord"><span class="mord mathcal">A</span><span class="mord mathnormal">a</span><span class="mord mathcal" style="margin-right:0.03041em;">B</span><span class="mord mathnormal">b</span><span class="mord">123</span></span></span></span></span></td>
<td style="text-align:left"><code>\cal AaBb123</code></td>
</tr>
<tr>
<td style="text-align:left">\cancel</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><menclose notation="updiagonalstrike"><mn>5</mn></menclose></mrow><annotation encoding="application/x-tex">\cancel{5}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8444em;"><span style="top:-3.0444em;"><span class="pstrut" style="height:3.0444em;"></span><span class="mord"><span class="mord">5</span></span></span><span class="svg-align" style="top:-2.8444em;"><span class="pstrut" style="height:3.0444em;"></span><span style="height:1.0444em;"><svg xmlns="http://www.w3.org/2000/svg" width='100%' height='1.0444em'><line x1='0' y1='100%' x2='100%' y2='0' stroke-width='0.046em'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2em;"><span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\cancel{5}</code></td>
</tr>
<tr>
<td style="text-align:left">\cancelto</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Cap</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋒</mo></mrow><annotation encoding="application/x-tex">\Cap</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5499em;"></span><span class="mord amsrm">⋒</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\cap</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∩</mo></mrow><annotation encoding="application/x-tex">\cap</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5556em;"></span><span class="mord">∩</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left" cases=""></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true">{</mo><mtable rowspacing="0.36em" columnalign="left left" columnspacing="1em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>a</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mrow><mtext>if </mtext><mi>b</mi></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>c</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mrow><mtext>if </mtext><mi>d</mi></mrow></mstyle></mtd></mtr></mtable></mrow><annotation encoding="application/x-tex">\begin{cases}a&amp;\text{if }b\\c&amp;\text{if }d\end{cases}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:3em;vertical-align:-1.25em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size4">{</span></span><span class="mord"><span class="mtable"><span class="col-align-l"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.69em;"><span style="top:-3.69em;"><span class="pstrut" style="height:3.008em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span><span style="top:-2.25em;"><span class="pstrut" style="height:3.008em;"></span><span class="mord"><span class="mord mathnormal">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.19em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:1em;"></span><span class="col-align-l"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.69em;"><span style="top:-3.69em;"><span class="pstrut" style="height:3.008em;"></span><span class="mord"><span class="mord text"><span class="mord">if </span></span><span class="mord mathnormal">b</span></span></span><span style="top:-2.25em;"><span class="pstrut" style="height:3.008em;"></span><span class="mord"><span class="mord text"><span class="mord">if </span></span><span class="mord mathnormal">d</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.19em;"><span></span></span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span></td>
<td style="text-align:left"><code>\begin{cases}</code><br>   <code>a &amp;\text{if } b  \\</code><br>   <code>c &amp;\text{if } d</code><br><code>\end{cases}</code></td>
</tr>
<tr>
<td style="text-align:left">\cases</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left">see <code>{cases}</code></td>
</tr>
<tr>
<td style="text-align:left" CD=""></td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\cdot</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋅</mo></mrow><annotation encoding="application/x-tex">\cdot</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4445em;"></span><span class="mord">⋅</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\cdotp</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo separator="true">⋅</mo></mrow><annotation encoding="application/x-tex">\cdotp</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4445em;"></span><span class="mpunct">⋅</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\cdots</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋯</mo></mrow><annotation encoding="application/x-tex">\cdots</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.313em;"></span><span class="minner">⋯</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\ce</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">C</mi><msub><mpadded width="0px"><mphantom><mi>X</mi></mphantom></mpadded><mpadded height="0px"><mn>6</mn></mpadded></msub><mi mathvariant="normal">H</mi><msub><mpadded width="0px"><mphantom><mi>X</mi></mphantom></mpadded><mpadded height="0px"><mn>5</mn></mpadded></msub><mo lspace="0em" rspace="0em">−</mo><mrow><mi mathvariant="normal">C</mi><mi mathvariant="normal">H</mi><mi mathvariant="normal">O</mi></mrow></mrow><annotation encoding="application/x-tex">{\mathrm{C}{\vphantom{X}}_{\smash[t]{6}}\mathrm{H}{\vphantom{X}}_{\smash[t]{5}}{-}\mathrm{CHO}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathrm">C</span><span class="mord"><span class="mord"><span class="mord rlap"><span class="inner"><span class="mord" style="color:transparent;"><span class="mord mathnormal" style="margin-right:0.07847em;color:transparent;">X</span></span></span><span class="fix"></span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:-0.15em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0em;"><span style="top:-2.7em;"><span class="pstrut" style="height:2.7em;"></span><span><span class="mord mtight"><span class="mord mtight">6</span></span></span></span></span></span></span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord mathrm">H</span><span class="mord"><span class="mord"><span class="mord rlap"><span class="inner"><span class="mord" style="color:transparent;"><span class="mord mathnormal" style="margin-right:0.07847em;color:transparent;">X</span></span></span><span class="fix"></span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:-0.15em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0em;"><span style="top:-2.7em;"><span class="pstrut" style="height:2.7em;"></span><span><span class="mord mtight"><span class="mord mtight">5</span></span></span></span></span></span></span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord">−</span></span><span class="mord"><span class="mord mathrm">CHO</span></span></span></span></span></span> <br> <span class='katex-error' title='ParseError: KaTeX parse error: Undefined control sequence: \ce at position 1: \̲c̲e̲{C6H5-CHO}'>\ce{C6H5-CHO}</span></td>
<td style="text-align:left"><code>{\mathrm{C}{\vphantom{X}}_{\smash[t]{6}}\mathrm{H}{\vphantom{X}}_{\smash[t]{5}}{-}\mathrm{CHO}}</code> <br> or <code>\ce{C6H5-CHO}</code> Requires an <a href="https://github.com/KaTeX/KaTeX/tree/master/contrib/mhchem/" target="_blank" rel="noreferrer">extension</a></td>
</tr>
<tr>
<td style="text-align:left">\cee</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left">Deprecated by mhchem</td>
</tr>
<tr>
<td style="text-align:left">\centerdot</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mo>⋅</mo><mi>b</mi></mrow><annotation encoding="application/x-tex">a\centerdot b</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5499em;"></span><span class="mord mathnormal">a</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin amsrm">⋅</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">b</span></span></span></span></td>
<td style="text-align:left"><code>a\centerdot b</code></td>
</tr>
<tr>
<td style="text-align:left">\cf</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left">Deprecated by mhchem;</td>
</tr>
<tr>
<td style="text-align:left">use <code>\ce</code> instead</td>
<td style="text-align:left"></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\cfrac</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle displaystyle="true" scriptlevel="0"><mfrac><mn>2</mn><mrow><mn>1</mn><mo>+</mo><mstyle displaystyle="true" scriptlevel="0"><mfrac><mn>2</mn><mrow><mn>1</mn><mo>+</mo><mstyle displaystyle="true" scriptlevel="0"><mfrac><mn>2</mn><mn>1</mn></mfrac></mstyle></mrow></mfrac></mstyle></mrow></mfrac></mstyle></mrow><annotation encoding="application/x-tex">\cfrac{2}{1+\cfrac{2}{1+\cfrac{2}{1}}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:5.236em;vertical-align:-3.646em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.59em;"><span style="top:-2.11em;"><span class="pstrut" style="height:3.59em;"></span><span class="mord"><span class="mord">1</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.59em;"><span style="top:-2.11em;"><span class="pstrut" style="height:3.59em;"></span><span class="mord"><span class="mord">1</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.59em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">1</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.74em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span></span></span></span></span><span style="top:-3.82em;"><span class="pstrut" style="height:3.59em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-4.33em;"><span class="pstrut" style="height:3.59em;"></span><span class="mord"><span class="mord">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:2.166em;"><span></span></span></span></span></span><span></span></span></span></span><span style="top:-3.82em;"><span class="pstrut" style="height:3.59em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-4.33em;"><span class="pstrut" style="height:3.59em;"></span><span class="mord"><span class="mord">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:3.646em;"><span></span></span></span></span></span><span></span></span></span></span></span></td>
<td style="text-align:left"><code>\cfrac{2}{1+\cfrac{2}{1+\cfrac{2}{1}}}</code></td>
</tr>
<tr>
<td style="text-align:left">\check</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mrow><mi>o</mi><mi>e</mi></mrow><mo>ˇ</mo></mover></mrow><annotation encoding="application/x-tex">\check{oe}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6285em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6285em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">oe</span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.25em;"><span class="mord">ˇ</span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\check{oe}</code></td>
</tr>
<tr>
<td style="text-align:left">\ch</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ch</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\ch</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mop">ch</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\checkmark</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">✓</mi></mrow><annotation encoding="application/x-tex">\checkmark</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mord amsrm">✓</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Chi</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">X</mi></mrow><annotation encoding="application/x-tex">\Chi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathrm">X</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\chi</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>χ</mi></mrow><annotation encoding="application/x-tex">\chi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">χ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\choose</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true">(</mo><mfrac linethickness="0px"><mrow><mi>n</mi><mo>+</mo><mn>1</mn></mrow><mrow><mi>k</mi><mo>+</mo><mn>2</mn></mrow></mfrac><mo fence="true">)</mo></mrow><annotation encoding="application/x-tex">{n+1 \choose k+2}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2984em;vertical-align:-0.4033em;"></span><span class="mord"><span class="mord"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size1">(</span></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8951em;"><span style="top:-2.355em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.03148em;">k</span><span class="mbin mtight">+</span><span class="mord mtight">2</span></span></span></span><span style="top:-3.144em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">n</span><span class="mbin mtight">+</span><span class="mord mtight">1</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.4033em;"><span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size1">)</span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>{n+1 \choose k+2}</code></td>
</tr>
<tr>
<td style="text-align:left">\circ</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∘</mo></mrow><annotation encoding="application/x-tex">\circ</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4445em;"></span><span class="mord">∘</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\circeq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≗</mo></mrow><annotation encoding="application/x-tex">\circeq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9592em;vertical-align:-0.2296em;"></span><span class="mrel amsrm">≗</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\circlearrowleft</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↺</mo></mrow><annotation encoding="application/x-tex">\circlearrowleft</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.664em;vertical-align:-0.082em;"></span><span class="mrel amsrm">↺</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\circlearrowright</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↻</mo></mrow><annotation encoding="application/x-tex">\circlearrowright</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.664em;vertical-align:-0.082em;"></span><span class="mrel amsrm">↻</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\circledast</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊛</mo></mrow><annotation encoding="application/x-tex">\circledast</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.664em;vertical-align:-0.082em;"></span><span class="mord amsrm">⊛</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\circledcirc</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊚</mo></mrow><annotation encoding="application/x-tex">\circledcirc</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.664em;vertical-align:-0.082em;"></span><span class="mord amsrm">⊚</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\circleddash</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊝</mo></mrow><annotation encoding="application/x-tex">\circleddash</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.664em;vertical-align:-0.082em;"></span><span class="mord amsrm">⊝</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\circledR</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">®</mi></mrow><annotation encoding="application/x-tex">\circledR</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8478em;vertical-align:-0.1556em;"></span><span class="mord amsrm">®</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\circledS</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Ⓢ</mi></mrow><annotation encoding="application/x-tex">\circledS</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8478em;vertical-align:-0.1556em;"></span><span class="mord amsrm">Ⓢ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\class</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left">A PR is pending.</td>
</tr>
<tr>
<td style="text-align:left">\cline</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"><a href="https://github.com/KaTeX/KaTeX/issues/269" target="_blank" rel="noreferrer">Issue #269</a></td>
</tr>
<tr>
<td style="text-align:left">\clubs</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">♣</mi></mrow><annotation encoding="application/x-tex">\clubs</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8241em;vertical-align:-0.1296em;"></span><span class="mord">♣</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\clubsuit</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">♣</mi></mrow><annotation encoding="application/x-tex">\clubsuit</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8241em;vertical-align:-0.1296em;"></span><span class="mord">♣</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\cnums</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="double-struck">C</mi></mrow><annotation encoding="application/x-tex">\cnums</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord mathbb">C</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\colon</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mspace></mspace><mspace width="0.1111em"/><mo lspace="0em" rspace="0.17em"></mo><mtext> ⁣</mtext><mo lspace="0em" rspace="0em">:</mo><mspace width="0.3333em"/></mrow><annotation encoding="application/x-tex">\colon</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mspace nobreak"></span><span class="mspace" style="margin-right:0.1111em;"></span><span class="mpunct"></span><span class="mspace" style="margin-right:-0.1667em;"></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mrel">:</span></span><span class="mspace" style="margin-right:0.3333em;"></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Colonapprox</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mi mathvariant="normal">∷</mi><mi mathvariant="normal">≈</mi></mo></mrow><annotation encoding="application/x-tex">\Colonapprox</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4831em;"></span><span class="mrel"><span class="mrel"><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span><span class="mrel"><span class="mspace" style="margin-right:-0.05em;"></span></span><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span></span><span class="mrel"><span class="mspace" style="margin-right:-0.0667em;"></span></span><span class="mrel">≈</span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\colonapprox</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mi mathvariant="normal">:</mi><mi mathvariant="normal">≈</mi></mo></mrow><annotation encoding="application/x-tex">\colonapprox</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4831em;"></span><span class="mrel"><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span><span class="mrel"><span class="mspace" style="margin-right:-0.0667em;"></span></span><span class="mrel">≈</span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Coloneq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mi mathvariant="normal">∷</mi><mi mathvariant="normal">−</mi></mo></mrow><annotation encoding="application/x-tex">\Coloneq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mrel"><span class="mrel"><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span><span class="mrel"><span class="mspace" style="margin-right:-0.05em;"></span></span><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span></span><span class="mrel"><span class="mspace" style="margin-right:-0.0667em;"></span></span><span class="mrel"><span class="mord">−</span></span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\coloneq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mi mathvariant="normal">:</mi><mi mathvariant="normal">−</mi></mo></mrow><annotation encoding="application/x-tex">\coloneq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mrel"><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span><span class="mrel"><span class="mspace" style="margin-right:-0.0667em;"></span></span><span class="mrel"><span class="mord">−</span></span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Coloneqq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mi mathvariant="normal">∷</mi><mi mathvariant="normal">=</mi></mo></mrow><annotation encoding="application/x-tex">\Coloneqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mrel"><span class="mrel"><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span><span class="mrel"><span class="mspace" style="margin-right:-0.05em;"></span></span><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span></span><span class="mrel"><span class="mspace" style="margin-right:-0.0667em;"></span></span><span class="mrel">=</span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\coloneqq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mi mathvariant="normal">≔</mi></mo></mrow><annotation encoding="application/x-tex">\coloneqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mrel"><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span><span class="mrel"><span class="mspace" style="margin-right:-0.0667em;"></span></span><span class="mrel">=</span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Colonsim</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mi mathvariant="normal">∷</mi><mi mathvariant="normal">∼</mi></mo></mrow><annotation encoding="application/x-tex">\Colonsim</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mrel"><span class="mrel"><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span><span class="mrel"><span class="mspace" style="margin-right:-0.05em;"></span></span><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span></span><span class="mrel"><span class="mspace" style="margin-right:-0.0667em;"></span></span><span class="mrel">∼</span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\colonsim</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mi mathvariant="normal">:</mi><mi mathvariant="normal">∼</mi></mo></mrow><annotation encoding="application/x-tex">\colonsim</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mrel"><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span><span class="mrel"><span class="mspace" style="margin-right:-0.0667em;"></span></span><span class="mrel">∼</span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\color</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathcolor="#0000FF"><mi>A</mi><mi>a</mi><mi>B</mi><mi>b</mi><mn>123</mn></mstyle></mrow><annotation encoding="application/x-tex">\color{#0000FF} AaBb123</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal" style="color:#0000FF;">A</span><span class="mord mathnormal" style="color:#0000FF;">a</span><span class="mord mathnormal" style="margin-right:0.05017em;color:#0000FF;">B</span><span class="mord mathnormal" style="color:#0000FF;">b</span><span class="mord" style="color:#0000FF;">123</span></span></span></span></td>
<td style="text-align:left"><code>\color{#0000FF} AaBb123</code></td>
</tr>
<tr>
<td style="text-align:left">\colorbox</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mpadded width="+6pt" height="+6pt" lspace="3pt" voffset="3pt" mathbackground="red"><mtext>Black on red</mtext></mpadded></mrow><annotation encoding="application/x-tex">\colorbox{red}{Black on red}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2944em;vertical-align:-0.3em;"></span><span class="mord"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.9944em;"><span style="top:-2.9944em;"><span class="pstrut" style="height:3.2944em;"></span><span class="stretchy colorbox" style="height:1.2944em;background-color:red;"></span></span><span style="top:-3.2944em;"><span class="pstrut" style="height:3.2944em;"></span><span class="mord boxpad"><span class="mord">Black on red</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.3em;"><span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\colorbox{red}{Black on red}</code></td>
</tr>
<tr>
<td style="text-align:left">\complement</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∁</mi></mrow><annotation encoding="application/x-tex">\complement</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.825em;"></span><span class="mord amsrm">∁</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Complex</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="double-struck">C</mi></mrow><annotation encoding="application/x-tex">\Complex</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord mathbb">C</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\cong</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≅</mo></mrow><annotation encoding="application/x-tex">\cong</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.589em;"></span><span class="mrel">≅</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Coppa</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\coppa</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\coprod</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∐</mo></mrow><annotation encoding="application/x-tex">\coprod</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mop op-symbol small-op" style="position:relative;top:0em;">∐</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\copyright</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>©</mtext></mrow><annotation encoding="application/x-tex">\copyright</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;"></span><span class="mord text"><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8889em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">c</span></span></span><span style="top:-3.1944em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body accent-full" style="left:0em;top:.2em;"><span class="mord">◯</span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\cos</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>cos</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\cos</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mop">cos</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\cosec</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>cosec</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\cosec</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mop">cosec</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\cosh</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>cosh</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\cosh</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mop">cosh</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\cot</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>cot</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\cot</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6151em;"></span><span class="mop">cot</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\cotg</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>cotg</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\cotg</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8095em;vertical-align:-0.1944em;"></span><span class="mop">cot<span style="margin-right:0.01389em;">g</span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\coth</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>coth</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\coth</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mop">coth</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\cr</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mtable rowspacing="0.16em" columnalign="center center" columnspacing="1em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>a</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>b</mi></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>c</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>d</mi></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{matrix} a &amp; b\cr c &amp; d \end{matrix}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.4em;vertical-align:-0.95em;"></span><span class="mord"><span class="mtable"><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:0.5em;"></span><span class="arraycolsep" style="width:0.5em;"></span><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">b</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">d</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\begin{matrix}</code><br>   <code>a &amp; b \cr</code><br>   <code>c &amp; d</code><br><code>\end{matrix}</code></td>
</tr>
<tr>
<td style="text-align:left">\csc</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>csc</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\csc</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mop">csc</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\cssId</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left">A PR is pending.</td>
</tr>
<tr>
<td style="text-align:left">\ctg</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ctg</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\ctg</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8095em;vertical-align:-0.1944em;"></span><span class="mop">ct<span style="margin-right:0.01389em;">g</span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\cth</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>cth</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\cth</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mop">cth</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Cup</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋓</mo></mrow><annotation encoding="application/x-tex">\Cup</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5499em;"></span><span class="mord amsrm">⋓</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\cup</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∪</mo></mrow><annotation encoding="application/x-tex">\cup</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5556em;"></span><span class="mord">∪</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\curlyeqprec</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋞</mo></mrow><annotation encoding="application/x-tex">\curlyeqprec</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7733em;vertical-align:-0.1367em;"></span><span class="mrel amsrm">⋞</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\curlyeqsucc</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋟</mo></mrow><annotation encoding="application/x-tex">\curlyeqsucc</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7733em;vertical-align:-0.1367em;"></span><span class="mrel amsrm">⋟</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\curlyvee</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋎</mo></mrow><annotation encoding="application/x-tex">\curlyvee</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5499em;"></span><span class="mord amsrm">⋎</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\curlywedge</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋏</mo></mrow><annotation encoding="application/x-tex">\curlywedge</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5499em;"></span><span class="mord amsrm">⋏</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\curvearrowleft</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↶</mo></mrow><annotation encoding="application/x-tex">\curvearrowleft</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mrel amsrm">↶</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\curvearrowright</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↷</mo></mrow><annotation encoding="application/x-tex">\curvearrowright</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mrel amsrm">↷</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
</tbody>
</table>
<h2 id="d" tabindex="-1">D <a class="header-anchor" href="#d" aria-label="Permalink to &quot;D&quot;">&ZeroWidthSpace;</a></h2>
<table>
<thead>
<tr>
<th style="text-align:left">Symbol/Function</th>
<th style="text-align:left">Rendered</th>
<th style="text-align:left">Source or Comment</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">\dag</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">†</mi></mrow><annotation encoding="application/x-tex">\dag</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord">†</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Dagger</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>‡</mo></mrow><annotation encoding="application/x-tex">\Dagger</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord">‡</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\dagger</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>†</mo></mrow><annotation encoding="application/x-tex">\dagger</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord">†</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\daleth</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">ℸ</mi></mrow><annotation encoding="application/x-tex">\daleth</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord amsrm">ℸ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Darr</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇓</mo></mrow><annotation encoding="application/x-tex">\Darr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel">⇓</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\dArr</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇓</mo></mrow><annotation encoding="application/x-tex">\dArr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel">⇓</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\darr</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↓</mo></mrow><annotation encoding="application/x-tex">\darr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel">↓</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left" darray=""></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mtable rowspacing="0.16em" columnalign="center center" columnspacing="1em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mi>a</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mi>b</mi></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mi>c</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mi>d</mi></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{darray}{cc}a&amp;b\\c&amp;d\end{darray}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.4em;vertical-align:-0.95em;"></span><span class="mord"><span class="mtable"><span class="arraycolsep" style="width:0.5em;"></span><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:0.5em;"></span><span class="arraycolsep" style="width:0.5em;"></span><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">b</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">d</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:0.5em;"></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\begin{darray}{cc}</code><br>   <code>a &amp; b \\</code><br>   <code>c &amp; d</code><br><code>\end{darray}</code></td>
</tr>
<tr>
<td style="text-align:left">\dashleftarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇠</mo></mrow><annotation encoding="application/x-tex">\dashleftarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.437em;"></span><span class="mrel amsrm">⇠</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\dashrightarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇢</mo></mrow><annotation encoding="application/x-tex">\dashrightarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.437em;"></span><span class="mrel amsrm">⇢</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\dashv</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊣</mo></mrow><annotation encoding="application/x-tex">\dashv</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mrel">⊣</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\dbinom</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true">(</mo><mstyle displaystyle="true" scriptlevel="0"><mfrac linethickness="0px"><mi>n</mi><mi>k</mi></mfrac></mstyle><mo fence="true">)</mo></mrow><annotation encoding="application/x-tex">\dbinom n k</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.4em;vertical-align:-0.95em;"></span><span class="mord"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size3">(</span></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1076em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03148em;">k</span></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">n</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size3">)</span></span></span></span></span></span></td>
<td style="text-align:left"><code>\dbinom n k</code></td>
</tr>
<tr>
<td style="text-align:left">\dblcolon</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mi mathvariant="normal">∷</mi></mo></mrow><annotation encoding="application/x-tex">\dblcolon</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mrel"><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span><span class="mrel"><span class="mspace" style="margin-right:-0.05em;"></span></span><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left" dcases=""></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true">{</mo><mtable rowspacing="0.36em" columnalign="left left" columnspacing="1em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mi>a</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mtext>if </mtext><mi>b</mi></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mi>c</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mtext>if </mtext><mi>d</mi></mrow></mstyle></mtd></mtr></mtable></mrow><annotation encoding="application/x-tex">\begin{dcases}a&amp;\text{if }b\\c&amp;\text{if }d\end{dcases}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:3em;vertical-align:-1.25em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size4">{</span></span><span class="mord"><span class="mtable"><span class="col-align-l"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.69em;"><span style="top:-3.69em;"><span class="pstrut" style="height:3.008em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span><span style="top:-2.25em;"><span class="pstrut" style="height:3.008em;"></span><span class="mord"><span class="mord mathnormal">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.19em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:1em;"></span><span class="col-align-l"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.69em;"><span style="top:-3.69em;"><span class="pstrut" style="height:3.008em;"></span><span class="mord"><span class="mord text"><span class="mord">if </span></span><span class="mord mathnormal">b</span></span></span><span style="top:-2.25em;"><span class="pstrut" style="height:3.008em;"></span><span class="mord"><span class="mord text"><span class="mord">if </span></span><span class="mord mathnormal">d</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.19em;"><span></span></span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span></td>
<td style="text-align:left"><code>\begin{dcases}</code><br>   <code>a &amp;\text{if } b  \\</code><br>   <code>c &amp;\text{if } d</code><br><code>\end{dcases}</code></td>
</tr>
<tr>
<td style="text-align:left">\ddag</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">‡</mi></mrow><annotation encoding="application/x-tex">\ddag</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord">‡</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\ddagger</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>‡</mo></mrow><annotation encoding="application/x-tex">\ddagger</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord">‡</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\ddddot</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\dddot</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\ddot</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mi>x</mi><mo>¨</mo></mover></mrow><annotation encoding="application/x-tex">\ddot x</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6679em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6679em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord mathnormal">x</span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.2222em;"><span class="mord">¨</span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\ddot x</code></td>
</tr>
<tr>
<td style="text-align:left">\ddots</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋱</mo></mrow><annotation encoding="application/x-tex">\ddots</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.823em;"></span><span class="minner">⋱</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\DeclareMathOperator</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\def</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msup><mi>x</mi><mn>2</mn></msup><mo>+</mo><msup><mi>x</mi><mn>2</mn></msup></mrow><annotation encoding="application/x-tex">\def\foo{x^2} \foo + \foo</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8974em;vertical-align:-0.0833em;"></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.8141em;"></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\def\foo{x^2} \foo + \foo</code></td>
</tr>
<tr>
<td style="text-align:left">\definecolor</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"><a href="https://github.com/KaTeX/KaTeX/issues/750" target="_blank" rel="noreferrer">Issue #750</a></td>
</tr>
<tr>
<td style="text-align:left">\deg</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>deg</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\deg</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mop">de<span style="margin-right:0.01389em;">g</span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\degree</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">°</mi></mrow><annotation encoding="application/x-tex">\degree</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">°</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\delta</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>δ</mi></mrow><annotation encoding="application/x-tex">\delta</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal" style="margin-right:0.03785em;">δ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Delta</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Δ</mi></mrow><annotation encoding="application/x-tex">\Delta</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">Δ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\det</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>det</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\det</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mop">det</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Digamma</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\digamma</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">ϝ</mi></mrow><annotation encoding="application/x-tex">\digamma</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6633em;vertical-align:-0.0817em;"></span><span class="mord amsrm">ϝ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\dfrac</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle displaystyle="true" scriptlevel="0"><mfrac><mrow><mi>a</mi><mo>−</mo><mn>1</mn></mrow><mrow><mi>b</mi><mo>−</mo><mn>1</mn></mrow></mfrac></mstyle></mrow><annotation encoding="application/x-tex">\dfrac{a-1}{b-1}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.0908em;vertical-align:-0.7693em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.3214em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">b</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord">1</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.7693em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span></td>
<td style="text-align:left"><code>\dfrac{a-1}{b-1}</code></td>
</tr>
<tr>
<td style="text-align:left">\diagdown</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">╲</mi></mrow><annotation encoding="application/x-tex">\diagdown</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9356em;vertical-align:-0.1944em;"></span><span class="mord amsrm">╲</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\diagup</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">╱</mi></mrow><annotation encoding="application/x-tex">\diagup</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8833em;vertical-align:-0.1944em;"></span><span class="mord amsrm">╱</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Diamond</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">◊</mi></mrow><annotation encoding="application/x-tex">\Diamond</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8034em;vertical-align:-0.1111em;"></span><span class="mord amsrm">◊</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\diamond</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋄</mo></mrow><annotation encoding="application/x-tex">\diamond</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4445em;"></span><span class="mord">⋄</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\diamonds</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">♢</mi></mrow><annotation encoding="application/x-tex">\diamonds</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8241em;vertical-align:-0.1296em;"></span><span class="mord">♢</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\diamondsuit</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">♢</mi></mrow><annotation encoding="application/x-tex">\diamondsuit</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8241em;vertical-align:-0.1296em;"></span><span class="mord">♢</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\dim</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>dim</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\dim</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mop">dim</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\displaylines</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\displaystyle</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle scriptlevel="0" displaystyle="true"><munderover><mo>∑</mo><mn>0</mn><mi>n</mi></munderover></mstyle></mrow><annotation encoding="application/x-tex">\displaystyle\sum_0^n</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.9185em;vertical-align:-1.2671em;"></span><span class="mop op-limits"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.6514em;"><span style="top:-1.8829em;margin-left:0em;"><span class="pstrut" style="height:3.05em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">0</span></span></span><span style="top:-3.05em;"><span class="pstrut" style="height:3.05em;"></span><span><span class="mop op-symbol large-op">∑</span></span></span><span style="top:-4.3em;margin-left:0em;"><span class="pstrut" style="height:3.05em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">n</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.2671em;"><span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\displaystyle\sum_0^n</code></td>
</tr>
<tr>
<td style="text-align:left">\div</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>÷</mo></mrow><annotation encoding="application/x-tex">\div</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mord">÷</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\divideontimes</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋇</mo></mrow><annotation encoding="application/x-tex">\divideontimes</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6633em;vertical-align:-0.0817em;"></span><span class="mord amsrm">⋇</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\dot</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mi>x</mi><mo>˙</mo></mover></mrow><annotation encoding="application/x-tex">\dot x</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6679em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6679em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord mathnormal">x</span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.1111em;"><span class="mord">˙</span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\dot x</code></td>
</tr>
<tr>
<td style="text-align:left">\Doteq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≑</mo></mrow><annotation encoding="application/x-tex">\Doteq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.664em;vertical-align:-0.082em;"></span><span class="mrel amsrm">≑</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\doteq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≐</mo></mrow><annotation encoding="application/x-tex">\doteq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.673em;"></span><span class="mrel">≐</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\doteqdot</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≑</mo></mrow><annotation encoding="application/x-tex">\doteqdot</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.664em;vertical-align:-0.082em;"></span><span class="mrel amsrm">≑</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\dotplus</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∔</mo></mrow><annotation encoding="application/x-tex">\dotplus</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7742em;vertical-align:-0.082em;"></span><span class="mord amsrm">∔</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\dots</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>x</mi><mn>1</mn></msub><mo>+</mo><mo>⋯</mo><mo>+</mo><msub><mi>x</mi><mi>n</mi></msub></mrow><annotation encoding="application/x-tex">x_1 + \dots + x_n</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="minner">⋯</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">n</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>x_1 + \dots + x_n</code></td>
</tr>
<tr>
<td style="text-align:left">\dotsb</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>x</mi><mn>1</mn></msub><mo>+</mo><mo>⋯</mo><mo>+</mo><msub><mi>x</mi><mi>n</mi></msub></mrow><annotation encoding="application/x-tex">x_1 +\dotsb + x_n</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="minner">⋯</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">n</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>x_1 +\dotsb + x_n</code></td>
</tr>
<tr>
<td style="text-align:left">\dotsc</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>x</mi><mo separator="true">,</mo><mo>…</mo><mo separator="true">,</mo><mi>y</mi></mrow><annotation encoding="application/x-tex">x,\dotsc,y</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">x</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner">…</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">y</span></span></span></span></td>
<td style="text-align:left"><code>x,\dotsc,y</code></td>
</tr>
<tr>
<td style="text-align:left">\dotsi</td>
<td style="text-align:left">$$\int_{A_1}\int_{A_2}\dotsi$$</td>
<td style="text-align:left"><code>\int_{A_1}\int_{A_2}\dotsi</code></td>
</tr>
<tr>
<td style="text-align:left">\dotsm</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>x</mi><mn>1</mn></msub><msub><mi>x</mi><mn>2</mn></msub><mo>⋯</mo><msub><mi>x</mi><mi>n</mi></msub></mrow><annotation encoding="application/x-tex">x_1 x_2 \dotsm x_n</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner">⋯</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">n</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>$x_1 x_2 \dotsm x_n</code></td>
</tr>
<tr>
<td style="text-align:left">\dotso</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>…</mo></mrow><annotation encoding="application/x-tex">\dotso</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.123em;"></span><span class="minner">…</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\doublebarwedge</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⩞</mo></mrow><annotation encoding="application/x-tex">\doublebarwedge</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9503em;vertical-align:-0.1944em;"></span><span class="mord amsrm">⩞</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\doublecap</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋒</mo></mrow><annotation encoding="application/x-tex">\doublecap</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5499em;"></span><span class="mord amsrm">⋒</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\doublecup</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋓</mo></mrow><annotation encoding="application/x-tex">\doublecup</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5499em;"></span><span class="mord amsrm">⋓</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Downarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇓</mo></mrow><annotation encoding="application/x-tex">\Downarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel">⇓</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\downarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↓</mo></mrow><annotation encoding="application/x-tex">\downarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel">↓</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\downdownarrows</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇊</mo></mrow><annotation encoding="application/x-tex">\downdownarrows</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8867em;vertical-align:-0.1944em;"></span><span class="mrel amsrm">⇊</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\downharpoonleft</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇃</mo></mrow><annotation encoding="application/x-tex">\downharpoonleft</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8867em;vertical-align:-0.1944em;"></span><span class="mrel amsrm">⇃</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\downharpoonright</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇂</mo></mrow><annotation encoding="application/x-tex">\downharpoonright</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8867em;vertical-align:-0.1944em;"></span><span class="mrel amsrm">⇂</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left" drcases=""></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtable rowspacing="0.36em" columnalign="left left" columnspacing="1em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mi>a</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mtext>if </mtext><mi>b</mi></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mi>c</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mtext>if </mtext><mi>d</mi></mrow></mstyle></mtd></mtr></mtable><mo fence="true">}</mo></mrow><annotation encoding="application/x-tex">\begin{drcases}a&amp;\text{if }b\\c&amp;\text{if }d\end{drcases}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:3em;vertical-align:-1.25em;"></span><span class="minner"><span class="mopen nulldelimiter"></span><span class="mord"><span class="mtable"><span class="col-align-l"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.69em;"><span style="top:-3.69em;"><span class="pstrut" style="height:3.008em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span><span style="top:-2.25em;"><span class="pstrut" style="height:3.008em;"></span><span class="mord"><span class="mord mathnormal">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.19em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:1em;"></span><span class="col-align-l"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.69em;"><span style="top:-3.69em;"><span class="pstrut" style="height:3.008em;"></span><span class="mord"><span class="mord text"><span class="mord">if </span></span><span class="mord mathnormal">b</span></span></span><span style="top:-2.25em;"><span class="pstrut" style="height:3.008em;"></span><span class="mord"><span class="mord text"><span class="mord">if </span></span><span class="mord mathnormal">d</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.19em;"><span></span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size4">}</span></span></span></span></span></span></td>
<td style="text-align:left"><code>\begin{drcases}</code><br>   <code>a &amp;\text{if } b  \\</code><br>   <code>c &amp;\text{if } d</code><br><code>\end{drcases}</code></td>
</tr>
</tbody>
</table>
<h2 id="e" tabindex="-1">E <a class="header-anchor" href="#e" aria-label="Permalink to &quot;E&quot;">&ZeroWidthSpace;</a></h2>
<table>
<thead>
<tr>
<th style="text-align:left">Symbol/Function</th>
<th style="text-align:left">Rendered</th>
<th style="text-align:left">Source or Comment</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">\edef</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi></mrow><annotation encoding="application/x-tex">\def\foo{a}\edef\bar{\foo}\def\foo{}\bar</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">a</span></span></span></span></td>
<td style="text-align:left"><code>\def\foo{a}\edef\bar{\foo}\def\foo{}\bar</code></td>
</tr>
<tr>
<td style="text-align:left">\ell</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">ℓ</mi></mrow><annotation encoding="application/x-tex">\ell</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">ℓ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\else</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"><a href="https://github.com/KaTeX/KaTeX/issues/1003" target="_blank" rel="noreferrer">Issue #1003</a></td>
</tr>
<tr>
<td style="text-align:left">\em</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\emph</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\empty</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∅</mi></mrow><annotation encoding="application/x-tex">\empty</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8056em;vertical-align:-0.0556em;"></span><span class="mord">∅</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\emptyset</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∅</mi></mrow><annotation encoding="application/x-tex">\emptyset</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8056em;vertical-align:-0.0556em;"></span><span class="mord">∅</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\enclose</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left">Non standard</td>
</tr>
<tr>
<td style="text-align:left">\end</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mtable rowspacing="0.16em" columnalign="center center" columnspacing="1em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>a</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>b</mi></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>c</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>d</mi></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{matrix} a &amp; b\\ c &amp; d\end{matrix}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.4em;vertical-align:-0.95em;"></span><span class="mord"><span class="mtable"><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:0.5em;"></span><span class="arraycolsep" style="width:0.5em;"></span><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">b</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">d</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\begin{matrix}</code><br>   <code>a &amp; b \\</code><br>   <code>c &amp; d</code><br><code>\end{matrix}</code></td>
</tr>
<tr>
<td style="text-align:left">\endgroup</td>
<td style="text-align:left"><span class='katex-error' title='ParseError: KaTeX parse error: Expected &#039;}&#039;, got &#039;\endgroup&#039; at position 3: {a\̲e̲n̲d̲g̲r̲o̲u̲p̲'>{a\endgroup</span></td>
<td style="text-align:left"><code>{a\endgroup</code></td>
</tr>
<tr>
<td style="text-align:left">\enspace</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mspace width="0.5em"/><mi>b</mi></mrow><annotation encoding="application/x-tex">a\enspace b</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">a</span><span class="mspace" style="margin-right:0.5em;"></span><span class="mord mathnormal">b</span></span></span></span></td>
<td style="text-align:left"><code>a\enspace b</code></td>
</tr>
<tr>
<td style="text-align:left">\Epsilon</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">E</mi></mrow><annotation encoding="application/x-tex">\Epsilon</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathrm">E</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\epsilon</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ϵ</mi></mrow><annotation encoding="application/x-tex">\epsilon</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">ϵ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\eqalign</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\eqalignno</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\eqcirc</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≖</mo></mrow><annotation encoding="application/x-tex">\eqcirc</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mrel amsrm">≖</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Eqcolon</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mi mathvariant="normal">−</mi><mi mathvariant="normal">∷</mi></mo></mrow><annotation encoding="application/x-tex">\Eqcolon</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mrel"><span class="mrel"><span class="mord">−</span></span><span class="mrel"><span class="mspace" style="margin-right:-0.0667em;"></span></span><span class="mrel"><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span><span class="mrel"><span class="mspace" style="margin-right:-0.05em;"></span></span><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span></span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\eqcolon</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mi mathvariant="normal">∹</mi></mo></mrow><annotation encoding="application/x-tex">\eqcolon</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mrel"><span class="mrel"><span class="mord">−</span></span><span class="mrel"><span class="mspace" style="margin-right:-0.0667em;"></span></span><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left" equation=""></td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"><a href="https://github.com/KaTeX/KaTeX/issues/445" target="_blank" rel="noreferrer">Issue #445</a></td>
</tr>
<tr>
<td style="text-align:left" eqnarray=""></td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Eqqcolon</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mi mathvariant="normal">=</mi><mi mathvariant="normal">∷</mi></mo></mrow><annotation encoding="application/x-tex">\Eqqcolon</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mrel"><span class="mrel">=</span><span class="mrel"><span class="mspace" style="margin-right:-0.0667em;"></span></span><span class="mrel"><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span><span class="mrel"><span class="mspace" style="margin-right:-0.05em;"></span></span><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span></span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\eqqcolon</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mi mathvariant="normal">≕</mi></mo></mrow><annotation encoding="application/x-tex">\eqqcolon</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mrel"><span class="mrel">=</span><span class="mrel"><span class="mspace" style="margin-right:-0.0667em;"></span></span><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\eqref</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"><a href="https://github.com/KaTeX/KaTeX/issues/350" target="_blank" rel="noreferrer">Issue #350</a></td>
</tr>
<tr>
<td style="text-align:left">\eqsim</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≂</mo></mrow><annotation encoding="application/x-tex">\eqsim</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4637em;"></span><span class="mrel amsrm">≂</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\eqslantgtr</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⪖</mo></mrow><annotation encoding="application/x-tex">\eqslantgtr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7733em;vertical-align:-0.1367em;"></span><span class="mrel amsrm">⪖</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\eqslantless</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⪕</mo></mrow><annotation encoding="application/x-tex">\eqslantless</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7733em;vertical-align:-0.1367em;"></span><span class="mrel amsrm">⪕</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\equiv</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≡</mo></mrow><annotation encoding="application/x-tex">\equiv</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4637em;"></span><span class="mrel">≡</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Eta</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">H</mi></mrow><annotation encoding="application/x-tex">\Eta</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathrm">H</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\eta</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>η</mi></mrow><annotation encoding="application/x-tex">\eta</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">η</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\eth</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">ð</mi></mrow><annotation encoding="application/x-tex">\eth</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord amsrm">ð</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\euro</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\exist</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∃</mi></mrow><annotation encoding="application/x-tex">\exist</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">∃</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\exists</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∃</mi></mrow><annotation encoding="application/x-tex">\exists</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">∃</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\exp</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>exp</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\exp</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mop">exp</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\expandafter</td>
<td style="text-align:left"></td>
<td style="text-align:left"></td>
</tr>
</tbody>
</table>
<h2 id="f" tabindex="-1">F <a class="header-anchor" href="#f" aria-label="Permalink to &quot;F&quot;">&ZeroWidthSpace;</a></h2>
<table>
<thead>
<tr>
<th style="text-align:left">Symbol/Function</th>
<th style="text-align:left">Rendered</th>
<th style="text-align:left">Source or Comment</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">\fallingdotseq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≒</mo></mrow><annotation encoding="application/x-tex">\fallingdotseq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.664em;vertical-align:-0.082em;"></span><span class="mrel amsrm">≒</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\fbox</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><menclose notation="box"><mstyle scriptlevel="0" displaystyle="false"><mtext>Hi there!</mtext></mstyle></menclose></mrow><annotation encoding="application/x-tex">\fbox{Hi there!}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.3744em;vertical-align:-0.34em;"></span><span class="mord"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.0344em;"><span style="top:-3.3744em;"><span class="pstrut" style="height:3.3744em;"></span><span class="boxpad"><span class="mord"><span class="mord">Hi there!</span></span></span></span><span style="top:-3.0344em;"><span class="pstrut" style="height:3.3744em;"></span><span class="stretchy fbox" style="height:1.3744em;border-style:solid;border-width:0.04em;"></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.34em;"><span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\fbox{Hi there!}</code></td>
</tr>
<tr>
<td style="text-align:left">\fcolorbox</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mpadded width="+6pt" height="+6pt" lspace="3pt" voffset="3pt" style="border: 0.04em solid red" mathbackground="aqua"><mtext>A</mtext></mpadded></mrow><annotation encoding="application/x-tex">\fcolorbox{red}{aqua}{A}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.3633em;vertical-align:-0.34em;"></span><span class="mord"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.0233em;"><span style="top:-3.0233em;"><span class="pstrut" style="height:3.3633em;"></span><span class="stretchy fcolorbox" style="height:1.3633em;border-style:solid;border-width:0.04em;background-color:aqua;border-color:red;"></span></span><span style="top:-3.3633em;"><span class="pstrut" style="height:3.3633em;"></span><span class="mord boxpad"><span class="mord">A</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.34em;"><span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\fcolorbox{red}{aqua}{A}</code></td>
</tr>
<tr>
<td style="text-align:left">\fi</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"><a href="https://github.com/KaTeX/KaTeX/issues/1003" target="_blank" rel="noreferrer">Issue #1003</a></td>
</tr>
<tr>
<td style="text-align:left">\Finv</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Ⅎ</mi></mrow><annotation encoding="application/x-tex">\Finv</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord amsrm">Ⅎ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\flat</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">♭</mi></mrow><annotation encoding="application/x-tex">\flat</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.75em;"></span><span class="mord">♭</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\footnotesize</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathsize="0.8em"><mi>f</mi><mi>o</mi><mi>o</mi><mi>t</mi><mi>n</mi><mi>o</mi><mi>t</mi><mi>e</mi><mi>s</mi><mi>i</mi><mi>z</mi><mi>e</mi></mstyle></mrow><annotation encoding="application/x-tex">\footnotesize footnotesize</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7111em;vertical-align:-0.1556em;"></span><span class="mord mathnormal sizing reset-size6 size4" style="margin-right:0.10764em;">f</span><span class="mord mathnormal sizing reset-size6 size4">oo</span><span class="mord mathnormal sizing reset-size6 size4">t</span><span class="mord mathnormal sizing reset-size6 size4">n</span><span class="mord mathnormal sizing reset-size6 size4">o</span><span class="mord mathnormal sizing reset-size6 size4">t</span><span class="mord mathnormal sizing reset-size6 size4">es</span><span class="mord mathnormal sizing reset-size6 size4">i</span><span class="mord mathnormal sizing reset-size6 size4">ze</span></span></span></span></td>
<td style="text-align:left"><code>\footnotesize footnotesize</code></td>
</tr>
<tr>
<td style="text-align:left">\forall</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∀</mi></mrow><annotation encoding="application/x-tex">\forall</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">∀</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\frac</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mfrac><mi>a</mi><mi>b</mi></mfrac></mrow><annotation encoding="application/x-tex">\frac a b</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0404em;vertical-align:-0.345em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6954em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">b</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">a</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span></td>
<td style="text-align:left"><code>\frac a b</code></td>
</tr>
<tr>
<td style="text-align:left">\frak</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="fraktur">A</mi><mi mathvariant="fraktur">a</mi><mi mathvariant="fraktur">B</mi><mi mathvariant="fraktur">b</mi></mrow><annotation encoding="application/x-tex">\frak{AaBb}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6914em;"></span><span class="mord"><span class="mord mathfrak">AaBb</span></span></span></span></span></td>
<td style="text-align:left"><code>\frak{AaBb}</code></td>
</tr>
<tr>
<td style="text-align:left">\frown</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⌢</mo></mrow><annotation encoding="application/x-tex">\frown</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3576em;"></span><span class="mrel">⌢</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\futurelet</td>
<td style="text-align:left"></td>
<td style="text-align:left"></td>
</tr>
</tbody>
</table>
<h2 id="g" tabindex="-1">G <a class="header-anchor" href="#g" aria-label="Permalink to &quot;G&quot;">&ZeroWidthSpace;</a></h2>
<table>
<thead>
<tr>
<th style="text-align:left">Symbol/Function</th>
<th style="text-align:left">Rendered</th>
<th style="text-align:left">Source or Comment</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">\Game</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">⅁</mi></mrow><annotation encoding="application/x-tex">\Game</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord amsrm">⅁</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Gamma</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Γ</mi></mrow><annotation encoding="application/x-tex">\Gamma</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">Γ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\gamma</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>γ</mi></mrow><annotation encoding="application/x-tex">\gamma</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.05556em;">γ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left" gather=""></td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left">see <code>{gathered}</code></td>
</tr>
<tr>
<td style="text-align:left" gathered=""></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mtable rowspacing="0.25em" columnalign="center" columnspacing="0em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mi>a</mi><mo>=</mo><mi>b</mi></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mi>e</mi><mo>=</mo><mi>b</mi><mo>+</mo><mi>c</mi></mrow></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{gathered}a=b\\e=b+c\end{gathered}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:3em;vertical-align:-1.25em;"></span><span class="mord"><span class="mtable"><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.75em;"><span style="top:-3.91em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord mathnormal">b</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">e</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord mathnormal">b</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.25em;"><span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\begin{gathered}</code><br>   <code>a=b \\ </code><br>   <code>e=b+c</code><br><code>\end{gathered}</code></td>
</tr>
<tr>
<td style="text-align:left">\gcd</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>gcd</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\gcd</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mop"><span style="margin-right:0.01389em;">g</span>cd</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\gdef</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msup><mi>y</mi><mn>2</mn></msup><mo>+</mo><msup><mi>y</mi><mn>2</mn></msup></mrow><annotation encoding="application/x-tex">\gdef\bar#1{#1^2} \bar{y} + \bar{y}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0085em;vertical-align:-0.1944em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">y</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1.0085em;vertical-align:-0.1944em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">y</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\gdef\bar#1{#1^2} \bar{y} + \bar{y}</code></td>
</tr>
<tr>
<td style="text-align:left">\ge</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≥</mo></mrow><annotation encoding="application/x-tex">\ge</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mrel">≥</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\geneuro</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\geneuronarrow</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\geneurowide</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\genfrac</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true">(</mo><mstyle displaystyle="true" scriptlevel="0"><mfrac linethickness="0.2em"><mi>a</mi><mrow><mi>a</mi><mo>+</mo><mn>1</mn></mrow></mfrac></mstyle><mo fence="true">]</mo></mrow><annotation encoding="application/x-tex">\genfrac ( ] {2pt}{0}a{a+1}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.6278em;vertical-align:-1.1778em;"></span><span class="mord"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size3">(</span></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.3806em;"><span style="top:-1.9056em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord">1</span></span></span><span style="top:-3.15em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.2em;"></span></span><span style="top:-3.95em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.1778em;"><span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size3">]</span></span></span></span></span></span></td>
<td style="text-align:left"><code>\genfrac ( ] {2pt}{0}a{a+1}</code></td>
</tr>
<tr>
<td style="text-align:left">\geq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≥</mo></mrow><annotation encoding="application/x-tex">\geq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mrel">≥</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\geqq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≧</mo></mrow><annotation encoding="application/x-tex">\geqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0117em;vertical-align:-0.2558em;"></span><span class="mrel amsrm">≧</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\geqslant</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⩾</mo></mrow><annotation encoding="application/x-tex">\geqslant</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7733em;vertical-align:-0.1367em;"></span><span class="mrel amsrm">⩾</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\gets</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>←</mo></mrow><annotation encoding="application/x-tex">\gets</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">←</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\gg</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≫</mo></mrow><annotation encoding="application/x-tex">\gg</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">≫</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\ggg</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋙</mo></mrow><annotation encoding="application/x-tex">\ggg</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.585em;vertical-align:-0.0352em;"></span><span class="mrel amsrm">⋙</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\gggtr</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋙</mo></mrow><annotation encoding="application/x-tex">\gggtr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.585em;vertical-align:-0.0352em;"></span><span class="mrel amsrm">⋙</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\gimel</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">ℷ</mi></mrow><annotation encoding="application/x-tex">\gimel</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord amsrm">ℷ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\global</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>2</mn><mo>+</mo><mn>3</mn></mrow><annotation encoding="application/x-tex">\global\def\add#1#2{#1+#2} \add 2 3</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7278em;vertical-align:-0.0833em;"></span><span class="mord">2</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">3</span></span></span></span></td>
<td style="text-align:left"><code>\global\def\add#1#2{#1+#2} \add 2 3</code></td>
</tr>
<tr>
<td style="text-align:left">\gnapprox</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⪊</mo></mrow><annotation encoding="application/x-tex">\gnapprox</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0189em;vertical-align:-0.2617em;"></span><span class="mrel amsrm">⪊</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\gneq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⪈</mo></mrow><annotation encoding="application/x-tex">\gneq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mrel amsrm">⪈</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\gneqq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≩</mo></mrow><annotation encoding="application/x-tex">\gneqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0087em;vertical-align:-0.2514em;"></span><span class="mrel amsrm">≩</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\gnsim</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋧</mo></mrow><annotation encoding="application/x-tex">\gnsim</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9733em;vertical-align:-0.2322em;"></span><span class="mrel amsrm">⋧</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\grave</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mrow><mi>e</mi><mi>u</mi></mrow><mo>ˋ</mo></mover></mrow><annotation encoding="application/x-tex">\grave{eu}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6944em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">e</span><span class="mord mathnormal">u</span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.25em;"><span class="mord">ˋ</span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\grave{eu}</code></td>
</tr>
<tr>
<td style="text-align:left">\gt</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mo>&gt;</mo><mi>b</mi></mrow><annotation encoding="application/x-tex">a \gt b</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mord mathnormal">a</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">&gt;</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">b</span></span></span></span></td>
<td style="text-align:left"><code>a \gt b</code></td>
</tr>
<tr>
<td style="text-align:left">\gtrdot</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋗</mo></mrow><annotation encoding="application/x-tex">\gtrdot</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mord amsrm">⋗</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\gtrapprox</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⪆</mo></mrow><annotation encoding="application/x-tex">\gtrapprox</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0117em;vertical-align:-0.2558em;"></span><span class="mrel amsrm">⪆</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\gtreqless</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋛</mo></mrow><annotation encoding="application/x-tex">\gtreqless</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2714em;vertical-align:-0.3857em;"></span><span class="mrel amsrm">⋛</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\gtreqqless</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⪌</mo></mrow><annotation encoding="application/x-tex">\gtreqqless</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.4651em;vertical-align:-0.4826em;"></span><span class="mrel amsrm">⪌</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\gtrless</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≷</mo></mrow><annotation encoding="application/x-tex">\gtrless</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8558em;vertical-align:-0.1808em;"></span><span class="mrel amsrm">≷</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\gtrsim</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≳</mo></mrow><annotation encoding="application/x-tex">\gtrsim</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9592em;vertical-align:-0.2296em;"></span><span class="mrel amsrm">≳</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\gvertneqq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≩</mo></mrow><annotation encoding="application/x-tex">\gvertneqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0087em;vertical-align:-0.2514em;"></span><span class="mrel amsrm"></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
</tbody>
</table>
<h2 id="h" tabindex="-1">H <a class="header-anchor" href="#h" aria-label="Permalink to &quot;H&quot;">&ZeroWidthSpace;</a></h2>
<table>
<thead>
<tr>
<th style="text-align:left">Symbol/Function</th>
<th style="text-align:left">Rendered</th>
<th style="text-align:left">Source or Comment</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">\H</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mtext>a</mtext><mo>˝</mo></mover></mrow><annotation encoding="application/x-tex">\text{\H{a}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6944em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">a</span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.25em;"><span class="mord">˝</span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\H{a}}</code></td>
</tr>
<tr>
<td style="text-align:left">\Harr</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇔</mo></mrow><annotation encoding="application/x-tex">\Harr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">⇔</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\hArr</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇔</mo></mrow><annotation encoding="application/x-tex">\hArr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">⇔</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\harr</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↔</mo></mrow><annotation encoding="application/x-tex">\harr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">↔</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\hat</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mi>θ</mi><mo>^</mo></mover></mrow><annotation encoding="application/x-tex">\hat{\theta}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9579em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.9579em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord mathnormal" style="margin-right:0.02778em;">θ</span></span><span style="top:-3.2634em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.1667em;"><span class="mord">^</span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\hat{\theta}</code></td>
</tr>
<tr>
<td style="text-align:left">\hbar</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">ℏ</mi></mrow><annotation encoding="application/x-tex">\hbar</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord">ℏ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\hbox</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\hdashline</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mtable rowspacing="0.16em" columnalign="center center" columnspacing="1em" rowlines="dashed"><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>a</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>b</mi></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>c</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>d</mi></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{matrix}a&amp;b\\ \hdashline c &amp;d\end{matrix}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.4em;vertical-align:-0.95em;"></span><span class="mord"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.45em;"><span class="pstrut" style="height:3.45em;"></span><span class="mtable"><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:0.5em;"></span><span class="arraycolsep" style="width:0.5em;"></span><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">b</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">d</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span></span></span><span style="top:-3.7em;"><span class="pstrut" style="height:3.45em;"></span><span class="hdashline" style="border-bottom-width:0.04em;"></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\begin{matrix}</code><br>   <code>a &amp; b \\</code><br>   <code>\hdashline</code><br>   <code>c &amp; d</code><br><code>\end{matrix}</code></td>
</tr>
<tr>
<td style="text-align:left">\hearts</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">♡</mi></mrow><annotation encoding="application/x-tex">\hearts</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8241em;vertical-align:-0.1296em;"></span><span class="mord">♡</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\heartsuit</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">♡</mi></mrow><annotation encoding="application/x-tex">\heartsuit</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8241em;vertical-align:-0.1296em;"></span><span class="mord">♡</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\hfil</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\hfill</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left">Issues <a href="https://github.com/KaTeX/KaTeX/issues/164" target="_blank" rel="noreferrer">#164</a> &amp; <a href="https://github.com/KaTeX/KaTeX/issues/269" target="_blank" rel="noreferrer">#269</a></td>
</tr>
<tr>
<td style="text-align:left">\hline</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mtable rowspacing="0.16em" columnalign="center center" columnspacing="1em" rowlines="solid"><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>a</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>b</mi></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>c</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>d</mi></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{matrix}a&amp;b\\ \hline c &amp;d\end{matrix}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.4em;vertical-align:-0.95em;"></span><span class="mord"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.45em;"><span class="pstrut" style="height:3.45em;"></span><span class="mtable"><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:0.5em;"></span><span class="arraycolsep" style="width:0.5em;"></span><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">b</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">d</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span></span></span><span style="top:-3.7em;"><span class="pstrut" style="height:3.45em;"></span><span class="hline" style="border-bottom-width:0.04em;"></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\begin{matrix}</code><br>   <code>a &amp; b \\ \hline</code><br>   <code>c &amp; d</code><br><code>\end{matrix}</code></td>
</tr>
<tr>
<td style="text-align:left">\hom</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>hom</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\hom</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mop">hom</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\hookleftarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↩</mo></mrow><annotation encoding="application/x-tex">\hookleftarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.522em;vertical-align:-0.011em;"></span><span class="mrel">↩</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\hookrightarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↪</mo></mrow><annotation encoding="application/x-tex">\hookrightarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.522em;vertical-align:-0.011em;"></span><span class="mrel">↪</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\hphantom</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mpadded height="0px" depth="0px"><mphantom><mi>b</mi><mi>c</mi></mphantom></mpadded><mi>d</mi></mrow><annotation encoding="application/x-tex">a\hphantom{bc}d</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">a</span><span class="mord"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span><span class="mord" style="color:transparent;"><span class="mord mathnormal" style="color:transparent;">b</span><span class="mord mathnormal" style="color:transparent;">c</span></span></span></span></span></span></span></span><span class="mord mathnormal">d</span></span></span></span></td>
<td style="text-align:left"><code>a\hphantom{bc}d</code></td>
</tr>
<tr>
<td style="text-align:left">\href</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathcolor="#cc0000"><mtext>\href</mtext></mstyle></mrow><annotation encoding="application/x-tex">\href{https://katex.org/}{\KaTeX}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\href</span></span></span></span></span></td>
<td style="text-align:left"><code>\href{https://katex.org/}{\KaTeX}</code> Requires <code>trust</code></td>
</tr>
<tr>
<td style="text-align:left">\hskip</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>w</mi><mspace width="1em"/><mi>i</mi><mspace width="2em"/><mi>d</mi></mrow><annotation encoding="application/x-tex">w\hskip1em i\hskip2em d</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal" style="margin-right:0.02691em;">w</span><span class="mspace" style="margin-right:1em;"></span><span class="mord mathnormal">i</span><span class="mspace" style="margin-right:2em;"></span><span class="mord mathnormal">d</span></span></span></span></td>
<td style="text-align:left"><code>w\hskip1em i\hskip2em d</code></td>
</tr>
<tr>
<td style="text-align:left">\hslash</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">ℏ</mi></mrow><annotation encoding="application/x-tex">\hslash</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord amsrm">ℏ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\hspace</td>
<td style="text-align:left"><span class='katex-error' title='ParseError: KaTeX parse error: Invalid size: &#039;7&#039; at position 9: s\hspace7̲ex k'>s\hspace7ex k</span></td>
<td style="text-align:left"><code>s\hspace7ex k</code></td>
</tr>
<tr>
<td style="text-align:left">\htmlClass</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathcolor="#cc0000"><mtext>\htmlClass</mtext></mstyle></mrow><annotation encoding="application/x-tex">\htmlClass{foo}{x}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\htmlClass</span></span></span></span></span></td>
<td style="text-align:left"><code>\htmlClass{foo}{x}</code> Must enable <code>trust</code> and disable <code>strict</code></td>
</tr>
<tr>
<td style="text-align:left">\htmlData</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathcolor="#cc0000"><mtext>\htmlData</mtext></mstyle></mrow><annotation encoding="application/x-tex">\htmlData{foo=a, bar=b}{x}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\htmlData</span></span></span></span></span></td>
<td style="text-align:left"><code>\htmlData{foo=a, bar=b}{x}</code> Must enable <code>trust</code> and disable <code>strict</code></td>
</tr>
<tr>
<td style="text-align:left">\htmlId</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathcolor="#cc0000"><mtext>\htmlId</mtext></mstyle></mrow><annotation encoding="application/x-tex">\htmlId{bar}{x}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\htmlId</span></span></span></span></span></td>
<td style="text-align:left"><code>\htmlId{bar}{x}</code> Must enable <code>trust</code> and disable <code>strict</code></td>
</tr>
<tr>
<td style="text-align:left">\htmlStyle</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathcolor="#cc0000"><mtext>\htmlStyle</mtext></mstyle></mrow><annotation encoding="application/x-tex">\htmlStyle{color: red;}{x}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\htmlStyle</span></span></span></span></span></td>
<td style="text-align:left"><code>\htmlStyle{color: red;}{x}</code> Must enable <code>trust</code> and disable <code>strict</code></td>
</tr>
<tr>
<td style="text-align:left">\huge</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathsize="2.074em"><mi>h</mi><mi>u</mi><mi>g</mi><mi>e</mi></mstyle></mrow><annotation encoding="application/x-tex">\huge huge</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.8435em;vertical-align:-0.4033em;"></span><span class="mord mathnormal sizing reset-size6 size10">h</span><span class="mord mathnormal sizing reset-size6 size10" style="margin-right:0.03588em;">ug</span><span class="mord mathnormal sizing reset-size6 size10">e</span></span></span></span></td>
<td style="text-align:left"><code>\huge huge</code></td>
</tr>
<tr>
<td style="text-align:left">\Huge</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathsize="2.488em"><mi>H</mi><mi>u</mi><mi>g</mi><mi>e</mi></mstyle></mrow><annotation encoding="application/x-tex">\Huge Huge</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.1839em;vertical-align:-0.4838em;"></span><span class="mord mathnormal sizing reset-size6 size11" style="margin-right:0.08125em;">H</span><span class="mord mathnormal sizing reset-size6 size11" style="margin-right:0.03588em;">ug</span><span class="mord mathnormal sizing reset-size6 size11">e</span></span></span></span></td>
<td style="text-align:left"><code>\Huge Huge</code></td>
</tr>
</tbody>
</table>
<h2 id="i" tabindex="-1">I <a class="header-anchor" href="#i" aria-label="Permalink to &quot;I&quot;">&ZeroWidthSpace;</a></h2>
<table>
<thead>
<tr>
<th style="text-align:left">Symbol/Function</th>
<th style="text-align:left">Rendered</th>
<th style="text-align:left">Source or Comment</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">\i</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>ı</mtext></mrow><annotation encoding="application/x-tex">\text{\i}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord text"><span class="mord latin_fallback">ı</span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\i}</code></td>
</tr>
<tr>
<td style="text-align:left">\idotsint</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\iddots</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"><a href="https://github.com/KaTeX/KaTeX/issues/1223" target="_blank" rel="noreferrer">Issue #1223</a></td>
</tr>
<tr>
<td style="text-align:left">\if</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"><a href="https://github.com/KaTeX/KaTeX/issues/1003" target="_blank" rel="noreferrer">Issue #1003</a></td>
</tr>
<tr>
<td style="text-align:left">\iff</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>A</mi><mtext>  </mtext><mo>⟺</mo><mtext>  </mtext><mi>B</mi></mrow><annotation encoding="application/x-tex">A\iff B</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7073em;vertical-align:-0.024em;"></span><span class="mord mathnormal">A</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">⟺</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span></span></td>
<td style="text-align:left"><code>A\iff B</code></td>
</tr>
<tr>
<td style="text-align:left">\ifmode</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"><a href="https://github.com/KaTeX/KaTeX/issues/1003" target="_blank" rel="noreferrer">Issue #1003</a></td>
</tr>
<tr>
<td style="text-align:left">\ifx</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"><a href="https://github.com/KaTeX/KaTeX/issues/1003" target="_blank" rel="noreferrer">Issue #1003</a></td>
</tr>
<tr>
<td style="text-align:left">\iiiint</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\iiint</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∭</mo></mrow><annotation encoding="application/x-tex">\iiint</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.111em;vertical-align:-0.306em;"></span><span class="mop op-symbol small-op" style="margin-right:0.19445em;position:relative;top:-0.0005em;">∭</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\iint</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∬</mo></mrow><annotation encoding="application/x-tex">\iint</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.111em;vertical-align:-0.306em;"></span><span class="mop op-symbol small-op" style="margin-right:0.19445em;position:relative;top:-0.0005em;">∬</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Im</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">ℑ</mi></mrow><annotation encoding="application/x-tex">\Im</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">ℑ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\image</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">ℑ</mi></mrow><annotation encoding="application/x-tex">\image</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">ℑ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\imath</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">ı</mi></mrow><annotation encoding="application/x-tex">\imath</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal"></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\impliedby</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>P</mi><mtext>  </mtext><mo>⟸</mo><mtext>  </mtext><mi>Q</mi></mrow><annotation encoding="application/x-tex">P\impliedby Q</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7073em;vertical-align:-0.024em;"></span><span class="mord mathnormal" style="margin-right:0.13889em;">P</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">⟸</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8778em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">Q</span></span></span></span></td>
<td style="text-align:left"><code>P\impliedby Q</code></td>
</tr>
<tr>
<td style="text-align:left">\implies</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>P</mi><mtext>  </mtext><mo>⟹</mo><mtext>  </mtext><mi>Q</mi></mrow><annotation encoding="application/x-tex">P\implies Q</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7073em;vertical-align:-0.024em;"></span><span class="mord mathnormal" style="margin-right:0.13889em;">P</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">⟹</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8778em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">Q</span></span></span></span></td>
<td style="text-align:left"><code>P\implies Q</code></td>
</tr>
<tr>
<td style="text-align:left">\in</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∈</mo></mrow><annotation encoding="application/x-tex">\in</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">∈</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\includegraphics</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathcolor="#cc0000"><mtext>\includegraphics</mtext></mstyle></mrow><annotation encoding="application/x-tex">\includegraphics[height=0.8em, totalheight=0.9em, width=0.9em, alt=KA logo]{https://cdn.kastatic.org/images/apple-touch-icon-57x57-precomposed.new.png}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\includegraphics</span></span></span></span></span></td>
<td style="text-align:left"><code>\includegraphics[height=0.8em, totalheight=0.9em, width=0.9em, alt=KA logo]{https://cdn.kastatic.org/images/apple-touch-icon-57x57-precomposed.new.png}</code> Requires <code>trust</code></td>
</tr>
<tr>
<td style="text-align:left">\inf</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>inf</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\inf</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mop">in<span style="margin-right:0.07778em;">f</span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\infin</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∞</mi></mrow><annotation encoding="application/x-tex">\infin</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord">∞</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\infty</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∞</mi></mrow><annotation encoding="application/x-tex">\infty</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord">∞</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\injlim</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\int</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∫</mo></mrow><annotation encoding="application/x-tex">\int</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1111em;vertical-align:-0.3061em;"></span><span class="mop op-symbol small-op" style="margin-right:0.19445em;position:relative;top:-0.0006em;">∫</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\intercal</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊺</mo></mrow><annotation encoding="application/x-tex">\intercal</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord amsrm">⊺</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\intop</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∫</mo></mrow><annotation encoding="application/x-tex">\intop</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1111em;vertical-align:-0.3061em;"></span><span class="mop op-symbol small-op" style="margin-right:0.19445em;position:relative;top:-0.0006em;">∫</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Iota</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">I</mi></mrow><annotation encoding="application/x-tex">\Iota</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathrm">I</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\iota</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ι</mi></mrow><annotation encoding="application/x-tex">\iota</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">ι</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\isin</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∈</mo></mrow><annotation encoding="application/x-tex">\isin</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">∈</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\it</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>A</mi><mi>a</mi><mi>B</mi><mi>b</mi></mrow><annotation encoding="application/x-tex">{\it AaBb}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord"><span class="mord"><span class="mord mathit">AaBb</span></span></span></span></span></span></td>
<td style="text-align:left"><code>{\it AaBb}</code></td>
</tr>
<tr>
<td style="text-align:left">\itshape</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
</tbody>
</table>
<h2 id="jk" tabindex="-1">JK <a class="header-anchor" href="#jk" aria-label="Permalink to &quot;JK&quot;">&ZeroWidthSpace;</a></h2>
<table>
<thead>
<tr>
<th style="text-align:left">Symbol/Function</th>
<th style="text-align:left">Rendered</th>
<th style="text-align:left">Source or Comment</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">\j</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>ȷ</mtext></mrow><annotation encoding="application/x-tex">\text{\j}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord text"><span class="mord latin_fallback">ȷ</span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\j}</code></td>
</tr>
<tr>
<td style="text-align:left">\jmath</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">ȷ</mi></mrow><annotation encoding="application/x-tex">\jmath</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal"></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Join</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋈</mo></mrow><annotation encoding="application/x-tex">\Join</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.51em;vertical-align:-0.005em;"></span><span class="mrel">⋈</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Kappa</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">K</mi></mrow><annotation encoding="application/x-tex">\Kappa</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathrm">K</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\kappa</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>κ</mi></mrow><annotation encoding="application/x-tex">\kappa</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">κ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\KaTeX</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>KaTeX</mtext></mrow><annotation encoding="application/x-tex">\KaTeX</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8988em;vertical-align:-0.2155em;"></span><span class="mord text"><span class="mord textrm">K</span><span class="mspace" style="margin-right:-0.17em;"></span><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6833em;"><span style="top:-2.905em;"><span class="pstrut" style="height:2.7em;"></span><span class="mord"><span class="mord textrm mtight sizing reset-size6 size3">A</span></span></span></span></span></span><span class="mspace" style="margin-right:-0.15em;"></span><span class="mord text"><span class="mord textrm">T</span><span class="mspace" style="margin-right:-0.1667em;"></span><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.4678em;"><span style="top:-2.7845em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord textrm">E</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2155em;"><span></span></span></span></span><span class="mspace" style="margin-right:-0.125em;"></span><span class="mord textrm">X</span></span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\ker</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ker</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\ker</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mop">ker</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\kern</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>I</mi><mspace width="-0.25em"/><mi>R</mi></mrow><annotation encoding="application/x-tex">I\kern-2.5pt R</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="mspace" style="margin-right:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.00773em;">R</span></span></span></span></td>
<td style="text-align:left"><code>I\kern-2.5pt R</code></td>
</tr>
<tr>
<td style="text-align:left">\Ket</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true">∣</mo><mi>ψ</mi><mo fence="true">⟩</mo></mrow><annotation encoding="application/x-tex">\left|\psi\right\rangle</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">∣</span><span class="mord mathnormal" style="margin-right:0.03588em;">ψ</span><span class="mclose delimcenter" style="top:0em;">⟩</span></span></span></span></span></td>
<td style="text-align:left"><code>\Ket{\psi}</code></td>
</tr>
<tr>
<td style="text-align:left">\ket</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mpadded><mi mathvariant="normal">∣</mi><mi>ψ</mi><mo stretchy="false">⟩</mo></mpadded></mrow><annotation encoding="application/x-tex">\mathinner{|{\psi}\rangle}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="minner"><span class="mord">∣</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">ψ</span></span><span class="mclose">⟩</span></span></span></span></span></td>
<td style="text-align:left"><code>\ket{\psi}</code></td>
</tr>
<tr>
<td style="text-align:left">\Koppa</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\koppa</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
</tbody>
</table>
<h2 id="l" tabindex="-1">L <a class="header-anchor" href="#l" aria-label="Permalink to &quot;L&quot;">&ZeroWidthSpace;</a></h2>
<table>
<thead>
<tr>
<th style="text-align:left">Symbol/Function</th>
<th style="text-align:left">Rendered</th>
<th style="text-align:left">Source or Comment</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">\L</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\l</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Lambda</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Λ</mi></mrow><annotation encoding="application/x-tex">\Lambda</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">Λ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\lambda</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>λ</mi></mrow><annotation encoding="application/x-tex">\lambda</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">λ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\label</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\land</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∧</mo></mrow><annotation encoding="application/x-tex">\land</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5556em;"></span><span class="mord">∧</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\lang</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">⟨</mo><mi>A</mi><mo stretchy="false">⟩</mo></mrow><annotation encoding="application/x-tex">\lang A\rangle</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">⟨</span><span class="mord mathnormal">A</span><span class="mclose">⟩</span></span></span></span></td>
<td style="text-align:left"><code>\lang A\rangle</code></td>
</tr>
<tr>
<td style="text-align:left">\langle</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">⟨</mo><mi>A</mi><mo stretchy="false">⟩</mo></mrow><annotation encoding="application/x-tex">\langle A\rangle</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">⟨</span><span class="mord mathnormal">A</span><span class="mclose">⟩</span></span></span></span></td>
<td style="text-align:left"><code>\langle A\rangle</code></td>
</tr>
<tr>
<td style="text-align:left">\Larr</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇐</mo></mrow><annotation encoding="application/x-tex">\Larr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">⇐</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\lArr</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇐</mo></mrow><annotation encoding="application/x-tex">\lArr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">⇐</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\larr</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>←</mo></mrow><annotation encoding="application/x-tex">\larr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">←</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\large</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathsize="1.2em"><mi>l</mi><mi>a</mi><mi>r</mi><mi>g</mi><mi>e</mi></mstyle></mrow><annotation encoding="application/x-tex">\large large</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0667em;vertical-align:-0.2333em;"></span><span class="mord mathnormal sizing reset-size6 size7" style="margin-right:0.01968em;">l</span><span class="mord mathnormal sizing reset-size6 size7">a</span><span class="mord mathnormal sizing reset-size6 size7" style="margin-right:0.02778em;">r</span><span class="mord mathnormal sizing reset-size6 size7" style="margin-right:0.03588em;">g</span><span class="mord mathnormal sizing reset-size6 size7">e</span></span></span></span></td>
<td style="text-align:left"><code>\large large</code></td>
</tr>
<tr>
<td style="text-align:left">\Large</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathsize="1.44em"><mi>L</mi><mi>a</mi><mi>r</mi><mi>g</mi><mi>e</mi></mstyle></mrow><annotation encoding="application/x-tex">\Large Large</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.264em;vertical-align:-0.28em;"></span><span class="mord mathnormal sizing reset-size6 size8">L</span><span class="mord mathnormal sizing reset-size6 size8">a</span><span class="mord mathnormal sizing reset-size6 size8" style="margin-right:0.02778em;">r</span><span class="mord mathnormal sizing reset-size6 size8" style="margin-right:0.03588em;">g</span><span class="mord mathnormal sizing reset-size6 size8">e</span></span></span></span></td>
<td style="text-align:left"><code>\Large Large</code></td>
</tr>
<tr>
<td style="text-align:left">\LARGE</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathsize="1.728em"><mi>L</mi><mi>A</mi><mi>R</mi><mi>G</mi><mi>E</mi></mstyle></mrow><annotation encoding="application/x-tex">\LARGE LARGE</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1808em;"></span><span class="mord mathnormal sizing reset-size6 size9">L</span><span class="mord mathnormal sizing reset-size6 size9">A</span><span class="mord mathnormal sizing reset-size6 size9" style="margin-right:0.05764em;">RGE</span></span></span></span></td>
<td style="text-align:left"><code>\LARGE LARGE</code></td>
</tr>
<tr>
<td style="text-align:left">\LaTeX</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>LaTeX</mtext></mrow><annotation encoding="application/x-tex">\LaTeX</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8988em;vertical-align:-0.2155em;"></span><span class="mord text"><span class="mord textrm">L</span><span class="mspace" style="margin-right:-0.36em;"></span><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6833em;"><span style="top:-2.905em;"><span class="pstrut" style="height:2.7em;"></span><span class="mord"><span class="mord textrm mtight sizing reset-size6 size3">A</span></span></span></span></span></span><span class="mspace" style="margin-right:-0.15em;"></span><span class="mord text"><span class="mord textrm">T</span><span class="mspace" style="margin-right:-0.1667em;"></span><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.4678em;"><span style="top:-2.7845em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord textrm">E</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2155em;"><span></span></span></span></span><span class="mspace" style="margin-right:-0.125em;"></span><span class="mord textrm">X</span></span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\lBrace</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo mathvariant="normal" lspace="0em" rspace="0em">⦃</mo></mrow><annotation encoding="application/x-tex">\lBrace</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen"><span class="mopen">{</span><span class="mspace" style="margin-right:-0.1778em;"></span><span class="mopen">[</span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\lbrace</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">{</mo></mrow><annotation encoding="application/x-tex">\lbrace</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">{</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\lbrack</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">[</mo></mrow><annotation encoding="application/x-tex">\lbrack</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">[</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\lceil</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">⌈</mo></mrow><annotation encoding="application/x-tex">\lceil</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">⌈</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\ldotp</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo separator="true">.</mo></mrow><annotation encoding="application/x-tex">\ldotp</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.1056em;"></span><span class="mpunct">.</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\ldots</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>…</mo></mrow><annotation encoding="application/x-tex">\ldots</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.123em;"></span><span class="minner">…</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\le</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≤</mo></mrow><annotation encoding="application/x-tex">\le</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mrel">≤</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\leadsto</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇝</mo></mrow><annotation encoding="application/x-tex">\leadsto</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3779em;"></span><span class="mrel amsrm">⇝</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\left</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true">{</mo><mstyle displaystyle="true" scriptlevel="0"><mfrac><mi>a</mi><mi>b</mi></mfrac></mstyle></mrow><annotation encoding="application/x-tex">\left\lbrace \dfrac ab \right.</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.836em;vertical-align:-0.686em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size2">{</span></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1076em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">b</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mclose nulldelimiter"></span></span></span></span></span></td>
<td style="text-align:left"><code>\left\lbrace \dfrac ab \right.</code></td>
</tr>
<tr>
<td style="text-align:left">\leftarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>←</mo></mrow><annotation encoding="application/x-tex">\leftarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">←</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Leftarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇐</mo></mrow><annotation encoding="application/x-tex">\Leftarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">⇐</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\LeftArrow</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left">Non standard</td>
</tr>
<tr>
<td style="text-align:left">\leftarrowtail</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\leftharpoondown</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↽</mo></mrow><annotation encoding="application/x-tex">\leftharpoondown</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">↽</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\leftharpoonup</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↼</mo></mrow><annotation encoding="application/x-tex">\leftharpoonup</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">↼</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\leftleftarrows</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇇</mo></mrow><annotation encoding="application/x-tex">\leftleftarrows</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8558em;vertical-align:-0.1808em;"></span><span class="mrel amsrm">⇇</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Leftrightarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇔</mo></mrow><annotation encoding="application/x-tex">\Leftrightarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">⇔</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\leftrightarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↔</mo></mrow><annotation encoding="application/x-tex">\leftrightarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">↔</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\leftrightarrows</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇆</mo></mrow><annotation encoding="application/x-tex">\leftrightarrows</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8558em;vertical-align:-0.1808em;"></span><span class="mrel amsrm">⇆</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\leftrightharpoons</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇋</mo></mrow><annotation encoding="application/x-tex">\leftrightharpoons</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5359em;vertical-align:-0.0135em;"></span><span class="mrel amsrm">⇋</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\leftrightsquigarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↭</mo></mrow><annotation encoding="application/x-tex">\leftrightsquigarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3779em;"></span><span class="mrel amsrm">↭</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\leftroot</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\leftthreetimes</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋋</mo></mrow><annotation encoding="application/x-tex">\leftthreetimes</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mord amsrm">⋋</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\leq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≤</mo></mrow><annotation encoding="application/x-tex">\leq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mrel">≤</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\leqalignno</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\leqq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≦</mo></mrow><annotation encoding="application/x-tex">\leqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0117em;vertical-align:-0.2558em;"></span><span class="mrel amsrm">≦</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\leqslant</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⩽</mo></mrow><annotation encoding="application/x-tex">\leqslant</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7733em;vertical-align:-0.1367em;"></span><span class="mrel amsrm">⩽</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\lessapprox</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⪅</mo></mrow><annotation encoding="application/x-tex">\lessapprox</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0117em;vertical-align:-0.2558em;"></span><span class="mrel amsrm">⪅</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\lessdot</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋖</mo></mrow><annotation encoding="application/x-tex">\lessdot</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mord amsrm">⋖</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\lesseqgtr</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋚</mo></mrow><annotation encoding="application/x-tex">\lesseqgtr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2714em;vertical-align:-0.3857em;"></span><span class="mrel amsrm">⋚</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\lesseqqgtr</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⪋</mo></mrow><annotation encoding="application/x-tex">\lesseqqgtr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.4651em;vertical-align:-0.4826em;"></span><span class="mrel amsrm">⪋</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\lessgtr</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≶</mo></mrow><annotation encoding="application/x-tex">\lessgtr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8558em;vertical-align:-0.1808em;"></span><span class="mrel amsrm">≶</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\lesssim</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≲</mo></mrow><annotation encoding="application/x-tex">\lesssim</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9592em;vertical-align:-0.2296em;"></span><span class="mrel amsrm">≲</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\let</td>
<td style="text-align:left"></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\lfloor</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">⌊</mo></mrow><annotation encoding="application/x-tex">\lfloor</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">⌊</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\lg</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>lg</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\lg</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mop">l<span style="margin-right:0.01389em;">g</span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\lgroup</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">⟮</mo></mrow><annotation encoding="application/x-tex">\lgroup</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.988em;vertical-align:-0.244em;"></span><span class="mopen">⟮</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\lhd</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊲</mo></mrow><annotation encoding="application/x-tex">\lhd</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.585em;vertical-align:-0.0352em;"></span><span class="mord amsrm">⊲</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\lim</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>lim</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\lim</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mop">lim</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\liminf</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">lim inf</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\liminf</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mop"><span class="mord mathrm">lim</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathrm" style="margin-right:0.07778em;">inf</span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\limits</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><munder><mrow><mi>lim</mi><mo>⁡</mo></mrow><mi>x</mi></munder></mrow><annotation encoding="application/x-tex">\lim\limits_x</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.3944em;vertical-align:-0.7em;"></span><span class="mop op-limits"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6944em;"><span style="top:-2.4em;margin-left:0em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">x</span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span><span class="mop">lim</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.7em;"><span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\lim\limits_x</code></td>
</tr>
<tr>
<td style="text-align:left">\limsup</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">lim sup</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\limsup</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mop"><span class="mord mathrm">lim</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathrm">sup</span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\ll</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≪</mo></mrow><annotation encoding="application/x-tex">\ll</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">≪</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\llap</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo lspace="0em" rspace="0em">=</mo><mpadded lspace="-1width" width="0px"><mrow><mtext>/</mtext><mtext> </mtext></mrow></mpadded></mrow><annotation encoding="application/x-tex">{=}\llap{/\,}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord"><span class="mrel">=</span></span><span class="mord vbox"><span class="thinbox"><span class="llap"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="inner"><span class="mord"><span class="mord text"><span class="mord textrm">/</span><span class="mspace" style="margin-right:0.1667em;"></span></span></span></span><span class="fix"></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>{=}\llap{/\,}</code></td>
</tr>
<tr>
<td style="text-align:left">\llbracket</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo mathvariant="normal" lspace="0em" rspace="0em">⟦</mo></mrow><annotation encoding="application/x-tex">\llbracket</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen"><span class="mopen">[</span><span class="mspace" style="margin-right:-0.1778em;"></span><span class="mopen">[</span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\llcorner</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mi mathvariant="normal">⌞</mi></mo></mrow><annotation encoding="application/x-tex">\llcorner</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3779em;"></span><span class="mopen amsrm">└</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Lleftarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇚</mo></mrow><annotation encoding="application/x-tex">\Lleftarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7733em;vertical-align:-0.1367em;"></span><span class="mrel amsrm">⇚</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\lll</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋘</mo></mrow><annotation encoding="application/x-tex">\lll</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.585em;vertical-align:-0.0352em;"></span><span class="mrel amsrm">⋘</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\llless</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋘</mo></mrow><annotation encoding="application/x-tex">\llless</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.585em;vertical-align:-0.0352em;"></span><span class="mrel amsrm">⋘</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\lmoustache</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">⎰</mo></mrow><annotation encoding="application/x-tex">\lmoustache</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.988em;vertical-align:-0.244em;"></span><span class="mopen">⎰</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\ln</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ln</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\ln</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mop">ln</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\lnapprox</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⪉</mo></mrow><annotation encoding="application/x-tex">\lnapprox</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0189em;vertical-align:-0.2617em;"></span><span class="mrel amsrm">⪉</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\lneq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⪇</mo></mrow><annotation encoding="application/x-tex">\lneq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mrel amsrm">⪇</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\lneqq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≨</mo></mrow><annotation encoding="application/x-tex">\lneqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0087em;vertical-align:-0.2514em;"></span><span class="mrel amsrm">≨</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\lnot</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">¬</mi></mrow><annotation encoding="application/x-tex">\lnot</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord">¬</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\lnsim</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋦</mo></mrow><annotation encoding="application/x-tex">\lnsim</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9733em;vertical-align:-0.2322em;"></span><span class="mrel amsrm">⋦</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\log</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>log</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\log</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mop">lo<span style="margin-right:0.01389em;">g</span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\long</td>
<td style="text-align:left"></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Longleftarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⟸</mo></mrow><annotation encoding="application/x-tex">\Longleftarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.549em;vertical-align:-0.024em;"></span><span class="mrel">⟸</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\longleftarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⟵</mo></mrow><annotation encoding="application/x-tex">\longleftarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.522em;vertical-align:-0.011em;"></span><span class="mrel">⟵</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Longleftrightarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⟺</mo></mrow><annotation encoding="application/x-tex">\Longleftrightarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.549em;vertical-align:-0.024em;"></span><span class="mrel">⟺</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\longleftrightarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⟷</mo></mrow><annotation encoding="application/x-tex">\longleftrightarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.522em;vertical-align:-0.011em;"></span><span class="mrel">⟷</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\longmapsto</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⟼</mo></mrow><annotation encoding="application/x-tex">\longmapsto</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.522em;vertical-align:-0.011em;"></span><span class="mrel">⟼</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Longrightarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⟹</mo></mrow><annotation encoding="application/x-tex">\Longrightarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.549em;vertical-align:-0.024em;"></span><span class="mrel">⟹</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\longrightarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⟶</mo></mrow><annotation encoding="application/x-tex">\longrightarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.522em;vertical-align:-0.011em;"></span><span class="mrel">⟶</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\looparrowleft</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↫</mo></mrow><annotation encoding="application/x-tex">\looparrowleft</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5499em;"></span><span class="mrel amsrm">↫</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\looparrowright</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↬</mo></mrow><annotation encoding="application/x-tex">\looparrowright</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5499em;"></span><span class="mrel amsrm">↬</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\lor</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∨</mo></mrow><annotation encoding="application/x-tex">\lor</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5556em;"></span><span class="mord">∨</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\lower</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\lozenge</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">◊</mi></mrow><annotation encoding="application/x-tex">\lozenge</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8034em;vertical-align:-0.1111em;"></span><span class="mord amsrm">◊</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\lparen</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">(</mo></mrow><annotation encoding="application/x-tex">\lparen</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">(</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Lrarr</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇔</mo></mrow><annotation encoding="application/x-tex">\Lrarr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">⇔</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\lrArr</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇔</mo></mrow><annotation encoding="application/x-tex">\lrArr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">⇔</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\lrarr</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↔</mo></mrow><annotation encoding="application/x-tex">\lrarr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">↔</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\lrcorner</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mi mathvariant="normal">⌟</mi></mo></mrow><annotation encoding="application/x-tex">\lrcorner</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3779em;"></span><span class="mclose amsrm">┘</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\lq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">‘</mi></mrow><annotation encoding="application/x-tex">\lq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">‘</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Lsh</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↰</mo></mrow><annotation encoding="application/x-tex">\Lsh</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mrel amsrm">↰</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\lt</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>&lt;</mo></mrow><annotation encoding="application/x-tex">\lt</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">&lt;</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\ltimes</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋉</mo></mrow><annotation encoding="application/x-tex">\ltimes</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6633em;vertical-align:-0.0817em;"></span><span class="mord amsrm">⋉</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\lVert</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">∥</mo></mrow><annotation encoding="application/x-tex">\lVert</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">∥</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\lvert</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">∣</mo></mrow><annotation encoding="application/x-tex">\lvert</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">∣</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\lvertneqq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≨</mo></mrow><annotation encoding="application/x-tex">\lvertneqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0087em;vertical-align:-0.2514em;"></span><span class="mrel amsrm"></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
</tbody>
</table>
<h2 id="m" tabindex="-1">M <a class="header-anchor" href="#m" aria-label="Permalink to &quot;M&quot;">&ZeroWidthSpace;</a></h2>
<table>
<thead>
<tr>
<th style="text-align:left">Symbol/Function</th>
<th style="text-align:left">Rendered</th>
<th style="text-align:left">Source or Comment</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">\maltese</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">✠</mi></mrow><annotation encoding="application/x-tex">\maltese</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mord amsrm">✠</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\mapsto</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↦</mo></mrow><annotation encoding="application/x-tex">\mapsto</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.522em;vertical-align:-0.011em;"></span><span class="mrel">↦</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\mathbb</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="double-struck">A</mi><mi mathvariant="double-struck">B</mi></mrow><annotation encoding="application/x-tex">\mathbb{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord"><span class="mord mathbb">AB</span></span></span></span></span></td>
<td style="text-align:left"><code>\mathbb{AB}</code><br>KaTeX supports A-Z k</td>
</tr>
<tr>
<td style="text-align:left">\mathbf</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="bold">A</mi><mi mathvariant="bold">a</mi><mi mathvariant="bold">B</mi><mi mathvariant="bold">b</mi><mn mathvariant="bold">123</mn></mrow><annotation encoding="application/x-tex">\mathbf{AaBb123}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord"><span class="mord mathbf">AaBb123</span></span></span></span></span></td>
<td style="text-align:left"><code>\mathbf{AaBb123}</code></td>
</tr>
<tr>
<td style="text-align:left">\mathbin</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mo stretchy="false" lspace="0.22em" rspace="0.22em">!</mo><mi>b</mi></mrow><annotation encoding="application/x-tex">a\mathbin{!}b</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">a</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin"><span class="mclose">!</span></span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">b</span></span></span></span></td>
<td style="text-align:left"><code>a\mathbin{!}b</code></td>
</tr>
<tr>
<td style="text-align:left">\mathcal</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="script">A</mi><mi mathvariant="script">a</mi><mi mathvariant="script">B</mi><mi mathvariant="script">b</mi><mn mathvariant="script">123</mn></mrow><annotation encoding="application/x-tex">\mathcal{AaBb123}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord"><span class="mord mathcal">A</span><span class="mord mathnormal">a</span><span class="mord mathcal" style="margin-right:0.03041em;">B</span><span class="mord mathnormal">b</span><span class="mord">123</span></span></span></span></span></td>
<td style="text-align:left"><code>\mathcal{AaBb123}</code></td>
</tr>
<tr>
<td style="text-align:left">\mathchoice</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mrow><mtext> </mtext><mtext> </mtext></mrow><mi>b</mi></mrow><annotation encoding="application/x-tex">a\mathchoice{\,}{\,\,}{\,\,\,}{\,\,\,\,}b</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">a</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">b</span></span></span></span></td>
<td style="text-align:left"><code>a\mathchoice{\,}{\,\,}{\,\,\,}{\,\,\,\,}b</code></td>
</tr>
<tr>
<td style="text-align:left">\mathclap</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle scriptlevel="0" displaystyle="true"><munder><mo>∑</mo><mpadded lspace="-0.5width" width="0px"><mrow><mn>1</mn><mo>≤</mo><mi>i</mi><mo>≤</mo><mi>n</mi></mrow></mpadded></munder><msub><mi>x</mi><mi>i</mi></msub></mstyle></mrow><annotation encoding="application/x-tex">\displaystyle\sum_{\mathclap{1\le i\le n}} x_{i}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.4229em;vertical-align:-1.3728em;"></span><span class="mop op-limits"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.05em;"><span style="top:-1.8723em;margin-left:0em;"><span class="pstrut" style="height:3.05em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord vbox mtight"><span class="thinbox mtight"><span class="clap mtight"><span class="strut" style="height:0.7955em;vertical-align:-0.136em;"></span><span class="inner mtight"><span><span class="mord mtight"><span class="mord mtight">1</span><span class="mrel mtight">≤</span><span class="mord mathnormal mtight">i</span><span class="mrel mtight">≤</span><span class="mord mathnormal mtight">n</span></span></span></span><span class="fix"></span></span></span></span></span></span></span><span style="top:-3.05em;"><span class="pstrut" style="height:3.05em;"></span><span><span class="mop op-symbol large-op">∑</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.3728em;"><span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">i</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\sum_{\mathclap{1\le i\le n}} x_{i}</code></td>
</tr>
<tr>
<td style="text-align:left">\mathclose</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mo>+</mo><mo stretchy="false">(</mo><mi>b</mi><mo lspace="0em" rspace="0em">&gt;</mo><mo>+</mo><mi>c</mi></mrow><annotation encoding="application/x-tex">a + (b\mathclose\gt + c</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mord mathnormal">a</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">(</span><span class="mord mathnormal">b</span><span class="mclose"><span class="mrel">&gt;</span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">c</span></span></span></span></td>
<td style="text-align:left"><code>a + (b\mathclose\gt + c</code></td>
</tr>
<tr>
<td style="text-align:left">\mathellipsis</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>…</mo></mrow><annotation encoding="application/x-tex">\mathellipsis</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.123em;"></span><span class="minner">…</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\mathfrak</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="fraktur">A</mi><mi mathvariant="fraktur">a</mi><mi mathvariant="fraktur">B</mi><mi mathvariant="fraktur">b</mi></mrow><annotation encoding="application/x-tex">\mathfrak{AaBb}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6914em;"></span><span class="mord"><span class="mord mathfrak">AaBb</span></span></span></span></span></td>
<td style="text-align:left"><code>\mathfrak{AaBb}</code><br>KaTeX supports A-Za-z</td>
</tr>
<tr>
<td style="text-align:left">\mathinner</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mi>b</mi><mpadded><mtext>inside</mtext></mpadded><mi>c</mi><mi>d</mi></mrow><annotation encoding="application/x-tex">ab\mathinner{\text{inside}}cd</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">ab</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mord text"><span class="mord">inside</span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">c</span><span class="mord mathnormal">d</span></span></span></span></td>
<td style="text-align:left"><code>ab\mathinner{\text{inside}}cd</code></td>
</tr>
<tr>
<td style="text-align:left">\mathit</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>A</mi><mi>a</mi><mi>B</mi><mi>b</mi></mrow><annotation encoding="application/x-tex">\mathit{AaBb}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord"><span class="mord mathit">AaBb</span></span></span></span></span></td>
<td style="text-align:left"><code>\mathit{AaBb}</code><br>KaTeX supports A-Za-z</td>
</tr>
<tr>
<td style="text-align:left">\mathllap</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo lspace="0em" rspace="0em">=</mo><mpadded lspace="-1width" width="0px"><mrow><mi mathvariant="normal">/</mi><mtext> </mtext></mrow></mpadded></mrow><annotation encoding="application/x-tex">{=}\mathllap{/\,}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord"><span class="mrel">=</span></span><span class="mord vbox"><span class="thinbox"><span class="llap"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="inner"><span class="mord"><span class="mord">/</span><span class="mspace" style="margin-right:0.1667em;"></span></span></span><span class="fix"></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>{=}\mathllap{/\,}</code></td>
</tr>
<tr>
<td style="text-align:left">\mathnormal</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>A</mi><mi>a</mi><mi>B</mi><mi>b</mi></mrow><annotation encoding="application/x-tex">\mathnormal{AaBb}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord"><span class="mord mathnormal">A</span><span class="mord mathnormal">a</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span><span class="mord mathnormal">b</span></span></span></span></span></td>
<td style="text-align:left"><code>\mathnormal{AaBb}</code><br>KaTeX supports A-Za-z</td>
</tr>
<tr>
<td style="text-align:left">\mathop</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msubsup><mo><mo>⋆</mo></mo><mi>a</mi><mi>b</mi></msubsup></mrow><annotation encoding="application/x-tex">\mathop{\star}_a^b</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0961em;vertical-align:-0.247em;"></span><span class="mop"><span class="mop">⋆</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8491em;"><span style="top:-2.453em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">a</span></span></span><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">b</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.247em;"><span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\mathop{\star}_a^b</code></td>
</tr>
<tr>
<td style="text-align:left">\mathopen</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mo>+</mo><mo lspace="0em" rspace="0em">&lt;</mo><mi>b</mi><mo stretchy="false">)</mo><mo>+</mo><mi>c</mi></mrow><annotation encoding="application/x-tex">a + \mathopen\lt b) + c</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mord mathnormal">a</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen"><span class="mrel">&lt;</span></span><span class="mord mathnormal">b</span><span class="mclose">)</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">c</span></span></span></span></td>
<td style="text-align:left"><code>a + \mathopen\lt b) + c</code></td>
</tr>
<tr>
<td style="text-align:left">\mathord</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>1</mn><mi separator="true">,</mi><mn>234</mn><mo separator="true" lspace="0em" rspace="0em">,</mo><mn>567</mn></mrow><annotation encoding="application/x-tex">1\mathord{,}234{,}567</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8389em;vertical-align:-0.1944em;"></span><span class="mord">1</span><span class="mord"><span class="mpunct">,</span></span><span class="mord">234</span><span class="mord"><span class="mpunct">,</span></span><span class="mord">567</span></span></span></span></td>
<td style="text-align:left"><code>1\mathord{,}234{,}567</code></td>
</tr>
<tr>
<td style="text-align:left">\mathpunct</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>A</mi><mo lspace="0em" rspace="0.17em">−</mo><mi>B</mi></mrow><annotation encoding="application/x-tex">A\mathpunct{-}B</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7667em;vertical-align:-0.0833em;"></span><span class="mord mathnormal">A</span><span class="mpunct"><span class="mord">−</span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span></span></td>
<td style="text-align:left"><code>A\mathpunct{-}B</code></td>
</tr>
<tr>
<td style="text-align:left">\mathrel</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mo mathvariant="normal">#</mo><mi>b</mi></mrow><annotation encoding="application/x-tex">a \mathrel{\#} b</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">a</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel"><span class="mord">#</span></span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">b</span></span></span></span></td>
<td style="text-align:left"><code>a \mathrel{\#} b</code></td>
</tr>
<tr>
<td style="text-align:left">\mathrlap</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mpadded width="0px"><mrow><mtext> </mtext><mi mathvariant="normal">/</mi></mrow></mpadded><mo lspace="0em" rspace="0em">=</mo></mrow><annotation encoding="application/x-tex">\mathrlap{\,/}{=}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord vbox"><span class="thinbox"><span class="rlap"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="inner"><span class="mord"><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord">/</span></span></span><span class="fix"></span></span></span></span><span class="mord"><span class="mrel">=</span></span></span></span></span></td>
<td style="text-align:left"><code>\mathrlap{\,/}{=}</code></td>
</tr>
<tr>
<td style="text-align:left">\mathring</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mi>a</mi><mo>˚</mo></mover></mrow><annotation encoding="application/x-tex">\mathring{a}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6944em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord mathnormal">a</span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.375em;"><span class="mord">˚</span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\mathring{a}</code></td>
</tr>
<tr>
<td style="text-align:left">\mathrm</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">A</mi><mi mathvariant="normal">a</mi><mi mathvariant="normal">B</mi><mi mathvariant="normal">b</mi><mn>123</mn></mrow><annotation encoding="application/x-tex">\mathrm{AaBb123}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord"><span class="mord mathrm">AaBb123</span></span></span></span></span></td>
<td style="text-align:left"><code>\mathrm{AaBb123}</code></td>
</tr>
<tr>
<td style="text-align:left">\mathscr</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="script">A</mi><mi mathvariant="script">B</mi></mrow><annotation encoding="application/x-tex">\mathscr{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7em;"></span><span class="mord"><span class="mord mathscr" style="margin-right:0.04087em;">AB</span></span></span></span></span></td>
<td style="text-align:left"><code>\mathscr{AaBb123}</code><br>KaTeX supports A-Z</td>
</tr>
<tr>
<td style="text-align:left">\mathsf</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="sans-serif">A</mi><mi mathvariant="sans-serif">a</mi><mi mathvariant="sans-serif">B</mi><mi mathvariant="sans-serif">b</mi><mn mathvariant="sans-serif">123</mn></mrow><annotation encoding="application/x-tex">\mathsf{AaBb123}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord"><span class="mord mathsf">AaBb123</span></span></span></span></span></td>
<td style="text-align:left"><code>\mathsf{AaBb123}</code></td>
</tr>
<tr>
<td style="text-align:left">\mathsterling</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">£</mi></mrow><annotation encoding="application/x-tex">\mathsterling</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">£</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\mathstrut</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\mathtip</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\mathtt</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="monospace">A</mi><mi mathvariant="monospace">a</mi><mi mathvariant="monospace">B</mi><mi mathvariant="monospace">b</mi><mn mathvariant="monospace">123</mn></mrow><annotation encoding="application/x-tex">\mathtt{AaBb123}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6111em;"></span><span class="mord"><span class="mord mathtt">AaBb123</span></span></span></span></span></td>
<td style="text-align:left"><code>\mathtt{AaBb123}</code></td>
</tr>
<tr>
<td style="text-align:left">\matrix</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left">See <code>{matrix}</code></td>
</tr>
<tr>
<td style="text-align:left" matrix=""></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mtable rowspacing="0.16em" columnalign="center center" columnspacing="1em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>a</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>b</mi></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>c</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>d</mi></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{matrix}a&amp;b\\c&amp;d\end{matrix}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.4em;vertical-align:-0.95em;"></span><span class="mord"><span class="mtable"><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:0.5em;"></span><span class="arraycolsep" style="width:0.5em;"></span><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">b</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">d</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\begin{matrix}</code><br>   <code>a &amp; b \\</code><br>   <code>c &amp; d</code><br><code>\end{matrix}</code></td>
</tr>
<tr>
<td style="text-align:left">\max</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>max</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\max</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mop">max</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\mbox</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\md</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\mdseries</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\measuredangle</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∡</mi></mrow><annotation encoding="application/x-tex">\measuredangle</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mord amsrm">∡</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\medspace</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mtext> </mtext><mi>b</mi></mrow><annotation encoding="application/x-tex">a\medspace b</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">a</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal">b</span></span></span></span></td>
<td style="text-align:left"><code>a\medspace b</code></td>
</tr>
<tr>
<td style="text-align:left">\mho</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">℧</mi></mrow><annotation encoding="application/x-tex">\mho</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord amsrm">℧</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\mid</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">{</mo><mi>x</mi><mo>∈</mo><mi mathvariant="normal">R</mi><mo>∣</mo><mi>x</mi><mo>&gt;</mo><mn>0</mn><mo stretchy="false">}</mo></mrow><annotation encoding="application/x-tex">\{x∈ℝ\mid x&gt;0\}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">{</span><span class="mord mathnormal">x</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">∈</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord amsrm">R</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">∣</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mord mathnormal">x</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">&gt;</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">0</span><span class="mclose">}</span></span></span></span></td>
<td style="text-align:left"><code>\{x∈ℝ\mid x&gt;0\}</code></td>
</tr>
<tr>
<td style="text-align:left">\middle</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>P</mi><mrow><mo fence="true">(</mo><mi>A</mi><mo fence="true" lspace="0.05em" rspace="0.05em">|</mo><mi>B</mi><mo fence="true">)</mo></mrow></mrow><annotation encoding="application/x-tex">P\left(A\middle\vert B\right)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.13889em;">P</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord mathnormal">A</span><span class="delimcenter" style="top:0em;">∣</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span><span class="mclose delimcenter" style="top:0em;">)</span></span></span></span></span></td>
<td style="text-align:left"><code>P\left(A\middle\vert B\right)</code></td>
</tr>
<tr>
<td style="text-align:left">\min</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>min</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\min</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6679em;"></span><span class="mop">min</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\mit</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left">See <code>\mathit</code></td>
</tr>
<tr>
<td style="text-align:left">\mkern</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mspace width="1em"/><mi>b</mi></mrow><annotation encoding="application/x-tex">a\mkern18mu b</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">a</span><span class="mspace" style="margin-right:1em;"></span><span class="mord mathnormal">b</span></span></span></span></td>
<td style="text-align:left"><code>a\mkern18mu b</code></td>
</tr>
<tr>
<td style="text-align:left">\mmlToken</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\mod</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>3</mn><mo>≡</mo><mn>5</mn><mspace></mspace><mspace width="0.6667em"/><mrow><mi mathvariant="normal">m</mi><mi mathvariant="normal">o</mi><mi mathvariant="normal">d</mi></mrow><mtext> </mtext><mtext> </mtext><mn>2</mn></mrow><annotation encoding="application/x-tex">3\equiv 5 \mod 2</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">3</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≡</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">5</span><span class="mspace allowbreak"></span><span class="mspace" style="margin-right:0.6667em;"></span></span><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord"><span class="mord"><span class="mord mathrm">mod</span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord">2</span></span></span></span></td>
<td style="text-align:left"><code>3\equiv 5 \mod 2</code></td>
</tr>
<tr>
<td style="text-align:left">\models</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊨</mo></mrow><annotation encoding="application/x-tex">\models</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.999em;vertical-align:-0.249em;"></span><span class="mrel">⊨</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\moveleft</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\moveright</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\mp</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∓</mo></mrow><annotation encoding="application/x-tex">\mp</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mord">∓</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\mskip</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mspace width="0.5556em"/><mi>b</mi></mrow><annotation encoding="application/x-tex">a\mskip{10mu}b</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">a</span><span class="mspace" style="margin-right:0.5556em;"></span><span class="mord mathnormal">b</span></span></span></span></td>
<td style="text-align:left"><code>a\mskip{10mu}b</code></td>
</tr>
<tr>
<td style="text-align:left">\mspace</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Mu</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">M</mi></mrow><annotation encoding="application/x-tex">\Mu</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathrm">M</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\mu</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>μ</mi></mrow><annotation encoding="application/x-tex">\mu</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">μ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\multicolumn</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"><a href="https://github.com/KaTeX/KaTeX/issues/269" target="_blank" rel="noreferrer">Issue #269</a></td>
</tr>
<tr>
<td style="text-align:left" multiline=""></td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\multimap</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊸</mo></mrow><annotation encoding="application/x-tex">\multimap</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5499em;"></span><span class="mrel amsrm">⊸</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
</tbody>
</table>
<h2 id="n" tabindex="-1">N <a class="header-anchor" href="#n" aria-label="Permalink to &quot;N&quot;">&ZeroWidthSpace;</a></h2>
<table>
<thead>
<tr>
<th style="text-align:left">Symbol/Function</th>
<th style="text-align:left">Rendered</th>
<th style="text-align:left">Source or Comment</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">\N</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="double-struck">N</mi></mrow><annotation encoding="application/x-tex">\N</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord mathbb">N</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\nabla</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∇</mi></mrow><annotation encoding="application/x-tex">\nabla</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">∇</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\natnums</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="double-struck">N</mi></mrow><annotation encoding="application/x-tex">\natnums</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord mathbb">N</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\natural</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">♮</mi></mrow><annotation encoding="application/x-tex">\natural</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord">♮</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\negmedspace</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mtext> ⁣</mtext><mi>b</mi></mrow><annotation encoding="application/x-tex">a\negmedspace b</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">a</span><span class="mspace" style="margin-right:-0.2222em;"></span><span class="mord mathnormal">b</span></span></span></span></td>
<td style="text-align:left"><code>a\negmedspace b</code></td>
</tr>
<tr>
<td style="text-align:left">\ncong</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≆</mo></mrow><annotation encoding="application/x-tex">\ncong</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0966em;vertical-align:-0.3027em;"></span><span class="mrel amsrm">≆</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\ne</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo mathvariant="normal">≠</mo></mrow><annotation encoding="application/x-tex">\ne</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel"><span class="mrel"><span class="mord vbox"><span class="thinbox"><span class="rlap"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="inner"><span class="mord"><span class="mrel"></span></span></span><span class="fix"></span></span></span></span></span><span class="mrel">=</span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\nearrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↗</mo></mrow><annotation encoding="application/x-tex">\nearrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel">↗</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\neg</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">¬</mi></mrow><annotation encoding="application/x-tex">\neg</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord">¬</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\negthickspace</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mtext> ⁣</mtext><mi>b</mi></mrow><annotation encoding="application/x-tex">a\negthickspace b</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">a</span><span class="mspace" style="margin-right:-0.2778em;"></span><span class="mord mathnormal">b</span></span></span></span></td>
<td style="text-align:left"><code>a\negthickspace b</code></td>
</tr>
<tr>
<td style="text-align:left">\negthinspace</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mtext> ⁣</mtext><mi>b</mi></mrow><annotation encoding="application/x-tex">a\negthinspace b</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">a</span><span class="mspace" style="margin-right:-0.1667em;"></span><span class="mord mathnormal">b</span></span></span></span></td>
<td style="text-align:left"><code>a\negthinspace b</code></td>
</tr>
<tr>
<td style="text-align:left">\neq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo mathvariant="normal">≠</mo></mrow><annotation encoding="application/x-tex">\neq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel"><span class="mrel"><span class="mord vbox"><span class="thinbox"><span class="rlap"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="inner"><span class="mord"><span class="mrel"></span></span></span><span class="fix"></span></span></span></span></span><span class="mrel">=</span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\newcommand</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">✓</mi></mrow><annotation encoding="application/x-tex">\newcommand\chk{\checkmark} \chk</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mord amsrm">✓</span></span></span></span></td>
<td style="text-align:left"><code>\newcommand\chk{\checkmark} \chk</code></td>
</tr>
<tr>
<td style="text-align:left">\newenvironment</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"><a href="https://github.com/KaTeX/KaTeX/issues/37" target="_blank" rel="noreferrer">Issue #37</a></td>
</tr>
<tr>
<td style="text-align:left">\Newextarrow</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\newline</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mspace linebreak="newline"></mspace><mi>b</mi></mrow><annotation encoding="application/x-tex">a\newline b</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">a</span></span><span class="mspace newline"></span><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">b</span></span></span></span></td>
<td style="text-align:left"><code>a\newline b</code></td>
</tr>
<tr>
<td style="text-align:left">\nexists</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∄</mi></mrow><annotation encoding="application/x-tex">\nexists</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord amsrm">∄</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\ngeq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≱</mo></mrow><annotation encoding="application/x-tex">\ngeq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0966em;vertical-align:-0.3027em;"></span><span class="mrel amsrm">≱</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\ngeqq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≱</mo></mrow><annotation encoding="application/x-tex">\ngeqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.339em;vertical-align:-0.4195em;"></span><span class="mrel amsrm"></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\ngeqslant</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≱</mo></mrow><annotation encoding="application/x-tex">\ngeqslant</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0966em;vertical-align:-0.3027em;"></span><span class="mrel amsrm"></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\ngtr</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≯</mo></mrow><annotation encoding="application/x-tex">\ngtr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9115em;vertical-align:-0.2058em;"></span><span class="mrel amsrm">≯</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\ni</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∋</mo></mrow><annotation encoding="application/x-tex">\ni</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">∋</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\nleftarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↚</mo></mrow><annotation encoding="application/x-tex">\nleftarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel amsrm">↚</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\nLeftarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇍</mo></mrow><annotation encoding="application/x-tex">\nLeftarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel amsrm">⇍</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\nLeftrightarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇎</mo></mrow><annotation encoding="application/x-tex">\nLeftrightarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel amsrm">⇎</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\nleftrightarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↮</mo></mrow><annotation encoding="application/x-tex">\nleftrightarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel amsrm">↮</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\nleq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≰</mo></mrow><annotation encoding="application/x-tex">\nleq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0966em;vertical-align:-0.3027em;"></span><span class="mrel amsrm">≰</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\nleqq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≰</mo></mrow><annotation encoding="application/x-tex">\nleqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.339em;vertical-align:-0.4195em;"></span><span class="mrel amsrm"></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\nleqslant</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≰</mo></mrow><annotation encoding="application/x-tex">\nleqslant</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0966em;vertical-align:-0.3027em;"></span><span class="mrel amsrm"></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\nless</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≮</mo></mrow><annotation encoding="application/x-tex">\nless</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9115em;vertical-align:-0.2058em;"></span><span class="mrel amsrm">≮</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\nmid</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∤</mo></mrow><annotation encoding="application/x-tex">\nmid</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9925em;vertical-align:-0.2514em;"></span><span class="mrel amsrm">∤</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\nobreak</td>
<td style="text-align:left"></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\nobreakspace</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mtext> </mtext><mi>b</mi></mrow><annotation encoding="application/x-tex">a\nobreakspace b</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">a</span><span class="mspace nobreak"> </span><span class="mord mathnormal">b</span></span></span></span></td>
<td style="text-align:left"><code>a\nobreakspace b</code></td>
</tr>
<tr>
<td style="text-align:left">\noexpand</td>
<td style="text-align:left"></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\nolimits</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mrow><mi>lim</mi><mo>⁡</mo></mrow><mi>x</mi></msub></mrow><annotation encoding="application/x-tex">\lim\nolimits_x</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8444em;vertical-align:-0.15em;"></span><span class="mop"><span class="mop">lim</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">x</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\lim\nolimits_x</code></td>
</tr>
<tr>
<td style="text-align:left">\normalfont</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\normalsize</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathsize="1em"><mi>n</mi><mi>o</mi><mi>r</mi><mi>m</mi><mi>a</mi><mi>l</mi><mi>s</mi><mi>i</mi><mi>z</mi><mi>e</mi></mstyle></mrow><annotation encoding="application/x-tex">\normalsize normalsize</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">n</span><span class="mord mathnormal" style="margin-right:0.02778em;">or</span><span class="mord mathnormal">ma</span><span class="mord mathnormal" style="margin-right:0.01968em;">l</span><span class="mord mathnormal">s</span><span class="mord mathnormal">i</span><span class="mord mathnormal">ze</span></span></span></span></td>
<td style="text-align:left"><code>\normalsize normalsize</code></td>
</tr>
<tr>
<td style="text-align:left">\not</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≠</mo></mrow><annotation encoding="application/x-tex">\not =</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel"><span class="mord vbox"><span class="thinbox"><span class="rlap"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="inner"><span class="mord"><span class="mrel"></span></span></span><span class="fix"></span></span></span></span></span></span><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">=</span></span></span></span></td>
<td style="text-align:left"><code>\not =</code></td>
</tr>
<tr>
<td style="text-align:left">\notag</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\notin</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo mathvariant="normal">∉</mo></mrow><annotation encoding="application/x-tex">\notin</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mrel"><span class="mord"><span class="mrel">∈</span></span><span class="mord vbox"><span class="thinbox"><span class="llap"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="inner"><span class="mord"><span class="mord">/</span><span class="mspace" style="margin-right:0.0556em;"></span></span></span><span class="fix"></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\notni</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo mathvariant="normal">∌</mo></mrow><annotation encoding="application/x-tex">\notni</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel"><span class="mord vbox"><span class="thinbox"><span class="rlap"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="inner"><span class="mord"><span class="mrel"></span></span></span><span class="fix"></span></span></span></span></span></span><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">∋</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\nparallel</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∦</mo></mrow><annotation encoding="application/x-tex">\nparallel</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9925em;vertical-align:-0.2514em;"></span><span class="mrel amsrm">∦</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\nprec</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊀</mo></mrow><annotation encoding="application/x-tex">\nprec</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9115em;vertical-align:-0.2058em;"></span><span class="mrel amsrm">⊀</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\npreceq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋠</mo></mrow><annotation encoding="application/x-tex">\npreceq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0966em;vertical-align:-0.3027em;"></span><span class="mrel amsrm">⋠</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\nRightarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇏</mo></mrow><annotation encoding="application/x-tex">\nRightarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel amsrm">⇏</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\nrightarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↛</mo></mrow><annotation encoding="application/x-tex">\nrightarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel amsrm">↛</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\nshortmid</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∤</mo></mrow><annotation encoding="application/x-tex">\nshortmid</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6633em;vertical-align:-0.0817em;"></span><span class="mrel amsrm"></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\nshortparallel</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∦</mo></mrow><annotation encoding="application/x-tex">\nshortparallel</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6633em;vertical-align:-0.0817em;"></span><span class="mrel amsrm"></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\nsim</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≁</mo></mrow><annotation encoding="application/x-tex">\nsim</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel amsrm">≁</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\nsubseteq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊈</mo></mrow><annotation encoding="application/x-tex">\nsubseteq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0966em;vertical-align:-0.3027em;"></span><span class="mrel amsrm">⊈</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\nsubseteqq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊈</mo></mrow><annotation encoding="application/x-tex">\nsubseteqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0087em;vertical-align:-0.2514em;"></span><span class="mrel amsrm"></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\nsucc</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊁</mo></mrow><annotation encoding="application/x-tex">\nsucc</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9115em;vertical-align:-0.2058em;"></span><span class="mrel amsrm">⊁</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\nsucceq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋡</mo></mrow><annotation encoding="application/x-tex">\nsucceq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0966em;vertical-align:-0.3027em;"></span><span class="mrel amsrm">⋡</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\nsupseteq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊉</mo></mrow><annotation encoding="application/x-tex">\nsupseteq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0966em;vertical-align:-0.3027em;"></span><span class="mrel amsrm">⊉</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\nsupseteqq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊉</mo></mrow><annotation encoding="application/x-tex">\nsupseteqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0087em;vertical-align:-0.2514em;"></span><span class="mrel amsrm"></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\ntriangleleft</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋪</mo></mrow><annotation encoding="application/x-tex">\ntriangleleft</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9115em;vertical-align:-0.2058em;"></span><span class="mrel amsrm">⋪</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\ntrianglelefteq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋬</mo></mrow><annotation encoding="application/x-tex">\ntrianglelefteq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0966em;vertical-align:-0.3027em;"></span><span class="mrel amsrm">⋬</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\ntriangleright</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋫</mo></mrow><annotation encoding="application/x-tex">\ntriangleright</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9115em;vertical-align:-0.2058em;"></span><span class="mrel amsrm">⋫</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\ntrianglerighteq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋭</mo></mrow><annotation encoding="application/x-tex">\ntrianglerighteq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0966em;vertical-align:-0.3027em;"></span><span class="mrel amsrm">⋭</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Nu</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">N</mi></mrow><annotation encoding="application/x-tex">\Nu</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathrm">N</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\nu</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ν</mi></mrow><annotation encoding="application/x-tex">\nu</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal" style="margin-right:0.06366em;">ν</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\nVDash</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊯</mo></mrow><annotation encoding="application/x-tex">\nVDash</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mrel amsrm">⊯</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\nVdash</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊮</mo></mrow><annotation encoding="application/x-tex">\nVdash</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mrel amsrm">⊮</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\nvDash</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊭</mo></mrow><annotation encoding="application/x-tex">\nvDash</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mrel amsrm">⊭</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\nvdash</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊬</mo></mrow><annotation encoding="application/x-tex">\nvdash</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mrel amsrm">⊬</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\nwarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↖</mo></mrow><annotation encoding="application/x-tex">\nwarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel">↖</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
</tbody>
</table>
<h2 id="o" tabindex="-1">O <a class="header-anchor" href="#o" aria-label="Permalink to &quot;O&quot;">&ZeroWidthSpace;</a></h2>
<table>
<thead>
<tr>
<th style="text-align:left">Symbol/Function</th>
<th style="text-align:left">Rendered</th>
<th style="text-align:left">Source or Comment</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">\O</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>Ø</mtext></mrow><annotation encoding="application/x-tex">\text{\O}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7806em;vertical-align:-0.0486em;"></span><span class="mord text"><span class="mord">Ø</span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\O}</code></td>
</tr>
<tr>
<td style="text-align:left">\o</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>ø</mtext></mrow><annotation encoding="application/x-tex">\text{\o}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.0972em;"></span><span class="mord text"><span class="mord">ø</span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\o}</code></td>
</tr>
<tr>
<td style="text-align:left">\odot</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊙</mo></mrow><annotation encoding="application/x-tex">\odot</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mord">⊙</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\OE</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>Œ</mtext></mrow><annotation encoding="application/x-tex">\text{\OE}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord text"><span class="mord latin_fallback">Œ</span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\OE}</code></td>
</tr>
<tr>
<td style="text-align:left">\oe</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>œ</mtext></mrow><annotation encoding="application/x-tex">\text{\oe}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord text"><span class="mord latin_fallback">œ</span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\oe}</code></td>
</tr>
<tr>
<td style="text-align:left">\officialeuro</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\oiiint</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∰</mo></mrow><annotation encoding="application/x-tex">\oiiint</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.111em;vertical-align:-0.306em;"></span><span class="mop vlist-t vlist-t2" style="position:relative;top:-0.0005em;"><span class="vlist-r"><span class="vlist" style="height:0.805em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mop op-symbol small-op" style="margin-right:0.19445em;">∭</span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="overlay" style="height:0.499em;width:1.304em;"><svg xmlns="http://www.w3.org/2000/svg" width='1.304em' height='0.499em' style='width:1.304em' viewBox='0 0 1304 499' preserveAspectRatio='xMinYMin'><path d='M681.4 71.6c408.9 0 480.5 106.8 480.5 178.2 0 70.8-71.6 177.6
-480.5 177.6S202.1 320.6 202.1 249.8c0-71.4 70.5-178.2 479.3-178.2z
m525.8 178.2c0-86.4-86.8-215.4-525.7-215.4-437.9 0-524.7 129-524.7 215.4 0
85.8 86.8 214.8 524.7 214.8 438.9 0 525.7-129 525.7-214.8z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.306em;"><span></span></span></span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\oiint</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∯</mo></mrow><annotation encoding="application/x-tex">\oiint</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.111em;vertical-align:-0.306em;"></span><span class="mop vlist-t vlist-t2" style="position:relative;top:-0.0005em;"><span class="vlist-r"><span class="vlist" style="height:0.805em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mop op-symbol small-op" style="margin-right:0.19445em;">∬</span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="overlay" style="height:0.499em;width:0.957em;"><svg xmlns="http://www.w3.org/2000/svg" width='0.957em' height='0.499em' style='width:0.957em' viewBox='0 0 957 499' preserveAspectRatio='xMinYMin'><path d='M512.6 71.6c272.6 0 320.3 106.8 320.3 178.2 0 70.8-47.7 177.6
-320.3 177.6S193.1 320.6 193.1 249.8c0-71.4 46.9-178.2 319.5-178.2z
m368.1 178.2c0-86.4-60.9-215.4-368.1-215.4-306.4 0-367.3 129-367.3 215.4 0 85.8
60.9 214.8 367.3 214.8 307.2 0 368.1-129 368.1-214.8z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.306em;"><span></span></span></span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\oint</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∮</mo></mrow><annotation encoding="application/x-tex">\oint</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1111em;vertical-align:-0.3061em;"></span><span class="mop op-symbol small-op" style="margin-right:0.19445em;position:relative;top:-0.0006em;">∮</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\oldstyle</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\omega</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ω</mi></mrow><annotation encoding="application/x-tex">\omega</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">ω</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Omega</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Ω</mi></mrow><annotation encoding="application/x-tex">\Omega</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">Ω</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Omicron</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">O</mi></mrow><annotation encoding="application/x-tex">\Omicron</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathrm">O</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\omicron</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ο</mi></mrow><annotation encoding="application/x-tex">\omicron</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">ο</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\ominus</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊖</mo></mrow><annotation encoding="application/x-tex">\ominus</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mord">⊖</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\operatorname</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">asin</mi><mo>⁡</mo><mi>x</mi></mrow><annotation encoding="application/x-tex">\operatorname{asin} x</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6679em;"></span><span class="mop"><span class="mord mathrm">asin</span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">x</span></span></span></span></td>
<td style="text-align:left">\operatorname{asin} x</td>
</tr>
<tr>
<td style="text-align:left">\operatorname*</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mrow><mi mathvariant="normal">asin</mi><mo>⁡</mo></mrow><mi>y</mi></msub><mi>x</mi></mrow><annotation encoding="application/x-tex">\operatorname{asin}\limits_y x</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.954em;vertical-align:-0.2861em;"></span><span class="mop"><span class="mop"><span class="mord mathrm">asin</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.03588em;">y</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">x</span></span></span></span></td>
<td style="text-align:left"><code>\operatorname{asin}\limits_y x</code></td>
</tr>
<tr>
<td style="text-align:left">\oplus</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊕</mo></mrow><annotation encoding="application/x-tex">\oplus</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mord">⊕</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\or</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\oslash</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊘</mo></mrow><annotation encoding="application/x-tex">\oslash</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mord">⊘</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\otimes</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊗</mo></mrow><annotation encoding="application/x-tex">\otimes</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mord">⊗</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\over</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mfrac><mrow><mi>a</mi><mo>+</mo><mn>1</mn></mrow><mrow><mi>b</mi><mo>+</mo><mn>2</mn></mrow></mfrac><mo>+</mo><mi>c</mi></mrow><annotation encoding="application/x-tex">{a+1 \over b+2}+c</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2484em;vertical-align:-0.4033em;"></span><span class="mord"><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8451em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">b</span><span class="mbin mtight">+</span><span class="mord mtight">2</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">a</span><span class="mbin mtight">+</span><span class="mord mtight">1</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.4033em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">c</span></span></span></span></td>
<td style="text-align:left"><code>{a+1 \over b+2}+c</code></td>
</tr>
<tr>
<td style="text-align:left">\overbrace</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mover><mrow><mi>x</mi><mo>+</mo><mo>⋯</mo><mo>+</mo><mi>x</mi></mrow><mo stretchy="true">⏞</mo></mover><mrow><mi>n</mi><mtext> times</mtext></mrow></mover></mrow><annotation encoding="application/x-tex">\overbrace{x+⋯+x}^{n\text{ times}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.9822em;vertical-align:-0.0833em;"></span><span class="mord mover"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.8988em;"><span style="top:-3.2313em;"><span class="pstrut" style="height:3.2313em;"></span><span class="mord mover"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.2313em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">x</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="minner">⋯</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal">x</span></span></span><span class="svg-align" style="top:-3.6833em;"><span class="pstrut" style="height:3em;"></span><span class="stretchy" style="height:0.548em;min-width:1.6em;"><span class="brace-left" style="height:0.548em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.548em' viewBox='0 0 400000 548' preserveAspectRatio='xMinYMin slice'><path d='M6 548l-6-6v-35l6-11c56-104 135.3-181.3 238-232 57.3-28.7 117
-45 179-50h399577v120H403c-43.3 7-81 15-113 26-100.7 33-179.7 91-237 174-2.7
 5-6 9-10 13-.7 1-7.3 1-20 1H6z'/></svg></span><span class="brace-center" style="height:0.548em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.548em' viewBox='0 0 400000 548' preserveAspectRatio='xMidYMin slice'><path d='M200428 334
c-100.7-8.3-195.3-44-280-108-55.3-42-101.7-93-139-153l-9-14c-2.7 4-5.7 8.7-9 14
-53.3 86.7-123.7 153-211 199-66.7 36-137.3 56.3-212 62H0V214h199568c178.3-11.7
 311.7-78.3 403-201 6-8 9.7-12 11-12 .7-.7 6.7-1 18-1s17.3.3 18 1c1.3 0 5 4 11
 12 44.7 59.3 101.3 106.3 170 141s145.3 54.3 229 60h199572v120z'/></svg></span><span class="brace-right" style="height:0.548em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.548em' viewBox='0 0 400000 548' preserveAspectRatio='xMaxYMin slice'><path d='M400000 542l
-6 6h-17c-12.7 0-19.3-.3-20-1-4-4-7.3-8.3-10-13-35.3-51.3-80.8-93.8-136.5-127.5
s-117.2-55.8-184.5-66.5c-.7 0-2-.3-4-1-18.7-2.7-76-4.3-172-5H0V214h399571l6 1
c124.7 8 235 61.7 331 161 31.3 33.3 59.7 72.7 85 118l7 13v35z'/></svg></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.0833em;"><span></span></span></span></span></span></span><span style="top:-4.6627em;"><span class="pstrut" style="height:3.2313em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">n</span><span class="mord text mtight"><span class="mord mtight"> times</span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.0833em;"><span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\overbrace{x+⋯+x}^{n\text{ times}}</code></td>
</tr>
<tr>
<td style="text-align:left">\overbracket</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\overgroup</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mrow><mi>A</mi><mi>B</mi></mrow><mo stretchy="true">⏠</mo></mover></mrow><annotation encoding="application/x-tex">\overgroup{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0253em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:1.0253em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span><span class="svg-align" style="top:-3.6833em;"><span class="pstrut" style="height:3em;"></span><span class="stretchy" style="height:0.342em;min-width:0.888em;"><span class="halfarrow-left" style="height:0.342em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.342em' viewBox='0 0 400000 342' preserveAspectRatio='xMinYMin slice'><path d='M400000 80
H435C64 80 168.3 229.4 21 260c-5.9 1.2-18 0-18 0-2 0-3-1-3-3v-38C76 61 257 0
 435 0h399565z'/></svg></span><span class="halfarrow-right" style="height:0.342em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.342em' viewBox='0 0 400000 342' preserveAspectRatio='xMaxYMin slice'><path d='M0 80h399565c371 0 266.7 149.4 414 180 5.9 1.2 18 0 18 0 2 0
 3-1 3-3v-38c-76-158-257-219-435-219H0z'/></svg></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\overgroup{AB}</code></td>
</tr>
<tr>
<td style="text-align:left">\overleftarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mrow><mi>A</mi><mi>B</mi></mrow><mo stretchy="true">←</mo></mover></mrow><annotation encoding="application/x-tex">\overleftarrow{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2053em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:1.2053em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span><span class="svg-align" style="top:-3.6833em;"><span class="pstrut" style="height:3em;"></span><span class="hide-tail" style="height:0.522em;min-width:0.888em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMinYMin slice'><path d='M400000 241H110l3-3c68.7-52.7 113.7-120
 135-202 4-14.7 6-23 6-25 0-7.3-7-11-21-11-8 0-13.2.8-15.5 2.5-2.3 1.7-4.2 5.8
-5.5 12.5-1.3 4.7-2.7 10.3-4 17-12 48.7-34.8 92-68.5 130S65.3 228.3 18 247
c-10 4-16 7.7-18 11 0 8.7 6 14.3 18 17 47.3 18.7 87.8 47 121.5 85S196 441.3 208
 490c.7 2 1.3 5 2 9s1.2 6.7 1.5 8c.3 1.3 1 3.3 2 6s2.2 4.5 3.5 5.5c1.3 1 3.3
 1.8 6 2.5s6 1 10 1c14 0 21-3.7 21-11 0-2-2-10.3-6-25-20-79.3-65-146.7-135-202
 l-3-3h399890zM100 241v40h399900v-40z'/></svg></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\overleftarrow{AB}</code></td>
</tr>
<tr>
<td style="text-align:left">\overleftharpoon</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mrow><mi>A</mi><mi>B</mi></mrow><mo stretchy="true">↼</mo></mover></mrow><annotation encoding="application/x-tex">\overleftharpoon{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2053em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:1.2053em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span><span class="svg-align" style="top:-3.6833em;"><span class="pstrut" style="height:3em;"></span><span class="hide-tail" style="height:0.522em;min-width:0.888em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMinYMin slice'><path d='M0 267c.7 5.3 3 10 7 14h399993v-40H93c3.3
-3.3 10.2-9.5 20.5-18.5s17.8-15.8 22.5-20.5c50.7-52 88-110.3 112-175 4-11.3 5
-18.3 3-21-1.3-4-7.3-6-18-6-8 0-13 .7-15 2s-4.7 6.7-8 16c-42 98.7-107.3 174.7
-196 228-6.7 4.7-10.7 8-12 10-1.3 2-2 5.7-2 11zm100-26v40h399900v-40z'/></svg></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\overleftharpoon{AB}</code></td>
</tr>
<tr>
<td style="text-align:left">\overleftrightarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mrow><mi>A</mi><mi>B</mi></mrow><mo stretchy="true">↔</mo></mover></mrow><annotation encoding="application/x-tex">\overleftrightarrow{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2053em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:1.2053em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span><span class="svg-align" style="top:-3.6833em;"><span class="pstrut" style="height:3em;"></span><span class="stretchy" style="height:0.522em;min-width:0.888em;"><span class="halfarrow-left" style="height:0.522em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMinYMin slice'><path d='M400000 241H110l3-3c68.7-52.7 113.7-120
 135-202 4-14.7 6-23 6-25 0-7.3-7-11-21-11-8 0-13.2.8-15.5 2.5-2.3 1.7-4.2 5.8
-5.5 12.5-1.3 4.7-2.7 10.3-4 17-12 48.7-34.8 92-68.5 130S65.3 228.3 18 247
c-10 4-16 7.7-18 11 0 8.7 6 14.3 18 17 47.3 18.7 87.8 47 121.5 85S196 441.3 208
 490c.7 2 1.3 5 2 9s1.2 6.7 1.5 8c.3 1.3 1 3.3 2 6s2.2 4.5 3.5 5.5c1.3 1 3.3
 1.8 6 2.5s6 1 10 1c14 0 21-3.7 21-11 0-2-2-10.3-6-25-20-79.3-65-146.7-135-202
 l-3-3h399890zM100 241v40h399900v-40z'/></svg></span><span class="halfarrow-right" style="height:0.522em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMaxYMin slice'><path d='M0 241v40h399891c-47.3 35.3-84 78-110 128
-16.7 32-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20
 11 8 0 13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7
 39-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85
-40.5-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5
-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67
 151.7 139 205zm0 0v40h399900v-40z'/></svg></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\overleftrightarrow{AB}</code></td>
</tr>
<tr>
<td style="text-align:left">\overline</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mtext>a long argument</mtext><mo stretchy="true">‾</mo></mover></mrow><annotation encoding="application/x-tex">\overline{\text{a long argument}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0889em;vertical-align:-0.1944em;"></span><span class="mord overline"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8944em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord text"><span class="mord">a long argument</span></span></span></span><span style="top:-3.8144em;"><span class="pstrut" style="height:3em;"></span><span class="overline-line" style="border-bottom-width:0.04em;"></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.1944em;"><span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\overline{\text{a long argument}}</code></td>
</tr>
<tr>
<td style="text-align:left">\overlinesegment</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mrow><mi>A</mi><mi>B</mi></mrow><mo stretchy="true">undefined</mo></mover></mrow><annotation encoding="application/x-tex">\overlinesegment{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2053em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:1.2053em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span><span class="svg-align" style="top:-3.6833em;"><span class="pstrut" style="height:3em;"></span><span class="stretchy" style="height:0.522em;min-width:0.888em;"><span class="halfarrow-left" style="height:0.522em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMinYMin slice'><path d='M40 281 V428 H0 V94 H40 V241 H400000 v40z
M40 281 V428 H0 V94 H40 V241 H400000 v40z'/></svg></span><span class="halfarrow-right" style="height:0.522em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMaxYMin slice'><path d='M399960 241 V94 h40 V428 h-40 V281 H0 v-40z
M399960 241 V94 h40 V428 h-40 V281 H0 v-40z'/></svg></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\overlinesegment{AB}</code></td>
</tr>
<tr>
<td style="text-align:left">\overparen</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left">See <code>\overgroup</code></td>
</tr>
<tr>
<td style="text-align:left">\Overrightarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mrow><mi>A</mi><mi>B</mi></mrow><mo stretchy="true">⇒</mo></mover></mrow><annotation encoding="application/x-tex">\Overrightarrow{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2433em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:1.2433em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span><span class="svg-align" style="top:-3.6833em;"><span class="pstrut" style="height:3em;"></span><span class="hide-tail" style="height:0.56em;min-width:0.888em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.56em' viewBox='0 0 400000 560' preserveAspectRatio='xMaxYMin slice'><path d='M399738 392l
-10 10c-34 36-62.7 77-86 123-3.3 8-5 13.3-5 16 0 5.3 6.7 8 20 8 7.3 0 12.2-.5
 14.5-1.5 2.3-1 4.8-4.5 7.5-10.5 49.3-97.3 121.7-169.3 217-216 28-14 57.3-25 88
-33 6.7-2 11-3.8 13-5.5 2-1.7 3-4.2 3-7.5s-1-5.8-3-7.5c-2-1.7-6.3-3.5-13-5.5-68
-17.3-128.2-47.8-180.5-91.5-52.3-43.7-93.8-96.2-124.5-157.5-9.3-8-15.3-12.3-18
-13h-6c-12 .7-18 4-18 10 0 2 1.7 7 5 15 23.3 46 52 87 86 123l10 10H0v40h399782
c-328 0 0 0 0 0l10 8c26.7 20 65.7 43 117 69-2.7 2-6 3.7-10 5-36.7 16-72.3 37.3
-107 64l-10 8H0v40zM0 157v40h399730v-40zm0 194v40h399730v-40z'/></svg></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\Overrightarrow{AB}</code></td>
</tr>
<tr>
<td style="text-align:left">\overrightarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mrow><mi>A</mi><mi>B</mi></mrow><mo stretchy="true">→</mo></mover></mrow><annotation encoding="application/x-tex">\overrightarrow{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2053em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:1.2053em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span><span class="svg-align" style="top:-3.6833em;"><span class="pstrut" style="height:3em;"></span><span class="hide-tail" style="height:0.522em;min-width:0.888em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMaxYMin slice'><path d='M0 241v40h399891c-47.3 35.3-84 78-110 128
-16.7 32-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20
 11 8 0 13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7
 39-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85
-40.5-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5
-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67
 151.7 139 205zm0 0v40h399900v-40z'/></svg></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\overrightarrow{AB}</code></td>
</tr>
<tr>
<td style="text-align:left">\overrightharpoon</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mrow><mi>a</mi><mi>c</mi></mrow><mo stretchy="true">⇀</mo></mover></mrow><annotation encoding="application/x-tex">\overrightharpoon{ac}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9526em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.9526em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="mord mathnormal">c</span></span></span><span class="svg-align" style="top:-3.4306em;"><span class="pstrut" style="height:3em;"></span><span class="hide-tail" style="height:0.522em;min-width:0.888em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMaxYMin slice'><path d='M0 241v40h399993c4.7-4.7 7-9.3 7-14 0-9.3
-3.7-15.3-11-18-92.7-56.7-159-133.7-199-231-3.3-9.3-6-14.7-8-16-2-1.3-7-2-15-2
-10.7 0-16.7 2-18 6-2 2.7-1 9.7 3 21 15.3 42 36.7 81.8 64 119.5 27.3 37.7 58
 69.2 92 94.5zm0 0v40h399900v-40z'/></svg></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\overrightharpoon{ac}</code></td>
</tr>
<tr>
<td style="text-align:left">\overset</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mover><mo><mo>=</mo></mo><mo stretchy="false" lspace="0em" rspace="0em">!</mo></mover></mo></mrow><annotation encoding="application/x-tex">\overset{!}{=}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.153em;"></span><span class="mrel"><span class="mop op-limits"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:1.153em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span><span class="mop">=</span></span></span><span style="top:-3.5669em;margin-left:0em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mclose mtight">!</span></span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\overset{!}{=}</code></td>
</tr>
<tr>
<td style="text-align:left">\overwithdelims</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\owns</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∋</mo></mrow><annotation encoding="application/x-tex">\owns</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">∋</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
</tbody>
</table>
<h2 id="p" tabindex="-1">P <a class="header-anchor" href="#p" aria-label="Permalink to &quot;P&quot;">&ZeroWidthSpace;</a></h2>
<table>
<thead>
<tr>
<th style="text-align:left">Symbol/Function</th>
<th style="text-align:left">Rendered</th>
<th style="text-align:left">Source or Comment</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">\P</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>¶</mtext></mrow><annotation encoding="application/x-tex">\text{\P}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord text"><span class="mord">¶</span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\P}</code></td>
</tr>
<tr>
<td style="text-align:left">\pagecolor</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"><a href="https://en.wikipedia.org/wiki/Help:Displaying_a_formula#Deprecated_syntax" target="_blank" rel="noreferrer">Deprecated</a></td>
</tr>
<tr>
<td style="text-align:left">\parallel</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∥</mo></mrow><annotation encoding="application/x-tex">\parallel</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mrel">∥</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\part</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"><a href="https://en.wikipedia.org/wiki/Help:Displaying_a_formula#Deprecated_syntax" target="_blank" rel="noreferrer">Deprecated</a></td>
</tr>
<tr>
<td style="text-align:left">\partial</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∂</mi></mrow><annotation encoding="application/x-tex">\partial</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord" style="margin-right:0.05556em;">∂</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\perp</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊥</mo></mrow><annotation encoding="application/x-tex">\perp</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mrel">⊥</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\phantom</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msubsup><mi mathvariant="normal">Γ</mi><mrow><mi>i</mi><mphantom><mi>j</mi></mphantom><mi>k</mi></mrow><mrow><mphantom><mi>i</mi></mphantom><mi>j</mi></mrow></msubsup></mrow><annotation encoding="application/x-tex">\Gamma^{\phantom{i}j}_{i\phantom{j}k}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.38em;vertical-align:-0.4374em;"></span><span class="mord"><span class="mord">Γ</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.9426em;"><span style="top:-2.3987em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">i</span><span class="mord mathnormal mtight" style="margin-right:0.05724em;color:transparent;">j</span><span class="mord mathnormal mtight" style="margin-right:0.03148em;">k</span></span></span></span><span style="top:-3.1809em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="color:transparent;">i</span><span class="mord mathnormal mtight" style="margin-right:0.05724em;">j</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.4374em;"><span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\Gamma^{\phantom{i}j}_{i\phantom{j}k}</code></td>
</tr>
<tr>
<td style="text-align:left">\phase</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Phi</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Φ</mi></mrow><annotation encoding="application/x-tex">\Phi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">Φ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\phi</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ϕ</mi></mrow><annotation encoding="application/x-tex">\phi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">ϕ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Pi</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Π</mi></mrow><annotation encoding="application/x-tex">\Pi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">Π</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\pi</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>π</mi></mrow><annotation encoding="application/x-tex">\pi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">π</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left" picture=""></td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\pitchfork</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋔</mo></mrow><annotation encoding="application/x-tex">\pitchfork</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mrel amsrm">⋔</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\plim</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mi mathvariant="normal">plim</mi><mo>⁡</mo></mo></mrow><annotation encoding="application/x-tex">\plim</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mop"><span class="mop"><span class="mord mathrm">plim</span></span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\plusmn</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>±</mo></mrow><annotation encoding="application/x-tex">\plusmn</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mord">±</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\pm</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>±</mo></mrow><annotation encoding="application/x-tex">\pm</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mord">±</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\pmatrix</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left">See <code>{pmatrix}</code></td>
</tr>
<tr>
<td style="text-align:left" pmatrix=""></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true">(</mo><mtable rowspacing="0.16em" columnalign="center center" columnspacing="1em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>a</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>b</mi></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>c</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>d</mi></mstyle></mtd></mtr></mtable><mo fence="true">)</mo></mrow><annotation encoding="application/x-tex">\begin{pmatrix}a&amp;b\\c&amp;d\end{pmatrix}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.4em;vertical-align:-0.95em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size3">(</span></span><span class="mord"><span class="mtable"><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:0.5em;"></span><span class="arraycolsep" style="width:0.5em;"></span><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">b</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">d</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size3">)</span></span></span></span></span></span></td>
<td style="text-align:left"><code>\begin{pmatrix}</code><br>   <code>a &amp; b \\</code><br>   <code>c &amp; d</code><br><code>\end{pmatrix}</code></td>
</tr>
<tr>
<td style="text-align:left">\pmb</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle style="text-shadow: 0.02em 0.01em 0.04px"><mi>μ</mi></mstyle></mrow><annotation encoding="application/x-tex">\pmb{\mu}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord" style="text-shadow:0.02em 0.01em 0.04px;"><span class="mord mathnormal">μ</span></span></span></span></span></td>
<td style="text-align:left"><code>\pmb{\mu}</code></td>
</tr>
<tr>
<td style="text-align:left">\pmod</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>x</mi><mspace></mspace><mspace width="0.4444em"/><mo stretchy="false">(</mo><mrow><mi mathvariant="normal">m</mi><mi mathvariant="normal">o</mi><mi mathvariant="normal">d</mi></mrow><mspace width="0.3333em"/><mi>a</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">x\pmod a</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">x</span><span class="mspace allowbreak"></span><span class="mspace" style="margin-right:0.4444em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">(</span><span class="mord"><span class="mord"><span class="mord mathrm">mod</span></span></span><span class="mspace" style="margin-right:0.3333em;"></span><span class="mord mathnormal">a</span><span class="mclose">)</span></span></span></span></td>
<td style="text-align:left"><code>x\pmod a</code></td>
</tr>
<tr>
<td style="text-align:left">\pod</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>x</mi><mspace></mspace><mspace width="0.4444em"/><mo stretchy="false">(</mo><mi>a</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">x \pod a</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">x</span><span class="mspace allowbreak"></span><span class="mspace" style="margin-right:0.4444em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">(</span><span class="mord mathnormal">a</span><span class="mclose">)</span></span></span></span></td>
<td style="text-align:left"><code>x \pod a</code></td>
</tr>
<tr>
<td style="text-align:left">\pounds</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">£</mi></mrow><annotation encoding="application/x-tex">\pounds</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">£</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Pr</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>Pr</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\Pr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mop">Pr</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\prec</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≺</mo></mrow><annotation encoding="application/x-tex">\prec</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">≺</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\precapprox</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⪷</mo></mrow><annotation encoding="application/x-tex">\precapprox</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0189em;vertical-align:-0.2617em;"></span><span class="mrel amsrm">⪷</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\preccurlyeq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≼</mo></mrow><annotation encoding="application/x-tex">\preccurlyeq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7733em;vertical-align:-0.1367em;"></span><span class="mrel amsrm">≼</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\preceq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⪯</mo></mrow><annotation encoding="application/x-tex">\preceq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mrel">⪯</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\precnapprox</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⪹</mo></mrow><annotation encoding="application/x-tex">\precnapprox</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0189em;vertical-align:-0.2617em;"></span><span class="mrel amsrm">⪹</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\precneqq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⪵</mo></mrow><annotation encoding="application/x-tex">\precneqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0087em;vertical-align:-0.2514em;"></span><span class="mrel amsrm">⪵</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\precnsim</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋨</mo></mrow><annotation encoding="application/x-tex">\precnsim</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9733em;vertical-align:-0.2322em;"></span><span class="mrel amsrm">⋨</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\precsim</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≾</mo></mrow><annotation encoding="application/x-tex">\precsim</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9592em;vertical-align:-0.2296em;"></span><span class="mrel amsrm">≾</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\prime</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo mathvariant="normal">′</mo></mrow><annotation encoding="application/x-tex">\prime</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5556em;"></span><span class="mord">′</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\prod</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∏</mo></mrow><annotation encoding="application/x-tex">\prod</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mop op-symbol small-op" style="position:relative;top:0em;">∏</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\projlim</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\propto</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∝</mo></mrow><annotation encoding="application/x-tex">\propto</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mrel">∝</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\providecommand</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>Hello</mtext></mrow><annotation encoding="application/x-tex">\providecommand\greet{\text{Hello}} \greet</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord">Hello</span></span></span></span></span></td>
<td style="text-align:left"><code>\providecommand\greet{\text{Hello}} \greet</code></td>
</tr>
<tr>
<td style="text-align:left">\psi</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ψ</mi></mrow><annotation encoding="application/x-tex">\psi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">ψ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Psi</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Ψ</mi></mrow><annotation encoding="application/x-tex">\Psi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">Ψ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\pu</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>123</mn><mtext> </mtext><mfrac><mrow><mi mathvariant="normal">k</mi><mi mathvariant="normal">J</mi></mrow><mrow><mi mathvariant="normal">m</mi><mi mathvariant="normal">o</mi><mi mathvariant="normal">l</mi></mrow></mfrac></mrow><annotation encoding="application/x-tex">{123~\mathchoice{\textstyle\frac{\mathrm{kJ}}{\mathrm{mol}}}{\frac{\mathrm{kJ}}{\mathrm{mol}}}{\frac{\mathrm{kJ}}{\mathrm{mol}}}{\frac{\mathrm{kJ}}{\mathrm{mol}}}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2251em;vertical-align:-0.345em;"></span><span class="mord"><span class="mord">123</span><span class="mspace nobreak"> </span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8801em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight"><span class="mord mathrm mtight">mol</span></span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight"><span class="mord mathrm mtight">kJ</span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\pu{123 kJ//mol}</code> Requires an <a href="https://github.com/KaTeX/KaTeX/tree/master/contrib/mhchem/" target="_blank" rel="noreferrer">extension</a></td>
</tr>
</tbody>
</table>
<h2 id="qr" tabindex="-1">QR <a class="header-anchor" href="#qr" aria-label="Permalink to &quot;QR&quot;">&ZeroWidthSpace;</a></h2>
<table>
<thead>
<tr>
<th style="text-align:left">Symbol/Function</th>
<th style="text-align:left">Rendered</th>
<th style="text-align:left">Source or Comment</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">\Q</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left">See <code>\Bbb{Q}</code></td>
</tr>
<tr>
<td style="text-align:left">\qquad</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mspace width="2em"/><mspace width="2em"/><mi>b</mi></mrow><annotation encoding="application/x-tex">a\qquad\qquad{b}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">a</span><span class="mspace" style="margin-right:2em;"></span><span class="mspace" style="margin-right:2em;"></span><span class="mord"><span class="mord mathnormal">b</span></span></span></span></span></td>
<td style="text-align:left"><code>a\qquad\qquad{b}</code></td>
</tr>
<tr>
<td style="text-align:left">\quad</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mspace width="1em"/><mspace width="1em"/><mi>b</mi></mrow><annotation encoding="application/x-tex">a\quad\quad{b}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">a</span><span class="mspace" style="margin-right:1em;"></span><span class="mspace" style="margin-right:1em;"></span><span class="mord"><span class="mord mathnormal">b</span></span></span></span></span></td>
<td style="text-align:left"><code>a\quad\quad{b}</code></td>
</tr>
<tr>
<td style="text-align:left">\R</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="double-struck">R</mi></mrow><annotation encoding="application/x-tex">\R</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord mathbb">R</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\r</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mtext>a</mtext><mo>˚</mo></mover></mrow><annotation encoding="application/x-tex">\text{\r{a}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6944em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">a</span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.375em;"><span class="mord">˚</span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\r{a}}</code></td>
</tr>
<tr>
<td style="text-align:left">\raise</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left">see <code>\raisebox</code></td>
</tr>
<tr>
<td style="text-align:left">\raisebox</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>h</mi><mpadded voffset="2pt"><mstyle scriptlevel="0" displaystyle="false"><mtext>ighe</mtext></mstyle></mpadded><mi>r</mi></mrow><annotation encoding="application/x-tex">h\raisebox{2pt}{ighe}r</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8944em;"></span><span class="mord mathnormal">h</span><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8944em;"><span style="top:-3.2em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">ighe</span></span></span></span></span></span><span class="mord mathnormal" style="margin-right:0.02778em;">r</span></span></span></span></td>
<td style="text-align:left"><code>h\raisebox{2pt}{ighe}r</code></td>
</tr>
<tr>
<td style="text-align:left">\rang</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">⟨</mo><mi>A</mi><mo stretchy="false">⟩</mo></mrow><annotation encoding="application/x-tex">\langle A\rang</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">⟨</span><span class="mord mathnormal">A</span><span class="mclose">⟩</span></span></span></span></td>
<td style="text-align:left"><code>\langle A\rang</code></td>
</tr>
<tr>
<td style="text-align:left">\rangle</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">⟨</mo><mi>A</mi><mo stretchy="false">⟩</mo></mrow><annotation encoding="application/x-tex">\langle A\rangle</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">⟨</span><span class="mord mathnormal">A</span><span class="mclose">⟩</span></span></span></span></td>
<td style="text-align:left"><code>\langle A\rangle</code></td>
</tr>
<tr>
<td style="text-align:left">\Rarr</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇒</mo></mrow><annotation encoding="application/x-tex">\Rarr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">⇒</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\rArr</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇒</mo></mrow><annotation encoding="application/x-tex">\rArr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">⇒</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\rarr</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>→</mo></mrow><annotation encoding="application/x-tex">\rarr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">→</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\rBrace</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo mathvariant="normal" lspace="0em" rspace="0em">⦄</mo></mrow><annotation encoding="application/x-tex">\rBrace</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mclose"><span class="mclose">]</span><span class="mspace" style="margin-right:-0.1778em;"></span><span class="mclose">}</span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\rbrace</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">}</mo></mrow><annotation encoding="application/x-tex">\rbrace</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mclose">}</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\rbrack</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">\rbrack</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mclose">]</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left" rcases=""></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtable rowspacing="0.36em" columnalign="left left" columnspacing="1em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>a</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mrow><mtext>if </mtext><mi>b</mi></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>c</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mrow><mtext>if </mtext><mi>d</mi></mrow></mstyle></mtd></mtr></mtable><mo fence="true">}</mo></mrow><annotation encoding="application/x-tex">\begin{rcases}a&amp;\text{if }b\\c&amp;\text{if }d\end{rcases}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:3em;vertical-align:-1.25em;"></span><span class="minner"><span class="mopen nulldelimiter"></span><span class="mord"><span class="mtable"><span class="col-align-l"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.69em;"><span style="top:-3.69em;"><span class="pstrut" style="height:3.008em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span><span style="top:-2.25em;"><span class="pstrut" style="height:3.008em;"></span><span class="mord"><span class="mord mathnormal">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.19em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:1em;"></span><span class="col-align-l"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.69em;"><span style="top:-3.69em;"><span class="pstrut" style="height:3.008em;"></span><span class="mord"><span class="mord text"><span class="mord">if </span></span><span class="mord mathnormal">b</span></span></span><span style="top:-2.25em;"><span class="pstrut" style="height:3.008em;"></span><span class="mord"><span class="mord text"><span class="mord">if </span></span><span class="mord mathnormal">d</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.19em;"><span></span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size4">}</span></span></span></span></span></span></td>
<td style="text-align:left"><code>\begin{rcases}</code><br>   <code>a &amp;\text{if } b  \\</code><br>   <code>c &amp;\text{if } d</code><br><code>\end{rcases}</code></td>
</tr>
<tr>
<td style="text-align:left">\rceil</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">⌉</mo></mrow><annotation encoding="application/x-tex">\rceil</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mclose">⌉</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Re</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">ℜ</mi></mrow><annotation encoding="application/x-tex">\Re</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">ℜ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\real</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">ℜ</mi></mrow><annotation encoding="application/x-tex">\real</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">ℜ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Reals</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="double-struck">R</mi></mrow><annotation encoding="application/x-tex">\Reals</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord mathbb">R</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\reals</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="double-struck">R</mi></mrow><annotation encoding="application/x-tex">\reals</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord mathbb">R</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\ref</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"><a href="https://github.com/KaTeX/KaTeX/issues/350" target="_blank" rel="noreferrer">Issue #350</a></td>
</tr>
<tr>
<td style="text-align:left">\relax</td>
<td style="text-align:left"></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\renewcommand</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>Ahoy!</mtext></mrow><annotation encoding="application/x-tex">\def\hail{Hi!}\renewcommand\hail{\text{Ahoy!}} \hail</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord text"><span class="mord">Ahoy!</span></span></span></span></span></td>
<td style="text-align:left"><code>\def\hail{Hi!}</code><br><code>\renewcommand\hail{\text{Ahoy!}}</code><br><code>\hail</code></td>
</tr>
<tr>
<td style="text-align:left">\renewenvironment</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\require</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\restriction</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↾</mo></mrow><annotation encoding="application/x-tex">\restriction</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8867em;vertical-align:-0.1944em;"></span><span class="mrel amsrm">↾</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\rfloor</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">⌋</mo></mrow><annotation encoding="application/x-tex">\rfloor</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mclose">⌋</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\rgroup</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">⟯</mo></mrow><annotation encoding="application/x-tex">\rgroup</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.989em;vertical-align:-0.244em;"></span><span class="mclose">⟯</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\rhd</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊳</mo></mrow><annotation encoding="application/x-tex">\rhd</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.585em;vertical-align:-0.0352em;"></span><span class="mord amsrm">⊳</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Rho</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">P</mi></mrow><annotation encoding="application/x-tex">\Rho</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathrm">P</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\rho</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ρ</mi></mrow><annotation encoding="application/x-tex">\rho</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">ρ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\right</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle displaystyle="true" scriptlevel="0"><mfrac><mi>a</mi><mi>b</mi></mfrac></mstyle><mo fence="true">)</mo></mrow><annotation encoding="application/x-tex">\left.\dfrac a b\right)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.836em;vertical-align:-0.686em;"></span><span class="minner"><span class="mopen nulldelimiter"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1076em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">b</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size2">)</span></span></span></span></span></span></td>
<td style="text-align:left"><code>\left.\dfrac a b\right)</code></td>
</tr>
<tr>
<td style="text-align:left">\Rightarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇒</mo></mrow><annotation encoding="application/x-tex">\Rightarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">⇒</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\rightarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>→</mo></mrow><annotation encoding="application/x-tex">\rightarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">→</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\rightarrowtail</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↣</mo></mrow><annotation encoding="application/x-tex">\rightarrowtail</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5359em;vertical-align:-0.0135em;"></span><span class="mrel amsrm">↣</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\rightharpoondown</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇁</mo></mrow><annotation encoding="application/x-tex">\rightharpoondown</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">⇁</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\rightharpoonup</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇀</mo></mrow><annotation encoding="application/x-tex">\rightharpoonup</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">⇀</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\rightleftarrows</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇄</mo></mrow><annotation encoding="application/x-tex">\rightleftarrows</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8558em;vertical-align:-0.1808em;"></span><span class="mrel amsrm">⇄</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\rightleftharpoons</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇌</mo></mrow><annotation encoding="application/x-tex">\rightleftharpoons</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.682em;vertical-align:-0.011em;"></span><span class="mrel">⇌</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\rightrightarrows</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇉</mo></mrow><annotation encoding="application/x-tex">\rightrightarrows</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8558em;vertical-align:-0.1808em;"></span><span class="mrel amsrm">⇉</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\rightsquigarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇝</mo></mrow><annotation encoding="application/x-tex">\rightsquigarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3779em;"></span><span class="mrel amsrm">⇝</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\rightthreetimes</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋌</mo></mrow><annotation encoding="application/x-tex">\rightthreetimes</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mord amsrm">⋌</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\risingdotseq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≓</mo></mrow><annotation encoding="application/x-tex">\risingdotseq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.664em;vertical-align:-0.082em;"></span><span class="mrel amsrm">≓</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\rlap</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mpadded width="0px"><mrow><mtext> </mtext><mtext>/</mtext></mrow></mpadded><mo lspace="0em" rspace="0em">=</mo></mrow><annotation encoding="application/x-tex">\rlap{\,/}{=}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord vbox"><span class="thinbox"><span class="rlap"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="inner"><span class="mord"><span class="mord text"><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord textrm">/</span></span></span></span><span class="fix"></span></span></span></span><span class="mord"><span class="mrel">=</span></span></span></span></span></td>
<td style="text-align:left"><code>\rlap{\,/}{=}</code></td>
</tr>
<tr>
<td style="text-align:left">\rm</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">A</mi><mi mathvariant="normal">a</mi><mi mathvariant="normal">B</mi><mi mathvariant="normal">b</mi><mn>12</mn></mrow><annotation encoding="application/x-tex">\rm AaBb12</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord"><span class="mord mathrm">AaBb12</span></span></span></span></span></td>
<td style="text-align:left"><code>\rm AaBb12</code></td>
</tr>
<tr>
<td style="text-align:left">\rmoustache</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">⎱</mo></mrow><annotation encoding="application/x-tex">\rmoustache</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.989em;vertical-align:-0.244em;"></span><span class="mclose">⎱</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\root</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\rotatebox</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"><a href="https://github.com/KaTeX/KaTeX/issues/681" target="_blank" rel="noreferrer">Issue #681</a></td>
</tr>
<tr>
<td style="text-align:left">\rparen</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">\rparen</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mclose">)</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\rq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msup><mrow></mrow><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup></mrow><annotation encoding="application/x-tex">\rq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7519em;"></span><span class="mord"><span></span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7519em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\rrbracket</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo mathvariant="normal" lspace="0em" rspace="0em">⟧</mo></mrow><annotation encoding="application/x-tex">\rrbracket</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mclose"><span class="mclose">]</span><span class="mspace" style="margin-right:-0.1778em;"></span><span class="mclose">]</span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Rrightarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇛</mo></mrow><annotation encoding="application/x-tex">\Rrightarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7733em;vertical-align:-0.1367em;"></span><span class="mrel amsrm">⇛</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Rsh</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↱</mo></mrow><annotation encoding="application/x-tex">\Rsh</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mrel amsrm">↱</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\rtimes</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋊</mo></mrow><annotation encoding="application/x-tex">\rtimes</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6633em;vertical-align:-0.0817em;"></span><span class="mord amsrm">⋊</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Rule</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left">see <code>\rule</code></td>
</tr>
<tr>
<td style="text-align:left">\rule</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>x</mi><mpadded height="0.6em" voffset="0.6em"><mspace mathbackground="black" width="0.862em" height="0.431em"></mspace></mpadded><mi>x</mi></mrow><annotation encoding="application/x-tex">x\rule[6pt]{2ex}{1ex}x</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.031em;"></span><span class="mord mathnormal">x</span><span class="mord rule" style="border-right-width:0.862em;border-top-width:0.431em;bottom:0.6em;"></span><span class="mord mathnormal">x</span></span></span></span></td>
<td style="text-align:left"><code>x\rule[6pt]{2ex}{1ex}x</code></td>
</tr>
<tr>
<td style="text-align:left">\rVert</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">∥</mo></mrow><annotation encoding="application/x-tex">\rVert</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mclose">∥</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\rvert</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">∣</mo></mrow><annotation encoding="application/x-tex">\rvert</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mclose">∣</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
</tbody>
</table>
<h2 id="s" tabindex="-1">S <a class="header-anchor" href="#s" aria-label="Permalink to &quot;S&quot;">&ZeroWidthSpace;</a></h2>
<table>
<thead>
<tr>
<th style="text-align:left">Symbol/Function</th>
<th style="text-align:left">Rendered</th>
<th style="text-align:left">Source or Comment</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">\S</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>§</mtext></mrow><annotation encoding="application/x-tex">\text{\S}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord text"><span class="mord">§</span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\S}</code></td>
</tr>
<tr>
<td style="text-align:left">\Sampi</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\sampi</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\sc</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"><a href="https://github.com/KaTeX/KaTeX/issues/471" target="_blank" rel="noreferrer">Issue #471</a></td>
</tr>
<tr>
<td style="text-align:left">\scalebox</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\scr</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left">See <code>\mathscr</code></td>
</tr>
<tr>
<td style="text-align:left">\scriptscriptstyle</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle scriptlevel="2" displaystyle="false"><mfrac><mi>c</mi><mi>d</mi></mfrac></mstyle></mrow><annotation encoding="application/x-tex">\scriptscriptstyle \frac cd</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6748em;vertical-align:-0.266em;"></span><span class="mord mtight sizing reset-size6 size1"><span class="mopen nulldelimiter sizing reset-size1 size6"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8176em;"><span style="top:-2.468em;"><span class="pstrut" style="height:3em;"></span><span class="mord mtight"><span class="mord mathnormal mtight">d</span></span></span><span style="top:-3.2255em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line mtight" style="border-bottom-width:0.049em;"></span></span><span style="top:-3.387em;"><span class="pstrut" style="height:3em;"></span><span class="mord mtight"><span class="mord mathnormal mtight">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.532em;"><span></span></span></span></span></span><span class="mclose nulldelimiter sizing reset-size1 size6"></span></span></span></span></span></td>
<td style="text-align:left"><code>\scriptscriptstyle \frac cd</code></td>
</tr>
<tr>
<td style="text-align:left">\scriptsize</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathsize="0.7em"><mi>s</mi><mi>c</mi><mi>r</mi><mi>i</mi><mi>p</mi><mi>t</mi><mi>s</mi><mi>i</mi><mi>z</mi><mi>e</mi></mstyle></mrow><annotation encoding="application/x-tex">\scriptsize scriptsize</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5978em;vertical-align:-0.1361em;"></span><span class="mord mathnormal sizing reset-size6 size3" style="margin-right:0.02778em;">scr</span><span class="mord mathnormal sizing reset-size6 size3">i</span><span class="mord mathnormal sizing reset-size6 size3">pt</span><span class="mord mathnormal sizing reset-size6 size3">s</span><span class="mord mathnormal sizing reset-size6 size3">i</span><span class="mord mathnormal sizing reset-size6 size3">ze</span></span></span></span></td>
<td style="text-align:left"><code>\scriptsize scriptsize</code></td>
</tr>
<tr>
<td style="text-align:left">\scriptstyle</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mfrac><mi>a</mi><mi>b</mi></mfrac><mo>+</mo><mstyle scriptlevel="1" displaystyle="false"><mfrac><mi>c</mi><mi>d</mi></mfrac></mstyle></mrow><annotation encoding="application/x-tex">\frac ab + {\scriptstyle \frac cd}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0404em;vertical-align:-0.345em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6954em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">b</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">a</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.7249em;vertical-align:-0.2408em;"></span><span class="mord"><span class="mord mtight sizing reset-size6 size3"><span class="mopen nulldelimiter sizing reset-size3 size6"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6915em;"><span style="top:-2.656em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size3 size1 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">d</span></span></span></span><span style="top:-3.2255em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line mtight" style="border-bottom-width:0.049em;"></span></span><span style="top:-3.384em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size3 size1 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">c</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.344em;"><span></span></span></span></span></span><span class="mclose nulldelimiter sizing reset-size3 size6"></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\frac ab + {\scriptstyle \frac cd}</code></td>
</tr>
<tr>
<td style="text-align:left">\sdot</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋅</mo></mrow><annotation encoding="application/x-tex">\sdot</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4445em;"></span><span class="mord">⋅</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\searrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↘</mo></mrow><annotation encoding="application/x-tex">\searrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel">↘</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\sec</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>sec</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\sec</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mop">sec</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\sect</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>§</mtext></mrow><annotation encoding="application/x-tex">\text{\sect}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord text"><span class="mord">§</span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\sect}</code></td>
</tr>
<tr>
<td style="text-align:left">\setlength</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"><a href="https://github.com/KaTeX/KaTeX/issues/687" target="_blank" rel="noreferrer">Issue #687</a></td>
</tr>
<tr>
<td style="text-align:left">\setminus</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∖</mo></mrow><annotation encoding="application/x-tex">\setminus</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">∖</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\sf</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="sans-serif">A</mi><mi mathvariant="sans-serif">a</mi><mi mathvariant="sans-serif">B</mi><mi mathvariant="sans-serif">b</mi><mn mathvariant="sans-serif">123</mn></mrow><annotation encoding="application/x-tex">\sf AaBb123</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord"><span class="mord mathsf">AaBb123</span></span></span></span></span></td>
<td style="text-align:left"><code>\sf AaBb123</code></td>
</tr>
<tr>
<td style="text-align:left">\sharp</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">♯</mi></mrow><annotation encoding="application/x-tex">\sharp</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord">♯</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\shortmid</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∣</mo></mrow><annotation encoding="application/x-tex">\shortmid</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6633em;vertical-align:-0.0817em;"></span><span class="mrel amsrm">∣</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\shortparallel</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∥</mo></mrow><annotation encoding="application/x-tex">\shortparallel</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6633em;vertical-align:-0.0817em;"></span><span class="mrel amsrm">∥</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\shoveleft</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\shoveright</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\sideset</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Sigma</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Σ</mi></mrow><annotation encoding="application/x-tex">\Sigma</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">Σ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\sigma</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>σ</mi></mrow><annotation encoding="application/x-tex">\sigma</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">σ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\sim</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∼</mo></mrow><annotation encoding="application/x-tex">\sim</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">∼</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\simeq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≃</mo></mrow><annotation encoding="application/x-tex">\simeq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4637em;"></span><span class="mrel">≃</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\sin</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>sin</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\sin</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6679em;"></span><span class="mop">sin</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\sinh</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>sinh</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\sinh</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mop">sinh</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\sixptsize</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathsize="0.6em"><mi>s</mi><mi>i</mi><mi>x</mi><mi>p</mi><mi>t</mi><mi>s</mi><mi>i</mi><mi>z</mi><mi>e</mi></mstyle></mrow><annotation encoding="application/x-tex">\sixptsize sixptsize</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5124em;vertical-align:-0.1167em;"></span><span class="mord mathnormal sizing reset-size6 size2">s</span><span class="mord mathnormal sizing reset-size6 size2">i</span><span class="mord mathnormal sizing reset-size6 size2">x</span><span class="mord mathnormal sizing reset-size6 size2">pt</span><span class="mord mathnormal sizing reset-size6 size2">s</span><span class="mord mathnormal sizing reset-size6 size2">i</span><span class="mord mathnormal sizing reset-size6 size2">ze</span></span></span></span></td>
<td style="text-align:left"><code>\sixptsize sixptsize</code></td>
</tr>
<tr>
<td style="text-align:left">\sh</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>sh</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\sh</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mop">sh</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\skew</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\skip</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\sl</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\small</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathsize="0.9em"><mi>s</mi><mi>m</mi><mi>a</mi><mi>l</mi><mi>l</mi></mstyle></mrow><annotation encoding="application/x-tex">\small small</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;"></span><span class="mord mathnormal sizing reset-size6 size5">s</span><span class="mord mathnormal sizing reset-size6 size5">ma</span><span class="mord mathnormal sizing reset-size6 size5" style="margin-right:0.01968em;">ll</span></span></span></span></td>
<td style="text-align:left"><code>\small small</code></td>
</tr>
<tr>
<td style="text-align:left">\smallfrown</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⌢</mo></mrow><annotation encoding="application/x-tex">\smallfrown</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8867em;vertical-align:-0.1944em;"></span><span class="mrel amsrm">⌢</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\smallint</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo largeop="false">∫</mo></mrow><annotation encoding="application/x-tex">\smallint</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1111em;vertical-align:-0.3061em;"></span><span class="mop op-symbol small-op" style="margin-right:0.19445em;position:relative;top:-0.0006em;">∫</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left" smallmatrix=""></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle scriptlevel="1"><mtable rowspacing="0.1em" columnspacing="0.2778em"><mtr><mtd><mstyle scriptlevel="1" displaystyle="false"><mi>a</mi></mstyle></mtd><mtd><mstyle scriptlevel="1" displaystyle="false"><mi>b</mi></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="1" displaystyle="false"><mi>c</mi></mstyle></mtd><mtd><mstyle scriptlevel="1" displaystyle="false"><mi>d</mi></mstyle></mtd></mtr></mtable></mstyle></mrow><annotation encoding="application/x-tex">\begin{smallmatrix} a &amp; b \\ c &amp; d \end{smallmatrix}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.3322em;vertical-align:-0.4161em;"></span><span class="mord"><span class="mtable"><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.9161em;"><span style="top:-3.13em;"><span class="pstrut" style="height:2.7em;"></span><span class="mord mtight sizing reset-size6 size3"><span class="mord mathnormal mtight">a</span></span></span><span style="top:-2.4639em;"><span class="pstrut" style="height:2.7em;"></span><span class="mord mtight sizing reset-size6 size3"><span class="mord mathnormal mtight">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.4161em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:0.1945em;"></span><span class="arraycolsep" style="width:0.1945em;"></span><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.9161em;"><span style="top:-3.13em;"><span class="pstrut" style="height:2.7em;"></span><span class="mord mtight sizing reset-size6 size3"><span class="mord mathnormal mtight">b</span></span></span><span style="top:-2.4639em;"><span class="pstrut" style="height:2.7em;"></span><span class="mord mtight sizing reset-size6 size3"><span class="mord mathnormal mtight">d</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.4161em;"><span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\begin{smallmatrix}</code><br>   <code>a &amp; b \\</code><br>   <code>c &amp; d</code><br><code>\end{smallmatrix}</code></td>
</tr>
<tr>
<td style="text-align:left">\smallsetminus</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∖</mo></mrow><annotation encoding="application/x-tex">\smallsetminus</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6633em;vertical-align:-0.0817em;"></span><span class="mord amsrm">∖</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\smallsmile</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⌣</mo></mrow><annotation encoding="application/x-tex">\smallsmile</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8867em;vertical-align:-0.1944em;"></span><span class="mrel amsrm">⌣</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\smash</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true">(</mo><msup><mi>x</mi><mpadded height="0px" depth="0px"><mn>2</mn></mpadded></msup><mo fence="true">)</mo></mrow><annotation encoding="application/x-tex">\left(x^{\smash{2}}\right)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.363em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0em;"><span style="top:-2.7em;"><span class="pstrut" style="height:2.7em;"></span><span><span class="mord mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">)</span></span></span></span></span></td>
<td style="text-align:left"><code>\left(x^{\smash{2}}\right)</code></td>
</tr>
<tr>
<td style="text-align:left">\smile</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⌣</mo></mrow><annotation encoding="application/x-tex">\smile</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3576em;"></span><span class="mrel">⌣</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\smiley</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\sout</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><menclose notation="horizontalstrike"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></menclose></mrow><annotation encoding="application/x-tex">\sout{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6944em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">ab</span><span class="mord mathnormal">c</span></span></span><span style="top:-3.2155em;"><span class="pstrut" style="height:3em;"></span><span class="stretchy sout"></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\sout{abc}</code></td>
</tr>
<tr>
<td style="text-align:left">\Space</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left">see <code>\space</code></td>
</tr>
<tr>
<td style="text-align:left">\space</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mtext> </mtext><mi>b</mi></mrow><annotation encoding="application/x-tex">a\space b</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">a</span><span class="mspace"> </span><span class="mord mathnormal">b</span></span></span></span></td>
<td style="text-align:left"><code>a\space b</code></td>
</tr>
<tr>
<td style="text-align:left">\spades</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">♠</mi></mrow><annotation encoding="application/x-tex">\spades</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8241em;vertical-align:-0.1296em;"></span><span class="mord">♠</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\spadesuit</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">♠</mi></mrow><annotation encoding="application/x-tex">\spadesuit</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8241em;vertical-align:-0.1296em;"></span><span class="mord">♠</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\sphericalangle</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∢</mi></mrow><annotation encoding="application/x-tex">\sphericalangle</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5576em;vertical-align:-0.0352em;"></span><span class="mord amsrm">∢</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left" split=""></td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"><a href="https://github.com/KaTeX/KaTeX/issues/1345" target="_blank" rel="noreferrer">Issue #1345</a></td>
</tr>
<tr>
<td style="text-align:left">\sqcap</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊓</mo></mrow><annotation encoding="application/x-tex">\sqcap</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5556em;"></span><span class="mord">⊓</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\sqcup</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊔</mo></mrow><annotation encoding="application/x-tex">\sqcup</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5556em;"></span><span class="mord">⊔</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\square</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">□</mi></mrow><annotation encoding="application/x-tex">\square</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.675em;"></span><span class="mord amsrm">□</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\sqrt</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mroot><mi>x</mi><mn>3</mn></mroot></mrow><annotation encoding="application/x-tex">\sqrt[3]{x}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.04em;vertical-align:-0.2397em;"></span><span class="mord sqrt"><span class="root"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6586em;"><span style="top:-2.8363em;"><span class="pstrut" style="height:2.5em;"></span><span class="sizing reset-size6 size1 mtight"><span class="mord mtight"><span class="mord mtight">3</span></span></span></span></span></span></span></span><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8003em;"><span class="svg-align" style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord" style="padding-left:0.833em;"><span class="mord mathnormal">x</span></span></span><span style="top:-2.7603em;"><span class="pstrut" style="height:3em;"></span><span class="hide-tail" style="min-width:0.853em;height:1.08em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='1.08em' viewBox='0 0 400000 1080' preserveAspectRatio='xMinYMin slice'><path d='M95,702
c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14
c0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54
c44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10
s173,378,173,378c0.7,0,35.3,-71,104,-213c68.7,-142,137.5,-285,206.5,-429
c69,-144,104.5,-217.7,106.5,-221
l0 -0
c5.3,-9.3,12,-14,20,-14
H400000v40H845.2724
s-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7
c-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z
M834 80h400000v40h-400000z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2397em;"><span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\sqrt[3]{x}</code></td>
</tr>
<tr>
<td style="text-align:left">\sqsubset</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊏</mo></mrow><annotation encoding="application/x-tex">\sqsubset</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.585em;vertical-align:-0.0352em;"></span><span class="mrel amsrm">⊏</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\sqsubseteq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊑</mo></mrow><annotation encoding="application/x-tex">\sqsubseteq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mrel">⊑</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\sqsupset</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊐</mo></mrow><annotation encoding="application/x-tex">\sqsupset</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.585em;vertical-align:-0.0352em;"></span><span class="mrel amsrm">⊐</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\sqsupseteq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊒</mo></mrow><annotation encoding="application/x-tex">\sqsupseteq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mrel">⊒</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\ss</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>ß</mtext></mrow><annotation encoding="application/x-tex">\text{\ss}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord">ß</span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\ss}</code></td>
</tr>
<tr>
<td style="text-align:left">\stackrel</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mover><mo><mo>=</mo></mo><mo stretchy="false" lspace="0em" rspace="0em">!</mo></mover></mo></mrow><annotation encoding="application/x-tex">\stackrel{!}{=}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.153em;"></span><span class="mrel"><span class="mop op-limits"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:1.153em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span><span class="mop">=</span></span></span><span style="top:-3.5669em;margin-left:0em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mclose mtight">!</span></span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\stackrel{!}{=}</code></td>
</tr>
<tr>
<td style="text-align:left">\star</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋆</mo></mrow><annotation encoding="application/x-tex">\star</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4653em;"></span><span class="mord">⋆</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Stigma</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\stigma</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\strut</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\style</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left">Non standard</td>
</tr>
<tr>
<td style="text-align:left">\sub</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊂</mo></mrow><annotation encoding="application/x-tex">\sub</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">⊂</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left" subarray=""></td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\sube</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊆</mo></mrow><annotation encoding="application/x-tex">\sube</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mrel">⊆</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Subset</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋐</mo></mrow><annotation encoding="application/x-tex">\Subset</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.585em;vertical-align:-0.0352em;"></span><span class="mrel amsrm">⋐</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\subset</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊂</mo></mrow><annotation encoding="application/x-tex">\subset</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">⊂</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\subseteq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊆</mo></mrow><annotation encoding="application/x-tex">\subseteq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mrel">⊆</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\subseteqq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⫅</mo></mrow><annotation encoding="application/x-tex">\subseteqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0117em;vertical-align:-0.2558em;"></span><span class="mrel amsrm">⫅</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\subsetneq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊊</mo></mrow><annotation encoding="application/x-tex">\subsetneq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mrel amsrm">⊊</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\subsetneqq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⫋</mo></mrow><annotation encoding="application/x-tex">\subsetneqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0786em;vertical-align:-0.2848em;"></span><span class="mrel amsrm">⫋</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\substack</td>
<td style="text-align:left">$$\sum_{\substack{0&lt;i&lt;m\0&lt;j&lt;n}}$$</td>
<td style="text-align:left"><code>\sum_{\substack{0&lt;i&lt;m\\0&lt;j&lt;n}}</code></td>
</tr>
<tr>
<td style="text-align:left">\succ</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≻</mo></mrow><annotation encoding="application/x-tex">\succ</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">≻</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\succapprox</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⪸</mo></mrow><annotation encoding="application/x-tex">\succapprox</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0189em;vertical-align:-0.2617em;"></span><span class="mrel amsrm">⪸</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\succcurlyeq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≽</mo></mrow><annotation encoding="application/x-tex">\succcurlyeq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7733em;vertical-align:-0.1367em;"></span><span class="mrel amsrm">≽</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\succeq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⪰</mo></mrow><annotation encoding="application/x-tex">\succeq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mrel">⪰</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\succnapprox</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⪺</mo></mrow><annotation encoding="application/x-tex">\succnapprox</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0189em;vertical-align:-0.2617em;"></span><span class="mrel amsrm">⪺</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\succneqq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⪶</mo></mrow><annotation encoding="application/x-tex">\succneqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0087em;vertical-align:-0.2514em;"></span><span class="mrel amsrm">⪶</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\succnsim</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋩</mo></mrow><annotation encoding="application/x-tex">\succnsim</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9733em;vertical-align:-0.2322em;"></span><span class="mrel amsrm">⋩</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\succsim</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≿</mo></mrow><annotation encoding="application/x-tex">\succsim</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9592em;vertical-align:-0.2296em;"></span><span class="mrel amsrm">≿</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\sum</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∑</mo></mrow><annotation encoding="application/x-tex">\sum</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mop op-symbol small-op" style="position:relative;top:0em;">∑</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\sup</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>sup</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\sup</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mop">sup</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\supe</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊇</mo></mrow><annotation encoding="application/x-tex">\supe</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mrel">⊇</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Supset</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋑</mo></mrow><annotation encoding="application/x-tex">\Supset</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.585em;vertical-align:-0.0352em;"></span><span class="mrel amsrm">⋑</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\supset</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊃</mo></mrow><annotation encoding="application/x-tex">\supset</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">⊃</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\supseteq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊇</mo></mrow><annotation encoding="application/x-tex">\supseteq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mrel">⊇</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\supseteqq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⫆</mo></mrow><annotation encoding="application/x-tex">\supseteqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0117em;vertical-align:-0.2558em;"></span><span class="mrel amsrm">⫆</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\supsetneq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊋</mo></mrow><annotation encoding="application/x-tex">\supsetneq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mrel amsrm">⊋</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\supsetneqq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⫌</mo></mrow><annotation encoding="application/x-tex">\supsetneqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0786em;vertical-align:-0.2848em;"></span><span class="mrel amsrm">⫌</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\surd</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">√</mi></mrow><annotation encoding="application/x-tex">\surd</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.2em;"></span><span class="mord">√</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\swarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↙</mo></mrow><annotation encoding="application/x-tex">\swarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel">↙</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
</tbody>
</table>
<h2 id="t" tabindex="-1">T <a class="header-anchor" href="#t" aria-label="Permalink to &quot;T&quot;">&ZeroWidthSpace;</a></h2>
<table>
<thead>
<tr>
<th style="text-align:left">Symbol/Function</th>
<th style="text-align:left">Rendered</th>
<th style="text-align:left">Source or Comment</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">\tag</td>
<td style="text-align:left">$$\tag{3.1c} a^2+b^2=c^2$$</td>
<td style="text-align:left"><code>\tag{3.1c} a^2+b^2=c^2</code></td>
</tr>
<tr>
<td style="text-align:left">\tag*</td>
<td style="text-align:left">$$\tag*{3.1c} a^2+b^2=c^2$$</td>
<td style="text-align:left"><code>\tag*{3.1c} a^2+b^2=c^2</code></td>
</tr>
<tr>
<td style="text-align:left">\tan</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>tan</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\tan</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6151em;"></span><span class="mop">tan</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\tanh</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>tanh</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\tanh</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mop">tanh</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Tau</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">T</mi></mrow><annotation encoding="application/x-tex">\Tau</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathrm">T</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\tau</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>τ</mi></mrow><annotation encoding="application/x-tex">\tau</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal" style="margin-right:0.1132em;">τ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\tbinom</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true">(</mo><mfrac linethickness="0px"><mi>n</mi><mi>k</mi></mfrac><mo fence="true">)</mo></mrow><annotation encoding="application/x-tex">\tbinom n k</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2em;vertical-align:-0.35em;"></span><span class="mord"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size1">(</span></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.7454em;"><span style="top:-2.355em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.03148em;">k</span></span></span></span><span style="top:-3.144em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">n</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size1">)</span></span></span></span></span></span></td>
<td style="text-align:left"><code>\tbinom n k</code></td>
</tr>
<tr>
<td style="text-align:left">\TeX</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>TeX</mtext></mrow><annotation encoding="application/x-tex">\TeX</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8988em;vertical-align:-0.2155em;"></span><span class="mord text"><span class="mord textrm">T</span><span class="mspace" style="margin-right:-0.1667em;"></span><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.4678em;"><span style="top:-2.7845em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord textrm">E</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2155em;"><span></span></span></span></span><span class="mspace" style="margin-right:-0.125em;"></span><span class="mord textrm">X</span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\text</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext> yes </mtext><mi mathvariant="normal">&amp;</mi><mtext> no </mtext></mrow><annotation encoding="application/x-tex">\text{ yes }\&amp;\text{ no }</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord text"><span class="mord"> yes </span></span><span class="mord">&amp;</span><span class="mord text"><span class="mord"> no </span></span></span></span></span></td>
<td style="text-align:left"><code>\text{ yes }\&amp;\text{ no }</code></td>
</tr>
<tr>
<td style="text-align:left">\textasciitilde</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>~</mtext></mrow><annotation encoding="application/x-tex">\text{\textasciitilde}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6679em;vertical-align:-0.35em;"></span><span class="mord text"><span class="mord">~</span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\textasciitilde}</code></td>
</tr>
<tr>
<td style="text-align:left">\textasciicircum</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>^</mtext></mrow><annotation encoding="application/x-tex">\text{\textasciicircum}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord">^</span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\textasciicircum}</code></td>
</tr>
<tr>
<td style="text-align:left">\textbackslash</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>\</mtext></mrow><annotation encoding="application/x-tex">\text{\textbackslash}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord text"><span class="mord">\</span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\textbackslash}</code></td>
</tr>
<tr>
<td style="text-align:left">\textbar</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>|</mtext></mrow><annotation encoding="application/x-tex">\text{\textbar}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord text"><span class="mord">|</span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\textbar}</code></td>
</tr>
<tr>
<td style="text-align:left">\textbardbl</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>∥</mtext></mrow><annotation encoding="application/x-tex">\text{\textbardbl}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord text"><span class="mord">∥</span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\textbardbl}</code></td>
</tr>
<tr>
<td style="text-align:left">\textbf</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext mathvariant="bold">AaBb123</mtext></mrow><annotation encoding="application/x-tex">\textbf{AaBb123}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord textbf">AaBb123</span></span></span></span></span></td>
<td style="text-align:left"><code>\textbf{AaBb123}</code></td>
</tr>
<tr>
<td style="text-align:left">\textbraceleft</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>{</mtext></mrow><annotation encoding="application/x-tex">\text{\textbraceleft}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord text"><span class="mord">{</span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\textbraceleft}</code></td>
</tr>
<tr>
<td style="text-align:left">\textbraceright</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>}</mtext></mrow><annotation encoding="application/x-tex">\text{\textbraceright}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord text"><span class="mord">}</span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\textbraceright}</code></td>
</tr>
<tr>
<td style="text-align:left">\textcircled</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mtext>a</mtext><mo>◯</mo></mover></mrow><annotation encoding="application/x-tex">\text{\textcircled a}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;"></span><span class="mord text"><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8889em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord">a</span></span><span style="top:-3.1944em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body accent-full" style="left:0em;top:.2em;"><span class="mord">◯</span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\textcircled a}</code></td>
</tr>
<tr>
<td style="text-align:left">\textcolor</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathcolor="blue"><mi>F</mi><mo>=</mo><mi>m</mi><mi>a</mi></mstyle></mrow><annotation encoding="application/x-tex">\textcolor{blue}{F=ma}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.13889em;color:blue;">F</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel" style="color:blue;">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal" style="color:blue;">ma</span></span></span></span></td>
<td style="text-align:left"><code>\textcolor{blue}{F=ma}</code></td>
</tr>
<tr>
<td style="text-align:left">\textdagger</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>†</mtext></mrow><annotation encoding="application/x-tex">\text{\textdagger}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord text"><span class="mord">†</span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\textdagger}</code></td>
</tr>
<tr>
<td style="text-align:left">\textdaggerdbl</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>‡</mtext></mrow><annotation encoding="application/x-tex">\text{\textdaggerdbl}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord text"><span class="mord">‡</span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\textdaggerdbl}</code></td>
</tr>
<tr>
<td style="text-align:left">\textdegree</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>°</mtext></mrow><annotation encoding="application/x-tex">\text{\textdegree}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord">°</span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\textdegree}</code></td>
</tr>
<tr>
<td style="text-align:left">\textdollar</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>$</mtext></mrow><annotation encoding="application/x-tex">\text{\textdollar}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8056em;vertical-align:-0.0556em;"></span><span class="mord text"><span class="mord">$</span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\textdollar}</code></td>
</tr>
<tr>
<td style="text-align:left">\textellipsis</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>…</mo></mrow><annotation encoding="application/x-tex">\text{\textellipsis}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.123em;"></span><span class="mord text"><span class="minner">…</span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\textellipsis}</code></td>
</tr>
<tr>
<td style="text-align:left">\textemdash</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>—</mtext></mrow><annotation encoding="application/x-tex">\text{\textemdash}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord text"><span class="mord">—</span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\textemdash}</code></td>
</tr>
<tr>
<td style="text-align:left">\textendash</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>–</mtext></mrow><annotation encoding="application/x-tex">\text{\textendash}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord text"><span class="mord">–</span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\textendash}</code></td>
</tr>
<tr>
<td style="text-align:left">\textgreater</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>&gt;</mtext></mrow><annotation encoding="application/x-tex">\text{\textgreater}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mord text"><span class="mord">&gt;</span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\textgreater}</code></td>
</tr>
<tr>
<td style="text-align:left">\textit</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext mathvariant="italic">AaBb</mtext></mrow><annotation encoding="application/x-tex">\textit{AaBb}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord textit">AaBb</span></span></span></span></span></td>
<td style="text-align:left"><code>\textit{AaBb}</code></td>
</tr>
<tr>
<td style="text-align:left">\textless</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>&lt;</mtext></mrow><annotation encoding="application/x-tex">\text{\textless}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mord text"><span class="mord">&lt;</span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\textless}</code></td>
</tr>
<tr>
<td style="text-align:left">\textmd</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>AaBb123</mtext></mrow><annotation encoding="application/x-tex">\textmd{AaBb123}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord textmd">AaBb123</span></span></span></span></span></td>
<td style="text-align:left"><code>\textmd{AaBb123}</code></td>
</tr>
<tr>
<td style="text-align:left">\textnormal</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>AB</mtext></mrow><annotation encoding="application/x-tex">\textnormal{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord text"><span class="mord textrm">AB</span></span></span></span></span></td>
<td style="text-align:left"><code>\textnormal{AB}</code></td>
</tr>
<tr>
<td style="text-align:left">\textquotedblleft</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>“</mtext></mrow><annotation encoding="application/x-tex">\text{\textquotedblleft}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord">“</span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\textquotedblleft}</code></td>
</tr>
<tr>
<td style="text-align:left">\textquotedblright</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>”</mtext></mrow><annotation encoding="application/x-tex">\text{\textquotedblright}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord">”</span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\textquotedblright}</code></td>
</tr>
<tr>
<td style="text-align:left">\textquoteleft</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>‘</mtext></mrow><annotation encoding="application/x-tex">\text{\textquoteleft}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord">‘</span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\textquoteleft}</code></td>
</tr>
<tr>
<td style="text-align:left">\textquoteright</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>’</mtext></mrow><annotation encoding="application/x-tex">\text{\textquoteright}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord">’</span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\textquoteright}</code></td>
</tr>
<tr>
<td style="text-align:left">\textregistered</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>®</mtext></mrow><annotation encoding="application/x-tex">\text{\textregistered}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;"></span><span class="mord text"><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8889em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord sizing reset-size6 size3">R</span></span></span><span style="top:-3.1944em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body accent-full" style="left:0em;top:.2em;"><span class="mord">◯</span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\textregistered}</code></td>
</tr>
<tr>
<td style="text-align:left">\textrm</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>AaBb123</mtext></mrow><annotation encoding="application/x-tex">\textrm{AaBb123}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord textrm">AaBb123</span></span></span></span></span></td>
<td style="text-align:left"><code>\textrm{AaBb123}</code></td>
</tr>
<tr>
<td style="text-align:left">\textsc</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"><a href="https://github.com/KaTeX/KaTeX/issues/471" target="_blank" rel="noreferrer">Issue #471</a></td>
</tr>
<tr>
<td style="text-align:left">\textsf</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext mathvariant="sans-serif">AaBb123</mtext></mrow><annotation encoding="application/x-tex">\textsf{AaBb123}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord textsf">AaBb123</span></span></span></span></span></td>
<td style="text-align:left"><code>\textsf{AaBb123}</code></td>
</tr>
<tr>
<td style="text-align:left">\textsl</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\textsterling</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>£</mtext></mrow><annotation encoding="application/x-tex">\text{\textsterling}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord">£</span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\textsterling}</code></td>
</tr>
<tr>
<td style="text-align:left">\textstyle</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle scriptlevel="0" displaystyle="false"><msubsup><mo>∑</mo><mn>0</mn><mi>n</mi></msubsup></mstyle></mrow><annotation encoding="application/x-tex">\textstyle\sum_0^n</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.104em;vertical-align:-0.2997em;"></span><span class="mop"><span class="mop op-symbol small-op" style="position:relative;top:0em;">∑</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8043em;"><span style="top:-2.4003em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">0</span></span></span><span style="top:-3.2029em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">n</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2997em;"><span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\textstyle\sum_0^n</code></td>
</tr>
<tr>
<td style="text-align:left">\texttip</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\texttt</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext mathvariant="monospace">AaBb123</mtext></mrow><annotation encoding="application/x-tex">\texttt{AaBb123}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6111em;"></span><span class="mord text"><span class="mord texttt">AaBb123</span></span></span></span></span></td>
<td style="text-align:left"><code>\texttt{AaBb123}</code></td>
</tr>
<tr>
<td style="text-align:left">\textunderscore</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>_</mtext></mrow><annotation encoding="application/x-tex">\text{\textunderscore}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;vertical-align:-0.31em;"></span><span class="mord text"><span class="mord">_</span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\textunderscore}</code></td>
</tr>
<tr>
<td style="text-align:left">\textup</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>AaBb123</mtext></mrow><annotation encoding="application/x-tex">\textup{AaBb123}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord textup">AaBb123</span></span></span></span></span></td>
<td style="text-align:left"><code>\textup{AaBb123}</code></td>
</tr>
<tr>
<td style="text-align:left">\textvisiblespace</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\tfrac</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mfrac><mi>a</mi><mi>b</mi></mfrac></mrow><annotation encoding="application/x-tex">\tfrac ab</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0404em;vertical-align:-0.345em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6954em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">b</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">a</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span></td>
<td style="text-align:left"><code>\tfrac ab</code></td>
</tr>
<tr>
<td style="text-align:left">\tg</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>tg</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\tg</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8095em;vertical-align:-0.1944em;"></span><span class="mop">t<span style="margin-right:0.01389em;">g</span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\th</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>th</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\th</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mop">th</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\therefore</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∴</mo></mrow><annotation encoding="application/x-tex">\therefore</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mrel amsrm">∴</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Theta</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Θ</mi></mrow><annotation encoding="application/x-tex">\Theta</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">Θ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\theta</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>θ</mi></mrow><annotation encoding="application/x-tex">\theta</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal" style="margin-right:0.02778em;">θ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\thetasym</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ϑ</mi></mrow><annotation encoding="application/x-tex">\thetasym</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">ϑ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\thickapprox</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≈</mo></mrow><annotation encoding="application/x-tex">\thickapprox</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4831em;"></span><span class="mrel amsrm">≈</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\thicksim</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∼</mo></mrow><annotation encoding="application/x-tex">\thicksim</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel amsrm">∼</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\thickspace</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mtext>  </mtext><mi>b</mi></mrow><annotation encoding="application/x-tex">a\thickspace b</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">a</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord mathnormal">b</span></span></span></span></td>
<td style="text-align:left"><code>a\thickspace b</code></td>
</tr>
<tr>
<td style="text-align:left">\thinspace</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mtext> </mtext><mi>b</mi></mrow><annotation encoding="application/x-tex">a\thinspace b</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">a</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">b</span></span></span></span></td>
<td style="text-align:left"><code>a\thinspace b</code></td>
</tr>
<tr>
<td style="text-align:left">\tilde</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mi>M</mi><mo>~</mo></mover></mrow><annotation encoding="application/x-tex">\tilde M</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9202em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.9202em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord mathnormal" style="margin-right:0.10903em;">M</span></span><span style="top:-3.6023em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.1667em;"><span class="mord">~</span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\tilde M</code></td>
</tr>
<tr>
<td style="text-align:left">\times</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>×</mo></mrow><annotation encoding="application/x-tex">\times</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mord">×</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Tiny</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left">see <code>\tiny</code></td>
</tr>
<tr>
<td style="text-align:left">\tiny</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathsize="0.5em"><mi>t</mi><mi>i</mi><mi>n</mi><mi>y</mi></mstyle></mrow><annotation encoding="application/x-tex">\tiny tiny</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.427em;vertical-align:-0.0972em;"></span><span class="mord mathnormal sizing reset-size6 size1">t</span><span class="mord mathnormal sizing reset-size6 size1">in</span><span class="mord mathnormal sizing reset-size6 size1" style="margin-right:0.03588em;">y</span></span></span></span></td>
<td style="text-align:left"><code>\tiny tiny</code></td>
</tr>
<tr>
<td style="text-align:left">\to</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>→</mo></mrow><annotation encoding="application/x-tex">\to</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">→</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\toggle</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\top</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">⊤</mi></mrow><annotation encoding="application/x-tex">\top</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">⊤</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\triangle</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">△</mi></mrow><annotation encoding="application/x-tex">\triangle</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord">△</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\triangledown</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">▽</mi></mrow><annotation encoding="application/x-tex">\triangledown</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5499em;"></span><span class="mord amsrm">▽</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\triangleleft</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>◃</mo></mrow><annotation encoding="application/x-tex">\triangleleft</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4653em;"></span><span class="mord">◃</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\trianglelefteq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊴</mo></mrow><annotation encoding="application/x-tex">\trianglelefteq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7733em;vertical-align:-0.1367em;"></span><span class="mrel amsrm">⊴</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\triangleq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≜</mo></mrow><annotation encoding="application/x-tex">\triangleq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9987em;vertical-align:-0.082em;"></span><span class="mrel amsrm">≜</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\triangleright</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>▹</mo></mrow><annotation encoding="application/x-tex">\triangleright</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4653em;"></span><span class="mord">▹</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\trianglerighteq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊵</mo></mrow><annotation encoding="application/x-tex">\trianglerighteq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7733em;vertical-align:-0.1367em;"></span><span class="mrel amsrm">⊵</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\tt</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="monospace">A</mi><mi mathvariant="monospace">a</mi><mi mathvariant="monospace">B</mi><mi mathvariant="monospace">b</mi><mn mathvariant="monospace">123</mn></mrow><annotation encoding="application/x-tex">{\tt AaBb123}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6111em;"></span><span class="mord"><span class="mord"><span class="mord mathtt">AaBb123</span></span></span></span></span></span></td>
<td style="text-align:left"><code>{\tt AaBb123}</code></td>
</tr>
<tr>
<td style="text-align:left">\twoheadleftarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↞</mo></mrow><annotation encoding="application/x-tex">\twoheadleftarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5359em;vertical-align:-0.0135em;"></span><span class="mrel amsrm">↞</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\twoheadrightarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↠</mo></mrow><annotation encoding="application/x-tex">\twoheadrightarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5359em;vertical-align:-0.0135em;"></span><span class="mrel amsrm">↠</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
</tbody>
</table>
<h2 id="u" tabindex="-1">U <a class="header-anchor" href="#u" aria-label="Permalink to &quot;U&quot;">&ZeroWidthSpace;</a></h2>
<table>
<thead>
<tr>
<th style="text-align:left">Symbol/Function</th>
<th style="text-align:left">Rendered</th>
<th style="text-align:left">Source or Comment</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">\u</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mtext>a</mtext><mo>˘</mo></mover></mrow><annotation encoding="application/x-tex">\text{\u{a}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6944em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">a</span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.25em;"><span class="mord">˘</span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\u{a}}</code></td>
</tr>
<tr>
<td style="text-align:left">\Uarr</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇑</mo></mrow><annotation encoding="application/x-tex">\Uarr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel">⇑</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\uArr</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇑</mo></mrow><annotation encoding="application/x-tex">\uArr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel">⇑</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\uarr</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↑</mo></mrow><annotation encoding="application/x-tex">\uarr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel">↑</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\ulcorner</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mi mathvariant="normal">⌜</mi></mo></mrow><annotation encoding="application/x-tex">\ulcorner</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mopen amsrm">┌</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\underbrace</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><munder><munder><mrow><mi>x</mi><mo>+</mo><mo>⋯</mo><mo>+</mo><mi>x</mi></mrow><mo stretchy="true">⏟</mo></munder><mrow><mi>n</mi><mtext> times</mtext></mrow></munder></mrow><annotation encoding="application/x-tex">\underbrace{x+⋯+x}_{n\text{ times}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.9822em;vertical-align:-1.3988em;"></span><span class="mord munder"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.5833em;"><span style="top:-1.6012em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">n</span><span class="mord text mtight"><span class="mord mtight"> times</span></span></span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord munder"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.5833em;"><span class="svg-align" style="top:-2.2687em;"><span class="pstrut" style="height:3em;"></span><span class="stretchy" style="height:0.548em;min-width:1.6em;"><span class="brace-left" style="height:0.548em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.548em' viewBox='0 0 400000 548' preserveAspectRatio='xMinYMin slice'><path d='M0 6l6-6h17c12.688 0 19.313.3 20 1 4 4 7.313 8.3 10 13
 35.313 51.3 80.813 93.8 136.5 127.5 55.688 33.7 117.188 55.8 184.5 66.5.688
 0 2 .3 4 1 18.688 2.7 76 4.3 172 5h399450v120H429l-6-1c-124.688-8-235-61.7
-331-161C60.687 138.7 32.312 99.3 7 54L0 41V6z'/></svg></span><span class="brace-center" style="height:0.548em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.548em' viewBox='0 0 400000 548' preserveAspectRatio='xMidYMin slice'><path d='M199572 214
c100.7 8.3 195.3 44 280 108 55.3 42 101.7 93 139 153l9 14c2.7-4 5.7-8.7 9-14
 53.3-86.7 123.7-153 211-199 66.7-36 137.3-56.3 212-62h199568v120H200432c-178.3
 11.7-311.7 78.3-403 201-6 8-9.7 12-11 12-.7.7-6.7 1-18 1s-17.3-.3-18-1c-1.3 0
-5-4-11-12-44.7-59.3-101.3-106.3-170-141s-145.3-54.3-229-60H0V214z'/></svg></span><span class="brace-right" style="height:0.548em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.548em' viewBox='0 0 400000 548' preserveAspectRatio='xMaxYMin slice'><path d='M399994 0l6 6v35l-6 11c-56 104-135.3 181.3-238 232-57.3
 28.7-117 45-179 50H-300V214h399897c43.3-7 81-15 113-26 100.7-33 179.7-91 237
-174 2.7-5 6-9 10-13 .7-1 7.3-1 20-1h17z'/></svg></span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">x</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="minner">⋯</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal">x</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.7313em;"><span></span></span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.3988em;"><span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\underbrace{x+⋯+x}_{n\text{ times}}</code></td>
</tr>
<tr>
<td style="text-align:left">\underbracket</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\undergroup</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><munder accentunder="true"><mrow><mi>A</mi><mi>B</mi></mrow><mo stretchy="true">⏡</mo></munder></mrow><annotation encoding="application/x-tex">\undergroup{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0253em;vertical-align:-0.342em;"></span><span class="mord accentunder"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6833em;"><span class="svg-align" style="top:-2.658em;"><span class="pstrut" style="height:3em;"></span><span class="stretchy" style="height:0.342em;min-width:0.888em;"><span class="halfarrow-left" style="height:0.342em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.342em' viewBox='0 0 400000 342' preserveAspectRatio='xMinYMin slice'><path d='M400000 262
H435C64 262 168.3 112.6 21 82c-5.9-1.2-18 0-18 0-2 0-3 1-3 3v38c76 158 257 219
 435 219h399565z'/></svg></span><span class="halfarrow-right" style="height:0.342em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.342em' viewBox='0 0 400000 342' preserveAspectRatio='xMaxYMin slice'><path d='M0 262h399565c371 0 266.7-149.4 414-180 5.9-1.2 18 0 18
 0 2 0 3 1 3 3v38c-76 158-257 219-435 219H0z'/></svg></span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.342em;"><span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\undergroup{AB}</code></td>
</tr>
<tr>
<td style="text-align:left">\underleftarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><munder accentunder="true"><mrow><mi>A</mi><mi>B</mi></mrow><mo stretchy="true">←</mo></munder></mrow><annotation encoding="application/x-tex">\underleftarrow{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2053em;vertical-align:-0.522em;"></span><span class="mord accentunder"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6833em;"><span class="svg-align" style="top:-2.478em;"><span class="pstrut" style="height:3em;"></span><span class="hide-tail" style="height:0.522em;min-width:0.888em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMinYMin slice'><path d='M400000 241H110l3-3c68.7-52.7 113.7-120
 135-202 4-14.7 6-23 6-25 0-7.3-7-11-21-11-8 0-13.2.8-15.5 2.5-2.3 1.7-4.2 5.8
-5.5 12.5-1.3 4.7-2.7 10.3-4 17-12 48.7-34.8 92-68.5 130S65.3 228.3 18 247
c-10 4-16 7.7-18 11 0 8.7 6 14.3 18 17 47.3 18.7 87.8 47 121.5 85S196 441.3 208
 490c.7 2 1.3 5 2 9s1.2 6.7 1.5 8c.3 1.3 1 3.3 2 6s2.2 4.5 3.5 5.5c1.3 1 3.3
 1.8 6 2.5s6 1 10 1c14 0 21-3.7 21-11 0-2-2-10.3-6-25-20-79.3-65-146.7-135-202
 l-3-3h399890zM100 241v40h399900v-40z'/></svg></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.522em;"><span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\underleftarrow{AB}</code></td>
</tr>
<tr>
<td style="text-align:left">\underleftrightarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><munder accentunder="true"><mrow><mi>A</mi><mi>B</mi></mrow><mo stretchy="true">↔</mo></munder></mrow><annotation encoding="application/x-tex">\underleftrightarrow{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2053em;vertical-align:-0.522em;"></span><span class="mord accentunder"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6833em;"><span class="svg-align" style="top:-2.478em;"><span class="pstrut" style="height:3em;"></span><span class="stretchy" style="height:0.522em;min-width:0.888em;"><span class="halfarrow-left" style="height:0.522em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMinYMin slice'><path d='M400000 241H110l3-3c68.7-52.7 113.7-120
 135-202 4-14.7 6-23 6-25 0-7.3-7-11-21-11-8 0-13.2.8-15.5 2.5-2.3 1.7-4.2 5.8
-5.5 12.5-1.3 4.7-2.7 10.3-4 17-12 48.7-34.8 92-68.5 130S65.3 228.3 18 247
c-10 4-16 7.7-18 11 0 8.7 6 14.3 18 17 47.3 18.7 87.8 47 121.5 85S196 441.3 208
 490c.7 2 1.3 5 2 9s1.2 6.7 1.5 8c.3 1.3 1 3.3 2 6s2.2 4.5 3.5 5.5c1.3 1 3.3
 1.8 6 2.5s6 1 10 1c14 0 21-3.7 21-11 0-2-2-10.3-6-25-20-79.3-65-146.7-135-202
 l-3-3h399890zM100 241v40h399900v-40z'/></svg></span><span class="halfarrow-right" style="height:0.522em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMaxYMin slice'><path d='M0 241v40h399891c-47.3 35.3-84 78-110 128
-16.7 32-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20
 11 8 0 13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7
 39-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85
-40.5-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5
-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67
 151.7 139 205zm0 0v40h399900v-40z'/></svg></span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.522em;"><span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\underleftrightarrow{AB}</code></td>
</tr>
<tr>
<td style="text-align:left">\underrightarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><munder accentunder="true"><mrow><mi>A</mi><mi>B</mi></mrow><mo stretchy="true">→</mo></munder></mrow><annotation encoding="application/x-tex">\underrightarrow{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2053em;vertical-align:-0.522em;"></span><span class="mord accentunder"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6833em;"><span class="svg-align" style="top:-2.478em;"><span class="pstrut" style="height:3em;"></span><span class="hide-tail" style="height:0.522em;min-width:0.888em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMaxYMin slice'><path d='M0 241v40h399891c-47.3 35.3-84 78-110 128
-16.7 32-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20
 11 8 0 13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7
 39-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85
-40.5-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5
-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67
 151.7 139 205zm0 0v40h399900v-40z'/></svg></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.522em;"><span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\underrightarrow{AB}</code></td>
</tr>
<tr>
<td style="text-align:left">\underline</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><munder accentunder="true"><mtext>a long argument</mtext><mo stretchy="true">‾</mo></munder></mrow><annotation encoding="application/x-tex">\underline{\text{a long argument}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0889em;vertical-align:-0.3944em;"></span><span class="mord underline"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6944em;"><span style="top:-2.6456em;"><span class="pstrut" style="height:3em;"></span><span class="underline-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord text"><span class="mord">a long argument</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.3944em;"><span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\underline{\text{a long argument}}</code></td>
</tr>
<tr>
<td style="text-align:left">\underlinesegment</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><munder accentunder="true"><mrow><mi>A</mi><mi>B</mi></mrow><mo stretchy="true">undefined</mo></munder></mrow><annotation encoding="application/x-tex">\underlinesegment{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2053em;vertical-align:-0.522em;"></span><span class="mord accentunder"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6833em;"><span class="svg-align" style="top:-2.478em;"><span class="pstrut" style="height:3em;"></span><span class="stretchy" style="height:0.522em;min-width:0.888em;"><span class="halfarrow-left" style="height:0.522em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMinYMin slice'><path d='M40 281 V428 H0 V94 H40 V241 H400000 v40z
M40 281 V428 H0 V94 H40 V241 H400000 v40z'/></svg></span><span class="halfarrow-right" style="height:0.522em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMaxYMin slice'><path d='M399960 241 V94 h40 V428 h-40 V281 H0 v-40z
M399960 241 V94 h40 V428 h-40 V281 H0 v-40z'/></svg></span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.522em;"><span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\underlinesegment{AB}</code></td>
</tr>
<tr>
<td style="text-align:left">\underparen</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left">See <code>\undergroup</code></td>
</tr>
<tr>
<td style="text-align:left">\underrightarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><munder accentunder="true"><mrow><mi>A</mi><mi>B</mi></mrow><mo stretchy="true">→</mo></munder></mrow><annotation encoding="application/x-tex">\underrightarrow{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2053em;vertical-align:-0.522em;"></span><span class="mord accentunder"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6833em;"><span class="svg-align" style="top:-2.478em;"><span class="pstrut" style="height:3em;"></span><span class="hide-tail" style="height:0.522em;min-width:0.888em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMaxYMin slice'><path d='M0 241v40h399891c-47.3 35.3-84 78-110 128
-16.7 32-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20
 11 8 0 13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7
 39-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85
-40.5-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5
-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67
 151.7 139 205zm0 0v40h399900v-40z'/></svg></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.522em;"><span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\underrightarrow{AB}</code></td>
</tr>
<tr>
<td style="text-align:left">\underset</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><munder><mo><mo>=</mo></mo><mo stretchy="false" lspace="0em" rspace="0em">!</mo></munder></mo></mrow><annotation encoding="application/x-tex">\underset{!}{=}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.119em;vertical-align:-0.7521em;"></span><span class="mrel"><span class="mop op-limits"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3669em;"><span style="top:-2.3479em;margin-left:0em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mclose mtight">!</span></span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span><span class="mop">=</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.7521em;"><span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\underset{!}{=}</code></td>
</tr>
<tr>
<td style="text-align:left">\unicode</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\unlhd</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊴</mo></mrow><annotation encoding="application/x-tex">\unlhd</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7733em;vertical-align:-0.1367em;"></span><span class="mord amsrm">⊴</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\unrhd</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊵</mo></mrow><annotation encoding="application/x-tex">\unrhd</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7733em;vertical-align:-0.1367em;"></span><span class="mord amsrm">⊵</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\up</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Uparrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇑</mo></mrow><annotation encoding="application/x-tex">\Uparrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel">⇑</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\uparrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↑</mo></mrow><annotation encoding="application/x-tex">\uparrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel">↑</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Updownarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇕</mo></mrow><annotation encoding="application/x-tex">\Updownarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mrel">⇕</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\updownarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↕</mo></mrow><annotation encoding="application/x-tex">\updownarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mrel">↕</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\upharpoonleft</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↿</mo></mrow><annotation encoding="application/x-tex">\upharpoonleft</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8867em;vertical-align:-0.1944em;"></span><span class="mrel amsrm">↿</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\upharpoonright</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↾</mo></mrow><annotation encoding="application/x-tex">\upharpoonright</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8867em;vertical-align:-0.1944em;"></span><span class="mrel amsrm">↾</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\uplus</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊎</mo></mrow><annotation encoding="application/x-tex">\uplus</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5556em;"></span><span class="mord">⊎</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\uproot</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\upshape</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Upsilon</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Υ</mi></mrow><annotation encoding="application/x-tex">\Upsilon</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">Υ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\upsilon</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>υ</mi></mrow><annotation encoding="application/x-tex">\upsilon</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">υ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\upuparrows</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇈</mo></mrow><annotation encoding="application/x-tex">\upuparrows</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8867em;vertical-align:-0.1944em;"></span><span class="mrel amsrm">⇈</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\urcorner</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mi mathvariant="normal">⌝</mi></mo></mrow><annotation encoding="application/x-tex">\urcorner</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mclose amsrm">┐</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\url</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathsize="0.8em"><mstyle mathcolor="#cc0000"><mtext>\url</mtext></mstyle></mstyle></mrow><annotation encoding="application/x-tex">\footnotesize\url{https://katex.org/}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8em;vertical-align:-0.2em;"></span><span class="mord text sizing reset-size6 size4" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\url</span></span></span></span></span></td>
<td style="text-align:left"><code>\url{https://katex.org/}</code> Requires <code>trust</code></td>
</tr>
<tr>
<td style="text-align:left">\utilde</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><munder accentunder="true"><mrow><mi>A</mi><mi>B</mi></mrow><mo stretchy="true">~</mo></munder></mrow><annotation encoding="application/x-tex">\utilde{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0893em;vertical-align:-0.406em;"></span><span class="mord accentunder"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6833em;"><span class="svg-align" style="top:-2.594em;"><span class="pstrut" style="height:3em;"></span><span style="height:0.286em;"><svg xmlns="http://www.w3.org/2000/svg" width='100%' height='0.286em' viewBox='0 0 1033 286' preserveAspectRatio='none'><path d='M344 55.266c-142 0-300.638 81.316-311.5 86.418
-8.01 3.762-22.5 10.91-23.5 5.562L1 120c-1-2-1-3-1-4 0-5 3-9 8-10l18.4-9C160.9
 31.9 283 0 358 0c148 0 188 122 331 122s314-97 326-97c4 0 8 2 10 7l7 21.114
c1 2.14 1 3.21 1 4.28 0 5.347-3 9.626-7 10.696l-22.3 12.622C852.6 158.372 751
 181.476 676 181.476c-149 0-189-126.21-332-126.21z'/></svg></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.406em;"><span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\utilde{AB}</code></td>
</tr>
</tbody>
</table>
<h2 id="v" tabindex="-1">V <a class="header-anchor" href="#v" aria-label="Permalink to &quot;V&quot;">&ZeroWidthSpace;</a></h2>
<table>
<thead>
<tr>
<th style="text-align:left">Symbol/Function</th>
<th style="text-align:left">Rendered</th>
<th style="text-align:left">Source or Comment</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">\v</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mtext>a</mtext><mo>ˇ</mo></mover></mrow><annotation encoding="application/x-tex">\text{\v{a}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6285em;"></span><span class="mord text"><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6285em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">a</span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.25em;"><span class="mord">ˇ</span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\v{a}}</code></td>
</tr>
<tr>
<td style="text-align:left">\varcoppa</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\varDelta</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>Δ</mi></mrow><annotation encoding="application/x-tex">\varDelta</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathit">Δ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\varepsilon</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ε</mi></mrow><annotation encoding="application/x-tex">\varepsilon</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">ε</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\varGamma</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>Γ</mi></mrow><annotation encoding="application/x-tex">\varGamma</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathit">Γ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\varinjlim</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\varkappa</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">ϰ</mi></mrow><annotation encoding="application/x-tex">\varkappa</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord amsrm" style="margin-right:0.04028em;">ϰ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\varLambda</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>Λ</mi></mrow><annotation encoding="application/x-tex">\varLambda</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathit">Λ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\varliminf</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\varlimsup</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\varnothing</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∅</mi></mrow><annotation encoding="application/x-tex">\varnothing</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6633em;vertical-align:-0.0817em;"></span><span class="mord amsrm">∅</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\varOmega</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>Ω</mi></mrow><annotation encoding="application/x-tex">\varOmega</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathit">Ω</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\varPhi</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>Φ</mi></mrow><annotation encoding="application/x-tex">\varPhi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathit">Φ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\varphi</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>φ</mi></mrow><annotation encoding="application/x-tex">\varphi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">φ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\varPi</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>Π</mi></mrow><annotation encoding="application/x-tex">\varPi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathit">Π</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\varpi</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ϖ</mi></mrow><annotation encoding="application/x-tex">\varpi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal" style="margin-right:0.02778em;">ϖ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\varprojlim</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\varpropto</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∝</mo></mrow><annotation encoding="application/x-tex">\varpropto</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mrel amsrm">∝</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\varPsi</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>Ψ</mi></mrow><annotation encoding="application/x-tex">\varPsi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathit">Ψ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\varPsi</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>Ψ</mi></mrow><annotation encoding="application/x-tex">\varPsi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathit">Ψ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\varrho</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ϱ</mi></mrow><annotation encoding="application/x-tex">\varrho</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">ϱ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\varSigma</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>Σ</mi></mrow><annotation encoding="application/x-tex">\varSigma</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathit">Σ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\varsigma</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ς</mi></mrow><annotation encoding="application/x-tex">\varsigma</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5278em;vertical-align:-0.0972em;"></span><span class="mord mathnormal" style="margin-right:0.07986em;">ς</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\varstigma</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\varsubsetneq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊊</mo></mrow><annotation encoding="application/x-tex">\varsubsetneq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mrel amsrm"></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\varsubsetneqq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⫋</mo></mrow><annotation encoding="application/x-tex">\varsubsetneqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0087em;vertical-align:-0.2514em;"></span><span class="mrel amsrm"></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\varsupsetneq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊋</mo></mrow><annotation encoding="application/x-tex">\varsupsetneq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mrel amsrm"></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\varsupsetneqq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⫌</mo></mrow><annotation encoding="application/x-tex">\varsupsetneqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0087em;vertical-align:-0.2514em;"></span><span class="mrel amsrm"></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\varTheta</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>Θ</mi></mrow><annotation encoding="application/x-tex">\varTheta</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathit">Θ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\vartheta</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ϑ</mi></mrow><annotation encoding="application/x-tex">\vartheta</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">ϑ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\vartriangle</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>△</mo></mrow><annotation encoding="application/x-tex">\vartriangle</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5499em;"></span><span class="mrel amsrm">△</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\vartriangleleft</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊲</mo></mrow><annotation encoding="application/x-tex">\vartriangleleft</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.585em;vertical-align:-0.0352em;"></span><span class="mrel amsrm">⊲</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\vartriangleright</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊳</mo></mrow><annotation encoding="application/x-tex">\vartriangleright</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.585em;vertical-align:-0.0352em;"></span><span class="mrel amsrm">⊳</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\varUpsilon</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>Υ</mi></mrow><annotation encoding="application/x-tex">\varUpsilon</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathit">Υ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\varXi</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>Ξ</mi></mrow><annotation encoding="application/x-tex">\varXi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathit">Ξ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\vcentcolon</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mo><mo>:</mo></mo></mo></mrow><annotation encoding="application/x-tex">\vcentcolon</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\vcenter</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Vdash</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊩</mo></mrow><annotation encoding="application/x-tex">\Vdash</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mrel amsrm">⊩</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\vDash</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊨</mo></mrow><annotation encoding="application/x-tex">\vDash</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mrel amsrm">⊨</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\vdash</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊢</mo></mrow><annotation encoding="application/x-tex">\vdash</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mrel">⊢</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\vdots</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi><mi mathvariant="normal">⋮</mi><mpadded height="0em" voffset="0em"><mspace mathbackground="black" width="0em" height="1.5em"></mspace></mpadded></mi></mrow><annotation encoding="application/x-tex">\vdots</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.53em;vertical-align:-0.03em;"></span><span class="mord"><span class="mord">⋮</span><span class="mord rule" style="border-right-width:0em;border-top-width:1.5em;bottom:0em;"></span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\vec</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mi>F</mi><mo>⃗</mo></mover></mrow><annotation encoding="application/x-tex">\vec{F}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9663em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.9663em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord mathnormal" style="margin-right:0.13889em;">F</span></span><span style="top:-3.2523em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.1522em;"><span class="overlay" style="height:0.714em;width:0.471em;"><svg xmlns="http://www.w3.org/2000/svg" width='0.471em' height='0.714em' style='width:0.471em' viewBox='0 0 471 714' preserveAspectRatio='xMinYMin'><path d='M377 20c0-5.333 1.833-10 5.5-14S391 0 397 0c4.667 0 8.667 1.667 12 5
3.333 2.667 6.667 9 10 19 6.667 24.667 20.333 43.667 41 57 7.333 4.667 11
10.667 11 18 0 6-1 10-3 12s-6.667 5-14 9c-28.667 14.667-53.667 35.667-75 63
-1.333 1.333-3.167 3.5-5.5 6.5s-4 4.833-5 5.5c-1 .667-2.5 1.333-4.5 2s-4.333 1
-7 1c-4.667 0-9.167-1.833-13.5-5.5S337 184 337 178c0-12.667 15.667-32.333 47-59
H213l-171-1c-8.667-6-13-12.333-13-19 0-4.667 4.333-11.333 13-20h359
c-16-25.333-24-45-24-59z'/></svg></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\vec{F}</code></td>
</tr>
<tr>
<td style="text-align:left">\vee</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∨</mo></mrow><annotation encoding="application/x-tex">\vee</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5556em;"></span><span class="mord">∨</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\veebar</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊻</mo></mrow><annotation encoding="application/x-tex">\veebar</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8867em;vertical-align:-0.1944em;"></span><span class="mord amsrm">⊻</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\verb</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext mathvariant="monospace">\frac a b</mtext></mrow><annotation encoding="application/x-tex">\verb!\frac a b!</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7778em;vertical-align:-0.0833em;"></span><span class="mord text"><span class="mord texttt">\frac a b</span></span></span></span></span></td>
<td style="text-align:left"><code>\verb!\frac a b!</code></td>
</tr>
<tr>
<td style="text-align:left">\Vert</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∥</mi></mrow><annotation encoding="application/x-tex">\Vert</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">∥</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\vert</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∣</mi></mrow><annotation encoding="application/x-tex">\vert</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">∣</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\vfil</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\vfill</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\vline</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"><a href="https://github.com/KaTeX/KaTeX/issues/269" target="_blank" rel="noreferrer">Issue #269</a></td>
</tr>
<tr>
<td style="text-align:left" Vmatrix=""></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true">∥</mo><mtable rowspacing="0.16em" columnalign="center center" columnspacing="1em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>a</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>b</mi></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>c</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>d</mi></mstyle></mtd></mtr></mtable><mo fence="true">∥</mo></mrow><annotation encoding="application/x-tex">\begin{Vmatrix}a&amp;b\\c&amp;d\end{Vmatrix}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.4em;vertical-align:-0.95em;"></span><span class="minner"><span class="mopen"><span class="delimsizing mult"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.45em;"><span class="pstrut" style="height:4.4em;"></span><span style="width:0.556em;height:2.400em;"><svg xmlns="http://www.w3.org/2000/svg" width='0.556em' height='2.400em' viewBox='0 0 556 2400'><path d='M145 15 v585 v1200 v585 c2.667,10,9.667,15,21,15
c10,0,16.667,-5,20,-15 v-585 v-1200 v-585 c-2.667,-10,-9.667,-15,-21,-15
c-10,0,-16.667,5,-20,15z M188 15 H145 v585 v1200 v585 h43z
M367 15 v585 v1200 v585 c2.667,10,9.667,15,21,15
c10,0,16.667,-5,20,-15 v-585 v-1200 v-585 c-2.667,-10,-9.667,-15,-21,-15
c-10,0,-16.667,5,-20,15z M410 15 H367 v585 v1200 v585 h43z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span></span><span class="mord"><span class="mtable"><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:0.5em;"></span><span class="arraycolsep" style="width:0.5em;"></span><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">b</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">d</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span></span></span><span class="mclose"><span class="delimsizing mult"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.45em;"><span class="pstrut" style="height:4.4em;"></span><span style="width:0.556em;height:2.400em;"><svg xmlns="http://www.w3.org/2000/svg" width='0.556em' height='2.400em' viewBox='0 0 556 2400'><path d='M145 15 v585 v1200 v585 c2.667,10,9.667,15,21,15
c10,0,16.667,-5,20,-15 v-585 v-1200 v-585 c-2.667,-10,-9.667,-15,-21,-15
c-10,0,-16.667,5,-20,15z M188 15 H145 v585 v1200 v585 h43z
M367 15 v585 v1200 v585 c2.667,10,9.667,15,21,15
c10,0,16.667,-5,20,-15 v-585 v-1200 v-585 c-2.667,-10,-9.667,-15,-21,-15
c-10,0,-16.667,5,-20,15z M410 15 H367 v585 v1200 v585 h43z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\begin{Vmatrix}</code><br>   <code>a &amp; b \\</code><br>   <code>c &amp; d</code><br><code>\end{Vmatrix}</code></td>
</tr>
<tr>
<td style="text-align:left" vmatrix=""></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true">∣</mo><mtable rowspacing="0.16em" columnalign="center center" columnspacing="1em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>a</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>b</mi></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>c</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>d</mi></mstyle></mtd></mtr></mtable><mo fence="true">∣</mo></mrow><annotation encoding="application/x-tex">\begin{vmatrix}a&amp;b\\c&amp;d\end{vmatrix}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.4em;vertical-align:-0.95em;"></span><span class="minner"><span class="mopen"><span class="delimsizing mult"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.45em;"><span class="pstrut" style="height:4.4em;"></span><span style="width:0.333em;height:2.400em;"><svg xmlns="http://www.w3.org/2000/svg" width='0.333em' height='2.400em' viewBox='0 0 333 2400'><path d='M145 15 v585 v1200 v585 c2.667,10,9.667,15,21,15
c10,0,16.667,-5,20,-15 v-585 v-1200 v-585 c-2.667,-10,-9.667,-15,-21,-15
c-10,0,-16.667,5,-20,15z M188 15 H145 v585 v1200 v585 h43z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span></span><span class="mord"><span class="mtable"><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:0.5em;"></span><span class="arraycolsep" style="width:0.5em;"></span><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">b</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">d</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span></span></span><span class="mclose"><span class="delimsizing mult"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.45em;"><span class="pstrut" style="height:4.4em;"></span><span style="width:0.333em;height:2.400em;"><svg xmlns="http://www.w3.org/2000/svg" width='0.333em' height='2.400em' viewBox='0 0 333 2400'><path d='M145 15 v585 v1200 v585 c2.667,10,9.667,15,21,15
c10,0,16.667,-5,20,-15 v-585 v-1200 v-585 c-2.667,-10,-9.667,-15,-21,-15
c-10,0,-16.667,5,-20,15z M188 15 H145 v585 v1200 v585 h43z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\begin{vmatrix}</code><br>   <code>a &amp; b \\</code><br>   <code>c &amp; d</code><br><code>\end{vmatrix}</code></td>
</tr>
<tr>
<td style="text-align:left">\vphantom</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mrow><mpadded width="0px"><mphantom><mi>M</mi></mphantom></mpadded><mi>a</mi></mrow><mo stretchy="true">‾</mo></mover></mrow><annotation encoding="application/x-tex">\overline{\vphantom{M}a}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8833em;"></span><span class="mord overline"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8833em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord rlap"><span class="inner"><span class="mord" style="color:transparent;"><span class="mord mathnormal" style="margin-right:0.10903em;color:transparent;">M</span></span></span><span class="fix"></span></span><span class="mord mathnormal">a</span></span></span><span style="top:-3.8033em;"><span class="pstrut" style="height:3em;"></span><span class="overline-line" style="border-bottom-width:0.04em;"></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\overline{\vphantom{M}a}</code></td>
</tr>
<tr>
<td style="text-align:left">\Vvdash</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊪</mo></mrow><annotation encoding="application/x-tex">\Vvdash</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mrel amsrm">⊪</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
</tbody>
</table>
<h2 id="w" tabindex="-1">W <a class="header-anchor" href="#w" aria-label="Permalink to &quot;W&quot;">&ZeroWidthSpace;</a></h2>
<table>
<thead>
<tr>
<th style="text-align:left">Symbol/Function</th>
<th style="text-align:left">Rendered</th>
<th style="text-align:left">Source or Comment</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">\wedge</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∧</mo></mrow><annotation encoding="application/x-tex">\wedge</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5556em;"></span><span class="mord">∧</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\weierp</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">℘</mi></mrow><annotation encoding="application/x-tex">\weierp</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord">℘</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\widecheck</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mrow><mi>A</mi><mi>B</mi></mrow><mo stretchy="true">ˇ</mo></mover></mrow><annotation encoding="application/x-tex">\widecheck{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9833em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.9833em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span><span class="svg-align" style="top:-3.6833em;"><span class="pstrut" style="height:3em;"></span><span style="height:0.3em;"><svg xmlns="http://www.w3.org/2000/svg" width='100%' height='0.3em' viewBox='0 0 2364 300' preserveAspectRatio='none'><path d='M1181,220h2l1171,-176c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,
-11,-10h-1l-1168,153l-1167,-153h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z'/></svg></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\widecheck{AB}</code></td>
</tr>
<tr>
<td style="text-align:left">\widehat</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mrow><mi>A</mi><mi>B</mi></mrow><mo stretchy="true">^</mo></mover></mrow><annotation encoding="application/x-tex">\widehat{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9833em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.9833em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span><span class="svg-align" style="top:-3.6833em;"><span class="pstrut" style="height:3em;"></span><span style="height:0.3em;"><svg xmlns="http://www.w3.org/2000/svg" width='100%' height='0.3em' viewBox='0 0 2364 300' preserveAspectRatio='none'><path d='M1181 0h2l1171 176c6 0 10 5 10 11l-2 23c-1 6-5 10
-11 10h-1L1182 67 15 220h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z'/></svg></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\widehat{AB}</code></td>
</tr>
<tr>
<td style="text-align:left">\wideparen</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"><a href="https://github.com/KaTeX/KaTeX/issues/560" target="_blank" rel="noreferrer">Issue #560</a></td>
</tr>
<tr>
<td style="text-align:left">\widetilde</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mrow><mi>A</mi><mi>B</mi></mrow><mo stretchy="true">~</mo></mover></mrow><annotation encoding="application/x-tex">\widetilde{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9693em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.9693em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span><span class="svg-align" style="top:-3.6833em;"><span class="pstrut" style="height:3em;"></span><span style="height:0.286em;"><svg xmlns="http://www.w3.org/2000/svg" width='100%' height='0.286em' viewBox='0 0 1033 286' preserveAspectRatio='none'><path d='M344 55.266c-142 0-300.638 81.316-311.5 86.418
-8.01 3.762-22.5 10.91-23.5 5.562L1 120c-1-2-1-3-1-4 0-5 3-9 8-10l18.4-9C160.9
 31.9 283 0 358 0c148 0 188 122 331 122s314-97 326-97c4 0 8 2 10 7l7 21.114
c1 2.14 1 3.21 1 4.28 0 5.347-3 9.626-7 10.696l-22.3 12.622C852.6 158.372 751
 181.476 676 181.476c-149 0-189-126.21-332-126.21z'/></svg></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\widetilde{AB}</code></td>
</tr>
<tr>
<td style="text-align:left">\wp</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">℘</mi></mrow><annotation encoding="application/x-tex">\wp</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord">℘</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\wr</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≀</mo></mrow><annotation encoding="application/x-tex">\wr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord">≀</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
</tbody>
</table>
<h2 id="x" tabindex="-1">X <a class="header-anchor" href="#x" aria-label="Permalink to &quot;X&quot;">&ZeroWidthSpace;</a></h2>
<table>
<thead>
<tr>
<th style="text-align:left">Symbol/Function</th>
<th style="text-align:left">Rendered</th>
<th style="text-align:left">Source or Comment</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">\xcancel</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><menclose notation="updiagonalstrike downdiagonalstrike"><mrow><mi>A</mi><mi>B</mi><mi>C</mi></mrow></menclose></mrow><annotation encoding="application/x-tex">\xcancel{ABC}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord cancel-lap"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6833em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord cancel-pad"><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.07153em;">BC</span></span></span><span class="svg-align" style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span style="height:0.6833em;"><svg xmlns="http://www.w3.org/2000/svg" width='100%' height='0.6833em'><line x1='0' y1='0' x2='100%' y2='100%' stroke-width='0.046em'/><line x1='0' y1='100%' x2='100%' y2='0' stroke-width='0.046em'/></svg></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\xcancel{ABC}</code></td>
</tr>
<tr>
<td style="text-align:left">\xdef</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi></mrow><annotation encoding="application/x-tex">\def\foo{a}\xdef\bar{\foo}\def\foo{}\bar</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">a</span></span></span></span></td>
<td style="text-align:left"><code>\def\foo{a}\xdef\bar{\foo}\def\foo{}\bar</code></td>
</tr>
<tr>
<td style="text-align:left">\Xi</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Ξ</mi></mrow><annotation encoding="application/x-tex">\Xi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">Ξ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\xi</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ξ</mi></mrow><annotation encoding="application/x-tex">\xi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.04601em;">ξ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\xhookleftarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mo stretchy="true" minsize="3.0em">↩</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></mpadded></mover></mrow><annotation encoding="application/x-tex">\xhookleftarrow{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1191em;vertical-align:-0.011em;"></span><span class="mrel x-arrow"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1081em;"><span style="top:-3.322em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">ab</span><span class="mord mathnormal mtight">c</span></span></span></span><span class="svg-align" style="top:-2.689em;"><span class="pstrut" style="height:2.7em;"></span><span class="stretchy" style="height:0.522em;min-width:1.08em;"><span class="halfarrow-left" style="height:0.522em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMinYMin slice'><path d='M400000 241H110l3-3c68.7-52.7 113.7-120
 135-202 4-14.7 6-23 6-25 0-7.3-7-11-21-11-8 0-13.2.8-15.5 2.5-2.3 1.7-4.2 5.8
-5.5 12.5-1.3 4.7-2.7 10.3-4 17-12 48.7-34.8 92-68.5 130S65.3 228.3 18 247
c-10 4-16 7.7-18 11 0 8.7 6 14.3 18 17 47.3 18.7 87.8 47 121.5 85S196 441.3 208
 490c.7 2 1.3 5 2 9s1.2 6.7 1.5 8c.3 1.3 1 3.3 2 6s2.2 4.5 3.5 5.5c1.3 1 3.3
 1.8 6 2.5s6 1 10 1c14 0 21-3.7 21-11 0-2-2-10.3-6-25-20-79.3-65-146.7-135-202
 l-3-3h399890zM100 241v40h399900v-40z'/></svg></span><span class="halfarrow-right" style="height:0.522em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMaxYMin slice'><path d='M399859 241c-764 0 0 0 0 0 40-3.3 68.7-15.7 86-37 10-12 15-25.3
 15-40 0-22.7-9.8-40.7-29.5-54-19.7-13.3-43.5-21-71.5-23-17.3-1.3-26-8-26-20 0
-13.3 8.7-20 26-20 38 0 71 11.2 99 33.5 0 0 7 5.6 21 16.7 14 11.2 21 33.5 21
 66.8s-14 61.2-42 83.5c-28 22.3-61 33.5-99 33.5L0 241z M0 281v-40h399859v40z'/></svg></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.011em;"><span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\xhookleftarrow{abc}</code></td>
</tr>
<tr>
<td style="text-align:left">\xhookrightarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mo stretchy="true" minsize="3.0em">↪</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></mpadded></mover></mrow><annotation encoding="application/x-tex">\xhookrightarrow{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1191em;vertical-align:-0.011em;"></span><span class="mrel x-arrow"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1081em;"><span style="top:-3.322em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">ab</span><span class="mord mathnormal mtight">c</span></span></span></span><span class="svg-align" style="top:-2.689em;"><span class="pstrut" style="height:2.7em;"></span><span class="stretchy" style="height:0.522em;min-width:1.08em;"><span class="halfarrow-left" style="height:0.522em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMinYMin slice'><path d='M400000 281 H103s-33-11.2-61-33.5S0 197.3 0 164s14.2-61.2 42.5
-83.5C70.8 58.2 104 47 142 47 c16.7 0 25 6.7 25 20 0 12-8.7 18.7-26 20-40 3.3
-68.7 15.7-86 37-10 12-15 25.3-15 40 0 22.7 9.8 40.7 29.5 54 19.7 13.3 43.5 21
 71.5 23h399859zM103 281v-40h399897v40z'/></svg></span><span class="halfarrow-right" style="height:0.522em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMaxYMin slice'><path d='M0 241v40h399891c-47.3 35.3-84 78-110 128
-16.7 32-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20
 11 8 0 13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7
 39-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85
-40.5-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5
-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67
 151.7 139 205zm0 0v40h399900v-40z'/></svg></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.011em;"><span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\xhookrightarrow{abc}</code></td>
</tr>
<tr>
<td style="text-align:left">\xLeftarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mo stretchy="true" minsize="3.0em">⇐</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></mpadded></mover></mrow><annotation encoding="application/x-tex">\xLeftarrow{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1571em;vertical-align:-0.03em;"></span><span class="mrel x-arrow"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1271em;"><span style="top:-3.341em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">ab</span><span class="mord mathnormal mtight">c</span></span></span></span><span class="svg-align" style="top:-2.67em;"><span class="pstrut" style="height:2.7em;"></span><span class="hide-tail" style="height:0.56em;min-width:1.526em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.56em' viewBox='0 0 400000 560' preserveAspectRatio='xMinYMin slice'><path d='M262 157
l10-10c34-36 62.7-77 86-123 3.3-8 5-13.3 5-16 0-5.3-6.7-8-20-8-7.3
 0-12.2.5-14.5 1.5-2.3 1-4.8 4.5-7.5 10.5-49.3 97.3-121.7 169.3-217 216-28
 14-57.3 25-88 33-6.7 2-11 3.8-13 5.5-2 1.7-3 4.2-3 7.5s1 5.8 3 7.5
c2 1.7 6.3 3.5 13 5.5 68 17.3 128.2 47.8 180.5 91.5 52.3 43.7 93.8 96.2 124.5
 157.5 9.3 8 15.3 12.3 18 13h6c12-.7 18-4 18-10 0-2-1.7-7-5-15-23.3-46-52-87
-86-123l-10-10h399738v-40H218c328 0 0 0 0 0l-10-8c-26.7-20-65.7-43-117-69 2.7
-2 6-3.7 10-5 36.7-16 72.3-37.3 107-64l10-8h399782v-40z
m8 0v40h399730v-40zm0 194v40h399730v-40z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.03em;"><span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\xLeftarrow{abc}</code></td>
</tr>
<tr>
<td style="text-align:left">\xleftarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mo stretchy="true" minsize="3.0em">←</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></mpadded></mover></mrow><annotation encoding="application/x-tex">\xleftarrow{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1191em;vertical-align:-0.011em;"></span><span class="mrel x-arrow"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1081em;"><span style="top:-3.322em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">ab</span><span class="mord mathnormal mtight">c</span></span></span></span><span class="svg-align" style="top:-2.689em;"><span class="pstrut" style="height:2.7em;"></span><span class="hide-tail" style="height:0.522em;min-width:1.469em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMinYMin slice'><path d='M400000 241H110l3-3c68.7-52.7 113.7-120
 135-202 4-14.7 6-23 6-25 0-7.3-7-11-21-11-8 0-13.2.8-15.5 2.5-2.3 1.7-4.2 5.8
-5.5 12.5-1.3 4.7-2.7 10.3-4 17-12 48.7-34.8 92-68.5 130S65.3 228.3 18 247
c-10 4-16 7.7-18 11 0 8.7 6 14.3 18 17 47.3 18.7 87.8 47 121.5 85S196 441.3 208
 490c.7 2 1.3 5 2 9s1.2 6.7 1.5 8c.3 1.3 1 3.3 2 6s2.2 4.5 3.5 5.5c1.3 1 3.3
 1.8 6 2.5s6 1 10 1c14 0 21-3.7 21-11 0-2-2-10.3-6-25-20-79.3-65-146.7-135-202
 l-3-3h399890zM100 241v40h399900v-40z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.011em;"><span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\xleftarrow{abc}</code></td>
</tr>
<tr>
<td style="text-align:left">\xleftharpoondown</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mo stretchy="true" minsize="3.0em">↽</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></mpadded></mover></mrow><annotation encoding="application/x-tex">\xleftharpoondown{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1191em;vertical-align:-0.011em;"></span><span class="mrel x-arrow"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1081em;"><span style="top:-3.322em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">ab</span><span class="mord mathnormal mtight">c</span></span></span></span><span class="svg-align" style="top:-2.689em;"><span class="pstrut" style="height:2.7em;"></span><span class="hide-tail" style="height:0.522em;min-width:0.888em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMinYMin slice'><path d='M7 241c-4 4-6.333 8.667-7 14 0 5.333.667 9 2 11s5.333
 5.333 12 10c90.667 54 156 130 196 228 3.333 10.667 6.333 16.333 9 17 2 .667 5
 1 9 1h5c10.667 0 16.667-2 18-6 2-2.667 1-9.667-3-21-32-87.333-82.667-157.667
-152-211l-3-3h399907v-40zM93 281 H400000 v-40L7 241z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.011em;"><span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\xleftharpoondown{abc}</code></td>
</tr>
<tr>
<td style="text-align:left">\xleftharpoonup</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mo stretchy="true" minsize="3.0em">↼</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></mpadded></mover></mrow><annotation encoding="application/x-tex">\xleftharpoonup{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1191em;vertical-align:-0.011em;"></span><span class="mrel x-arrow"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1081em;"><span style="top:-3.322em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">ab</span><span class="mord mathnormal mtight">c</span></span></span></span><span class="svg-align" style="top:-2.689em;"><span class="pstrut" style="height:2.7em;"></span><span class="hide-tail" style="height:0.522em;min-width:0.888em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMinYMin slice'><path d='M0 267c.7 5.3 3 10 7 14h399993v-40H93c3.3
-3.3 10.2-9.5 20.5-18.5s17.8-15.8 22.5-20.5c50.7-52 88-110.3 112-175 4-11.3 5
-18.3 3-21-1.3-4-7.3-6-18-6-8 0-13 .7-15 2s-4.7 6.7-8 16c-42 98.7-107.3 174.7
-196 228-6.7 4.7-10.7 8-12 10-1.3 2-2 5.7-2 11zm100-26v40h399900v-40z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.011em;"><span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\xleftharpoonup{abc}</code></td>
</tr>
<tr>
<td style="text-align:left">\xLeftrightarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mo stretchy="true" minsize="3.0em">⇔</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></mpadded></mover></mrow><annotation encoding="application/x-tex">\xLeftrightarrow{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1571em;vertical-align:-0.03em;"></span><span class="mrel x-arrow"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1271em;"><span style="top:-3.341em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">ab</span><span class="mord mathnormal mtight">c</span></span></span></span><span class="svg-align" style="top:-2.67em;"><span class="pstrut" style="height:2.7em;"></span><span class="stretchy" style="height:0.56em;min-width:1.75em;"><span class="halfarrow-left" style="height:0.56em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.56em' viewBox='0 0 400000 560' preserveAspectRatio='xMinYMin slice'><path d='M262 157
l10-10c34-36 62.7-77 86-123 3.3-8 5-13.3 5-16 0-5.3-6.7-8-20-8-7.3
 0-12.2.5-14.5 1.5-2.3 1-4.8 4.5-7.5 10.5-49.3 97.3-121.7 169.3-217 216-28
 14-57.3 25-88 33-6.7 2-11 3.8-13 5.5-2 1.7-3 4.2-3 7.5s1 5.8 3 7.5
c2 1.7 6.3 3.5 13 5.5 68 17.3 128.2 47.8 180.5 91.5 52.3 43.7 93.8 96.2 124.5
 157.5 9.3 8 15.3 12.3 18 13h6c12-.7 18-4 18-10 0-2-1.7-7-5-15-23.3-46-52-87
-86-123l-10-10h399738v-40H218c328 0 0 0 0 0l-10-8c-26.7-20-65.7-43-117-69 2.7
-2 6-3.7 10-5 36.7-16 72.3-37.3 107-64l10-8h399782v-40z
m8 0v40h399730v-40zm0 194v40h399730v-40z'/></svg></span><span class="halfarrow-right" style="height:0.56em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.56em' viewBox='0 0 400000 560' preserveAspectRatio='xMaxYMin slice'><path d='M399738 392l
-10 10c-34 36-62.7 77-86 123-3.3 8-5 13.3-5 16 0 5.3 6.7 8 20 8 7.3 0 12.2-.5
 14.5-1.5 2.3-1 4.8-4.5 7.5-10.5 49.3-97.3 121.7-169.3 217-216 28-14 57.3-25 88
-33 6.7-2 11-3.8 13-5.5 2-1.7 3-4.2 3-7.5s-1-5.8-3-7.5c-2-1.7-6.3-3.5-13-5.5-68
-17.3-128.2-47.8-180.5-91.5-52.3-43.7-93.8-96.2-124.5-157.5-9.3-8-15.3-12.3-18
-13h-6c-12 .7-18 4-18 10 0 2 1.7 7 5 15 23.3 46 52 87 86 123l10 10H0v40h399782
c-328 0 0 0 0 0l10 8c26.7 20 65.7 43 117 69-2.7 2-6 3.7-10 5-36.7 16-72.3 37.3
-107 64l-10 8H0v40zM0 157v40h399730v-40zm0 194v40h399730v-40z'/></svg></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.03em;"><span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\xLeftrightarrow{abc}</code></td>
</tr>
<tr>
<td style="text-align:left">\xleftrightarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mo stretchy="true" minsize="3.0em">↔</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></mpadded></mover></mrow><annotation encoding="application/x-tex">\xleftrightarrow{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1191em;vertical-align:-0.011em;"></span><span class="mrel x-arrow"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1081em;"><span style="top:-3.322em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">ab</span><span class="mord mathnormal mtight">c</span></span></span></span><span class="svg-align" style="top:-2.689em;"><span class="pstrut" style="height:2.7em;"></span><span class="stretchy" style="height:0.522em;min-width:1.75em;"><span class="halfarrow-left" style="height:0.522em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMinYMin slice'><path d='M400000 241H110l3-3c68.7-52.7 113.7-120
 135-202 4-14.7 6-23 6-25 0-7.3-7-11-21-11-8 0-13.2.8-15.5 2.5-2.3 1.7-4.2 5.8
-5.5 12.5-1.3 4.7-2.7 10.3-4 17-12 48.7-34.8 92-68.5 130S65.3 228.3 18 247
c-10 4-16 7.7-18 11 0 8.7 6 14.3 18 17 47.3 18.7 87.8 47 121.5 85S196 441.3 208
 490c.7 2 1.3 5 2 9s1.2 6.7 1.5 8c.3 1.3 1 3.3 2 6s2.2 4.5 3.5 5.5c1.3 1 3.3
 1.8 6 2.5s6 1 10 1c14 0 21-3.7 21-11 0-2-2-10.3-6-25-20-79.3-65-146.7-135-202
 l-3-3h399890zM100 241v40h399900v-40z'/></svg></span><span class="halfarrow-right" style="height:0.522em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMaxYMin slice'><path d='M0 241v40h399891c-47.3 35.3-84 78-110 128
-16.7 32-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20
 11 8 0 13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7
 39-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85
-40.5-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5
-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67
 151.7 139 205zm0 0v40h399900v-40z'/></svg></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.011em;"><span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\xleftrightarrow{abc}</code></td>
</tr>
<tr>
<td style="text-align:left">\xleftrightharpoons</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mo stretchy="true" minsize="3.0em">⇋</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></mpadded></mover></mrow><annotation encoding="application/x-tex">\xleftrightharpoons{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.3131em;vertical-align:-0.108em;"></span><span class="mrel x-arrow"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.2051em;"><span style="top:-3.435em;"><span class="pstrut" style="height:2.716em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">ab</span><span class="mord mathnormal mtight">c</span></span></span></span><span class="svg-align" style="top:-2.608em;"><span class="pstrut" style="height:2.716em;"></span><span class="stretchy" style="height:0.716em;min-width:1.75em;"><span class="halfarrow-left" style="height:0.716em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.716em' viewBox='0 0 400000 716' preserveAspectRatio='xMinYMin slice'><path d='M0 267c.7 5.3 3 10 7 14h399993v-40H93c3.3-3.3 10.2-9.5
 20.5-18.5s17.8-15.8 22.5-20.5c50.7-52 88-110.3 112-175 4-11.3 5-18.3 3-21-1.3
-4-7.3-6-18-6-8 0-13 .7-15 2s-4.7 6.7-8 16c-42 98.7-107.3 174.7-196 228-6.7 4.7
-10.7 8-12 10-1.3 2-2 5.7-2 11zm100-26v40h399900v-40zM0 435v40h400000v-40z
m0 0v40h400000v-40z'/></svg></span><span class="halfarrow-right" style="height:0.716em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.716em' viewBox='0 0 400000 716' preserveAspectRatio='xMaxYMin slice'><path d='M399747 705c0 7.3 6.7 11 20 11 8 0 13-.8
 15-2.5s4.7-6.8 8-15.5c40-94 99.3-166.3 178-217 13.3-8 20.3-12.3 21-13 5.3-3.3
 8.5-5.8 9.5-7.5 1-1.7 1.5-5.2 1.5-10.5s-2.3-10.3-7-15H0v40h399908c-34 25.3
-64.7 57-92 95-27.3 38-48.7 77.7-64 119-3.3 8.7-5 14-5 16zM0 435v40h399900v-40z
m0-194v40h400000v-40zm0 0v40h400000v-40z'/></svg></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.108em;"><span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\xleftrightharpoons{abc}</code></td>
</tr>
<tr>
<td style="text-align:left">\xlongequal</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mo stretchy="true" minsize="3.0em">=</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></mpadded></mover></mrow><annotation encoding="application/x-tex">\xlongequal{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0141em;"></span><span class="mrel x-arrow"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:1.0141em;"><span style="top:-3.228em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">ab</span><span class="mord mathnormal mtight">c</span></span></span></span><span class="svg-align" style="top:-2.783em;"><span class="pstrut" style="height:2.7em;"></span><span class="hide-tail" style="height:0.334em;min-width:0.888em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.334em' viewBox='0 0 400000 334' preserveAspectRatio='xMinYMin slice'><path d='M0 50 h400000 v40H0z m0 194h40000v40H0z
M0 50 h400000 v40H0z m0 194h40000v40H0z'/></svg></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\xlongequal{abc}</code></td>
</tr>
<tr>
<td style="text-align:left">\xmapsto</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mo stretchy="true" minsize="3.0em">↦</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></mpadded></mover></mrow><annotation encoding="application/x-tex">\xmapsto{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1191em;vertical-align:-0.011em;"></span><span class="mrel x-arrow"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1081em;"><span style="top:-3.322em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">ab</span><span class="mord mathnormal mtight">c</span></span></span></span><span class="svg-align" style="top:-2.689em;"><span class="pstrut" style="height:2.7em;"></span><span class="stretchy" style="height:0.522em;min-width:1.5em;"><span class="halfarrow-left" style="height:0.522em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMinYMin slice'><path d='M40 281 V448H0V74H40V241H400000v40z
M40 281 V448H0V74H40V241H400000v40z'/></svg></span><span class="halfarrow-right" style="height:0.522em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMaxYMin slice'><path d='M0 241v40h399891c-47.3 35.3-84 78-110 128
-16.7 32-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20
 11 8 0 13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7
 39-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85
-40.5-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5
-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67
 151.7 139 205zm0 0v40h399900v-40z'/></svg></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.011em;"><span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\xmapsto{abc}</code></td>
</tr>
<tr>
<td style="text-align:left">\xRightarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mo stretchy="true" minsize="3.0em">⇒</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></mpadded></mover></mrow><annotation encoding="application/x-tex">\xRightarrow{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1571em;vertical-align:-0.03em;"></span><span class="mrel x-arrow"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1271em;"><span style="top:-3.341em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">ab</span><span class="mord mathnormal mtight">c</span></span></span></span><span class="svg-align" style="top:-2.67em;"><span class="pstrut" style="height:2.7em;"></span><span class="hide-tail" style="height:0.56em;min-width:1.526em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.56em' viewBox='0 0 400000 560' preserveAspectRatio='xMaxYMin slice'><path d='M399738 392l
-10 10c-34 36-62.7 77-86 123-3.3 8-5 13.3-5 16 0 5.3 6.7 8 20 8 7.3 0 12.2-.5
 14.5-1.5 2.3-1 4.8-4.5 7.5-10.5 49.3-97.3 121.7-169.3 217-216 28-14 57.3-25 88
-33 6.7-2 11-3.8 13-5.5 2-1.7 3-4.2 3-7.5s-1-5.8-3-7.5c-2-1.7-6.3-3.5-13-5.5-68
-17.3-128.2-47.8-180.5-91.5-52.3-43.7-93.8-96.2-124.5-157.5-9.3-8-15.3-12.3-18
-13h-6c-12 .7-18 4-18 10 0 2 1.7 7 5 15 23.3 46 52 87 86 123l10 10H0v40h399782
c-328 0 0 0 0 0l10 8c26.7 20 65.7 43 117 69-2.7 2-6 3.7-10 5-36.7 16-72.3 37.3
-107 64l-10 8H0v40zM0 157v40h399730v-40zm0 194v40h399730v-40z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.03em;"><span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\xRightarrow{abc}</code></td>
</tr>
<tr>
<td style="text-align:left">\xrightarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mo stretchy="true" minsize="3.0em">→</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></mpadded></mover></mrow><annotation encoding="application/x-tex">\xrightarrow{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1191em;vertical-align:-0.011em;"></span><span class="mrel x-arrow"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1081em;"><span style="top:-3.322em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">ab</span><span class="mord mathnormal mtight">c</span></span></span></span><span class="svg-align" style="top:-2.689em;"><span class="pstrut" style="height:2.7em;"></span><span class="hide-tail" style="height:0.522em;min-width:1.469em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMaxYMin slice'><path d='M0 241v40h399891c-47.3 35.3-84 78-110 128
-16.7 32-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20
 11 8 0 13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7
 39-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85
-40.5-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5
-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67
 151.7 139 205zm0 0v40h399900v-40z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.011em;"><span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\xrightarrow{abc}</code></td>
</tr>
<tr>
<td style="text-align:left">\xrightharpoondown</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mo stretchy="true" minsize="3.0em">⇁</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></mpadded></mover></mrow><annotation encoding="application/x-tex">\xrightharpoondown{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1191em;vertical-align:-0.011em;"></span><span class="mrel x-arrow"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1081em;"><span style="top:-3.322em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">ab</span><span class="mord mathnormal mtight">c</span></span></span></span><span class="svg-align" style="top:-2.689em;"><span class="pstrut" style="height:2.7em;"></span><span class="hide-tail" style="height:0.522em;min-width:0.888em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMaxYMin slice'><path d='M399747 511c0 7.3 6.7 11 20 11 8 0 13-.8 15-2.5s4.7-6.8
 8-15.5c40-94 99.3-166.3 178-217 13.3-8 20.3-12.3 21-13 5.3-3.3 8.5-5.8 9.5
-7.5 1-1.7 1.5-5.2 1.5-10.5s-2.3-10.3-7-15H0v40h399908c-34 25.3-64.7 57-92 95
-27.3 38-48.7 77.7-64 119-3.3 8.7-5 14-5 16zM0 241v40h399900v-40z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.011em;"><span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\xrightharpoondown{abc}</code></td>
</tr>
<tr>
<td style="text-align:left">\xrightharpoonup</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mo stretchy="true" minsize="3.0em">⇀</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></mpadded></mover></mrow><annotation encoding="application/x-tex">\xrightharpoonup{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1191em;vertical-align:-0.011em;"></span><span class="mrel x-arrow"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1081em;"><span style="top:-3.322em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">ab</span><span class="mord mathnormal mtight">c</span></span></span></span><span class="svg-align" style="top:-2.689em;"><span class="pstrut" style="height:2.7em;"></span><span class="hide-tail" style="height:0.522em;min-width:0.888em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMaxYMin slice'><path d='M0 241v40h399993c4.7-4.7 7-9.3 7-14 0-9.3
-3.7-15.3-11-18-92.7-56.7-159-133.7-199-231-3.3-9.3-6-14.7-8-16-2-1.3-7-2-15-2
-10.7 0-16.7 2-18 6-2 2.7-1 9.7 3 21 15.3 42 36.7 81.8 64 119.5 27.3 37.7 58
 69.2 92 94.5zm0 0v40h399900v-40z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.011em;"><span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\xrightharpoonup{abc}</code></td>
</tr>
<tr>
<td style="text-align:left">\xrightleftharpoons</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mo stretchy="true" minsize="3.0em">⇌</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></mpadded></mover></mrow><annotation encoding="application/x-tex">\xrightleftharpoons{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.3131em;vertical-align:-0.108em;"></span><span class="mrel x-arrow"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.2051em;"><span style="top:-3.435em;"><span class="pstrut" style="height:2.716em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">ab</span><span class="mord mathnormal mtight">c</span></span></span></span><span class="svg-align" style="top:-2.608em;"><span class="pstrut" style="height:2.716em;"></span><span class="stretchy" style="height:0.716em;min-width:1.75em;"><span class="halfarrow-left" style="height:0.716em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.716em' viewBox='0 0 400000 716' preserveAspectRatio='xMinYMin slice'><path d='M7 435c-4 4-6.3 8.7-7 14 0 5.3.7 9 2 11s5.3 5.3 12
 10c90.7 54 156 130 196 228 3.3 10.7 6.3 16.3 9 17 2 .7 5 1 9 1h5c10.7 0 16.7
-2 18-6 2-2.7 1-9.7-3-21-32-87.3-82.7-157.7-152-211l-3-3h399907v-40H7zm93 0
v40h399900v-40zM0 241v40h399900v-40zm0 0v40h399900v-40z'/></svg></span><span class="halfarrow-right" style="height:0.716em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.716em' viewBox='0 0 400000 716' preserveAspectRatio='xMaxYMin slice'><path d='M0 241v40h399993c4.7-4.7 7-9.3 7-14 0-9.3-3.7-15.3-11
-18-92.7-56.7-159-133.7-199-231-3.3-9.3-6-14.7-8-16-2-1.3-7-2-15-2-10.7 0-16.7
 2-18 6-2 2.7-1 9.7 3 21 15.3 42 36.7 81.8 64 119.5 27.3 37.7 58 69.2 92 94.5z
m0 0v40h399900v-40z m100 194v40h399900v-40zm0 0v40h399900v-40z'/></svg></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.108em;"><span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\xrightleftharpoons{abc}</code></td>
</tr>
<tr>
<td style="text-align:left">\xtofrom</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mo stretchy="true" minsize="3.0em">⇄</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></mpadded></mover></mrow><annotation encoding="application/x-tex">\xtofrom{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1251em;vertical-align:-0.014em;"></span><span class="mrel x-arrow"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1111em;"><span style="top:-3.325em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">ab</span><span class="mord mathnormal mtight">c</span></span></span></span><span class="svg-align" style="top:-2.686em;"><span class="pstrut" style="height:2.7em;"></span><span class="stretchy" style="height:0.528em;min-width:1.75em;"><span class="halfarrow-left" style="height:0.528em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.528em' viewBox='0 0 400000 528' preserveAspectRatio='xMinYMin slice'><path d='M0 147h400000v40H0zm0 214c68 40 115.7 95.7 143 167h22c15.3 0 23
-.3 23-1 0-1.3-5.3-13.7-16-37-18-35.3-41.3-69-70-101l-7-8h399905v-40H95l7-8
c28.7-32 52-65.7 70-101 10.7-23.3 16-35.7 16-37 0-.7-7.7-1-23-1h-22C115.7 265.3
 68 321 0 361zm0-174v-40h399900v40zm100 154v40h399900v-40z'/></svg></span><span class="halfarrow-right" style="height:0.528em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.528em' viewBox='0 0 400000 528' preserveAspectRatio='xMaxYMin slice'><path d='M400000 167c-70.7-42-118-97.7-142-167h-23c-15.3 0-23 .3-23
 1 0 1.3 5.3 13.7 16 37 18 35.3 41.3 69 70 101l7 8H0v40h399905l-7 8c-28.7 32
-52 65.7-70 101-10.7 23.3-16 35.7-16 37 0 .7 7.7 1 23 1h23c24-69.3 71.3-125 142
-167z M100 147v40h399900v-40zM0 341v40h399900v-40z'/></svg></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.014em;"><span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\xtofrom{abc}</code></td>
</tr>
<tr>
<td style="text-align:left">\xtwoheadleftarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mo stretchy="true" minsize="3.0em">↞</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></mpadded></mover></mrow><annotation encoding="application/x-tex">\xtwoheadleftarrow{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0141em;"></span><span class="mrel x-arrow"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:1.0141em;"><span style="top:-3.228em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">ab</span><span class="mord mathnormal mtight">c</span></span></span></span><span class="svg-align" style="top:-2.783em;"><span class="pstrut" style="height:2.7em;"></span><span class="hide-tail" style="height:0.334em;min-width:0.888em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.334em' viewBox='0 0 400000 334' preserveAspectRatio='xMinYMin slice'><path d='M0 167c68 40
 115.7 95.7 143 167h22c15.3 0 23-.3 23-1 0-1.3-5.3-13.7-16-37-18-35.3-41.3-69
-70-101l-7-8h125l9 7c50.7 39.3 85 86 103 140h46c0-4.7-6.3-18.7-19-42-18-35.3
-40-67.3-66-96l-9-9h399716v-40H284l9-9c26-28.7 48-60.7 66-96 12.7-23.333 19
-37.333 19-42h-46c-18 54-52.3 100.7-103 140l-9 7H95l7-8c28.7-32 52-65.7 70-101
 10.7-23.333 16-35.7 16-37 0-.7-7.7-1-23-1h-22C115.7 71.3 68 127 0 167z'/></svg></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\xtwoheadleftarrow{abc}</code></td>
</tr>
<tr>
<td style="text-align:left">\xtwoheadrightarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mo stretchy="true" minsize="3.0em">↠</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></mpadded></mover></mrow><annotation encoding="application/x-tex">\xtwoheadrightarrow{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0141em;"></span><span class="mrel x-arrow"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:1.0141em;"><span style="top:-3.228em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">ab</span><span class="mord mathnormal mtight">c</span></span></span></span><span class="svg-align" style="top:-2.783em;"><span class="pstrut" style="height:2.7em;"></span><span class="hide-tail" style="height:0.334em;min-width:0.888em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.334em' viewBox='0 0 400000 334' preserveAspectRatio='xMaxYMin slice'><path d='M400000 167
c-68-40-115.7-95.7-143-167h-22c-15.3 0-23 .3-23 1 0 1.3 5.3 13.7 16 37 18 35.3
 41.3 69 70 101l7 8h-125l-9-7c-50.7-39.3-85-86-103-140h-46c0 4.7 6.3 18.7 19 42
 18 35.3 40 67.3 66 96l9 9H0v40h399716l-9 9c-26 28.7-48 60.7-66 96-12.7 23.333
-19 37.333-19 42h46c18-54 52.3-100.7 103-140l9-7h125l-7 8c-28.7 32-52 65.7-70
 101-10.7 23.333-16 35.7-16 37 0 .7 7.7 1 23 1h22c27.3-71.3 75-127 143-167z'/></svg></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\xtwoheadrightarrow{abc}</code></td>
</tr>
</tbody>
</table>
<h2 id="yz" tabindex="-1">YZ <a class="header-anchor" href="#yz" aria-label="Permalink to &quot;YZ&quot;">&ZeroWidthSpace;</a></h2>
<table>
<thead>
<tr>
<th style="text-align:left">Symbol/Function</th>
<th style="text-align:left">Rendered</th>
<th style="text-align:left">Source or Comment</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">\yen</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">¥</mi></mrow><annotation encoding="application/x-tex">\yen</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.675em;"></span><span class="mord amsrm" style="margin-right:0.025em;">¥</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Z</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="double-struck">Z</mi></mrow><annotation encoding="application/x-tex">\Z</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord mathbb">Z</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Zeta</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Z</mi></mrow><annotation encoding="application/x-tex">\Zeta</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathrm">Z</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\zeta</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ζ</mi></mrow><annotation encoding="application/x-tex">\zeta</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.07378em;">ζ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
</tbody>
</table>
]]></description>
            <content:encoded><![CDATA[<h1 id="katex-support-table" tabindex="-1">KaTeX: Support table <a class="header-anchor" href="#katex-support-table" aria-label="Permalink to &quot;KaTeX: Support table&quot;">&ZeroWidthSpace;</a></h1>
<div class="tip custom-block"><p class="custom-block-title">note</p>
<p>This is an direct shameful copy of the documentation pulled from <a href="https://raw.githubusercontent.com/Khan/KaTeX/master/docs/supported.md" target="_blank" rel="noreferrer">KaTeX</a> documentation, <strong>I do not own any of the content below on behalf of this part of the documentation</strong>, the table might be outdated as versions migrates, please also refer to <a href="https://katex.org/docs/supported.html" target="_blank" rel="noreferrer">KaTeX's official documentation</a>.</p>
</div>
<h2 id="symbols" tabindex="-1">Symbols <a class="header-anchor" href="#symbols" aria-label="Permalink to &quot;Symbols&quot;">&ZeroWidthSpace;</a></h2>
<table>
<thead>
<tr>
<th style="text-align:left">Symbol/Function</th>
<th style="text-align:left">Rendered</th>
<th style="text-align:left">Source or Comment</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">!</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>n</mi><mo stretchy="false">!</mo></mrow><annotation encoding="application/x-tex">n!</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">n</span><span class="mclose">!</span></span></span></span></td>
<td style="text-align:left"><code>n!</code></td>
</tr>
<tr>
<td style="text-align:left">\!</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mtext> ⁣</mtext><mi>b</mi></mrow><annotation encoding="application/x-tex">a\!b</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">a</span><span class="mspace" style="margin-right:-0.1667em;"></span><span class="mord mathnormal">b</span></span></span></span></td>
<td style="text-align:left"><code>a\!b</code></td>
</tr>
<tr>
<td style="text-align:left">#</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msup><mi>y</mi><mn>2</mn></msup></mrow><annotation encoding="application/x-tex">\def\bar#1{#1^2} \bar{y}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0085em;vertical-align:-0.1944em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">y</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\def\bar#1{#1^2} \bar{y}</code></td>
</tr>
<tr>
<td style="text-align:left">\#</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">#</mi></mrow><annotation encoding="application/x-tex">\#</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord">#</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">%</td>
<td style="text-align:left"></td>
<td style="text-align:left"><code>%this is a comment</code></td>
</tr>
<tr>
<td style="text-align:left">\%</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">%</mi></mrow><annotation encoding="application/x-tex">\%</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8056em;vertical-align:-0.0556em;"></span><span class="mord">%</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">&amp;</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mtable rowspacing="0.16em" columnalign="center center" columnspacing="1em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>a</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>b</mi></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>c</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>d</mi></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{matrix} a &amp; b\cr c &amp; d \end{matrix}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.4em;vertical-align:-0.95em;"></span><span class="mord"><span class="mtable"><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:0.5em;"></span><span class="arraycolsep" style="width:0.5em;"></span><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">b</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">d</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\begin{matrix}</code><br>   <code>a &amp; b \\</code><br>   <code>c &amp; d</code><br><code>\end{matrix}</code></td>
</tr>
<tr>
<td style="text-align:left">\&amp;</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">&amp;</mi></mrow><annotation encoding="application/x-tex">\&amp;</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">&amp;</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">'</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msup><mrow></mrow><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup></mrow><annotation encoding="application/x-tex">&#x27;</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7519em;"></span><span class="mord"><span></span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7519em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\'</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mtext>a</mtext><mo>ˊ</mo></mover></mrow><annotation encoding="application/x-tex">\text{\&#x27;{a}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6944em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">a</span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.25em;"><span class="mord">ˊ</span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\'{a}}</code></td>
</tr>
<tr>
<td style="text-align:left">(</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">(</mo></mrow><annotation encoding="application/x-tex">(</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">(</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">)</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mclose">)</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\(…\)</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle scriptlevel="0" displaystyle="false"><mfrac><mi>a</mi><mi>b</mi></mfrac></mstyle></mrow><annotation encoding="application/x-tex">\text{\(\frac a b\)}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0404em;vertical-align:-0.345em;"></span><span class="mord text"><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6954em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">b</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">a</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\(\frac a b\)}</code></td>
</tr>
<tr>
<td style="text-align:left">\</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mtext> </mtext><mi>b</mi></mrow><annotation encoding="application/x-tex">a\ b</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">a</span><span class="mspace"> </span><span class="mord mathnormal">b</span></span></span></span></td>
<td style="text-align:left"><code>a\ b</code></td>
</tr>
<tr>
<td style="text-align:left">\&quot;</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mtext>a</mtext><mo>¨</mo></mover></mrow><annotation encoding="application/x-tex">\text{\&quot;{a}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6679em;"></span><span class="mord text"><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6679em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">a</span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.25em;"><span class="mord">¨</span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\&quot;{a}}</code></td>
</tr>
<tr>
<td style="text-align:left">\$</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>$</mtext></mrow><annotation encoding="application/x-tex">\text{\textdollar}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8056em;vertical-align:-0.0556em;"></span><span class="mord text"><span class="mord">$</span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\,</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mtext> </mtext><mtext> </mtext><mi>b</mi></mrow><annotation encoding="application/x-tex">a\,\,{b}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">a</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal">b</span></span></span></span></span></td>
<td style="text-align:left"><code>a\,\,{b}</code></td>
</tr>
<tr>
<td style="text-align:left">\.</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mtext>a</mtext><mo>˙</mo></mover></mrow><annotation encoding="application/x-tex">\text{\.{a}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6679em;"></span><span class="mord text"><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6679em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">a</span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.1389em;"><span class="mord">˙</span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\.{a}}</code></td>
</tr>
<tr>
<td style="text-align:left">\:</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mtext> </mtext><mtext> </mtext><mi>b</mi></mrow><annotation encoding="application/x-tex">a\:\:{b}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">a</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal">b</span></span></span></span></span></td>
<td style="text-align:left"><code>a\:\:{b}</code></td>
</tr>
<tr>
<td style="text-align:left">\;</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mtext>  </mtext><mtext>  </mtext><mi>b</mi></mrow><annotation encoding="application/x-tex">a\;\;{b}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">a</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord"><span class="mord mathnormal">b</span></span></span></span></span></td>
<td style="text-align:left">a<code>\;\;{b}</code></td>
</tr>
<tr>
<td style="text-align:left">_</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>x</mi><mi>i</mi></msub></mrow><annotation encoding="application/x-tex">x_i</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>x_i</code></td>
</tr>
<tr>
<td style="text-align:left">\_</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">_</mi></mrow><annotation encoding="application/x-tex">\_</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;vertical-align:-0.31em;"></span><span class="mord" style="margin-right:0.02778em;">_</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\<code>`</code></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mtext>a</mtext><mo>ˋ</mo></mover></mrow><annotation encoding="application/x-tex">\text{\`{a}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6944em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">a</span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.25em;"><span class="mord">ˋ</span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\'{a}}</code></td>
</tr>
<tr>
<td style="text-align:left">&lt;</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>&lt;</mo></mrow><annotation encoding="application/x-tex">&lt;</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">&lt;</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\=</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mtext>a</mtext><mo>ˉ</mo></mover></mrow><annotation encoding="application/x-tex">\text{\={a}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5678em;"></span><span class="mord text"><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.5678em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">a</span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.25em;"><span class="mord">ˉ</span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\\={a}}</code></td>
</tr>
<tr>
<td style="text-align:left">&gt;</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>&gt;</mo></mrow><annotation encoding="application/x-tex">&gt;</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">&gt;</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\&gt;</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mtext> </mtext><mtext> </mtext><mi>b</mi></mrow><annotation encoding="application/x-tex">a\&gt;\&gt;{b}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">a</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mord mathnormal">b</span></span></span></span></span></td>
<td style="text-align:left"><code>a\&gt;\&gt;{b}</code></td>
</tr>
<tr>
<td style="text-align:left">[</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">[</mo></mrow><annotation encoding="application/x-tex">[</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">[</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">]</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">]</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mclose">]</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">{</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi></mrow><annotation encoding="application/x-tex">{a}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span></span></span></td>
<td style="text-align:left"><code>{a}</code></td>
</tr>
<tr>
<td style="text-align:left">}</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi></mrow><annotation encoding="application/x-tex">{a}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span></span></span></td>
<td style="text-align:left"><code>{a}</code></td>
</tr>
<tr>
<td style="text-align:left">\{</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">{</mo></mrow><annotation encoding="application/x-tex">\{</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">{</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\}</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">}</mo></mrow><annotation encoding="application/x-tex">\}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mclose">}</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">|</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∣</mi></mrow><annotation encoding="application/x-tex">\vert</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">∣</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\|</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∥</mi></mrow><annotation encoding="application/x-tex">\Vert</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">∥</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">~</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>no no no breaks</mtext></mrow><annotation encoding="application/x-tex">\text{no~no~no~breaks}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord">no</span><span class="mord nobreak"> </span><span class="mord">no</span><span class="mord nobreak"> </span><span class="mord">no</span><span class="mord nobreak"> </span><span class="mord">breaks</span></span></span></span></span></td>
<td style="text-align:left"><code>\text{no~no~no~breaks}</code></td>
</tr>
<tr>
<td style="text-align:left">\~</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mtext>a</mtext><mo>˜</mo></mover></mrow><annotation encoding="application/x-tex">\text{\~{a}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6679em;"></span><span class="mord text"><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6679em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">a</span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.25em;"><span class="mord">˜</span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\\~{a}}</code></td>
</tr>
<tr>
<td style="text-align:left">\\</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mtable rowspacing="0.16em" columnalign="center center" columnspacing="1em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>a</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>b</mi></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>c</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>d</mi></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{matrix} a &amp; b\\ c &amp; d\end{matrix}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.4em;vertical-align:-0.95em;"></span><span class="mord"><span class="mtable"><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:0.5em;"></span><span class="arraycolsep" style="width:0.5em;"></span><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">b</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">d</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\begin{matrix}</code><br>   <code>a &amp; b \\</code><br>   <code>c &amp; d</code><br><code>\end{matrix}</code></td>
</tr>
<tr>
<td style="text-align:left">^</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msup><mi>x</mi><mi>i</mi></msup></mrow><annotation encoding="application/x-tex">x^i</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8247em;"></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8247em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">i</span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>x^i</code></td>
</tr>
<tr>
<td style="text-align:left">\^</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mtext>a</mtext><mo>ˆ</mo></mover></mrow><annotation encoding="application/x-tex">\text{\^{a}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6944em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">a</span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.25em;"><span class="mord">ˆ</span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\\^{a}}</code></td>
</tr>
</tbody>
</table>
<h2 id="a" tabindex="-1">A <a class="header-anchor" href="#a" aria-label="Permalink to &quot;A&quot;">&ZeroWidthSpace;</a></h2>
<table>
<thead>
<tr>
<th style="text-align:left">Symbol/Function</th>
<th style="text-align:left">Rendered</th>
<th style="text-align:left">Source or Comment</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">\AA</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mtext>A</mtext><mo>˚</mo></mover></mrow><annotation encoding="application/x-tex">\text{\AA}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9468em;"></span><span class="mord text"><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.9468em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord">A</span></span><span style="top:-3.2523em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.375em;"><span class="mord">˚</span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\AA}</code></td>
</tr>
<tr>
<td style="text-align:left">\aa</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mtext>a</mtext><mo>˚</mo></mover></mrow><annotation encoding="application/x-tex">\text{\aa}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6944em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord">a</span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.375em;"><span class="mord">˚</span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\aa}</code></td>
</tr>
<tr>
<td style="text-align:left">\above</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mfrac linethickness="0.2em"><mi>a</mi><mrow><mi>b</mi><mo>+</mo><mn>1</mn></mrow></mfrac></mrow><annotation encoding="application/x-tex">{a \above{2pt} b+1}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.4458em;vertical-align:-0.5944em;"></span><span class="mord"><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8514em;"><span style="top:-2.4639em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">b</span><span class="mbin mtight">+</span><span class="mord mtight">1</span></span></span></span><span style="top:-3.15em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.2em;"></span></span><span style="top:-3.55em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">a</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.5944em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span></span></td>
<td style="text-align:left"><code>{a \above{2pt} b+1}</code></td>
</tr>
<tr>
<td style="text-align:left">\abovewithdelims</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\acute</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mi>e</mi><mo>ˊ</mo></mover></mrow><annotation encoding="application/x-tex">\acute e</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6944em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord mathnormal">e</span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.1944em;"><span class="mord">ˊ</span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\acute e</code></td>
</tr>
<tr>
<td style="text-align:left">\AE</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>Æ</mtext></mrow><annotation encoding="application/x-tex">\text{\AE}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord text"><span class="mord">Æ</span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\AE}</code></td>
</tr>
<tr>
<td style="text-align:left">\ae</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>æ</mtext></mrow><annotation encoding="application/x-tex">\text{\ae}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord text"><span class="mord">æ</span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\ae}</code></td>
</tr>
<tr>
<td style="text-align:left">\alef</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">ℵ</mi></mrow><annotation encoding="application/x-tex">\alef</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">ℵ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\alefsym</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">ℵ</mi></mrow><annotation encoding="application/x-tex">\alefsym</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">ℵ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\aleph</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">ℵ</mi></mrow><annotation encoding="application/x-tex">\aleph</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">ℵ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left" align=""></td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left">see <code>{aligned}</code></td>
</tr>
<tr>
<td style="text-align:left" aligned=""></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mtable rowspacing="0.25em" columnalign="right left" columnspacing="0em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mi>a</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mo>=</mo><mi>b</mi><mo>+</mo><mi>c</mi></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mi>d</mi><mo>+</mo><mi>e</mi></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mo>=</mo><mi>f</mi></mrow></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{aligned}a&amp;=b+c\\d+e&amp;=f\end{aligned}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:3em;vertical-align:-1.25em;"></span><span class="mord"><span class="mtable"><span class="col-align-r"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.75em;"><span style="top:-3.91em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">d</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal">e</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.25em;"><span></span></span></span></span></span><span class="col-align-l"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.75em;"><span style="top:-3.91em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord mathnormal">b</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal">c</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord mathnormal" style="margin-right:0.10764em;">f</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.25em;"><span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\begin{aligned}</code><br>   <code>a&amp;=b+c \\</code><br>   <code>d+e&amp;=f</code><br><code>\end{aligned}</code></td>
</tr>
<tr>
<td style="text-align:left" alignat=""></td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left">see <code>{alignedat}</code></td>
</tr>
<tr>
<td style="text-align:left" alignedat=""></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mtable rowspacing="0.25em" columnalign="right left right left" columnspacing="0em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mn>10</mn></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mi>x</mi><mo>+</mo></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mn>3</mn></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mi>y</mi><mo>=</mo><mn>2</mn></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mn>3</mn></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mi>x</mi><mo>+</mo></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mn>13</mn></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mi>y</mi><mo>=</mo><mn>4</mn></mrow></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{alignedat}{2}10&amp;x+&amp;3&amp;y=2\\3&amp;x+&amp;13&amp;y=4\end{alignedat}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:3em;vertical-align:-1.25em;"></span><span class="mord"><span class="mtable"><span class="col-align-r"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.75em;"><span style="top:-3.91em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">10</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">3</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.25em;"><span></span></span></span></span></span><span class="col-align-l"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.75em;"><span style="top:-3.91em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"></span><span class="mord mathnormal">x</span><span class="mord">+</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"></span><span class="mord mathnormal">x</span><span class="mord">+</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.25em;"><span></span></span></span></span></span><span class="col-align-r"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.75em;"><span style="top:-3.91em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">3</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">13</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.25em;"><span></span></span></span></span></span><span class="col-align-l"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.75em;"><span style="top:-3.91em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"></span><span class="mord mathnormal" style="margin-right:0.03588em;">y</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord">2</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"></span><span class="mord mathnormal" style="margin-right:0.03588em;">y</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord">4</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.25em;"><span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\begin{alignedat}{2}</code><br>   <code>10&amp;x+ &amp;3&amp;y = 2 \\</code><br>   <code> 3&amp;x+&amp;13&amp;y = 4</code><br><code>\end{alignedat}</code></td>
</tr>
<tr>
<td style="text-align:left">\allowbreak</td>
<td style="text-align:left"></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Alpha</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">A</mi></mrow><annotation encoding="application/x-tex">\Alpha</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathrm">A</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\alpha</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>α</mi></mrow><annotation encoding="application/x-tex">\alpha</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal" style="margin-right:0.0037em;">α</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\amalg</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⨿</mo></mrow><annotation encoding="application/x-tex">\amalg</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">⨿</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\And</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>&amp;</mo></mrow><annotation encoding="application/x-tex">\And</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">&amp;</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\and</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"><a href="https://en.wikipedia.org/wiki/Help:Displaying_a_formula#Deprecated_syntax" target="_blank" rel="noreferrer">Deprecated</a></td>
</tr>
<tr>
<td style="text-align:left">\ang</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"><a href="https://en.wikipedia.org/wiki/Help:Displaying_a_formula#Deprecated_syntax" target="_blank" rel="noreferrer">Deprecated</a></td>
</tr>
<tr>
<td style="text-align:left">\angl</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\angle</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∠</mi></mrow><annotation encoding="application/x-tex">\angle</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mord">∠</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\approx</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≈</mo></mrow><annotation encoding="application/x-tex">\approx</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4831em;"></span><span class="mrel">≈</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\approxeq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≊</mo></mrow><annotation encoding="application/x-tex">\approxeq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6633em;vertical-align:-0.0817em;"></span><span class="mrel amsrm">≊</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\arccos</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>arccos</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\arccos</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mop">arccos</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\arcctg</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>arcctg</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\arcctg</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8095em;vertical-align:-0.1944em;"></span><span class="mop">arcct<span style="margin-right:0.01389em;">g</span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\arcsin</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>arcsin</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\arcsin</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6679em;"></span><span class="mop">arcsin</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\arctan</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>arctan</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\arctan</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6151em;"></span><span class="mop">arctan</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\arctg</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>arctg</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\arctg</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8095em;vertical-align:-0.1944em;"></span><span class="mop">arct<span style="margin-right:0.01389em;">g</span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\arg</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>arg</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\arg</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mop">ar<span style="margin-right:0.01389em;">g</span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\argmax</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">arg max</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\argmax</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mop"><span class="mord mathrm" style="margin-right:0.01389em;">arg</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathrm">max</span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\argmin</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">arg min</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\argmin</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8623em;vertical-align:-0.1944em;"></span><span class="mop"><span class="mord mathrm" style="margin-right:0.01389em;">arg</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathrm">min</span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left" array=""></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mtable rowspacing="0.16em" columnalign="center center" columnspacing="1em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>a</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>b</mi></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>c</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>d</mi></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{array}{cc}a&amp;b\\c&amp;d\end{array}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.4em;vertical-align:-0.95em;"></span><span class="mord"><span class="mtable"><span class="arraycolsep" style="width:0.5em;"></span><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:0.5em;"></span><span class="arraycolsep" style="width:0.5em;"></span><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">b</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">d</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:0.5em;"></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\begin{array}{cc}</code><br>   <code>a &amp; b \\</code><br>   <code>c &amp; d</code><br><code>\end{array}</code></td>
</tr>
<tr>
<td style="text-align:left">\array</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left">see <code>{array}</code></td>
</tr>
<tr>
<td style="text-align:left">\arraystretch</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mtable rowspacing="0.66em" columnalign="center center" columnspacing="1em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>a</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>b</mi></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>c</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>d</mi></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\def\arraystretch{1.5}\begin{array}{cc}a&amp;b\\c&amp;d\end{array}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:3.6em;vertical-align:-1.55em;"></span><span class="mord"><span class="mtable"><span class="arraycolsep" style="width:0.5em;"></span><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:2.05em;"><span style="top:-4.05em;"><span class="pstrut" style="height:3.26em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span><span style="top:-2.25em;"><span class="pstrut" style="height:3.26em;"></span><span class="mord"><span class="mord mathnormal">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.55em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:0.5em;"></span><span class="arraycolsep" style="width:0.5em;"></span><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:2.05em;"><span style="top:-4.05em;"><span class="pstrut" style="height:3.26em;"></span><span class="mord"><span class="mord mathnormal">b</span></span></span><span style="top:-2.25em;"><span class="pstrut" style="height:3.26em;"></span><span class="mord"><span class="mord mathnormal">d</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.55em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:0.5em;"></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\def\arraystretch{1.5}</code><br><code>\begin{array}{cc}</code><br>   <code>a &amp; b \\</code><br>   <code>c &amp; d</code><br><code>\end{array}</code></td>
</tr>
<tr>
<td style="text-align:left">\Arrowvert</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\arrowvert</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\ast</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∗</mo></mrow><annotation encoding="application/x-tex">\ast</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4653em;"></span><span class="mord">∗</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\asymp</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≍</mo></mrow><annotation encoding="application/x-tex">\asymp</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4637em;"></span><span class="mrel">≍</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\atop</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mfrac linethickness="0px"><mi>a</mi><mi>b</mi></mfrac></mrow><annotation encoding="application/x-tex">{a \atop b}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0904em;vertical-align:-0.345em;"></span><span class="mord"><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.7454em;"><span style="top:-2.355em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">b</span></span></span></span><span style="top:-3.144em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">a</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span></span></td>
<td style="text-align:left"><code>{a \atop b}</code></td>
</tr>
<tr>
<td style="text-align:left">\atopwithdelims</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
</tbody>
</table>
<h2 id="b" tabindex="-1">B <a class="header-anchor" href="#b" aria-label="Permalink to &quot;B&quot;">&ZeroWidthSpace;</a></h2>
<p>| Symbol/Function     | Rendered                                            | Source or Comment                                                                                 |
| :------------------ | :-------------------------------------------------- | :------------------------------------------------------------------------------------------------ | ------ |
| \backepsilon        | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∍</mo></mrow><annotation encoding="application/x-tex">\backepsilon</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mrel amsrm">∍</span></span></span></span>                                      |                                                                                                   |
| \backprime          | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">‵</mi></mrow><annotation encoding="application/x-tex">\backprime</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5499em;"></span><span class="mord amsrm">‵</span></span></span></span>                                        |                                                                                                   |
| \backsim            | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∽</mo></mrow><annotation encoding="application/x-tex">\backsim</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3779em;"></span><span class="mrel amsrm">∽</span></span></span></span>                                          |                                                                                                   |
| \backsimeq          | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋍</mo></mrow><annotation encoding="application/x-tex">\backsimeq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.464em;"></span><span class="mrel amsrm">⋍</span></span></span></span>                                        |                                                                                                   |
| \backslash          | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">\</mi></mrow><annotation encoding="application/x-tex">\backslash</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">\</span></span></span></span>                                        |                                                                                                   |
| \bar                | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mi>y</mi><mo>ˉ</mo></mover></mrow><annotation encoding="application/x-tex">\bar{y}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7622em;vertical-align:-0.1944em;"></span><span class="mord accent"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.5678em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">y</span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.1944em;"><span class="mord">ˉ</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.1944em;"><span></span></span></span></span></span></span></span></span>                                           | <code>\bar{y}</code>                                                                                         |
| \barwedge           | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊼</mo></mrow><annotation encoding="application/x-tex">\barwedge</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8867em;vertical-align:-0.1944em;"></span><span class="mord amsrm">⊼</span></span></span></span>                                         |                                                                                                   |
| \Bbb                | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="double-struck">A</mi><mi mathvariant="double-struck">B</mi><mi mathvariant="double-struck">C</mi></mrow><annotation encoding="application/x-tex">\Bbb{ABC}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord"><span class="mord mathbb">ABC</span></span></span></span></span>                                         | <code>\Bbb{ABC}</code><br>KaTeX supports A-Z &amp; k                                                             |
| \Bbbk               | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="double-struck">k</mi></mrow><annotation encoding="application/x-tex">\Bbbk</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord mathbb">k</span></span></span></span>                                             |                                                                                                   |
| \bbox               | <span style="color:firebrick;">Not supported</span> |                                                                                                   |
| \bcancel            | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><menclose notation="downdiagonalstrike"><mn>5</mn></menclose></mrow><annotation encoding="application/x-tex">\bcancel{5}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8444em;"><span style="top:-3.0444em;"><span class="pstrut" style="height:3.0444em;"></span><span class="mord"><span class="mord">5</span></span></span><span class="svg-align" style="top:-2.8444em;"><span class="pstrut" style="height:3.0444em;"></span><span style="height:1.0444em;"><svg xmlns="http://www.w3.org/2000/svg" width='100%' height='1.0444em'><line x1='0' y1='0' x2='100%' y2='100%' stroke-width='0.046em'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2em;"><span></span></span></span></span></span></span></span></span>                                       | <code>\bcancel{5}</code>                                                                                     |
| \because            | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∵</mo></mrow><annotation encoding="application/x-tex">\because</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mrel amsrm">∵</span></span></span></span>                                          |                                                                                                   |
| \begin              | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mtable rowspacing="0.16em" columnalign="center center" columnspacing="1em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>a</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>b</mi></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>c</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>d</mi></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{matrix} a &amp; b\\ c &amp; d\end{matrix}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.4em;vertical-align:-0.95em;"></span><span class="mord"><span class="mtable"><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:0.5em;"></span><span class="arraycolsep" style="width:0.5em;"></span><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">b</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">d</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span></span></span></span></span></span>          | <code>\begin{matrix}</code><br>   <code>a &amp; b \\</code><br>   <code>c &amp; d</code><br><code>\end{matrix}</code>   |
| \begingroup         | <span class='katex-error' title='ParseError: KaTeX parse error: Expected &#039;\endgroup&#039;, got &#039;}&#039; at position 14: \begingroup a}̲'>\begingroup a}</span>                                    | <code>\begingroup a}</code>                                                                                  |
| \Beta               | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">B</mi></mrow><annotation encoding="application/x-tex">\Beta</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathrm">B</span></span></span></span>                                             |                                                                                                   |
| \beta               | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>β</mi></mrow><annotation encoding="application/x-tex">\beta</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.05278em;">β</span></span></span></span>                                             |                                                                                                   |
| \beth               | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">ℶ</mi></mrow><annotation encoding="application/x-tex">\beth</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord amsrm">ℶ</span></span></span></span>                                             |                                                                                                   |
| \between            | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≬</mo></mrow><annotation encoding="application/x-tex">\between</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0117em;vertical-align:-0.2558em;"></span><span class="mrel amsrm">≬</span></span></span></span>                                          |                                                                                                   |
| \bf                 | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="bold">A</mi><mi mathvariant="bold">a</mi><mi mathvariant="bold">B</mi><mi mathvariant="bold">b</mi><mn mathvariant="bold">12</mn></mrow><annotation encoding="application/x-tex">\bf AaBb12</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord"><span class="mord mathbf">AaBb12</span></span></span></span></span>                                        | <code>\bf AaBb12</code>                                                                                      |
| \bfseries           | <span style="color:firebrick;">Not supported</span> |                                                                                                   |
| \big                | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="false" stretchy="true" minsize="1.2em" maxsize="1.2em">(</mo><mo fence="false" stretchy="true" minsize="1.2em" maxsize="1.2em">)</mo></mrow><annotation encoding="application/x-tex">\big(\big)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2em;vertical-align:-0.35em;"></span><span class="mord"><span class="delimsizing size1">(</span></span><span class="mord"><span class="delimsizing size1">)</span></span></span></span></span>                                        | <code>\big(\big)</code>                                                                                      |
| \Big                | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="false" stretchy="true" minsize="1.8em" maxsize="1.8em">(</mo><mo fence="false" stretchy="true" minsize="1.8em" maxsize="1.8em">)</mo></mrow><annotation encoding="application/x-tex">\Big(\Big)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.8em;vertical-align:-0.65em;"></span><span class="mord"><span class="delimsizing size2">(</span></span><span class="mord"><span class="delimsizing size2">)</span></span></span></span></span>                                        | <code>\Big(\Big)</code>                                                                                      |
| \bigcap             | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋂</mo></mrow><annotation encoding="application/x-tex">\bigcap</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mop op-symbol small-op" style="position:relative;top:0em;">⋂</span></span></span></span>                                           |                                                                                                   |
| \bigcirc            | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>◯</mo></mrow><annotation encoding="application/x-tex">\bigcirc</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord">◯</span></span></span></span>                                          |                                                                                                   |
| \bigcup             | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋃</mo></mrow><annotation encoding="application/x-tex">\bigcup</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mop op-symbol small-op" style="position:relative;top:0em;">⋃</span></span></span></span>                                           |                                                                                                   |
| \bigg               | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="false" stretchy="true" minsize="2.4em" maxsize="2.4em">(</mo><mo fence="false" stretchy="true" minsize="2.4em" maxsize="2.4em">)</mo></mrow><annotation encoding="application/x-tex">\bigg(\bigg)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.4em;vertical-align:-0.95em;"></span><span class="mord"><span class="delimsizing size3">(</span></span><span class="mord"><span class="delimsizing size3">)</span></span></span></span></span>                                      | <code>\bigg(\bigg)</code>                                                                                    |
| \Bigg               | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="false" stretchy="true" minsize="3em" maxsize="3em">(</mo><mo fence="false" stretchy="true" minsize="3em" maxsize="3em">)</mo></mrow><annotation encoding="application/x-tex">\Bigg(\Bigg)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:3em;vertical-align:-1.25em;"></span><span class="mord"><span class="delimsizing size4">(</span></span><span class="mord"><span class="delimsizing size4">)</span></span></span></span></span>                                      | <code>\Bigg(\Bigg)</code>                                                                                    |
| \biggl              | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true" stretchy="true" minsize="2.4em" maxsize="2.4em">(</mo></mrow><annotation encoding="application/x-tex">\biggl(</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.4em;vertical-align:-0.95em;"></span><span class="mopen"><span class="delimsizing size3">(</span></span></span></span></span>                                           | <code>\biggl(</code>                                                                                         |
| \Biggl              | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true" stretchy="true" minsize="3em" maxsize="3em">(</mo></mrow><annotation encoding="application/x-tex">\Biggl(</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:3em;vertical-align:-1.25em;"></span><span class="mopen"><span class="delimsizing size4">(</span></span></span></span></span>                                           | <code>\Biggl(</code>                                                                                         |
| \biggm              | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="false" stretchy="true" minsize="2.4em" maxsize="2.4em">∣</mo></mrow><annotation encoding="application/x-tex">\biggm\vert</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.4em;vertical-align:-0.95em;"></span><span class="mrel"><span class="delimsizing mult"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.45em;"><span class="pstrut" style="height:4.4em;"></span><span style="width:0.333em;height:2.400em;"><svg xmlns="http://www.w3.org/2000/svg" width='0.333em' height='2.400em' viewBox='0 0 333 2400'><path d='M145 15 v585 v1200 v585 c2.667,10,9.667,15,21,15
c10,0,16.667,-5,20,-15 v-585 v-1200 v-585 c-2.667,-10,-9.667,-15,-21,-15
c-10,0,-16.667,5,-20,15z M188 15 H145 v585 v1200 v585 h43z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span></span></span></span></span>                                       | <code>\biggm\vert</code>                                                                                     |
| \Biggm              | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="false" stretchy="true" minsize="3em" maxsize="3em">∣</mo></mrow><annotation encoding="application/x-tex">\Biggm\vert</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:3em;vertical-align:-1.25em;"></span><span class="mrel"><span class="delimsizing mult"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.75em;"><span style="top:-3.75em;"><span class="pstrut" style="height:5em;"></span><span style="width:0.333em;height:3.000em;"><svg xmlns="http://www.w3.org/2000/svg" width='0.333em' height='3.000em' viewBox='0 0 333 3000'><path d='M145 15 v585 v1800 v585 c2.667,10,9.667,15,21,15
c10,0,16.667,-5,20,-15 v-585 v-1800 v-585 c-2.667,-10,-9.667,-15,-21,-15
c-10,0,-16.667,5,-20,15z M188 15 H145 v585 v1800 v585 h43z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.25em;"><span></span></span></span></span></span></span></span></span></span>                                       | <code>\Biggm\vert</code>                                                                                     |
| \biggr              | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true" stretchy="true" minsize="2.4em" maxsize="2.4em">)</mo></mrow><annotation encoding="application/x-tex">\biggr)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.4em;vertical-align:-0.95em;"></span><span class="mclose"><span class="delimsizing size3">)</span></span></span></span></span>                                           | <code>\biggr)</code>                                                                                         |
| \Biggr              | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true" stretchy="true" minsize="3em" maxsize="3em">)</mo></mrow><annotation encoding="application/x-tex">\Biggr)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:3em;vertical-align:-1.25em;"></span><span class="mclose"><span class="delimsizing size4">)</span></span></span></span></span>                                           | <code>\Biggr)</code>                                                                                         |
| \bigl               | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true" stretchy="true" minsize="1.2em" maxsize="1.2em">(</mo></mrow><annotation encoding="application/x-tex">\bigl(</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2em;vertical-align:-0.35em;"></span><span class="mopen"><span class="delimsizing size1">(</span></span></span></span></span>                                            | <code>\bigl(</code>                                                                                          |
| \Bigl               | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true" stretchy="true" minsize="1.8em" maxsize="1.8em">(</mo></mrow><annotation encoding="application/x-tex">\Bigl(</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.8em;vertical-align:-0.65em;"></span><span class="mopen"><span class="delimsizing size2">(</span></span></span></span></span>                                            | <code>\Bigl(</code>                                                                                          |
| \bigm               | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="false" stretchy="true" minsize="1.2em" maxsize="1.2em">∣</mo></mrow><annotation encoding="application/x-tex">\bigm\vert</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2em;vertical-align:-0.35em;"></span><span class="mrel"><span class="delimsizing mult"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.85em;"><span style="top:-2.85em;"><span class="pstrut" style="height:3.2em;"></span><span style="width:0.333em;height:1.200em;"><svg xmlns="http://www.w3.org/2000/svg" width='0.333em' height='1.200em' viewBox='0 0 333 1200'><path d='M145 15 v585 v0 v585 c2.667,10,9.667,15,21,15
c10,0,16.667,-5,20,-15 v-585 v0 v-585 c-2.667,-10,-9.667,-15,-21,-15
c-10,0,-16.667,5,-20,15z M188 15 H145 v585 v0 v585 h43z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.35em;"><span></span></span></span></span></span></span></span></span></span>                                        | <code>\bigm\vert</code>                                                                                      |
| \Bigm               | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="false" stretchy="true" minsize="1.8em" maxsize="1.8em">∣</mo></mrow><annotation encoding="application/x-tex">\Bigm\vert</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.8em;vertical-align:-0.65em;"></span><span class="mrel"><span class="delimsizing mult"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.15em;"><span style="top:-3.15em;"><span class="pstrut" style="height:3.8em;"></span><span style="width:0.333em;height:1.800em;"><svg xmlns="http://www.w3.org/2000/svg" width='0.333em' height='1.800em' viewBox='0 0 333 1800'><path d='M145 15 v585 v600 v585 c2.667,10,9.667,15,21,15
c10,0,16.667,-5,20,-15 v-585 v-600 v-585 c-2.667,-10,-9.667,-15,-21,-15
c-10,0,-16.667,5,-20,15z M188 15 H145 v585 v600 v585 h43z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.65em;"><span></span></span></span></span></span></span></span></span></span>                                        | <code>\Bigm\vert</code>                                                                                      |
| \bigodot            | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⨀</mo></mrow><annotation encoding="application/x-tex">\bigodot</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mop op-symbol small-op" style="position:relative;top:0em;">⨀</span></span></span></span>                                          |                                                                                                   |
| \bigominus          | <span style="color:firebrick;">Not supported</span> | <a href="https://github.com/KaTeX/KaTeX/issues/1222" target="_blank" rel="noreferrer">Issue #1222</a>                                         |
| \bigoplus           | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⨁</mo></mrow><annotation encoding="application/x-tex">\bigoplus</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mop op-symbol small-op" style="position:relative;top:0em;">⨁</span></span></span></span>                                         |                                                                                                   |
| \bigoslash          | <span style="color:firebrick;">Not supported</span> | <a href="https://github.com/KaTeX/KaTeX/issues/1222" target="_blank" rel="noreferrer">Issue #1222</a>                                         |
| \bigotimes          | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⨂</mo></mrow><annotation encoding="application/x-tex">\bigotimes</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mop op-symbol small-op" style="position:relative;top:0em;">⨂</span></span></span></span>                                        |                                                                                                   |
| \bigr               | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true" stretchy="true" minsize="1.2em" maxsize="1.2em">)</mo></mrow><annotation encoding="application/x-tex">\bigr)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2em;vertical-align:-0.35em;"></span><span class="mclose"><span class="delimsizing size1">)</span></span></span></span></span>                                            | <code>\bigr)</code>                                                                                          |
| \Bigr               | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true" stretchy="true" minsize="1.8em" maxsize="1.8em">)</mo></mrow><annotation encoding="application/x-tex">\Bigr)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.8em;vertical-align:-0.65em;"></span><span class="mclose"><span class="delimsizing size2">)</span></span></span></span></span>                                            | <code>\Bigr)</code>                                                                                          |
| \bigsqcap           | <span style="color:firebrick;">Not supported</span> | <a href="https://github.com/KaTeX/KaTeX/issues/1222" target="_blank" rel="noreferrer">Issue #1222</a>                                         |
| \bigsqcup           | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⨆</mo></mrow><annotation encoding="application/x-tex">\bigsqcup</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mop op-symbol small-op" style="position:relative;top:0em;">⨆</span></span></span></span>                                         |                                                                                                   |
| \bigstar            | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">★</mi></mrow><annotation encoding="application/x-tex">\bigstar</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8867em;vertical-align:-0.1944em;"></span><span class="mord amsrm">★</span></span></span></span>                                          |                                                                                                   |
| \bigtriangledown    | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>▽</mo></mrow><annotation encoding="application/x-tex">\bigtriangledown</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord">▽</span></span></span></span>                                  |                                                                                                   |
| \bigtriangleup      | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>△</mo></mrow><annotation encoding="application/x-tex">\bigtriangleup</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord">△</span></span></span></span>                                    |                                                                                                   |
| \biguplus           | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⨄</mo></mrow><annotation encoding="application/x-tex">\biguplus</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mop op-symbol small-op" style="position:relative;top:0em;">⨄</span></span></span></span>                                         |                                                                                                   |
| \bigvee             | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋁</mo></mrow><annotation encoding="application/x-tex">\bigvee</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mop op-symbol small-op" style="position:relative;top:0em;">⋁</span></span></span></span>                                           |                                                                                                   |
| \bigwedge           | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋀</mo></mrow><annotation encoding="application/x-tex">\bigwedge</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mop op-symbol small-op" style="position:relative;top:0em;">⋀</span></span></span></span>                                         |                                                                                                   |
| \binom              | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true">(</mo><mfrac linethickness="0px"><mi>n</mi><mi>k</mi></mfrac><mo fence="true">)</mo></mrow><annotation encoding="application/x-tex">\binom n k</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2em;vertical-align:-0.35em;"></span><span class="mord"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size1">(</span></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.7454em;"><span style="top:-2.355em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.03148em;">k</span></span></span></span><span style="top:-3.144em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">n</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size1">)</span></span></span></span></span></span>                                        | <code>\binom n k</code>                                                                                      |
| \blacklozenge       | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">⧫</mi></mrow><annotation encoding="application/x-tex">\blacklozenge</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8034em;vertical-align:-0.1111em;"></span><span class="mord amsrm">⧫</span></span></span></span>                                     |                                                                                                   |
| \blacksquare        | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">■</mi></mrow><annotation encoding="application/x-tex">\blacksquare</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.675em;"></span><span class="mord amsrm">■</span></span></span></span>                                      |                                                                                                   |
| \blacktriangle      | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">▲</mi></mrow><annotation encoding="application/x-tex">\blacktriangle</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5499em;"></span><span class="mord amsrm">▲</span></span></span></span>                                    |                                                                                                   |
| \blacktriangledown  | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">▼</mi></mrow><annotation encoding="application/x-tex">\blacktriangledown</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5499em;"></span><span class="mord amsrm">▼</span></span></span></span>                                |                                                                                                   |
| \blacktriangleleft  | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>◀</mo></mrow><annotation encoding="application/x-tex">\blacktriangleleft</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.585em;vertical-align:-0.0352em;"></span><span class="mrel amsrm">◀</span></span></span></span>                                |                                                                                                   |
| \blacktriangleright | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>▶</mo></mrow><annotation encoding="application/x-tex">\blacktriangleright</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.585em;vertical-align:-0.0352em;"></span><span class="mrel amsrm">▶</span></span></span></span>                               |                                                                                                   |
| \bm                 | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi><mrow><mi mathvariant="bold-italic">A</mi><mi mathvariant="bold-italic">a</mi><mi mathvariant="bold-italic">B</mi><mi mathvariant="bold-italic">b</mi></mrow></mi></mrow><annotation encoding="application/x-tex">\bm{AaBb}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol">AaBb</span></span></span></span></span></span>                                         | <code>\bm{AaBb}</code>                                                                                       |
| {Bmatrix}           | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true">{</mo><mtable rowspacing="0.16em" columnalign="center center" columnspacing="1em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>a</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>b</mi></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>c</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>d</mi></mstyle></mtd></mtr></mtable><mo fence="true">}</mo></mrow><annotation encoding="application/x-tex">\begin{Bmatrix}a&amp;b\\c&amp;d\end{Bmatrix}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.4em;vertical-align:-0.95em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size3">{</span></span><span class="mord"><span class="mtable"><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:0.5em;"></span><span class="arraycolsep" style="width:0.5em;"></span><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">b</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">d</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size3">}</span></span></span></span></span></span>              | <code>\begin{Bmatrix}</code><br>   <code>a &amp; b \\</code><br>   <code>c &amp; d</code><br><code>\end{Bmatrix}</code> |
| {bmatrix}           | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true">[</mo><mtable rowspacing="0.16em" columnalign="center center" columnspacing="1em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>a</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>b</mi></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>c</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>d</mi></mstyle></mtd></mtr></mtable><mo fence="true">]</mo></mrow><annotation encoding="application/x-tex">\begin{bmatrix}a&amp;b\\c&amp;d\end{bmatrix}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.4em;vertical-align:-0.95em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size3">[</span></span><span class="mord"><span class="mtable"><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:0.5em;"></span><span class="arraycolsep" style="width:0.5em;"></span><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">b</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">d</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size3">]</span></span></span></span></span></span>              | <code>\begin{bmatrix}</code><br>   <code>a &amp; b \\</code><br>   <code>c &amp; d</code><br><code>\end{bmatrix}</code> |
| \bmod               | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mtext> </mtext><mo lspace="0.22em" rspace="0.22em"><mrow><mi mathvariant="normal">m</mi><mi mathvariant="normal">o</mi><mi mathvariant="normal">d</mi></mrow></mo><mtext> </mtext><mi>b</mi></mrow><annotation encoding="application/x-tex">a \bmod b</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">a</span><span class="mspace" style="margin-right:0.0556em;"></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin"><span class="mord"><span class="mord mathrm">mod</span></span></span><span class="mspace" style="margin-right:0.0556em;"></span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">b</span></span></span></span>                                         | <code>a \bmod b</code>                                                                                       |
| \bold               | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="bold">A</mi><mi mathvariant="bold">a</mi><mi mathvariant="bold">B</mi><mi mathvariant="bold">b</mi><mn mathvariant="bold">123</mn></mrow><annotation encoding="application/x-tex">\bold{AaBb123}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord"><span class="mord mathbf">AaBb123</span></span></span></span></span>                                    | <code>\bold{AaBb123}</code>                                                                                  |
| \boldsymbol         | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi><mrow><mi mathvariant="bold-italic">A</mi><mi mathvariant="bold-italic">a</mi><mi mathvariant="bold-italic">B</mi><mi mathvariant="bold-italic">b</mi></mrow></mi></mrow><annotation encoding="application/x-tex">\boldsymbol{AaBb}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord"><span class="mord"><span class="mord boldsymbol">AaBb</span></span></span></span></span></span>                                 | <code>\boldsymbol{AaBb}</code>                                                                               |
| \bot                | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">⊥</mi></mrow><annotation encoding="application/x-tex">\bot</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">⊥</span></span></span></span>                                              |                                                                                                   |
| \bowtie             | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋈</mo></mrow><annotation encoding="application/x-tex">\bowtie</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.51em;vertical-align:-0.005em;"></span><span class="mrel">⋈</span></span></span></span>                                           |                                                                                                   |
| \Box                | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">□</mi></mrow><annotation encoding="application/x-tex">\Box</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.675em;"></span><span class="mord amsrm">□</span></span></span></span>                                              |                                                                                                   |
| \boxdot             | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊡</mo></mrow><annotation encoding="application/x-tex">\boxdot</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.675em;"></span><span class="mord amsrm">⊡</span></span></span></span>                                           |                                                                                                   |
| \boxed              | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><menclose notation="box"><mstyle scriptlevel="0" displaystyle="false"><mstyle scriptlevel="0" displaystyle="false"><mstyle scriptlevel="0" displaystyle="true"><mrow><mi>a</mi><mi>b</mi></mrow></mstyle></mstyle></mstyle></menclose></mrow><annotation encoding="application/x-tex">\boxed{ab}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.3744em;vertical-align:-0.34em;"></span><span class="mord"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.0344em;"><span style="top:-3.3744em;"><span class="pstrut" style="height:3.3744em;"></span><span class="boxpad"><span class="mord"><span class="mord"><span class="mord mathnormal">ab</span></span></span></span></span><span style="top:-3.0344em;"><span class="pstrut" style="height:3.3744em;"></span><span class="stretchy fbox" style="height:1.3744em;border-style:solid;border-width:0.04em;"></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.34em;"><span></span></span></span></span></span></span></span></span>                                        | <code>\boxed{ab}</code>                                                                                      |
| \boxminus           | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊟</mo></mrow><annotation encoding="application/x-tex">\boxminus</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.675em;"></span><span class="mord amsrm">⊟</span></span></span></span>                                         |                                                                                                   |
| \boxplus            | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊞</mo></mrow><annotation encoding="application/x-tex">\boxplus</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.675em;"></span><span class="mord amsrm">⊞</span></span></span></span>                                          |                                                                                                   |
| \boxtimes           | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊠</mo></mrow><annotation encoding="application/x-tex">\boxtimes</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.675em;"></span><span class="mord amsrm">⊠</span></span></span></span>                                         |                                                                                                   |
| \Bra                | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true">⟨</mo><mi>ψ</mi><mo fence="true">∥</mo></mrow><annotation encoding="application/x-tex">\left\langle\psi\right\|</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">⟨</span><span class="mord mathnormal" style="margin-right:0.03588em;">ψ</span><span class="mclose delimcenter" style="top:0em;">∥</span></span></span></span></span>                          | <code>\Bra{\psi}</code>                                                                                      |
| \bra                | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mpadded><mo stretchy="false">⟨</mo><mi>ψ</mi><mi mathvariant="normal">∥</mi></mpadded></mrow><annotation encoding="application/x-tex">\mathinner{\langle{\psi}\|}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="minner"><span class="mopen">⟨</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">ψ</span></span><span class="mord">∥</span></span></span></span></span>                       | <code>\bra{\psi}</code>                                                                                      |
| \braket             | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mpadded><mo stretchy="false">⟨</mo><mrow><mi>ϕ</mi><mi mathvariant="normal">∥</mi><mi>ψ</mi></mrow><mo stretchy="false">⟩</mo></mpadded></mrow><annotation encoding="application/x-tex">\mathinner{\langle{\phi\|\psi}\rangle}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="minner"><span class="mopen">⟨</span><span class="mord"><span class="mord mathnormal">ϕ</span><span class="mord">∥</span><span class="mord mathnormal" style="margin-right:0.03588em;">ψ</span></span><span class="mclose">⟩</span></span></span></span></span>            | <code>\braket{\phi                                                                                     | \psi}</code> |
| \brace              | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true">{</mo><mfrac linethickness="0px"><mi>n</mi><mi>k</mi></mfrac><mo fence="true">}</mo></mrow><annotation encoding="application/x-tex">{n\brace k}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2em;vertical-align:-0.35em;"></span><span class="mord"><span class="mord"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size1">{</span></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.7454em;"><span style="top:-2.355em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.03148em;">k</span></span></span></span><span style="top:-3.144em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">n</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size1">}</span></span></span></span></span></span></span>                                       | <code>{n\brace k}</code>                                                                                     |
| \bracevert          | <span style="color:firebrick;">Not supported</span> |                                                                                                   |
| \brack              | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true">[</mo><mfrac linethickness="0px"><mi>n</mi><mi>k</mi></mfrac><mo fence="true">]</mo></mrow><annotation encoding="application/x-tex">{n\brack k}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2em;vertical-align:-0.35em;"></span><span class="mord"><span class="mord"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size1">[</span></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.7454em;"><span style="top:-2.355em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.03148em;">k</span></span></span></span><span style="top:-3.144em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">n</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size1">]</span></span></span></span></span></span></span>                                       | <code>{n\brack k}</code>                                                                                     |
| \breve              | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mrow><mi>e</mi><mi>u</mi></mrow><mo>˘</mo></mover></mrow><annotation encoding="application/x-tex">\breve{eu}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6944em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">e</span><span class="mord mathnormal">u</span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.25em;"><span class="mord">˘</span></span></span></span></span></span></span></span></span></span>                                        | <code>\breve{eu}</code>                                                                                      |
| \buildrel           | <span style="color:firebrick;">Not supported</span> |                                                                                                   |
| \bull               | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∙</mo></mrow><annotation encoding="application/x-tex">\bull</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4445em;"></span><span class="mord">∙</span></span></span></span>                                             |                                                                                                   |
| \bullet             | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∙</mo></mrow><annotation encoding="application/x-tex">\bullet</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4445em;"></span><span class="mord">∙</span></span></span></span>                                           |                                                                                                   |
| \Bumpeq             | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≎</mo></mrow><annotation encoding="application/x-tex">\Bumpeq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6105em;vertical-align:-0.0606em;"></span><span class="mrel amsrm">≎</span></span></span></span>                                           |                                                                                                   |
| \bumpeq             | <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≏</mo></mrow><annotation encoding="application/x-tex">\bumpeq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6105em;vertical-align:-0.0606em;"></span><span class="mrel amsrm">≏</span></span></span></span>                                           |                                                                                                   |</p>
<h2 id="c" tabindex="-1">C <a class="header-anchor" href="#c" aria-label="Permalink to &quot;C&quot;">&ZeroWidthSpace;</a></h2>
<table>
<thead>
<tr>
<th style="text-align:left">Symbol/Function</th>
<th style="text-align:left">Rendered</th>
<th style="text-align:left">Source or Comment</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">\C</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"><a href="https://en.wikipedia.org/wiki/Help:Displaying_a_formula#Deprecated_syntax" target="_blank" rel="noreferrer">Deprecated</a></td>
</tr>
<tr>
<td style="text-align:left">\cal</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="script">A</mi><mi mathvariant="script">a</mi><mi mathvariant="script">B</mi><mi mathvariant="script">b</mi><mn mathvariant="script">123</mn></mrow><annotation encoding="application/x-tex">\cal AaBb123</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord"><span class="mord mathcal">A</span><span class="mord mathnormal">a</span><span class="mord mathcal" style="margin-right:0.03041em;">B</span><span class="mord mathnormal">b</span><span class="mord">123</span></span></span></span></span></td>
<td style="text-align:left"><code>\cal AaBb123</code></td>
</tr>
<tr>
<td style="text-align:left">\cancel</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><menclose notation="updiagonalstrike"><mn>5</mn></menclose></mrow><annotation encoding="application/x-tex">\cancel{5}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8444em;"><span style="top:-3.0444em;"><span class="pstrut" style="height:3.0444em;"></span><span class="mord"><span class="mord">5</span></span></span><span class="svg-align" style="top:-2.8444em;"><span class="pstrut" style="height:3.0444em;"></span><span style="height:1.0444em;"><svg xmlns="http://www.w3.org/2000/svg" width='100%' height='1.0444em'><line x1='0' y1='100%' x2='100%' y2='0' stroke-width='0.046em'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2em;"><span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\cancel{5}</code></td>
</tr>
<tr>
<td style="text-align:left">\cancelto</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Cap</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋒</mo></mrow><annotation encoding="application/x-tex">\Cap</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5499em;"></span><span class="mord amsrm">⋒</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\cap</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∩</mo></mrow><annotation encoding="application/x-tex">\cap</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5556em;"></span><span class="mord">∩</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left" cases=""></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true">{</mo><mtable rowspacing="0.36em" columnalign="left left" columnspacing="1em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>a</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mrow><mtext>if </mtext><mi>b</mi></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>c</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mrow><mtext>if </mtext><mi>d</mi></mrow></mstyle></mtd></mtr></mtable></mrow><annotation encoding="application/x-tex">\begin{cases}a&amp;\text{if }b\\c&amp;\text{if }d\end{cases}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:3em;vertical-align:-1.25em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size4">{</span></span><span class="mord"><span class="mtable"><span class="col-align-l"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.69em;"><span style="top:-3.69em;"><span class="pstrut" style="height:3.008em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span><span style="top:-2.25em;"><span class="pstrut" style="height:3.008em;"></span><span class="mord"><span class="mord mathnormal">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.19em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:1em;"></span><span class="col-align-l"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.69em;"><span style="top:-3.69em;"><span class="pstrut" style="height:3.008em;"></span><span class="mord"><span class="mord text"><span class="mord">if </span></span><span class="mord mathnormal">b</span></span></span><span style="top:-2.25em;"><span class="pstrut" style="height:3.008em;"></span><span class="mord"><span class="mord text"><span class="mord">if </span></span><span class="mord mathnormal">d</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.19em;"><span></span></span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span></td>
<td style="text-align:left"><code>\begin{cases}</code><br>   <code>a &amp;\text{if } b  \\</code><br>   <code>c &amp;\text{if } d</code><br><code>\end{cases}</code></td>
</tr>
<tr>
<td style="text-align:left">\cases</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left">see <code>{cases}</code></td>
</tr>
<tr>
<td style="text-align:left" CD=""></td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\cdot</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋅</mo></mrow><annotation encoding="application/x-tex">\cdot</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4445em;"></span><span class="mord">⋅</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\cdotp</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo separator="true">⋅</mo></mrow><annotation encoding="application/x-tex">\cdotp</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4445em;"></span><span class="mpunct">⋅</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\cdots</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋯</mo></mrow><annotation encoding="application/x-tex">\cdots</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.313em;"></span><span class="minner">⋯</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\ce</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">C</mi><msub><mpadded width="0px"><mphantom><mi>X</mi></mphantom></mpadded><mpadded height="0px"><mn>6</mn></mpadded></msub><mi mathvariant="normal">H</mi><msub><mpadded width="0px"><mphantom><mi>X</mi></mphantom></mpadded><mpadded height="0px"><mn>5</mn></mpadded></msub><mo lspace="0em" rspace="0em">−</mo><mrow><mi mathvariant="normal">C</mi><mi mathvariant="normal">H</mi><mi mathvariant="normal">O</mi></mrow></mrow><annotation encoding="application/x-tex">{\mathrm{C}{\vphantom{X}}_{\smash[t]{6}}\mathrm{H}{\vphantom{X}}_{\smash[t]{5}}{-}\mathrm{CHO}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathrm">C</span><span class="mord"><span class="mord"><span class="mord rlap"><span class="inner"><span class="mord" style="color:transparent;"><span class="mord mathnormal" style="margin-right:0.07847em;color:transparent;">X</span></span></span><span class="fix"></span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:-0.15em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0em;"><span style="top:-2.7em;"><span class="pstrut" style="height:2.7em;"></span><span><span class="mord mtight"><span class="mord mtight">6</span></span></span></span></span></span></span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord mathrm">H</span><span class="mord"><span class="mord"><span class="mord rlap"><span class="inner"><span class="mord" style="color:transparent;"><span class="mord mathnormal" style="margin-right:0.07847em;color:transparent;">X</span></span></span><span class="fix"></span></span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:-0.15em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0em;"><span style="top:-2.7em;"><span class="pstrut" style="height:2.7em;"></span><span><span class="mord mtight"><span class="mord mtight">5</span></span></span></span></span></span></span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord">−</span></span><span class="mord"><span class="mord mathrm">CHO</span></span></span></span></span></span> <br> <span class='katex-error' title='ParseError: KaTeX parse error: Undefined control sequence: \ce at position 1: \̲c̲e̲{C6H5-CHO}'>\ce{C6H5-CHO}</span></td>
<td style="text-align:left"><code>{\mathrm{C}{\vphantom{X}}_{\smash[t]{6}}\mathrm{H}{\vphantom{X}}_{\smash[t]{5}}{-}\mathrm{CHO}}</code> <br> or <code>\ce{C6H5-CHO}</code> Requires an <a href="https://github.com/KaTeX/KaTeX/tree/master/contrib/mhchem/" target="_blank" rel="noreferrer">extension</a></td>
</tr>
<tr>
<td style="text-align:left">\cee</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left">Deprecated by mhchem</td>
</tr>
<tr>
<td style="text-align:left">\centerdot</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mo>⋅</mo><mi>b</mi></mrow><annotation encoding="application/x-tex">a\centerdot b</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5499em;"></span><span class="mord mathnormal">a</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin amsrm">⋅</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">b</span></span></span></span></td>
<td style="text-align:left"><code>a\centerdot b</code></td>
</tr>
<tr>
<td style="text-align:left">\cf</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left">Deprecated by mhchem;</td>
</tr>
<tr>
<td style="text-align:left">use <code>\ce</code> instead</td>
<td style="text-align:left"></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\cfrac</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle displaystyle="true" scriptlevel="0"><mfrac><mn>2</mn><mrow><mn>1</mn><mo>+</mo><mstyle displaystyle="true" scriptlevel="0"><mfrac><mn>2</mn><mrow><mn>1</mn><mo>+</mo><mstyle displaystyle="true" scriptlevel="0"><mfrac><mn>2</mn><mn>1</mn></mfrac></mstyle></mrow></mfrac></mstyle></mrow></mfrac></mstyle></mrow><annotation encoding="application/x-tex">\cfrac{2}{1+\cfrac{2}{1+\cfrac{2}{1}}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:5.236em;vertical-align:-3.646em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.59em;"><span style="top:-2.11em;"><span class="pstrut" style="height:3.59em;"></span><span class="mord"><span class="mord">1</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.59em;"><span style="top:-2.11em;"><span class="pstrut" style="height:3.59em;"></span><span class="mord"><span class="mord">1</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.59em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">1</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.74em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span></span></span></span></span><span style="top:-3.82em;"><span class="pstrut" style="height:3.59em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-4.33em;"><span class="pstrut" style="height:3.59em;"></span><span class="mord"><span class="mord">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:2.166em;"><span></span></span></span></span></span><span></span></span></span></span><span style="top:-3.82em;"><span class="pstrut" style="height:3.59em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-4.33em;"><span class="pstrut" style="height:3.59em;"></span><span class="mord"><span class="mord">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:3.646em;"><span></span></span></span></span></span><span></span></span></span></span></span></td>
<td style="text-align:left"><code>\cfrac{2}{1+\cfrac{2}{1+\cfrac{2}{1}}}</code></td>
</tr>
<tr>
<td style="text-align:left">\check</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mrow><mi>o</mi><mi>e</mi></mrow><mo>ˇ</mo></mover></mrow><annotation encoding="application/x-tex">\check{oe}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6285em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6285em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">oe</span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.25em;"><span class="mord">ˇ</span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\check{oe}</code></td>
</tr>
<tr>
<td style="text-align:left">\ch</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ch</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\ch</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mop">ch</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\checkmark</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">✓</mi></mrow><annotation encoding="application/x-tex">\checkmark</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mord amsrm">✓</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Chi</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">X</mi></mrow><annotation encoding="application/x-tex">\Chi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathrm">X</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\chi</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>χ</mi></mrow><annotation encoding="application/x-tex">\chi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">χ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\choose</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true">(</mo><mfrac linethickness="0px"><mrow><mi>n</mi><mo>+</mo><mn>1</mn></mrow><mrow><mi>k</mi><mo>+</mo><mn>2</mn></mrow></mfrac><mo fence="true">)</mo></mrow><annotation encoding="application/x-tex">{n+1 \choose k+2}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2984em;vertical-align:-0.4033em;"></span><span class="mord"><span class="mord"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size1">(</span></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8951em;"><span style="top:-2.355em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.03148em;">k</span><span class="mbin mtight">+</span><span class="mord mtight">2</span></span></span></span><span style="top:-3.144em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">n</span><span class="mbin mtight">+</span><span class="mord mtight">1</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.4033em;"><span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size1">)</span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>{n+1 \choose k+2}</code></td>
</tr>
<tr>
<td style="text-align:left">\circ</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∘</mo></mrow><annotation encoding="application/x-tex">\circ</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4445em;"></span><span class="mord">∘</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\circeq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≗</mo></mrow><annotation encoding="application/x-tex">\circeq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9592em;vertical-align:-0.2296em;"></span><span class="mrel amsrm">≗</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\circlearrowleft</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↺</mo></mrow><annotation encoding="application/x-tex">\circlearrowleft</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.664em;vertical-align:-0.082em;"></span><span class="mrel amsrm">↺</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\circlearrowright</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↻</mo></mrow><annotation encoding="application/x-tex">\circlearrowright</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.664em;vertical-align:-0.082em;"></span><span class="mrel amsrm">↻</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\circledast</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊛</mo></mrow><annotation encoding="application/x-tex">\circledast</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.664em;vertical-align:-0.082em;"></span><span class="mord amsrm">⊛</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\circledcirc</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊚</mo></mrow><annotation encoding="application/x-tex">\circledcirc</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.664em;vertical-align:-0.082em;"></span><span class="mord amsrm">⊚</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\circleddash</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊝</mo></mrow><annotation encoding="application/x-tex">\circleddash</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.664em;vertical-align:-0.082em;"></span><span class="mord amsrm">⊝</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\circledR</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">®</mi></mrow><annotation encoding="application/x-tex">\circledR</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8478em;vertical-align:-0.1556em;"></span><span class="mord amsrm">®</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\circledS</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Ⓢ</mi></mrow><annotation encoding="application/x-tex">\circledS</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8478em;vertical-align:-0.1556em;"></span><span class="mord amsrm">Ⓢ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\class</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left">A PR is pending.</td>
</tr>
<tr>
<td style="text-align:left">\cline</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"><a href="https://github.com/KaTeX/KaTeX/issues/269" target="_blank" rel="noreferrer">Issue #269</a></td>
</tr>
<tr>
<td style="text-align:left">\clubs</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">♣</mi></mrow><annotation encoding="application/x-tex">\clubs</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8241em;vertical-align:-0.1296em;"></span><span class="mord">♣</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\clubsuit</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">♣</mi></mrow><annotation encoding="application/x-tex">\clubsuit</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8241em;vertical-align:-0.1296em;"></span><span class="mord">♣</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\cnums</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="double-struck">C</mi></mrow><annotation encoding="application/x-tex">\cnums</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord mathbb">C</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\colon</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mspace></mspace><mspace width="0.1111em"/><mo lspace="0em" rspace="0.17em"></mo><mtext> ⁣</mtext><mo lspace="0em" rspace="0em">:</mo><mspace width="0.3333em"/></mrow><annotation encoding="application/x-tex">\colon</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mspace nobreak"></span><span class="mspace" style="margin-right:0.1111em;"></span><span class="mpunct"></span><span class="mspace" style="margin-right:-0.1667em;"></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mrel">:</span></span><span class="mspace" style="margin-right:0.3333em;"></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Colonapprox</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mi mathvariant="normal">∷</mi><mi mathvariant="normal">≈</mi></mo></mrow><annotation encoding="application/x-tex">\Colonapprox</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4831em;"></span><span class="mrel"><span class="mrel"><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span><span class="mrel"><span class="mspace" style="margin-right:-0.05em;"></span></span><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span></span><span class="mrel"><span class="mspace" style="margin-right:-0.0667em;"></span></span><span class="mrel">≈</span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\colonapprox</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mi mathvariant="normal">:</mi><mi mathvariant="normal">≈</mi></mo></mrow><annotation encoding="application/x-tex">\colonapprox</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4831em;"></span><span class="mrel"><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span><span class="mrel"><span class="mspace" style="margin-right:-0.0667em;"></span></span><span class="mrel">≈</span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Coloneq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mi mathvariant="normal">∷</mi><mi mathvariant="normal">−</mi></mo></mrow><annotation encoding="application/x-tex">\Coloneq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mrel"><span class="mrel"><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span><span class="mrel"><span class="mspace" style="margin-right:-0.05em;"></span></span><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span></span><span class="mrel"><span class="mspace" style="margin-right:-0.0667em;"></span></span><span class="mrel"><span class="mord">−</span></span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\coloneq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mi mathvariant="normal">:</mi><mi mathvariant="normal">−</mi></mo></mrow><annotation encoding="application/x-tex">\coloneq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mrel"><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span><span class="mrel"><span class="mspace" style="margin-right:-0.0667em;"></span></span><span class="mrel"><span class="mord">−</span></span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Coloneqq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mi mathvariant="normal">∷</mi><mi mathvariant="normal">=</mi></mo></mrow><annotation encoding="application/x-tex">\Coloneqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mrel"><span class="mrel"><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span><span class="mrel"><span class="mspace" style="margin-right:-0.05em;"></span></span><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span></span><span class="mrel"><span class="mspace" style="margin-right:-0.0667em;"></span></span><span class="mrel">=</span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\coloneqq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mi mathvariant="normal">≔</mi></mo></mrow><annotation encoding="application/x-tex">\coloneqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mrel"><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span><span class="mrel"><span class="mspace" style="margin-right:-0.0667em;"></span></span><span class="mrel">=</span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Colonsim</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mi mathvariant="normal">∷</mi><mi mathvariant="normal">∼</mi></mo></mrow><annotation encoding="application/x-tex">\Colonsim</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mrel"><span class="mrel"><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span><span class="mrel"><span class="mspace" style="margin-right:-0.05em;"></span></span><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span></span><span class="mrel"><span class="mspace" style="margin-right:-0.0667em;"></span></span><span class="mrel">∼</span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\colonsim</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mi mathvariant="normal">:</mi><mi mathvariant="normal">∼</mi></mo></mrow><annotation encoding="application/x-tex">\colonsim</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mrel"><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span><span class="mrel"><span class="mspace" style="margin-right:-0.0667em;"></span></span><span class="mrel">∼</span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\color</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathcolor="#0000FF"><mi>A</mi><mi>a</mi><mi>B</mi><mi>b</mi><mn>123</mn></mstyle></mrow><annotation encoding="application/x-tex">\color{#0000FF} AaBb123</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal" style="color:#0000FF;">A</span><span class="mord mathnormal" style="color:#0000FF;">a</span><span class="mord mathnormal" style="margin-right:0.05017em;color:#0000FF;">B</span><span class="mord mathnormal" style="color:#0000FF;">b</span><span class="mord" style="color:#0000FF;">123</span></span></span></span></td>
<td style="text-align:left"><code>\color{#0000FF} AaBb123</code></td>
</tr>
<tr>
<td style="text-align:left">\colorbox</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mpadded width="+6pt" height="+6pt" lspace="3pt" voffset="3pt" mathbackground="red"><mtext>Black on red</mtext></mpadded></mrow><annotation encoding="application/x-tex">\colorbox{red}{Black on red}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2944em;vertical-align:-0.3em;"></span><span class="mord"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.9944em;"><span style="top:-2.9944em;"><span class="pstrut" style="height:3.2944em;"></span><span class="stretchy colorbox" style="height:1.2944em;background-color:red;"></span></span><span style="top:-3.2944em;"><span class="pstrut" style="height:3.2944em;"></span><span class="mord boxpad"><span class="mord">Black on red</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.3em;"><span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\colorbox{red}{Black on red}</code></td>
</tr>
<tr>
<td style="text-align:left">\complement</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∁</mi></mrow><annotation encoding="application/x-tex">\complement</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.825em;"></span><span class="mord amsrm">∁</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Complex</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="double-struck">C</mi></mrow><annotation encoding="application/x-tex">\Complex</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord mathbb">C</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\cong</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≅</mo></mrow><annotation encoding="application/x-tex">\cong</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.589em;"></span><span class="mrel">≅</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Coppa</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\coppa</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\coprod</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∐</mo></mrow><annotation encoding="application/x-tex">\coprod</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mop op-symbol small-op" style="position:relative;top:0em;">∐</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\copyright</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>©</mtext></mrow><annotation encoding="application/x-tex">\copyright</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;"></span><span class="mord text"><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8889em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">c</span></span></span><span style="top:-3.1944em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body accent-full" style="left:0em;top:.2em;"><span class="mord">◯</span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\cos</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>cos</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\cos</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mop">cos</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\cosec</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>cosec</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\cosec</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mop">cosec</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\cosh</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>cosh</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\cosh</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mop">cosh</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\cot</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>cot</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\cot</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6151em;"></span><span class="mop">cot</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\cotg</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>cotg</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\cotg</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8095em;vertical-align:-0.1944em;"></span><span class="mop">cot<span style="margin-right:0.01389em;">g</span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\coth</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>coth</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\coth</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mop">coth</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\cr</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mtable rowspacing="0.16em" columnalign="center center" columnspacing="1em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>a</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>b</mi></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>c</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>d</mi></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{matrix} a &amp; b\cr c &amp; d \end{matrix}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.4em;vertical-align:-0.95em;"></span><span class="mord"><span class="mtable"><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:0.5em;"></span><span class="arraycolsep" style="width:0.5em;"></span><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">b</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">d</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\begin{matrix}</code><br>   <code>a &amp; b \cr</code><br>   <code>c &amp; d</code><br><code>\end{matrix}</code></td>
</tr>
<tr>
<td style="text-align:left">\csc</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>csc</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\csc</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mop">csc</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\cssId</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left">A PR is pending.</td>
</tr>
<tr>
<td style="text-align:left">\ctg</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ctg</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\ctg</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8095em;vertical-align:-0.1944em;"></span><span class="mop">ct<span style="margin-right:0.01389em;">g</span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\cth</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>cth</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\cth</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mop">cth</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Cup</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋓</mo></mrow><annotation encoding="application/x-tex">\Cup</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5499em;"></span><span class="mord amsrm">⋓</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\cup</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∪</mo></mrow><annotation encoding="application/x-tex">\cup</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5556em;"></span><span class="mord">∪</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\curlyeqprec</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋞</mo></mrow><annotation encoding="application/x-tex">\curlyeqprec</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7733em;vertical-align:-0.1367em;"></span><span class="mrel amsrm">⋞</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\curlyeqsucc</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋟</mo></mrow><annotation encoding="application/x-tex">\curlyeqsucc</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7733em;vertical-align:-0.1367em;"></span><span class="mrel amsrm">⋟</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\curlyvee</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋎</mo></mrow><annotation encoding="application/x-tex">\curlyvee</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5499em;"></span><span class="mord amsrm">⋎</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\curlywedge</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋏</mo></mrow><annotation encoding="application/x-tex">\curlywedge</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5499em;"></span><span class="mord amsrm">⋏</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\curvearrowleft</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↶</mo></mrow><annotation encoding="application/x-tex">\curvearrowleft</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mrel amsrm">↶</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\curvearrowright</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↷</mo></mrow><annotation encoding="application/x-tex">\curvearrowright</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mrel amsrm">↷</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
</tbody>
</table>
<h2 id="d" tabindex="-1">D <a class="header-anchor" href="#d" aria-label="Permalink to &quot;D&quot;">&ZeroWidthSpace;</a></h2>
<table>
<thead>
<tr>
<th style="text-align:left">Symbol/Function</th>
<th style="text-align:left">Rendered</th>
<th style="text-align:left">Source or Comment</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">\dag</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">†</mi></mrow><annotation encoding="application/x-tex">\dag</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord">†</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Dagger</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>‡</mo></mrow><annotation encoding="application/x-tex">\Dagger</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord">‡</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\dagger</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>†</mo></mrow><annotation encoding="application/x-tex">\dagger</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord">†</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\daleth</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">ℸ</mi></mrow><annotation encoding="application/x-tex">\daleth</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord amsrm">ℸ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Darr</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇓</mo></mrow><annotation encoding="application/x-tex">\Darr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel">⇓</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\dArr</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇓</mo></mrow><annotation encoding="application/x-tex">\dArr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel">⇓</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\darr</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↓</mo></mrow><annotation encoding="application/x-tex">\darr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel">↓</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left" darray=""></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mtable rowspacing="0.16em" columnalign="center center" columnspacing="1em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mi>a</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mi>b</mi></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mi>c</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mi>d</mi></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{darray}{cc}a&amp;b\\c&amp;d\end{darray}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.4em;vertical-align:-0.95em;"></span><span class="mord"><span class="mtable"><span class="arraycolsep" style="width:0.5em;"></span><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:0.5em;"></span><span class="arraycolsep" style="width:0.5em;"></span><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">b</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">d</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:0.5em;"></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\begin{darray}{cc}</code><br>   <code>a &amp; b \\</code><br>   <code>c &amp; d</code><br><code>\end{darray}</code></td>
</tr>
<tr>
<td style="text-align:left">\dashleftarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇠</mo></mrow><annotation encoding="application/x-tex">\dashleftarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.437em;"></span><span class="mrel amsrm">⇠</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\dashrightarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇢</mo></mrow><annotation encoding="application/x-tex">\dashrightarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.437em;"></span><span class="mrel amsrm">⇢</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\dashv</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊣</mo></mrow><annotation encoding="application/x-tex">\dashv</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mrel">⊣</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\dbinom</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true">(</mo><mstyle displaystyle="true" scriptlevel="0"><mfrac linethickness="0px"><mi>n</mi><mi>k</mi></mfrac></mstyle><mo fence="true">)</mo></mrow><annotation encoding="application/x-tex">\dbinom n k</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.4em;vertical-align:-0.95em;"></span><span class="mord"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size3">(</span></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1076em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03148em;">k</span></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">n</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size3">)</span></span></span></span></span></span></td>
<td style="text-align:left"><code>\dbinom n k</code></td>
</tr>
<tr>
<td style="text-align:left">\dblcolon</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mi mathvariant="normal">∷</mi></mo></mrow><annotation encoding="application/x-tex">\dblcolon</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mrel"><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span><span class="mrel"><span class="mspace" style="margin-right:-0.05em;"></span></span><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left" dcases=""></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true">{</mo><mtable rowspacing="0.36em" columnalign="left left" columnspacing="1em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mi>a</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mtext>if </mtext><mi>b</mi></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mi>c</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mtext>if </mtext><mi>d</mi></mrow></mstyle></mtd></mtr></mtable></mrow><annotation encoding="application/x-tex">\begin{dcases}a&amp;\text{if }b\\c&amp;\text{if }d\end{dcases}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:3em;vertical-align:-1.25em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size4">{</span></span><span class="mord"><span class="mtable"><span class="col-align-l"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.69em;"><span style="top:-3.69em;"><span class="pstrut" style="height:3.008em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span><span style="top:-2.25em;"><span class="pstrut" style="height:3.008em;"></span><span class="mord"><span class="mord mathnormal">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.19em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:1em;"></span><span class="col-align-l"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.69em;"><span style="top:-3.69em;"><span class="pstrut" style="height:3.008em;"></span><span class="mord"><span class="mord text"><span class="mord">if </span></span><span class="mord mathnormal">b</span></span></span><span style="top:-2.25em;"><span class="pstrut" style="height:3.008em;"></span><span class="mord"><span class="mord text"><span class="mord">if </span></span><span class="mord mathnormal">d</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.19em;"><span></span></span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span></td>
<td style="text-align:left"><code>\begin{dcases}</code><br>   <code>a &amp;\text{if } b  \\</code><br>   <code>c &amp;\text{if } d</code><br><code>\end{dcases}</code></td>
</tr>
<tr>
<td style="text-align:left">\ddag</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">‡</mi></mrow><annotation encoding="application/x-tex">\ddag</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord">‡</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\ddagger</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>‡</mo></mrow><annotation encoding="application/x-tex">\ddagger</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord">‡</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\ddddot</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\dddot</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\ddot</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mi>x</mi><mo>¨</mo></mover></mrow><annotation encoding="application/x-tex">\ddot x</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6679em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6679em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord mathnormal">x</span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.2222em;"><span class="mord">¨</span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\ddot x</code></td>
</tr>
<tr>
<td style="text-align:left">\ddots</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋱</mo></mrow><annotation encoding="application/x-tex">\ddots</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.823em;"></span><span class="minner">⋱</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\DeclareMathOperator</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\def</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msup><mi>x</mi><mn>2</mn></msup><mo>+</mo><msup><mi>x</mi><mn>2</mn></msup></mrow><annotation encoding="application/x-tex">\def\foo{x^2} \foo + \foo</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8974em;vertical-align:-0.0833em;"></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.8141em;"></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\def\foo{x^2} \foo + \foo</code></td>
</tr>
<tr>
<td style="text-align:left">\definecolor</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"><a href="https://github.com/KaTeX/KaTeX/issues/750" target="_blank" rel="noreferrer">Issue #750</a></td>
</tr>
<tr>
<td style="text-align:left">\deg</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>deg</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\deg</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mop">de<span style="margin-right:0.01389em;">g</span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\degree</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">°</mi></mrow><annotation encoding="application/x-tex">\degree</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">°</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\delta</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>δ</mi></mrow><annotation encoding="application/x-tex">\delta</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal" style="margin-right:0.03785em;">δ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Delta</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Δ</mi></mrow><annotation encoding="application/x-tex">\Delta</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">Δ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\det</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>det</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\det</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mop">det</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Digamma</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\digamma</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">ϝ</mi></mrow><annotation encoding="application/x-tex">\digamma</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6633em;vertical-align:-0.0817em;"></span><span class="mord amsrm">ϝ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\dfrac</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle displaystyle="true" scriptlevel="0"><mfrac><mrow><mi>a</mi><mo>−</mo><mn>1</mn></mrow><mrow><mi>b</mi><mo>−</mo><mn>1</mn></mrow></mfrac></mstyle></mrow><annotation encoding="application/x-tex">\dfrac{a-1}{b-1}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.0908em;vertical-align:-0.7693em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.3214em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">b</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord">1</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.7693em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span></td>
<td style="text-align:left"><code>\dfrac{a-1}{b-1}</code></td>
</tr>
<tr>
<td style="text-align:left">\diagdown</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">╲</mi></mrow><annotation encoding="application/x-tex">\diagdown</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9356em;vertical-align:-0.1944em;"></span><span class="mord amsrm">╲</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\diagup</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">╱</mi></mrow><annotation encoding="application/x-tex">\diagup</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8833em;vertical-align:-0.1944em;"></span><span class="mord amsrm">╱</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Diamond</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">◊</mi></mrow><annotation encoding="application/x-tex">\Diamond</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8034em;vertical-align:-0.1111em;"></span><span class="mord amsrm">◊</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\diamond</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋄</mo></mrow><annotation encoding="application/x-tex">\diamond</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4445em;"></span><span class="mord">⋄</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\diamonds</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">♢</mi></mrow><annotation encoding="application/x-tex">\diamonds</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8241em;vertical-align:-0.1296em;"></span><span class="mord">♢</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\diamondsuit</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">♢</mi></mrow><annotation encoding="application/x-tex">\diamondsuit</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8241em;vertical-align:-0.1296em;"></span><span class="mord">♢</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\dim</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>dim</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\dim</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mop">dim</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\displaylines</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\displaystyle</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle scriptlevel="0" displaystyle="true"><munderover><mo>∑</mo><mn>0</mn><mi>n</mi></munderover></mstyle></mrow><annotation encoding="application/x-tex">\displaystyle\sum_0^n</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.9185em;vertical-align:-1.2671em;"></span><span class="mop op-limits"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.6514em;"><span style="top:-1.8829em;margin-left:0em;"><span class="pstrut" style="height:3.05em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">0</span></span></span><span style="top:-3.05em;"><span class="pstrut" style="height:3.05em;"></span><span><span class="mop op-symbol large-op">∑</span></span></span><span style="top:-4.3em;margin-left:0em;"><span class="pstrut" style="height:3.05em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">n</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.2671em;"><span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\displaystyle\sum_0^n</code></td>
</tr>
<tr>
<td style="text-align:left">\div</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>÷</mo></mrow><annotation encoding="application/x-tex">\div</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mord">÷</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\divideontimes</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋇</mo></mrow><annotation encoding="application/x-tex">\divideontimes</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6633em;vertical-align:-0.0817em;"></span><span class="mord amsrm">⋇</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\dot</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mi>x</mi><mo>˙</mo></mover></mrow><annotation encoding="application/x-tex">\dot x</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6679em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6679em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord mathnormal">x</span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.1111em;"><span class="mord">˙</span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\dot x</code></td>
</tr>
<tr>
<td style="text-align:left">\Doteq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≑</mo></mrow><annotation encoding="application/x-tex">\Doteq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.664em;vertical-align:-0.082em;"></span><span class="mrel amsrm">≑</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\doteq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≐</mo></mrow><annotation encoding="application/x-tex">\doteq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.673em;"></span><span class="mrel">≐</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\doteqdot</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≑</mo></mrow><annotation encoding="application/x-tex">\doteqdot</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.664em;vertical-align:-0.082em;"></span><span class="mrel amsrm">≑</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\dotplus</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∔</mo></mrow><annotation encoding="application/x-tex">\dotplus</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7742em;vertical-align:-0.082em;"></span><span class="mord amsrm">∔</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\dots</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>x</mi><mn>1</mn></msub><mo>+</mo><mo>⋯</mo><mo>+</mo><msub><mi>x</mi><mi>n</mi></msub></mrow><annotation encoding="application/x-tex">x_1 + \dots + x_n</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="minner">⋯</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">n</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>x_1 + \dots + x_n</code></td>
</tr>
<tr>
<td style="text-align:left">\dotsb</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>x</mi><mn>1</mn></msub><mo>+</mo><mo>⋯</mo><mo>+</mo><msub><mi>x</mi><mi>n</mi></msub></mrow><annotation encoding="application/x-tex">x_1 +\dotsb + x_n</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7333em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="minner">⋯</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">n</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>x_1 +\dotsb + x_n</code></td>
</tr>
<tr>
<td style="text-align:left">\dotsc</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>x</mi><mo separator="true">,</mo><mo>…</mo><mo separator="true">,</mo><mi>y</mi></mrow><annotation encoding="application/x-tex">x,\dotsc,y</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">x</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner">…</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">y</span></span></span></span></td>
<td style="text-align:left"><code>x,\dotsc,y</code></td>
</tr>
<tr>
<td style="text-align:left">\dotsi</td>
<td style="text-align:left">$$\int_{A_1}\int_{A_2}\dotsi$$</td>
<td style="text-align:left"><code>\int_{A_1}\int_{A_2}\dotsi</code></td>
</tr>
<tr>
<td style="text-align:left">\dotsm</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>x</mi><mn>1</mn></msub><msub><mi>x</mi><mn>2</mn></msub><mo>⋯</mo><msub><mi>x</mi><mi>n</mi></msub></mrow><annotation encoding="application/x-tex">x_1 x_2 \dotsm x_n</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5806em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner">⋯</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">n</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>$x_1 x_2 \dotsm x_n</code></td>
</tr>
<tr>
<td style="text-align:left">\dotso</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>…</mo></mrow><annotation encoding="application/x-tex">\dotso</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.123em;"></span><span class="minner">…</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\doublebarwedge</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⩞</mo></mrow><annotation encoding="application/x-tex">\doublebarwedge</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9503em;vertical-align:-0.1944em;"></span><span class="mord amsrm">⩞</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\doublecap</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋒</mo></mrow><annotation encoding="application/x-tex">\doublecap</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5499em;"></span><span class="mord amsrm">⋒</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\doublecup</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋓</mo></mrow><annotation encoding="application/x-tex">\doublecup</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5499em;"></span><span class="mord amsrm">⋓</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Downarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇓</mo></mrow><annotation encoding="application/x-tex">\Downarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel">⇓</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\downarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↓</mo></mrow><annotation encoding="application/x-tex">\downarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel">↓</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\downdownarrows</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇊</mo></mrow><annotation encoding="application/x-tex">\downdownarrows</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8867em;vertical-align:-0.1944em;"></span><span class="mrel amsrm">⇊</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\downharpoonleft</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇃</mo></mrow><annotation encoding="application/x-tex">\downharpoonleft</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8867em;vertical-align:-0.1944em;"></span><span class="mrel amsrm">⇃</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\downharpoonright</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇂</mo></mrow><annotation encoding="application/x-tex">\downharpoonright</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8867em;vertical-align:-0.1944em;"></span><span class="mrel amsrm">⇂</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left" drcases=""></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtable rowspacing="0.36em" columnalign="left left" columnspacing="1em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mi>a</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mtext>if </mtext><mi>b</mi></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mi>c</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mtext>if </mtext><mi>d</mi></mrow></mstyle></mtd></mtr></mtable><mo fence="true">}</mo></mrow><annotation encoding="application/x-tex">\begin{drcases}a&amp;\text{if }b\\c&amp;\text{if }d\end{drcases}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:3em;vertical-align:-1.25em;"></span><span class="minner"><span class="mopen nulldelimiter"></span><span class="mord"><span class="mtable"><span class="col-align-l"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.69em;"><span style="top:-3.69em;"><span class="pstrut" style="height:3.008em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span><span style="top:-2.25em;"><span class="pstrut" style="height:3.008em;"></span><span class="mord"><span class="mord mathnormal">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.19em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:1em;"></span><span class="col-align-l"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.69em;"><span style="top:-3.69em;"><span class="pstrut" style="height:3.008em;"></span><span class="mord"><span class="mord text"><span class="mord">if </span></span><span class="mord mathnormal">b</span></span></span><span style="top:-2.25em;"><span class="pstrut" style="height:3.008em;"></span><span class="mord"><span class="mord text"><span class="mord">if </span></span><span class="mord mathnormal">d</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.19em;"><span></span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size4">}</span></span></span></span></span></span></td>
<td style="text-align:left"><code>\begin{drcases}</code><br>   <code>a &amp;\text{if } b  \\</code><br>   <code>c &amp;\text{if } d</code><br><code>\end{drcases}</code></td>
</tr>
</tbody>
</table>
<h2 id="e" tabindex="-1">E <a class="header-anchor" href="#e" aria-label="Permalink to &quot;E&quot;">&ZeroWidthSpace;</a></h2>
<table>
<thead>
<tr>
<th style="text-align:left">Symbol/Function</th>
<th style="text-align:left">Rendered</th>
<th style="text-align:left">Source or Comment</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">\edef</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi></mrow><annotation encoding="application/x-tex">\def\foo{a}\edef\bar{\foo}\def\foo{}\bar</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">a</span></span></span></span></td>
<td style="text-align:left"><code>\def\foo{a}\edef\bar{\foo}\def\foo{}\bar</code></td>
</tr>
<tr>
<td style="text-align:left">\ell</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">ℓ</mi></mrow><annotation encoding="application/x-tex">\ell</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">ℓ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\else</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"><a href="https://github.com/KaTeX/KaTeX/issues/1003" target="_blank" rel="noreferrer">Issue #1003</a></td>
</tr>
<tr>
<td style="text-align:left">\em</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\emph</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\empty</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∅</mi></mrow><annotation encoding="application/x-tex">\empty</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8056em;vertical-align:-0.0556em;"></span><span class="mord">∅</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\emptyset</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∅</mi></mrow><annotation encoding="application/x-tex">\emptyset</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8056em;vertical-align:-0.0556em;"></span><span class="mord">∅</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\enclose</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left">Non standard</td>
</tr>
<tr>
<td style="text-align:left">\end</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mtable rowspacing="0.16em" columnalign="center center" columnspacing="1em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>a</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>b</mi></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>c</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>d</mi></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{matrix} a &amp; b\\ c &amp; d\end{matrix}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.4em;vertical-align:-0.95em;"></span><span class="mord"><span class="mtable"><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:0.5em;"></span><span class="arraycolsep" style="width:0.5em;"></span><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">b</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">d</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\begin{matrix}</code><br>   <code>a &amp; b \\</code><br>   <code>c &amp; d</code><br><code>\end{matrix}</code></td>
</tr>
<tr>
<td style="text-align:left">\endgroup</td>
<td style="text-align:left"><span class='katex-error' title='ParseError: KaTeX parse error: Expected &#039;}&#039;, got &#039;\endgroup&#039; at position 3: {a\̲e̲n̲d̲g̲r̲o̲u̲p̲'>{a\endgroup</span></td>
<td style="text-align:left"><code>{a\endgroup</code></td>
</tr>
<tr>
<td style="text-align:left">\enspace</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mspace width="0.5em"/><mi>b</mi></mrow><annotation encoding="application/x-tex">a\enspace b</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">a</span><span class="mspace" style="margin-right:0.5em;"></span><span class="mord mathnormal">b</span></span></span></span></td>
<td style="text-align:left"><code>a\enspace b</code></td>
</tr>
<tr>
<td style="text-align:left">\Epsilon</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">E</mi></mrow><annotation encoding="application/x-tex">\Epsilon</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathrm">E</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\epsilon</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ϵ</mi></mrow><annotation encoding="application/x-tex">\epsilon</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">ϵ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\eqalign</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\eqalignno</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\eqcirc</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≖</mo></mrow><annotation encoding="application/x-tex">\eqcirc</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mrel amsrm">≖</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Eqcolon</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mi mathvariant="normal">−</mi><mi mathvariant="normal">∷</mi></mo></mrow><annotation encoding="application/x-tex">\Eqcolon</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mrel"><span class="mrel"><span class="mord">−</span></span><span class="mrel"><span class="mspace" style="margin-right:-0.0667em;"></span></span><span class="mrel"><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span><span class="mrel"><span class="mspace" style="margin-right:-0.05em;"></span></span><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span></span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\eqcolon</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mi mathvariant="normal">∹</mi></mo></mrow><annotation encoding="application/x-tex">\eqcolon</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mrel"><span class="mrel"><span class="mord">−</span></span><span class="mrel"><span class="mspace" style="margin-right:-0.0667em;"></span></span><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left" equation=""></td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"><a href="https://github.com/KaTeX/KaTeX/issues/445" target="_blank" rel="noreferrer">Issue #445</a></td>
</tr>
<tr>
<td style="text-align:left" eqnarray=""></td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Eqqcolon</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mi mathvariant="normal">=</mi><mi mathvariant="normal">∷</mi></mo></mrow><annotation encoding="application/x-tex">\Eqqcolon</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mrel"><span class="mrel">=</span><span class="mrel"><span class="mspace" style="margin-right:-0.0667em;"></span></span><span class="mrel"><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span><span class="mrel"><span class="mspace" style="margin-right:-0.05em;"></span></span><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span></span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\eqqcolon</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mi mathvariant="normal">≕</mi></mo></mrow><annotation encoding="application/x-tex">\eqqcolon</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mrel"><span class="mrel">=</span><span class="mrel"><span class="mspace" style="margin-right:-0.0667em;"></span></span><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\eqref</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"><a href="https://github.com/KaTeX/KaTeX/issues/350" target="_blank" rel="noreferrer">Issue #350</a></td>
</tr>
<tr>
<td style="text-align:left">\eqsim</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≂</mo></mrow><annotation encoding="application/x-tex">\eqsim</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4637em;"></span><span class="mrel amsrm">≂</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\eqslantgtr</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⪖</mo></mrow><annotation encoding="application/x-tex">\eqslantgtr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7733em;vertical-align:-0.1367em;"></span><span class="mrel amsrm">⪖</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\eqslantless</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⪕</mo></mrow><annotation encoding="application/x-tex">\eqslantless</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7733em;vertical-align:-0.1367em;"></span><span class="mrel amsrm">⪕</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\equiv</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≡</mo></mrow><annotation encoding="application/x-tex">\equiv</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4637em;"></span><span class="mrel">≡</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Eta</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">H</mi></mrow><annotation encoding="application/x-tex">\Eta</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathrm">H</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\eta</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>η</mi></mrow><annotation encoding="application/x-tex">\eta</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">η</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\eth</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">ð</mi></mrow><annotation encoding="application/x-tex">\eth</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord amsrm">ð</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\euro</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\exist</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∃</mi></mrow><annotation encoding="application/x-tex">\exist</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">∃</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\exists</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∃</mi></mrow><annotation encoding="application/x-tex">\exists</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">∃</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\exp</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>exp</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\exp</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mop">exp</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\expandafter</td>
<td style="text-align:left"></td>
<td style="text-align:left"></td>
</tr>
</tbody>
</table>
<h2 id="f" tabindex="-1">F <a class="header-anchor" href="#f" aria-label="Permalink to &quot;F&quot;">&ZeroWidthSpace;</a></h2>
<table>
<thead>
<tr>
<th style="text-align:left">Symbol/Function</th>
<th style="text-align:left">Rendered</th>
<th style="text-align:left">Source or Comment</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">\fallingdotseq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≒</mo></mrow><annotation encoding="application/x-tex">\fallingdotseq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.664em;vertical-align:-0.082em;"></span><span class="mrel amsrm">≒</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\fbox</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><menclose notation="box"><mstyle scriptlevel="0" displaystyle="false"><mtext>Hi there!</mtext></mstyle></menclose></mrow><annotation encoding="application/x-tex">\fbox{Hi there!}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.3744em;vertical-align:-0.34em;"></span><span class="mord"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.0344em;"><span style="top:-3.3744em;"><span class="pstrut" style="height:3.3744em;"></span><span class="boxpad"><span class="mord"><span class="mord">Hi there!</span></span></span></span><span style="top:-3.0344em;"><span class="pstrut" style="height:3.3744em;"></span><span class="stretchy fbox" style="height:1.3744em;border-style:solid;border-width:0.04em;"></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.34em;"><span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\fbox{Hi there!}</code></td>
</tr>
<tr>
<td style="text-align:left">\fcolorbox</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mpadded width="+6pt" height="+6pt" lspace="3pt" voffset="3pt" style="border: 0.04em solid red" mathbackground="aqua"><mtext>A</mtext></mpadded></mrow><annotation encoding="application/x-tex">\fcolorbox{red}{aqua}{A}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.3633em;vertical-align:-0.34em;"></span><span class="mord"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.0233em;"><span style="top:-3.0233em;"><span class="pstrut" style="height:3.3633em;"></span><span class="stretchy fcolorbox" style="height:1.3633em;border-style:solid;border-width:0.04em;background-color:aqua;border-color:red;"></span></span><span style="top:-3.3633em;"><span class="pstrut" style="height:3.3633em;"></span><span class="mord boxpad"><span class="mord">A</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.34em;"><span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\fcolorbox{red}{aqua}{A}</code></td>
</tr>
<tr>
<td style="text-align:left">\fi</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"><a href="https://github.com/KaTeX/KaTeX/issues/1003" target="_blank" rel="noreferrer">Issue #1003</a></td>
</tr>
<tr>
<td style="text-align:left">\Finv</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Ⅎ</mi></mrow><annotation encoding="application/x-tex">\Finv</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord amsrm">Ⅎ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\flat</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">♭</mi></mrow><annotation encoding="application/x-tex">\flat</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.75em;"></span><span class="mord">♭</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\footnotesize</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathsize="0.8em"><mi>f</mi><mi>o</mi><mi>o</mi><mi>t</mi><mi>n</mi><mi>o</mi><mi>t</mi><mi>e</mi><mi>s</mi><mi>i</mi><mi>z</mi><mi>e</mi></mstyle></mrow><annotation encoding="application/x-tex">\footnotesize footnotesize</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7111em;vertical-align:-0.1556em;"></span><span class="mord mathnormal sizing reset-size6 size4" style="margin-right:0.10764em;">f</span><span class="mord mathnormal sizing reset-size6 size4">oo</span><span class="mord mathnormal sizing reset-size6 size4">t</span><span class="mord mathnormal sizing reset-size6 size4">n</span><span class="mord mathnormal sizing reset-size6 size4">o</span><span class="mord mathnormal sizing reset-size6 size4">t</span><span class="mord mathnormal sizing reset-size6 size4">es</span><span class="mord mathnormal sizing reset-size6 size4">i</span><span class="mord mathnormal sizing reset-size6 size4">ze</span></span></span></span></td>
<td style="text-align:left"><code>\footnotesize footnotesize</code></td>
</tr>
<tr>
<td style="text-align:left">\forall</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∀</mi></mrow><annotation encoding="application/x-tex">\forall</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">∀</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\frac</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mfrac><mi>a</mi><mi>b</mi></mfrac></mrow><annotation encoding="application/x-tex">\frac a b</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0404em;vertical-align:-0.345em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6954em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">b</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">a</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span></td>
<td style="text-align:left"><code>\frac a b</code></td>
</tr>
<tr>
<td style="text-align:left">\frak</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="fraktur">A</mi><mi mathvariant="fraktur">a</mi><mi mathvariant="fraktur">B</mi><mi mathvariant="fraktur">b</mi></mrow><annotation encoding="application/x-tex">\frak{AaBb}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6914em;"></span><span class="mord"><span class="mord mathfrak">AaBb</span></span></span></span></span></td>
<td style="text-align:left"><code>\frak{AaBb}</code></td>
</tr>
<tr>
<td style="text-align:left">\frown</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⌢</mo></mrow><annotation encoding="application/x-tex">\frown</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3576em;"></span><span class="mrel">⌢</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\futurelet</td>
<td style="text-align:left"></td>
<td style="text-align:left"></td>
</tr>
</tbody>
</table>
<h2 id="g" tabindex="-1">G <a class="header-anchor" href="#g" aria-label="Permalink to &quot;G&quot;">&ZeroWidthSpace;</a></h2>
<table>
<thead>
<tr>
<th style="text-align:left">Symbol/Function</th>
<th style="text-align:left">Rendered</th>
<th style="text-align:left">Source or Comment</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">\Game</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">⅁</mi></mrow><annotation encoding="application/x-tex">\Game</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord amsrm">⅁</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Gamma</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Γ</mi></mrow><annotation encoding="application/x-tex">\Gamma</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">Γ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\gamma</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>γ</mi></mrow><annotation encoding="application/x-tex">\gamma</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.05556em;">γ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left" gather=""></td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left">see <code>{gathered}</code></td>
</tr>
<tr>
<td style="text-align:left" gathered=""></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mtable rowspacing="0.25em" columnalign="center" columnspacing="0em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mi>a</mi><mo>=</mo><mi>b</mi></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mi>e</mi><mo>=</mo><mi>b</mi><mo>+</mo><mi>c</mi></mrow></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{gathered}a=b\\e=b+c\end{gathered}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:3em;vertical-align:-1.25em;"></span><span class="mord"><span class="mtable"><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.75em;"><span style="top:-3.91em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord mathnormal">b</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">e</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord mathnormal">b</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.25em;"><span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\begin{gathered}</code><br>   <code>a=b \\ </code><br>   <code>e=b+c</code><br><code>\end{gathered}</code></td>
</tr>
<tr>
<td style="text-align:left">\gcd</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>gcd</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\gcd</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mop"><span style="margin-right:0.01389em;">g</span>cd</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\gdef</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msup><mi>y</mi><mn>2</mn></msup><mo>+</mo><msup><mi>y</mi><mn>2</mn></msup></mrow><annotation encoding="application/x-tex">\gdef\bar#1{#1^2} \bar{y} + \bar{y}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0085em;vertical-align:-0.1944em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">y</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1.0085em;vertical-align:-0.1944em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">y</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\gdef\bar#1{#1^2} \bar{y} + \bar{y}</code></td>
</tr>
<tr>
<td style="text-align:left">\ge</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≥</mo></mrow><annotation encoding="application/x-tex">\ge</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mrel">≥</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\geneuro</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\geneuronarrow</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\geneurowide</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\genfrac</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true">(</mo><mstyle displaystyle="true" scriptlevel="0"><mfrac linethickness="0.2em"><mi>a</mi><mrow><mi>a</mi><mo>+</mo><mn>1</mn></mrow></mfrac></mstyle><mo fence="true">]</mo></mrow><annotation encoding="application/x-tex">\genfrac ( ] {2pt}{0}a{a+1}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.6278em;vertical-align:-1.1778em;"></span><span class="mord"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size3">(</span></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.3806em;"><span style="top:-1.9056em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord">1</span></span></span><span style="top:-3.15em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.2em;"></span></span><span style="top:-3.95em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.1778em;"><span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size3">]</span></span></span></span></span></span></td>
<td style="text-align:left"><code>\genfrac ( ] {2pt}{0}a{a+1}</code></td>
</tr>
<tr>
<td style="text-align:left">\geq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≥</mo></mrow><annotation encoding="application/x-tex">\geq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mrel">≥</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\geqq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≧</mo></mrow><annotation encoding="application/x-tex">\geqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0117em;vertical-align:-0.2558em;"></span><span class="mrel amsrm">≧</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\geqslant</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⩾</mo></mrow><annotation encoding="application/x-tex">\geqslant</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7733em;vertical-align:-0.1367em;"></span><span class="mrel amsrm">⩾</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\gets</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>←</mo></mrow><annotation encoding="application/x-tex">\gets</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">←</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\gg</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≫</mo></mrow><annotation encoding="application/x-tex">\gg</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">≫</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\ggg</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋙</mo></mrow><annotation encoding="application/x-tex">\ggg</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.585em;vertical-align:-0.0352em;"></span><span class="mrel amsrm">⋙</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\gggtr</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋙</mo></mrow><annotation encoding="application/x-tex">\gggtr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.585em;vertical-align:-0.0352em;"></span><span class="mrel amsrm">⋙</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\gimel</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">ℷ</mi></mrow><annotation encoding="application/x-tex">\gimel</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord amsrm">ℷ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\global</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>2</mn><mo>+</mo><mn>3</mn></mrow><annotation encoding="application/x-tex">\global\def\add#1#2{#1+#2} \add 2 3</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7278em;vertical-align:-0.0833em;"></span><span class="mord">2</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">3</span></span></span></span></td>
<td style="text-align:left"><code>\global\def\add#1#2{#1+#2} \add 2 3</code></td>
</tr>
<tr>
<td style="text-align:left">\gnapprox</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⪊</mo></mrow><annotation encoding="application/x-tex">\gnapprox</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0189em;vertical-align:-0.2617em;"></span><span class="mrel amsrm">⪊</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\gneq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⪈</mo></mrow><annotation encoding="application/x-tex">\gneq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mrel amsrm">⪈</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\gneqq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≩</mo></mrow><annotation encoding="application/x-tex">\gneqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0087em;vertical-align:-0.2514em;"></span><span class="mrel amsrm">≩</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\gnsim</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋧</mo></mrow><annotation encoding="application/x-tex">\gnsim</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9733em;vertical-align:-0.2322em;"></span><span class="mrel amsrm">⋧</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\grave</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mrow><mi>e</mi><mi>u</mi></mrow><mo>ˋ</mo></mover></mrow><annotation encoding="application/x-tex">\grave{eu}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6944em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">e</span><span class="mord mathnormal">u</span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.25em;"><span class="mord">ˋ</span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\grave{eu}</code></td>
</tr>
<tr>
<td style="text-align:left">\gt</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mo>&gt;</mo><mi>b</mi></mrow><annotation encoding="application/x-tex">a \gt b</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mord mathnormal">a</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">&gt;</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">b</span></span></span></span></td>
<td style="text-align:left"><code>a \gt b</code></td>
</tr>
<tr>
<td style="text-align:left">\gtrdot</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋗</mo></mrow><annotation encoding="application/x-tex">\gtrdot</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mord amsrm">⋗</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\gtrapprox</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⪆</mo></mrow><annotation encoding="application/x-tex">\gtrapprox</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0117em;vertical-align:-0.2558em;"></span><span class="mrel amsrm">⪆</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\gtreqless</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋛</mo></mrow><annotation encoding="application/x-tex">\gtreqless</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2714em;vertical-align:-0.3857em;"></span><span class="mrel amsrm">⋛</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\gtreqqless</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⪌</mo></mrow><annotation encoding="application/x-tex">\gtreqqless</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.4651em;vertical-align:-0.4826em;"></span><span class="mrel amsrm">⪌</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\gtrless</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≷</mo></mrow><annotation encoding="application/x-tex">\gtrless</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8558em;vertical-align:-0.1808em;"></span><span class="mrel amsrm">≷</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\gtrsim</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≳</mo></mrow><annotation encoding="application/x-tex">\gtrsim</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9592em;vertical-align:-0.2296em;"></span><span class="mrel amsrm">≳</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\gvertneqq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≩</mo></mrow><annotation encoding="application/x-tex">\gvertneqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0087em;vertical-align:-0.2514em;"></span><span class="mrel amsrm"></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
</tbody>
</table>
<h2 id="h" tabindex="-1">H <a class="header-anchor" href="#h" aria-label="Permalink to &quot;H&quot;">&ZeroWidthSpace;</a></h2>
<table>
<thead>
<tr>
<th style="text-align:left">Symbol/Function</th>
<th style="text-align:left">Rendered</th>
<th style="text-align:left">Source or Comment</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">\H</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mtext>a</mtext><mo>˝</mo></mover></mrow><annotation encoding="application/x-tex">\text{\H{a}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6944em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">a</span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.25em;"><span class="mord">˝</span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\H{a}}</code></td>
</tr>
<tr>
<td style="text-align:left">\Harr</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇔</mo></mrow><annotation encoding="application/x-tex">\Harr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">⇔</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\hArr</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇔</mo></mrow><annotation encoding="application/x-tex">\hArr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">⇔</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\harr</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↔</mo></mrow><annotation encoding="application/x-tex">\harr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">↔</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\hat</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mi>θ</mi><mo>^</mo></mover></mrow><annotation encoding="application/x-tex">\hat{\theta}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9579em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.9579em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord mathnormal" style="margin-right:0.02778em;">θ</span></span><span style="top:-3.2634em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.1667em;"><span class="mord">^</span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\hat{\theta}</code></td>
</tr>
<tr>
<td style="text-align:left">\hbar</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">ℏ</mi></mrow><annotation encoding="application/x-tex">\hbar</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord">ℏ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\hbox</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\hdashline</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mtable rowspacing="0.16em" columnalign="center center" columnspacing="1em" rowlines="dashed"><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>a</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>b</mi></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>c</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>d</mi></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{matrix}a&amp;b\\ \hdashline c &amp;d\end{matrix}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.4em;vertical-align:-0.95em;"></span><span class="mord"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.45em;"><span class="pstrut" style="height:3.45em;"></span><span class="mtable"><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:0.5em;"></span><span class="arraycolsep" style="width:0.5em;"></span><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">b</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">d</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span></span></span><span style="top:-3.7em;"><span class="pstrut" style="height:3.45em;"></span><span class="hdashline" style="border-bottom-width:0.04em;"></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\begin{matrix}</code><br>   <code>a &amp; b \\</code><br>   <code>\hdashline</code><br>   <code>c &amp; d</code><br><code>\end{matrix}</code></td>
</tr>
<tr>
<td style="text-align:left">\hearts</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">♡</mi></mrow><annotation encoding="application/x-tex">\hearts</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8241em;vertical-align:-0.1296em;"></span><span class="mord">♡</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\heartsuit</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">♡</mi></mrow><annotation encoding="application/x-tex">\heartsuit</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8241em;vertical-align:-0.1296em;"></span><span class="mord">♡</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\hfil</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\hfill</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left">Issues <a href="https://github.com/KaTeX/KaTeX/issues/164" target="_blank" rel="noreferrer">#164</a> &amp; <a href="https://github.com/KaTeX/KaTeX/issues/269" target="_blank" rel="noreferrer">#269</a></td>
</tr>
<tr>
<td style="text-align:left">\hline</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mtable rowspacing="0.16em" columnalign="center center" columnspacing="1em" rowlines="solid"><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>a</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>b</mi></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>c</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>d</mi></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{matrix}a&amp;b\\ \hline c &amp;d\end{matrix}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.4em;vertical-align:-0.95em;"></span><span class="mord"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.45em;"><span class="pstrut" style="height:3.45em;"></span><span class="mtable"><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:0.5em;"></span><span class="arraycolsep" style="width:0.5em;"></span><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">b</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">d</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span></span></span><span style="top:-3.7em;"><span class="pstrut" style="height:3.45em;"></span><span class="hline" style="border-bottom-width:0.04em;"></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\begin{matrix}</code><br>   <code>a &amp; b \\ \hline</code><br>   <code>c &amp; d</code><br><code>\end{matrix}</code></td>
</tr>
<tr>
<td style="text-align:left">\hom</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>hom</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\hom</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mop">hom</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\hookleftarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↩</mo></mrow><annotation encoding="application/x-tex">\hookleftarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.522em;vertical-align:-0.011em;"></span><span class="mrel">↩</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\hookrightarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↪</mo></mrow><annotation encoding="application/x-tex">\hookrightarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.522em;vertical-align:-0.011em;"></span><span class="mrel">↪</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\hphantom</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mpadded height="0px" depth="0px"><mphantom><mi>b</mi><mi>c</mi></mphantom></mpadded><mi>d</mi></mrow><annotation encoding="application/x-tex">a\hphantom{bc}d</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">a</span><span class="mord"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span><span class="mord" style="color:transparent;"><span class="mord mathnormal" style="color:transparent;">b</span><span class="mord mathnormal" style="color:transparent;">c</span></span></span></span></span></span></span></span><span class="mord mathnormal">d</span></span></span></span></td>
<td style="text-align:left"><code>a\hphantom{bc}d</code></td>
</tr>
<tr>
<td style="text-align:left">\href</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathcolor="#cc0000"><mtext>\href</mtext></mstyle></mrow><annotation encoding="application/x-tex">\href{https://katex.org/}{\KaTeX}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\href</span></span></span></span></span></td>
<td style="text-align:left"><code>\href{https://katex.org/}{\KaTeX}</code> Requires <code>trust</code></td>
</tr>
<tr>
<td style="text-align:left">\hskip</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>w</mi><mspace width="1em"/><mi>i</mi><mspace width="2em"/><mi>d</mi></mrow><annotation encoding="application/x-tex">w\hskip1em i\hskip2em d</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal" style="margin-right:0.02691em;">w</span><span class="mspace" style="margin-right:1em;"></span><span class="mord mathnormal">i</span><span class="mspace" style="margin-right:2em;"></span><span class="mord mathnormal">d</span></span></span></span></td>
<td style="text-align:left"><code>w\hskip1em i\hskip2em d</code></td>
</tr>
<tr>
<td style="text-align:left">\hslash</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">ℏ</mi></mrow><annotation encoding="application/x-tex">\hslash</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord amsrm">ℏ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\hspace</td>
<td style="text-align:left"><span class='katex-error' title='ParseError: KaTeX parse error: Invalid size: &#039;7&#039; at position 9: s\hspace7̲ex k'>s\hspace7ex k</span></td>
<td style="text-align:left"><code>s\hspace7ex k</code></td>
</tr>
<tr>
<td style="text-align:left">\htmlClass</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathcolor="#cc0000"><mtext>\htmlClass</mtext></mstyle></mrow><annotation encoding="application/x-tex">\htmlClass{foo}{x}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\htmlClass</span></span></span></span></span></td>
<td style="text-align:left"><code>\htmlClass{foo}{x}</code> Must enable <code>trust</code> and disable <code>strict</code></td>
</tr>
<tr>
<td style="text-align:left">\htmlData</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathcolor="#cc0000"><mtext>\htmlData</mtext></mstyle></mrow><annotation encoding="application/x-tex">\htmlData{foo=a, bar=b}{x}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\htmlData</span></span></span></span></span></td>
<td style="text-align:left"><code>\htmlData{foo=a, bar=b}{x}</code> Must enable <code>trust</code> and disable <code>strict</code></td>
</tr>
<tr>
<td style="text-align:left">\htmlId</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathcolor="#cc0000"><mtext>\htmlId</mtext></mstyle></mrow><annotation encoding="application/x-tex">\htmlId{bar}{x}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\htmlId</span></span></span></span></span></td>
<td style="text-align:left"><code>\htmlId{bar}{x}</code> Must enable <code>trust</code> and disable <code>strict</code></td>
</tr>
<tr>
<td style="text-align:left">\htmlStyle</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathcolor="#cc0000"><mtext>\htmlStyle</mtext></mstyle></mrow><annotation encoding="application/x-tex">\htmlStyle{color: red;}{x}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\htmlStyle</span></span></span></span></span></td>
<td style="text-align:left"><code>\htmlStyle{color: red;}{x}</code> Must enable <code>trust</code> and disable <code>strict</code></td>
</tr>
<tr>
<td style="text-align:left">\huge</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathsize="2.074em"><mi>h</mi><mi>u</mi><mi>g</mi><mi>e</mi></mstyle></mrow><annotation encoding="application/x-tex">\huge huge</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.8435em;vertical-align:-0.4033em;"></span><span class="mord mathnormal sizing reset-size6 size10">h</span><span class="mord mathnormal sizing reset-size6 size10" style="margin-right:0.03588em;">ug</span><span class="mord mathnormal sizing reset-size6 size10">e</span></span></span></span></td>
<td style="text-align:left"><code>\huge huge</code></td>
</tr>
<tr>
<td style="text-align:left">\Huge</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathsize="2.488em"><mi>H</mi><mi>u</mi><mi>g</mi><mi>e</mi></mstyle></mrow><annotation encoding="application/x-tex">\Huge Huge</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.1839em;vertical-align:-0.4838em;"></span><span class="mord mathnormal sizing reset-size6 size11" style="margin-right:0.08125em;">H</span><span class="mord mathnormal sizing reset-size6 size11" style="margin-right:0.03588em;">ug</span><span class="mord mathnormal sizing reset-size6 size11">e</span></span></span></span></td>
<td style="text-align:left"><code>\Huge Huge</code></td>
</tr>
</tbody>
</table>
<h2 id="i" tabindex="-1">I <a class="header-anchor" href="#i" aria-label="Permalink to &quot;I&quot;">&ZeroWidthSpace;</a></h2>
<table>
<thead>
<tr>
<th style="text-align:left">Symbol/Function</th>
<th style="text-align:left">Rendered</th>
<th style="text-align:left">Source or Comment</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">\i</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>ı</mtext></mrow><annotation encoding="application/x-tex">\text{\i}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord text"><span class="mord latin_fallback">ı</span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\i}</code></td>
</tr>
<tr>
<td style="text-align:left">\idotsint</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\iddots</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"><a href="https://github.com/KaTeX/KaTeX/issues/1223" target="_blank" rel="noreferrer">Issue #1223</a></td>
</tr>
<tr>
<td style="text-align:left">\if</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"><a href="https://github.com/KaTeX/KaTeX/issues/1003" target="_blank" rel="noreferrer">Issue #1003</a></td>
</tr>
<tr>
<td style="text-align:left">\iff</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>A</mi><mtext>  </mtext><mo>⟺</mo><mtext>  </mtext><mi>B</mi></mrow><annotation encoding="application/x-tex">A\iff B</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7073em;vertical-align:-0.024em;"></span><span class="mord mathnormal">A</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">⟺</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span></span></td>
<td style="text-align:left"><code>A\iff B</code></td>
</tr>
<tr>
<td style="text-align:left">\ifmode</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"><a href="https://github.com/KaTeX/KaTeX/issues/1003" target="_blank" rel="noreferrer">Issue #1003</a></td>
</tr>
<tr>
<td style="text-align:left">\ifx</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"><a href="https://github.com/KaTeX/KaTeX/issues/1003" target="_blank" rel="noreferrer">Issue #1003</a></td>
</tr>
<tr>
<td style="text-align:left">\iiiint</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\iiint</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∭</mo></mrow><annotation encoding="application/x-tex">\iiint</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.111em;vertical-align:-0.306em;"></span><span class="mop op-symbol small-op" style="margin-right:0.19445em;position:relative;top:-0.0005em;">∭</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\iint</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∬</mo></mrow><annotation encoding="application/x-tex">\iint</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.111em;vertical-align:-0.306em;"></span><span class="mop op-symbol small-op" style="margin-right:0.19445em;position:relative;top:-0.0005em;">∬</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Im</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">ℑ</mi></mrow><annotation encoding="application/x-tex">\Im</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">ℑ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\image</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">ℑ</mi></mrow><annotation encoding="application/x-tex">\image</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">ℑ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\imath</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">ı</mi></mrow><annotation encoding="application/x-tex">\imath</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal"></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\impliedby</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>P</mi><mtext>  </mtext><mo>⟸</mo><mtext>  </mtext><mi>Q</mi></mrow><annotation encoding="application/x-tex">P\impliedby Q</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7073em;vertical-align:-0.024em;"></span><span class="mord mathnormal" style="margin-right:0.13889em;">P</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">⟸</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8778em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">Q</span></span></span></span></td>
<td style="text-align:left"><code>P\impliedby Q</code></td>
</tr>
<tr>
<td style="text-align:left">\implies</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>P</mi><mtext>  </mtext><mo>⟹</mo><mtext>  </mtext><mi>Q</mi></mrow><annotation encoding="application/x-tex">P\implies Q</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7073em;vertical-align:-0.024em;"></span><span class="mord mathnormal" style="margin-right:0.13889em;">P</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">⟹</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.8778em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">Q</span></span></span></span></td>
<td style="text-align:left"><code>P\implies Q</code></td>
</tr>
<tr>
<td style="text-align:left">\in</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∈</mo></mrow><annotation encoding="application/x-tex">\in</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">∈</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\includegraphics</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathcolor="#cc0000"><mtext>\includegraphics</mtext></mstyle></mrow><annotation encoding="application/x-tex">\includegraphics[height=0.8em, totalheight=0.9em, width=0.9em, alt=KA logo]{https://cdn.kastatic.org/images/apple-touch-icon-57x57-precomposed.new.png}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord text" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\includegraphics</span></span></span></span></span></td>
<td style="text-align:left"><code>\includegraphics[height=0.8em, totalheight=0.9em, width=0.9em, alt=KA logo]{https://cdn.kastatic.org/images/apple-touch-icon-57x57-precomposed.new.png}</code> Requires <code>trust</code></td>
</tr>
<tr>
<td style="text-align:left">\inf</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>inf</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\inf</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mop">in<span style="margin-right:0.07778em;">f</span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\infin</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∞</mi></mrow><annotation encoding="application/x-tex">\infin</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord">∞</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\infty</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∞</mi></mrow><annotation encoding="application/x-tex">\infty</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord">∞</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\injlim</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\int</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∫</mo></mrow><annotation encoding="application/x-tex">\int</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1111em;vertical-align:-0.3061em;"></span><span class="mop op-symbol small-op" style="margin-right:0.19445em;position:relative;top:-0.0006em;">∫</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\intercal</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊺</mo></mrow><annotation encoding="application/x-tex">\intercal</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord amsrm">⊺</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\intop</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∫</mo></mrow><annotation encoding="application/x-tex">\intop</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1111em;vertical-align:-0.3061em;"></span><span class="mop op-symbol small-op" style="margin-right:0.19445em;position:relative;top:-0.0006em;">∫</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Iota</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">I</mi></mrow><annotation encoding="application/x-tex">\Iota</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathrm">I</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\iota</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ι</mi></mrow><annotation encoding="application/x-tex">\iota</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">ι</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\isin</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∈</mo></mrow><annotation encoding="application/x-tex">\isin</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">∈</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\it</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>A</mi><mi>a</mi><mi>B</mi><mi>b</mi></mrow><annotation encoding="application/x-tex">{\it AaBb}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord"><span class="mord"><span class="mord mathit">AaBb</span></span></span></span></span></span></td>
<td style="text-align:left"><code>{\it AaBb}</code></td>
</tr>
<tr>
<td style="text-align:left">\itshape</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
</tbody>
</table>
<h2 id="jk" tabindex="-1">JK <a class="header-anchor" href="#jk" aria-label="Permalink to &quot;JK&quot;">&ZeroWidthSpace;</a></h2>
<table>
<thead>
<tr>
<th style="text-align:left">Symbol/Function</th>
<th style="text-align:left">Rendered</th>
<th style="text-align:left">Source or Comment</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">\j</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>ȷ</mtext></mrow><annotation encoding="application/x-tex">\text{\j}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord text"><span class="mord latin_fallback">ȷ</span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\j}</code></td>
</tr>
<tr>
<td style="text-align:left">\jmath</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">ȷ</mi></mrow><annotation encoding="application/x-tex">\jmath</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal"></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Join</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋈</mo></mrow><annotation encoding="application/x-tex">\Join</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.51em;vertical-align:-0.005em;"></span><span class="mrel">⋈</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Kappa</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">K</mi></mrow><annotation encoding="application/x-tex">\Kappa</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathrm">K</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\kappa</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>κ</mi></mrow><annotation encoding="application/x-tex">\kappa</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">κ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\KaTeX</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>KaTeX</mtext></mrow><annotation encoding="application/x-tex">\KaTeX</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8988em;vertical-align:-0.2155em;"></span><span class="mord text"><span class="mord textrm">K</span><span class="mspace" style="margin-right:-0.17em;"></span><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6833em;"><span style="top:-2.905em;"><span class="pstrut" style="height:2.7em;"></span><span class="mord"><span class="mord textrm mtight sizing reset-size6 size3">A</span></span></span></span></span></span><span class="mspace" style="margin-right:-0.15em;"></span><span class="mord text"><span class="mord textrm">T</span><span class="mspace" style="margin-right:-0.1667em;"></span><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.4678em;"><span style="top:-2.7845em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord textrm">E</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2155em;"><span></span></span></span></span><span class="mspace" style="margin-right:-0.125em;"></span><span class="mord textrm">X</span></span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\ker</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ker</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\ker</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mop">ker</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\kern</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>I</mi><mspace width="-0.25em"/><mi>R</mi></mrow><annotation encoding="application/x-tex">I\kern-2.5pt R</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="mspace" style="margin-right:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.00773em;">R</span></span></span></span></td>
<td style="text-align:left"><code>I\kern-2.5pt R</code></td>
</tr>
<tr>
<td style="text-align:left">\Ket</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true">∣</mo><mi>ψ</mi><mo fence="true">⟩</mo></mrow><annotation encoding="application/x-tex">\left|\psi\right\rangle</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">∣</span><span class="mord mathnormal" style="margin-right:0.03588em;">ψ</span><span class="mclose delimcenter" style="top:0em;">⟩</span></span></span></span></span></td>
<td style="text-align:left"><code>\Ket{\psi}</code></td>
</tr>
<tr>
<td style="text-align:left">\ket</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mpadded><mi mathvariant="normal">∣</mi><mi>ψ</mi><mo stretchy="false">⟩</mo></mpadded></mrow><annotation encoding="application/x-tex">\mathinner{|{\psi}\rangle}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="minner"><span class="mord">∣</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">ψ</span></span><span class="mclose">⟩</span></span></span></span></span></td>
<td style="text-align:left"><code>\ket{\psi}</code></td>
</tr>
<tr>
<td style="text-align:left">\Koppa</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\koppa</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
</tbody>
</table>
<h2 id="l" tabindex="-1">L <a class="header-anchor" href="#l" aria-label="Permalink to &quot;L&quot;">&ZeroWidthSpace;</a></h2>
<table>
<thead>
<tr>
<th style="text-align:left">Symbol/Function</th>
<th style="text-align:left">Rendered</th>
<th style="text-align:left">Source or Comment</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">\L</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\l</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Lambda</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Λ</mi></mrow><annotation encoding="application/x-tex">\Lambda</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">Λ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\lambda</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>λ</mi></mrow><annotation encoding="application/x-tex">\lambda</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">λ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\label</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\land</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∧</mo></mrow><annotation encoding="application/x-tex">\land</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5556em;"></span><span class="mord">∧</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\lang</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">⟨</mo><mi>A</mi><mo stretchy="false">⟩</mo></mrow><annotation encoding="application/x-tex">\lang A\rangle</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">⟨</span><span class="mord mathnormal">A</span><span class="mclose">⟩</span></span></span></span></td>
<td style="text-align:left"><code>\lang A\rangle</code></td>
</tr>
<tr>
<td style="text-align:left">\langle</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">⟨</mo><mi>A</mi><mo stretchy="false">⟩</mo></mrow><annotation encoding="application/x-tex">\langle A\rangle</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">⟨</span><span class="mord mathnormal">A</span><span class="mclose">⟩</span></span></span></span></td>
<td style="text-align:left"><code>\langle A\rangle</code></td>
</tr>
<tr>
<td style="text-align:left">\Larr</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇐</mo></mrow><annotation encoding="application/x-tex">\Larr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">⇐</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\lArr</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇐</mo></mrow><annotation encoding="application/x-tex">\lArr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">⇐</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\larr</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>←</mo></mrow><annotation encoding="application/x-tex">\larr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">←</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\large</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathsize="1.2em"><mi>l</mi><mi>a</mi><mi>r</mi><mi>g</mi><mi>e</mi></mstyle></mrow><annotation encoding="application/x-tex">\large large</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0667em;vertical-align:-0.2333em;"></span><span class="mord mathnormal sizing reset-size6 size7" style="margin-right:0.01968em;">l</span><span class="mord mathnormal sizing reset-size6 size7">a</span><span class="mord mathnormal sizing reset-size6 size7" style="margin-right:0.02778em;">r</span><span class="mord mathnormal sizing reset-size6 size7" style="margin-right:0.03588em;">g</span><span class="mord mathnormal sizing reset-size6 size7">e</span></span></span></span></td>
<td style="text-align:left"><code>\large large</code></td>
</tr>
<tr>
<td style="text-align:left">\Large</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathsize="1.44em"><mi>L</mi><mi>a</mi><mi>r</mi><mi>g</mi><mi>e</mi></mstyle></mrow><annotation encoding="application/x-tex">\Large Large</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.264em;vertical-align:-0.28em;"></span><span class="mord mathnormal sizing reset-size6 size8">L</span><span class="mord mathnormal sizing reset-size6 size8">a</span><span class="mord mathnormal sizing reset-size6 size8" style="margin-right:0.02778em;">r</span><span class="mord mathnormal sizing reset-size6 size8" style="margin-right:0.03588em;">g</span><span class="mord mathnormal sizing reset-size6 size8">e</span></span></span></span></td>
<td style="text-align:left"><code>\Large Large</code></td>
</tr>
<tr>
<td style="text-align:left">\LARGE</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathsize="1.728em"><mi>L</mi><mi>A</mi><mi>R</mi><mi>G</mi><mi>E</mi></mstyle></mrow><annotation encoding="application/x-tex">\LARGE LARGE</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1808em;"></span><span class="mord mathnormal sizing reset-size6 size9">L</span><span class="mord mathnormal sizing reset-size6 size9">A</span><span class="mord mathnormal sizing reset-size6 size9" style="margin-right:0.05764em;">RGE</span></span></span></span></td>
<td style="text-align:left"><code>\LARGE LARGE</code></td>
</tr>
<tr>
<td style="text-align:left">\LaTeX</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>LaTeX</mtext></mrow><annotation encoding="application/x-tex">\LaTeX</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8988em;vertical-align:-0.2155em;"></span><span class="mord text"><span class="mord textrm">L</span><span class="mspace" style="margin-right:-0.36em;"></span><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6833em;"><span style="top:-2.905em;"><span class="pstrut" style="height:2.7em;"></span><span class="mord"><span class="mord textrm mtight sizing reset-size6 size3">A</span></span></span></span></span></span><span class="mspace" style="margin-right:-0.15em;"></span><span class="mord text"><span class="mord textrm">T</span><span class="mspace" style="margin-right:-0.1667em;"></span><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.4678em;"><span style="top:-2.7845em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord textrm">E</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2155em;"><span></span></span></span></span><span class="mspace" style="margin-right:-0.125em;"></span><span class="mord textrm">X</span></span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\lBrace</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo mathvariant="normal" lspace="0em" rspace="0em">⦃</mo></mrow><annotation encoding="application/x-tex">\lBrace</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen"><span class="mopen">{</span><span class="mspace" style="margin-right:-0.1778em;"></span><span class="mopen">[</span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\lbrace</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">{</mo></mrow><annotation encoding="application/x-tex">\lbrace</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">{</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\lbrack</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">[</mo></mrow><annotation encoding="application/x-tex">\lbrack</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">[</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\lceil</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">⌈</mo></mrow><annotation encoding="application/x-tex">\lceil</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">⌈</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\ldotp</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo separator="true">.</mo></mrow><annotation encoding="application/x-tex">\ldotp</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.1056em;"></span><span class="mpunct">.</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\ldots</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>…</mo></mrow><annotation encoding="application/x-tex">\ldots</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.123em;"></span><span class="minner">…</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\le</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≤</mo></mrow><annotation encoding="application/x-tex">\le</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mrel">≤</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\leadsto</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇝</mo></mrow><annotation encoding="application/x-tex">\leadsto</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3779em;"></span><span class="mrel amsrm">⇝</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\left</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true">{</mo><mstyle displaystyle="true" scriptlevel="0"><mfrac><mi>a</mi><mi>b</mi></mfrac></mstyle></mrow><annotation encoding="application/x-tex">\left\lbrace \dfrac ab \right.</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.836em;vertical-align:-0.686em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size2">{</span></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1076em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">b</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mclose nulldelimiter"></span></span></span></span></span></td>
<td style="text-align:left"><code>\left\lbrace \dfrac ab \right.</code></td>
</tr>
<tr>
<td style="text-align:left">\leftarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>←</mo></mrow><annotation encoding="application/x-tex">\leftarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">←</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Leftarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇐</mo></mrow><annotation encoding="application/x-tex">\Leftarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">⇐</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\LeftArrow</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left">Non standard</td>
</tr>
<tr>
<td style="text-align:left">\leftarrowtail</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\leftharpoondown</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↽</mo></mrow><annotation encoding="application/x-tex">\leftharpoondown</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">↽</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\leftharpoonup</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↼</mo></mrow><annotation encoding="application/x-tex">\leftharpoonup</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">↼</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\leftleftarrows</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇇</mo></mrow><annotation encoding="application/x-tex">\leftleftarrows</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8558em;vertical-align:-0.1808em;"></span><span class="mrel amsrm">⇇</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Leftrightarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇔</mo></mrow><annotation encoding="application/x-tex">\Leftrightarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">⇔</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\leftrightarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↔</mo></mrow><annotation encoding="application/x-tex">\leftrightarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">↔</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\leftrightarrows</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇆</mo></mrow><annotation encoding="application/x-tex">\leftrightarrows</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8558em;vertical-align:-0.1808em;"></span><span class="mrel amsrm">⇆</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\leftrightharpoons</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇋</mo></mrow><annotation encoding="application/x-tex">\leftrightharpoons</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5359em;vertical-align:-0.0135em;"></span><span class="mrel amsrm">⇋</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\leftrightsquigarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↭</mo></mrow><annotation encoding="application/x-tex">\leftrightsquigarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3779em;"></span><span class="mrel amsrm">↭</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\leftroot</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\leftthreetimes</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋋</mo></mrow><annotation encoding="application/x-tex">\leftthreetimes</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mord amsrm">⋋</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\leq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≤</mo></mrow><annotation encoding="application/x-tex">\leq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mrel">≤</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\leqalignno</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\leqq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≦</mo></mrow><annotation encoding="application/x-tex">\leqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0117em;vertical-align:-0.2558em;"></span><span class="mrel amsrm">≦</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\leqslant</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⩽</mo></mrow><annotation encoding="application/x-tex">\leqslant</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7733em;vertical-align:-0.1367em;"></span><span class="mrel amsrm">⩽</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\lessapprox</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⪅</mo></mrow><annotation encoding="application/x-tex">\lessapprox</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0117em;vertical-align:-0.2558em;"></span><span class="mrel amsrm">⪅</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\lessdot</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋖</mo></mrow><annotation encoding="application/x-tex">\lessdot</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mord amsrm">⋖</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\lesseqgtr</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋚</mo></mrow><annotation encoding="application/x-tex">\lesseqgtr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2714em;vertical-align:-0.3857em;"></span><span class="mrel amsrm">⋚</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\lesseqqgtr</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⪋</mo></mrow><annotation encoding="application/x-tex">\lesseqqgtr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.4651em;vertical-align:-0.4826em;"></span><span class="mrel amsrm">⪋</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\lessgtr</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≶</mo></mrow><annotation encoding="application/x-tex">\lessgtr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8558em;vertical-align:-0.1808em;"></span><span class="mrel amsrm">≶</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\lesssim</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≲</mo></mrow><annotation encoding="application/x-tex">\lesssim</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9592em;vertical-align:-0.2296em;"></span><span class="mrel amsrm">≲</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\let</td>
<td style="text-align:left"></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\lfloor</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">⌊</mo></mrow><annotation encoding="application/x-tex">\lfloor</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">⌊</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\lg</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>lg</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\lg</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mop">l<span style="margin-right:0.01389em;">g</span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\lgroup</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">⟮</mo></mrow><annotation encoding="application/x-tex">\lgroup</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.988em;vertical-align:-0.244em;"></span><span class="mopen">⟮</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\lhd</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊲</mo></mrow><annotation encoding="application/x-tex">\lhd</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.585em;vertical-align:-0.0352em;"></span><span class="mord amsrm">⊲</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\lim</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>lim</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\lim</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mop">lim</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\liminf</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">lim inf</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\liminf</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mop"><span class="mord mathrm">lim</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathrm" style="margin-right:0.07778em;">inf</span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\limits</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><munder><mrow><mi>lim</mi><mo>⁡</mo></mrow><mi>x</mi></munder></mrow><annotation encoding="application/x-tex">\lim\limits_x</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.3944em;vertical-align:-0.7em;"></span><span class="mop op-limits"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6944em;"><span style="top:-2.4em;margin-left:0em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">x</span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span><span class="mop">lim</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.7em;"><span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\lim\limits_x</code></td>
</tr>
<tr>
<td style="text-align:left">\limsup</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">lim sup</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\limsup</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mop"><span class="mord mathrm">lim</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathrm">sup</span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\ll</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≪</mo></mrow><annotation encoding="application/x-tex">\ll</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">≪</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\llap</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo lspace="0em" rspace="0em">=</mo><mpadded lspace="-1width" width="0px"><mrow><mtext>/</mtext><mtext> </mtext></mrow></mpadded></mrow><annotation encoding="application/x-tex">{=}\llap{/\,}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord"><span class="mrel">=</span></span><span class="mord vbox"><span class="thinbox"><span class="llap"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="inner"><span class="mord"><span class="mord text"><span class="mord textrm">/</span><span class="mspace" style="margin-right:0.1667em;"></span></span></span></span><span class="fix"></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>{=}\llap{/\,}</code></td>
</tr>
<tr>
<td style="text-align:left">\llbracket</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo mathvariant="normal" lspace="0em" rspace="0em">⟦</mo></mrow><annotation encoding="application/x-tex">\llbracket</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen"><span class="mopen">[</span><span class="mspace" style="margin-right:-0.1778em;"></span><span class="mopen">[</span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\llcorner</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mi mathvariant="normal">⌞</mi></mo></mrow><annotation encoding="application/x-tex">\llcorner</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3779em;"></span><span class="mopen amsrm">└</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Lleftarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇚</mo></mrow><annotation encoding="application/x-tex">\Lleftarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7733em;vertical-align:-0.1367em;"></span><span class="mrel amsrm">⇚</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\lll</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋘</mo></mrow><annotation encoding="application/x-tex">\lll</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.585em;vertical-align:-0.0352em;"></span><span class="mrel amsrm">⋘</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\llless</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋘</mo></mrow><annotation encoding="application/x-tex">\llless</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.585em;vertical-align:-0.0352em;"></span><span class="mrel amsrm">⋘</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\lmoustache</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">⎰</mo></mrow><annotation encoding="application/x-tex">\lmoustache</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.988em;vertical-align:-0.244em;"></span><span class="mopen">⎰</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\ln</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ln</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\ln</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mop">ln</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\lnapprox</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⪉</mo></mrow><annotation encoding="application/x-tex">\lnapprox</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0189em;vertical-align:-0.2617em;"></span><span class="mrel amsrm">⪉</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\lneq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⪇</mo></mrow><annotation encoding="application/x-tex">\lneq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mrel amsrm">⪇</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\lneqq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≨</mo></mrow><annotation encoding="application/x-tex">\lneqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0087em;vertical-align:-0.2514em;"></span><span class="mrel amsrm">≨</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\lnot</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">¬</mi></mrow><annotation encoding="application/x-tex">\lnot</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord">¬</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\lnsim</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋦</mo></mrow><annotation encoding="application/x-tex">\lnsim</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9733em;vertical-align:-0.2322em;"></span><span class="mrel amsrm">⋦</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\log</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>log</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\log</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mop">lo<span style="margin-right:0.01389em;">g</span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\long</td>
<td style="text-align:left"></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Longleftarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⟸</mo></mrow><annotation encoding="application/x-tex">\Longleftarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.549em;vertical-align:-0.024em;"></span><span class="mrel">⟸</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\longleftarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⟵</mo></mrow><annotation encoding="application/x-tex">\longleftarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.522em;vertical-align:-0.011em;"></span><span class="mrel">⟵</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Longleftrightarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⟺</mo></mrow><annotation encoding="application/x-tex">\Longleftrightarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.549em;vertical-align:-0.024em;"></span><span class="mrel">⟺</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\longleftrightarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⟷</mo></mrow><annotation encoding="application/x-tex">\longleftrightarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.522em;vertical-align:-0.011em;"></span><span class="mrel">⟷</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\longmapsto</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⟼</mo></mrow><annotation encoding="application/x-tex">\longmapsto</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.522em;vertical-align:-0.011em;"></span><span class="mrel">⟼</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Longrightarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⟹</mo></mrow><annotation encoding="application/x-tex">\Longrightarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.549em;vertical-align:-0.024em;"></span><span class="mrel">⟹</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\longrightarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⟶</mo></mrow><annotation encoding="application/x-tex">\longrightarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.522em;vertical-align:-0.011em;"></span><span class="mrel">⟶</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\looparrowleft</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↫</mo></mrow><annotation encoding="application/x-tex">\looparrowleft</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5499em;"></span><span class="mrel amsrm">↫</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\looparrowright</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↬</mo></mrow><annotation encoding="application/x-tex">\looparrowright</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5499em;"></span><span class="mrel amsrm">↬</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\lor</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∨</mo></mrow><annotation encoding="application/x-tex">\lor</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5556em;"></span><span class="mord">∨</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\lower</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\lozenge</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">◊</mi></mrow><annotation encoding="application/x-tex">\lozenge</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8034em;vertical-align:-0.1111em;"></span><span class="mord amsrm">◊</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\lparen</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">(</mo></mrow><annotation encoding="application/x-tex">\lparen</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">(</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Lrarr</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇔</mo></mrow><annotation encoding="application/x-tex">\Lrarr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">⇔</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\lrArr</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇔</mo></mrow><annotation encoding="application/x-tex">\lrArr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">⇔</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\lrarr</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↔</mo></mrow><annotation encoding="application/x-tex">\lrarr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">↔</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\lrcorner</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mi mathvariant="normal">⌟</mi></mo></mrow><annotation encoding="application/x-tex">\lrcorner</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3779em;"></span><span class="mclose amsrm">┘</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\lq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">‘</mi></mrow><annotation encoding="application/x-tex">\lq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">‘</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Lsh</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↰</mo></mrow><annotation encoding="application/x-tex">\Lsh</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mrel amsrm">↰</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\lt</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>&lt;</mo></mrow><annotation encoding="application/x-tex">\lt</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">&lt;</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\ltimes</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋉</mo></mrow><annotation encoding="application/x-tex">\ltimes</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6633em;vertical-align:-0.0817em;"></span><span class="mord amsrm">⋉</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\lVert</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">∥</mo></mrow><annotation encoding="application/x-tex">\lVert</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">∥</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\lvert</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">∣</mo></mrow><annotation encoding="application/x-tex">\lvert</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">∣</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\lvertneqq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≨</mo></mrow><annotation encoding="application/x-tex">\lvertneqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0087em;vertical-align:-0.2514em;"></span><span class="mrel amsrm"></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
</tbody>
</table>
<h2 id="m" tabindex="-1">M <a class="header-anchor" href="#m" aria-label="Permalink to &quot;M&quot;">&ZeroWidthSpace;</a></h2>
<table>
<thead>
<tr>
<th style="text-align:left">Symbol/Function</th>
<th style="text-align:left">Rendered</th>
<th style="text-align:left">Source or Comment</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">\maltese</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">✠</mi></mrow><annotation encoding="application/x-tex">\maltese</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mord amsrm">✠</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\mapsto</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↦</mo></mrow><annotation encoding="application/x-tex">\mapsto</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.522em;vertical-align:-0.011em;"></span><span class="mrel">↦</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\mathbb</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="double-struck">A</mi><mi mathvariant="double-struck">B</mi></mrow><annotation encoding="application/x-tex">\mathbb{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord"><span class="mord mathbb">AB</span></span></span></span></span></td>
<td style="text-align:left"><code>\mathbb{AB}</code><br>KaTeX supports A-Z k</td>
</tr>
<tr>
<td style="text-align:left">\mathbf</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="bold">A</mi><mi mathvariant="bold">a</mi><mi mathvariant="bold">B</mi><mi mathvariant="bold">b</mi><mn mathvariant="bold">123</mn></mrow><annotation encoding="application/x-tex">\mathbf{AaBb123}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord"><span class="mord mathbf">AaBb123</span></span></span></span></span></td>
<td style="text-align:left"><code>\mathbf{AaBb123}</code></td>
</tr>
<tr>
<td style="text-align:left">\mathbin</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mo stretchy="false" lspace="0.22em" rspace="0.22em">!</mo><mi>b</mi></mrow><annotation encoding="application/x-tex">a\mathbin{!}b</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">a</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin"><span class="mclose">!</span></span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">b</span></span></span></span></td>
<td style="text-align:left"><code>a\mathbin{!}b</code></td>
</tr>
<tr>
<td style="text-align:left">\mathcal</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="script">A</mi><mi mathvariant="script">a</mi><mi mathvariant="script">B</mi><mi mathvariant="script">b</mi><mn mathvariant="script">123</mn></mrow><annotation encoding="application/x-tex">\mathcal{AaBb123}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord"><span class="mord mathcal">A</span><span class="mord mathnormal">a</span><span class="mord mathcal" style="margin-right:0.03041em;">B</span><span class="mord mathnormal">b</span><span class="mord">123</span></span></span></span></span></td>
<td style="text-align:left"><code>\mathcal{AaBb123}</code></td>
</tr>
<tr>
<td style="text-align:left">\mathchoice</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mrow><mtext> </mtext><mtext> </mtext></mrow><mi>b</mi></mrow><annotation encoding="application/x-tex">a\mathchoice{\,}{\,\,}{\,\,\,}{\,\,\,\,}b</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">a</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">b</span></span></span></span></td>
<td style="text-align:left"><code>a\mathchoice{\,}{\,\,}{\,\,\,}{\,\,\,\,}b</code></td>
</tr>
<tr>
<td style="text-align:left">\mathclap</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle scriptlevel="0" displaystyle="true"><munder><mo>∑</mo><mpadded lspace="-0.5width" width="0px"><mrow><mn>1</mn><mo>≤</mo><mi>i</mi><mo>≤</mo><mi>n</mi></mrow></mpadded></munder><msub><mi>x</mi><mi>i</mi></msub></mstyle></mrow><annotation encoding="application/x-tex">\displaystyle\sum_{\mathclap{1\le i\le n}} x_{i}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.4229em;vertical-align:-1.3728em;"></span><span class="mop op-limits"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.05em;"><span style="top:-1.8723em;margin-left:0em;"><span class="pstrut" style="height:3.05em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord vbox mtight"><span class="thinbox mtight"><span class="clap mtight"><span class="strut" style="height:0.7955em;vertical-align:-0.136em;"></span><span class="inner mtight"><span><span class="mord mtight"><span class="mord mtight">1</span><span class="mrel mtight">≤</span><span class="mord mathnormal mtight">i</span><span class="mrel mtight">≤</span><span class="mord mathnormal mtight">n</span></span></span></span><span class="fix"></span></span></span></span></span></span></span><span style="top:-3.05em;"><span class="pstrut" style="height:3.05em;"></span><span><span class="mop op-symbol large-op">∑</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.3728em;"><span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3117em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">i</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\sum_{\mathclap{1\le i\le n}} x_{i}</code></td>
</tr>
<tr>
<td style="text-align:left">\mathclose</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mo>+</mo><mo stretchy="false">(</mo><mi>b</mi><mo lspace="0em" rspace="0em">&gt;</mo><mo>+</mo><mi>c</mi></mrow><annotation encoding="application/x-tex">a + (b\mathclose\gt + c</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mord mathnormal">a</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">(</span><span class="mord mathnormal">b</span><span class="mclose"><span class="mrel">&gt;</span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">c</span></span></span></span></td>
<td style="text-align:left"><code>a + (b\mathclose\gt + c</code></td>
</tr>
<tr>
<td style="text-align:left">\mathellipsis</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>…</mo></mrow><annotation encoding="application/x-tex">\mathellipsis</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.123em;"></span><span class="minner">…</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\mathfrak</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="fraktur">A</mi><mi mathvariant="fraktur">a</mi><mi mathvariant="fraktur">B</mi><mi mathvariant="fraktur">b</mi></mrow><annotation encoding="application/x-tex">\mathfrak{AaBb}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6914em;"></span><span class="mord"><span class="mord mathfrak">AaBb</span></span></span></span></span></td>
<td style="text-align:left"><code>\mathfrak{AaBb}</code><br>KaTeX supports A-Za-z</td>
</tr>
<tr>
<td style="text-align:left">\mathinner</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mi>b</mi><mpadded><mtext>inside</mtext></mpadded><mi>c</mi><mi>d</mi></mrow><annotation encoding="application/x-tex">ab\mathinner{\text{inside}}cd</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">ab</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mord text"><span class="mord">inside</span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">c</span><span class="mord mathnormal">d</span></span></span></span></td>
<td style="text-align:left"><code>ab\mathinner{\text{inside}}cd</code></td>
</tr>
<tr>
<td style="text-align:left">\mathit</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>A</mi><mi>a</mi><mi>B</mi><mi>b</mi></mrow><annotation encoding="application/x-tex">\mathit{AaBb}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord"><span class="mord mathit">AaBb</span></span></span></span></span></td>
<td style="text-align:left"><code>\mathit{AaBb}</code><br>KaTeX supports A-Za-z</td>
</tr>
<tr>
<td style="text-align:left">\mathllap</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo lspace="0em" rspace="0em">=</mo><mpadded lspace="-1width" width="0px"><mrow><mi mathvariant="normal">/</mi><mtext> </mtext></mrow></mpadded></mrow><annotation encoding="application/x-tex">{=}\mathllap{/\,}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord"><span class="mrel">=</span></span><span class="mord vbox"><span class="thinbox"><span class="llap"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="inner"><span class="mord"><span class="mord">/</span><span class="mspace" style="margin-right:0.1667em;"></span></span></span><span class="fix"></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>{=}\mathllap{/\,}</code></td>
</tr>
<tr>
<td style="text-align:left">\mathnormal</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>A</mi><mi>a</mi><mi>B</mi><mi>b</mi></mrow><annotation encoding="application/x-tex">\mathnormal{AaBb}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord"><span class="mord mathnormal">A</span><span class="mord mathnormal">a</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span><span class="mord mathnormal">b</span></span></span></span></span></td>
<td style="text-align:left"><code>\mathnormal{AaBb}</code><br>KaTeX supports A-Za-z</td>
</tr>
<tr>
<td style="text-align:left">\mathop</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msubsup><mo><mo>⋆</mo></mo><mi>a</mi><mi>b</mi></msubsup></mrow><annotation encoding="application/x-tex">\mathop{\star}_a^b</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0961em;vertical-align:-0.247em;"></span><span class="mop"><span class="mop">⋆</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8491em;"><span style="top:-2.453em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">a</span></span></span><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">b</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.247em;"><span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\mathop{\star}_a^b</code></td>
</tr>
<tr>
<td style="text-align:left">\mathopen</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mo>+</mo><mo lspace="0em" rspace="0em">&lt;</mo><mi>b</mi><mo stretchy="false">)</mo><mo>+</mo><mi>c</mi></mrow><annotation encoding="application/x-tex">a + \mathopen\lt b) + c</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mord mathnormal">a</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen"><span class="mrel">&lt;</span></span><span class="mord mathnormal">b</span><span class="mclose">)</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">c</span></span></span></span></td>
<td style="text-align:left"><code>a + \mathopen\lt b) + c</code></td>
</tr>
<tr>
<td style="text-align:left">\mathord</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>1</mn><mi separator="true">,</mi><mn>234</mn><mo separator="true" lspace="0em" rspace="0em">,</mo><mn>567</mn></mrow><annotation encoding="application/x-tex">1\mathord{,}234{,}567</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8389em;vertical-align:-0.1944em;"></span><span class="mord">1</span><span class="mord"><span class="mpunct">,</span></span><span class="mord">234</span><span class="mord"><span class="mpunct">,</span></span><span class="mord">567</span></span></span></span></td>
<td style="text-align:left"><code>1\mathord{,}234{,}567</code></td>
</tr>
<tr>
<td style="text-align:left">\mathpunct</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>A</mi><mo lspace="0em" rspace="0.17em">−</mo><mi>B</mi></mrow><annotation encoding="application/x-tex">A\mathpunct{-}B</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7667em;vertical-align:-0.0833em;"></span><span class="mord mathnormal">A</span><span class="mpunct"><span class="mord">−</span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span></span></td>
<td style="text-align:left"><code>A\mathpunct{-}B</code></td>
</tr>
<tr>
<td style="text-align:left">\mathrel</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mo mathvariant="normal">#</mo><mi>b</mi></mrow><annotation encoding="application/x-tex">a \mathrel{\#} b</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">a</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel"><span class="mord">#</span></span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">b</span></span></span></span></td>
<td style="text-align:left"><code>a \mathrel{\#} b</code></td>
</tr>
<tr>
<td style="text-align:left">\mathrlap</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mpadded width="0px"><mrow><mtext> </mtext><mi mathvariant="normal">/</mi></mrow></mpadded><mo lspace="0em" rspace="0em">=</mo></mrow><annotation encoding="application/x-tex">\mathrlap{\,/}{=}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord vbox"><span class="thinbox"><span class="rlap"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="inner"><span class="mord"><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord">/</span></span></span><span class="fix"></span></span></span></span><span class="mord"><span class="mrel">=</span></span></span></span></span></td>
<td style="text-align:left"><code>\mathrlap{\,/}{=}</code></td>
</tr>
<tr>
<td style="text-align:left">\mathring</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mi>a</mi><mo>˚</mo></mover></mrow><annotation encoding="application/x-tex">\mathring{a}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6944em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord mathnormal">a</span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.375em;"><span class="mord">˚</span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\mathring{a}</code></td>
</tr>
<tr>
<td style="text-align:left">\mathrm</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">A</mi><mi mathvariant="normal">a</mi><mi mathvariant="normal">B</mi><mi mathvariant="normal">b</mi><mn>123</mn></mrow><annotation encoding="application/x-tex">\mathrm{AaBb123}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord"><span class="mord mathrm">AaBb123</span></span></span></span></span></td>
<td style="text-align:left"><code>\mathrm{AaBb123}</code></td>
</tr>
<tr>
<td style="text-align:left">\mathscr</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="script">A</mi><mi mathvariant="script">B</mi></mrow><annotation encoding="application/x-tex">\mathscr{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7em;"></span><span class="mord"><span class="mord mathscr" style="margin-right:0.04087em;">AB</span></span></span></span></span></td>
<td style="text-align:left"><code>\mathscr{AaBb123}</code><br>KaTeX supports A-Z</td>
</tr>
<tr>
<td style="text-align:left">\mathsf</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="sans-serif">A</mi><mi mathvariant="sans-serif">a</mi><mi mathvariant="sans-serif">B</mi><mi mathvariant="sans-serif">b</mi><mn mathvariant="sans-serif">123</mn></mrow><annotation encoding="application/x-tex">\mathsf{AaBb123}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord"><span class="mord mathsf">AaBb123</span></span></span></span></span></td>
<td style="text-align:left"><code>\mathsf{AaBb123}</code></td>
</tr>
<tr>
<td style="text-align:left">\mathsterling</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">£</mi></mrow><annotation encoding="application/x-tex">\mathsterling</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">£</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\mathstrut</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\mathtip</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\mathtt</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="monospace">A</mi><mi mathvariant="monospace">a</mi><mi mathvariant="monospace">B</mi><mi mathvariant="monospace">b</mi><mn mathvariant="monospace">123</mn></mrow><annotation encoding="application/x-tex">\mathtt{AaBb123}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6111em;"></span><span class="mord"><span class="mord mathtt">AaBb123</span></span></span></span></span></td>
<td style="text-align:left"><code>\mathtt{AaBb123}</code></td>
</tr>
<tr>
<td style="text-align:left">\matrix</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left">See <code>{matrix}</code></td>
</tr>
<tr>
<td style="text-align:left" matrix=""></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mtable rowspacing="0.16em" columnalign="center center" columnspacing="1em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>a</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>b</mi></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>c</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>d</mi></mstyle></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{matrix}a&amp;b\\c&amp;d\end{matrix}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.4em;vertical-align:-0.95em;"></span><span class="mord"><span class="mtable"><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:0.5em;"></span><span class="arraycolsep" style="width:0.5em;"></span><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">b</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">d</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\begin{matrix}</code><br>   <code>a &amp; b \\</code><br>   <code>c &amp; d</code><br><code>\end{matrix}</code></td>
</tr>
<tr>
<td style="text-align:left">\max</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>max</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\max</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mop">max</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\mbox</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\md</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\mdseries</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\measuredangle</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∡</mi></mrow><annotation encoding="application/x-tex">\measuredangle</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mord amsrm">∡</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\medspace</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mtext> </mtext><mi>b</mi></mrow><annotation encoding="application/x-tex">a\medspace b</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">a</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal">b</span></span></span></span></td>
<td style="text-align:left"><code>a\medspace b</code></td>
</tr>
<tr>
<td style="text-align:left">\mho</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">℧</mi></mrow><annotation encoding="application/x-tex">\mho</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord amsrm">℧</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\mid</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">{</mo><mi>x</mi><mo>∈</mo><mi mathvariant="normal">R</mi><mo>∣</mo><mi>x</mi><mo>&gt;</mo><mn>0</mn><mo stretchy="false">}</mo></mrow><annotation encoding="application/x-tex">\{x∈ℝ\mid x&gt;0\}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">{</span><span class="mord mathnormal">x</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">∈</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord amsrm">R</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">∣</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mord mathnormal">x</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">&gt;</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">0</span><span class="mclose">}</span></span></span></span></td>
<td style="text-align:left"><code>\{x∈ℝ\mid x&gt;0\}</code></td>
</tr>
<tr>
<td style="text-align:left">\middle</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>P</mi><mrow><mo fence="true">(</mo><mi>A</mi><mo fence="true" lspace="0.05em" rspace="0.05em">|</mo><mi>B</mi><mo fence="true">)</mo></mrow></mrow><annotation encoding="application/x-tex">P\left(A\middle\vert B\right)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.13889em;">P</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord mathnormal">A</span><span class="delimcenter" style="top:0em;">∣</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span><span class="mclose delimcenter" style="top:0em;">)</span></span></span></span></span></td>
<td style="text-align:left"><code>P\left(A\middle\vert B\right)</code></td>
</tr>
<tr>
<td style="text-align:left">\min</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>min</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\min</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6679em;"></span><span class="mop">min</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\mit</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left">See <code>\mathit</code></td>
</tr>
<tr>
<td style="text-align:left">\mkern</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mspace width="1em"/><mi>b</mi></mrow><annotation encoding="application/x-tex">a\mkern18mu b</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">a</span><span class="mspace" style="margin-right:1em;"></span><span class="mord mathnormal">b</span></span></span></span></td>
<td style="text-align:left"><code>a\mkern18mu b</code></td>
</tr>
<tr>
<td style="text-align:left">\mmlToken</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\mod</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>3</mn><mo>≡</mo><mn>5</mn><mspace></mspace><mspace width="0.6667em"/><mrow><mi mathvariant="normal">m</mi><mi mathvariant="normal">o</mi><mi mathvariant="normal">d</mi></mrow><mtext> </mtext><mtext> </mtext><mn>2</mn></mrow><annotation encoding="application/x-tex">3\equiv 5 \mod 2</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">3</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">≡</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">5</span><span class="mspace allowbreak"></span><span class="mspace" style="margin-right:0.6667em;"></span></span><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord"><span class="mord"><span class="mord mathrm">mod</span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord">2</span></span></span></span></td>
<td style="text-align:left"><code>3\equiv 5 \mod 2</code></td>
</tr>
<tr>
<td style="text-align:left">\models</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊨</mo></mrow><annotation encoding="application/x-tex">\models</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.999em;vertical-align:-0.249em;"></span><span class="mrel">⊨</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\moveleft</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\moveright</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\mp</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∓</mo></mrow><annotation encoding="application/x-tex">\mp</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mord">∓</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\mskip</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mspace width="0.5556em"/><mi>b</mi></mrow><annotation encoding="application/x-tex">a\mskip{10mu}b</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">a</span><span class="mspace" style="margin-right:0.5556em;"></span><span class="mord mathnormal">b</span></span></span></span></td>
<td style="text-align:left"><code>a\mskip{10mu}b</code></td>
</tr>
<tr>
<td style="text-align:left">\mspace</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Mu</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">M</mi></mrow><annotation encoding="application/x-tex">\Mu</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathrm">M</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\mu</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>μ</mi></mrow><annotation encoding="application/x-tex">\mu</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">μ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\multicolumn</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"><a href="https://github.com/KaTeX/KaTeX/issues/269" target="_blank" rel="noreferrer">Issue #269</a></td>
</tr>
<tr>
<td style="text-align:left" multiline=""></td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\multimap</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊸</mo></mrow><annotation encoding="application/x-tex">\multimap</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5499em;"></span><span class="mrel amsrm">⊸</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
</tbody>
</table>
<h2 id="n" tabindex="-1">N <a class="header-anchor" href="#n" aria-label="Permalink to &quot;N&quot;">&ZeroWidthSpace;</a></h2>
<table>
<thead>
<tr>
<th style="text-align:left">Symbol/Function</th>
<th style="text-align:left">Rendered</th>
<th style="text-align:left">Source or Comment</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">\N</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="double-struck">N</mi></mrow><annotation encoding="application/x-tex">\N</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord mathbb">N</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\nabla</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∇</mi></mrow><annotation encoding="application/x-tex">\nabla</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">∇</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\natnums</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="double-struck">N</mi></mrow><annotation encoding="application/x-tex">\natnums</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord mathbb">N</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\natural</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">♮</mi></mrow><annotation encoding="application/x-tex">\natural</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord">♮</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\negmedspace</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mtext> ⁣</mtext><mi>b</mi></mrow><annotation encoding="application/x-tex">a\negmedspace b</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">a</span><span class="mspace" style="margin-right:-0.2222em;"></span><span class="mord mathnormal">b</span></span></span></span></td>
<td style="text-align:left"><code>a\negmedspace b</code></td>
</tr>
<tr>
<td style="text-align:left">\ncong</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≆</mo></mrow><annotation encoding="application/x-tex">\ncong</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0966em;vertical-align:-0.3027em;"></span><span class="mrel amsrm">≆</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\ne</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo mathvariant="normal">≠</mo></mrow><annotation encoding="application/x-tex">\ne</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel"><span class="mrel"><span class="mord vbox"><span class="thinbox"><span class="rlap"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="inner"><span class="mord"><span class="mrel"></span></span></span><span class="fix"></span></span></span></span></span><span class="mrel">=</span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\nearrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↗</mo></mrow><annotation encoding="application/x-tex">\nearrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel">↗</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\neg</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">¬</mi></mrow><annotation encoding="application/x-tex">\neg</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord">¬</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\negthickspace</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mtext> ⁣</mtext><mi>b</mi></mrow><annotation encoding="application/x-tex">a\negthickspace b</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">a</span><span class="mspace" style="margin-right:-0.2778em;"></span><span class="mord mathnormal">b</span></span></span></span></td>
<td style="text-align:left"><code>a\negthickspace b</code></td>
</tr>
<tr>
<td style="text-align:left">\negthinspace</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mtext> ⁣</mtext><mi>b</mi></mrow><annotation encoding="application/x-tex">a\negthinspace b</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">a</span><span class="mspace" style="margin-right:-0.1667em;"></span><span class="mord mathnormal">b</span></span></span></span></td>
<td style="text-align:left"><code>a\negthinspace b</code></td>
</tr>
<tr>
<td style="text-align:left">\neq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo mathvariant="normal">≠</mo></mrow><annotation encoding="application/x-tex">\neq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel"><span class="mrel"><span class="mord vbox"><span class="thinbox"><span class="rlap"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="inner"><span class="mord"><span class="mrel"></span></span></span><span class="fix"></span></span></span></span></span><span class="mrel">=</span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\newcommand</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">✓</mi></mrow><annotation encoding="application/x-tex">\newcommand\chk{\checkmark} \chk</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mord amsrm">✓</span></span></span></span></td>
<td style="text-align:left"><code>\newcommand\chk{\checkmark} \chk</code></td>
</tr>
<tr>
<td style="text-align:left">\newenvironment</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"><a href="https://github.com/KaTeX/KaTeX/issues/37" target="_blank" rel="noreferrer">Issue #37</a></td>
</tr>
<tr>
<td style="text-align:left">\Newextarrow</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\newline</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mspace linebreak="newline"></mspace><mi>b</mi></mrow><annotation encoding="application/x-tex">a\newline b</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">a</span></span><span class="mspace newline"></span><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">b</span></span></span></span></td>
<td style="text-align:left"><code>a\newline b</code></td>
</tr>
<tr>
<td style="text-align:left">\nexists</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∄</mi></mrow><annotation encoding="application/x-tex">\nexists</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord amsrm">∄</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\ngeq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≱</mo></mrow><annotation encoding="application/x-tex">\ngeq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0966em;vertical-align:-0.3027em;"></span><span class="mrel amsrm">≱</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\ngeqq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≱</mo></mrow><annotation encoding="application/x-tex">\ngeqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.339em;vertical-align:-0.4195em;"></span><span class="mrel amsrm"></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\ngeqslant</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≱</mo></mrow><annotation encoding="application/x-tex">\ngeqslant</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0966em;vertical-align:-0.3027em;"></span><span class="mrel amsrm"></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\ngtr</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≯</mo></mrow><annotation encoding="application/x-tex">\ngtr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9115em;vertical-align:-0.2058em;"></span><span class="mrel amsrm">≯</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\ni</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∋</mo></mrow><annotation encoding="application/x-tex">\ni</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">∋</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\nleftarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↚</mo></mrow><annotation encoding="application/x-tex">\nleftarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel amsrm">↚</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\nLeftarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇍</mo></mrow><annotation encoding="application/x-tex">\nLeftarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel amsrm">⇍</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\nLeftrightarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇎</mo></mrow><annotation encoding="application/x-tex">\nLeftrightarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel amsrm">⇎</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\nleftrightarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↮</mo></mrow><annotation encoding="application/x-tex">\nleftrightarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel amsrm">↮</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\nleq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≰</mo></mrow><annotation encoding="application/x-tex">\nleq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0966em;vertical-align:-0.3027em;"></span><span class="mrel amsrm">≰</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\nleqq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≰</mo></mrow><annotation encoding="application/x-tex">\nleqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.339em;vertical-align:-0.4195em;"></span><span class="mrel amsrm"></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\nleqslant</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≰</mo></mrow><annotation encoding="application/x-tex">\nleqslant</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0966em;vertical-align:-0.3027em;"></span><span class="mrel amsrm"></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\nless</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≮</mo></mrow><annotation encoding="application/x-tex">\nless</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9115em;vertical-align:-0.2058em;"></span><span class="mrel amsrm">≮</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\nmid</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∤</mo></mrow><annotation encoding="application/x-tex">\nmid</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9925em;vertical-align:-0.2514em;"></span><span class="mrel amsrm">∤</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\nobreak</td>
<td style="text-align:left"></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\nobreakspace</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mtext> </mtext><mi>b</mi></mrow><annotation encoding="application/x-tex">a\nobreakspace b</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">a</span><span class="mspace nobreak"> </span><span class="mord mathnormal">b</span></span></span></span></td>
<td style="text-align:left"><code>a\nobreakspace b</code></td>
</tr>
<tr>
<td style="text-align:left">\noexpand</td>
<td style="text-align:left"></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\nolimits</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mrow><mi>lim</mi><mo>⁡</mo></mrow><mi>x</mi></msub></mrow><annotation encoding="application/x-tex">\lim\nolimits_x</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8444em;vertical-align:-0.15em;"></span><span class="mop"><span class="mop">lim</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">x</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\lim\nolimits_x</code></td>
</tr>
<tr>
<td style="text-align:left">\normalfont</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\normalsize</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathsize="1em"><mi>n</mi><mi>o</mi><mi>r</mi><mi>m</mi><mi>a</mi><mi>l</mi><mi>s</mi><mi>i</mi><mi>z</mi><mi>e</mi></mstyle></mrow><annotation encoding="application/x-tex">\normalsize normalsize</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">n</span><span class="mord mathnormal" style="margin-right:0.02778em;">or</span><span class="mord mathnormal">ma</span><span class="mord mathnormal" style="margin-right:0.01968em;">l</span><span class="mord mathnormal">s</span><span class="mord mathnormal">i</span><span class="mord mathnormal">ze</span></span></span></span></td>
<td style="text-align:left"><code>\normalsize normalsize</code></td>
</tr>
<tr>
<td style="text-align:left">\not</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≠</mo></mrow><annotation encoding="application/x-tex">\not =</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel"><span class="mord vbox"><span class="thinbox"><span class="rlap"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="inner"><span class="mord"><span class="mrel"></span></span></span><span class="fix"></span></span></span></span></span></span><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">=</span></span></span></span></td>
<td style="text-align:left"><code>\not =</code></td>
</tr>
<tr>
<td style="text-align:left">\notag</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\notin</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo mathvariant="normal">∉</mo></mrow><annotation encoding="application/x-tex">\notin</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mrel"><span class="mord"><span class="mrel">∈</span></span><span class="mord vbox"><span class="thinbox"><span class="llap"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="inner"><span class="mord"><span class="mord">/</span><span class="mspace" style="margin-right:0.0556em;"></span></span></span><span class="fix"></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\notni</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo mathvariant="normal">∌</mo></mrow><annotation encoding="application/x-tex">\notni</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel"><span class="mord vbox"><span class="thinbox"><span class="rlap"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="inner"><span class="mord"><span class="mrel"></span></span></span><span class="fix"></span></span></span></span></span></span><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">∋</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\nparallel</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∦</mo></mrow><annotation encoding="application/x-tex">\nparallel</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9925em;vertical-align:-0.2514em;"></span><span class="mrel amsrm">∦</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\nprec</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊀</mo></mrow><annotation encoding="application/x-tex">\nprec</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9115em;vertical-align:-0.2058em;"></span><span class="mrel amsrm">⊀</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\npreceq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋠</mo></mrow><annotation encoding="application/x-tex">\npreceq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0966em;vertical-align:-0.3027em;"></span><span class="mrel amsrm">⋠</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\nRightarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇏</mo></mrow><annotation encoding="application/x-tex">\nRightarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel amsrm">⇏</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\nrightarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↛</mo></mrow><annotation encoding="application/x-tex">\nrightarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel amsrm">↛</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\nshortmid</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∤</mo></mrow><annotation encoding="application/x-tex">\nshortmid</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6633em;vertical-align:-0.0817em;"></span><span class="mrel amsrm"></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\nshortparallel</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∦</mo></mrow><annotation encoding="application/x-tex">\nshortparallel</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6633em;vertical-align:-0.0817em;"></span><span class="mrel amsrm"></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\nsim</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≁</mo></mrow><annotation encoding="application/x-tex">\nsim</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel amsrm">≁</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\nsubseteq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊈</mo></mrow><annotation encoding="application/x-tex">\nsubseteq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0966em;vertical-align:-0.3027em;"></span><span class="mrel amsrm">⊈</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\nsubseteqq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊈</mo></mrow><annotation encoding="application/x-tex">\nsubseteqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0087em;vertical-align:-0.2514em;"></span><span class="mrel amsrm"></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\nsucc</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊁</mo></mrow><annotation encoding="application/x-tex">\nsucc</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9115em;vertical-align:-0.2058em;"></span><span class="mrel amsrm">⊁</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\nsucceq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋡</mo></mrow><annotation encoding="application/x-tex">\nsucceq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0966em;vertical-align:-0.3027em;"></span><span class="mrel amsrm">⋡</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\nsupseteq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊉</mo></mrow><annotation encoding="application/x-tex">\nsupseteq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0966em;vertical-align:-0.3027em;"></span><span class="mrel amsrm">⊉</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\nsupseteqq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊉</mo></mrow><annotation encoding="application/x-tex">\nsupseteqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0087em;vertical-align:-0.2514em;"></span><span class="mrel amsrm"></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\ntriangleleft</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋪</mo></mrow><annotation encoding="application/x-tex">\ntriangleleft</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9115em;vertical-align:-0.2058em;"></span><span class="mrel amsrm">⋪</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\ntrianglelefteq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋬</mo></mrow><annotation encoding="application/x-tex">\ntrianglelefteq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0966em;vertical-align:-0.3027em;"></span><span class="mrel amsrm">⋬</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\ntriangleright</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋫</mo></mrow><annotation encoding="application/x-tex">\ntriangleright</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9115em;vertical-align:-0.2058em;"></span><span class="mrel amsrm">⋫</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\ntrianglerighteq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋭</mo></mrow><annotation encoding="application/x-tex">\ntrianglerighteq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0966em;vertical-align:-0.3027em;"></span><span class="mrel amsrm">⋭</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Nu</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">N</mi></mrow><annotation encoding="application/x-tex">\Nu</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathrm">N</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\nu</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ν</mi></mrow><annotation encoding="application/x-tex">\nu</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal" style="margin-right:0.06366em;">ν</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\nVDash</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊯</mo></mrow><annotation encoding="application/x-tex">\nVDash</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mrel amsrm">⊯</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\nVdash</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊮</mo></mrow><annotation encoding="application/x-tex">\nVdash</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mrel amsrm">⊮</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\nvDash</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊭</mo></mrow><annotation encoding="application/x-tex">\nvDash</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mrel amsrm">⊭</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\nvdash</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊬</mo></mrow><annotation encoding="application/x-tex">\nvdash</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mrel amsrm">⊬</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\nwarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↖</mo></mrow><annotation encoding="application/x-tex">\nwarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel">↖</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
</tbody>
</table>
<h2 id="o" tabindex="-1">O <a class="header-anchor" href="#o" aria-label="Permalink to &quot;O&quot;">&ZeroWidthSpace;</a></h2>
<table>
<thead>
<tr>
<th style="text-align:left">Symbol/Function</th>
<th style="text-align:left">Rendered</th>
<th style="text-align:left">Source or Comment</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">\O</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>Ø</mtext></mrow><annotation encoding="application/x-tex">\text{\O}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7806em;vertical-align:-0.0486em;"></span><span class="mord text"><span class="mord">Ø</span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\O}</code></td>
</tr>
<tr>
<td style="text-align:left">\o</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>ø</mtext></mrow><annotation encoding="application/x-tex">\text{\o}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.0972em;"></span><span class="mord text"><span class="mord">ø</span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\o}</code></td>
</tr>
<tr>
<td style="text-align:left">\odot</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊙</mo></mrow><annotation encoding="application/x-tex">\odot</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mord">⊙</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\OE</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>Œ</mtext></mrow><annotation encoding="application/x-tex">\text{\OE}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord text"><span class="mord latin_fallback">Œ</span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\OE}</code></td>
</tr>
<tr>
<td style="text-align:left">\oe</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>œ</mtext></mrow><annotation encoding="application/x-tex">\text{\oe}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord text"><span class="mord latin_fallback">œ</span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\oe}</code></td>
</tr>
<tr>
<td style="text-align:left">\officialeuro</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\oiiint</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∰</mo></mrow><annotation encoding="application/x-tex">\oiiint</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.111em;vertical-align:-0.306em;"></span><span class="mop vlist-t vlist-t2" style="position:relative;top:-0.0005em;"><span class="vlist-r"><span class="vlist" style="height:0.805em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mop op-symbol small-op" style="margin-right:0.19445em;">∭</span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="overlay" style="height:0.499em;width:1.304em;"><svg xmlns="http://www.w3.org/2000/svg" width='1.304em' height='0.499em' style='width:1.304em' viewBox='0 0 1304 499' preserveAspectRatio='xMinYMin'><path d='M681.4 71.6c408.9 0 480.5 106.8 480.5 178.2 0 70.8-71.6 177.6
-480.5 177.6S202.1 320.6 202.1 249.8c0-71.4 70.5-178.2 479.3-178.2z
m525.8 178.2c0-86.4-86.8-215.4-525.7-215.4-437.9 0-524.7 129-524.7 215.4 0
85.8 86.8 214.8 524.7 214.8 438.9 0 525.7-129 525.7-214.8z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.306em;"><span></span></span></span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\oiint</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∯</mo></mrow><annotation encoding="application/x-tex">\oiint</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.111em;vertical-align:-0.306em;"></span><span class="mop vlist-t vlist-t2" style="position:relative;top:-0.0005em;"><span class="vlist-r"><span class="vlist" style="height:0.805em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mop op-symbol small-op" style="margin-right:0.19445em;">∬</span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="overlay" style="height:0.499em;width:0.957em;"><svg xmlns="http://www.w3.org/2000/svg" width='0.957em' height='0.499em' style='width:0.957em' viewBox='0 0 957 499' preserveAspectRatio='xMinYMin'><path d='M512.6 71.6c272.6 0 320.3 106.8 320.3 178.2 0 70.8-47.7 177.6
-320.3 177.6S193.1 320.6 193.1 249.8c0-71.4 46.9-178.2 319.5-178.2z
m368.1 178.2c0-86.4-60.9-215.4-368.1-215.4-306.4 0-367.3 129-367.3 215.4 0 85.8
60.9 214.8 367.3 214.8 307.2 0 368.1-129 368.1-214.8z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.306em;"><span></span></span></span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\oint</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∮</mo></mrow><annotation encoding="application/x-tex">\oint</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1111em;vertical-align:-0.3061em;"></span><span class="mop op-symbol small-op" style="margin-right:0.19445em;position:relative;top:-0.0006em;">∮</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\oldstyle</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\omega</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ω</mi></mrow><annotation encoding="application/x-tex">\omega</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">ω</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Omega</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Ω</mi></mrow><annotation encoding="application/x-tex">\Omega</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">Ω</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Omicron</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">O</mi></mrow><annotation encoding="application/x-tex">\Omicron</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathrm">O</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\omicron</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ο</mi></mrow><annotation encoding="application/x-tex">\omicron</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">ο</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\ominus</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊖</mo></mrow><annotation encoding="application/x-tex">\ominus</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mord">⊖</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\operatorname</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">asin</mi><mo>⁡</mo><mi>x</mi></mrow><annotation encoding="application/x-tex">\operatorname{asin} x</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6679em;"></span><span class="mop"><span class="mord mathrm">asin</span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">x</span></span></span></span></td>
<td style="text-align:left">\operatorname{asin} x</td>
</tr>
<tr>
<td style="text-align:left">\operatorname*</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mrow><mi mathvariant="normal">asin</mi><mo>⁡</mo></mrow><mi>y</mi></msub><mi>x</mi></mrow><annotation encoding="application/x-tex">\operatorname{asin}\limits_y x</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.954em;vertical-align:-0.2861em;"></span><span class="mop"><span class="mop"><span class="mord mathrm">asin</span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.03588em;">y</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">x</span></span></span></span></td>
<td style="text-align:left"><code>\operatorname{asin}\limits_y x</code></td>
</tr>
<tr>
<td style="text-align:left">\oplus</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊕</mo></mrow><annotation encoding="application/x-tex">\oplus</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mord">⊕</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\or</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\oslash</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊘</mo></mrow><annotation encoding="application/x-tex">\oslash</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mord">⊘</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\otimes</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊗</mo></mrow><annotation encoding="application/x-tex">\otimes</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mord">⊗</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\over</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mfrac><mrow><mi>a</mi><mo>+</mo><mn>1</mn></mrow><mrow><mi>b</mi><mo>+</mo><mn>2</mn></mrow></mfrac><mo>+</mo><mi>c</mi></mrow><annotation encoding="application/x-tex">{a+1 \over b+2}+c</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2484em;vertical-align:-0.4033em;"></span><span class="mord"><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8451em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">b</span><span class="mbin mtight">+</span><span class="mord mtight">2</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">a</span><span class="mbin mtight">+</span><span class="mord mtight">1</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.4033em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">c</span></span></span></span></td>
<td style="text-align:left"><code>{a+1 \over b+2}+c</code></td>
</tr>
<tr>
<td style="text-align:left">\overbrace</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mover><mrow><mi>x</mi><mo>+</mo><mo>⋯</mo><mo>+</mo><mi>x</mi></mrow><mo stretchy="true">⏞</mo></mover><mrow><mi>n</mi><mtext> times</mtext></mrow></mover></mrow><annotation encoding="application/x-tex">\overbrace{x+⋯+x}^{n\text{ times}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.9822em;vertical-align:-0.0833em;"></span><span class="mord mover"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.8988em;"><span style="top:-3.2313em;"><span class="pstrut" style="height:3.2313em;"></span><span class="mord mover"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.2313em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">x</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="minner">⋯</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal">x</span></span></span><span class="svg-align" style="top:-3.6833em;"><span class="pstrut" style="height:3em;"></span><span class="stretchy" style="height:0.548em;min-width:1.6em;"><span class="brace-left" style="height:0.548em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.548em' viewBox='0 0 400000 548' preserveAspectRatio='xMinYMin slice'><path d='M6 548l-6-6v-35l6-11c56-104 135.3-181.3 238-232 57.3-28.7 117
-45 179-50h399577v120H403c-43.3 7-81 15-113 26-100.7 33-179.7 91-237 174-2.7
 5-6 9-10 13-.7 1-7.3 1-20 1H6z'/></svg></span><span class="brace-center" style="height:0.548em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.548em' viewBox='0 0 400000 548' preserveAspectRatio='xMidYMin slice'><path d='M200428 334
c-100.7-8.3-195.3-44-280-108-55.3-42-101.7-93-139-153l-9-14c-2.7 4-5.7 8.7-9 14
-53.3 86.7-123.7 153-211 199-66.7 36-137.3 56.3-212 62H0V214h199568c178.3-11.7
 311.7-78.3 403-201 6-8 9.7-12 11-12 .7-.7 6.7-1 18-1s17.3.3 18 1c1.3 0 5 4 11
 12 44.7 59.3 101.3 106.3 170 141s145.3 54.3 229 60h199572v120z'/></svg></span><span class="brace-right" style="height:0.548em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.548em' viewBox='0 0 400000 548' preserveAspectRatio='xMaxYMin slice'><path d='M400000 542l
-6 6h-17c-12.7 0-19.3-.3-20-1-4-4-7.3-8.3-10-13-35.3-51.3-80.8-93.8-136.5-127.5
s-117.2-55.8-184.5-66.5c-.7 0-2-.3-4-1-18.7-2.7-76-4.3-172-5H0V214h399571l6 1
c124.7 8 235 61.7 331 161 31.3 33.3 59.7 72.7 85 118l7 13v35z'/></svg></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.0833em;"><span></span></span></span></span></span></span><span style="top:-4.6627em;"><span class="pstrut" style="height:3.2313em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">n</span><span class="mord text mtight"><span class="mord mtight"> times</span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.0833em;"><span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\overbrace{x+⋯+x}^{n\text{ times}}</code></td>
</tr>
<tr>
<td style="text-align:left">\overbracket</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\overgroup</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mrow><mi>A</mi><mi>B</mi></mrow><mo stretchy="true">⏠</mo></mover></mrow><annotation encoding="application/x-tex">\overgroup{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0253em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:1.0253em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span><span class="svg-align" style="top:-3.6833em;"><span class="pstrut" style="height:3em;"></span><span class="stretchy" style="height:0.342em;min-width:0.888em;"><span class="halfarrow-left" style="height:0.342em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.342em' viewBox='0 0 400000 342' preserveAspectRatio='xMinYMin slice'><path d='M400000 80
H435C64 80 168.3 229.4 21 260c-5.9 1.2-18 0-18 0-2 0-3-1-3-3v-38C76 61 257 0
 435 0h399565z'/></svg></span><span class="halfarrow-right" style="height:0.342em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.342em' viewBox='0 0 400000 342' preserveAspectRatio='xMaxYMin slice'><path d='M0 80h399565c371 0 266.7 149.4 414 180 5.9 1.2 18 0 18 0 2 0
 3-1 3-3v-38c-76-158-257-219-435-219H0z'/></svg></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\overgroup{AB}</code></td>
</tr>
<tr>
<td style="text-align:left">\overleftarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mrow><mi>A</mi><mi>B</mi></mrow><mo stretchy="true">←</mo></mover></mrow><annotation encoding="application/x-tex">\overleftarrow{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2053em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:1.2053em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span><span class="svg-align" style="top:-3.6833em;"><span class="pstrut" style="height:3em;"></span><span class="hide-tail" style="height:0.522em;min-width:0.888em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMinYMin slice'><path d='M400000 241H110l3-3c68.7-52.7 113.7-120
 135-202 4-14.7 6-23 6-25 0-7.3-7-11-21-11-8 0-13.2.8-15.5 2.5-2.3 1.7-4.2 5.8
-5.5 12.5-1.3 4.7-2.7 10.3-4 17-12 48.7-34.8 92-68.5 130S65.3 228.3 18 247
c-10 4-16 7.7-18 11 0 8.7 6 14.3 18 17 47.3 18.7 87.8 47 121.5 85S196 441.3 208
 490c.7 2 1.3 5 2 9s1.2 6.7 1.5 8c.3 1.3 1 3.3 2 6s2.2 4.5 3.5 5.5c1.3 1 3.3
 1.8 6 2.5s6 1 10 1c14 0 21-3.7 21-11 0-2-2-10.3-6-25-20-79.3-65-146.7-135-202
 l-3-3h399890zM100 241v40h399900v-40z'/></svg></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\overleftarrow{AB}</code></td>
</tr>
<tr>
<td style="text-align:left">\overleftharpoon</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mrow><mi>A</mi><mi>B</mi></mrow><mo stretchy="true">↼</mo></mover></mrow><annotation encoding="application/x-tex">\overleftharpoon{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2053em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:1.2053em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span><span class="svg-align" style="top:-3.6833em;"><span class="pstrut" style="height:3em;"></span><span class="hide-tail" style="height:0.522em;min-width:0.888em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMinYMin slice'><path d='M0 267c.7 5.3 3 10 7 14h399993v-40H93c3.3
-3.3 10.2-9.5 20.5-18.5s17.8-15.8 22.5-20.5c50.7-52 88-110.3 112-175 4-11.3 5
-18.3 3-21-1.3-4-7.3-6-18-6-8 0-13 .7-15 2s-4.7 6.7-8 16c-42 98.7-107.3 174.7
-196 228-6.7 4.7-10.7 8-12 10-1.3 2-2 5.7-2 11zm100-26v40h399900v-40z'/></svg></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\overleftharpoon{AB}</code></td>
</tr>
<tr>
<td style="text-align:left">\overleftrightarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mrow><mi>A</mi><mi>B</mi></mrow><mo stretchy="true">↔</mo></mover></mrow><annotation encoding="application/x-tex">\overleftrightarrow{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2053em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:1.2053em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span><span class="svg-align" style="top:-3.6833em;"><span class="pstrut" style="height:3em;"></span><span class="stretchy" style="height:0.522em;min-width:0.888em;"><span class="halfarrow-left" style="height:0.522em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMinYMin slice'><path d='M400000 241H110l3-3c68.7-52.7 113.7-120
 135-202 4-14.7 6-23 6-25 0-7.3-7-11-21-11-8 0-13.2.8-15.5 2.5-2.3 1.7-4.2 5.8
-5.5 12.5-1.3 4.7-2.7 10.3-4 17-12 48.7-34.8 92-68.5 130S65.3 228.3 18 247
c-10 4-16 7.7-18 11 0 8.7 6 14.3 18 17 47.3 18.7 87.8 47 121.5 85S196 441.3 208
 490c.7 2 1.3 5 2 9s1.2 6.7 1.5 8c.3 1.3 1 3.3 2 6s2.2 4.5 3.5 5.5c1.3 1 3.3
 1.8 6 2.5s6 1 10 1c14 0 21-3.7 21-11 0-2-2-10.3-6-25-20-79.3-65-146.7-135-202
 l-3-3h399890zM100 241v40h399900v-40z'/></svg></span><span class="halfarrow-right" style="height:0.522em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMaxYMin slice'><path d='M0 241v40h399891c-47.3 35.3-84 78-110 128
-16.7 32-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20
 11 8 0 13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7
 39-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85
-40.5-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5
-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67
 151.7 139 205zm0 0v40h399900v-40z'/></svg></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\overleftrightarrow{AB}</code></td>
</tr>
<tr>
<td style="text-align:left">\overline</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mtext>a long argument</mtext><mo stretchy="true">‾</mo></mover></mrow><annotation encoding="application/x-tex">\overline{\text{a long argument}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0889em;vertical-align:-0.1944em;"></span><span class="mord overline"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8944em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord text"><span class="mord">a long argument</span></span></span></span><span style="top:-3.8144em;"><span class="pstrut" style="height:3em;"></span><span class="overline-line" style="border-bottom-width:0.04em;"></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.1944em;"><span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\overline{\text{a long argument}}</code></td>
</tr>
<tr>
<td style="text-align:left">\overlinesegment</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mrow><mi>A</mi><mi>B</mi></mrow><mo stretchy="true">undefined</mo></mover></mrow><annotation encoding="application/x-tex">\overlinesegment{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2053em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:1.2053em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span><span class="svg-align" style="top:-3.6833em;"><span class="pstrut" style="height:3em;"></span><span class="stretchy" style="height:0.522em;min-width:0.888em;"><span class="halfarrow-left" style="height:0.522em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMinYMin slice'><path d='M40 281 V428 H0 V94 H40 V241 H400000 v40z
M40 281 V428 H0 V94 H40 V241 H400000 v40z'/></svg></span><span class="halfarrow-right" style="height:0.522em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMaxYMin slice'><path d='M399960 241 V94 h40 V428 h-40 V281 H0 v-40z
M399960 241 V94 h40 V428 h-40 V281 H0 v-40z'/></svg></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\overlinesegment{AB}</code></td>
</tr>
<tr>
<td style="text-align:left">\overparen</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left">See <code>\overgroup</code></td>
</tr>
<tr>
<td style="text-align:left">\Overrightarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mrow><mi>A</mi><mi>B</mi></mrow><mo stretchy="true">⇒</mo></mover></mrow><annotation encoding="application/x-tex">\Overrightarrow{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2433em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:1.2433em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span><span class="svg-align" style="top:-3.6833em;"><span class="pstrut" style="height:3em;"></span><span class="hide-tail" style="height:0.56em;min-width:0.888em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.56em' viewBox='0 0 400000 560' preserveAspectRatio='xMaxYMin slice'><path d='M399738 392l
-10 10c-34 36-62.7 77-86 123-3.3 8-5 13.3-5 16 0 5.3 6.7 8 20 8 7.3 0 12.2-.5
 14.5-1.5 2.3-1 4.8-4.5 7.5-10.5 49.3-97.3 121.7-169.3 217-216 28-14 57.3-25 88
-33 6.7-2 11-3.8 13-5.5 2-1.7 3-4.2 3-7.5s-1-5.8-3-7.5c-2-1.7-6.3-3.5-13-5.5-68
-17.3-128.2-47.8-180.5-91.5-52.3-43.7-93.8-96.2-124.5-157.5-9.3-8-15.3-12.3-18
-13h-6c-12 .7-18 4-18 10 0 2 1.7 7 5 15 23.3 46 52 87 86 123l10 10H0v40h399782
c-328 0 0 0 0 0l10 8c26.7 20 65.7 43 117 69-2.7 2-6 3.7-10 5-36.7 16-72.3 37.3
-107 64l-10 8H0v40zM0 157v40h399730v-40zm0 194v40h399730v-40z'/></svg></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\Overrightarrow{AB}</code></td>
</tr>
<tr>
<td style="text-align:left">\overrightarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mrow><mi>A</mi><mi>B</mi></mrow><mo stretchy="true">→</mo></mover></mrow><annotation encoding="application/x-tex">\overrightarrow{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2053em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:1.2053em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span><span class="svg-align" style="top:-3.6833em;"><span class="pstrut" style="height:3em;"></span><span class="hide-tail" style="height:0.522em;min-width:0.888em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMaxYMin slice'><path d='M0 241v40h399891c-47.3 35.3-84 78-110 128
-16.7 32-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20
 11 8 0 13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7
 39-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85
-40.5-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5
-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67
 151.7 139 205zm0 0v40h399900v-40z'/></svg></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\overrightarrow{AB}</code></td>
</tr>
<tr>
<td style="text-align:left">\overrightharpoon</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mrow><mi>a</mi><mi>c</mi></mrow><mo stretchy="true">⇀</mo></mover></mrow><annotation encoding="application/x-tex">\overrightharpoon{ac}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9526em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.9526em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span><span class="mord mathnormal">c</span></span></span><span class="svg-align" style="top:-3.4306em;"><span class="pstrut" style="height:3em;"></span><span class="hide-tail" style="height:0.522em;min-width:0.888em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMaxYMin slice'><path d='M0 241v40h399993c4.7-4.7 7-9.3 7-14 0-9.3
-3.7-15.3-11-18-92.7-56.7-159-133.7-199-231-3.3-9.3-6-14.7-8-16-2-1.3-7-2-15-2
-10.7 0-16.7 2-18 6-2 2.7-1 9.7 3 21 15.3 42 36.7 81.8 64 119.5 27.3 37.7 58
 69.2 92 94.5zm0 0v40h399900v-40z'/></svg></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\overrightharpoon{ac}</code></td>
</tr>
<tr>
<td style="text-align:left">\overset</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mover><mo><mo>=</mo></mo><mo stretchy="false" lspace="0em" rspace="0em">!</mo></mover></mo></mrow><annotation encoding="application/x-tex">\overset{!}{=}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.153em;"></span><span class="mrel"><span class="mop op-limits"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:1.153em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span><span class="mop">=</span></span></span><span style="top:-3.5669em;margin-left:0em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mclose mtight">!</span></span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\overset{!}{=}</code></td>
</tr>
<tr>
<td style="text-align:left">\overwithdelims</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\owns</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∋</mo></mrow><annotation encoding="application/x-tex">\owns</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">∋</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
</tbody>
</table>
<h2 id="p" tabindex="-1">P <a class="header-anchor" href="#p" aria-label="Permalink to &quot;P&quot;">&ZeroWidthSpace;</a></h2>
<table>
<thead>
<tr>
<th style="text-align:left">Symbol/Function</th>
<th style="text-align:left">Rendered</th>
<th style="text-align:left">Source or Comment</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">\P</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>¶</mtext></mrow><annotation encoding="application/x-tex">\text{\P}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord text"><span class="mord">¶</span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\P}</code></td>
</tr>
<tr>
<td style="text-align:left">\pagecolor</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"><a href="https://en.wikipedia.org/wiki/Help:Displaying_a_formula#Deprecated_syntax" target="_blank" rel="noreferrer">Deprecated</a></td>
</tr>
<tr>
<td style="text-align:left">\parallel</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∥</mo></mrow><annotation encoding="application/x-tex">\parallel</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mrel">∥</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\part</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"><a href="https://en.wikipedia.org/wiki/Help:Displaying_a_formula#Deprecated_syntax" target="_blank" rel="noreferrer">Deprecated</a></td>
</tr>
<tr>
<td style="text-align:left">\partial</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∂</mi></mrow><annotation encoding="application/x-tex">\partial</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord" style="margin-right:0.05556em;">∂</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\perp</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊥</mo></mrow><annotation encoding="application/x-tex">\perp</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mrel">⊥</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\phantom</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msubsup><mi mathvariant="normal">Γ</mi><mrow><mi>i</mi><mphantom><mi>j</mi></mphantom><mi>k</mi></mrow><mrow><mphantom><mi>i</mi></mphantom><mi>j</mi></mrow></msubsup></mrow><annotation encoding="application/x-tex">\Gamma^{\phantom{i}j}_{i\phantom{j}k}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.38em;vertical-align:-0.4374em;"></span><span class="mord"><span class="mord">Γ</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.9426em;"><span style="top:-2.3987em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">i</span><span class="mord mathnormal mtight" style="margin-right:0.05724em;color:transparent;">j</span><span class="mord mathnormal mtight" style="margin-right:0.03148em;">k</span></span></span></span><span style="top:-3.1809em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="color:transparent;">i</span><span class="mord mathnormal mtight" style="margin-right:0.05724em;">j</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.4374em;"><span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\Gamma^{\phantom{i}j}_{i\phantom{j}k}</code></td>
</tr>
<tr>
<td style="text-align:left">\phase</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Phi</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Φ</mi></mrow><annotation encoding="application/x-tex">\Phi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">Φ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\phi</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ϕ</mi></mrow><annotation encoding="application/x-tex">\phi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">ϕ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Pi</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Π</mi></mrow><annotation encoding="application/x-tex">\Pi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">Π</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\pi</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>π</mi></mrow><annotation encoding="application/x-tex">\pi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">π</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left" picture=""></td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\pitchfork</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋔</mo></mrow><annotation encoding="application/x-tex">\pitchfork</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mrel amsrm">⋔</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\plim</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mi mathvariant="normal">plim</mi><mo>⁡</mo></mo></mrow><annotation encoding="application/x-tex">\plim</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mop"><span class="mop"><span class="mord mathrm">plim</span></span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\plusmn</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>±</mo></mrow><annotation encoding="application/x-tex">\plusmn</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mord">±</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\pm</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>±</mo></mrow><annotation encoding="application/x-tex">\pm</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mord">±</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\pmatrix</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left">See <code>{pmatrix}</code></td>
</tr>
<tr>
<td style="text-align:left" pmatrix=""></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true">(</mo><mtable rowspacing="0.16em" columnalign="center center" columnspacing="1em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>a</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>b</mi></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>c</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>d</mi></mstyle></mtd></mtr></mtable><mo fence="true">)</mo></mrow><annotation encoding="application/x-tex">\begin{pmatrix}a&amp;b\\c&amp;d\end{pmatrix}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.4em;vertical-align:-0.95em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size3">(</span></span><span class="mord"><span class="mtable"><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:0.5em;"></span><span class="arraycolsep" style="width:0.5em;"></span><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">b</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">d</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size3">)</span></span></span></span></span></span></td>
<td style="text-align:left"><code>\begin{pmatrix}</code><br>   <code>a &amp; b \\</code><br>   <code>c &amp; d</code><br><code>\end{pmatrix}</code></td>
</tr>
<tr>
<td style="text-align:left">\pmb</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle style="text-shadow: 0.02em 0.01em 0.04px"><mi>μ</mi></mstyle></mrow><annotation encoding="application/x-tex">\pmb{\mu}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord" style="text-shadow:0.02em 0.01em 0.04px;"><span class="mord mathnormal">μ</span></span></span></span></span></td>
<td style="text-align:left"><code>\pmb{\mu}</code></td>
</tr>
<tr>
<td style="text-align:left">\pmod</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>x</mi><mspace></mspace><mspace width="0.4444em"/><mo stretchy="false">(</mo><mrow><mi mathvariant="normal">m</mi><mi mathvariant="normal">o</mi><mi mathvariant="normal">d</mi></mrow><mspace width="0.3333em"/><mi>a</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">x\pmod a</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">x</span><span class="mspace allowbreak"></span><span class="mspace" style="margin-right:0.4444em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">(</span><span class="mord"><span class="mord"><span class="mord mathrm">mod</span></span></span><span class="mspace" style="margin-right:0.3333em;"></span><span class="mord mathnormal">a</span><span class="mclose">)</span></span></span></span></td>
<td style="text-align:left"><code>x\pmod a</code></td>
</tr>
<tr>
<td style="text-align:left">\pod</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>x</mi><mspace></mspace><mspace width="0.4444em"/><mo stretchy="false">(</mo><mi>a</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">x \pod a</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">x</span><span class="mspace allowbreak"></span><span class="mspace" style="margin-right:0.4444em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">(</span><span class="mord mathnormal">a</span><span class="mclose">)</span></span></span></span></td>
<td style="text-align:left"><code>x \pod a</code></td>
</tr>
<tr>
<td style="text-align:left">\pounds</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">£</mi></mrow><annotation encoding="application/x-tex">\pounds</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">£</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Pr</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>Pr</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\Pr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mop">Pr</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\prec</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≺</mo></mrow><annotation encoding="application/x-tex">\prec</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">≺</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\precapprox</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⪷</mo></mrow><annotation encoding="application/x-tex">\precapprox</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0189em;vertical-align:-0.2617em;"></span><span class="mrel amsrm">⪷</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\preccurlyeq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≼</mo></mrow><annotation encoding="application/x-tex">\preccurlyeq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7733em;vertical-align:-0.1367em;"></span><span class="mrel amsrm">≼</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\preceq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⪯</mo></mrow><annotation encoding="application/x-tex">\preceq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mrel">⪯</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\precnapprox</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⪹</mo></mrow><annotation encoding="application/x-tex">\precnapprox</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0189em;vertical-align:-0.2617em;"></span><span class="mrel amsrm">⪹</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\precneqq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⪵</mo></mrow><annotation encoding="application/x-tex">\precneqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0087em;vertical-align:-0.2514em;"></span><span class="mrel amsrm">⪵</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\precnsim</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋨</mo></mrow><annotation encoding="application/x-tex">\precnsim</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9733em;vertical-align:-0.2322em;"></span><span class="mrel amsrm">⋨</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\precsim</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≾</mo></mrow><annotation encoding="application/x-tex">\precsim</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9592em;vertical-align:-0.2296em;"></span><span class="mrel amsrm">≾</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\prime</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo mathvariant="normal">′</mo></mrow><annotation encoding="application/x-tex">\prime</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5556em;"></span><span class="mord">′</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\prod</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∏</mo></mrow><annotation encoding="application/x-tex">\prod</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mop op-symbol small-op" style="position:relative;top:0em;">∏</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\projlim</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\propto</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∝</mo></mrow><annotation encoding="application/x-tex">\propto</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mrel">∝</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\providecommand</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>Hello</mtext></mrow><annotation encoding="application/x-tex">\providecommand\greet{\text{Hello}} \greet</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord">Hello</span></span></span></span></span></td>
<td style="text-align:left"><code>\providecommand\greet{\text{Hello}} \greet</code></td>
</tr>
<tr>
<td style="text-align:left">\psi</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ψ</mi></mrow><annotation encoding="application/x-tex">\psi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">ψ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Psi</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Ψ</mi></mrow><annotation encoding="application/x-tex">\Psi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">Ψ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\pu</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>123</mn><mtext> </mtext><mfrac><mrow><mi mathvariant="normal">k</mi><mi mathvariant="normal">J</mi></mrow><mrow><mi mathvariant="normal">m</mi><mi mathvariant="normal">o</mi><mi mathvariant="normal">l</mi></mrow></mfrac></mrow><annotation encoding="application/x-tex">{123~\mathchoice{\textstyle\frac{\mathrm{kJ}}{\mathrm{mol}}}{\frac{\mathrm{kJ}}{\mathrm{mol}}}{\frac{\mathrm{kJ}}{\mathrm{mol}}}{\frac{\mathrm{kJ}}{\mathrm{mol}}}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2251em;vertical-align:-0.345em;"></span><span class="mord"><span class="mord">123</span><span class="mspace nobreak"> </span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8801em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight"><span class="mord mathrm mtight">mol</span></span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight"><span class="mord mathrm mtight">kJ</span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\pu{123 kJ//mol}</code> Requires an <a href="https://github.com/KaTeX/KaTeX/tree/master/contrib/mhchem/" target="_blank" rel="noreferrer">extension</a></td>
</tr>
</tbody>
</table>
<h2 id="qr" tabindex="-1">QR <a class="header-anchor" href="#qr" aria-label="Permalink to &quot;QR&quot;">&ZeroWidthSpace;</a></h2>
<table>
<thead>
<tr>
<th style="text-align:left">Symbol/Function</th>
<th style="text-align:left">Rendered</th>
<th style="text-align:left">Source or Comment</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">\Q</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left">See <code>\Bbb{Q}</code></td>
</tr>
<tr>
<td style="text-align:left">\qquad</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mspace width="2em"/><mspace width="2em"/><mi>b</mi></mrow><annotation encoding="application/x-tex">a\qquad\qquad{b}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">a</span><span class="mspace" style="margin-right:2em;"></span><span class="mspace" style="margin-right:2em;"></span><span class="mord"><span class="mord mathnormal">b</span></span></span></span></span></td>
<td style="text-align:left"><code>a\qquad\qquad{b}</code></td>
</tr>
<tr>
<td style="text-align:left">\quad</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mspace width="1em"/><mspace width="1em"/><mi>b</mi></mrow><annotation encoding="application/x-tex">a\quad\quad{b}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">a</span><span class="mspace" style="margin-right:1em;"></span><span class="mspace" style="margin-right:1em;"></span><span class="mord"><span class="mord mathnormal">b</span></span></span></span></span></td>
<td style="text-align:left"><code>a\quad\quad{b}</code></td>
</tr>
<tr>
<td style="text-align:left">\R</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="double-struck">R</mi></mrow><annotation encoding="application/x-tex">\R</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord mathbb">R</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\r</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mtext>a</mtext><mo>˚</mo></mover></mrow><annotation encoding="application/x-tex">\text{\r{a}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6944em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">a</span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.375em;"><span class="mord">˚</span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\r{a}}</code></td>
</tr>
<tr>
<td style="text-align:left">\raise</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left">see <code>\raisebox</code></td>
</tr>
<tr>
<td style="text-align:left">\raisebox</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>h</mi><mpadded voffset="2pt"><mstyle scriptlevel="0" displaystyle="false"><mtext>ighe</mtext></mstyle></mpadded><mi>r</mi></mrow><annotation encoding="application/x-tex">h\raisebox{2pt}{ighe}r</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8944em;"></span><span class="mord mathnormal">h</span><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8944em;"><span style="top:-3.2em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">ighe</span></span></span></span></span></span><span class="mord mathnormal" style="margin-right:0.02778em;">r</span></span></span></span></td>
<td style="text-align:left"><code>h\raisebox{2pt}{ighe}r</code></td>
</tr>
<tr>
<td style="text-align:left">\rang</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">⟨</mo><mi>A</mi><mo stretchy="false">⟩</mo></mrow><annotation encoding="application/x-tex">\langle A\rang</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">⟨</span><span class="mord mathnormal">A</span><span class="mclose">⟩</span></span></span></span></td>
<td style="text-align:left"><code>\langle A\rang</code></td>
</tr>
<tr>
<td style="text-align:left">\rangle</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">⟨</mo><mi>A</mi><mo stretchy="false">⟩</mo></mrow><annotation encoding="application/x-tex">\langle A\rangle</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">⟨</span><span class="mord mathnormal">A</span><span class="mclose">⟩</span></span></span></span></td>
<td style="text-align:left"><code>\langle A\rangle</code></td>
</tr>
<tr>
<td style="text-align:left">\Rarr</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇒</mo></mrow><annotation encoding="application/x-tex">\Rarr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">⇒</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\rArr</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇒</mo></mrow><annotation encoding="application/x-tex">\rArr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">⇒</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\rarr</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>→</mo></mrow><annotation encoding="application/x-tex">\rarr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">→</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\rBrace</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo mathvariant="normal" lspace="0em" rspace="0em">⦄</mo></mrow><annotation encoding="application/x-tex">\rBrace</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mclose"><span class="mclose">]</span><span class="mspace" style="margin-right:-0.1778em;"></span><span class="mclose">}</span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\rbrace</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">}</mo></mrow><annotation encoding="application/x-tex">\rbrace</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mclose">}</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\rbrack</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">\rbrack</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mclose">]</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left" rcases=""></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtable rowspacing="0.36em" columnalign="left left" columnspacing="1em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>a</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mrow><mtext>if </mtext><mi>b</mi></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>c</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mrow><mtext>if </mtext><mi>d</mi></mrow></mstyle></mtd></mtr></mtable><mo fence="true">}</mo></mrow><annotation encoding="application/x-tex">\begin{rcases}a&amp;\text{if }b\\c&amp;\text{if }d\end{rcases}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:3em;vertical-align:-1.25em;"></span><span class="minner"><span class="mopen nulldelimiter"></span><span class="mord"><span class="mtable"><span class="col-align-l"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.69em;"><span style="top:-3.69em;"><span class="pstrut" style="height:3.008em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span><span style="top:-2.25em;"><span class="pstrut" style="height:3.008em;"></span><span class="mord"><span class="mord mathnormal">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.19em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:1em;"></span><span class="col-align-l"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.69em;"><span style="top:-3.69em;"><span class="pstrut" style="height:3.008em;"></span><span class="mord"><span class="mord text"><span class="mord">if </span></span><span class="mord mathnormal">b</span></span></span><span style="top:-2.25em;"><span class="pstrut" style="height:3.008em;"></span><span class="mord"><span class="mord text"><span class="mord">if </span></span><span class="mord mathnormal">d</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.19em;"><span></span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size4">}</span></span></span></span></span></span></td>
<td style="text-align:left"><code>\begin{rcases}</code><br>   <code>a &amp;\text{if } b  \\</code><br>   <code>c &amp;\text{if } d</code><br><code>\end{rcases}</code></td>
</tr>
<tr>
<td style="text-align:left">\rceil</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">⌉</mo></mrow><annotation encoding="application/x-tex">\rceil</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mclose">⌉</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Re</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">ℜ</mi></mrow><annotation encoding="application/x-tex">\Re</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">ℜ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\real</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">ℜ</mi></mrow><annotation encoding="application/x-tex">\real</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">ℜ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Reals</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="double-struck">R</mi></mrow><annotation encoding="application/x-tex">\Reals</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord mathbb">R</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\reals</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="double-struck">R</mi></mrow><annotation encoding="application/x-tex">\reals</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord mathbb">R</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\ref</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"><a href="https://github.com/KaTeX/KaTeX/issues/350" target="_blank" rel="noreferrer">Issue #350</a></td>
</tr>
<tr>
<td style="text-align:left">\relax</td>
<td style="text-align:left"></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\renewcommand</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>Ahoy!</mtext></mrow><annotation encoding="application/x-tex">\def\hail{Hi!}\renewcommand\hail{\text{Ahoy!}} \hail</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord text"><span class="mord">Ahoy!</span></span></span></span></span></td>
<td style="text-align:left"><code>\def\hail{Hi!}</code><br><code>\renewcommand\hail{\text{Ahoy!}}</code><br><code>\hail</code></td>
</tr>
<tr>
<td style="text-align:left">\renewenvironment</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\require</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\restriction</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↾</mo></mrow><annotation encoding="application/x-tex">\restriction</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8867em;vertical-align:-0.1944em;"></span><span class="mrel amsrm">↾</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\rfloor</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">⌋</mo></mrow><annotation encoding="application/x-tex">\rfloor</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mclose">⌋</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\rgroup</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">⟯</mo></mrow><annotation encoding="application/x-tex">\rgroup</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.989em;vertical-align:-0.244em;"></span><span class="mclose">⟯</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\rhd</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊳</mo></mrow><annotation encoding="application/x-tex">\rhd</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.585em;vertical-align:-0.0352em;"></span><span class="mord amsrm">⊳</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Rho</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">P</mi></mrow><annotation encoding="application/x-tex">\Rho</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathrm">P</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\rho</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ρ</mi></mrow><annotation encoding="application/x-tex">\rho</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">ρ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\right</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle displaystyle="true" scriptlevel="0"><mfrac><mi>a</mi><mi>b</mi></mfrac></mstyle><mo fence="true">)</mo></mrow><annotation encoding="application/x-tex">\left.\dfrac a b\right)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.836em;vertical-align:-0.686em;"></span><span class="minner"><span class="mopen nulldelimiter"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1076em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">b</span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.686em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size2">)</span></span></span></span></span></span></td>
<td style="text-align:left"><code>\left.\dfrac a b\right)</code></td>
</tr>
<tr>
<td style="text-align:left">\Rightarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇒</mo></mrow><annotation encoding="application/x-tex">\Rightarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">⇒</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\rightarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>→</mo></mrow><annotation encoding="application/x-tex">\rightarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">→</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\rightarrowtail</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↣</mo></mrow><annotation encoding="application/x-tex">\rightarrowtail</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5359em;vertical-align:-0.0135em;"></span><span class="mrel amsrm">↣</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\rightharpoondown</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇁</mo></mrow><annotation encoding="application/x-tex">\rightharpoondown</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">⇁</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\rightharpoonup</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇀</mo></mrow><annotation encoding="application/x-tex">\rightharpoonup</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">⇀</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\rightleftarrows</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇄</mo></mrow><annotation encoding="application/x-tex">\rightleftarrows</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8558em;vertical-align:-0.1808em;"></span><span class="mrel amsrm">⇄</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\rightleftharpoons</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇌</mo></mrow><annotation encoding="application/x-tex">\rightleftharpoons</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.682em;vertical-align:-0.011em;"></span><span class="mrel">⇌</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\rightrightarrows</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇉</mo></mrow><annotation encoding="application/x-tex">\rightrightarrows</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8558em;vertical-align:-0.1808em;"></span><span class="mrel amsrm">⇉</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\rightsquigarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇝</mo></mrow><annotation encoding="application/x-tex">\rightsquigarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3779em;"></span><span class="mrel amsrm">⇝</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\rightthreetimes</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋌</mo></mrow><annotation encoding="application/x-tex">\rightthreetimes</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mord amsrm">⋌</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\risingdotseq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≓</mo></mrow><annotation encoding="application/x-tex">\risingdotseq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.664em;vertical-align:-0.082em;"></span><span class="mrel amsrm">≓</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\rlap</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mpadded width="0px"><mrow><mtext> </mtext><mtext>/</mtext></mrow></mpadded><mo lspace="0em" rspace="0em">=</mo></mrow><annotation encoding="application/x-tex">\rlap{\,/}{=}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord vbox"><span class="thinbox"><span class="rlap"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="inner"><span class="mord"><span class="mord text"><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord textrm">/</span></span></span></span><span class="fix"></span></span></span></span><span class="mord"><span class="mrel">=</span></span></span></span></span></td>
<td style="text-align:left"><code>\rlap{\,/}{=}</code></td>
</tr>
<tr>
<td style="text-align:left">\rm</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">A</mi><mi mathvariant="normal">a</mi><mi mathvariant="normal">B</mi><mi mathvariant="normal">b</mi><mn>12</mn></mrow><annotation encoding="application/x-tex">\rm AaBb12</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord"><span class="mord mathrm">AaBb12</span></span></span></span></span></td>
<td style="text-align:left"><code>\rm AaBb12</code></td>
</tr>
<tr>
<td style="text-align:left">\rmoustache</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">⎱</mo></mrow><annotation encoding="application/x-tex">\rmoustache</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.989em;vertical-align:-0.244em;"></span><span class="mclose">⎱</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\root</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\rotatebox</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"><a href="https://github.com/KaTeX/KaTeX/issues/681" target="_blank" rel="noreferrer">Issue #681</a></td>
</tr>
<tr>
<td style="text-align:left">\rparen</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">\rparen</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mclose">)</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\rq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msup><mrow></mrow><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup></mrow><annotation encoding="application/x-tex">\rq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7519em;"></span><span class="mord"><span></span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.7519em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\rrbracket</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo mathvariant="normal" lspace="0em" rspace="0em">⟧</mo></mrow><annotation encoding="application/x-tex">\rrbracket</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mclose"><span class="mclose">]</span><span class="mspace" style="margin-right:-0.1778em;"></span><span class="mclose">]</span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Rrightarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇛</mo></mrow><annotation encoding="application/x-tex">\Rrightarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7733em;vertical-align:-0.1367em;"></span><span class="mrel amsrm">⇛</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Rsh</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↱</mo></mrow><annotation encoding="application/x-tex">\Rsh</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mrel amsrm">↱</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\rtimes</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋊</mo></mrow><annotation encoding="application/x-tex">\rtimes</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6633em;vertical-align:-0.0817em;"></span><span class="mord amsrm">⋊</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Rule</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left">see <code>\rule</code></td>
</tr>
<tr>
<td style="text-align:left">\rule</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>x</mi><mpadded height="0.6em" voffset="0.6em"><mspace mathbackground="black" width="0.862em" height="0.431em"></mspace></mpadded><mi>x</mi></mrow><annotation encoding="application/x-tex">x\rule[6pt]{2ex}{1ex}x</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.031em;"></span><span class="mord mathnormal">x</span><span class="mord rule" style="border-right-width:0.862em;border-top-width:0.431em;bottom:0.6em;"></span><span class="mord mathnormal">x</span></span></span></span></td>
<td style="text-align:left"><code>x\rule[6pt]{2ex}{1ex}x</code></td>
</tr>
<tr>
<td style="text-align:left">\rVert</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">∥</mo></mrow><annotation encoding="application/x-tex">\rVert</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mclose">∥</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\rvert</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">∣</mo></mrow><annotation encoding="application/x-tex">\rvert</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mclose">∣</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
</tbody>
</table>
<h2 id="s" tabindex="-1">S <a class="header-anchor" href="#s" aria-label="Permalink to &quot;S&quot;">&ZeroWidthSpace;</a></h2>
<table>
<thead>
<tr>
<th style="text-align:left">Symbol/Function</th>
<th style="text-align:left">Rendered</th>
<th style="text-align:left">Source or Comment</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">\S</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>§</mtext></mrow><annotation encoding="application/x-tex">\text{\S}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord text"><span class="mord">§</span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\S}</code></td>
</tr>
<tr>
<td style="text-align:left">\Sampi</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\sampi</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\sc</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"><a href="https://github.com/KaTeX/KaTeX/issues/471" target="_blank" rel="noreferrer">Issue #471</a></td>
</tr>
<tr>
<td style="text-align:left">\scalebox</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\scr</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left">See <code>\mathscr</code></td>
</tr>
<tr>
<td style="text-align:left">\scriptscriptstyle</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle scriptlevel="2" displaystyle="false"><mfrac><mi>c</mi><mi>d</mi></mfrac></mstyle></mrow><annotation encoding="application/x-tex">\scriptscriptstyle \frac cd</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6748em;vertical-align:-0.266em;"></span><span class="mord mtight sizing reset-size6 size1"><span class="mopen nulldelimiter sizing reset-size1 size6"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8176em;"><span style="top:-2.468em;"><span class="pstrut" style="height:3em;"></span><span class="mord mtight"><span class="mord mathnormal mtight">d</span></span></span><span style="top:-3.2255em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line mtight" style="border-bottom-width:0.049em;"></span></span><span style="top:-3.387em;"><span class="pstrut" style="height:3em;"></span><span class="mord mtight"><span class="mord mathnormal mtight">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.532em;"><span></span></span></span></span></span><span class="mclose nulldelimiter sizing reset-size1 size6"></span></span></span></span></span></td>
<td style="text-align:left"><code>\scriptscriptstyle \frac cd</code></td>
</tr>
<tr>
<td style="text-align:left">\scriptsize</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathsize="0.7em"><mi>s</mi><mi>c</mi><mi>r</mi><mi>i</mi><mi>p</mi><mi>t</mi><mi>s</mi><mi>i</mi><mi>z</mi><mi>e</mi></mstyle></mrow><annotation encoding="application/x-tex">\scriptsize scriptsize</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5978em;vertical-align:-0.1361em;"></span><span class="mord mathnormal sizing reset-size6 size3" style="margin-right:0.02778em;">scr</span><span class="mord mathnormal sizing reset-size6 size3">i</span><span class="mord mathnormal sizing reset-size6 size3">pt</span><span class="mord mathnormal sizing reset-size6 size3">s</span><span class="mord mathnormal sizing reset-size6 size3">i</span><span class="mord mathnormal sizing reset-size6 size3">ze</span></span></span></span></td>
<td style="text-align:left"><code>\scriptsize scriptsize</code></td>
</tr>
<tr>
<td style="text-align:left">\scriptstyle</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mfrac><mi>a</mi><mi>b</mi></mfrac><mo>+</mo><mstyle scriptlevel="1" displaystyle="false"><mfrac><mi>c</mi><mi>d</mi></mfrac></mstyle></mrow><annotation encoding="application/x-tex">\frac ab + {\scriptstyle \frac cd}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0404em;vertical-align:-0.345em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6954em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">b</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">a</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.7249em;vertical-align:-0.2408em;"></span><span class="mord"><span class="mord mtight sizing reset-size6 size3"><span class="mopen nulldelimiter sizing reset-size3 size6"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6915em;"><span style="top:-2.656em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size3 size1 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">d</span></span></span></span><span style="top:-3.2255em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line mtight" style="border-bottom-width:0.049em;"></span></span><span style="top:-3.384em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size3 size1 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">c</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.344em;"><span></span></span></span></span></span><span class="mclose nulldelimiter sizing reset-size3 size6"></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\frac ab + {\scriptstyle \frac cd}</code></td>
</tr>
<tr>
<td style="text-align:left">\sdot</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋅</mo></mrow><annotation encoding="application/x-tex">\sdot</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4445em;"></span><span class="mord">⋅</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\searrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↘</mo></mrow><annotation encoding="application/x-tex">\searrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel">↘</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\sec</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>sec</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\sec</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mop">sec</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\sect</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>§</mtext></mrow><annotation encoding="application/x-tex">\text{\sect}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord text"><span class="mord">§</span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\sect}</code></td>
</tr>
<tr>
<td style="text-align:left">\setlength</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"><a href="https://github.com/KaTeX/KaTeX/issues/687" target="_blank" rel="noreferrer">Issue #687</a></td>
</tr>
<tr>
<td style="text-align:left">\setminus</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∖</mo></mrow><annotation encoding="application/x-tex">\setminus</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">∖</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\sf</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="sans-serif">A</mi><mi mathvariant="sans-serif">a</mi><mi mathvariant="sans-serif">B</mi><mi mathvariant="sans-serif">b</mi><mn mathvariant="sans-serif">123</mn></mrow><annotation encoding="application/x-tex">\sf AaBb123</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord"><span class="mord mathsf">AaBb123</span></span></span></span></span></td>
<td style="text-align:left"><code>\sf AaBb123</code></td>
</tr>
<tr>
<td style="text-align:left">\sharp</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">♯</mi></mrow><annotation encoding="application/x-tex">\sharp</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord">♯</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\shortmid</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∣</mo></mrow><annotation encoding="application/x-tex">\shortmid</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6633em;vertical-align:-0.0817em;"></span><span class="mrel amsrm">∣</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\shortparallel</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∥</mo></mrow><annotation encoding="application/x-tex">\shortparallel</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6633em;vertical-align:-0.0817em;"></span><span class="mrel amsrm">∥</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\shoveleft</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\shoveright</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\sideset</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Sigma</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Σ</mi></mrow><annotation encoding="application/x-tex">\Sigma</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">Σ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\sigma</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>σ</mi></mrow><annotation encoding="application/x-tex">\sigma</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">σ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\sim</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∼</mo></mrow><annotation encoding="application/x-tex">\sim</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">∼</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\simeq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≃</mo></mrow><annotation encoding="application/x-tex">\simeq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4637em;"></span><span class="mrel">≃</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\sin</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>sin</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\sin</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6679em;"></span><span class="mop">sin</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\sinh</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>sinh</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\sinh</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mop">sinh</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\sixptsize</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathsize="0.6em"><mi>s</mi><mi>i</mi><mi>x</mi><mi>p</mi><mi>t</mi><mi>s</mi><mi>i</mi><mi>z</mi><mi>e</mi></mstyle></mrow><annotation encoding="application/x-tex">\sixptsize sixptsize</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5124em;vertical-align:-0.1167em;"></span><span class="mord mathnormal sizing reset-size6 size2">s</span><span class="mord mathnormal sizing reset-size6 size2">i</span><span class="mord mathnormal sizing reset-size6 size2">x</span><span class="mord mathnormal sizing reset-size6 size2">pt</span><span class="mord mathnormal sizing reset-size6 size2">s</span><span class="mord mathnormal sizing reset-size6 size2">i</span><span class="mord mathnormal sizing reset-size6 size2">ze</span></span></span></span></td>
<td style="text-align:left"><code>\sixptsize sixptsize</code></td>
</tr>
<tr>
<td style="text-align:left">\sh</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>sh</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\sh</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mop">sh</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\skew</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\skip</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\sl</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\small</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathsize="0.9em"><mi>s</mi><mi>m</mi><mi>a</mi><mi>l</mi><mi>l</mi></mstyle></mrow><annotation encoding="application/x-tex">\small small</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;"></span><span class="mord mathnormal sizing reset-size6 size5">s</span><span class="mord mathnormal sizing reset-size6 size5">ma</span><span class="mord mathnormal sizing reset-size6 size5" style="margin-right:0.01968em;">ll</span></span></span></span></td>
<td style="text-align:left"><code>\small small</code></td>
</tr>
<tr>
<td style="text-align:left">\smallfrown</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⌢</mo></mrow><annotation encoding="application/x-tex">\smallfrown</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8867em;vertical-align:-0.1944em;"></span><span class="mrel amsrm">⌢</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\smallint</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo largeop="false">∫</mo></mrow><annotation encoding="application/x-tex">\smallint</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1111em;vertical-align:-0.3061em;"></span><span class="mop op-symbol small-op" style="margin-right:0.19445em;position:relative;top:-0.0006em;">∫</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left" smallmatrix=""></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle scriptlevel="1"><mtable rowspacing="0.1em" columnspacing="0.2778em"><mtr><mtd><mstyle scriptlevel="1" displaystyle="false"><mi>a</mi></mstyle></mtd><mtd><mstyle scriptlevel="1" displaystyle="false"><mi>b</mi></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="1" displaystyle="false"><mi>c</mi></mstyle></mtd><mtd><mstyle scriptlevel="1" displaystyle="false"><mi>d</mi></mstyle></mtd></mtr></mtable></mstyle></mrow><annotation encoding="application/x-tex">\begin{smallmatrix} a &amp; b \\ c &amp; d \end{smallmatrix}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.3322em;vertical-align:-0.4161em;"></span><span class="mord"><span class="mtable"><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.9161em;"><span style="top:-3.13em;"><span class="pstrut" style="height:2.7em;"></span><span class="mord mtight sizing reset-size6 size3"><span class="mord mathnormal mtight">a</span></span></span><span style="top:-2.4639em;"><span class="pstrut" style="height:2.7em;"></span><span class="mord mtight sizing reset-size6 size3"><span class="mord mathnormal mtight">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.4161em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:0.1945em;"></span><span class="arraycolsep" style="width:0.1945em;"></span><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.9161em;"><span style="top:-3.13em;"><span class="pstrut" style="height:2.7em;"></span><span class="mord mtight sizing reset-size6 size3"><span class="mord mathnormal mtight">b</span></span></span><span style="top:-2.4639em;"><span class="pstrut" style="height:2.7em;"></span><span class="mord mtight sizing reset-size6 size3"><span class="mord mathnormal mtight">d</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.4161em;"><span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\begin{smallmatrix}</code><br>   <code>a &amp; b \\</code><br>   <code>c &amp; d</code><br><code>\end{smallmatrix}</code></td>
</tr>
<tr>
<td style="text-align:left">\smallsetminus</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∖</mo></mrow><annotation encoding="application/x-tex">\smallsetminus</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6633em;vertical-align:-0.0817em;"></span><span class="mord amsrm">∖</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\smallsmile</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⌣</mo></mrow><annotation encoding="application/x-tex">\smallsmile</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8867em;vertical-align:-0.1944em;"></span><span class="mrel amsrm">⌣</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\smash</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true">(</mo><msup><mi>x</mi><mpadded height="0px" depth="0px"><mn>2</mn></mpadded></msup><mo fence="true">)</mo></mrow><annotation encoding="application/x-tex">\left(x^{\smash{2}}\right)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="minner"><span class="mopen delimcenter" style="top:0em;">(</span><span class="mord"><span class="mord mathnormal">x</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.363em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0em;"><span style="top:-2.7em;"><span class="pstrut" style="height:2.7em;"></span><span><span class="mord mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;">)</span></span></span></span></span></td>
<td style="text-align:left"><code>\left(x^{\smash{2}}\right)</code></td>
</tr>
<tr>
<td style="text-align:left">\smile</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⌣</mo></mrow><annotation encoding="application/x-tex">\smile</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3576em;"></span><span class="mrel">⌣</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\smiley</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\sout</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><menclose notation="horizontalstrike"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></menclose></mrow><annotation encoding="application/x-tex">\sout{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6944em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">ab</span><span class="mord mathnormal">c</span></span></span><span style="top:-3.2155em;"><span class="pstrut" style="height:3em;"></span><span class="stretchy sout"></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\sout{abc}</code></td>
</tr>
<tr>
<td style="text-align:left">\Space</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left">see <code>\space</code></td>
</tr>
<tr>
<td style="text-align:left">\space</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mtext> </mtext><mi>b</mi></mrow><annotation encoding="application/x-tex">a\space b</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">a</span><span class="mspace"> </span><span class="mord mathnormal">b</span></span></span></span></td>
<td style="text-align:left"><code>a\space b</code></td>
</tr>
<tr>
<td style="text-align:left">\spades</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">♠</mi></mrow><annotation encoding="application/x-tex">\spades</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8241em;vertical-align:-0.1296em;"></span><span class="mord">♠</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\spadesuit</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">♠</mi></mrow><annotation encoding="application/x-tex">\spadesuit</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8241em;vertical-align:-0.1296em;"></span><span class="mord">♠</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\sphericalangle</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∢</mi></mrow><annotation encoding="application/x-tex">\sphericalangle</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5576em;vertical-align:-0.0352em;"></span><span class="mord amsrm">∢</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left" split=""></td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"><a href="https://github.com/KaTeX/KaTeX/issues/1345" target="_blank" rel="noreferrer">Issue #1345</a></td>
</tr>
<tr>
<td style="text-align:left">\sqcap</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊓</mo></mrow><annotation encoding="application/x-tex">\sqcap</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5556em;"></span><span class="mord">⊓</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\sqcup</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊔</mo></mrow><annotation encoding="application/x-tex">\sqcup</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5556em;"></span><span class="mord">⊔</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\square</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">□</mi></mrow><annotation encoding="application/x-tex">\square</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.675em;"></span><span class="mord amsrm">□</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\sqrt</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mroot><mi>x</mi><mn>3</mn></mroot></mrow><annotation encoding="application/x-tex">\sqrt[3]{x}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.04em;vertical-align:-0.2397em;"></span><span class="mord sqrt"><span class="root"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6586em;"><span style="top:-2.8363em;"><span class="pstrut" style="height:2.5em;"></span><span class="sizing reset-size6 size1 mtight"><span class="mord mtight"><span class="mord mtight">3</span></span></span></span></span></span></span></span><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8003em;"><span class="svg-align" style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord" style="padding-left:0.833em;"><span class="mord mathnormal">x</span></span></span><span style="top:-2.7603em;"><span class="pstrut" style="height:3em;"></span><span class="hide-tail" style="min-width:0.853em;height:1.08em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='1.08em' viewBox='0 0 400000 1080' preserveAspectRatio='xMinYMin slice'><path d='M95,702
c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14
c0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54
c44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10
s173,378,173,378c0.7,0,35.3,-71,104,-213c68.7,-142,137.5,-285,206.5,-429
c69,-144,104.5,-217.7,106.5,-221
l0 -0
c5.3,-9.3,12,-14,20,-14
H400000v40H845.2724
s-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7
c-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z
M834 80h400000v40h-400000z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2397em;"><span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\sqrt[3]{x}</code></td>
</tr>
<tr>
<td style="text-align:left">\sqsubset</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊏</mo></mrow><annotation encoding="application/x-tex">\sqsubset</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.585em;vertical-align:-0.0352em;"></span><span class="mrel amsrm">⊏</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\sqsubseteq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊑</mo></mrow><annotation encoding="application/x-tex">\sqsubseteq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mrel">⊑</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\sqsupset</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊐</mo></mrow><annotation encoding="application/x-tex">\sqsupset</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.585em;vertical-align:-0.0352em;"></span><span class="mrel amsrm">⊐</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\sqsupseteq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊒</mo></mrow><annotation encoding="application/x-tex">\sqsupseteq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mrel">⊒</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\ss</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>ß</mtext></mrow><annotation encoding="application/x-tex">\text{\ss}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord">ß</span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\ss}</code></td>
</tr>
<tr>
<td style="text-align:left">\stackrel</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mover><mo><mo>=</mo></mo><mo stretchy="false" lspace="0em" rspace="0em">!</mo></mover></mo></mrow><annotation encoding="application/x-tex">\stackrel{!}{=}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.153em;"></span><span class="mrel"><span class="mop op-limits"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:1.153em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span><span class="mop">=</span></span></span><span style="top:-3.5669em;margin-left:0em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mclose mtight">!</span></span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\stackrel{!}{=}</code></td>
</tr>
<tr>
<td style="text-align:left">\star</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋆</mo></mrow><annotation encoding="application/x-tex">\star</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4653em;"></span><span class="mord">⋆</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Stigma</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\stigma</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\strut</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\style</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left">Non standard</td>
</tr>
<tr>
<td style="text-align:left">\sub</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊂</mo></mrow><annotation encoding="application/x-tex">\sub</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">⊂</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left" subarray=""></td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\sube</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊆</mo></mrow><annotation encoding="application/x-tex">\sube</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mrel">⊆</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Subset</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋐</mo></mrow><annotation encoding="application/x-tex">\Subset</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.585em;vertical-align:-0.0352em;"></span><span class="mrel amsrm">⋐</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\subset</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊂</mo></mrow><annotation encoding="application/x-tex">\subset</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">⊂</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\subseteq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊆</mo></mrow><annotation encoding="application/x-tex">\subseteq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mrel">⊆</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\subseteqq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⫅</mo></mrow><annotation encoding="application/x-tex">\subseteqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0117em;vertical-align:-0.2558em;"></span><span class="mrel amsrm">⫅</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\subsetneq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊊</mo></mrow><annotation encoding="application/x-tex">\subsetneq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mrel amsrm">⊊</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\subsetneqq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⫋</mo></mrow><annotation encoding="application/x-tex">\subsetneqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0786em;vertical-align:-0.2848em;"></span><span class="mrel amsrm">⫋</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\substack</td>
<td style="text-align:left">$$\sum_{\substack{0&lt;i&lt;m\0&lt;j&lt;n}}$$</td>
<td style="text-align:left"><code>\sum_{\substack{0&lt;i&lt;m\\0&lt;j&lt;n}}</code></td>
</tr>
<tr>
<td style="text-align:left">\succ</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≻</mo></mrow><annotation encoding="application/x-tex">\succ</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">≻</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\succapprox</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⪸</mo></mrow><annotation encoding="application/x-tex">\succapprox</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0189em;vertical-align:-0.2617em;"></span><span class="mrel amsrm">⪸</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\succcurlyeq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≽</mo></mrow><annotation encoding="application/x-tex">\succcurlyeq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7733em;vertical-align:-0.1367em;"></span><span class="mrel amsrm">≽</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\succeq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⪰</mo></mrow><annotation encoding="application/x-tex">\succeq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mrel">⪰</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\succnapprox</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⪺</mo></mrow><annotation encoding="application/x-tex">\succnapprox</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0189em;vertical-align:-0.2617em;"></span><span class="mrel amsrm">⪺</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\succneqq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⪶</mo></mrow><annotation encoding="application/x-tex">\succneqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0087em;vertical-align:-0.2514em;"></span><span class="mrel amsrm">⪶</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\succnsim</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋩</mo></mrow><annotation encoding="application/x-tex">\succnsim</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9733em;vertical-align:-0.2322em;"></span><span class="mrel amsrm">⋩</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\succsim</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≿</mo></mrow><annotation encoding="application/x-tex">\succsim</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9592em;vertical-align:-0.2296em;"></span><span class="mrel amsrm">≿</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\sum</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∑</mo></mrow><annotation encoding="application/x-tex">\sum</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mop op-symbol small-op" style="position:relative;top:0em;">∑</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\sup</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>sup</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\sup</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mop">sup</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\supe</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊇</mo></mrow><annotation encoding="application/x-tex">\supe</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mrel">⊇</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Supset</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⋑</mo></mrow><annotation encoding="application/x-tex">\Supset</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.585em;vertical-align:-0.0352em;"></span><span class="mrel amsrm">⋑</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\supset</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊃</mo></mrow><annotation encoding="application/x-tex">\supset</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mrel">⊃</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\supseteq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊇</mo></mrow><annotation encoding="application/x-tex">\supseteq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mrel">⊇</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\supseteqq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⫆</mo></mrow><annotation encoding="application/x-tex">\supseteqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0117em;vertical-align:-0.2558em;"></span><span class="mrel amsrm">⫆</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\supsetneq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊋</mo></mrow><annotation encoding="application/x-tex">\supsetneq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mrel amsrm">⊋</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\supsetneqq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⫌</mo></mrow><annotation encoding="application/x-tex">\supsetneqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0786em;vertical-align:-0.2848em;"></span><span class="mrel amsrm">⫌</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\surd</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">√</mi></mrow><annotation encoding="application/x-tex">\surd</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.2em;"></span><span class="mord">√</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\swarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↙</mo></mrow><annotation encoding="application/x-tex">\swarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel">↙</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
</tbody>
</table>
<h2 id="t" tabindex="-1">T <a class="header-anchor" href="#t" aria-label="Permalink to &quot;T&quot;">&ZeroWidthSpace;</a></h2>
<table>
<thead>
<tr>
<th style="text-align:left">Symbol/Function</th>
<th style="text-align:left">Rendered</th>
<th style="text-align:left">Source or Comment</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">\tag</td>
<td style="text-align:left">$$\tag{3.1c} a^2+b^2=c^2$$</td>
<td style="text-align:left"><code>\tag{3.1c} a^2+b^2=c^2</code></td>
</tr>
<tr>
<td style="text-align:left">\tag*</td>
<td style="text-align:left">$$\tag*{3.1c} a^2+b^2=c^2$$</td>
<td style="text-align:left"><code>\tag*{3.1c} a^2+b^2=c^2</code></td>
</tr>
<tr>
<td style="text-align:left">\tan</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>tan</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\tan</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6151em;"></span><span class="mop">tan</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\tanh</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>tanh</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\tanh</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mop">tanh</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Tau</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">T</mi></mrow><annotation encoding="application/x-tex">\Tau</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathrm">T</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\tau</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>τ</mi></mrow><annotation encoding="application/x-tex">\tau</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal" style="margin-right:0.1132em;">τ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\tbinom</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true">(</mo><mfrac linethickness="0px"><mi>n</mi><mi>k</mi></mfrac><mo fence="true">)</mo></mrow><annotation encoding="application/x-tex">\tbinom n k</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2em;vertical-align:-0.35em;"></span><span class="mord"><span class="mopen delimcenter" style="top:0em;"><span class="delimsizing size1">(</span></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.7454em;"><span style="top:-2.355em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right:0.03148em;">k</span></span></span></span><span style="top:-3.144em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">n</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose delimcenter" style="top:0em;"><span class="delimsizing size1">)</span></span></span></span></span></span></td>
<td style="text-align:left"><code>\tbinom n k</code></td>
</tr>
<tr>
<td style="text-align:left">\TeX</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>TeX</mtext></mrow><annotation encoding="application/x-tex">\TeX</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8988em;vertical-align:-0.2155em;"></span><span class="mord text"><span class="mord textrm">T</span><span class="mspace" style="margin-right:-0.1667em;"></span><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.4678em;"><span style="top:-2.7845em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord textrm">E</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2155em;"><span></span></span></span></span><span class="mspace" style="margin-right:-0.125em;"></span><span class="mord textrm">X</span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\text</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext> yes </mtext><mi mathvariant="normal">&amp;</mi><mtext> no </mtext></mrow><annotation encoding="application/x-tex">\text{ yes }\&amp;\text{ no }</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord text"><span class="mord"> yes </span></span><span class="mord">&amp;</span><span class="mord text"><span class="mord"> no </span></span></span></span></span></td>
<td style="text-align:left"><code>\text{ yes }\&amp;\text{ no }</code></td>
</tr>
<tr>
<td style="text-align:left">\textasciitilde</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>~</mtext></mrow><annotation encoding="application/x-tex">\text{\textasciitilde}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6679em;vertical-align:-0.35em;"></span><span class="mord text"><span class="mord">~</span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\textasciitilde}</code></td>
</tr>
<tr>
<td style="text-align:left">\textasciicircum</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>^</mtext></mrow><annotation encoding="application/x-tex">\text{\textasciicircum}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord">^</span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\textasciicircum}</code></td>
</tr>
<tr>
<td style="text-align:left">\textbackslash</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>\</mtext></mrow><annotation encoding="application/x-tex">\text{\textbackslash}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord text"><span class="mord">\</span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\textbackslash}</code></td>
</tr>
<tr>
<td style="text-align:left">\textbar</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>|</mtext></mrow><annotation encoding="application/x-tex">\text{\textbar}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord text"><span class="mord">|</span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\textbar}</code></td>
</tr>
<tr>
<td style="text-align:left">\textbardbl</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>∥</mtext></mrow><annotation encoding="application/x-tex">\text{\textbardbl}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord text"><span class="mord">∥</span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\textbardbl}</code></td>
</tr>
<tr>
<td style="text-align:left">\textbf</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext mathvariant="bold">AaBb123</mtext></mrow><annotation encoding="application/x-tex">\textbf{AaBb123}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord textbf">AaBb123</span></span></span></span></span></td>
<td style="text-align:left"><code>\textbf{AaBb123}</code></td>
</tr>
<tr>
<td style="text-align:left">\textbraceleft</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>{</mtext></mrow><annotation encoding="application/x-tex">\text{\textbraceleft}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord text"><span class="mord">{</span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\textbraceleft}</code></td>
</tr>
<tr>
<td style="text-align:left">\textbraceright</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>}</mtext></mrow><annotation encoding="application/x-tex">\text{\textbraceright}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord text"><span class="mord">}</span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\textbraceright}</code></td>
</tr>
<tr>
<td style="text-align:left">\textcircled</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mtext>a</mtext><mo>◯</mo></mover></mrow><annotation encoding="application/x-tex">\text{\textcircled a}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;"></span><span class="mord text"><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8889em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord">a</span></span><span style="top:-3.1944em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body accent-full" style="left:0em;top:.2em;"><span class="mord">◯</span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\textcircled a}</code></td>
</tr>
<tr>
<td style="text-align:left">\textcolor</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathcolor="blue"><mi>F</mi><mo>=</mo><mi>m</mi><mi>a</mi></mstyle></mrow><annotation encoding="application/x-tex">\textcolor{blue}{F=ma}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathnormal" style="margin-right:0.13889em;color:blue;">F</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel" style="color:blue;">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal" style="color:blue;">ma</span></span></span></span></td>
<td style="text-align:left"><code>\textcolor{blue}{F=ma}</code></td>
</tr>
<tr>
<td style="text-align:left">\textdagger</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>†</mtext></mrow><annotation encoding="application/x-tex">\text{\textdagger}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord text"><span class="mord">†</span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\textdagger}</code></td>
</tr>
<tr>
<td style="text-align:left">\textdaggerdbl</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>‡</mtext></mrow><annotation encoding="application/x-tex">\text{\textdaggerdbl}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord text"><span class="mord">‡</span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\textdaggerdbl}</code></td>
</tr>
<tr>
<td style="text-align:left">\textdegree</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>°</mtext></mrow><annotation encoding="application/x-tex">\text{\textdegree}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord">°</span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\textdegree}</code></td>
</tr>
<tr>
<td style="text-align:left">\textdollar</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>$</mtext></mrow><annotation encoding="application/x-tex">\text{\textdollar}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8056em;vertical-align:-0.0556em;"></span><span class="mord text"><span class="mord">$</span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\textdollar}</code></td>
</tr>
<tr>
<td style="text-align:left">\textellipsis</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>…</mo></mrow><annotation encoding="application/x-tex">\text{\textellipsis}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.123em;"></span><span class="mord text"><span class="minner">…</span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\textellipsis}</code></td>
</tr>
<tr>
<td style="text-align:left">\textemdash</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>—</mtext></mrow><annotation encoding="application/x-tex">\text{\textemdash}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord text"><span class="mord">—</span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\textemdash}</code></td>
</tr>
<tr>
<td style="text-align:left">\textendash</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>–</mtext></mrow><annotation encoding="application/x-tex">\text{\textendash}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord text"><span class="mord">–</span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\textendash}</code></td>
</tr>
<tr>
<td style="text-align:left">\textgreater</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>&gt;</mtext></mrow><annotation encoding="application/x-tex">\text{\textgreater}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mord text"><span class="mord">&gt;</span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\textgreater}</code></td>
</tr>
<tr>
<td style="text-align:left">\textit</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext mathvariant="italic">AaBb</mtext></mrow><annotation encoding="application/x-tex">\textit{AaBb}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord textit">AaBb</span></span></span></span></span></td>
<td style="text-align:left"><code>\textit{AaBb}</code></td>
</tr>
<tr>
<td style="text-align:left">\textless</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>&lt;</mtext></mrow><annotation encoding="application/x-tex">\text{\textless}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5782em;vertical-align:-0.0391em;"></span><span class="mord text"><span class="mord">&lt;</span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\textless}</code></td>
</tr>
<tr>
<td style="text-align:left">\textmd</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>AaBb123</mtext></mrow><annotation encoding="application/x-tex">\textmd{AaBb123}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord textmd">AaBb123</span></span></span></span></span></td>
<td style="text-align:left"><code>\textmd{AaBb123}</code></td>
</tr>
<tr>
<td style="text-align:left">\textnormal</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>AB</mtext></mrow><annotation encoding="application/x-tex">\textnormal{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord text"><span class="mord textrm">AB</span></span></span></span></span></td>
<td style="text-align:left"><code>\textnormal{AB}</code></td>
</tr>
<tr>
<td style="text-align:left">\textquotedblleft</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>“</mtext></mrow><annotation encoding="application/x-tex">\text{\textquotedblleft}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord">“</span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\textquotedblleft}</code></td>
</tr>
<tr>
<td style="text-align:left">\textquotedblright</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>”</mtext></mrow><annotation encoding="application/x-tex">\text{\textquotedblright}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord">”</span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\textquotedblright}</code></td>
</tr>
<tr>
<td style="text-align:left">\textquoteleft</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>‘</mtext></mrow><annotation encoding="application/x-tex">\text{\textquoteleft}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord">‘</span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\textquoteleft}</code></td>
</tr>
<tr>
<td style="text-align:left">\textquoteright</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>’</mtext></mrow><annotation encoding="application/x-tex">\text{\textquoteright}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord">’</span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\textquoteright}</code></td>
</tr>
<tr>
<td style="text-align:left">\textregistered</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>®</mtext></mrow><annotation encoding="application/x-tex">\text{\textregistered}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;"></span><span class="mord text"><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8889em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord sizing reset-size6 size3">R</span></span></span><span style="top:-3.1944em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body accent-full" style="left:0em;top:.2em;"><span class="mord">◯</span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\textregistered}</code></td>
</tr>
<tr>
<td style="text-align:left">\textrm</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>AaBb123</mtext></mrow><annotation encoding="application/x-tex">\textrm{AaBb123}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord textrm">AaBb123</span></span></span></span></span></td>
<td style="text-align:left"><code>\textrm{AaBb123}</code></td>
</tr>
<tr>
<td style="text-align:left">\textsc</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"><a href="https://github.com/KaTeX/KaTeX/issues/471" target="_blank" rel="noreferrer">Issue #471</a></td>
</tr>
<tr>
<td style="text-align:left">\textsf</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext mathvariant="sans-serif">AaBb123</mtext></mrow><annotation encoding="application/x-tex">\textsf{AaBb123}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord textsf">AaBb123</span></span></span></span></span></td>
<td style="text-align:left"><code>\textsf{AaBb123}</code></td>
</tr>
<tr>
<td style="text-align:left">\textsl</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\textsterling</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>£</mtext></mrow><annotation encoding="application/x-tex">\text{\textsterling}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord">£</span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\textsterling}</code></td>
</tr>
<tr>
<td style="text-align:left">\textstyle</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle scriptlevel="0" displaystyle="false"><msubsup><mo>∑</mo><mn>0</mn><mi>n</mi></msubsup></mstyle></mrow><annotation encoding="application/x-tex">\textstyle\sum_0^n</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.104em;vertical-align:-0.2997em;"></span><span class="mop"><span class="mop op-symbol small-op" style="position:relative;top:0em;">∑</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.8043em;"><span style="top:-2.4003em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">0</span></span></span><span style="top:-3.2029em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">n</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2997em;"><span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\textstyle\sum_0^n</code></td>
</tr>
<tr>
<td style="text-align:left">\texttip</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\texttt</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext mathvariant="monospace">AaBb123</mtext></mrow><annotation encoding="application/x-tex">\texttt{AaBb123}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6111em;"></span><span class="mord text"><span class="mord texttt">AaBb123</span></span></span></span></span></td>
<td style="text-align:left"><code>\texttt{AaBb123}</code></td>
</tr>
<tr>
<td style="text-align:left">\textunderscore</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>_</mtext></mrow><annotation encoding="application/x-tex">\text{\textunderscore}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;vertical-align:-0.31em;"></span><span class="mord text"><span class="mord">_</span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\textunderscore}</code></td>
</tr>
<tr>
<td style="text-align:left">\textup</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext>AaBb123</mtext></mrow><annotation encoding="application/x-tex">\textup{AaBb123}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord textup">AaBb123</span></span></span></span></span></td>
<td style="text-align:left"><code>\textup{AaBb123}</code></td>
</tr>
<tr>
<td style="text-align:left">\textvisiblespace</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\tfrac</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mfrac><mi>a</mi><mi>b</mi></mfrac></mrow><annotation encoding="application/x-tex">\tfrac ab</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0404em;vertical-align:-0.345em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6954em;"><span style="top:-2.655em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">b</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.394em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">a</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.345em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span></td>
<td style="text-align:left"><code>\tfrac ab</code></td>
</tr>
<tr>
<td style="text-align:left">\tg</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>tg</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\tg</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8095em;vertical-align:-0.1944em;"></span><span class="mop">t<span style="margin-right:0.01389em;">g</span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\th</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>th</mi><mo>⁡</mo></mrow><annotation encoding="application/x-tex">\th</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mop">th</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\therefore</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∴</mo></mrow><annotation encoding="application/x-tex">\therefore</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mrel amsrm">∴</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Theta</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Θ</mi></mrow><annotation encoding="application/x-tex">\Theta</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">Θ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\theta</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>θ</mi></mrow><annotation encoding="application/x-tex">\theta</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal" style="margin-right:0.02778em;">θ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\thetasym</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ϑ</mi></mrow><annotation encoding="application/x-tex">\thetasym</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">ϑ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\thickapprox</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≈</mo></mrow><annotation encoding="application/x-tex">\thickapprox</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4831em;"></span><span class="mrel amsrm">≈</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\thicksim</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∼</mo></mrow><annotation encoding="application/x-tex">\thicksim</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel amsrm">∼</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\thickspace</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mtext>  </mtext><mi>b</mi></mrow><annotation encoding="application/x-tex">a\thickspace b</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">a</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mord mathnormal">b</span></span></span></span></td>
<td style="text-align:left"><code>a\thickspace b</code></td>
</tr>
<tr>
<td style="text-align:left">\thinspace</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mtext> </mtext><mi>b</mi></mrow><annotation encoding="application/x-tex">a\thinspace b</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">a</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">b</span></span></span></span></td>
<td style="text-align:left"><code>a\thinspace b</code></td>
</tr>
<tr>
<td style="text-align:left">\tilde</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mi>M</mi><mo>~</mo></mover></mrow><annotation encoding="application/x-tex">\tilde M</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9202em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.9202em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord mathnormal" style="margin-right:0.10903em;">M</span></span><span style="top:-3.6023em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.1667em;"><span class="mord">~</span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\tilde M</code></td>
</tr>
<tr>
<td style="text-align:left">\times</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>×</mo></mrow><annotation encoding="application/x-tex">\times</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6667em;vertical-align:-0.0833em;"></span><span class="mord">×</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Tiny</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left">see <code>\tiny</code></td>
</tr>
<tr>
<td style="text-align:left">\tiny</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathsize="0.5em"><mi>t</mi><mi>i</mi><mi>n</mi><mi>y</mi></mstyle></mrow><annotation encoding="application/x-tex">\tiny tiny</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.427em;vertical-align:-0.0972em;"></span><span class="mord mathnormal sizing reset-size6 size1">t</span><span class="mord mathnormal sizing reset-size6 size1">in</span><span class="mord mathnormal sizing reset-size6 size1" style="margin-right:0.03588em;">y</span></span></span></span></td>
<td style="text-align:left"><code>\tiny tiny</code></td>
</tr>
<tr>
<td style="text-align:left">\to</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>→</mo></mrow><annotation encoding="application/x-tex">\to</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3669em;"></span><span class="mrel">→</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\toggle</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\top</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">⊤</mi></mrow><annotation encoding="application/x-tex">\top</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord">⊤</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\triangle</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">△</mi></mrow><annotation encoding="application/x-tex">\triangle</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord">△</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\triangledown</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">▽</mi></mrow><annotation encoding="application/x-tex">\triangledown</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5499em;"></span><span class="mord amsrm">▽</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\triangleleft</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>◃</mo></mrow><annotation encoding="application/x-tex">\triangleleft</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4653em;"></span><span class="mord">◃</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\trianglelefteq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊴</mo></mrow><annotation encoding="application/x-tex">\trianglelefteq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7733em;vertical-align:-0.1367em;"></span><span class="mrel amsrm">⊴</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\triangleq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≜</mo></mrow><annotation encoding="application/x-tex">\triangleq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9987em;vertical-align:-0.082em;"></span><span class="mrel amsrm">≜</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\triangleright</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>▹</mo></mrow><annotation encoding="application/x-tex">\triangleright</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4653em;"></span><span class="mord">▹</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\trianglerighteq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊵</mo></mrow><annotation encoding="application/x-tex">\trianglerighteq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7733em;vertical-align:-0.1367em;"></span><span class="mrel amsrm">⊵</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\tt</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="monospace">A</mi><mi mathvariant="monospace">a</mi><mi mathvariant="monospace">B</mi><mi mathvariant="monospace">b</mi><mn mathvariant="monospace">123</mn></mrow><annotation encoding="application/x-tex">{\tt AaBb123}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6111em;"></span><span class="mord"><span class="mord"><span class="mord mathtt">AaBb123</span></span></span></span></span></span></td>
<td style="text-align:left"><code>{\tt AaBb123}</code></td>
</tr>
<tr>
<td style="text-align:left">\twoheadleftarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↞</mo></mrow><annotation encoding="application/x-tex">\twoheadleftarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5359em;vertical-align:-0.0135em;"></span><span class="mrel amsrm">↞</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\twoheadrightarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↠</mo></mrow><annotation encoding="application/x-tex">\twoheadrightarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5359em;vertical-align:-0.0135em;"></span><span class="mrel amsrm">↠</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
</tbody>
</table>
<h2 id="u" tabindex="-1">U <a class="header-anchor" href="#u" aria-label="Permalink to &quot;U&quot;">&ZeroWidthSpace;</a></h2>
<table>
<thead>
<tr>
<th style="text-align:left">Symbol/Function</th>
<th style="text-align:left">Rendered</th>
<th style="text-align:left">Source or Comment</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">\u</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mtext>a</mtext><mo>˘</mo></mover></mrow><annotation encoding="application/x-tex">\text{\u{a}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord text"><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6944em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">a</span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.25em;"><span class="mord">˘</span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\u{a}}</code></td>
</tr>
<tr>
<td style="text-align:left">\Uarr</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇑</mo></mrow><annotation encoding="application/x-tex">\Uarr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel">⇑</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\uArr</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇑</mo></mrow><annotation encoding="application/x-tex">\uArr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel">⇑</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\uarr</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↑</mo></mrow><annotation encoding="application/x-tex">\uarr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel">↑</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\ulcorner</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mi mathvariant="normal">⌜</mi></mo></mrow><annotation encoding="application/x-tex">\ulcorner</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mopen amsrm">┌</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\underbrace</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><munder><munder><mrow><mi>x</mi><mo>+</mo><mo>⋯</mo><mo>+</mo><mi>x</mi></mrow><mo stretchy="true">⏟</mo></munder><mrow><mi>n</mi><mtext> times</mtext></mrow></munder></mrow><annotation encoding="application/x-tex">\underbrace{x+⋯+x}_{n\text{ times}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.9822em;vertical-align:-1.3988em;"></span><span class="mord munder"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.5833em;"><span style="top:-1.6012em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">n</span><span class="mord text mtight"><span class="mord mtight"> times</span></span></span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord munder"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.5833em;"><span class="svg-align" style="top:-2.2687em;"><span class="pstrut" style="height:3em;"></span><span class="stretchy" style="height:0.548em;min-width:1.6em;"><span class="brace-left" style="height:0.548em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.548em' viewBox='0 0 400000 548' preserveAspectRatio='xMinYMin slice'><path d='M0 6l6-6h17c12.688 0 19.313.3 20 1 4 4 7.313 8.3 10 13
 35.313 51.3 80.813 93.8 136.5 127.5 55.688 33.7 117.188 55.8 184.5 66.5.688
 0 2 .3 4 1 18.688 2.7 76 4.3 172 5h399450v120H429l-6-1c-124.688-8-235-61.7
-331-161C60.687 138.7 32.312 99.3 7 54L0 41V6z'/></svg></span><span class="brace-center" style="height:0.548em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.548em' viewBox='0 0 400000 548' preserveAspectRatio='xMidYMin slice'><path d='M199572 214
c100.7 8.3 195.3 44 280 108 55.3 42 101.7 93 139 153l9 14c2.7-4 5.7-8.7 9-14
 53.3-86.7 123.7-153 211-199 66.7-36 137.3-56.3 212-62h199568v120H200432c-178.3
 11.7-311.7 78.3-403 201-6 8-9.7 12-11 12-.7.7-6.7 1-18 1s-17.3-.3-18-1c-1.3 0
-5-4-11-12-44.7-59.3-101.3-106.3-170-141s-145.3-54.3-229-60H0V214z'/></svg></span><span class="brace-right" style="height:0.548em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.548em' viewBox='0 0 400000 548' preserveAspectRatio='xMaxYMin slice'><path d='M399994 0l6 6v35l-6 11c-56 104-135.3 181.3-238 232-57.3
 28.7-117 45-179 50H-300V214h399897c43.3-7 81-15 113-26 100.7-33 179.7-91 237
-174 2.7-5 6-9 10-13 .7-1 7.3-1 20-1h17z'/></svg></span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">x</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="minner">⋯</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mord mathnormal">x</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.7313em;"><span></span></span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:1.3988em;"><span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\underbrace{x+⋯+x}_{n\text{ times}}</code></td>
</tr>
<tr>
<td style="text-align:left">\underbracket</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\undergroup</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><munder accentunder="true"><mrow><mi>A</mi><mi>B</mi></mrow><mo stretchy="true">⏡</mo></munder></mrow><annotation encoding="application/x-tex">\undergroup{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0253em;vertical-align:-0.342em;"></span><span class="mord accentunder"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6833em;"><span class="svg-align" style="top:-2.658em;"><span class="pstrut" style="height:3em;"></span><span class="stretchy" style="height:0.342em;min-width:0.888em;"><span class="halfarrow-left" style="height:0.342em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.342em' viewBox='0 0 400000 342' preserveAspectRatio='xMinYMin slice'><path d='M400000 262
H435C64 262 168.3 112.6 21 82c-5.9-1.2-18 0-18 0-2 0-3 1-3 3v38c76 158 257 219
 435 219h399565z'/></svg></span><span class="halfarrow-right" style="height:0.342em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.342em' viewBox='0 0 400000 342' preserveAspectRatio='xMaxYMin slice'><path d='M0 262h399565c371 0 266.7-149.4 414-180 5.9-1.2 18 0 18
 0 2 0 3 1 3 3v38c-76 158-257 219-435 219H0z'/></svg></span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.342em;"><span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\undergroup{AB}</code></td>
</tr>
<tr>
<td style="text-align:left">\underleftarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><munder accentunder="true"><mrow><mi>A</mi><mi>B</mi></mrow><mo stretchy="true">←</mo></munder></mrow><annotation encoding="application/x-tex">\underleftarrow{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2053em;vertical-align:-0.522em;"></span><span class="mord accentunder"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6833em;"><span class="svg-align" style="top:-2.478em;"><span class="pstrut" style="height:3em;"></span><span class="hide-tail" style="height:0.522em;min-width:0.888em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMinYMin slice'><path d='M400000 241H110l3-3c68.7-52.7 113.7-120
 135-202 4-14.7 6-23 6-25 0-7.3-7-11-21-11-8 0-13.2.8-15.5 2.5-2.3 1.7-4.2 5.8
-5.5 12.5-1.3 4.7-2.7 10.3-4 17-12 48.7-34.8 92-68.5 130S65.3 228.3 18 247
c-10 4-16 7.7-18 11 0 8.7 6 14.3 18 17 47.3 18.7 87.8 47 121.5 85S196 441.3 208
 490c.7 2 1.3 5 2 9s1.2 6.7 1.5 8c.3 1.3 1 3.3 2 6s2.2 4.5 3.5 5.5c1.3 1 3.3
 1.8 6 2.5s6 1 10 1c14 0 21-3.7 21-11 0-2-2-10.3-6-25-20-79.3-65-146.7-135-202
 l-3-3h399890zM100 241v40h399900v-40z'/></svg></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.522em;"><span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\underleftarrow{AB}</code></td>
</tr>
<tr>
<td style="text-align:left">\underleftrightarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><munder accentunder="true"><mrow><mi>A</mi><mi>B</mi></mrow><mo stretchy="true">↔</mo></munder></mrow><annotation encoding="application/x-tex">\underleftrightarrow{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2053em;vertical-align:-0.522em;"></span><span class="mord accentunder"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6833em;"><span class="svg-align" style="top:-2.478em;"><span class="pstrut" style="height:3em;"></span><span class="stretchy" style="height:0.522em;min-width:0.888em;"><span class="halfarrow-left" style="height:0.522em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMinYMin slice'><path d='M400000 241H110l3-3c68.7-52.7 113.7-120
 135-202 4-14.7 6-23 6-25 0-7.3-7-11-21-11-8 0-13.2.8-15.5 2.5-2.3 1.7-4.2 5.8
-5.5 12.5-1.3 4.7-2.7 10.3-4 17-12 48.7-34.8 92-68.5 130S65.3 228.3 18 247
c-10 4-16 7.7-18 11 0 8.7 6 14.3 18 17 47.3 18.7 87.8 47 121.5 85S196 441.3 208
 490c.7 2 1.3 5 2 9s1.2 6.7 1.5 8c.3 1.3 1 3.3 2 6s2.2 4.5 3.5 5.5c1.3 1 3.3
 1.8 6 2.5s6 1 10 1c14 0 21-3.7 21-11 0-2-2-10.3-6-25-20-79.3-65-146.7-135-202
 l-3-3h399890zM100 241v40h399900v-40z'/></svg></span><span class="halfarrow-right" style="height:0.522em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMaxYMin slice'><path d='M0 241v40h399891c-47.3 35.3-84 78-110 128
-16.7 32-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20
 11 8 0 13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7
 39-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85
-40.5-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5
-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67
 151.7 139 205zm0 0v40h399900v-40z'/></svg></span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.522em;"><span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\underleftrightarrow{AB}</code></td>
</tr>
<tr>
<td style="text-align:left">\underrightarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><munder accentunder="true"><mrow><mi>A</mi><mi>B</mi></mrow><mo stretchy="true">→</mo></munder></mrow><annotation encoding="application/x-tex">\underrightarrow{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2053em;vertical-align:-0.522em;"></span><span class="mord accentunder"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6833em;"><span class="svg-align" style="top:-2.478em;"><span class="pstrut" style="height:3em;"></span><span class="hide-tail" style="height:0.522em;min-width:0.888em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMaxYMin slice'><path d='M0 241v40h399891c-47.3 35.3-84 78-110 128
-16.7 32-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20
 11 8 0 13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7
 39-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85
-40.5-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5
-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67
 151.7 139 205zm0 0v40h399900v-40z'/></svg></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.522em;"><span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\underrightarrow{AB}</code></td>
</tr>
<tr>
<td style="text-align:left">\underline</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><munder accentunder="true"><mtext>a long argument</mtext><mo stretchy="true">‾</mo></munder></mrow><annotation encoding="application/x-tex">\underline{\text{a long argument}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0889em;vertical-align:-0.3944em;"></span><span class="mord underline"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6944em;"><span style="top:-2.6456em;"><span class="pstrut" style="height:3em;"></span><span class="underline-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord text"><span class="mord">a long argument</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.3944em;"><span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\underline{\text{a long argument}}</code></td>
</tr>
<tr>
<td style="text-align:left">\underlinesegment</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><munder accentunder="true"><mrow><mi>A</mi><mi>B</mi></mrow><mo stretchy="true">undefined</mo></munder></mrow><annotation encoding="application/x-tex">\underlinesegment{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2053em;vertical-align:-0.522em;"></span><span class="mord accentunder"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6833em;"><span class="svg-align" style="top:-2.478em;"><span class="pstrut" style="height:3em;"></span><span class="stretchy" style="height:0.522em;min-width:0.888em;"><span class="halfarrow-left" style="height:0.522em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMinYMin slice'><path d='M40 281 V428 H0 V94 H40 V241 H400000 v40z
M40 281 V428 H0 V94 H40 V241 H400000 v40z'/></svg></span><span class="halfarrow-right" style="height:0.522em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMaxYMin slice'><path d='M399960 241 V94 h40 V428 h-40 V281 H0 v-40z
M399960 241 V94 h40 V428 h-40 V281 H0 v-40z'/></svg></span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.522em;"><span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\underlinesegment{AB}</code></td>
</tr>
<tr>
<td style="text-align:left">\underparen</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left">See <code>\undergroup</code></td>
</tr>
<tr>
<td style="text-align:left">\underrightarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><munder accentunder="true"><mrow><mi>A</mi><mi>B</mi></mrow><mo stretchy="true">→</mo></munder></mrow><annotation encoding="application/x-tex">\underrightarrow{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.2053em;vertical-align:-0.522em;"></span><span class="mord accentunder"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6833em;"><span class="svg-align" style="top:-2.478em;"><span class="pstrut" style="height:3em;"></span><span class="hide-tail" style="height:0.522em;min-width:0.888em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMaxYMin slice'><path d='M0 241v40h399891c-47.3 35.3-84 78-110 128
-16.7 32-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20
 11 8 0 13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7
 39-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85
-40.5-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5
-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67
 151.7 139 205zm0 0v40h399900v-40z'/></svg></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.522em;"><span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\underrightarrow{AB}</code></td>
</tr>
<tr>
<td style="text-align:left">\underset</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><munder><mo><mo>=</mo></mo><mo stretchy="false" lspace="0em" rspace="0em">!</mo></munder></mo></mrow><annotation encoding="application/x-tex">\underset{!}{=}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.119em;vertical-align:-0.7521em;"></span><span class="mrel"><span class="mop op-limits"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3669em;"><span style="top:-2.3479em;margin-left:0em;"><span class="pstrut" style="height:3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mclose mtight">!</span></span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span><span class="mop">=</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.7521em;"><span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\underset{!}{=}</code></td>
</tr>
<tr>
<td style="text-align:left">\unicode</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\unlhd</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊴</mo></mrow><annotation encoding="application/x-tex">\unlhd</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7733em;vertical-align:-0.1367em;"></span><span class="mord amsrm">⊴</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\unrhd</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊵</mo></mrow><annotation encoding="application/x-tex">\unrhd</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7733em;vertical-align:-0.1367em;"></span><span class="mord amsrm">⊵</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\up</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Uparrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇑</mo></mrow><annotation encoding="application/x-tex">\Uparrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel">⇑</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\uparrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↑</mo></mrow><annotation encoding="application/x-tex">\uparrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mrel">↑</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Updownarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇕</mo></mrow><annotation encoding="application/x-tex">\Updownarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mrel">⇕</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\updownarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↕</mo></mrow><annotation encoding="application/x-tex">\updownarrow</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mrel">↕</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\upharpoonleft</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↿</mo></mrow><annotation encoding="application/x-tex">\upharpoonleft</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8867em;vertical-align:-0.1944em;"></span><span class="mrel amsrm">↿</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\upharpoonright</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>↾</mo></mrow><annotation encoding="application/x-tex">\upharpoonright</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8867em;vertical-align:-0.1944em;"></span><span class="mrel amsrm">↾</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\uplus</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊎</mo></mrow><annotation encoding="application/x-tex">\uplus</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5556em;"></span><span class="mord">⊎</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\uproot</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\upshape</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Upsilon</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Υ</mi></mrow><annotation encoding="application/x-tex">\Upsilon</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">Υ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\upsilon</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>υ</mi></mrow><annotation encoding="application/x-tex">\upsilon</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">υ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\upuparrows</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⇈</mo></mrow><annotation encoding="application/x-tex">\upuparrows</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8867em;vertical-align:-0.1944em;"></span><span class="mrel amsrm">⇈</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\urcorner</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mi mathvariant="normal">⌝</mi></mo></mrow><annotation encoding="application/x-tex">\urcorner</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mclose amsrm">┐</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\url</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathsize="0.8em"><mstyle mathcolor="#cc0000"><mtext>\url</mtext></mstyle></mstyle></mrow><annotation encoding="application/x-tex">\footnotesize\url{https://katex.org/}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8em;vertical-align:-0.2em;"></span><span class="mord text sizing reset-size6 size4" style="color:#cc0000;"><span class="mord" style="color:#cc0000;">\url</span></span></span></span></span></td>
<td style="text-align:left"><code>\url{https://katex.org/}</code> Requires <code>trust</code></td>
</tr>
<tr>
<td style="text-align:left">\utilde</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><munder accentunder="true"><mrow><mi>A</mi><mi>B</mi></mrow><mo stretchy="true">~</mo></munder></mrow><annotation encoding="application/x-tex">\utilde{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0893em;vertical-align:-0.406em;"></span><span class="mord accentunder"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.6833em;"><span class="svg-align" style="top:-2.594em;"><span class="pstrut" style="height:3em;"></span><span style="height:0.286em;"><svg xmlns="http://www.w3.org/2000/svg" width='100%' height='0.286em' viewBox='0 0 1033 286' preserveAspectRatio='none'><path d='M344 55.266c-142 0-300.638 81.316-311.5 86.418
-8.01 3.762-22.5 10.91-23.5 5.562L1 120c-1-2-1-3-1-4 0-5 3-9 8-10l18.4-9C160.9
 31.9 283 0 358 0c148 0 188 122 331 122s314-97 326-97c4 0 8 2 10 7l7 21.114
c1 2.14 1 3.21 1 4.28 0 5.347-3 9.626-7 10.696l-22.3 12.622C852.6 158.372 751
 181.476 676 181.476c-149 0-189-126.21-332-126.21z'/></svg></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.406em;"><span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\utilde{AB}</code></td>
</tr>
</tbody>
</table>
<h2 id="v" tabindex="-1">V <a class="header-anchor" href="#v" aria-label="Permalink to &quot;V&quot;">&ZeroWidthSpace;</a></h2>
<table>
<thead>
<tr>
<th style="text-align:left">Symbol/Function</th>
<th style="text-align:left">Rendered</th>
<th style="text-align:left">Source or Comment</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">\v</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mtext>a</mtext><mo>ˇ</mo></mover></mrow><annotation encoding="application/x-tex">\text{\v{a}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6285em;"></span><span class="mord text"><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6285em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord">a</span></span></span><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.25em;"><span class="mord">ˇ</span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\text{\v{a}}</code></td>
</tr>
<tr>
<td style="text-align:left">\varcoppa</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\varDelta</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>Δ</mi></mrow><annotation encoding="application/x-tex">\varDelta</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathit">Δ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\varepsilon</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ε</mi></mrow><annotation encoding="application/x-tex">\varepsilon</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">ε</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\varGamma</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>Γ</mi></mrow><annotation encoding="application/x-tex">\varGamma</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathit">Γ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\varinjlim</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\varkappa</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">ϰ</mi></mrow><annotation encoding="application/x-tex">\varkappa</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord amsrm" style="margin-right:0.04028em;">ϰ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\varLambda</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>Λ</mi></mrow><annotation encoding="application/x-tex">\varLambda</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathit">Λ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\varliminf</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\varlimsup</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\varnothing</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∅</mi></mrow><annotation encoding="application/x-tex">\varnothing</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6633em;vertical-align:-0.0817em;"></span><span class="mord amsrm">∅</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\varOmega</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>Ω</mi></mrow><annotation encoding="application/x-tex">\varOmega</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathit">Ω</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\varPhi</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>Φ</mi></mrow><annotation encoding="application/x-tex">\varPhi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathit">Φ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\varphi</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>φ</mi></mrow><annotation encoding="application/x-tex">\varphi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">φ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\varPi</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>Π</mi></mrow><annotation encoding="application/x-tex">\varPi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathit">Π</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\varpi</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ϖ</mi></mrow><annotation encoding="application/x-tex">\varpi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal" style="margin-right:0.02778em;">ϖ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\varprojlim</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\varpropto</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∝</mo></mrow><annotation encoding="application/x-tex">\varpropto</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mrel amsrm">∝</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\varPsi</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>Ψ</mi></mrow><annotation encoding="application/x-tex">\varPsi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathit">Ψ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\varPsi</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>Ψ</mi></mrow><annotation encoding="application/x-tex">\varPsi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathit">Ψ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\varrho</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ϱ</mi></mrow><annotation encoding="application/x-tex">\varrho</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">ϱ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\varSigma</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>Σ</mi></mrow><annotation encoding="application/x-tex">\varSigma</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathit">Σ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\varsigma</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ς</mi></mrow><annotation encoding="application/x-tex">\varsigma</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5278em;vertical-align:-0.0972em;"></span><span class="mord mathnormal" style="margin-right:0.07986em;">ς</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\varstigma</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\varsubsetneq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊊</mo></mrow><annotation encoding="application/x-tex">\varsubsetneq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mrel amsrm"></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\varsubsetneqq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⫋</mo></mrow><annotation encoding="application/x-tex">\varsubsetneqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0087em;vertical-align:-0.2514em;"></span><span class="mrel amsrm"></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\varsupsetneq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊋</mo></mrow><annotation encoding="application/x-tex">\varsupsetneq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7719em;vertical-align:-0.136em;"></span><span class="mrel amsrm"></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\varsupsetneqq</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⫌</mo></mrow><annotation encoding="application/x-tex">\varsupsetneqq</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0087em;vertical-align:-0.2514em;"></span><span class="mrel amsrm"></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\varTheta</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>Θ</mi></mrow><annotation encoding="application/x-tex">\varTheta</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathit">Θ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\vartheta</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ϑ</mi></mrow><annotation encoding="application/x-tex">\vartheta</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">ϑ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\vartriangle</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>△</mo></mrow><annotation encoding="application/x-tex">\vartriangle</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5499em;"></span><span class="mrel amsrm">△</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\vartriangleleft</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊲</mo></mrow><annotation encoding="application/x-tex">\vartriangleleft</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.585em;vertical-align:-0.0352em;"></span><span class="mrel amsrm">⊲</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\vartriangleright</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊳</mo></mrow><annotation encoding="application/x-tex">\vartriangleright</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.585em;vertical-align:-0.0352em;"></span><span class="mrel amsrm">⊳</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\varUpsilon</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>Υ</mi></mrow><annotation encoding="application/x-tex">\varUpsilon</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathit">Υ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\varXi</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>Ξ</mi></mrow><annotation encoding="application/x-tex">\varXi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathit">Ξ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\vcentcolon</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo><mo><mo>:</mo></mo></mo></mrow><annotation encoding="application/x-tex">\vcentcolon</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mrel"><span class="mop" style="position:relative;top:-0.0347em;">:</span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\vcenter</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Vdash</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊩</mo></mrow><annotation encoding="application/x-tex">\Vdash</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mrel amsrm">⊩</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\vDash</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊨</mo></mrow><annotation encoding="application/x-tex">\vDash</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mrel amsrm">⊨</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\vdash</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊢</mo></mrow><annotation encoding="application/x-tex">\vdash</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mrel">⊢</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\vdots</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi><mi mathvariant="normal">⋮</mi><mpadded height="0em" voffset="0em"><mspace mathbackground="black" width="0em" height="1.5em"></mspace></mpadded></mi></mrow><annotation encoding="application/x-tex">\vdots</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.53em;vertical-align:-0.03em;"></span><span class="mord"><span class="mord">⋮</span><span class="mord rule" style="border-right-width:0em;border-top-width:1.5em;bottom:0em;"></span></span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\vec</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mi>F</mi><mo>⃗</mo></mover></mrow><annotation encoding="application/x-tex">\vec{F}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9663em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.9663em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord mathnormal" style="margin-right:0.13889em;">F</span></span><span style="top:-3.2523em;"><span class="pstrut" style="height:3em;"></span><span class="accent-body" style="left:-0.1522em;"><span class="overlay" style="height:0.714em;width:0.471em;"><svg xmlns="http://www.w3.org/2000/svg" width='0.471em' height='0.714em' style='width:0.471em' viewBox='0 0 471 714' preserveAspectRatio='xMinYMin'><path d='M377 20c0-5.333 1.833-10 5.5-14S391 0 397 0c4.667 0 8.667 1.667 12 5
3.333 2.667 6.667 9 10 19 6.667 24.667 20.333 43.667 41 57 7.333 4.667 11
10.667 11 18 0 6-1 10-3 12s-6.667 5-14 9c-28.667 14.667-53.667 35.667-75 63
-1.333 1.333-3.167 3.5-5.5 6.5s-4 4.833-5 5.5c-1 .667-2.5 1.333-4.5 2s-4.333 1
-7 1c-4.667 0-9.167-1.833-13.5-5.5S337 184 337 178c0-12.667 15.667-32.333 47-59
H213l-171-1c-8.667-6-13-12.333-13-19 0-4.667 4.333-11.333 13-20h359
c-16-25.333-24-45-24-59z'/></svg></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\vec{F}</code></td>
</tr>
<tr>
<td style="text-align:left">\vee</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∨</mo></mrow><annotation encoding="application/x-tex">\vee</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5556em;"></span><span class="mord">∨</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\veebar</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊻</mo></mrow><annotation encoding="application/x-tex">\veebar</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8867em;vertical-align:-0.1944em;"></span><span class="mord amsrm">⊻</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\verb</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mtext mathvariant="monospace">\frac a b</mtext></mrow><annotation encoding="application/x-tex">\verb!\frac a b!</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7778em;vertical-align:-0.0833em;"></span><span class="mord text"><span class="mord texttt">\frac a b</span></span></span></span></span></td>
<td style="text-align:left"><code>\verb!\frac a b!</code></td>
</tr>
<tr>
<td style="text-align:left">\Vert</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∥</mi></mrow><annotation encoding="application/x-tex">\Vert</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">∥</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\vert</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∣</mi></mrow><annotation encoding="application/x-tex">\vert</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord">∣</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\vfil</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\vfill</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\vline</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"><a href="https://github.com/KaTeX/KaTeX/issues/269" target="_blank" rel="noreferrer">Issue #269</a></td>
</tr>
<tr>
<td style="text-align:left" Vmatrix=""></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true">∥</mo><mtable rowspacing="0.16em" columnalign="center center" columnspacing="1em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>a</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>b</mi></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>c</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>d</mi></mstyle></mtd></mtr></mtable><mo fence="true">∥</mo></mrow><annotation encoding="application/x-tex">\begin{Vmatrix}a&amp;b\\c&amp;d\end{Vmatrix}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.4em;vertical-align:-0.95em;"></span><span class="minner"><span class="mopen"><span class="delimsizing mult"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.45em;"><span class="pstrut" style="height:4.4em;"></span><span style="width:0.556em;height:2.400em;"><svg xmlns="http://www.w3.org/2000/svg" width='0.556em' height='2.400em' viewBox='0 0 556 2400'><path d='M145 15 v585 v1200 v585 c2.667,10,9.667,15,21,15
c10,0,16.667,-5,20,-15 v-585 v-1200 v-585 c-2.667,-10,-9.667,-15,-21,-15
c-10,0,-16.667,5,-20,15z M188 15 H145 v585 v1200 v585 h43z
M367 15 v585 v1200 v585 c2.667,10,9.667,15,21,15
c10,0,16.667,-5,20,-15 v-585 v-1200 v-585 c-2.667,-10,-9.667,-15,-21,-15
c-10,0,-16.667,5,-20,15z M410 15 H367 v585 v1200 v585 h43z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span></span><span class="mord"><span class="mtable"><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:0.5em;"></span><span class="arraycolsep" style="width:0.5em;"></span><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">b</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">d</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span></span></span><span class="mclose"><span class="delimsizing mult"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.45em;"><span class="pstrut" style="height:4.4em;"></span><span style="width:0.556em;height:2.400em;"><svg xmlns="http://www.w3.org/2000/svg" width='0.556em' height='2.400em' viewBox='0 0 556 2400'><path d='M145 15 v585 v1200 v585 c2.667,10,9.667,15,21,15
c10,0,16.667,-5,20,-15 v-585 v-1200 v-585 c-2.667,-10,-9.667,-15,-21,-15
c-10,0,-16.667,5,-20,15z M188 15 H145 v585 v1200 v585 h43z
M367 15 v585 v1200 v585 c2.667,10,9.667,15,21,15
c10,0,16.667,-5,20,-15 v-585 v-1200 v-585 c-2.667,-10,-9.667,-15,-21,-15
c-10,0,-16.667,5,-20,15z M410 15 H367 v585 v1200 v585 h43z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\begin{Vmatrix}</code><br>   <code>a &amp; b \\</code><br>   <code>c &amp; d</code><br><code>\end{Vmatrix}</code></td>
</tr>
<tr>
<td style="text-align:left" vmatrix=""></td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo fence="true">∣</mo><mtable rowspacing="0.16em" columnalign="center center" columnspacing="1em"><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>a</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>b</mi></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>c</mi></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="false"><mi>d</mi></mstyle></mtd></mtr></mtable><mo fence="true">∣</mo></mrow><annotation encoding="application/x-tex">\begin{vmatrix}a&amp;b\\c&amp;d\end{vmatrix}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:2.4em;vertical-align:-0.95em;"></span><span class="minner"><span class="mopen"><span class="delimsizing mult"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.45em;"><span class="pstrut" style="height:4.4em;"></span><span style="width:0.333em;height:2.400em;"><svg xmlns="http://www.w3.org/2000/svg" width='0.333em' height='2.400em' viewBox='0 0 333 2400'><path d='M145 15 v585 v1200 v585 c2.667,10,9.667,15,21,15
c10,0,16.667,-5,20,-15 v-585 v-1200 v-585 c-2.667,-10,-9.667,-15,-21,-15
c-10,0,-16.667,5,-20,15z M188 15 H145 v585 v1200 v585 h43z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span></span><span class="mord"><span class="mtable"><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">a</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">c</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span><span class="arraycolsep" style="width:0.5em;"></span><span class="arraycolsep" style="width:0.5em;"></span><span class="col-align-c"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.61em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">b</span></span></span><span style="top:-2.41em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">d</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span></span></span><span class="mclose"><span class="delimsizing mult"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.45em;"><span style="top:-3.45em;"><span class="pstrut" style="height:4.4em;"></span><span style="width:0.333em;height:2.400em;"><svg xmlns="http://www.w3.org/2000/svg" width='0.333em' height='2.400em' viewBox='0 0 333 2400'><path d='M145 15 v585 v1200 v585 c2.667,10,9.667,15,21,15
c10,0,16.667,-5,20,-15 v-585 v-1200 v-585 c-2.667,-10,-9.667,-15,-21,-15
c-10,0,-16.667,5,-20,15z M188 15 H145 v585 v1200 v585 h43z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.95em;"><span></span></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\begin{vmatrix}</code><br>   <code>a &amp; b \\</code><br>   <code>c &amp; d</code><br><code>\end{vmatrix}</code></td>
</tr>
<tr>
<td style="text-align:left">\vphantom</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mrow><mpadded width="0px"><mphantom><mi>M</mi></mphantom></mpadded><mi>a</mi></mrow><mo stretchy="true">‾</mo></mover></mrow><annotation encoding="application/x-tex">\overline{\vphantom{M}a}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8833em;"></span><span class="mord overline"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8833em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord rlap"><span class="inner"><span class="mord" style="color:transparent;"><span class="mord mathnormal" style="margin-right:0.10903em;color:transparent;">M</span></span></span><span class="fix"></span></span><span class="mord mathnormal">a</span></span></span><span style="top:-3.8033em;"><span class="pstrut" style="height:3em;"></span><span class="overline-line" style="border-bottom-width:0.04em;"></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\overline{\vphantom{M}a}</code></td>
</tr>
<tr>
<td style="text-align:left">\Vvdash</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>⊪</mo></mrow><annotation encoding="application/x-tex">\Vvdash</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6922em;"></span><span class="mrel amsrm">⊪</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
</tbody>
</table>
<h2 id="w" tabindex="-1">W <a class="header-anchor" href="#w" aria-label="Permalink to &quot;W&quot;">&ZeroWidthSpace;</a></h2>
<table>
<thead>
<tr>
<th style="text-align:left">Symbol/Function</th>
<th style="text-align:left">Rendered</th>
<th style="text-align:left">Source or Comment</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">\wedge</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>∧</mo></mrow><annotation encoding="application/x-tex">\wedge</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.5556em;"></span><span class="mord">∧</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\weierp</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">℘</mi></mrow><annotation encoding="application/x-tex">\weierp</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord">℘</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\widecheck</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mrow><mi>A</mi><mi>B</mi></mrow><mo stretchy="true">ˇ</mo></mover></mrow><annotation encoding="application/x-tex">\widecheck{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9833em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.9833em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span><span class="svg-align" style="top:-3.6833em;"><span class="pstrut" style="height:3em;"></span><span style="height:0.3em;"><svg xmlns="http://www.w3.org/2000/svg" width='100%' height='0.3em' viewBox='0 0 2364 300' preserveAspectRatio='none'><path d='M1181,220h2l1171,-176c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,
-11,-10h-1l-1168,153l-1167,-153h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z'/></svg></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\widecheck{AB}</code></td>
</tr>
<tr>
<td style="text-align:left">\widehat</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mrow><mi>A</mi><mi>B</mi></mrow><mo stretchy="true">^</mo></mover></mrow><annotation encoding="application/x-tex">\widehat{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9833em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.9833em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span><span class="svg-align" style="top:-3.6833em;"><span class="pstrut" style="height:3em;"></span><span style="height:0.3em;"><svg xmlns="http://www.w3.org/2000/svg" width='100%' height='0.3em' viewBox='0 0 2364 300' preserveAspectRatio='none'><path d='M1181 0h2l1171 176c6 0 10 5 10 11l-2 23c-1 6-5 10
-11 10h-1L1182 67 15 220h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z'/></svg></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\widehat{AB}</code></td>
</tr>
<tr>
<td style="text-align:left">\wideparen</td>
<td style="text-align:left"><span style="color:firebrick;">Not supported</span></td>
<td style="text-align:left"><a href="https://github.com/KaTeX/KaTeX/issues/560" target="_blank" rel="noreferrer">Issue #560</a></td>
</tr>
<tr>
<td style="text-align:left">\widetilde</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover accent="true"><mrow><mi>A</mi><mi>B</mi></mrow><mo stretchy="true">~</mo></mover></mrow><annotation encoding="application/x-tex">\widetilde{AB}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.9693em;"></span><span class="mord accent"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.9693em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.05017em;">B</span></span></span><span class="svg-align" style="top:-3.6833em;"><span class="pstrut" style="height:3em;"></span><span style="height:0.286em;"><svg xmlns="http://www.w3.org/2000/svg" width='100%' height='0.286em' viewBox='0 0 1033 286' preserveAspectRatio='none'><path d='M344 55.266c-142 0-300.638 81.316-311.5 86.418
-8.01 3.762-22.5 10.91-23.5 5.562L1 120c-1-2-1-3-1-4 0-5 3-9 8-10l18.4-9C160.9
 31.9 283 0 358 0c148 0 188 122 331 122s314-97 326-97c4 0 8 2 10 7l7 21.114
c1 2.14 1 3.21 1 4.28 0 5.347-3 9.626-7 10.696l-22.3 12.622C852.6 158.372 751
 181.476 676 181.476c-149 0-189-126.21-332-126.21z'/></svg></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\widetilde{AB}</code></td>
</tr>
<tr>
<td style="text-align:left">\wp</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">℘</mi></mrow><annotation encoding="application/x-tex">\wp</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord">℘</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\wr</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo>≀</mo></mrow><annotation encoding="application/x-tex">\wr</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord">≀</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
</tbody>
</table>
<h2 id="x" tabindex="-1">X <a class="header-anchor" href="#x" aria-label="Permalink to &quot;X&quot;">&ZeroWidthSpace;</a></h2>
<table>
<thead>
<tr>
<th style="text-align:left">Symbol/Function</th>
<th style="text-align:left">Rendered</th>
<th style="text-align:left">Source or Comment</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">\xcancel</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><menclose notation="updiagonalstrike downdiagonalstrike"><mrow><mi>A</mi><mi>B</mi><mi>C</mi></mrow></menclose></mrow><annotation encoding="application/x-tex">\xcancel{ABC}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord cancel-lap"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.6833em;"><span style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span class="mord cancel-pad"><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.07153em;">BC</span></span></span><span class="svg-align" style="top:-3em;"><span class="pstrut" style="height:3em;"></span><span style="height:0.6833em;"><svg xmlns="http://www.w3.org/2000/svg" width='100%' height='0.6833em'><line x1='0' y1='0' x2='100%' y2='100%' stroke-width='0.046em'/><line x1='0' y1='100%' x2='100%' y2='0' stroke-width='0.046em'/></svg></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\xcancel{ABC}</code></td>
</tr>
<tr>
<td style="text-align:left">\xdef</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi></mrow><annotation encoding="application/x-tex">\def\foo{a}\xdef\bar{\foo}\def\foo{}\bar</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">a</span></span></span></span></td>
<td style="text-align:left"><code>\def\foo{a}\xdef\bar{\foo}\def\foo{}\bar</code></td>
</tr>
<tr>
<td style="text-align:left">\Xi</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Ξ</mi></mrow><annotation encoding="application/x-tex">\Xi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord">Ξ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\xi</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ξ</mi></mrow><annotation encoding="application/x-tex">\xi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.04601em;">ξ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\xhookleftarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mo stretchy="true" minsize="3.0em">↩</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></mpadded></mover></mrow><annotation encoding="application/x-tex">\xhookleftarrow{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1191em;vertical-align:-0.011em;"></span><span class="mrel x-arrow"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1081em;"><span style="top:-3.322em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">ab</span><span class="mord mathnormal mtight">c</span></span></span></span><span class="svg-align" style="top:-2.689em;"><span class="pstrut" style="height:2.7em;"></span><span class="stretchy" style="height:0.522em;min-width:1.08em;"><span class="halfarrow-left" style="height:0.522em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMinYMin slice'><path d='M400000 241H110l3-3c68.7-52.7 113.7-120
 135-202 4-14.7 6-23 6-25 0-7.3-7-11-21-11-8 0-13.2.8-15.5 2.5-2.3 1.7-4.2 5.8
-5.5 12.5-1.3 4.7-2.7 10.3-4 17-12 48.7-34.8 92-68.5 130S65.3 228.3 18 247
c-10 4-16 7.7-18 11 0 8.7 6 14.3 18 17 47.3 18.7 87.8 47 121.5 85S196 441.3 208
 490c.7 2 1.3 5 2 9s1.2 6.7 1.5 8c.3 1.3 1 3.3 2 6s2.2 4.5 3.5 5.5c1.3 1 3.3
 1.8 6 2.5s6 1 10 1c14 0 21-3.7 21-11 0-2-2-10.3-6-25-20-79.3-65-146.7-135-202
 l-3-3h399890zM100 241v40h399900v-40z'/></svg></span><span class="halfarrow-right" style="height:0.522em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMaxYMin slice'><path d='M399859 241c-764 0 0 0 0 0 40-3.3 68.7-15.7 86-37 10-12 15-25.3
 15-40 0-22.7-9.8-40.7-29.5-54-19.7-13.3-43.5-21-71.5-23-17.3-1.3-26-8-26-20 0
-13.3 8.7-20 26-20 38 0 71 11.2 99 33.5 0 0 7 5.6 21 16.7 14 11.2 21 33.5 21
 66.8s-14 61.2-42 83.5c-28 22.3-61 33.5-99 33.5L0 241z M0 281v-40h399859v40z'/></svg></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.011em;"><span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\xhookleftarrow{abc}</code></td>
</tr>
<tr>
<td style="text-align:left">\xhookrightarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mo stretchy="true" minsize="3.0em">↪</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></mpadded></mover></mrow><annotation encoding="application/x-tex">\xhookrightarrow{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1191em;vertical-align:-0.011em;"></span><span class="mrel x-arrow"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1081em;"><span style="top:-3.322em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">ab</span><span class="mord mathnormal mtight">c</span></span></span></span><span class="svg-align" style="top:-2.689em;"><span class="pstrut" style="height:2.7em;"></span><span class="stretchy" style="height:0.522em;min-width:1.08em;"><span class="halfarrow-left" style="height:0.522em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMinYMin slice'><path d='M400000 281 H103s-33-11.2-61-33.5S0 197.3 0 164s14.2-61.2 42.5
-83.5C70.8 58.2 104 47 142 47 c16.7 0 25 6.7 25 20 0 12-8.7 18.7-26 20-40 3.3
-68.7 15.7-86 37-10 12-15 25.3-15 40 0 22.7 9.8 40.7 29.5 54 19.7 13.3 43.5 21
 71.5 23h399859zM103 281v-40h399897v40z'/></svg></span><span class="halfarrow-right" style="height:0.522em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMaxYMin slice'><path d='M0 241v40h399891c-47.3 35.3-84 78-110 128
-16.7 32-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20
 11 8 0 13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7
 39-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85
-40.5-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5
-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67
 151.7 139 205zm0 0v40h399900v-40z'/></svg></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.011em;"><span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\xhookrightarrow{abc}</code></td>
</tr>
<tr>
<td style="text-align:left">\xLeftarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mo stretchy="true" minsize="3.0em">⇐</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></mpadded></mover></mrow><annotation encoding="application/x-tex">\xLeftarrow{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1571em;vertical-align:-0.03em;"></span><span class="mrel x-arrow"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1271em;"><span style="top:-3.341em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">ab</span><span class="mord mathnormal mtight">c</span></span></span></span><span class="svg-align" style="top:-2.67em;"><span class="pstrut" style="height:2.7em;"></span><span class="hide-tail" style="height:0.56em;min-width:1.526em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.56em' viewBox='0 0 400000 560' preserveAspectRatio='xMinYMin slice'><path d='M262 157
l10-10c34-36 62.7-77 86-123 3.3-8 5-13.3 5-16 0-5.3-6.7-8-20-8-7.3
 0-12.2.5-14.5 1.5-2.3 1-4.8 4.5-7.5 10.5-49.3 97.3-121.7 169.3-217 216-28
 14-57.3 25-88 33-6.7 2-11 3.8-13 5.5-2 1.7-3 4.2-3 7.5s1 5.8 3 7.5
c2 1.7 6.3 3.5 13 5.5 68 17.3 128.2 47.8 180.5 91.5 52.3 43.7 93.8 96.2 124.5
 157.5 9.3 8 15.3 12.3 18 13h6c12-.7 18-4 18-10 0-2-1.7-7-5-15-23.3-46-52-87
-86-123l-10-10h399738v-40H218c328 0 0 0 0 0l-10-8c-26.7-20-65.7-43-117-69 2.7
-2 6-3.7 10-5 36.7-16 72.3-37.3 107-64l10-8h399782v-40z
m8 0v40h399730v-40zm0 194v40h399730v-40z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.03em;"><span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\xLeftarrow{abc}</code></td>
</tr>
<tr>
<td style="text-align:left">\xleftarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mo stretchy="true" minsize="3.0em">←</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></mpadded></mover></mrow><annotation encoding="application/x-tex">\xleftarrow{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1191em;vertical-align:-0.011em;"></span><span class="mrel x-arrow"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1081em;"><span style="top:-3.322em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">ab</span><span class="mord mathnormal mtight">c</span></span></span></span><span class="svg-align" style="top:-2.689em;"><span class="pstrut" style="height:2.7em;"></span><span class="hide-tail" style="height:0.522em;min-width:1.469em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMinYMin slice'><path d='M400000 241H110l3-3c68.7-52.7 113.7-120
 135-202 4-14.7 6-23 6-25 0-7.3-7-11-21-11-8 0-13.2.8-15.5 2.5-2.3 1.7-4.2 5.8
-5.5 12.5-1.3 4.7-2.7 10.3-4 17-12 48.7-34.8 92-68.5 130S65.3 228.3 18 247
c-10 4-16 7.7-18 11 0 8.7 6 14.3 18 17 47.3 18.7 87.8 47 121.5 85S196 441.3 208
 490c.7 2 1.3 5 2 9s1.2 6.7 1.5 8c.3 1.3 1 3.3 2 6s2.2 4.5 3.5 5.5c1.3 1 3.3
 1.8 6 2.5s6 1 10 1c14 0 21-3.7 21-11 0-2-2-10.3-6-25-20-79.3-65-146.7-135-202
 l-3-3h399890zM100 241v40h399900v-40z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.011em;"><span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\xleftarrow{abc}</code></td>
</tr>
<tr>
<td style="text-align:left">\xleftharpoondown</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mo stretchy="true" minsize="3.0em">↽</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></mpadded></mover></mrow><annotation encoding="application/x-tex">\xleftharpoondown{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1191em;vertical-align:-0.011em;"></span><span class="mrel x-arrow"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1081em;"><span style="top:-3.322em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">ab</span><span class="mord mathnormal mtight">c</span></span></span></span><span class="svg-align" style="top:-2.689em;"><span class="pstrut" style="height:2.7em;"></span><span class="hide-tail" style="height:0.522em;min-width:0.888em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMinYMin slice'><path d='M7 241c-4 4-6.333 8.667-7 14 0 5.333.667 9 2 11s5.333
 5.333 12 10c90.667 54 156 130 196 228 3.333 10.667 6.333 16.333 9 17 2 .667 5
 1 9 1h5c10.667 0 16.667-2 18-6 2-2.667 1-9.667-3-21-32-87.333-82.667-157.667
-152-211l-3-3h399907v-40zM93 281 H400000 v-40L7 241z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.011em;"><span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\xleftharpoondown{abc}</code></td>
</tr>
<tr>
<td style="text-align:left">\xleftharpoonup</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mo stretchy="true" minsize="3.0em">↼</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></mpadded></mover></mrow><annotation encoding="application/x-tex">\xleftharpoonup{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1191em;vertical-align:-0.011em;"></span><span class="mrel x-arrow"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1081em;"><span style="top:-3.322em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">ab</span><span class="mord mathnormal mtight">c</span></span></span></span><span class="svg-align" style="top:-2.689em;"><span class="pstrut" style="height:2.7em;"></span><span class="hide-tail" style="height:0.522em;min-width:0.888em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMinYMin slice'><path d='M0 267c.7 5.3 3 10 7 14h399993v-40H93c3.3
-3.3 10.2-9.5 20.5-18.5s17.8-15.8 22.5-20.5c50.7-52 88-110.3 112-175 4-11.3 5
-18.3 3-21-1.3-4-7.3-6-18-6-8 0-13 .7-15 2s-4.7 6.7-8 16c-42 98.7-107.3 174.7
-196 228-6.7 4.7-10.7 8-12 10-1.3 2-2 5.7-2 11zm100-26v40h399900v-40z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.011em;"><span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\xleftharpoonup{abc}</code></td>
</tr>
<tr>
<td style="text-align:left">\xLeftrightarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mo stretchy="true" minsize="3.0em">⇔</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></mpadded></mover></mrow><annotation encoding="application/x-tex">\xLeftrightarrow{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1571em;vertical-align:-0.03em;"></span><span class="mrel x-arrow"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1271em;"><span style="top:-3.341em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">ab</span><span class="mord mathnormal mtight">c</span></span></span></span><span class="svg-align" style="top:-2.67em;"><span class="pstrut" style="height:2.7em;"></span><span class="stretchy" style="height:0.56em;min-width:1.75em;"><span class="halfarrow-left" style="height:0.56em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.56em' viewBox='0 0 400000 560' preserveAspectRatio='xMinYMin slice'><path d='M262 157
l10-10c34-36 62.7-77 86-123 3.3-8 5-13.3 5-16 0-5.3-6.7-8-20-8-7.3
 0-12.2.5-14.5 1.5-2.3 1-4.8 4.5-7.5 10.5-49.3 97.3-121.7 169.3-217 216-28
 14-57.3 25-88 33-6.7 2-11 3.8-13 5.5-2 1.7-3 4.2-3 7.5s1 5.8 3 7.5
c2 1.7 6.3 3.5 13 5.5 68 17.3 128.2 47.8 180.5 91.5 52.3 43.7 93.8 96.2 124.5
 157.5 9.3 8 15.3 12.3 18 13h6c12-.7 18-4 18-10 0-2-1.7-7-5-15-23.3-46-52-87
-86-123l-10-10h399738v-40H218c328 0 0 0 0 0l-10-8c-26.7-20-65.7-43-117-69 2.7
-2 6-3.7 10-5 36.7-16 72.3-37.3 107-64l10-8h399782v-40z
m8 0v40h399730v-40zm0 194v40h399730v-40z'/></svg></span><span class="halfarrow-right" style="height:0.56em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.56em' viewBox='0 0 400000 560' preserveAspectRatio='xMaxYMin slice'><path d='M399738 392l
-10 10c-34 36-62.7 77-86 123-3.3 8-5 13.3-5 16 0 5.3 6.7 8 20 8 7.3 0 12.2-.5
 14.5-1.5 2.3-1 4.8-4.5 7.5-10.5 49.3-97.3 121.7-169.3 217-216 28-14 57.3-25 88
-33 6.7-2 11-3.8 13-5.5 2-1.7 3-4.2 3-7.5s-1-5.8-3-7.5c-2-1.7-6.3-3.5-13-5.5-68
-17.3-128.2-47.8-180.5-91.5-52.3-43.7-93.8-96.2-124.5-157.5-9.3-8-15.3-12.3-18
-13h-6c-12 .7-18 4-18 10 0 2 1.7 7 5 15 23.3 46 52 87 86 123l10 10H0v40h399782
c-328 0 0 0 0 0l10 8c26.7 20 65.7 43 117 69-2.7 2-6 3.7-10 5-36.7 16-72.3 37.3
-107 64l-10 8H0v40zM0 157v40h399730v-40zm0 194v40h399730v-40z'/></svg></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.03em;"><span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\xLeftrightarrow{abc}</code></td>
</tr>
<tr>
<td style="text-align:left">\xleftrightarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mo stretchy="true" minsize="3.0em">↔</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></mpadded></mover></mrow><annotation encoding="application/x-tex">\xleftrightarrow{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1191em;vertical-align:-0.011em;"></span><span class="mrel x-arrow"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1081em;"><span style="top:-3.322em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">ab</span><span class="mord mathnormal mtight">c</span></span></span></span><span class="svg-align" style="top:-2.689em;"><span class="pstrut" style="height:2.7em;"></span><span class="stretchy" style="height:0.522em;min-width:1.75em;"><span class="halfarrow-left" style="height:0.522em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMinYMin slice'><path d='M400000 241H110l3-3c68.7-52.7 113.7-120
 135-202 4-14.7 6-23 6-25 0-7.3-7-11-21-11-8 0-13.2.8-15.5 2.5-2.3 1.7-4.2 5.8
-5.5 12.5-1.3 4.7-2.7 10.3-4 17-12 48.7-34.8 92-68.5 130S65.3 228.3 18 247
c-10 4-16 7.7-18 11 0 8.7 6 14.3 18 17 47.3 18.7 87.8 47 121.5 85S196 441.3 208
 490c.7 2 1.3 5 2 9s1.2 6.7 1.5 8c.3 1.3 1 3.3 2 6s2.2 4.5 3.5 5.5c1.3 1 3.3
 1.8 6 2.5s6 1 10 1c14 0 21-3.7 21-11 0-2-2-10.3-6-25-20-79.3-65-146.7-135-202
 l-3-3h399890zM100 241v40h399900v-40z'/></svg></span><span class="halfarrow-right" style="height:0.522em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMaxYMin slice'><path d='M0 241v40h399891c-47.3 35.3-84 78-110 128
-16.7 32-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20
 11 8 0 13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7
 39-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85
-40.5-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5
-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67
 151.7 139 205zm0 0v40h399900v-40z'/></svg></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.011em;"><span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\xleftrightarrow{abc}</code></td>
</tr>
<tr>
<td style="text-align:left">\xleftrightharpoons</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mo stretchy="true" minsize="3.0em">⇋</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></mpadded></mover></mrow><annotation encoding="application/x-tex">\xleftrightharpoons{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.3131em;vertical-align:-0.108em;"></span><span class="mrel x-arrow"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.2051em;"><span style="top:-3.435em;"><span class="pstrut" style="height:2.716em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">ab</span><span class="mord mathnormal mtight">c</span></span></span></span><span class="svg-align" style="top:-2.608em;"><span class="pstrut" style="height:2.716em;"></span><span class="stretchy" style="height:0.716em;min-width:1.75em;"><span class="halfarrow-left" style="height:0.716em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.716em' viewBox='0 0 400000 716' preserveAspectRatio='xMinYMin slice'><path d='M0 267c.7 5.3 3 10 7 14h399993v-40H93c3.3-3.3 10.2-9.5
 20.5-18.5s17.8-15.8 22.5-20.5c50.7-52 88-110.3 112-175 4-11.3 5-18.3 3-21-1.3
-4-7.3-6-18-6-8 0-13 .7-15 2s-4.7 6.7-8 16c-42 98.7-107.3 174.7-196 228-6.7 4.7
-10.7 8-12 10-1.3 2-2 5.7-2 11zm100-26v40h399900v-40zM0 435v40h400000v-40z
m0 0v40h400000v-40z'/></svg></span><span class="halfarrow-right" style="height:0.716em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.716em' viewBox='0 0 400000 716' preserveAspectRatio='xMaxYMin slice'><path d='M399747 705c0 7.3 6.7 11 20 11 8 0 13-.8
 15-2.5s4.7-6.8 8-15.5c40-94 99.3-166.3 178-217 13.3-8 20.3-12.3 21-13 5.3-3.3
 8.5-5.8 9.5-7.5 1-1.7 1.5-5.2 1.5-10.5s-2.3-10.3-7-15H0v40h399908c-34 25.3
-64.7 57-92 95-27.3 38-48.7 77.7-64 119-3.3 8.7-5 14-5 16zM0 435v40h399900v-40z
m0-194v40h400000v-40zm0 0v40h400000v-40z'/></svg></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.108em;"><span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\xleftrightharpoons{abc}</code></td>
</tr>
<tr>
<td style="text-align:left">\xlongequal</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mo stretchy="true" minsize="3.0em">=</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></mpadded></mover></mrow><annotation encoding="application/x-tex">\xlongequal{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0141em;"></span><span class="mrel x-arrow"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:1.0141em;"><span style="top:-3.228em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">ab</span><span class="mord mathnormal mtight">c</span></span></span></span><span class="svg-align" style="top:-2.783em;"><span class="pstrut" style="height:2.7em;"></span><span class="hide-tail" style="height:0.334em;min-width:0.888em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.334em' viewBox='0 0 400000 334' preserveAspectRatio='xMinYMin slice'><path d='M0 50 h400000 v40H0z m0 194h40000v40H0z
M0 50 h400000 v40H0z m0 194h40000v40H0z'/></svg></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\xlongequal{abc}</code></td>
</tr>
<tr>
<td style="text-align:left">\xmapsto</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mo stretchy="true" minsize="3.0em">↦</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></mpadded></mover></mrow><annotation encoding="application/x-tex">\xmapsto{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1191em;vertical-align:-0.011em;"></span><span class="mrel x-arrow"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1081em;"><span style="top:-3.322em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">ab</span><span class="mord mathnormal mtight">c</span></span></span></span><span class="svg-align" style="top:-2.689em;"><span class="pstrut" style="height:2.7em;"></span><span class="stretchy" style="height:0.522em;min-width:1.5em;"><span class="halfarrow-left" style="height:0.522em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMinYMin slice'><path d='M40 281 V448H0V74H40V241H400000v40z
M40 281 V448H0V74H40V241H400000v40z'/></svg></span><span class="halfarrow-right" style="height:0.522em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMaxYMin slice'><path d='M0 241v40h399891c-47.3 35.3-84 78-110 128
-16.7 32-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20
 11 8 0 13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7
 39-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85
-40.5-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5
-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67
 151.7 139 205zm0 0v40h399900v-40z'/></svg></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.011em;"><span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\xmapsto{abc}</code></td>
</tr>
<tr>
<td style="text-align:left">\xRightarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mo stretchy="true" minsize="3.0em">⇒</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></mpadded></mover></mrow><annotation encoding="application/x-tex">\xRightarrow{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1571em;vertical-align:-0.03em;"></span><span class="mrel x-arrow"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1271em;"><span style="top:-3.341em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">ab</span><span class="mord mathnormal mtight">c</span></span></span></span><span class="svg-align" style="top:-2.67em;"><span class="pstrut" style="height:2.7em;"></span><span class="hide-tail" style="height:0.56em;min-width:1.526em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.56em' viewBox='0 0 400000 560' preserveAspectRatio='xMaxYMin slice'><path d='M399738 392l
-10 10c-34 36-62.7 77-86 123-3.3 8-5 13.3-5 16 0 5.3 6.7 8 20 8 7.3 0 12.2-.5
 14.5-1.5 2.3-1 4.8-4.5 7.5-10.5 49.3-97.3 121.7-169.3 217-216 28-14 57.3-25 88
-33 6.7-2 11-3.8 13-5.5 2-1.7 3-4.2 3-7.5s-1-5.8-3-7.5c-2-1.7-6.3-3.5-13-5.5-68
-17.3-128.2-47.8-180.5-91.5-52.3-43.7-93.8-96.2-124.5-157.5-9.3-8-15.3-12.3-18
-13h-6c-12 .7-18 4-18 10 0 2 1.7 7 5 15 23.3 46 52 87 86 123l10 10H0v40h399782
c-328 0 0 0 0 0l10 8c26.7 20 65.7 43 117 69-2.7 2-6 3.7-10 5-36.7 16-72.3 37.3
-107 64l-10 8H0v40zM0 157v40h399730v-40zm0 194v40h399730v-40z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.03em;"><span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\xRightarrow{abc}</code></td>
</tr>
<tr>
<td style="text-align:left">\xrightarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mo stretchy="true" minsize="3.0em">→</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></mpadded></mover></mrow><annotation encoding="application/x-tex">\xrightarrow{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1191em;vertical-align:-0.011em;"></span><span class="mrel x-arrow"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1081em;"><span style="top:-3.322em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">ab</span><span class="mord mathnormal mtight">c</span></span></span></span><span class="svg-align" style="top:-2.689em;"><span class="pstrut" style="height:2.7em;"></span><span class="hide-tail" style="height:0.522em;min-width:1.469em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMaxYMin slice'><path d='M0 241v40h399891c-47.3 35.3-84 78-110 128
-16.7 32-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20
 11 8 0 13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7
 39-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85
-40.5-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5
-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67
 151.7 139 205zm0 0v40h399900v-40z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.011em;"><span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\xrightarrow{abc}</code></td>
</tr>
<tr>
<td style="text-align:left">\xrightharpoondown</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mo stretchy="true" minsize="3.0em">⇁</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></mpadded></mover></mrow><annotation encoding="application/x-tex">\xrightharpoondown{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1191em;vertical-align:-0.011em;"></span><span class="mrel x-arrow"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1081em;"><span style="top:-3.322em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">ab</span><span class="mord mathnormal mtight">c</span></span></span></span><span class="svg-align" style="top:-2.689em;"><span class="pstrut" style="height:2.7em;"></span><span class="hide-tail" style="height:0.522em;min-width:0.888em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMaxYMin slice'><path d='M399747 511c0 7.3 6.7 11 20 11 8 0 13-.8 15-2.5s4.7-6.8
 8-15.5c40-94 99.3-166.3 178-217 13.3-8 20.3-12.3 21-13 5.3-3.3 8.5-5.8 9.5
-7.5 1-1.7 1.5-5.2 1.5-10.5s-2.3-10.3-7-15H0v40h399908c-34 25.3-64.7 57-92 95
-27.3 38-48.7 77.7-64 119-3.3 8.7-5 14-5 16zM0 241v40h399900v-40z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.011em;"><span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\xrightharpoondown{abc}</code></td>
</tr>
<tr>
<td style="text-align:left">\xrightharpoonup</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mo stretchy="true" minsize="3.0em">⇀</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></mpadded></mover></mrow><annotation encoding="application/x-tex">\xrightharpoonup{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1191em;vertical-align:-0.011em;"></span><span class="mrel x-arrow"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1081em;"><span style="top:-3.322em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">ab</span><span class="mord mathnormal mtight">c</span></span></span></span><span class="svg-align" style="top:-2.689em;"><span class="pstrut" style="height:2.7em;"></span><span class="hide-tail" style="height:0.522em;min-width:0.888em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.522em' viewBox='0 0 400000 522' preserveAspectRatio='xMaxYMin slice'><path d='M0 241v40h399993c4.7-4.7 7-9.3 7-14 0-9.3
-3.7-15.3-11-18-92.7-56.7-159-133.7-199-231-3.3-9.3-6-14.7-8-16-2-1.3-7-2-15-2
-10.7 0-16.7 2-18 6-2 2.7-1 9.7 3 21 15.3 42 36.7 81.8 64 119.5 27.3 37.7 58
 69.2 92 94.5zm0 0v40h399900v-40z'/></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.011em;"><span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\xrightharpoonup{abc}</code></td>
</tr>
<tr>
<td style="text-align:left">\xrightleftharpoons</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mo stretchy="true" minsize="3.0em">⇌</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></mpadded></mover></mrow><annotation encoding="application/x-tex">\xrightleftharpoons{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.3131em;vertical-align:-0.108em;"></span><span class="mrel x-arrow"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.2051em;"><span style="top:-3.435em;"><span class="pstrut" style="height:2.716em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">ab</span><span class="mord mathnormal mtight">c</span></span></span></span><span class="svg-align" style="top:-2.608em;"><span class="pstrut" style="height:2.716em;"></span><span class="stretchy" style="height:0.716em;min-width:1.75em;"><span class="halfarrow-left" style="height:0.716em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.716em' viewBox='0 0 400000 716' preserveAspectRatio='xMinYMin slice'><path d='M7 435c-4 4-6.3 8.7-7 14 0 5.3.7 9 2 11s5.3 5.3 12
 10c90.7 54 156 130 196 228 3.3 10.7 6.3 16.3 9 17 2 .7 5 1 9 1h5c10.7 0 16.7
-2 18-6 2-2.7 1-9.7-3-21-32-87.3-82.7-157.7-152-211l-3-3h399907v-40H7zm93 0
v40h399900v-40zM0 241v40h399900v-40zm0 0v40h399900v-40z'/></svg></span><span class="halfarrow-right" style="height:0.716em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.716em' viewBox='0 0 400000 716' preserveAspectRatio='xMaxYMin slice'><path d='M0 241v40h399993c4.7-4.7 7-9.3 7-14 0-9.3-3.7-15.3-11
-18-92.7-56.7-159-133.7-199-231-3.3-9.3-6-14.7-8-16-2-1.3-7-2-15-2-10.7 0-16.7
 2-18 6-2 2.7-1 9.7 3 21 15.3 42 36.7 81.8 64 119.5 27.3 37.7 58 69.2 92 94.5z
m0 0v40h399900v-40z m100 194v40h399900v-40zm0 0v40h399900v-40z'/></svg></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.108em;"><span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\xrightleftharpoons{abc}</code></td>
</tr>
<tr>
<td style="text-align:left">\xtofrom</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mo stretchy="true" minsize="3.0em">⇄</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></mpadded></mover></mrow><annotation encoding="application/x-tex">\xtofrom{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.1251em;vertical-align:-0.014em;"></span><span class="mrel x-arrow"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.1111em;"><span style="top:-3.325em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">ab</span><span class="mord mathnormal mtight">c</span></span></span></span><span class="svg-align" style="top:-2.686em;"><span class="pstrut" style="height:2.7em;"></span><span class="stretchy" style="height:0.528em;min-width:1.75em;"><span class="halfarrow-left" style="height:0.528em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.528em' viewBox='0 0 400000 528' preserveAspectRatio='xMinYMin slice'><path d='M0 147h400000v40H0zm0 214c68 40 115.7 95.7 143 167h22c15.3 0 23
-.3 23-1 0-1.3-5.3-13.7-16-37-18-35.3-41.3-69-70-101l-7-8h399905v-40H95l7-8
c28.7-32 52-65.7 70-101 10.7-23.3 16-35.7 16-37 0-.7-7.7-1-23-1h-22C115.7 265.3
 68 321 0 361zm0-174v-40h399900v40zm100 154v40h399900v-40z'/></svg></span><span class="halfarrow-right" style="height:0.528em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.528em' viewBox='0 0 400000 528' preserveAspectRatio='xMaxYMin slice'><path d='M400000 167c-70.7-42-118-97.7-142-167h-23c-15.3 0-23 .3-23
 1 0 1.3 5.3 13.7 16 37 18 35.3 41.3 69 70 101l7 8H0v40h399905l-7 8c-28.7 32
-52 65.7-70 101-10.7 23.3-16 35.7-16 37 0 .7 7.7 1 23 1h23c24-69.3 71.3-125 142
-167z M100 147v40h399900v-40zM0 341v40h399900v-40z'/></svg></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.014em;"><span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\xtofrom{abc}</code></td>
</tr>
<tr>
<td style="text-align:left">\xtwoheadleftarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mo stretchy="true" minsize="3.0em">↞</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></mpadded></mover></mrow><annotation encoding="application/x-tex">\xtwoheadleftarrow{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0141em;"></span><span class="mrel x-arrow"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:1.0141em;"><span style="top:-3.228em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">ab</span><span class="mord mathnormal mtight">c</span></span></span></span><span class="svg-align" style="top:-2.783em;"><span class="pstrut" style="height:2.7em;"></span><span class="hide-tail" style="height:0.334em;min-width:0.888em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.334em' viewBox='0 0 400000 334' preserveAspectRatio='xMinYMin slice'><path d='M0 167c68 40
 115.7 95.7 143 167h22c15.3 0 23-.3 23-1 0-1.3-5.3-13.7-16-37-18-35.3-41.3-69
-70-101l-7-8h125l9 7c50.7 39.3 85 86 103 140h46c0-4.7-6.3-18.7-19-42-18-35.3
-40-67.3-66-96l-9-9h399716v-40H284l9-9c26-28.7 48-60.7 66-96 12.7-23.333 19
-37.333 19-42h-46c-18 54-52.3 100.7-103 140l-9 7H95l7-8c28.7-32 52-65.7 70-101
 10.7-23.333 16-35.7 16-37 0-.7-7.7-1-23-1h-22C115.7 71.3 68 127 0 167z'/></svg></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\xtwoheadleftarrow{abc}</code></td>
</tr>
<tr>
<td style="text-align:left">\xtwoheadrightarrow</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mover><mo stretchy="true" minsize="3.0em">↠</mo><mpadded width="+0.6em" lspace="0.3em"><mrow><mi>a</mi><mi>b</mi><mi>c</mi></mrow></mpadded></mover></mrow><annotation encoding="application/x-tex">\xtwoheadrightarrow{abc}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.0141em;"></span><span class="mrel x-arrow"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:1.0141em;"><span style="top:-3.228em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight x-arrow-pad"><span class="mord mtight"><span class="mord mathnormal mtight">ab</span><span class="mord mathnormal mtight">c</span></span></span></span><span class="svg-align" style="top:-2.783em;"><span class="pstrut" style="height:2.7em;"></span><span class="hide-tail" style="height:0.334em;min-width:0.888em;"><svg xmlns="http://www.w3.org/2000/svg" width='400em' height='0.334em' viewBox='0 0 400000 334' preserveAspectRatio='xMaxYMin slice'><path d='M400000 167
c-68-40-115.7-95.7-143-167h-22c-15.3 0-23 .3-23 1 0 1.3 5.3 13.7 16 37 18 35.3
 41.3 69 70 101l7 8h-125l-9-7c-50.7-39.3-85-86-103-140h-46c0 4.7 6.3 18.7 19 42
 18 35.3 40 67.3 66 96l9 9H0v40h399716l-9 9c-26 28.7-48 60.7-66 96-12.7 23.333
-19 37.333-19 42h46c18-54 52.3-100.7 103-140l9-7h125l-7 8c-28.7 32-52 65.7-70
 101-10.7 23.333-16 35.7-16 37 0 .7 7.7 1 23 1h22c27.3-71.3 75-127 143-167z'/></svg></span></span></span></span></span></span></span></span></span></td>
<td style="text-align:left"><code>\xtwoheadrightarrow{abc}</code></td>
</tr>
</tbody>
</table>
<h2 id="yz" tabindex="-1">YZ <a class="header-anchor" href="#yz" aria-label="Permalink to &quot;YZ&quot;">&ZeroWidthSpace;</a></h2>
<table>
<thead>
<tr>
<th style="text-align:left">Symbol/Function</th>
<th style="text-align:left">Rendered</th>
<th style="text-align:left">Source or Comment</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">\yen</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">¥</mi></mrow><annotation encoding="application/x-tex">\yen</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.675em;"></span><span class="mord amsrm" style="margin-right:0.025em;">¥</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Z</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="double-struck">Z</mi></mrow><annotation encoding="application/x-tex">\Z</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6889em;"></span><span class="mord mathbb">Z</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\Zeta</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">Z</mi></mrow><annotation encoding="application/x-tex">\Zeta</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord mathrm">Z</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
<tr>
<td style="text-align:left">\zeta</td>
<td style="text-align:left"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>ζ</mi></mrow><annotation encoding="application/x-tex">\zeta</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.07378em;">ζ</span></span></span></span></td>
<td style="text-align:left"></td>
</tr>
</tbody>
</table>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tips to Use markdown-it-katex]]></title>
            <link>https://note.toshiki.devapplication/markdown-it-katex/tips</link>
            <guid>https://note.toshiki.devapplication/markdown-it-katex/tips</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="tips-hacks" tabindex="-1">Tips &amp; Hacks <a class="header-anchor" href="#tips-hacks" aria-label="Permalink to &quot;Tips &amp; Hacks&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="_1-responsive-katex-styling" tabindex="-1">1: Responsive KaTeX Styling <a class="header-anchor" href="#_1-responsive-katex-styling" aria-label="Permalink to &quot;1: Responsive KaTeX Styling&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="_1-1-issue-background" tabindex="-1">1.1: Issue background <a class="header-anchor" href="#_1-1-issue-background" aria-label="Permalink to &quot;1.1: Issue background&quot;">&ZeroWidthSpace;</a></h3>
<p>KaTeX works out of the box on large screen devices such as laptops and desktop computers. But as KaTeX's built-in does not support responsiveness on it's default stylings, hence KaTeX equations might overflow out of the default width of the default application containers on small-screened mobile devices as you can see in the following image in the dev tool of chrome, when the dimension of the webpage is set to responsive or under a certain fixed device dimension, the equations rendered in KaTeX overflows out of the viewport as inspected in blue hightlight.</p>
<p><figure><img src="./assets/2023-03-22-17-04-25.png" alt="katex overflowing on small screen devices" title="katex overflowing on small screen devices" /><figcaption align="center"><small>◎ katex overflowing on small screen devices</small></figcaption></figure></p>
<p>This inevitably causes the viewport to break and extends the default width for KaTeX equations <code>&lt;div&gt;</code> to fit, users will be required to manually scroll right in order to view the full equation consequently as follows,</p>
<p><figure><img src="./assets/2023-03-22-20-29-28.png" alt="katex overflowing with labels annotated" title="katex overflowing with labels annotated" /><figcaption align="center"><small>◎ katex overflowing with labels annotated</small></figcaption></figure></p>
<p>The above situation is undoubtedly annoying for user experiences while reading documentation, consider at what scenarios users have to scroll, scroll and scroll only for viewing a single long-blocked equation, who would want to read such a text, right? But don't worry we have a simple fix for this situation via by several line of css.</p>
<h3 id="_1-2-temporary-solution" tabindex="-1">1.2: Temporary solution <a class="header-anchor" href="#_1-2-temporary-solution" aria-label="Permalink to &quot;1.2: Temporary solution&quot;">&ZeroWidthSpace;</a></h3>
<p>If you happened to search over KaTeX's official repo issue tracker on GitHub, there are several user-made css tweaks hack already, the fix is simple by adjusting the overflows of both x and y axes of the KaTeX render <code>&lt;div&gt;</code> blocks. The <code>katex-display &gt; .katex</code> selector targets the child element of the <code>.katex-display</code> class that has the <code>.katex</code> class. This is the element that contains the KaTeX math expression. The first block of styles is mostly concerned with making sure that the KaTeX expression doesn't overflow its container and can be scrolled horizontally if needed. The second block of styles sets the font and line-height for the KaTeX expression and makes sure that its text is properly indented.</p>
<p><a href="https://github.com/KaTeX/KaTeX/issues/327" target="_blank" rel="noreferrer">@preview</a></p>
<p>But, the issue here is, the overflowing issue is resolved on the webpage, but the style itself left with a slight whitish &quot;box&quot; at the crossing corner of both horizontal as well as vertical scrollbar tracks, this might not be so explicit in the light mode of the webpage, but when it turns to dark mode, the box become annoying. Some people might say it's an easy tweak via setting the display property of the &quot;box&quot; element to <code>display: none;</code> to directly remove the box out of the page, this is a smart approach; however, while the box is gone, the two crossing tracks is going to form an untouched invisible box again against two bars without color. Thus, neither ways seems to perfectly solve the problem.</p>
<h3 id="_1-3-finding-solution" tabindex="-1">1.3: Finding solution <a class="header-anchor" href="#_1-3-finding-solution" aria-label="Permalink to &quot;1.3: Finding solution&quot;">&ZeroWidthSpace;</a></h3>
<p>After running a quick research on Google, I found a simple hack tweak used in a theme of VuePress, <a href="https://github.com/vuepress-theme-hope/vuepress-theme-hope" target="_blank" rel="noreferrer">vuepress-theme-hope</a> on GitHub, the theme both integrate with KaTeX and MathJax for math supports.</p>
<p><a href="https://github.com/vuepress-theme-hope/vuepress-theme-hope" target="_blank" rel="noreferrer">@preview</a></p>
<p>Under the styles directory of the repository, several line of scss styles came across my eyes,</p>
<p><figure><img src="./assets/2023-05-22-10-14-11.png" alt="KaTeX tweak fix styles in theme" title="KaTeX tweak fix styles in theme" /><figcaption align="center"><small>◎ KaTeX tweak fix styles in theme</small></figcaption></figure></p>
<p>this scss lines only add a horizontal trackbar at the bottom of each overflowing equation while maximizing the vertical height of the equation, when user is on a small screened device as follows,</p>
<p><figure><img src="./assets/2023-05-22-10-27-47.png" alt="Horizontal scrollbar of equations on small screens" title="Horizontal scrollbar of equations on small screen" /><figcaption align="center"><small>◎ Horizontal scrollbar of equations on small screen</small></figcaption></figure></p>
<p>Consequently, the fix is easy.</p>
<h3 id="_1-4-solution" tabindex="-1">1.4: Solution <a class="header-anchor" href="#_1-4-solution" aria-label="Permalink to &quot;1.4: Solution&quot;">&ZeroWidthSpace;</a></h3>
<p>If you are running a documentation site like this version controlled via Node, especially VitePress without native scss supports, your fix would be installing scss support globally across the project, then add the scss styles and finally import the stylesheets to take effect globally.</p>
<p>Install global scss support using your favored package manager.</p>
<div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-cjnoZ" id="tab-E_1KZt7" checked="checked"><label for="tab-E_1KZt7">npm</label><input type="radio" name="group-cjnoZ" id="tab-C0Zgopt" ><label for="tab-C0Zgopt">yarn</label><input type="radio" name="group-cjnoZ" id="tab-Xl6rIhz" ><label for="tab-Xl6rIhz">pnpm</label></div><div class="blocks">
<div class="language-sh vp-adaptive-theme active line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">npm</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">install</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-D</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">scss</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">npm</span><span style="color: #24292E"> </span><span style="color: #032F62">install</span><span style="color: #24292E"> </span><span style="color: #005CC5">-D</span><span style="color: #24292E"> </span><span style="color: #032F62">scss</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">yarn</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">add</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--dev</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">scss</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">yarn</span><span style="color: #24292E"> </span><span style="color: #032F62">add</span><span style="color: #24292E"> </span><span style="color: #005CC5">--dev</span><span style="color: #24292E"> </span><span style="color: #032F62">scss</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">pnpm</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">add</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-D</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">scss</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">pnpm</span><span style="color: #24292E"> </span><span style="color: #032F62">add</span><span style="color: #24292E"> </span><span style="color: #005CC5">-D</span><span style="color: #24292E"> </span><span style="color: #032F62">scss</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div></div></div>
<p>Then in your scss stylesheets, add the following and link or import them to your global styles, you should be off to go with a complete fix-up for KaTeX.</p>
<div class="language-scss vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">scss</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">...</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390">// katex responsiveness fix</span></span>
<span class="line"><span style="color: #6CB6FF">.katex</span><span style="color: #ADBAC7"> {</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #6CB6FF">font-size</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">1.05</span><span style="color: #F47067">em</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #6CB6FF">direction</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">ltr</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">}</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6CB6FF">.katex-display</span><span style="color: #ADBAC7"> {</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #6CB6FF">overflow</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">auto</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">hidden</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #6CB6FF">-webkit-overflow-scrolling</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">touch</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #6CB6FF">padding-top</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">0.2</span><span style="color: #F47067">em</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #6CB6FF">padding-bottom</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">0.2</span><span style="color: #F47067">em</span><span style="color: #ADBAC7">;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #8DDB8C">&amp;</span><span style="color: #6CB6FF">::-webkit-scrollbar</span><span style="color: #ADBAC7"> {</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">height</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">3</span><span style="color: #F47067">px</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">  }</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #6CB6FF">.katex</span><span style="color: #ADBAC7"> {</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">font-size</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">1.21</span><span style="color: #F47067">em</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">  }</span></span>
<span class="line"><span style="color: #ADBAC7">}</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6CB6FF">.katex-error</span><span style="color: #ADBAC7"> {</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #6CB6FF">color</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">#f00</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">}</span></span>
<span class="line"><span style="color: #768390">// katex responsiveness fix ends</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">...</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">...</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D">// katex responsiveness fix</span></span>
<span class="line"><span style="color: #6F42C1">.katex</span><span style="color: #24292E"> {</span></span>
<span class="line"><span style="color: #24292E">  </span><span style="color: #005CC5">font-size</span><span style="color: #24292E">: </span><span style="color: #005CC5">1.05</span><span style="color: #D73A49">em</span><span style="color: #24292E">;</span></span>
<span class="line"><span style="color: #24292E">  </span><span style="color: #005CC5">direction</span><span style="color: #24292E">: </span><span style="color: #005CC5">ltr</span><span style="color: #24292E">;</span></span>
<span class="line"><span style="color: #24292E">}</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6F42C1">.katex-display</span><span style="color: #24292E"> {</span></span>
<span class="line"><span style="color: #24292E">  </span><span style="color: #005CC5">overflow</span><span style="color: #24292E">: </span><span style="color: #005CC5">auto</span><span style="color: #24292E"> </span><span style="color: #005CC5">hidden</span><span style="color: #24292E">;</span></span>
<span class="line"><span style="color: #24292E">  </span><span style="color: #005CC5">-webkit-overflow-scrolling</span><span style="color: #24292E">: </span><span style="color: #005CC5">touch</span><span style="color: #24292E">;</span></span>
<span class="line"><span style="color: #24292E">  </span><span style="color: #005CC5">padding-top</span><span style="color: #24292E">: </span><span style="color: #005CC5">0.2</span><span style="color: #D73A49">em</span><span style="color: #24292E">;</span></span>
<span class="line"><span style="color: #24292E">  </span><span style="color: #005CC5">padding-bottom</span><span style="color: #24292E">: </span><span style="color: #005CC5">0.2</span><span style="color: #D73A49">em</span><span style="color: #24292E">;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">  </span><span style="color: #22863A">&amp;</span><span style="color: #6F42C1">::-webkit-scrollbar</span><span style="color: #24292E"> {</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">height</span><span style="color: #24292E">: </span><span style="color: #005CC5">3</span><span style="color: #D73A49">px</span><span style="color: #24292E">;</span></span>
<span class="line"><span style="color: #24292E">  }</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">  </span><span style="color: #6F42C1">.katex</span><span style="color: #24292E"> {</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">font-size</span><span style="color: #24292E">: </span><span style="color: #005CC5">1.21</span><span style="color: #D73A49">em</span><span style="color: #24292E">;</span></span>
<span class="line"><span style="color: #24292E">  }</span></span>
<span class="line"><span style="color: #24292E">}</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6F42C1">.katex-error</span><span style="color: #24292E"> {</span></span>
<span class="line"><span style="color: #24292E">  </span><span style="color: #005CC5">color</span><span style="color: #24292E">: </span><span style="color: #005CC5">#f00</span><span style="color: #24292E">;</span></span>
<span class="line"><span style="color: #24292E">}</span></span>
<span class="line"><span style="color: #6A737D">// katex responsiveness fix ends</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">...</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br></div></div><p>Next, import your styles globally to take effect,</p>
<div class="language-scss vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">scss</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">@import</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;&lt;your-scss-file&gt;.scss&#39;</span><span style="color: #ADBAC7">;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">@import</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;&lt;your-scss-file&gt;.scss&#39;</span><span style="color: #24292E">;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><h4 id="_1-4-1-fix-explanation" tabindex="-1">1.4.1: Fix Explanation <a class="header-anchor" href="#_1-4-1-fix-explanation" aria-label="Permalink to &quot;1.4.1: Fix Explanation&quot;">&ZeroWidthSpace;</a></h4>
<p>The first section sets the base styles for all KaTeX elements by increasing the font size slightly and ensuring that the text direction is left to right.</p>
<p>The second section of code targets the KaTeX display elements specifically. This section adds a bit of padding to the top and bottom of the display elements and sets overflow to auto hidden, which allows the content to scroll inside the container horizontally if it overflows the container's width. The <code>-webkit-overflow-scrolling</code> property is added to ensure smooth scrolling on mobile devices.</p>
<p>Additionally, this section contains a nested <code>.katex selector</code>, which increases the font size of the KaTeX elements within the display element.</p>
<p>The third section targets the <code>.katex-error</code> class and sets the color to red to indicate that there is an error in rendering the LaTeX expression.</p>
<h3 id="_1-5-what-if-i-don-t-have-scss" tabindex="-1">1.5: What if I Don't Have SCSS? <a class="header-anchor" href="#_1-5-what-if-i-don-t-have-scss" aria-label="Permalink to &quot;1.5: What if I Don't Have SCSS?&quot;">&ZeroWidthSpace;</a></h3>
<p>If you do not have native scss support for your site, such as a static HTML based documentation site or content management site builder such as Wiki.JS that works as an SaaS which only allows users to apply custom stylesheets within slots provided and make effects, you could use some scss to css converter online with options follows,</p>
<ul>
<li><a href="https://jsonformatter.org" target="_blank" rel="noreferrer">@preview</a></li>
<li><a href="https://json2csharp.com" target="_blank" rel="noreferrer">@preview</a></li>
</ul>
<p>to precompile from source scss into normal css styles and use them based on your needs, below are auto-generated compiled css, <strong>ONLY take it as reference</strong>, I do not guarantee the usability.</p>
<div class="language-css vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">css</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #6CB6FF">.katex</span><span style="color: #ADBAC7"> {</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">font-size</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">1.05</span><span style="color: #F47067">em</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">direction</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">ltr</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">}</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6CB6FF">.katex-display</span><span style="color: #ADBAC7"> {</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">overflow</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">auto</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">hidden</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">-webkit-overflow-scrolling</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">touch</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">padding-top</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">0.2</span><span style="color: #F47067">em</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">padding-bottom</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">0.2</span><span style="color: #F47067">em</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">}</span></span>
<span class="line"><span style="color: #6CB6FF">.katex-display::-webkit-scrollbar</span><span style="color: #ADBAC7"> {</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">height</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">3</span><span style="color: #F47067">px</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">}</span></span>
<span class="line"><span style="color: #6CB6FF">.katex-display</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">.katex</span><span style="color: #ADBAC7"> {</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">font-size</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">1.21</span><span style="color: #F47067">em</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">}</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6CB6FF">.katex-error</span><span style="color: #ADBAC7"> {</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">color</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">#f00</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">}</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">.katex</span><span style="color: #24292E"> {</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">font-size</span><span style="color: #24292E">: </span><span style="color: #005CC5">1.05</span><span style="color: #D73A49">em</span><span style="color: #24292E">;</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">direction</span><span style="color: #24292E">: </span><span style="color: #005CC5">ltr</span><span style="color: #24292E">;</span></span>
<span class="line"><span style="color: #24292E">}</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6F42C1">.katex-display</span><span style="color: #24292E"> {</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">overflow</span><span style="color: #24292E">: </span><span style="color: #005CC5">auto</span><span style="color: #24292E"> </span><span style="color: #005CC5">hidden</span><span style="color: #24292E">;</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">-webkit-overflow-scrolling</span><span style="color: #24292E">: </span><span style="color: #005CC5">touch</span><span style="color: #24292E">;</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">padding-top</span><span style="color: #24292E">: </span><span style="color: #005CC5">0.2</span><span style="color: #D73A49">em</span><span style="color: #24292E">;</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">padding-bottom</span><span style="color: #24292E">: </span><span style="color: #005CC5">0.2</span><span style="color: #D73A49">em</span><span style="color: #24292E">;</span></span>
<span class="line"><span style="color: #24292E">}</span></span>
<span class="line"><span style="color: #6F42C1">.katex-display::-webkit-scrollbar</span><span style="color: #24292E"> {</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">height</span><span style="color: #24292E">: </span><span style="color: #005CC5">3</span><span style="color: #D73A49">px</span><span style="color: #24292E">;</span></span>
<span class="line"><span style="color: #24292E">}</span></span>
<span class="line"><span style="color: #6F42C1">.katex-display</span><span style="color: #24292E"> </span><span style="color: #6F42C1">.katex</span><span style="color: #24292E"> {</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">font-size</span><span style="color: #24292E">: </span><span style="color: #005CC5">1.21</span><span style="color: #D73A49">em</span><span style="color: #24292E">;</span></span>
<span class="line"><span style="color: #24292E">}</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6F42C1">.katex-error</span><span style="color: #24292E"> {</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">color</span><span style="color: #24292E">: </span><span style="color: #005CC5">#f00</span><span style="color: #24292E">;</span></span>
<span class="line"><span style="color: #24292E">}</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br></div></div><p>To be continued.</p>
<div class="info custom-block"><p class="custom-block-title">Reference</p>
<ul>
<li><a href="https://github.com/vuepress-theme-hope/vuepress-theme-hope/blob/main/docs/theme/src/.vuepress/components/toggle-rtl-button.scss" target="_blank" rel="noreferrer">vuepress-theme-hope/docs/theme/src/.vuepress/components/toggle-rtl-button.scss</a></li>
<li><a href="https://chat.toshiki.dev" target="_blank" rel="noreferrer">Toshiki's ChaGPT</a></li>
</ul>
</div>
]]></description>
            <content:encoded><![CDATA[<h1 id="tips-hacks" tabindex="-1">Tips &amp; Hacks <a class="header-anchor" href="#tips-hacks" aria-label="Permalink to &quot;Tips &amp; Hacks&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="_1-responsive-katex-styling" tabindex="-1">1: Responsive KaTeX Styling <a class="header-anchor" href="#_1-responsive-katex-styling" aria-label="Permalink to &quot;1: Responsive KaTeX Styling&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="_1-1-issue-background" tabindex="-1">1.1: Issue background <a class="header-anchor" href="#_1-1-issue-background" aria-label="Permalink to &quot;1.1: Issue background&quot;">&ZeroWidthSpace;</a></h3>
<p>KaTeX works out of the box on large screen devices such as laptops and desktop computers. But as KaTeX's built-in does not support responsiveness on it's default stylings, hence KaTeX equations might overflow out of the default width of the default application containers on small-screened mobile devices as you can see in the following image in the dev tool of chrome, when the dimension of the webpage is set to responsive or under a certain fixed device dimension, the equations rendered in KaTeX overflows out of the viewport as inspected in blue hightlight.</p>
<p><figure><img src="./assets/2023-03-22-17-04-25.png" alt="katex overflowing on small screen devices" title="katex overflowing on small screen devices" /><figcaption align="center"><small>◎ katex overflowing on small screen devices</small></figcaption></figure></p>
<p>This inevitably causes the viewport to break and extends the default width for KaTeX equations <code>&lt;div&gt;</code> to fit, users will be required to manually scroll right in order to view the full equation consequently as follows,</p>
<p><figure><img src="./assets/2023-03-22-20-29-28.png" alt="katex overflowing with labels annotated" title="katex overflowing with labels annotated" /><figcaption align="center"><small>◎ katex overflowing with labels annotated</small></figcaption></figure></p>
<p>The above situation is undoubtedly annoying for user experiences while reading documentation, consider at what scenarios users have to scroll, scroll and scroll only for viewing a single long-blocked equation, who would want to read such a text, right? But don't worry we have a simple fix for this situation via by several line of css.</p>
<h3 id="_1-2-temporary-solution" tabindex="-1">1.2: Temporary solution <a class="header-anchor" href="#_1-2-temporary-solution" aria-label="Permalink to &quot;1.2: Temporary solution&quot;">&ZeroWidthSpace;</a></h3>
<p>If you happened to search over KaTeX's official repo issue tracker on GitHub, there are several user-made css tweaks hack already, the fix is simple by adjusting the overflows of both x and y axes of the KaTeX render <code>&lt;div&gt;</code> blocks. The <code>katex-display &gt; .katex</code> selector targets the child element of the <code>.katex-display</code> class that has the <code>.katex</code> class. This is the element that contains the KaTeX math expression. The first block of styles is mostly concerned with making sure that the KaTeX expression doesn't overflow its container and can be scrolled horizontally if needed. The second block of styles sets the font and line-height for the KaTeX expression and makes sure that its text is properly indented.</p>
<p><a href="https://github.com/KaTeX/KaTeX/issues/327" target="_blank" rel="noreferrer">@preview</a></p>
<p>But, the issue here is, the overflowing issue is resolved on the webpage, but the style itself left with a slight whitish &quot;box&quot; at the crossing corner of both horizontal as well as vertical scrollbar tracks, this might not be so explicit in the light mode of the webpage, but when it turns to dark mode, the box become annoying. Some people might say it's an easy tweak via setting the display property of the &quot;box&quot; element to <code>display: none;</code> to directly remove the box out of the page, this is a smart approach; however, while the box is gone, the two crossing tracks is going to form an untouched invisible box again against two bars without color. Thus, neither ways seems to perfectly solve the problem.</p>
<h3 id="_1-3-finding-solution" tabindex="-1">1.3: Finding solution <a class="header-anchor" href="#_1-3-finding-solution" aria-label="Permalink to &quot;1.3: Finding solution&quot;">&ZeroWidthSpace;</a></h3>
<p>After running a quick research on Google, I found a simple hack tweak used in a theme of VuePress, <a href="https://github.com/vuepress-theme-hope/vuepress-theme-hope" target="_blank" rel="noreferrer">vuepress-theme-hope</a> on GitHub, the theme both integrate with KaTeX and MathJax for math supports.</p>
<p><a href="https://github.com/vuepress-theme-hope/vuepress-theme-hope" target="_blank" rel="noreferrer">@preview</a></p>
<p>Under the styles directory of the repository, several line of scss styles came across my eyes,</p>
<p><figure><img src="./assets/2023-05-22-10-14-11.png" alt="KaTeX tweak fix styles in theme" title="KaTeX tweak fix styles in theme" /><figcaption align="center"><small>◎ KaTeX tweak fix styles in theme</small></figcaption></figure></p>
<p>this scss lines only add a horizontal trackbar at the bottom of each overflowing equation while maximizing the vertical height of the equation, when user is on a small screened device as follows,</p>
<p><figure><img src="./assets/2023-05-22-10-27-47.png" alt="Horizontal scrollbar of equations on small screens" title="Horizontal scrollbar of equations on small screen" /><figcaption align="center"><small>◎ Horizontal scrollbar of equations on small screen</small></figcaption></figure></p>
<p>Consequently, the fix is easy.</p>
<h3 id="_1-4-solution" tabindex="-1">1.4: Solution <a class="header-anchor" href="#_1-4-solution" aria-label="Permalink to &quot;1.4: Solution&quot;">&ZeroWidthSpace;</a></h3>
<p>If you are running a documentation site like this version controlled via Node, especially VitePress without native scss supports, your fix would be installing scss support globally across the project, then add the scss styles and finally import the stylesheets to take effect globally.</p>
<p>Install global scss support using your favored package manager.</p>
<div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-cjnoZ" id="tab-E_1KZt7" checked="checked"><label for="tab-E_1KZt7">npm</label><input type="radio" name="group-cjnoZ" id="tab-C0Zgopt" ><label for="tab-C0Zgopt">yarn</label><input type="radio" name="group-cjnoZ" id="tab-Xl6rIhz" ><label for="tab-Xl6rIhz">pnpm</label></div><div class="blocks">
<div class="language-sh vp-adaptive-theme active line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">npm</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">install</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-D</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">scss</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">npm</span><span style="color: #24292E"> </span><span style="color: #032F62">install</span><span style="color: #24292E"> </span><span style="color: #005CC5">-D</span><span style="color: #24292E"> </span><span style="color: #032F62">scss</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">yarn</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">add</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--dev</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">scss</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">yarn</span><span style="color: #24292E"> </span><span style="color: #032F62">add</span><span style="color: #24292E"> </span><span style="color: #005CC5">--dev</span><span style="color: #24292E"> </span><span style="color: #032F62">scss</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">pnpm</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">add</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-D</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">scss</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">pnpm</span><span style="color: #24292E"> </span><span style="color: #032F62">add</span><span style="color: #24292E"> </span><span style="color: #005CC5">-D</span><span style="color: #24292E"> </span><span style="color: #032F62">scss</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div></div></div>
<p>Then in your scss stylesheets, add the following and link or import them to your global styles, you should be off to go with a complete fix-up for KaTeX.</p>
<div class="language-scss vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">scss</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">...</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390">// katex responsiveness fix</span></span>
<span class="line"><span style="color: #6CB6FF">.katex</span><span style="color: #ADBAC7"> {</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #6CB6FF">font-size</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">1.05</span><span style="color: #F47067">em</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #6CB6FF">direction</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">ltr</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">}</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6CB6FF">.katex-display</span><span style="color: #ADBAC7"> {</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #6CB6FF">overflow</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">auto</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">hidden</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #6CB6FF">-webkit-overflow-scrolling</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">touch</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #6CB6FF">padding-top</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">0.2</span><span style="color: #F47067">em</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #6CB6FF">padding-bottom</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">0.2</span><span style="color: #F47067">em</span><span style="color: #ADBAC7">;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #8DDB8C">&amp;</span><span style="color: #6CB6FF">::-webkit-scrollbar</span><span style="color: #ADBAC7"> {</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">height</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">3</span><span style="color: #F47067">px</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">  }</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #6CB6FF">.katex</span><span style="color: #ADBAC7"> {</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">font-size</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">1.21</span><span style="color: #F47067">em</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">  }</span></span>
<span class="line"><span style="color: #ADBAC7">}</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6CB6FF">.katex-error</span><span style="color: #ADBAC7"> {</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #6CB6FF">color</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">#f00</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">}</span></span>
<span class="line"><span style="color: #768390">// katex responsiveness fix ends</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">...</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">...</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D">// katex responsiveness fix</span></span>
<span class="line"><span style="color: #6F42C1">.katex</span><span style="color: #24292E"> {</span></span>
<span class="line"><span style="color: #24292E">  </span><span style="color: #005CC5">font-size</span><span style="color: #24292E">: </span><span style="color: #005CC5">1.05</span><span style="color: #D73A49">em</span><span style="color: #24292E">;</span></span>
<span class="line"><span style="color: #24292E">  </span><span style="color: #005CC5">direction</span><span style="color: #24292E">: </span><span style="color: #005CC5">ltr</span><span style="color: #24292E">;</span></span>
<span class="line"><span style="color: #24292E">}</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6F42C1">.katex-display</span><span style="color: #24292E"> {</span></span>
<span class="line"><span style="color: #24292E">  </span><span style="color: #005CC5">overflow</span><span style="color: #24292E">: </span><span style="color: #005CC5">auto</span><span style="color: #24292E"> </span><span style="color: #005CC5">hidden</span><span style="color: #24292E">;</span></span>
<span class="line"><span style="color: #24292E">  </span><span style="color: #005CC5">-webkit-overflow-scrolling</span><span style="color: #24292E">: </span><span style="color: #005CC5">touch</span><span style="color: #24292E">;</span></span>
<span class="line"><span style="color: #24292E">  </span><span style="color: #005CC5">padding-top</span><span style="color: #24292E">: </span><span style="color: #005CC5">0.2</span><span style="color: #D73A49">em</span><span style="color: #24292E">;</span></span>
<span class="line"><span style="color: #24292E">  </span><span style="color: #005CC5">padding-bottom</span><span style="color: #24292E">: </span><span style="color: #005CC5">0.2</span><span style="color: #D73A49">em</span><span style="color: #24292E">;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">  </span><span style="color: #22863A">&amp;</span><span style="color: #6F42C1">::-webkit-scrollbar</span><span style="color: #24292E"> {</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">height</span><span style="color: #24292E">: </span><span style="color: #005CC5">3</span><span style="color: #D73A49">px</span><span style="color: #24292E">;</span></span>
<span class="line"><span style="color: #24292E">  }</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">  </span><span style="color: #6F42C1">.katex</span><span style="color: #24292E"> {</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">font-size</span><span style="color: #24292E">: </span><span style="color: #005CC5">1.21</span><span style="color: #D73A49">em</span><span style="color: #24292E">;</span></span>
<span class="line"><span style="color: #24292E">  }</span></span>
<span class="line"><span style="color: #24292E">}</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6F42C1">.katex-error</span><span style="color: #24292E"> {</span></span>
<span class="line"><span style="color: #24292E">  </span><span style="color: #005CC5">color</span><span style="color: #24292E">: </span><span style="color: #005CC5">#f00</span><span style="color: #24292E">;</span></span>
<span class="line"><span style="color: #24292E">}</span></span>
<span class="line"><span style="color: #6A737D">// katex responsiveness fix ends</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">...</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br></div></div><p>Next, import your styles globally to take effect,</p>
<div class="language-scss vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">scss</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">@import</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;&lt;your-scss-file&gt;.scss&#39;</span><span style="color: #ADBAC7">;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">@import</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;&lt;your-scss-file&gt;.scss&#39;</span><span style="color: #24292E">;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><h4 id="_1-4-1-fix-explanation" tabindex="-1">1.4.1: Fix Explanation <a class="header-anchor" href="#_1-4-1-fix-explanation" aria-label="Permalink to &quot;1.4.1: Fix Explanation&quot;">&ZeroWidthSpace;</a></h4>
<p>The first section sets the base styles for all KaTeX elements by increasing the font size slightly and ensuring that the text direction is left to right.</p>
<p>The second section of code targets the KaTeX display elements specifically. This section adds a bit of padding to the top and bottom of the display elements and sets overflow to auto hidden, which allows the content to scroll inside the container horizontally if it overflows the container's width. The <code>-webkit-overflow-scrolling</code> property is added to ensure smooth scrolling on mobile devices.</p>
<p>Additionally, this section contains a nested <code>.katex selector</code>, which increases the font size of the KaTeX elements within the display element.</p>
<p>The third section targets the <code>.katex-error</code> class and sets the color to red to indicate that there is an error in rendering the LaTeX expression.</p>
<h3 id="_1-5-what-if-i-don-t-have-scss" tabindex="-1">1.5: What if I Don't Have SCSS? <a class="header-anchor" href="#_1-5-what-if-i-don-t-have-scss" aria-label="Permalink to &quot;1.5: What if I Don't Have SCSS?&quot;">&ZeroWidthSpace;</a></h3>
<p>If you do not have native scss support for your site, such as a static HTML based documentation site or content management site builder such as Wiki.JS that works as an SaaS which only allows users to apply custom stylesheets within slots provided and make effects, you could use some scss to css converter online with options follows,</p>
<ul>
<li><a href="https://jsonformatter.org" target="_blank" rel="noreferrer">@preview</a></li>
<li><a href="https://json2csharp.com" target="_blank" rel="noreferrer">@preview</a></li>
</ul>
<p>to precompile from source scss into normal css styles and use them based on your needs, below are auto-generated compiled css, <strong>ONLY take it as reference</strong>, I do not guarantee the usability.</p>
<div class="language-css vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">css</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #6CB6FF">.katex</span><span style="color: #ADBAC7"> {</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">font-size</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">1.05</span><span style="color: #F47067">em</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">direction</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">ltr</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">}</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6CB6FF">.katex-display</span><span style="color: #ADBAC7"> {</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">overflow</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">auto</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">hidden</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">-webkit-overflow-scrolling</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">touch</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">padding-top</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">0.2</span><span style="color: #F47067">em</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">padding-bottom</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">0.2</span><span style="color: #F47067">em</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">}</span></span>
<span class="line"><span style="color: #6CB6FF">.katex-display::-webkit-scrollbar</span><span style="color: #ADBAC7"> {</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">height</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">3</span><span style="color: #F47067">px</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">}</span></span>
<span class="line"><span style="color: #6CB6FF">.katex-display</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">.katex</span><span style="color: #ADBAC7"> {</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">font-size</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">1.21</span><span style="color: #F47067">em</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">}</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6CB6FF">.katex-error</span><span style="color: #ADBAC7"> {</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">color</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">#f00</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">}</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">.katex</span><span style="color: #24292E"> {</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">font-size</span><span style="color: #24292E">: </span><span style="color: #005CC5">1.05</span><span style="color: #D73A49">em</span><span style="color: #24292E">;</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">direction</span><span style="color: #24292E">: </span><span style="color: #005CC5">ltr</span><span style="color: #24292E">;</span></span>
<span class="line"><span style="color: #24292E">}</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6F42C1">.katex-display</span><span style="color: #24292E"> {</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">overflow</span><span style="color: #24292E">: </span><span style="color: #005CC5">auto</span><span style="color: #24292E"> </span><span style="color: #005CC5">hidden</span><span style="color: #24292E">;</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">-webkit-overflow-scrolling</span><span style="color: #24292E">: </span><span style="color: #005CC5">touch</span><span style="color: #24292E">;</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">padding-top</span><span style="color: #24292E">: </span><span style="color: #005CC5">0.2</span><span style="color: #D73A49">em</span><span style="color: #24292E">;</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">padding-bottom</span><span style="color: #24292E">: </span><span style="color: #005CC5">0.2</span><span style="color: #D73A49">em</span><span style="color: #24292E">;</span></span>
<span class="line"><span style="color: #24292E">}</span></span>
<span class="line"><span style="color: #6F42C1">.katex-display::-webkit-scrollbar</span><span style="color: #24292E"> {</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">height</span><span style="color: #24292E">: </span><span style="color: #005CC5">3</span><span style="color: #D73A49">px</span><span style="color: #24292E">;</span></span>
<span class="line"><span style="color: #24292E">}</span></span>
<span class="line"><span style="color: #6F42C1">.katex-display</span><span style="color: #24292E"> </span><span style="color: #6F42C1">.katex</span><span style="color: #24292E"> {</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">font-size</span><span style="color: #24292E">: </span><span style="color: #005CC5">1.21</span><span style="color: #D73A49">em</span><span style="color: #24292E">;</span></span>
<span class="line"><span style="color: #24292E">}</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6F42C1">.katex-error</span><span style="color: #24292E"> {</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">color</span><span style="color: #24292E">: </span><span style="color: #005CC5">#f00</span><span style="color: #24292E">;</span></span>
<span class="line"><span style="color: #24292E">}</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br></div></div><p>To be continued.</p>
<div class="info custom-block"><p class="custom-block-title">Reference</p>
<ul>
<li><a href="https://github.com/vuepress-theme-hope/vuepress-theme-hope/blob/main/docs/theme/src/.vuepress/components/toggle-rtl-button.scss" target="_blank" rel="noreferrer">vuepress-theme-hope/docs/theme/src/.vuepress/components/toggle-rtl-button.scss</a></li>
<li><a href="https://chat.toshiki.dev" target="_blank" rel="noreferrer">Toshiki's ChaGPT</a></li>
</ul>
</div>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Meta Annotations]]></title>
            <link>https://note.toshiki.devapplication/vitepress-plugin-shiki-twoslash/api/annotations</link>
            <guid>https://note.toshiki.devapplication/vitepress-plugin-shiki-twoslash/api/annotations</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="queries" tabindex="-1">Queries <a class="header-anchor" href="#queries" aria-label="Permalink to &quot;Queries&quot;">&ZeroWidthSpace;</a></h1>
<p>Sometimes the thing you want to say is about the code, annotations provide a way to provide outside commentary on your code.</p>
<h2 id="annotate-left-right-overrides-text" tabindex="-1"><code>@annotate: [left|right] [overrides] - [text]</code> <a class="header-anchor" href="#annotate-left-right-overrides-text" aria-label="Permalink to &quot;`@annotate: [left|right] [overrides] - [text]`&quot;">&ZeroWidthSpace;</a></h2>
<p>Annotate has a lot more controls than most of the other Twoslash commands, because each use of it probably needs to feel a bit different. Here's an example based on the TypeScript home page, click it to get it running so we can talk about what it does:</p>
<div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-RL7xR" id="tab-iqykz0a" checked="checked"><label for="tab-iqykz0a">output</label><input type="radio" name="group-RL7xR" id="tab-cWq2P8c" ><label for="tab-cWq2P8c">markdown</label></div><div class="blocks">
<div class="language-ts vp-adaptive-theme active line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre><code class="language-ts"><div class='tag-container'><pre class="shiki github-dark-dimmed twoslash lsp" style="background-color: #22272e; color: #adbac7"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #F47067">function</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB"><data-lsp lsp='function compact(arr: any): any' >compact</data-lsp></span><span style="color: #ADBAC7">(</span><span style="color: #F69D50"><data-lsp lsp='(parameter) arr: any' >arr</data-lsp></span><span style="color: #ADBAC7">) {</span></div><div class='line'><span style="color: #ADBAC7">    </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> (<data-err><data-lsp lsp='any' >orr</data-lsp></data-err>.</span><span style="color: #6CB6FF"><data-lsp lsp='any' >length</data-lsp></span><span style="color: #ADBAC7"> </span><span style="color: #F47067">&gt;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">10</span><span style="color: #ADBAC7">) </span><span style="color: #F47067">return</span><span style="color: #ADBAC7"> <data-lsp lsp='(parameter) arr: any' >arr</data-lsp>.</span><span style="color: #DCBDFB"><data-lsp lsp='any' >trim</data-lsp></span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">10</span><span style="color: #ADBAC7">)</span></div><span class="error"><span>Cannot find name 'orr'.</span><span class="code">2304</span></span><span class="error-behind">Cannot find name 'orr'.</span><div class='line'><span style="color: #ADBAC7">    </span><span style="color: #F47067">return</span><span style="color: #ADBAC7"> <data-lsp lsp='(parameter) arr: any' >arr</data-lsp></span></div><div class='line'><span style="color: #ADBAC7">}</span></div></code></div></pre>
<div class='twoslash-annotation left' style="top: 0rem">
  <svg style='transform: translateX(8px) translateY(27px) rotate(90deg);' width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
    <path d="M1 39C1.5 32.7511 6.1 17.5173 20.5 6.57333M11.5 4.04L27 0.999998C24.8333 4.88444 20.5 13.16 20.5 15.1867" stroke="black" />
</svg>
  <p class='twoslash-annotation-text' style="transform: rotate(3deg)">Discovered a typo, the param is arr, not orr!</p>
</div></div>
<div class='tag-container'><pre class="shiki github-light twoslash lsp" style="background-color: #fff; color: #24292e"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #D73A49">function</span><span style="color: #24292E"> </span><span style="color: #6F42C1"><data-lsp lsp='function compact(arr: any): any' >compact</data-lsp></span><span style="color: #24292E">(</span><span style="color: #E36209"><data-lsp lsp='(parameter) arr: any' >arr</data-lsp></span><span style="color: #24292E">) {</span></div><div class='line'><span style="color: #24292E">    </span><span style="color: #D73A49">if</span><span style="color: #24292E"> (<data-err><data-lsp lsp='any' >orr</data-lsp></data-err>.</span><span style="color: #005CC5"><data-lsp lsp='any' >length</data-lsp></span><span style="color: #24292E"> </span><span style="color: #D73A49">&gt;</span><span style="color: #24292E"> </span><span style="color: #005CC5">10</span><span style="color: #24292E">) </span><span style="color: #D73A49">return</span><span style="color: #24292E"> <data-lsp lsp='(parameter) arr: any' >arr</data-lsp>.</span><span style="color: #6F42C1"><data-lsp lsp='any' >trim</data-lsp></span><span style="color: #24292E">(</span><span style="color: #005CC5">0</span><span style="color: #24292E">, </span><span style="color: #005CC5">10</span><span style="color: #24292E">)</span></div><span class="error"><span>Cannot find name 'orr'.</span><span class="code">2304</span></span><span class="error-behind">Cannot find name 'orr'.</span><div class='line'><span style="color: #24292E">    </span><span style="color: #D73A49">return</span><span style="color: #24292E"> <data-lsp lsp='(parameter) arr: any' >arr</data-lsp></span></div><div class='line'><span style="color: #24292E">}</span></div></code></div></pre>
<div class='twoslash-annotation left' style="top: 0rem">
  <svg style='transform: translateX(8px) translateY(27px) rotate(90deg);' width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
    <path d="M1 39C1.5 32.7511 6.1 17.5173 20.5 6.57333M11.5 4.04L27 0.999998C24.8333 4.88444 20.5 13.16 20.5 15.1867" stroke="black" />
</svg>
  <p class='twoslash-annotation-text' style="transform: rotate(3deg)">Discovered a typo, the param is arr, not orr!</p>
</div></div></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="language-md vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">md</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">```ts twoslash</span></span>
<span class="line"><span style="color: #768390">// @errors: 2304</span></span>
<span class="line"><span style="color: #768390">// @strict: false</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F47067">function</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">compact</span><span style="color: #ADBAC7">(</span><span style="color: #F69D50">arr</span><span style="color: #ADBAC7">) {</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> (orr.</span><span style="color: #6CB6FF">length</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">&gt;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">10</span><span style="color: #ADBAC7">) </span><span style="color: #F47067">return</span><span style="color: #ADBAC7"> arr.</span><span style="color: #DCBDFB">trim</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">10</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">return</span><span style="color: #ADBAC7"> arr</span></span>
<span class="line"><span style="color: #ADBAC7">}</span></span>
<span class="line"><span style="color: #768390">// @annotate: left { &quot;arrowRot&quot;: &quot;90deg 8px 27px&quot;, &quot;textDegree&quot;: &quot;3deg&quot;, &quot;top&quot;: &quot;0rem&quot; } - Discovered a typo, the param is arr, not orr!</span></span>
<span class="line"><span style="color: #ADBAC7">```</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">```ts twoslash</span></span>
<span class="line"><span style="color: #6A737D">// @errors: 2304</span></span>
<span class="line"><span style="color: #6A737D">// @strict: false</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D73A49">function</span><span style="color: #24292E"> </span><span style="color: #6F42C1">compact</span><span style="color: #24292E">(</span><span style="color: #E36209">arr</span><span style="color: #24292E">) {</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">if</span><span style="color: #24292E"> (orr.</span><span style="color: #005CC5">length</span><span style="color: #24292E"> </span><span style="color: #D73A49">&gt;</span><span style="color: #24292E"> </span><span style="color: #005CC5">10</span><span style="color: #24292E">) </span><span style="color: #D73A49">return</span><span style="color: #24292E"> arr.</span><span style="color: #6F42C1">trim</span><span style="color: #24292E">(</span><span style="color: #005CC5">0</span><span style="color: #24292E">, </span><span style="color: #005CC5">10</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">return</span><span style="color: #24292E"> arr</span></span>
<span class="line"><span style="color: #24292E">}</span></span>
<span class="line"><span style="color: #6A737D">// @annotate: left { &quot;arrowRot&quot;: &quot;90deg 8px 27px&quot;, &quot;textDegree&quot;: &quot;3deg&quot;, &quot;top&quot;: &quot;0rem&quot; } - Discovered a typo, the param is arr, not orr!</span></span>
<span class="line"><span style="color: #24292E">```</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br></div></div></div></div>
<p>First up, cool — it adds some text to the left hand side of the code. It features quite a few different options, so lets go through them one by one:</p>
<ul>
<li>
<p><code>left</code> or <code>right</code>: It's currently <code>left</code>. It's worth noting the arrow flips also, and <code>90deg</code> isn't a great option. Let's look at that next.</p>
</li>
<li>
<p><code>{ &quot;arrrowRot&quot;: &quot;90deg 8px 27px&quot; }</code> - This JSON object is used to manipulate the annotation, you have 3 controls for arrow positioning and rotation: <code>degrees x y</code>. I recommend keeping those in degrees and px, but it's your life. These are overrides from defaults which are okay, but not really something you ever want to ship.</p>
</li>
<li>
<p><code>{ &quot;textDegree&quot;: &quot;3deg&quot; }</code> - Rotates the text, you probably want something between <code>-3deg</code> and <code>3deg</code>. Optional, defaults to <code>0</code>.</p>
</li>
<li>
<p><code>{ &quot;top&quot;: &quot;0rem&quot; }</code> - Sets the y coordinates for the annotation relative to the code sample, if it's not included then it becomes <code>[lineNum]rem</code>.</p>
</li>
</ul>
<p>What's not included in this sample is <code>flipped</code>, which can be used to flip the arrow's orientation. Here's some examples:</p>
<p>A horizontal right example:</p>
<div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-isBpX" id="tab-R9RuM2y" checked="checked"><label for="tab-R9RuM2y">output</label><input type="radio" name="group-isBpX" id="tab-M5ArioQ" ><label for="tab-M5ArioQ">markdown</label></div><div class="blocks">
<div class="language-ts vp-adaptive-theme active line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre><code class="language-ts"><div class='tag-container'><pre class="shiki github-dark-dimmed twoslash lsp" style="background-color: #22272e; color: #adbac7"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #F47067">function</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB"><data-lsp lsp='function compact(arr: any): any' >compact</data-lsp></span><span style="color: #ADBAC7">(</span><span style="color: #F69D50"><data-lsp lsp='(parameter) arr: any' >arr</data-lsp></span><span style="color: #ADBAC7">) {</span></div><div class='line'><span style="color: #ADBAC7">    </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> (<data-err><data-lsp lsp='any' >orr</data-lsp></data-err>.</span><span style="color: #6CB6FF"><data-lsp lsp='any' >length</data-lsp></span><span style="color: #ADBAC7"> </span><span style="color: #F47067">&gt;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">10</span><span style="color: #ADBAC7">) </span><span style="color: #F47067">return</span><span style="color: #ADBAC7"> <data-lsp lsp='(parameter) arr: any' >arr</data-lsp>.</span><span style="color: #DCBDFB"><data-lsp lsp='any' >trim</data-lsp></span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">10</span><span style="color: #ADBAC7">)</span></div><span class="error"><span>Cannot find name 'orr'.</span><span class="code">2304</span></span><span class="error-behind">Cannot find name 'orr'.</span><div class='line'><span style="color: #ADBAC7">    </span><span style="color: #F47067">return</span><span style="color: #ADBAC7"> <data-lsp lsp='(parameter) arr: any' >arr</data-lsp></span></div><div class='line'><span style="color: #ADBAC7">}</span></div></code></div></pre>
<div class='twoslash-annotation right' style="top: 3rem">
  <svg style='transform: translateX(-10px) translateY(-10px) rotate(-50deg);' width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
    <path d="M27 39C26.5 32.7511 21.9 17.5173 7.5 6.57333M16.5 4.04L0.999999 0.999998C3.16667 4.88444 7.5 13.16 7.5 15.1867" stroke="black" />
</svg>
  <p class='twoslash-annotation-text' style="transform: rotate(0deg)">Discovered a typo, the param is arr, not orr!</p>
</div></div>
<div class='tag-container'><pre class="shiki github-light twoslash lsp" style="background-color: #fff; color: #24292e"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #D73A49">function</span><span style="color: #24292E"> </span><span style="color: #6F42C1"><data-lsp lsp='function compact(arr: any): any' >compact</data-lsp></span><span style="color: #24292E">(</span><span style="color: #E36209"><data-lsp lsp='(parameter) arr: any' >arr</data-lsp></span><span style="color: #24292E">) {</span></div><div class='line'><span style="color: #24292E">    </span><span style="color: #D73A49">if</span><span style="color: #24292E"> (<data-err><data-lsp lsp='any' >orr</data-lsp></data-err>.</span><span style="color: #005CC5"><data-lsp lsp='any' >length</data-lsp></span><span style="color: #24292E"> </span><span style="color: #D73A49">&gt;</span><span style="color: #24292E"> </span><span style="color: #005CC5">10</span><span style="color: #24292E">) </span><span style="color: #D73A49">return</span><span style="color: #24292E"> <data-lsp lsp='(parameter) arr: any' >arr</data-lsp>.</span><span style="color: #6F42C1"><data-lsp lsp='any' >trim</data-lsp></span><span style="color: #24292E">(</span><span style="color: #005CC5">0</span><span style="color: #24292E">, </span><span style="color: #005CC5">10</span><span style="color: #24292E">)</span></div><span class="error"><span>Cannot find name 'orr'.</span><span class="code">2304</span></span><span class="error-behind">Cannot find name 'orr'.</span><div class='line'><span style="color: #24292E">    </span><span style="color: #D73A49">return</span><span style="color: #24292E"> <data-lsp lsp='(parameter) arr: any' >arr</data-lsp></span></div><div class='line'><span style="color: #24292E">}</span></div></code></div></pre>
<div class='twoslash-annotation right' style="top: 3rem">
  <svg style='transform: translateX(-10px) translateY(-10px) rotate(-50deg);' width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
    <path d="M27 39C26.5 32.7511 21.9 17.5173 7.5 6.57333M16.5 4.04L0.999999 0.999998C3.16667 4.88444 7.5 13.16 7.5 15.1867" stroke="black" />
</svg>
  <p class='twoslash-annotation-text' style="transform: rotate(0deg)">Discovered a typo, the param is arr, not orr!</p>
</div></div></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="language-md vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">md</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">```ts twoslash</span></span>
<span class="line"><span style="color: #768390">// @errors: 2304</span></span>
<span class="line"><span style="color: #768390">// @strict: false</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F47067">function</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">compact</span><span style="color: #ADBAC7">(</span><span style="color: #F69D50">arr</span><span style="color: #ADBAC7">) {</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> (orr.</span><span style="color: #6CB6FF">length</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">&gt;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">10</span><span style="color: #ADBAC7">) </span><span style="color: #F47067">return</span><span style="color: #ADBAC7"> arr.</span><span style="color: #DCBDFB">trim</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">10</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">return</span><span style="color: #ADBAC7"> arr</span></span>
<span class="line"><span style="color: #ADBAC7">}</span></span>
<span class="line"><span style="color: #768390">// @annotate: left { &quot;arrowRot&quot;: &quot;90deg 8px 27px&quot;, &quot;textDegree&quot;: &quot;3deg&quot;, &quot;top&quot;: &quot;0rem&quot; } - Discovered a typo, the param is arr, not orr!</span></span>
<span class="line"><span style="color: #ADBAC7">```</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">```ts twoslash</span></span>
<span class="line"><span style="color: #6A737D">// @errors: 2304</span></span>
<span class="line"><span style="color: #6A737D">// @strict: false</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D73A49">function</span><span style="color: #24292E"> </span><span style="color: #6F42C1">compact</span><span style="color: #24292E">(</span><span style="color: #E36209">arr</span><span style="color: #24292E">) {</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">if</span><span style="color: #24292E"> (orr.</span><span style="color: #005CC5">length</span><span style="color: #24292E"> </span><span style="color: #D73A49">&gt;</span><span style="color: #24292E"> </span><span style="color: #005CC5">10</span><span style="color: #24292E">) </span><span style="color: #D73A49">return</span><span style="color: #24292E"> arr.</span><span style="color: #6F42C1">trim</span><span style="color: #24292E">(</span><span style="color: #005CC5">0</span><span style="color: #24292E">, </span><span style="color: #005CC5">10</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">return</span><span style="color: #24292E"> arr</span></span>
<span class="line"><span style="color: #24292E">}</span></span>
<span class="line"><span style="color: #6A737D">// @annotate: left { &quot;arrowRot&quot;: &quot;90deg 8px 27px&quot;, &quot;textDegree&quot;: &quot;3deg&quot;, &quot;top&quot;: &quot;0rem&quot; } - Discovered a typo, the param is arr, not orr!</span></span>
<span class="line"><span style="color: #24292E">```</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br></div></div></div></div>
<p>Upside down arrow pointing at the error, using flipped to re-flip the arrow:</p>
<div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-UxMM0" id="tab-JNUm7H0" checked="checked"><label for="tab-JNUm7H0">output</label><input type="radio" name="group-UxMM0" id="tab-kJghORW" ><label for="tab-kJghORW">markdown</label></div><div class="blocks">
<div class="language-ts vp-adaptive-theme active line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre><code class="language-ts"><div class='tag-container'><pre class="shiki github-dark-dimmed twoslash lsp" style="background-color: #22272e; color: #adbac7"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #F47067">function</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB"><data-lsp lsp='function compact(arr: any): any' >compact</data-lsp></span><span style="color: #ADBAC7">(</span><span style="color: #F69D50"><data-lsp lsp='(parameter) arr: any' >arr</data-lsp></span><span style="color: #ADBAC7">) {</span></div><div class='line'><span style="color: #ADBAC7">    </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> (<data-err><data-lsp lsp='any' >orr</data-lsp></data-err>.</span><span style="color: #6CB6FF"><data-lsp lsp='any' >length</data-lsp></span><span style="color: #ADBAC7"> </span><span style="color: #F47067">&gt;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">10</span><span style="color: #ADBAC7">) </span><span style="color: #F47067">return</span><span style="color: #ADBAC7"> <data-lsp lsp='(parameter) arr: any' >arr</data-lsp>.</span><span style="color: #DCBDFB"><data-lsp lsp='any' >trim</data-lsp></span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">10</span><span style="color: #ADBAC7">)</span></div><span class="error"><span>Cannot find name 'orr'.</span><span class="code">2304</span></span><span class="error-behind">Cannot find name 'orr'.</span><div class='line'><span style="color: #ADBAC7">    </span><span style="color: #F47067">return</span><span style="color: #ADBAC7"> <data-lsp lsp='(parameter) arr: any' >arr</data-lsp></span></div><div class='line'><span style="color: #ADBAC7">}</span></div></code></div></pre>
<div class='twoslash-annotation right' style="top: -0.7rem">
  <svg style='transform: translateX(8px) translateY(46px) rotate(190deg);' width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
    <path d="M1 39C1.5 32.7511 6.1 17.5173 20.5 6.57333M11.5 4.04L27 0.999998C24.8333 4.88444 20.5 13.16 20.5 15.1867" stroke="black" />
</svg>
  <p class='twoslash-annotation-text' style="transform: rotate(-3deg)">Discovered a typo, the param is arr, not orr!</p>
</div></div>
<div class='tag-container'><pre class="shiki github-light twoslash lsp" style="background-color: #fff; color: #24292e"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #D73A49">function</span><span style="color: #24292E"> </span><span style="color: #6F42C1"><data-lsp lsp='function compact(arr: any): any' >compact</data-lsp></span><span style="color: #24292E">(</span><span style="color: #E36209"><data-lsp lsp='(parameter) arr: any' >arr</data-lsp></span><span style="color: #24292E">) {</span></div><div class='line'><span style="color: #24292E">    </span><span style="color: #D73A49">if</span><span style="color: #24292E"> (<data-err><data-lsp lsp='any' >orr</data-lsp></data-err>.</span><span style="color: #005CC5"><data-lsp lsp='any' >length</data-lsp></span><span style="color: #24292E"> </span><span style="color: #D73A49">&gt;</span><span style="color: #24292E"> </span><span style="color: #005CC5">10</span><span style="color: #24292E">) </span><span style="color: #D73A49">return</span><span style="color: #24292E"> <data-lsp lsp='(parameter) arr: any' >arr</data-lsp>.</span><span style="color: #6F42C1"><data-lsp lsp='any' >trim</data-lsp></span><span style="color: #24292E">(</span><span style="color: #005CC5">0</span><span style="color: #24292E">, </span><span style="color: #005CC5">10</span><span style="color: #24292E">)</span></div><span class="error"><span>Cannot find name 'orr'.</span><span class="code">2304</span></span><span class="error-behind">Cannot find name 'orr'.</span><div class='line'><span style="color: #24292E">    </span><span style="color: #D73A49">return</span><span style="color: #24292E"> <data-lsp lsp='(parameter) arr: any' >arr</data-lsp></span></div><div class='line'><span style="color: #24292E">}</span></div></code></div></pre>
<div class='twoslash-annotation right' style="top: -0.7rem">
  <svg style='transform: translateX(8px) translateY(46px) rotate(190deg);' width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
    <path d="M1 39C1.5 32.7511 6.1 17.5173 20.5 6.57333M11.5 4.04L27 0.999998C24.8333 4.88444 20.5 13.16 20.5 15.1867" stroke="black" />
</svg>
  <p class='twoslash-annotation-text' style="transform: rotate(-3deg)">Discovered a typo, the param is arr, not orr!</p>
</div></div></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="language-md vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">md</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">```ts twoslash</span></span>
<span class="line"><span style="color: #768390">// @errors: 2304</span></span>
<span class="line"><span style="color: #768390">// @strict: false</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F47067">function</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">compact</span><span style="color: #ADBAC7">(</span><span style="color: #F69D50">arr</span><span style="color: #ADBAC7">) {</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> (orr.</span><span style="color: #6CB6FF">length</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">&gt;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">10</span><span style="color: #ADBAC7">) </span><span style="color: #F47067">return</span><span style="color: #ADBAC7"> arr.</span><span style="color: #DCBDFB">trim</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">10</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">return</span><span style="color: #ADBAC7"> arr</span></span>
<span class="line"><span style="color: #ADBAC7">}</span></span>
<span class="line"><span style="color: #768390">// @annotate: left { &quot;arrowRot&quot;: &quot;90deg 8px 27px&quot;, &quot;textDegree&quot;: &quot;3deg&quot;, &quot;top&quot;: &quot;0rem&quot; } - Discovered a typo, the param is arr, not orr!</span></span>
<span class="line"><span style="color: #ADBAC7">```</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">```ts twoslash</span></span>
<span class="line"><span style="color: #6A737D">// @errors: 2304</span></span>
<span class="line"><span style="color: #6A737D">// @strict: false</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D73A49">function</span><span style="color: #24292E"> </span><span style="color: #6F42C1">compact</span><span style="color: #24292E">(</span><span style="color: #E36209">arr</span><span style="color: #24292E">) {</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">if</span><span style="color: #24292E"> (orr.</span><span style="color: #005CC5">length</span><span style="color: #24292E"> </span><span style="color: #D73A49">&gt;</span><span style="color: #24292E"> </span><span style="color: #005CC5">10</span><span style="color: #24292E">) </span><span style="color: #D73A49">return</span><span style="color: #24292E"> arr.</span><span style="color: #6F42C1">trim</span><span style="color: #24292E">(</span><span style="color: #005CC5">0</span><span style="color: #24292E">, </span><span style="color: #005CC5">10</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">return</span><span style="color: #24292E"> arr</span></span>
<span class="line"><span style="color: #24292E">}</span></span>
<span class="line"><span style="color: #6A737D">// @annotate: left { &quot;arrowRot&quot;: &quot;90deg 8px 27px&quot;, &quot;textDegree&quot;: &quot;3deg&quot;, &quot;top&quot;: &quot;0rem&quot; } - Discovered a typo, the param is arr, not orr!</span></span>
<span class="line"><span style="color: #24292E">```</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br></div></div></div></div>
]]></description>
            <content:encoded><![CDATA[<h1 id="queries" tabindex="-1">Queries <a class="header-anchor" href="#queries" aria-label="Permalink to &quot;Queries&quot;">&ZeroWidthSpace;</a></h1>
<p>Sometimes the thing you want to say is about the code, annotations provide a way to provide outside commentary on your code.</p>
<h2 id="annotate-left-right-overrides-text" tabindex="-1"><code>@annotate: [left|right] [overrides] - [text]</code> <a class="header-anchor" href="#annotate-left-right-overrides-text" aria-label="Permalink to &quot;`@annotate: [left|right] [overrides] - [text]`&quot;">&ZeroWidthSpace;</a></h2>
<p>Annotate has a lot more controls than most of the other Twoslash commands, because each use of it probably needs to feel a bit different. Here's an example based on the TypeScript home page, click it to get it running so we can talk about what it does:</p>
<div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-RL7xR" id="tab-iqykz0a" checked="checked"><label for="tab-iqykz0a">output</label><input type="radio" name="group-RL7xR" id="tab-cWq2P8c" ><label for="tab-cWq2P8c">markdown</label></div><div class="blocks">
<div class="language-ts vp-adaptive-theme active line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre><code class="language-ts"><div class='tag-container'><pre class="shiki github-dark-dimmed twoslash lsp" style="background-color: #22272e; color: #adbac7"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #F47067">function</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB"><data-lsp lsp='function compact(arr: any): any' >compact</data-lsp></span><span style="color: #ADBAC7">(</span><span style="color: #F69D50"><data-lsp lsp='(parameter) arr: any' >arr</data-lsp></span><span style="color: #ADBAC7">) {</span></div><div class='line'><span style="color: #ADBAC7">    </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> (<data-err><data-lsp lsp='any' >orr</data-lsp></data-err>.</span><span style="color: #6CB6FF"><data-lsp lsp='any' >length</data-lsp></span><span style="color: #ADBAC7"> </span><span style="color: #F47067">&gt;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">10</span><span style="color: #ADBAC7">) </span><span style="color: #F47067">return</span><span style="color: #ADBAC7"> <data-lsp lsp='(parameter) arr: any' >arr</data-lsp>.</span><span style="color: #DCBDFB"><data-lsp lsp='any' >trim</data-lsp></span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">10</span><span style="color: #ADBAC7">)</span></div><span class="error"><span>Cannot find name 'orr'.</span><span class="code">2304</span></span><span class="error-behind">Cannot find name 'orr'.</span><div class='line'><span style="color: #ADBAC7">    </span><span style="color: #F47067">return</span><span style="color: #ADBAC7"> <data-lsp lsp='(parameter) arr: any' >arr</data-lsp></span></div><div class='line'><span style="color: #ADBAC7">}</span></div></code></div></pre>
<div class='twoslash-annotation left' style="top: 0rem">
  <svg style='transform: translateX(8px) translateY(27px) rotate(90deg);' width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
    <path d="M1 39C1.5 32.7511 6.1 17.5173 20.5 6.57333M11.5 4.04L27 0.999998C24.8333 4.88444 20.5 13.16 20.5 15.1867" stroke="black" />
</svg>
  <p class='twoslash-annotation-text' style="transform: rotate(3deg)">Discovered a typo, the param is arr, not orr!</p>
</div></div>
<div class='tag-container'><pre class="shiki github-light twoslash lsp" style="background-color: #fff; color: #24292e"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #D73A49">function</span><span style="color: #24292E"> </span><span style="color: #6F42C1"><data-lsp lsp='function compact(arr: any): any' >compact</data-lsp></span><span style="color: #24292E">(</span><span style="color: #E36209"><data-lsp lsp='(parameter) arr: any' >arr</data-lsp></span><span style="color: #24292E">) {</span></div><div class='line'><span style="color: #24292E">    </span><span style="color: #D73A49">if</span><span style="color: #24292E"> (<data-err><data-lsp lsp='any' >orr</data-lsp></data-err>.</span><span style="color: #005CC5"><data-lsp lsp='any' >length</data-lsp></span><span style="color: #24292E"> </span><span style="color: #D73A49">&gt;</span><span style="color: #24292E"> </span><span style="color: #005CC5">10</span><span style="color: #24292E">) </span><span style="color: #D73A49">return</span><span style="color: #24292E"> <data-lsp lsp='(parameter) arr: any' >arr</data-lsp>.</span><span style="color: #6F42C1"><data-lsp lsp='any' >trim</data-lsp></span><span style="color: #24292E">(</span><span style="color: #005CC5">0</span><span style="color: #24292E">, </span><span style="color: #005CC5">10</span><span style="color: #24292E">)</span></div><span class="error"><span>Cannot find name 'orr'.</span><span class="code">2304</span></span><span class="error-behind">Cannot find name 'orr'.</span><div class='line'><span style="color: #24292E">    </span><span style="color: #D73A49">return</span><span style="color: #24292E"> <data-lsp lsp='(parameter) arr: any' >arr</data-lsp></span></div><div class='line'><span style="color: #24292E">}</span></div></code></div></pre>
<div class='twoslash-annotation left' style="top: 0rem">
  <svg style='transform: translateX(8px) translateY(27px) rotate(90deg);' width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
    <path d="M1 39C1.5 32.7511 6.1 17.5173 20.5 6.57333M11.5 4.04L27 0.999998C24.8333 4.88444 20.5 13.16 20.5 15.1867" stroke="black" />
</svg>
  <p class='twoslash-annotation-text' style="transform: rotate(3deg)">Discovered a typo, the param is arr, not orr!</p>
</div></div></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="language-md vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">md</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">```ts twoslash</span></span>
<span class="line"><span style="color: #768390">// @errors: 2304</span></span>
<span class="line"><span style="color: #768390">// @strict: false</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F47067">function</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">compact</span><span style="color: #ADBAC7">(</span><span style="color: #F69D50">arr</span><span style="color: #ADBAC7">) {</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> (orr.</span><span style="color: #6CB6FF">length</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">&gt;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">10</span><span style="color: #ADBAC7">) </span><span style="color: #F47067">return</span><span style="color: #ADBAC7"> arr.</span><span style="color: #DCBDFB">trim</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">10</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">return</span><span style="color: #ADBAC7"> arr</span></span>
<span class="line"><span style="color: #ADBAC7">}</span></span>
<span class="line"><span style="color: #768390">// @annotate: left { &quot;arrowRot&quot;: &quot;90deg 8px 27px&quot;, &quot;textDegree&quot;: &quot;3deg&quot;, &quot;top&quot;: &quot;0rem&quot; } - Discovered a typo, the param is arr, not orr!</span></span>
<span class="line"><span style="color: #ADBAC7">```</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">```ts twoslash</span></span>
<span class="line"><span style="color: #6A737D">// @errors: 2304</span></span>
<span class="line"><span style="color: #6A737D">// @strict: false</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D73A49">function</span><span style="color: #24292E"> </span><span style="color: #6F42C1">compact</span><span style="color: #24292E">(</span><span style="color: #E36209">arr</span><span style="color: #24292E">) {</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">if</span><span style="color: #24292E"> (orr.</span><span style="color: #005CC5">length</span><span style="color: #24292E"> </span><span style="color: #D73A49">&gt;</span><span style="color: #24292E"> </span><span style="color: #005CC5">10</span><span style="color: #24292E">) </span><span style="color: #D73A49">return</span><span style="color: #24292E"> arr.</span><span style="color: #6F42C1">trim</span><span style="color: #24292E">(</span><span style="color: #005CC5">0</span><span style="color: #24292E">, </span><span style="color: #005CC5">10</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">return</span><span style="color: #24292E"> arr</span></span>
<span class="line"><span style="color: #24292E">}</span></span>
<span class="line"><span style="color: #6A737D">// @annotate: left { &quot;arrowRot&quot;: &quot;90deg 8px 27px&quot;, &quot;textDegree&quot;: &quot;3deg&quot;, &quot;top&quot;: &quot;0rem&quot; } - Discovered a typo, the param is arr, not orr!</span></span>
<span class="line"><span style="color: #24292E">```</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br></div></div></div></div>
<p>First up, cool — it adds some text to the left hand side of the code. It features quite a few different options, so lets go through them one by one:</p>
<ul>
<li>
<p><code>left</code> or <code>right</code>: It's currently <code>left</code>. It's worth noting the arrow flips also, and <code>90deg</code> isn't a great option. Let's look at that next.</p>
</li>
<li>
<p><code>{ &quot;arrrowRot&quot;: &quot;90deg 8px 27px&quot; }</code> - This JSON object is used to manipulate the annotation, you have 3 controls for arrow positioning and rotation: <code>degrees x y</code>. I recommend keeping those in degrees and px, but it's your life. These are overrides from defaults which are okay, but not really something you ever want to ship.</p>
</li>
<li>
<p><code>{ &quot;textDegree&quot;: &quot;3deg&quot; }</code> - Rotates the text, you probably want something between <code>-3deg</code> and <code>3deg</code>. Optional, defaults to <code>0</code>.</p>
</li>
<li>
<p><code>{ &quot;top&quot;: &quot;0rem&quot; }</code> - Sets the y coordinates for the annotation relative to the code sample, if it's not included then it becomes <code>[lineNum]rem</code>.</p>
</li>
</ul>
<p>What's not included in this sample is <code>flipped</code>, which can be used to flip the arrow's orientation. Here's some examples:</p>
<p>A horizontal right example:</p>
<div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-isBpX" id="tab-R9RuM2y" checked="checked"><label for="tab-R9RuM2y">output</label><input type="radio" name="group-isBpX" id="tab-M5ArioQ" ><label for="tab-M5ArioQ">markdown</label></div><div class="blocks">
<div class="language-ts vp-adaptive-theme active line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre><code class="language-ts"><div class='tag-container'><pre class="shiki github-dark-dimmed twoslash lsp" style="background-color: #22272e; color: #adbac7"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #F47067">function</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB"><data-lsp lsp='function compact(arr: any): any' >compact</data-lsp></span><span style="color: #ADBAC7">(</span><span style="color: #F69D50"><data-lsp lsp='(parameter) arr: any' >arr</data-lsp></span><span style="color: #ADBAC7">) {</span></div><div class='line'><span style="color: #ADBAC7">    </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> (<data-err><data-lsp lsp='any' >orr</data-lsp></data-err>.</span><span style="color: #6CB6FF"><data-lsp lsp='any' >length</data-lsp></span><span style="color: #ADBAC7"> </span><span style="color: #F47067">&gt;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">10</span><span style="color: #ADBAC7">) </span><span style="color: #F47067">return</span><span style="color: #ADBAC7"> <data-lsp lsp='(parameter) arr: any' >arr</data-lsp>.</span><span style="color: #DCBDFB"><data-lsp lsp='any' >trim</data-lsp></span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">10</span><span style="color: #ADBAC7">)</span></div><span class="error"><span>Cannot find name 'orr'.</span><span class="code">2304</span></span><span class="error-behind">Cannot find name 'orr'.</span><div class='line'><span style="color: #ADBAC7">    </span><span style="color: #F47067">return</span><span style="color: #ADBAC7"> <data-lsp lsp='(parameter) arr: any' >arr</data-lsp></span></div><div class='line'><span style="color: #ADBAC7">}</span></div></code></div></pre>
<div class='twoslash-annotation right' style="top: 3rem">
  <svg style='transform: translateX(-10px) translateY(-10px) rotate(-50deg);' width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
    <path d="M27 39C26.5 32.7511 21.9 17.5173 7.5 6.57333M16.5 4.04L0.999999 0.999998C3.16667 4.88444 7.5 13.16 7.5 15.1867" stroke="black" />
</svg>
  <p class='twoslash-annotation-text' style="transform: rotate(0deg)">Discovered a typo, the param is arr, not orr!</p>
</div></div>
<div class='tag-container'><pre class="shiki github-light twoslash lsp" style="background-color: #fff; color: #24292e"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #D73A49">function</span><span style="color: #24292E"> </span><span style="color: #6F42C1"><data-lsp lsp='function compact(arr: any): any' >compact</data-lsp></span><span style="color: #24292E">(</span><span style="color: #E36209"><data-lsp lsp='(parameter) arr: any' >arr</data-lsp></span><span style="color: #24292E">) {</span></div><div class='line'><span style="color: #24292E">    </span><span style="color: #D73A49">if</span><span style="color: #24292E"> (<data-err><data-lsp lsp='any' >orr</data-lsp></data-err>.</span><span style="color: #005CC5"><data-lsp lsp='any' >length</data-lsp></span><span style="color: #24292E"> </span><span style="color: #D73A49">&gt;</span><span style="color: #24292E"> </span><span style="color: #005CC5">10</span><span style="color: #24292E">) </span><span style="color: #D73A49">return</span><span style="color: #24292E"> <data-lsp lsp='(parameter) arr: any' >arr</data-lsp>.</span><span style="color: #6F42C1"><data-lsp lsp='any' >trim</data-lsp></span><span style="color: #24292E">(</span><span style="color: #005CC5">0</span><span style="color: #24292E">, </span><span style="color: #005CC5">10</span><span style="color: #24292E">)</span></div><span class="error"><span>Cannot find name 'orr'.</span><span class="code">2304</span></span><span class="error-behind">Cannot find name 'orr'.</span><div class='line'><span style="color: #24292E">    </span><span style="color: #D73A49">return</span><span style="color: #24292E"> <data-lsp lsp='(parameter) arr: any' >arr</data-lsp></span></div><div class='line'><span style="color: #24292E">}</span></div></code></div></pre>
<div class='twoslash-annotation right' style="top: 3rem">
  <svg style='transform: translateX(-10px) translateY(-10px) rotate(-50deg);' width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
    <path d="M27 39C26.5 32.7511 21.9 17.5173 7.5 6.57333M16.5 4.04L0.999999 0.999998C3.16667 4.88444 7.5 13.16 7.5 15.1867" stroke="black" />
</svg>
  <p class='twoslash-annotation-text' style="transform: rotate(0deg)">Discovered a typo, the param is arr, not orr!</p>
</div></div></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="language-md vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">md</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">```ts twoslash</span></span>
<span class="line"><span style="color: #768390">// @errors: 2304</span></span>
<span class="line"><span style="color: #768390">// @strict: false</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F47067">function</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">compact</span><span style="color: #ADBAC7">(</span><span style="color: #F69D50">arr</span><span style="color: #ADBAC7">) {</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> (orr.</span><span style="color: #6CB6FF">length</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">&gt;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">10</span><span style="color: #ADBAC7">) </span><span style="color: #F47067">return</span><span style="color: #ADBAC7"> arr.</span><span style="color: #DCBDFB">trim</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">10</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">return</span><span style="color: #ADBAC7"> arr</span></span>
<span class="line"><span style="color: #ADBAC7">}</span></span>
<span class="line"><span style="color: #768390">// @annotate: left { &quot;arrowRot&quot;: &quot;90deg 8px 27px&quot;, &quot;textDegree&quot;: &quot;3deg&quot;, &quot;top&quot;: &quot;0rem&quot; } - Discovered a typo, the param is arr, not orr!</span></span>
<span class="line"><span style="color: #ADBAC7">```</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">```ts twoslash</span></span>
<span class="line"><span style="color: #6A737D">// @errors: 2304</span></span>
<span class="line"><span style="color: #6A737D">// @strict: false</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D73A49">function</span><span style="color: #24292E"> </span><span style="color: #6F42C1">compact</span><span style="color: #24292E">(</span><span style="color: #E36209">arr</span><span style="color: #24292E">) {</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">if</span><span style="color: #24292E"> (orr.</span><span style="color: #005CC5">length</span><span style="color: #24292E"> </span><span style="color: #D73A49">&gt;</span><span style="color: #24292E"> </span><span style="color: #005CC5">10</span><span style="color: #24292E">) </span><span style="color: #D73A49">return</span><span style="color: #24292E"> arr.</span><span style="color: #6F42C1">trim</span><span style="color: #24292E">(</span><span style="color: #005CC5">0</span><span style="color: #24292E">, </span><span style="color: #005CC5">10</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">return</span><span style="color: #24292E"> arr</span></span>
<span class="line"><span style="color: #24292E">}</span></span>
<span class="line"><span style="color: #6A737D">// @annotate: left { &quot;arrowRot&quot;: &quot;90deg 8px 27px&quot;, &quot;textDegree&quot;: &quot;3deg&quot;, &quot;top&quot;: &quot;0rem&quot; } - Discovered a typo, the param is arr, not orr!</span></span>
<span class="line"><span style="color: #24292E">```</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br></div></div></div></div>
<p>Upside down arrow pointing at the error, using flipped to re-flip the arrow:</p>
<div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-UxMM0" id="tab-JNUm7H0" checked="checked"><label for="tab-JNUm7H0">output</label><input type="radio" name="group-UxMM0" id="tab-kJghORW" ><label for="tab-kJghORW">markdown</label></div><div class="blocks">
<div class="language-ts vp-adaptive-theme active line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre><code class="language-ts"><div class='tag-container'><pre class="shiki github-dark-dimmed twoslash lsp" style="background-color: #22272e; color: #adbac7"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #F47067">function</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB"><data-lsp lsp='function compact(arr: any): any' >compact</data-lsp></span><span style="color: #ADBAC7">(</span><span style="color: #F69D50"><data-lsp lsp='(parameter) arr: any' >arr</data-lsp></span><span style="color: #ADBAC7">) {</span></div><div class='line'><span style="color: #ADBAC7">    </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> (<data-err><data-lsp lsp='any' >orr</data-lsp></data-err>.</span><span style="color: #6CB6FF"><data-lsp lsp='any' >length</data-lsp></span><span style="color: #ADBAC7"> </span><span style="color: #F47067">&gt;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">10</span><span style="color: #ADBAC7">) </span><span style="color: #F47067">return</span><span style="color: #ADBAC7"> <data-lsp lsp='(parameter) arr: any' >arr</data-lsp>.</span><span style="color: #DCBDFB"><data-lsp lsp='any' >trim</data-lsp></span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">10</span><span style="color: #ADBAC7">)</span></div><span class="error"><span>Cannot find name 'orr'.</span><span class="code">2304</span></span><span class="error-behind">Cannot find name 'orr'.</span><div class='line'><span style="color: #ADBAC7">    </span><span style="color: #F47067">return</span><span style="color: #ADBAC7"> <data-lsp lsp='(parameter) arr: any' >arr</data-lsp></span></div><div class='line'><span style="color: #ADBAC7">}</span></div></code></div></pre>
<div class='twoslash-annotation right' style="top: -0.7rem">
  <svg style='transform: translateX(8px) translateY(46px) rotate(190deg);' width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
    <path d="M1 39C1.5 32.7511 6.1 17.5173 20.5 6.57333M11.5 4.04L27 0.999998C24.8333 4.88444 20.5 13.16 20.5 15.1867" stroke="black" />
</svg>
  <p class='twoslash-annotation-text' style="transform: rotate(-3deg)">Discovered a typo, the param is arr, not orr!</p>
</div></div>
<div class='tag-container'><pre class="shiki github-light twoslash lsp" style="background-color: #fff; color: #24292e"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #D73A49">function</span><span style="color: #24292E"> </span><span style="color: #6F42C1"><data-lsp lsp='function compact(arr: any): any' >compact</data-lsp></span><span style="color: #24292E">(</span><span style="color: #E36209"><data-lsp lsp='(parameter) arr: any' >arr</data-lsp></span><span style="color: #24292E">) {</span></div><div class='line'><span style="color: #24292E">    </span><span style="color: #D73A49">if</span><span style="color: #24292E"> (<data-err><data-lsp lsp='any' >orr</data-lsp></data-err>.</span><span style="color: #005CC5"><data-lsp lsp='any' >length</data-lsp></span><span style="color: #24292E"> </span><span style="color: #D73A49">&gt;</span><span style="color: #24292E"> </span><span style="color: #005CC5">10</span><span style="color: #24292E">) </span><span style="color: #D73A49">return</span><span style="color: #24292E"> <data-lsp lsp='(parameter) arr: any' >arr</data-lsp>.</span><span style="color: #6F42C1"><data-lsp lsp='any' >trim</data-lsp></span><span style="color: #24292E">(</span><span style="color: #005CC5">0</span><span style="color: #24292E">, </span><span style="color: #005CC5">10</span><span style="color: #24292E">)</span></div><span class="error"><span>Cannot find name 'orr'.</span><span class="code">2304</span></span><span class="error-behind">Cannot find name 'orr'.</span><div class='line'><span style="color: #24292E">    </span><span style="color: #D73A49">return</span><span style="color: #24292E"> <data-lsp lsp='(parameter) arr: any' >arr</data-lsp></span></div><div class='line'><span style="color: #24292E">}</span></div></code></div></pre>
<div class='twoslash-annotation right' style="top: -0.7rem">
  <svg style='transform: translateX(8px) translateY(46px) rotate(190deg);' width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
    <path d="M1 39C1.5 32.7511 6.1 17.5173 20.5 6.57333M11.5 4.04L27 0.999998C24.8333 4.88444 20.5 13.16 20.5 15.1867" stroke="black" />
</svg>
  <p class='twoslash-annotation-text' style="transform: rotate(-3deg)">Discovered a typo, the param is arr, not orr!</p>
</div></div></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="language-md vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">md</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">```ts twoslash</span></span>
<span class="line"><span style="color: #768390">// @errors: 2304</span></span>
<span class="line"><span style="color: #768390">// @strict: false</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F47067">function</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">compact</span><span style="color: #ADBAC7">(</span><span style="color: #F69D50">arr</span><span style="color: #ADBAC7">) {</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> (orr.</span><span style="color: #6CB6FF">length</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">&gt;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">10</span><span style="color: #ADBAC7">) </span><span style="color: #F47067">return</span><span style="color: #ADBAC7"> arr.</span><span style="color: #DCBDFB">trim</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">10</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">return</span><span style="color: #ADBAC7"> arr</span></span>
<span class="line"><span style="color: #ADBAC7">}</span></span>
<span class="line"><span style="color: #768390">// @annotate: left { &quot;arrowRot&quot;: &quot;90deg 8px 27px&quot;, &quot;textDegree&quot;: &quot;3deg&quot;, &quot;top&quot;: &quot;0rem&quot; } - Discovered a typo, the param is arr, not orr!</span></span>
<span class="line"><span style="color: #ADBAC7">```</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">```ts twoslash</span></span>
<span class="line"><span style="color: #6A737D">// @errors: 2304</span></span>
<span class="line"><span style="color: #6A737D">// @strict: false</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D73A49">function</span><span style="color: #24292E"> </span><span style="color: #6F42C1">compact</span><span style="color: #24292E">(</span><span style="color: #E36209">arr</span><span style="color: #24292E">) {</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">if</span><span style="color: #24292E"> (orr.</span><span style="color: #005CC5">length</span><span style="color: #24292E"> </span><span style="color: #D73A49">&gt;</span><span style="color: #24292E"> </span><span style="color: #005CC5">10</span><span style="color: #24292E">) </span><span style="color: #D73A49">return</span><span style="color: #24292E"> arr.</span><span style="color: #6F42C1">trim</span><span style="color: #24292E">(</span><span style="color: #005CC5">0</span><span style="color: #24292E">, </span><span style="color: #005CC5">10</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">return</span><span style="color: #24292E"> arr</span></span>
<span class="line"><span style="color: #24292E">}</span></span>
<span class="line"><span style="color: #6A737D">// @annotate: left { &quot;arrowRot&quot;: &quot;90deg 8px 27px&quot;, &quot;textDegree&quot;: &quot;3deg&quot;, &quot;top&quot;: &quot;0rem&quot; } - Discovered a typo, the param is arr, not orr!</span></span>
<span class="line"><span style="color: #24292E">```</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br></div></div></div></div>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cutting]]></title>
            <link>https://note.toshiki.devapplication/vitepress-plugin-shiki-twoslash/api/cutting</link>
            <guid>https://note.toshiki.devapplication/vitepress-plugin-shiki-twoslash/api/cutting</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="cutting" tabindex="-1">Cutting <a class="header-anchor" href="#cutting" aria-label="Permalink to &quot;Cutting&quot;">&ZeroWidthSpace;</a></h1>
<p>Every Twoslash code example needs to be a complete TypeScript program so it can compile. Quite often to make it compile, there is a bunch of code which isn't relevant to the user. This can be extracted out of the code examples via cut comments.</p>
<h2 id="cut" tabindex="-1"><code>---cut---</code> <a class="header-anchor" href="#cut" aria-label="Permalink to &quot;`---cut---`&quot;">&ZeroWidthSpace;</a></h2>
<p>Cut works after TypeScript has generated the project and pulled out all the editor information (like identifiers, queries, highlights etc) and then amends all of their offsets and lines to re-fit the smaller output. What your user sees is everything below the <code>---cut---</code>.</p>
<div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-2G1oi" id="tab-rm8CM2O" checked="checked"><label for="tab-rm8CM2O">output</label><input type="radio" name="group-2G1oi" id="tab-UaT22DZ" ><label for="tab-UaT22DZ">markdown</label></div><div class="blocks">
<div class="language-ts vp-adaptive-theme active line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki github-dark-dimmed twoslash lsp" style="background-color: #22272e; color: #adbac7"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #ADBAC7"><data-lsp lsp='var console: Console' >console</data-lsp>.</span><span style="color: #DCBDFB"><data-lsp lsp='(method) Console.log(...data: any[]): void' >log</data-lsp></span><span style="color: #ADBAC7">(<data-lsp lsp='const level: string' >level</data-lsp>)</span></div></code></div></pre>
<pre class="shiki github-light twoslash lsp" style="background-color: #fff; color: #24292e"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #24292E"><data-lsp lsp='var console: Console' >console</data-lsp>.</span><span style="color: #6F42C1"><data-lsp lsp='(method) Console.log(...data: any[]): void' >log</data-lsp></span><span style="color: #24292E">(<data-lsp lsp='const level: string' >level</data-lsp>)</span></div></code></div></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="language-md vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">md</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">```ts twoslash</span></span>
<span class="line"><span style="color: #F47067">const</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">level</span><span style="color: #F47067">:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">string</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;Danger&#39;</span></span>
<span class="line"><span style="color: #768390">// ---cut---</span></span>
<span class="line"><span style="color: #ADBAC7">console.</span><span style="color: #DCBDFB">log</span><span style="color: #ADBAC7">(level)</span></span>
<span class="line"><span style="color: #ADBAC7">```</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">```ts twoslash</span></span>
<span class="line"><span style="color: #D73A49">const</span><span style="color: #24292E"> </span><span style="color: #005CC5">level</span><span style="color: #D73A49">:</span><span style="color: #24292E"> </span><span style="color: #005CC5">string</span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;Danger&#39;</span></span>
<span class="line"><span style="color: #6A737D">// ---cut---</span></span>
<span class="line"><span style="color: #24292E">console.</span><span style="color: #6F42C1">log</span><span style="color: #24292E">(level)</span></span>
<span class="line"><span style="color: #24292E">```</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br></div></div></div></div>
<p>Cutting even works across <a href="./multi-file.html">multiple files</a>. This is why <code>// @filename: [file]</code> is specifically the only Twoslash command which is not removed, because if it's not relevant it can be <code>---cut---</code> away.</p>
<div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-lcJy7" id="tab-GJUM2Je" checked="checked"><label for="tab-GJUM2Je">output</label><input type="radio" name="group-lcJy7" id="tab-LvNF6M-" ><label for="tab-LvNF6M-">markdown</label></div><div class="blocks">
<div class="language-ts vp-adaptive-theme active line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki github-dark-dimmed twoslash lsp" style="background-color: #22272e; color: #adbac7"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #F47067">import</span><span style="color: #ADBAC7"> { <data-lsp lsp='(alias) const helloWorld: string&#10;import helloWorld' >helloWorld</data-lsp> } </span><span style="color: #F47067">from</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&apos;./a&apos;</span></div><div class='line'><span style="color: #ADBAC7"><data-lsp lsp='var console: Console' >console</data-lsp>.</span><span style="color: #DCBDFB"><data-lsp lsp='(method) Console.log(...data: any[]): void' >log</data-lsp></span><span style="color: #ADBAC7">(<data-lsp lsp='(alias) const helloWorld: string&#10;import helloWorld' >helloWorld</data-lsp>)</span></div></code></div></pre>
<pre class="shiki github-light twoslash lsp" style="background-color: #fff; color: #24292e"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #D73A49">import</span><span style="color: #24292E"> { <data-lsp lsp='(alias) const helloWorld: string&#10;import helloWorld' >helloWorld</data-lsp> } </span><span style="color: #D73A49">from</span><span style="color: #24292E"> </span><span style="color: #032F62">&apos;./a&apos;</span></div><div class='line'><span style="color: #24292E"><data-lsp lsp='var console: Console' >console</data-lsp>.</span><span style="color: #6F42C1"><data-lsp lsp='(method) Console.log(...data: any[]): void' >log</data-lsp></span><span style="color: #24292E">(<data-lsp lsp='(alias) const helloWorld: string&#10;import helloWorld' >helloWorld</data-lsp>)</span></div></code></div></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="language-md vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">md</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">```ts twoslash</span></span>
<span class="line"><span style="color: #768390">// @filename: a.ts</span></span>
<span class="line"><span style="color: #F47067">export</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">const</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">helloWorld</span><span style="color: #F47067">:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">string</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;Hi&#39;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390">// @filename: b.ts</span></span>
<span class="line"><span style="color: #768390">// ---cut---</span></span>
<span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> { helloWorld } </span><span style="color: #F47067">from</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;./a&#39;</span></span>
<span class="line"><span style="color: #ADBAC7">console.</span><span style="color: #DCBDFB">log</span><span style="color: #ADBAC7">(helloWorld)</span></span>
<span class="line"><span style="color: #ADBAC7">```</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">```ts twoslash</span></span>
<span class="line"><span style="color: #6A737D">// @filename: a.ts</span></span>
<span class="line"><span style="color: #D73A49">export</span><span style="color: #24292E"> </span><span style="color: #D73A49">const</span><span style="color: #24292E"> </span><span style="color: #005CC5">helloWorld</span><span style="color: #D73A49">:</span><span style="color: #24292E"> </span><span style="color: #005CC5">string</span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;Hi&#39;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D">// @filename: b.ts</span></span>
<span class="line"><span style="color: #6A737D">// ---cut---</span></span>
<span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> { helloWorld } </span><span style="color: #D73A49">from</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;./a&#39;</span></span>
<span class="line"><span style="color: #24292E">console.</span><span style="color: #6F42C1">log</span><span style="color: #24292E">(helloWorld)</span></span>
<span class="line"><span style="color: #24292E">```</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br></div></div></div></div>
<h2 id="cut-after" tabindex="-1"><code>---cut-after---</code> <a class="header-anchor" href="#cut-after" aria-label="Permalink to &quot;`---cut-after---`&quot;">&ZeroWidthSpace;</a></h2>
<p>The sibling to <code>---cut---</code>, which trims anything after the sigil:</p>
<div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-aAVRu" id="tab-0XZDbZx" checked="checked"><label for="tab-0XZDbZx">output</label><input type="radio" name="group-aAVRu" id="tab-IEg0dPl" ><label for="tab-IEg0dPl">markdown</label></div><div class="blocks">
<div class="language-tsx vp-adaptive-theme active line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">tsx</span><pre class="shiki github-dark-dimmed twoslash lsp" style="background-color: #22272e; color: #adbac7"><div class="language-id">tsx</div><div class='code-container'><code><div class='line'><span style="color: #ADBAC7">    &lt;</span><span style="color: #8DDB8C"><data-lsp lsp='any' >Container</data-lsp></span><span style="color: #ADBAC7">&gt;</span></div><div class='line'><span style="color: #ADBAC7">        &lt;</span><span style="color: #8DDB8C"><data-lsp lsp='any' >ImportantComponent</data-lsp></span><span style="color: #ADBAC7"> /&gt;</span></div><div class='line'><span style="color: #ADBAC7">    &lt;/</span><span style="color: #8DDB8C"><data-lsp lsp='any' >Container</data-lsp></span><span style="color: #ADBAC7">&gt;</span></div></code></div></pre>
<pre class="shiki github-light twoslash lsp" style="background-color: #fff; color: #24292e"><div class="language-id">tsx</div><div class='code-container'><code><div class='line'><span style="color: #24292E">    &lt;</span><span style="color: #005CC5"><data-lsp lsp='any' >Container</data-lsp></span><span style="color: #24292E">&gt;</span></div><div class='line'><span style="color: #24292E">        &lt;</span><span style="color: #005CC5"><data-lsp lsp='any' >ImportantComponent</data-lsp></span><span style="color: #24292E"> /&gt;</span></div><div class='line'><span style="color: #24292E">    &lt;/</span><span style="color: #005CC5"><data-lsp lsp='any' >Container</data-lsp></span><span style="color: #24292E">&gt;</span></div></code></div></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="language-md vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">md</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">```tsx twoslash</span></span>
<span class="line"><span style="color: #F47067">const</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">Page</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> () </span><span style="color: #F47067">=&gt;</span><span style="color: #ADBAC7"> (</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #768390">// ---cut---</span></span>
<span class="line"><span style="color: #ADBAC7">    &lt;</span><span style="color: #8DDB8C">Container</span><span style="color: #ADBAC7">&gt;</span></span>
<span class="line"><span style="color: #ADBAC7">        &lt;</span><span style="color: #8DDB8C">ImportantComponent</span><span style="color: #ADBAC7"> /&gt;</span></span>
<span class="line"><span style="color: #ADBAC7">    &lt;/</span><span style="color: #8DDB8C">Container</span><span style="color: #ADBAC7">&gt;</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #768390">// ---cut-after---</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">```</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">```tsx twoslash</span></span>
<span class="line"><span style="color: #D73A49">const</span><span style="color: #24292E"> </span><span style="color: #6F42C1">Page</span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> () </span><span style="color: #D73A49">=&gt;</span><span style="color: #24292E"> (</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #6A737D">// ---cut---</span></span>
<span class="line"><span style="color: #24292E">    &lt;</span><span style="color: #005CC5">Container</span><span style="color: #24292E">&gt;</span></span>
<span class="line"><span style="color: #24292E">        &lt;</span><span style="color: #005CC5">ImportantComponent</span><span style="color: #24292E"> /&gt;</span></span>
<span class="line"><span style="color: #24292E">    &lt;/</span><span style="color: #005CC5">Container</span><span style="color: #24292E">&gt;</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #6A737D">// ---cut-after---</span></span>
<span class="line"><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">```</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br></div></div></div></div>
]]></description>
            <content:encoded><![CDATA[<h1 id="cutting" tabindex="-1">Cutting <a class="header-anchor" href="#cutting" aria-label="Permalink to &quot;Cutting&quot;">&ZeroWidthSpace;</a></h1>
<p>Every Twoslash code example needs to be a complete TypeScript program so it can compile. Quite often to make it compile, there is a bunch of code which isn't relevant to the user. This can be extracted out of the code examples via cut comments.</p>
<h2 id="cut" tabindex="-1"><code>---cut---</code> <a class="header-anchor" href="#cut" aria-label="Permalink to &quot;`---cut---`&quot;">&ZeroWidthSpace;</a></h2>
<p>Cut works after TypeScript has generated the project and pulled out all the editor information (like identifiers, queries, highlights etc) and then amends all of their offsets and lines to re-fit the smaller output. What your user sees is everything below the <code>---cut---</code>.</p>
<div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-2G1oi" id="tab-rm8CM2O" checked="checked"><label for="tab-rm8CM2O">output</label><input type="radio" name="group-2G1oi" id="tab-UaT22DZ" ><label for="tab-UaT22DZ">markdown</label></div><div class="blocks">
<div class="language-ts vp-adaptive-theme active line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki github-dark-dimmed twoslash lsp" style="background-color: #22272e; color: #adbac7"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #ADBAC7"><data-lsp lsp='var console: Console' >console</data-lsp>.</span><span style="color: #DCBDFB"><data-lsp lsp='(method) Console.log(...data: any[]): void' >log</data-lsp></span><span style="color: #ADBAC7">(<data-lsp lsp='const level: string' >level</data-lsp>)</span></div></code></div></pre>
<pre class="shiki github-light twoslash lsp" style="background-color: #fff; color: #24292e"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #24292E"><data-lsp lsp='var console: Console' >console</data-lsp>.</span><span style="color: #6F42C1"><data-lsp lsp='(method) Console.log(...data: any[]): void' >log</data-lsp></span><span style="color: #24292E">(<data-lsp lsp='const level: string' >level</data-lsp>)</span></div></code></div></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="language-md vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">md</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">```ts twoslash</span></span>
<span class="line"><span style="color: #F47067">const</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">level</span><span style="color: #F47067">:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">string</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;Danger&#39;</span></span>
<span class="line"><span style="color: #768390">// ---cut---</span></span>
<span class="line"><span style="color: #ADBAC7">console.</span><span style="color: #DCBDFB">log</span><span style="color: #ADBAC7">(level)</span></span>
<span class="line"><span style="color: #ADBAC7">```</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">```ts twoslash</span></span>
<span class="line"><span style="color: #D73A49">const</span><span style="color: #24292E"> </span><span style="color: #005CC5">level</span><span style="color: #D73A49">:</span><span style="color: #24292E"> </span><span style="color: #005CC5">string</span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;Danger&#39;</span></span>
<span class="line"><span style="color: #6A737D">// ---cut---</span></span>
<span class="line"><span style="color: #24292E">console.</span><span style="color: #6F42C1">log</span><span style="color: #24292E">(level)</span></span>
<span class="line"><span style="color: #24292E">```</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br></div></div></div></div>
<p>Cutting even works across <a href="./multi-file.html">multiple files</a>. This is why <code>// @filename: [file]</code> is specifically the only Twoslash command which is not removed, because if it's not relevant it can be <code>---cut---</code> away.</p>
<div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-lcJy7" id="tab-GJUM2Je" checked="checked"><label for="tab-GJUM2Je">output</label><input type="radio" name="group-lcJy7" id="tab-LvNF6M-" ><label for="tab-LvNF6M-">markdown</label></div><div class="blocks">
<div class="language-ts vp-adaptive-theme active line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki github-dark-dimmed twoslash lsp" style="background-color: #22272e; color: #adbac7"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #F47067">import</span><span style="color: #ADBAC7"> { <data-lsp lsp='(alias) const helloWorld: string&#10;import helloWorld' >helloWorld</data-lsp> } </span><span style="color: #F47067">from</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&apos;./a&apos;</span></div><div class='line'><span style="color: #ADBAC7"><data-lsp lsp='var console: Console' >console</data-lsp>.</span><span style="color: #DCBDFB"><data-lsp lsp='(method) Console.log(...data: any[]): void' >log</data-lsp></span><span style="color: #ADBAC7">(<data-lsp lsp='(alias) const helloWorld: string&#10;import helloWorld' >helloWorld</data-lsp>)</span></div></code></div></pre>
<pre class="shiki github-light twoslash lsp" style="background-color: #fff; color: #24292e"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #D73A49">import</span><span style="color: #24292E"> { <data-lsp lsp='(alias) const helloWorld: string&#10;import helloWorld' >helloWorld</data-lsp> } </span><span style="color: #D73A49">from</span><span style="color: #24292E"> </span><span style="color: #032F62">&apos;./a&apos;</span></div><div class='line'><span style="color: #24292E"><data-lsp lsp='var console: Console' >console</data-lsp>.</span><span style="color: #6F42C1"><data-lsp lsp='(method) Console.log(...data: any[]): void' >log</data-lsp></span><span style="color: #24292E">(<data-lsp lsp='(alias) const helloWorld: string&#10;import helloWorld' >helloWorld</data-lsp>)</span></div></code></div></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="language-md vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">md</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">```ts twoslash</span></span>
<span class="line"><span style="color: #768390">// @filename: a.ts</span></span>
<span class="line"><span style="color: #F47067">export</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">const</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">helloWorld</span><span style="color: #F47067">:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">string</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;Hi&#39;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390">// @filename: b.ts</span></span>
<span class="line"><span style="color: #768390">// ---cut---</span></span>
<span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> { helloWorld } </span><span style="color: #F47067">from</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;./a&#39;</span></span>
<span class="line"><span style="color: #ADBAC7">console.</span><span style="color: #DCBDFB">log</span><span style="color: #ADBAC7">(helloWorld)</span></span>
<span class="line"><span style="color: #ADBAC7">```</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">```ts twoslash</span></span>
<span class="line"><span style="color: #6A737D">// @filename: a.ts</span></span>
<span class="line"><span style="color: #D73A49">export</span><span style="color: #24292E"> </span><span style="color: #D73A49">const</span><span style="color: #24292E"> </span><span style="color: #005CC5">helloWorld</span><span style="color: #D73A49">:</span><span style="color: #24292E"> </span><span style="color: #005CC5">string</span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;Hi&#39;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D">// @filename: b.ts</span></span>
<span class="line"><span style="color: #6A737D">// ---cut---</span></span>
<span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> { helloWorld } </span><span style="color: #D73A49">from</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;./a&#39;</span></span>
<span class="line"><span style="color: #24292E">console.</span><span style="color: #6F42C1">log</span><span style="color: #24292E">(helloWorld)</span></span>
<span class="line"><span style="color: #24292E">```</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br></div></div></div></div>
<h2 id="cut-after" tabindex="-1"><code>---cut-after---</code> <a class="header-anchor" href="#cut-after" aria-label="Permalink to &quot;`---cut-after---`&quot;">&ZeroWidthSpace;</a></h2>
<p>The sibling to <code>---cut---</code>, which trims anything after the sigil:</p>
<div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-aAVRu" id="tab-0XZDbZx" checked="checked"><label for="tab-0XZDbZx">output</label><input type="radio" name="group-aAVRu" id="tab-IEg0dPl" ><label for="tab-IEg0dPl">markdown</label></div><div class="blocks">
<div class="language-tsx vp-adaptive-theme active line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">tsx</span><pre class="shiki github-dark-dimmed twoslash lsp" style="background-color: #22272e; color: #adbac7"><div class="language-id">tsx</div><div class='code-container'><code><div class='line'><span style="color: #ADBAC7">    &lt;</span><span style="color: #8DDB8C"><data-lsp lsp='any' >Container</data-lsp></span><span style="color: #ADBAC7">&gt;</span></div><div class='line'><span style="color: #ADBAC7">        &lt;</span><span style="color: #8DDB8C"><data-lsp lsp='any' >ImportantComponent</data-lsp></span><span style="color: #ADBAC7"> /&gt;</span></div><div class='line'><span style="color: #ADBAC7">    &lt;/</span><span style="color: #8DDB8C"><data-lsp lsp='any' >Container</data-lsp></span><span style="color: #ADBAC7">&gt;</span></div></code></div></pre>
<pre class="shiki github-light twoslash lsp" style="background-color: #fff; color: #24292e"><div class="language-id">tsx</div><div class='code-container'><code><div class='line'><span style="color: #24292E">    &lt;</span><span style="color: #005CC5"><data-lsp lsp='any' >Container</data-lsp></span><span style="color: #24292E">&gt;</span></div><div class='line'><span style="color: #24292E">        &lt;</span><span style="color: #005CC5"><data-lsp lsp='any' >ImportantComponent</data-lsp></span><span style="color: #24292E"> /&gt;</span></div><div class='line'><span style="color: #24292E">    &lt;/</span><span style="color: #005CC5"><data-lsp lsp='any' >Container</data-lsp></span><span style="color: #24292E">&gt;</span></div></code></div></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="language-md vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">md</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">```tsx twoslash</span></span>
<span class="line"><span style="color: #F47067">const</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">Page</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> () </span><span style="color: #F47067">=&gt;</span><span style="color: #ADBAC7"> (</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #768390">// ---cut---</span></span>
<span class="line"><span style="color: #ADBAC7">    &lt;</span><span style="color: #8DDB8C">Container</span><span style="color: #ADBAC7">&gt;</span></span>
<span class="line"><span style="color: #ADBAC7">        &lt;</span><span style="color: #8DDB8C">ImportantComponent</span><span style="color: #ADBAC7"> /&gt;</span></span>
<span class="line"><span style="color: #ADBAC7">    &lt;/</span><span style="color: #8DDB8C">Container</span><span style="color: #ADBAC7">&gt;</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #768390">// ---cut-after---</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">```</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">```tsx twoslash</span></span>
<span class="line"><span style="color: #D73A49">const</span><span style="color: #24292E"> </span><span style="color: #6F42C1">Page</span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> () </span><span style="color: #D73A49">=&gt;</span><span style="color: #24292E"> (</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #6A737D">// ---cut---</span></span>
<span class="line"><span style="color: #24292E">    &lt;</span><span style="color: #005CC5">Container</span><span style="color: #24292E">&gt;</span></span>
<span class="line"><span style="color: #24292E">        &lt;</span><span style="color: #005CC5">ImportantComponent</span><span style="color: #24292E"> /&gt;</span></span>
<span class="line"><span style="color: #24292E">    &lt;/</span><span style="color: #005CC5">Container</span><span style="color: #24292E">&gt;</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #6A737D">// ---cut-after---</span></span>
<span class="line"><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">```</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br></div></div></div></div>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Emit]]></title>
            <link>https://note.toshiki.devapplication/vitepress-plugin-shiki-twoslash/api/emit</link>
            <guid>https://note.toshiki.devapplication/vitepress-plugin-shiki-twoslash/api/emit</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="emit" tabindex="-1">Emit <a class="header-anchor" href="#emit" aria-label="Permalink to &quot;Emit&quot;">&ZeroWidthSpace;</a></h1>
<p>Running a Twoslash code example is a full TypeScript compiler run that will create files inside the virtual file system. You can replace the contents of your code examples with the results of running TypeScript over the project.</p>
<h2 id="showemit" tabindex="-1"><code>@showEmit</code> <a class="header-anchor" href="#showemit" aria-label="Permalink to &quot;`@showEmit`&quot;">&ZeroWidthSpace;</a></h2>
<p><code>// @showEmit</code> is the main command to tell Shiki Twoslash that you want to replace the output of your code example with the equivalent <code>.js</code> file.</p>
<div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-8CKtV" id="tab-GOeMGMx" checked="checked"><label for="tab-GOeMGMx">output</label><input type="radio" name="group-8CKtV" id="tab-nE2Fmxg" ><label for="tab-nE2Fmxg">markdown</label></div><div class="blocks">
<div class="language-ts vp-adaptive-theme active line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki github-dark-dimmed twoslash lsp" style="background-color: #22272e; color: #adbac7"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #96D0FF">"use strict"</span><span style="color: #ADBAC7">;</span></div><div class='line'><span style="color: #F47067">const</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">level</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&apos;Danger&apos;</span><span style="color: #ADBAC7">;</span></div><div class='line'>&nbsp;</div></code></div></pre>
<pre class="shiki github-light twoslash lsp" style="background-color: #fff; color: #24292e"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #032F62">"use strict"</span><span style="color: #24292E">;</span></div><div class='line'><span style="color: #D73A49">const</span><span style="color: #24292E"> </span><span style="color: #005CC5">level</span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #032F62">&apos;Danger&apos;</span><span style="color: #24292E">;</span></div><div class='line'>&nbsp;</div></code></div></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="language-md vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">md</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">```ts twoslash</span></span>
<span class="line"><span style="color: #768390">// @showEmit</span></span>
<span class="line"><span style="color: #F47067">const</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">level</span><span style="color: #F47067">:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">string</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;Danger&#39;</span></span>
<span class="line"><span style="color: #ADBAC7">```</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">```ts twoslash</span></span>
<span class="line"><span style="color: #6A737D">// @showEmit</span></span>
<span class="line"><span style="color: #D73A49">const</span><span style="color: #24292E"> </span><span style="color: #005CC5">level</span><span style="color: #D73A49">:</span><span style="color: #24292E"> </span><span style="color: #005CC5">string</span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;Danger&#39;</span></span>
<span class="line"><span style="color: #24292E">```</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br></div></div></div></div>
<h2 id="showemittedfile-file" tabindex="-1"><code>@showEmittedFile: [file]</code> <a class="header-anchor" href="#showemittedfile-file" aria-label="Permalink to &quot;`@showEmittedFile: [file]`&quot;">&ZeroWidthSpace;</a></h2>
<p>While the <code>.js</code> file is probably the most useful file out of the box, TypeScript does emit other files if you have the right flags enabled (<code>.d.ts</code> and <code>.map</code>) but also when you have a multi-file code sample — you might need to tell Twoslash which file to show. For all these cases you can also add <code>@showEmittedFile: [file]</code> to tell Twoslash which file you want to show.</p>
<p>Shows emitted <code>.d.ts</code> for a TypeScript code example:</p>
<div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group--Ls8T" id="tab-LIKPGzw" checked="checked"><label for="tab-LIKPGzw">markdown</label><input type="radio" name="group--Ls8T" id="tab-q2evYMA" ><label for="tab-q2evYMA">output</label></div><div class="blocks">
<div class="language-md vp-adaptive-theme active line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">md</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">```ts twoslash</span></span>
<span class="line"><span style="color: #768390">// @declaration</span></span>
<span class="line"><span style="color: #768390">// @showEmit</span></span>
<span class="line"><span style="color: #768390">// @showEmittedFile: index.d.ts</span></span>
<span class="line"><span style="color: #F47067">export</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">const</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">hello</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;world&#39;</span></span>
<span class="line"><span style="color: #ADBAC7">```</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">```ts twoslash</span></span>
<span class="line"><span style="color: #6A737D">// @declaration</span></span>
<span class="line"><span style="color: #6A737D">// @showEmit</span></span>
<span class="line"><span style="color: #6A737D">// @showEmittedFile: index.d.ts</span></span>
<span class="line"><span style="color: #D73A49">export</span><span style="color: #24292E"> </span><span style="color: #D73A49">const</span><span style="color: #24292E"> </span><span style="color: #005CC5">hello</span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;world&#39;</span></span>
<span class="line"><span style="color: #24292E">```</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br></div></div><div class="language-ts vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki github-dark-dimmed twoslash lsp" style="background-color: #22272e; color: #adbac7"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #F47067">export</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">declare</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">const</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">hello</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">"world"</span><span style="color: #ADBAC7">;</span></div><div class='line'>&nbsp;</div></code></div></pre>
<pre class="shiki github-light twoslash lsp" style="background-color: #fff; color: #24292e"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #D73A49">export</span><span style="color: #24292E"> </span><span style="color: #D73A49">declare</span><span style="color: #24292E"> </span><span style="color: #D73A49">const</span><span style="color: #24292E"> </span><span style="color: #005CC5">hello</span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #032F62">"world"</span><span style="color: #24292E">;</span></div><div class='line'>&nbsp;</div></code></div></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div></div></div>
<p>Shows emitted <code>.map</code> files:</p>
<div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-aGTqY" id="tab-3k7OYrB" checked="checked"><label for="tab-3k7OYrB">markdown</label><input type="radio" name="group-aGTqY" id="tab-mXISwtW" ><label for="tab-mXISwtW">output</label></div><div class="blocks">
<div class="language-md vp-adaptive-theme active line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">md</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">```ts twoslash</span></span>
<span class="line"><span style="color: #768390">// @sourceMap</span></span>
<span class="line"><span style="color: #768390">// @showEmit</span></span>
<span class="line"><span style="color: #768390">// @showEmittedFile: index.js.map</span></span>
<span class="line"><span style="color: #F47067">export</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">const</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">hello</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;world&#39;</span></span>
<span class="line"><span style="color: #ADBAC7">```</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">```ts twoslash</span></span>
<span class="line"><span style="color: #6A737D">// @sourceMap</span></span>
<span class="line"><span style="color: #6A737D">// @showEmit</span></span>
<span class="line"><span style="color: #6A737D">// @showEmittedFile: index.js.map</span></span>
<span class="line"><span style="color: #D73A49">export</span><span style="color: #24292E"> </span><span style="color: #D73A49">const</span><span style="color: #24292E"> </span><span style="color: #005CC5">hello</span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;world&#39;</span></span>
<span class="line"><span style="color: #24292E">```</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br></div></div><div class="language-ts vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki github-dark-dimmed twoslash lsp" style="background-color: #22272e; color: #adbac7"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #ADBAC7">{</span><span style="color: #96D0FF">"version"</span><span style="color: #ADBAC7">:</span><span style="color: #6CB6FF">3</span><span style="color: #ADBAC7">,</span><span style="color: #96D0FF">"file"</span><span style="color: #ADBAC7">:</span><span style="color: #96D0FF">"index.js"</span><span style="color: #ADBAC7">,</span><span style="color: #96D0FF">"sourceRoot"</span><span style="color: #ADBAC7">:</span><span style="color: #96D0FF">""</span><span style="color: #ADBAC7">,</span><span style="color: #96D0FF">"sources"</span><span style="color: #ADBAC7">:[</span><span style="color: #96D0FF">"index.ts"</span><span style="color: #ADBAC7">],</span><span style="color: #96D0FF">"names"</span><span style="color: #ADBAC7">:[],</span><span style="color: #96D0FF">"mappings"</span><span style="color: #ADBAC7">:</span><span style="color: #96D0FF">"AAAA,MAAM,CAAC,MAAM,KAAK,GAAG,OAAO,CAAA"</span><span style="color: #ADBAC7">}</span></div></code></div></pre>
<pre class="shiki github-light twoslash lsp" style="background-color: #fff; color: #24292e"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #24292E">{</span><span style="color: #032F62">"version"</span><span style="color: #24292E">:</span><span style="color: #005CC5">3</span><span style="color: #24292E">,</span><span style="color: #032F62">"file"</span><span style="color: #24292E">:</span><span style="color: #032F62">"index.js"</span><span style="color: #24292E">,</span><span style="color: #032F62">"sourceRoot"</span><span style="color: #24292E">:</span><span style="color: #032F62">""</span><span style="color: #24292E">,</span><span style="color: #032F62">"sources"</span><span style="color: #24292E">:[</span><span style="color: #032F62">"index.ts"</span><span style="color: #24292E">],</span><span style="color: #032F62">"names"</span><span style="color: #24292E">:[],</span><span style="color: #032F62">"mappings"</span><span style="color: #24292E">:</span><span style="color: #032F62">"AAAA,MAAM,CAAC,MAAM,KAAK,GAAG,OAAO,CAAA"</span><span style="color: #24292E">}</span></div></code></div></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div></div></div>
<div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-Kjs7n" id="tab-33POrMx" checked="checked"><label for="tab-33POrMx">markdown</label><input type="radio" name="group-Kjs7n" id="tab-OVpf0aT" ><label for="tab-OVpf0aT">output</label></div><div class="blocks">
<div class="language-md vp-adaptive-theme active line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">md</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">```ts twoslash</span></span>
<span class="line"><span style="color: #768390">// @declaration</span></span>
<span class="line"><span style="color: #768390">// @declarationMap</span></span>
<span class="line"><span style="color: #768390">// @showEmit</span></span>
<span class="line"><span style="color: #768390">// @showEmittedFile: index.d.ts.map</span></span>
<span class="line"><span style="color: #F47067">export</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">const</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">hello</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;world&#39;</span></span>
<span class="line"><span style="color: #ADBAC7">```</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">```ts twoslash</span></span>
<span class="line"><span style="color: #6A737D">// @declaration</span></span>
<span class="line"><span style="color: #6A737D">// @declarationMap</span></span>
<span class="line"><span style="color: #6A737D">// @showEmit</span></span>
<span class="line"><span style="color: #6A737D">// @showEmittedFile: index.d.ts.map</span></span>
<span class="line"><span style="color: #D73A49">export</span><span style="color: #24292E"> </span><span style="color: #D73A49">const</span><span style="color: #24292E"> </span><span style="color: #005CC5">hello</span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;world&#39;</span></span>
<span class="line"><span style="color: #24292E">```</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br></div></div><div class="language-ts vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki github-dark-dimmed twoslash lsp" style="background-color: #22272e; color: #adbac7"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #ADBAC7">{</span><span style="color: #96D0FF">"version"</span><span style="color: #ADBAC7">:</span><span style="color: #6CB6FF">3</span><span style="color: #ADBAC7">,</span><span style="color: #96D0FF">"file"</span><span style="color: #ADBAC7">:</span><span style="color: #96D0FF">"index.d.ts"</span><span style="color: #ADBAC7">,</span><span style="color: #96D0FF">"sourceRoot"</span><span style="color: #ADBAC7">:</span><span style="color: #96D0FF">""</span><span style="color: #ADBAC7">,</span><span style="color: #96D0FF">"sources"</span><span style="color: #ADBAC7">:[</span><span style="color: #96D0FF">"index.ts"</span><span style="color: #ADBAC7">],</span><span style="color: #96D0FF">"names"</span><span style="color: #ADBAC7">:[],</span><span style="color: #96D0FF">"mappings"</span><span style="color: #ADBAC7">:</span><span style="color: #96D0FF">"AAAA,eAAO,MAAM,KAAK,UAAU,CAAA"</span><span style="color: #ADBAC7">}</span></div></code></div></pre>
<pre class="shiki github-light twoslash lsp" style="background-color: #fff; color: #24292e"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #24292E">{</span><span style="color: #032F62">"version"</span><span style="color: #24292E">:</span><span style="color: #005CC5">3</span><span style="color: #24292E">,</span><span style="color: #032F62">"file"</span><span style="color: #24292E">:</span><span style="color: #032F62">"index.d.ts"</span><span style="color: #24292E">,</span><span style="color: #032F62">"sourceRoot"</span><span style="color: #24292E">:</span><span style="color: #032F62">""</span><span style="color: #24292E">,</span><span style="color: #032F62">"sources"</span><span style="color: #24292E">:[</span><span style="color: #032F62">"index.ts"</span><span style="color: #24292E">],</span><span style="color: #032F62">"names"</span><span style="color: #24292E">:[],</span><span style="color: #032F62">"mappings"</span><span style="color: #24292E">:</span><span style="color: #032F62">"AAAA,eAAO,MAAM,KAAK,UAAU,CAAA"</span><span style="color: #24292E">}</span></div></code></div></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div></div></div>
]]></description>
            <content:encoded><![CDATA[<h1 id="emit" tabindex="-1">Emit <a class="header-anchor" href="#emit" aria-label="Permalink to &quot;Emit&quot;">&ZeroWidthSpace;</a></h1>
<p>Running a Twoslash code example is a full TypeScript compiler run that will create files inside the virtual file system. You can replace the contents of your code examples with the results of running TypeScript over the project.</p>
<h2 id="showemit" tabindex="-1"><code>@showEmit</code> <a class="header-anchor" href="#showemit" aria-label="Permalink to &quot;`@showEmit`&quot;">&ZeroWidthSpace;</a></h2>
<p><code>// @showEmit</code> is the main command to tell Shiki Twoslash that you want to replace the output of your code example with the equivalent <code>.js</code> file.</p>
<div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-8CKtV" id="tab-GOeMGMx" checked="checked"><label for="tab-GOeMGMx">output</label><input type="radio" name="group-8CKtV" id="tab-nE2Fmxg" ><label for="tab-nE2Fmxg">markdown</label></div><div class="blocks">
<div class="language-ts vp-adaptive-theme active line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki github-dark-dimmed twoslash lsp" style="background-color: #22272e; color: #adbac7"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #96D0FF">"use strict"</span><span style="color: #ADBAC7">;</span></div><div class='line'><span style="color: #F47067">const</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">level</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&apos;Danger&apos;</span><span style="color: #ADBAC7">;</span></div><div class='line'>&nbsp;</div></code></div></pre>
<pre class="shiki github-light twoslash lsp" style="background-color: #fff; color: #24292e"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #032F62">"use strict"</span><span style="color: #24292E">;</span></div><div class='line'><span style="color: #D73A49">const</span><span style="color: #24292E"> </span><span style="color: #005CC5">level</span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #032F62">&apos;Danger&apos;</span><span style="color: #24292E">;</span></div><div class='line'>&nbsp;</div></code></div></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="language-md vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">md</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">```ts twoslash</span></span>
<span class="line"><span style="color: #768390">// @showEmit</span></span>
<span class="line"><span style="color: #F47067">const</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">level</span><span style="color: #F47067">:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">string</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;Danger&#39;</span></span>
<span class="line"><span style="color: #ADBAC7">```</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">```ts twoslash</span></span>
<span class="line"><span style="color: #6A737D">// @showEmit</span></span>
<span class="line"><span style="color: #D73A49">const</span><span style="color: #24292E"> </span><span style="color: #005CC5">level</span><span style="color: #D73A49">:</span><span style="color: #24292E"> </span><span style="color: #005CC5">string</span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;Danger&#39;</span></span>
<span class="line"><span style="color: #24292E">```</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br></div></div></div></div>
<h2 id="showemittedfile-file" tabindex="-1"><code>@showEmittedFile: [file]</code> <a class="header-anchor" href="#showemittedfile-file" aria-label="Permalink to &quot;`@showEmittedFile: [file]`&quot;">&ZeroWidthSpace;</a></h2>
<p>While the <code>.js</code> file is probably the most useful file out of the box, TypeScript does emit other files if you have the right flags enabled (<code>.d.ts</code> and <code>.map</code>) but also when you have a multi-file code sample — you might need to tell Twoslash which file to show. For all these cases you can also add <code>@showEmittedFile: [file]</code> to tell Twoslash which file you want to show.</p>
<p>Shows emitted <code>.d.ts</code> for a TypeScript code example:</p>
<div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group--Ls8T" id="tab-LIKPGzw" checked="checked"><label for="tab-LIKPGzw">markdown</label><input type="radio" name="group--Ls8T" id="tab-q2evYMA" ><label for="tab-q2evYMA">output</label></div><div class="blocks">
<div class="language-md vp-adaptive-theme active line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">md</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">```ts twoslash</span></span>
<span class="line"><span style="color: #768390">// @declaration</span></span>
<span class="line"><span style="color: #768390">// @showEmit</span></span>
<span class="line"><span style="color: #768390">// @showEmittedFile: index.d.ts</span></span>
<span class="line"><span style="color: #F47067">export</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">const</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">hello</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;world&#39;</span></span>
<span class="line"><span style="color: #ADBAC7">```</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">```ts twoslash</span></span>
<span class="line"><span style="color: #6A737D">// @declaration</span></span>
<span class="line"><span style="color: #6A737D">// @showEmit</span></span>
<span class="line"><span style="color: #6A737D">// @showEmittedFile: index.d.ts</span></span>
<span class="line"><span style="color: #D73A49">export</span><span style="color: #24292E"> </span><span style="color: #D73A49">const</span><span style="color: #24292E"> </span><span style="color: #005CC5">hello</span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;world&#39;</span></span>
<span class="line"><span style="color: #24292E">```</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br></div></div><div class="language-ts vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki github-dark-dimmed twoslash lsp" style="background-color: #22272e; color: #adbac7"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #F47067">export</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">declare</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">const</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">hello</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">"world"</span><span style="color: #ADBAC7">;</span></div><div class='line'>&nbsp;</div></code></div></pre>
<pre class="shiki github-light twoslash lsp" style="background-color: #fff; color: #24292e"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #D73A49">export</span><span style="color: #24292E"> </span><span style="color: #D73A49">declare</span><span style="color: #24292E"> </span><span style="color: #D73A49">const</span><span style="color: #24292E"> </span><span style="color: #005CC5">hello</span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #032F62">"world"</span><span style="color: #24292E">;</span></div><div class='line'>&nbsp;</div></code></div></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div></div></div>
<p>Shows emitted <code>.map</code> files:</p>
<div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-aGTqY" id="tab-3k7OYrB" checked="checked"><label for="tab-3k7OYrB">markdown</label><input type="radio" name="group-aGTqY" id="tab-mXISwtW" ><label for="tab-mXISwtW">output</label></div><div class="blocks">
<div class="language-md vp-adaptive-theme active line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">md</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">```ts twoslash</span></span>
<span class="line"><span style="color: #768390">// @sourceMap</span></span>
<span class="line"><span style="color: #768390">// @showEmit</span></span>
<span class="line"><span style="color: #768390">// @showEmittedFile: index.js.map</span></span>
<span class="line"><span style="color: #F47067">export</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">const</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">hello</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;world&#39;</span></span>
<span class="line"><span style="color: #ADBAC7">```</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">```ts twoslash</span></span>
<span class="line"><span style="color: #6A737D">// @sourceMap</span></span>
<span class="line"><span style="color: #6A737D">// @showEmit</span></span>
<span class="line"><span style="color: #6A737D">// @showEmittedFile: index.js.map</span></span>
<span class="line"><span style="color: #D73A49">export</span><span style="color: #24292E"> </span><span style="color: #D73A49">const</span><span style="color: #24292E"> </span><span style="color: #005CC5">hello</span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;world&#39;</span></span>
<span class="line"><span style="color: #24292E">```</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br></div></div><div class="language-ts vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki github-dark-dimmed twoslash lsp" style="background-color: #22272e; color: #adbac7"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #ADBAC7">{</span><span style="color: #96D0FF">"version"</span><span style="color: #ADBAC7">:</span><span style="color: #6CB6FF">3</span><span style="color: #ADBAC7">,</span><span style="color: #96D0FF">"file"</span><span style="color: #ADBAC7">:</span><span style="color: #96D0FF">"index.js"</span><span style="color: #ADBAC7">,</span><span style="color: #96D0FF">"sourceRoot"</span><span style="color: #ADBAC7">:</span><span style="color: #96D0FF">""</span><span style="color: #ADBAC7">,</span><span style="color: #96D0FF">"sources"</span><span style="color: #ADBAC7">:[</span><span style="color: #96D0FF">"index.ts"</span><span style="color: #ADBAC7">],</span><span style="color: #96D0FF">"names"</span><span style="color: #ADBAC7">:[],</span><span style="color: #96D0FF">"mappings"</span><span style="color: #ADBAC7">:</span><span style="color: #96D0FF">"AAAA,MAAM,CAAC,MAAM,KAAK,GAAG,OAAO,CAAA"</span><span style="color: #ADBAC7">}</span></div></code></div></pre>
<pre class="shiki github-light twoslash lsp" style="background-color: #fff; color: #24292e"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #24292E">{</span><span style="color: #032F62">"version"</span><span style="color: #24292E">:</span><span style="color: #005CC5">3</span><span style="color: #24292E">,</span><span style="color: #032F62">"file"</span><span style="color: #24292E">:</span><span style="color: #032F62">"index.js"</span><span style="color: #24292E">,</span><span style="color: #032F62">"sourceRoot"</span><span style="color: #24292E">:</span><span style="color: #032F62">""</span><span style="color: #24292E">,</span><span style="color: #032F62">"sources"</span><span style="color: #24292E">:[</span><span style="color: #032F62">"index.ts"</span><span style="color: #24292E">],</span><span style="color: #032F62">"names"</span><span style="color: #24292E">:[],</span><span style="color: #032F62">"mappings"</span><span style="color: #24292E">:</span><span style="color: #032F62">"AAAA,MAAM,CAAC,MAAM,KAAK,GAAG,OAAO,CAAA"</span><span style="color: #24292E">}</span></div></code></div></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div></div></div>
<div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-Kjs7n" id="tab-33POrMx" checked="checked"><label for="tab-33POrMx">markdown</label><input type="radio" name="group-Kjs7n" id="tab-OVpf0aT" ><label for="tab-OVpf0aT">output</label></div><div class="blocks">
<div class="language-md vp-adaptive-theme active line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">md</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">```ts twoslash</span></span>
<span class="line"><span style="color: #768390">// @declaration</span></span>
<span class="line"><span style="color: #768390">// @declarationMap</span></span>
<span class="line"><span style="color: #768390">// @showEmit</span></span>
<span class="line"><span style="color: #768390">// @showEmittedFile: index.d.ts.map</span></span>
<span class="line"><span style="color: #F47067">export</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">const</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">hello</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;world&#39;</span></span>
<span class="line"><span style="color: #ADBAC7">```</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">```ts twoslash</span></span>
<span class="line"><span style="color: #6A737D">// @declaration</span></span>
<span class="line"><span style="color: #6A737D">// @declarationMap</span></span>
<span class="line"><span style="color: #6A737D">// @showEmit</span></span>
<span class="line"><span style="color: #6A737D">// @showEmittedFile: index.d.ts.map</span></span>
<span class="line"><span style="color: #D73A49">export</span><span style="color: #24292E"> </span><span style="color: #D73A49">const</span><span style="color: #24292E"> </span><span style="color: #005CC5">hello</span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;world&#39;</span></span>
<span class="line"><span style="color: #24292E">```</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br></div></div><div class="language-ts vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki github-dark-dimmed twoslash lsp" style="background-color: #22272e; color: #adbac7"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #ADBAC7">{</span><span style="color: #96D0FF">"version"</span><span style="color: #ADBAC7">:</span><span style="color: #6CB6FF">3</span><span style="color: #ADBAC7">,</span><span style="color: #96D0FF">"file"</span><span style="color: #ADBAC7">:</span><span style="color: #96D0FF">"index.d.ts"</span><span style="color: #ADBAC7">,</span><span style="color: #96D0FF">"sourceRoot"</span><span style="color: #ADBAC7">:</span><span style="color: #96D0FF">""</span><span style="color: #ADBAC7">,</span><span style="color: #96D0FF">"sources"</span><span style="color: #ADBAC7">:[</span><span style="color: #96D0FF">"index.ts"</span><span style="color: #ADBAC7">],</span><span style="color: #96D0FF">"names"</span><span style="color: #ADBAC7">:[],</span><span style="color: #96D0FF">"mappings"</span><span style="color: #ADBAC7">:</span><span style="color: #96D0FF">"AAAA,eAAO,MAAM,KAAK,UAAU,CAAA"</span><span style="color: #ADBAC7">}</span></div></code></div></pre>
<pre class="shiki github-light twoslash lsp" style="background-color: #fff; color: #24292e"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #24292E">{</span><span style="color: #032F62">"version"</span><span style="color: #24292E">:</span><span style="color: #005CC5">3</span><span style="color: #24292E">,</span><span style="color: #032F62">"file"</span><span style="color: #24292E">:</span><span style="color: #032F62">"index.d.ts"</span><span style="color: #24292E">,</span><span style="color: #032F62">"sourceRoot"</span><span style="color: #24292E">:</span><span style="color: #032F62">""</span><span style="color: #24292E">,</span><span style="color: #032F62">"sources"</span><span style="color: #24292E">:[</span><span style="color: #032F62">"index.ts"</span><span style="color: #24292E">],</span><span style="color: #032F62">"names"</span><span style="color: #24292E">:[],</span><span style="color: #032F62">"mappings"</span><span style="color: #24292E">:</span><span style="color: #032F62">"AAAA,eAAO,MAAM,KAAK,UAAU,CAAA"</span><span style="color: #24292E">}</span></div></code></div></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div></div></div>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Errors]]></title>
            <link>https://note.toshiki.devapplication/vitepress-plugin-shiki-twoslash/api/errors</link>
            <guid>https://note.toshiki.devapplication/vitepress-plugin-shiki-twoslash/api/errors</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="errors" tabindex="-1">Errors <a class="header-anchor" href="#errors" aria-label="Permalink to &quot;Errors&quot;">&ZeroWidthSpace;</a></h1>
<p>Most of the time, you want to avoid errors in your code examples. Strictly speaking, this usually means setting the right compiler flags and environment in each code example.</p>
<p>Sometimes however, you do want to raise a compiler error — to show incorrect states. In those cases, twoslash has a way to mark the compiler errors you expect.</p>
<h2 id="errors-num" tabindex="-1"><code>@errors: [num]</code> <a class="header-anchor" href="#errors-num" aria-label="Permalink to &quot;`@errors: [num]`&quot;">&ZeroWidthSpace;</a></h2>
<p>All TypeScript compiler errors have a number, this number is relatively arbitrary and can change between TypeScript versions. For our case these numbers are useul in declaring what we expect to see.</p>
<p>You can use <code>// @errors: [num]</code> to tell Twoslash that you expect this error to occur. This moves the compiler error message into the code example.</p>
<div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-7i-WR" id="tab-PVW3k32" checked="checked"><label for="tab-PVW3k32">output</label><input type="radio" name="group-7i-WR" id="tab-YHlm_3Y" ><label for="tab-YHlm_3Y">markdown</label></div><div class="blocks">
<div class="language-ts vp-adaptive-theme active line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki github-dark-dimmed twoslash lsp" style="background-color: #22272e; color: #adbac7"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #F47067">const</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF"><data-lsp lsp='const a: "123"' >a</data-lsp></span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&apos;123&apos;</span></div><div class='line'><span style="color: #ADBAC7"><data-err><data-lsp lsp='const a: any' >a</data-lsp></data-err> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">132</span></div><span class="error"><span>Cannot assign to 'a' because it is a constant.</span><span class="code">2588</span></span><span class="error-behind">Cannot assign to 'a' because it is a constant.</span></code></div></pre>
<pre class="shiki github-light twoslash lsp" style="background-color: #fff; color: #24292e"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #D73A49">const</span><span style="color: #24292E"> </span><span style="color: #005CC5"><data-lsp lsp='const a: "123"' >a</data-lsp></span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #032F62">&apos;123&apos;</span></div><div class='line'><span style="color: #24292E"><data-err><data-lsp lsp='const a: any' >a</data-lsp></data-err> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #005CC5">132</span></div><span class="error"><span>Cannot assign to 'a' because it is a constant.</span><span class="code">2588</span></span><span class="error-behind">Cannot assign to 'a' because it is a constant.</span></code></div></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="language-md vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">md</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">```ts twoslash</span></span>
<span class="line"><span style="color: #768390">// @errors: 2588</span></span>
<span class="line"><span style="color: #F47067">const</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">a</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;123&#39;</span></span>
<span class="line"><span style="color: #ADBAC7">a </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">132</span></span>
<span class="line"><span style="color: #ADBAC7">```</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">```ts twoslash</span></span>
<span class="line"><span style="color: #6A737D">// @errors: 2588</span></span>
<span class="line"><span style="color: #D73A49">const</span><span style="color: #24292E"> </span><span style="color: #005CC5">a</span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;123&#39;</span></span>
<span class="line"><span style="color: #24292E">a </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #005CC5">132</span></span>
<span class="line"><span style="color: #24292E">```</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br></div></div></div></div>
<h2 id="noerrors" tabindex="-1"><code>@noErrors</code> <a class="header-anchor" href="#noerrors" aria-label="Permalink to &quot;`@noErrors`&quot;">&ZeroWidthSpace;</a></h2>
<p>Sometimes you have needs in which a broken TypeScript build is okay. A good example of this is using a <a href="./queries.html#completions">completion query</a>, which requires a broken TypeScript project to work. You can use <code>// @noErrors</code> to supress all errors in a code sample, and not have them show inline.</p>
<div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-of96-" id="tab-wdn6ekv" checked="checked"><label for="tab-wdn6ekv">output</label><input type="radio" name="group-of96-" id="tab-nEwKJva" ><label for="tab-nEwKJva">markdown</label></div><div class="blocks">
<div class="language-ts vp-adaptive-theme active line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki github-dark-dimmed twoslash lsp" style="background-color: #22272e; color: #adbac7"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #F47067">const</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF"><data-lsp lsp='const a: "123"' >a</data-lsp></span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&apos;123&apos;</span></div><div class='line'><span style="color: #ADBAC7"><data-lsp lsp='const a: any' >a</data-lsp> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">132</span></div></code></div></pre>
<pre class="shiki github-light twoslash lsp" style="background-color: #fff; color: #24292e"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #D73A49">const</span><span style="color: #24292E"> </span><span style="color: #005CC5"><data-lsp lsp='const a: "123"' >a</data-lsp></span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #032F62">&apos;123&apos;</span></div><div class='line'><span style="color: #24292E"><data-lsp lsp='const a: any' >a</data-lsp> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #005CC5">132</span></div></code></div></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="language-md vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">md</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">```ts twoslash</span></span>
<span class="line"><span style="color: #768390">// @noErrors</span></span>
<span class="line"><span style="color: #F47067">const</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">a</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;123&#39;</span></span>
<span class="line"><span style="color: #ADBAC7">a </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">132</span></span>
<span class="line"><span style="color: #ADBAC7">```</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">```ts twoslash</span></span>
<span class="line"><span style="color: #6A737D">// @noErrors</span></span>
<span class="line"><span style="color: #D73A49">const</span><span style="color: #24292E"> </span><span style="color: #005CC5">a</span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;123&#39;</span></span>
<span class="line"><span style="color: #24292E">a </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #005CC5">132</span></span>
<span class="line"><span style="color: #24292E">```</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br></div></div></div></div>
]]></description>
            <content:encoded><![CDATA[<h1 id="errors" tabindex="-1">Errors <a class="header-anchor" href="#errors" aria-label="Permalink to &quot;Errors&quot;">&ZeroWidthSpace;</a></h1>
<p>Most of the time, you want to avoid errors in your code examples. Strictly speaking, this usually means setting the right compiler flags and environment in each code example.</p>
<p>Sometimes however, you do want to raise a compiler error — to show incorrect states. In those cases, twoslash has a way to mark the compiler errors you expect.</p>
<h2 id="errors-num" tabindex="-1"><code>@errors: [num]</code> <a class="header-anchor" href="#errors-num" aria-label="Permalink to &quot;`@errors: [num]`&quot;">&ZeroWidthSpace;</a></h2>
<p>All TypeScript compiler errors have a number, this number is relatively arbitrary and can change between TypeScript versions. For our case these numbers are useul in declaring what we expect to see.</p>
<p>You can use <code>// @errors: [num]</code> to tell Twoslash that you expect this error to occur. This moves the compiler error message into the code example.</p>
<div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-7i-WR" id="tab-PVW3k32" checked="checked"><label for="tab-PVW3k32">output</label><input type="radio" name="group-7i-WR" id="tab-YHlm_3Y" ><label for="tab-YHlm_3Y">markdown</label></div><div class="blocks">
<div class="language-ts vp-adaptive-theme active line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki github-dark-dimmed twoslash lsp" style="background-color: #22272e; color: #adbac7"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #F47067">const</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF"><data-lsp lsp='const a: "123"' >a</data-lsp></span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&apos;123&apos;</span></div><div class='line'><span style="color: #ADBAC7"><data-err><data-lsp lsp='const a: any' >a</data-lsp></data-err> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">132</span></div><span class="error"><span>Cannot assign to 'a' because it is a constant.</span><span class="code">2588</span></span><span class="error-behind">Cannot assign to 'a' because it is a constant.</span></code></div></pre>
<pre class="shiki github-light twoslash lsp" style="background-color: #fff; color: #24292e"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #D73A49">const</span><span style="color: #24292E"> </span><span style="color: #005CC5"><data-lsp lsp='const a: "123"' >a</data-lsp></span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #032F62">&apos;123&apos;</span></div><div class='line'><span style="color: #24292E"><data-err><data-lsp lsp='const a: any' >a</data-lsp></data-err> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #005CC5">132</span></div><span class="error"><span>Cannot assign to 'a' because it is a constant.</span><span class="code">2588</span></span><span class="error-behind">Cannot assign to 'a' because it is a constant.</span></code></div></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="language-md vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">md</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">```ts twoslash</span></span>
<span class="line"><span style="color: #768390">// @errors: 2588</span></span>
<span class="line"><span style="color: #F47067">const</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">a</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;123&#39;</span></span>
<span class="line"><span style="color: #ADBAC7">a </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">132</span></span>
<span class="line"><span style="color: #ADBAC7">```</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">```ts twoslash</span></span>
<span class="line"><span style="color: #6A737D">// @errors: 2588</span></span>
<span class="line"><span style="color: #D73A49">const</span><span style="color: #24292E"> </span><span style="color: #005CC5">a</span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;123&#39;</span></span>
<span class="line"><span style="color: #24292E">a </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #005CC5">132</span></span>
<span class="line"><span style="color: #24292E">```</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br></div></div></div></div>
<h2 id="noerrors" tabindex="-1"><code>@noErrors</code> <a class="header-anchor" href="#noerrors" aria-label="Permalink to &quot;`@noErrors`&quot;">&ZeroWidthSpace;</a></h2>
<p>Sometimes you have needs in which a broken TypeScript build is okay. A good example of this is using a <a href="./queries.html#completions">completion query</a>, which requires a broken TypeScript project to work. You can use <code>// @noErrors</code> to supress all errors in a code sample, and not have them show inline.</p>
<div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-of96-" id="tab-wdn6ekv" checked="checked"><label for="tab-wdn6ekv">output</label><input type="radio" name="group-of96-" id="tab-nEwKJva" ><label for="tab-nEwKJva">markdown</label></div><div class="blocks">
<div class="language-ts vp-adaptive-theme active line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki github-dark-dimmed twoslash lsp" style="background-color: #22272e; color: #adbac7"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #F47067">const</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF"><data-lsp lsp='const a: "123"' >a</data-lsp></span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&apos;123&apos;</span></div><div class='line'><span style="color: #ADBAC7"><data-lsp lsp='const a: any' >a</data-lsp> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">132</span></div></code></div></pre>
<pre class="shiki github-light twoslash lsp" style="background-color: #fff; color: #24292e"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #D73A49">const</span><span style="color: #24292E"> </span><span style="color: #005CC5"><data-lsp lsp='const a: "123"' >a</data-lsp></span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #032F62">&apos;123&apos;</span></div><div class='line'><span style="color: #24292E"><data-lsp lsp='const a: any' >a</data-lsp> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #005CC5">132</span></div></code></div></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="language-md vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">md</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">```ts twoslash</span></span>
<span class="line"><span style="color: #768390">// @noErrors</span></span>
<span class="line"><span style="color: #F47067">const</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">a</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;123&#39;</span></span>
<span class="line"><span style="color: #ADBAC7">a </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">132</span></span>
<span class="line"><span style="color: #ADBAC7">```</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">```ts twoslash</span></span>
<span class="line"><span style="color: #6A737D">// @noErrors</span></span>
<span class="line"><span style="color: #D73A49">const</span><span style="color: #24292E"> </span><span style="color: #005CC5">a</span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;123&#39;</span></span>
<span class="line"><span style="color: #24292E">a </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #005CC5">132</span></span>
<span class="line"><span style="color: #24292E">```</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br></div></div></div></div>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Includes]]></title>
            <link>https://note.toshiki.devapplication/vitepress-plugin-shiki-twoslash/api/includes</link>
            <guid>https://note.toshiki.devapplication/vitepress-plugin-shiki-twoslash/api/includes</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="includes" tabindex="-1">Includes <a class="header-anchor" href="#includes" aria-label="Permalink to &quot;Includes&quot;">&ZeroWidthSpace;</a></h1>
<p>As your documentation grows, you may need a way of re-using code blocks to prevent code duplication. Shiki Twoslash provides a simple includes system.</p>
<h2 id="defining-a-re-usable-block" tabindex="-1">Defining a re-usable block <a class="header-anchor" href="#defining-a-re-usable-block" aria-label="Permalink to &quot;Defining a re-usable block&quot;">&ZeroWidthSpace;</a></h2>
<p>Re-usable code blocks are defined by the <code>twoslash</code> language, followed by the <code>include</code> keyword and the reference name of your choice.</p>
<div class="language-md vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">md</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">```twoslash include myBlock</span></span>
<span class="line"><span style="color: #ADBAC7">type SomeString = string</span></span>
<span class="line"><span style="color: #ADBAC7">```</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">```twoslash include myBlock</span></span>
<span class="line"><span style="color: #24292E">type SomeString = string</span></span>
<span class="line"><span style="color: #24292E">```</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><h3 id="incremental-steps" tabindex="-1">Incremental steps <a class="header-anchor" href="#incremental-steps" aria-label="Permalink to &quot;Incremental steps&quot;">&ZeroWidthSpace;</a></h3>
<p>Shiki Twoslash also provide the ability to define incremental steps through the definition of re-usable blocks. This means whenever a new step is delimited down the code, it will also include previous steps. These are <strong>not groups</strong>.</p>
<ul>
<li>Incremental steps are delimited by <code>// - [name of the step]</code></li>
<li>They are named <strong>at the end</strong> of the actual code</li>
</ul>
<div class="language-md vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">md</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">```twoslash include myBlockWithSteps</span></span>
<span class="line"><span style="color: #ADBAC7">type SomeString = string</span></span>
<span class="line"><span style="color: #ADBAC7">// - base</span></span>
<span class="line"><span style="color: #ADBAC7">type SomeUser = { name: string; mail?: SomeUserMail }</span></span>
<span class="line"><span style="color: #ADBAC7">type SomeUserMail = { content: string; verified: boolean }</span></span>
<span class="line"><span style="color: #ADBAC7">// - afterUserDefinitions</span></span>
<span class="line"><span style="color: #ADBAC7">type SomeGroup = { name: string; members: SomeUser[] }</span></span>
<span class="line"><span style="color: #ADBAC7">// - afterGroupDefinitions</span></span>
<span class="line"><span style="color: #ADBAC7">```</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">```twoslash include myBlockWithSteps</span></span>
<span class="line"><span style="color: #24292E">type SomeString = string</span></span>
<span class="line"><span style="color: #24292E">// - base</span></span>
<span class="line"><span style="color: #24292E">type SomeUser = { name: string; mail?: SomeUserMail }</span></span>
<span class="line"><span style="color: #24292E">type SomeUserMail = { content: string; verified: boolean }</span></span>
<span class="line"><span style="color: #24292E">// - afterUserDefinitions</span></span>
<span class="line"><span style="color: #24292E">type SomeGroup = { name: string; members: SomeUser[] }</span></span>
<span class="line"><span style="color: #24292E">// - afterGroupDefinitions</span></span>
<span class="line"><span style="color: #24292E">```</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br></div></div><h2 id="including-a-whole-block" tabindex="-1">Including a whole block <a class="header-anchor" href="#including-a-whole-block" aria-label="Permalink to &quot;Including a whole block&quot;">&ZeroWidthSpace;</a></h2>
<p>To include a re-usable block, add <code>// @include: [block name]</code> in your code block.</p>
<div class="language-twoslash vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">twoslash</span><pre />
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-qjYxj" id="tab-SeZDGgz" checked="checked"><label for="tab-SeZDGgz">output</label><input type="radio" name="group-qjYxj" id="tab-yKbVyvG" ><label for="tab-yKbVyvG">markdown</label></div><div class="blocks">
<div class="language-ts vp-adaptive-theme active line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki github-dark-dimmed twoslash lsp" style="background-color: #22272e; color: #adbac7"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #F47067">type</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50"><data-lsp lsp='type SomeString = string' >SomeString</data-lsp></span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">string</span></div><div class='line'><span style="color: #F47067">const</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF"><data-lsp lsp='const a: string' >a</data-lsp></span><span style="color: #F47067">:</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50"><data-lsp lsp='type SomeString = string' >SomeString</data-lsp></span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&apos;string&apos;</span></div></code></div></pre>
<pre class="shiki github-light twoslash lsp" style="background-color: #fff; color: #24292e"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #D73A49">type</span><span style="color: #24292E"> </span><span style="color: #6F42C1"><data-lsp lsp='type SomeString = string' >SomeString</data-lsp></span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #005CC5">string</span></div><div class='line'><span style="color: #D73A49">const</span><span style="color: #24292E"> </span><span style="color: #005CC5"><data-lsp lsp='const a: string' >a</data-lsp></span><span style="color: #D73A49">:</span><span style="color: #24292E"> </span><span style="color: #6F42C1"><data-lsp lsp='type SomeString = string' >SomeString</data-lsp></span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #032F62">&apos;string&apos;</span></div></code></div></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="language-md vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">md</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">```twoslash include myBlock</span></span>
<span class="line"><span style="color: #ADBAC7">type SomeString = string</span></span>
<span class="line"><span style="color: #ADBAC7">```</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">```ts twoslash</span></span>
<span class="line"><span style="color: #768390">// @include: myBlock</span></span>
<span class="line"><span style="color: #F47067">const</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">a</span><span style="color: #F47067">:</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50">SomeString</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;string&#39;</span></span>
<span class="line"><span style="color: #ADBAC7">```</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">```twoslash include myBlock</span></span>
<span class="line"><span style="color: #24292E">type SomeString = string</span></span>
<span class="line"><span style="color: #24292E">```</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">```ts twoslash</span></span>
<span class="line"><span style="color: #6A737D">// @include: myBlock</span></span>
<span class="line"><span style="color: #D73A49">const</span><span style="color: #24292E"> </span><span style="color: #005CC5">a</span><span style="color: #D73A49">:</span><span style="color: #24292E"> </span><span style="color: #6F42C1">SomeString</span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;string&#39;</span></span>
<span class="line"><span style="color: #24292E">```</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br></div></div></div></div>
<h2 id="including-a-block-step" tabindex="-1">Including a block step <a class="header-anchor" href="#including-a-block-step" aria-label="Permalink to &quot;Including a block step&quot;">&ZeroWidthSpace;</a></h2>
<p>To include a re-usable block at a specific step, add <code>// @include: [block name]-[step name]</code> in your code block.</p>
<div class="language-twoslash vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">twoslash</span><pre />
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-qpZax" id="tab-0bisV5P" checked="checked"><label for="tab-0bisV5P">output</label><input type="radio" name="group-qpZax" id="tab-FP_MR_5" ><label for="tab-FP_MR_5">markdown</label></div><div class="blocks">
<div class="language-ts vp-adaptive-theme active line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki github-dark-dimmed twoslash lsp" style="background-color: #22272e; color: #adbac7"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #F47067">type</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50"><data-lsp lsp='type SomeString = string' >SomeString</data-lsp></span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">string</span></div><div class='line'><span style="color: #F47067">type</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50"><data-lsp lsp='type SomeUser = {&#10;    name: string;&#10;    mail?: SomeUserMail | undefined;&#10;}' >SomeUser</data-lsp></span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> { </span><span style="color: #F69D50"><data-lsp lsp='(property) name: string' >name</data-lsp></span><span style="color: #F47067">:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">string</span><span style="color: #ADBAC7">; </span><span style="color: #F69D50"><data-lsp lsp='(property) mail?: SomeUserMail | undefined' >mail</data-lsp></span><span style="color: #F47067">?:</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50"><data-lsp lsp='type SomeUserMail = {&#10;    content: string;&#10;    verified: boolean;&#10;}' >SomeUserMail</data-lsp></span><span style="color: #ADBAC7"> }</span></div><div class='line'><span style="color: #F47067">type</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50"><data-lsp lsp='type SomeUserMail = {&#10;    content: string;&#10;    verified: boolean;&#10;}' >SomeUserMail</data-lsp></span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> { </span><span style="color: #F69D50"><data-lsp lsp='(property) content: string' >content</data-lsp></span><span style="color: #F47067">:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">string</span><span style="color: #ADBAC7">; </span><span style="color: #F69D50"><data-lsp lsp='(property) verified: boolean' >verified</data-lsp></span><span style="color: #F47067">:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">boolean</span><span style="color: #ADBAC7"> }</span></div><div class='line'><span style="color: #F47067">const</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF"><data-lsp lsp='const mail: SomeUserMail' >mail</data-lsp></span><span style="color: #F47067">:</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50"><data-lsp lsp='type SomeUserMail = {&#10;    content: string;&#10;    verified: boolean;&#10;}' >SomeUserMail</data-lsp></span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> { <data-lsp lsp='(property) content: string' >content</data-lsp>: </span><span style="color: #96D0FF">&apos;some-email&apos;</span><span style="color: #ADBAC7">, <data-lsp lsp='(property) verified: boolean' >verified</data-lsp>: </span><span style="color: #6CB6FF">true</span><span style="color: #ADBAC7"> }</span></div></code></div></pre>
<pre class="shiki github-light twoslash lsp" style="background-color: #fff; color: #24292e"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #D73A49">type</span><span style="color: #24292E"> </span><span style="color: #6F42C1"><data-lsp lsp='type SomeString = string' >SomeString</data-lsp></span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #005CC5">string</span></div><div class='line'><span style="color: #D73A49">type</span><span style="color: #24292E"> </span><span style="color: #6F42C1"><data-lsp lsp='type SomeUser = {&#10;    name: string;&#10;    mail?: SomeUserMail | undefined;&#10;}' >SomeUser</data-lsp></span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> { </span><span style="color: #E36209"><data-lsp lsp='(property) name: string' >name</data-lsp></span><span style="color: #D73A49">:</span><span style="color: #24292E"> </span><span style="color: #005CC5">string</span><span style="color: #24292E">; </span><span style="color: #E36209"><data-lsp lsp='(property) mail?: SomeUserMail | undefined' >mail</data-lsp></span><span style="color: #D73A49">?:</span><span style="color: #24292E"> </span><span style="color: #6F42C1"><data-lsp lsp='type SomeUserMail = {&#10;    content: string;&#10;    verified: boolean;&#10;}' >SomeUserMail</data-lsp></span><span style="color: #24292E"> }</span></div><div class='line'><span style="color: #D73A49">type</span><span style="color: #24292E"> </span><span style="color: #6F42C1"><data-lsp lsp='type SomeUserMail = {&#10;    content: string;&#10;    verified: boolean;&#10;}' >SomeUserMail</data-lsp></span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> { </span><span style="color: #E36209"><data-lsp lsp='(property) content: string' >content</data-lsp></span><span style="color: #D73A49">:</span><span style="color: #24292E"> </span><span style="color: #005CC5">string</span><span style="color: #24292E">; </span><span style="color: #E36209"><data-lsp lsp='(property) verified: boolean' >verified</data-lsp></span><span style="color: #D73A49">:</span><span style="color: #24292E"> </span><span style="color: #005CC5">boolean</span><span style="color: #24292E"> }</span></div><div class='line'><span style="color: #D73A49">const</span><span style="color: #24292E"> </span><span style="color: #005CC5"><data-lsp lsp='const mail: SomeUserMail' >mail</data-lsp></span><span style="color: #D73A49">:</span><span style="color: #24292E"> </span><span style="color: #6F42C1"><data-lsp lsp='type SomeUserMail = {&#10;    content: string;&#10;    verified: boolean;&#10;}' >SomeUserMail</data-lsp></span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> { <data-lsp lsp='(property) content: string' >content</data-lsp>: </span><span style="color: #032F62">&apos;some-email&apos;</span><span style="color: #24292E">, <data-lsp lsp='(property) verified: boolean' >verified</data-lsp>: </span><span style="color: #005CC5">true</span><span style="color: #24292E"> }</span></div></code></div></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="language-md vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">md</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">```twoslash include myBlockWithSteps</span></span>
<span class="line"><span style="color: #ADBAC7">type SomeString = string</span></span>
<span class="line"><span style="color: #ADBAC7">// - base</span></span>
<span class="line"><span style="color: #ADBAC7">type SomeUser = { name: string; mail?: SomeUserMail }</span></span>
<span class="line"><span style="color: #ADBAC7">type SomeUserMail = { content: string; verified: boolean }</span></span>
<span class="line"><span style="color: #ADBAC7">// - afterUserDefinitions</span></span>
<span class="line"><span style="color: #ADBAC7">type SomeGroup = { name: string; members: SomeUser[] }</span></span>
<span class="line"><span style="color: #ADBAC7">// - afterGroupDefinitions</span></span>
<span class="line"><span style="color: #ADBAC7">```</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">```ts twoslash</span></span>
<span class="line"><span style="color: #768390">// @include: myBlockWithSteps-afterUserDefinitions</span></span>
<span class="line"><span style="color: #F47067">const</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">mail</span><span style="color: #F47067">:</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50">SomeUserMail</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> { content: </span><span style="color: #96D0FF">&#39;some-email&#39;</span><span style="color: #ADBAC7">, verified: </span><span style="color: #6CB6FF">true</span><span style="color: #ADBAC7"> }</span></span>
<span class="line"><span style="color: #ADBAC7">```</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">```twoslash include myBlockWithSteps</span></span>
<span class="line"><span style="color: #24292E">type SomeString = string</span></span>
<span class="line"><span style="color: #24292E">// - base</span></span>
<span class="line"><span style="color: #24292E">type SomeUser = { name: string; mail?: SomeUserMail }</span></span>
<span class="line"><span style="color: #24292E">type SomeUserMail = { content: string; verified: boolean }</span></span>
<span class="line"><span style="color: #24292E">// - afterUserDefinitions</span></span>
<span class="line"><span style="color: #24292E">type SomeGroup = { name: string; members: SomeUser[] }</span></span>
<span class="line"><span style="color: #24292E">// - afterGroupDefinitions</span></span>
<span class="line"><span style="color: #24292E">```</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">```ts twoslash</span></span>
<span class="line"><span style="color: #6A737D">// @include: myBlockWithSteps-afterUserDefinitions</span></span>
<span class="line"><span style="color: #D73A49">const</span><span style="color: #24292E"> </span><span style="color: #005CC5">mail</span><span style="color: #D73A49">:</span><span style="color: #24292E"> </span><span style="color: #6F42C1">SomeUserMail</span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> { content: </span><span style="color: #032F62">&#39;some-email&#39;</span><span style="color: #24292E">, verified: </span><span style="color: #005CC5">true</span><span style="color: #24292E"> }</span></span>
<span class="line"><span style="color: #24292E">```</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br></div></div></div></div>
<h2 id="hiding-re-used-code" tabindex="-1">Hiding re-used code <a class="header-anchor" href="#hiding-re-used-code" aria-label="Permalink to &quot;Hiding re-used code&quot;">&ZeroWidthSpace;</a></h2>
<p>Re-using a lot of TypeScript code can easily bloat your documentation and obstruct the main point of your code block. You can hide re-used code to keep your code blocks clean and concise by <a href="./cutting.html">cutting</a> right after the <code>@include</code> statement.</p>
<div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-cwJ3v" id="tab-HX3he0W" checked="checked"><label for="tab-HX3he0W">output</label><input type="radio" name="group-cwJ3v" id="tab-kiL-bbm" ><label for="tab-kiL-bbm">markdown</label></div><div class="blocks">
<div class="language-ts vp-adaptive-theme active line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki github-dark-dimmed twoslash lsp" style="background-color: #22272e; color: #adbac7"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #F47067">const</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF"><data-lsp lsp='const mail: SomeUserMail' >mail</data-lsp></span><span style="color: #F47067">:</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50"><data-lsp lsp='type SomeUserMail = {&#10;    content: string;&#10;    verified: boolean;&#10;}' >SomeUserMail</data-lsp></span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> { <data-lsp lsp='(property) content: string' >content</data-lsp>: </span><span style="color: #96D0FF">&apos;some-email&apos;</span><span style="color: #ADBAC7">, <data-lsp lsp='(property) verified: boolean' >verified</data-lsp>: </span><span style="color: #6CB6FF">true</span><span style="color: #ADBAC7"> }</span></div></code></div></pre>
<pre class="shiki github-light twoslash lsp" style="background-color: #fff; color: #24292e"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #D73A49">const</span><span style="color: #24292E"> </span><span style="color: #005CC5"><data-lsp lsp='const mail: SomeUserMail' >mail</data-lsp></span><span style="color: #D73A49">:</span><span style="color: #24292E"> </span><span style="color: #6F42C1"><data-lsp lsp='type SomeUserMail = {&#10;    content: string;&#10;    verified: boolean;&#10;}' >SomeUserMail</data-lsp></span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> { <data-lsp lsp='(property) content: string' >content</data-lsp>: </span><span style="color: #032F62">&apos;some-email&apos;</span><span style="color: #24292E">, <data-lsp lsp='(property) verified: boolean' >verified</data-lsp>: </span><span style="color: #005CC5">true</span><span style="color: #24292E"> }</span></div></code></div></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="language-md vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">md</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">```twoslash include myBlockWithSteps</span></span>
<span class="line"><span style="color: #ADBAC7">type SomeString = string</span></span>
<span class="line"><span style="color: #ADBAC7">// - base</span></span>
<span class="line"><span style="color: #ADBAC7">type SomeUser = { name: string; mail?: SomeUserMail }</span></span>
<span class="line"><span style="color: #ADBAC7">type SomeUserMail = { content: string; verified: boolean }</span></span>
<span class="line"><span style="color: #ADBAC7">// - afterUserDefinitions</span></span>
<span class="line"><span style="color: #ADBAC7">type SomeGroup = { name: string; members: SomeUser[] }</span></span>
<span class="line"><span style="color: #ADBAC7">// - afterGroupDefinitions</span></span>
<span class="line"><span style="color: #ADBAC7">```</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">```ts twoslash</span></span>
<span class="line"><span style="color: #768390">// @include: myBlockWithSteps-afterUserDefinitions</span></span>
<span class="line"><span style="color: #768390">// ---cut---</span></span>
<span class="line"><span style="color: #F47067">const</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">mail</span><span style="color: #F47067">:</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50">SomeUserMail</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> { content: </span><span style="color: #96D0FF">&#39;some-email&#39;</span><span style="color: #ADBAC7">, verified: </span><span style="color: #6CB6FF">true</span><span style="color: #ADBAC7"> }</span></span>
<span class="line"><span style="color: #ADBAC7">```</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">```twoslash include myBlockWithSteps</span></span>
<span class="line"><span style="color: #24292E">type SomeString = string</span></span>
<span class="line"><span style="color: #24292E">// - base</span></span>
<span class="line"><span style="color: #24292E">type SomeUser = { name: string; mail?: SomeUserMail }</span></span>
<span class="line"><span style="color: #24292E">type SomeUserMail = { content: string; verified: boolean }</span></span>
<span class="line"><span style="color: #24292E">// - afterUserDefinitions</span></span>
<span class="line"><span style="color: #24292E">type SomeGroup = { name: string; members: SomeUser[] }</span></span>
<span class="line"><span style="color: #24292E">// - afterGroupDefinitions</span></span>
<span class="line"><span style="color: #24292E">```</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">```ts twoslash</span></span>
<span class="line"><span style="color: #6A737D">// @include: myBlockWithSteps-afterUserDefinitions</span></span>
<span class="line"><span style="color: #6A737D">// ---cut---</span></span>
<span class="line"><span style="color: #D73A49">const</span><span style="color: #24292E"> </span><span style="color: #005CC5">mail</span><span style="color: #D73A49">:</span><span style="color: #24292E"> </span><span style="color: #6F42C1">SomeUserMail</span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> { content: </span><span style="color: #032F62">&#39;some-email&#39;</span><span style="color: #24292E">, verified: </span><span style="color: #005CC5">true</span><span style="color: #24292E"> }</span></span>
<span class="line"><span style="color: #24292E">```</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br></div></div></div></div>
]]></description>
            <content:encoded><![CDATA[<h1 id="includes" tabindex="-1">Includes <a class="header-anchor" href="#includes" aria-label="Permalink to &quot;Includes&quot;">&ZeroWidthSpace;</a></h1>
<p>As your documentation grows, you may need a way of re-using code blocks to prevent code duplication. Shiki Twoslash provides a simple includes system.</p>
<h2 id="defining-a-re-usable-block" tabindex="-1">Defining a re-usable block <a class="header-anchor" href="#defining-a-re-usable-block" aria-label="Permalink to &quot;Defining a re-usable block&quot;">&ZeroWidthSpace;</a></h2>
<p>Re-usable code blocks are defined by the <code>twoslash</code> language, followed by the <code>include</code> keyword and the reference name of your choice.</p>
<div class="language-md vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">md</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">```twoslash include myBlock</span></span>
<span class="line"><span style="color: #ADBAC7">type SomeString = string</span></span>
<span class="line"><span style="color: #ADBAC7">```</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">```twoslash include myBlock</span></span>
<span class="line"><span style="color: #24292E">type SomeString = string</span></span>
<span class="line"><span style="color: #24292E">```</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><h3 id="incremental-steps" tabindex="-1">Incremental steps <a class="header-anchor" href="#incremental-steps" aria-label="Permalink to &quot;Incremental steps&quot;">&ZeroWidthSpace;</a></h3>
<p>Shiki Twoslash also provide the ability to define incremental steps through the definition of re-usable blocks. This means whenever a new step is delimited down the code, it will also include previous steps. These are <strong>not groups</strong>.</p>
<ul>
<li>Incremental steps are delimited by <code>// - [name of the step]</code></li>
<li>They are named <strong>at the end</strong> of the actual code</li>
</ul>
<div class="language-md vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">md</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">```twoslash include myBlockWithSteps</span></span>
<span class="line"><span style="color: #ADBAC7">type SomeString = string</span></span>
<span class="line"><span style="color: #ADBAC7">// - base</span></span>
<span class="line"><span style="color: #ADBAC7">type SomeUser = { name: string; mail?: SomeUserMail }</span></span>
<span class="line"><span style="color: #ADBAC7">type SomeUserMail = { content: string; verified: boolean }</span></span>
<span class="line"><span style="color: #ADBAC7">// - afterUserDefinitions</span></span>
<span class="line"><span style="color: #ADBAC7">type SomeGroup = { name: string; members: SomeUser[] }</span></span>
<span class="line"><span style="color: #ADBAC7">// - afterGroupDefinitions</span></span>
<span class="line"><span style="color: #ADBAC7">```</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">```twoslash include myBlockWithSteps</span></span>
<span class="line"><span style="color: #24292E">type SomeString = string</span></span>
<span class="line"><span style="color: #24292E">// - base</span></span>
<span class="line"><span style="color: #24292E">type SomeUser = { name: string; mail?: SomeUserMail }</span></span>
<span class="line"><span style="color: #24292E">type SomeUserMail = { content: string; verified: boolean }</span></span>
<span class="line"><span style="color: #24292E">// - afterUserDefinitions</span></span>
<span class="line"><span style="color: #24292E">type SomeGroup = { name: string; members: SomeUser[] }</span></span>
<span class="line"><span style="color: #24292E">// - afterGroupDefinitions</span></span>
<span class="line"><span style="color: #24292E">```</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br></div></div><h2 id="including-a-whole-block" tabindex="-1">Including a whole block <a class="header-anchor" href="#including-a-whole-block" aria-label="Permalink to &quot;Including a whole block&quot;">&ZeroWidthSpace;</a></h2>
<p>To include a re-usable block, add <code>// @include: [block name]</code> in your code block.</p>
<div class="language-twoslash vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">twoslash</span><pre />
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-qjYxj" id="tab-SeZDGgz" checked="checked"><label for="tab-SeZDGgz">output</label><input type="radio" name="group-qjYxj" id="tab-yKbVyvG" ><label for="tab-yKbVyvG">markdown</label></div><div class="blocks">
<div class="language-ts vp-adaptive-theme active line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki github-dark-dimmed twoslash lsp" style="background-color: #22272e; color: #adbac7"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #F47067">type</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50"><data-lsp lsp='type SomeString = string' >SomeString</data-lsp></span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">string</span></div><div class='line'><span style="color: #F47067">const</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF"><data-lsp lsp='const a: string' >a</data-lsp></span><span style="color: #F47067">:</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50"><data-lsp lsp='type SomeString = string' >SomeString</data-lsp></span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&apos;string&apos;</span></div></code></div></pre>
<pre class="shiki github-light twoslash lsp" style="background-color: #fff; color: #24292e"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #D73A49">type</span><span style="color: #24292E"> </span><span style="color: #6F42C1"><data-lsp lsp='type SomeString = string' >SomeString</data-lsp></span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #005CC5">string</span></div><div class='line'><span style="color: #D73A49">const</span><span style="color: #24292E"> </span><span style="color: #005CC5"><data-lsp lsp='const a: string' >a</data-lsp></span><span style="color: #D73A49">:</span><span style="color: #24292E"> </span><span style="color: #6F42C1"><data-lsp lsp='type SomeString = string' >SomeString</data-lsp></span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #032F62">&apos;string&apos;</span></div></code></div></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="language-md vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">md</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">```twoslash include myBlock</span></span>
<span class="line"><span style="color: #ADBAC7">type SomeString = string</span></span>
<span class="line"><span style="color: #ADBAC7">```</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">```ts twoslash</span></span>
<span class="line"><span style="color: #768390">// @include: myBlock</span></span>
<span class="line"><span style="color: #F47067">const</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">a</span><span style="color: #F47067">:</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50">SomeString</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;string&#39;</span></span>
<span class="line"><span style="color: #ADBAC7">```</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">```twoslash include myBlock</span></span>
<span class="line"><span style="color: #24292E">type SomeString = string</span></span>
<span class="line"><span style="color: #24292E">```</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">```ts twoslash</span></span>
<span class="line"><span style="color: #6A737D">// @include: myBlock</span></span>
<span class="line"><span style="color: #D73A49">const</span><span style="color: #24292E"> </span><span style="color: #005CC5">a</span><span style="color: #D73A49">:</span><span style="color: #24292E"> </span><span style="color: #6F42C1">SomeString</span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;string&#39;</span></span>
<span class="line"><span style="color: #24292E">```</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br></div></div></div></div>
<h2 id="including-a-block-step" tabindex="-1">Including a block step <a class="header-anchor" href="#including-a-block-step" aria-label="Permalink to &quot;Including a block step&quot;">&ZeroWidthSpace;</a></h2>
<p>To include a re-usable block at a specific step, add <code>// @include: [block name]-[step name]</code> in your code block.</p>
<div class="language-twoslash vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">twoslash</span><pre />
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-qpZax" id="tab-0bisV5P" checked="checked"><label for="tab-0bisV5P">output</label><input type="radio" name="group-qpZax" id="tab-FP_MR_5" ><label for="tab-FP_MR_5">markdown</label></div><div class="blocks">
<div class="language-ts vp-adaptive-theme active line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki github-dark-dimmed twoslash lsp" style="background-color: #22272e; color: #adbac7"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #F47067">type</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50"><data-lsp lsp='type SomeString = string' >SomeString</data-lsp></span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">string</span></div><div class='line'><span style="color: #F47067">type</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50"><data-lsp lsp='type SomeUser = {&#10;    name: string;&#10;    mail?: SomeUserMail | undefined;&#10;}' >SomeUser</data-lsp></span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> { </span><span style="color: #F69D50"><data-lsp lsp='(property) name: string' >name</data-lsp></span><span style="color: #F47067">:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">string</span><span style="color: #ADBAC7">; </span><span style="color: #F69D50"><data-lsp lsp='(property) mail?: SomeUserMail | undefined' >mail</data-lsp></span><span style="color: #F47067">?:</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50"><data-lsp lsp='type SomeUserMail = {&#10;    content: string;&#10;    verified: boolean;&#10;}' >SomeUserMail</data-lsp></span><span style="color: #ADBAC7"> }</span></div><div class='line'><span style="color: #F47067">type</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50"><data-lsp lsp='type SomeUserMail = {&#10;    content: string;&#10;    verified: boolean;&#10;}' >SomeUserMail</data-lsp></span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> { </span><span style="color: #F69D50"><data-lsp lsp='(property) content: string' >content</data-lsp></span><span style="color: #F47067">:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">string</span><span style="color: #ADBAC7">; </span><span style="color: #F69D50"><data-lsp lsp='(property) verified: boolean' >verified</data-lsp></span><span style="color: #F47067">:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">boolean</span><span style="color: #ADBAC7"> }</span></div><div class='line'><span style="color: #F47067">const</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF"><data-lsp lsp='const mail: SomeUserMail' >mail</data-lsp></span><span style="color: #F47067">:</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50"><data-lsp lsp='type SomeUserMail = {&#10;    content: string;&#10;    verified: boolean;&#10;}' >SomeUserMail</data-lsp></span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> { <data-lsp lsp='(property) content: string' >content</data-lsp>: </span><span style="color: #96D0FF">&apos;some-email&apos;</span><span style="color: #ADBAC7">, <data-lsp lsp='(property) verified: boolean' >verified</data-lsp>: </span><span style="color: #6CB6FF">true</span><span style="color: #ADBAC7"> }</span></div></code></div></pre>
<pre class="shiki github-light twoslash lsp" style="background-color: #fff; color: #24292e"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #D73A49">type</span><span style="color: #24292E"> </span><span style="color: #6F42C1"><data-lsp lsp='type SomeString = string' >SomeString</data-lsp></span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #005CC5">string</span></div><div class='line'><span style="color: #D73A49">type</span><span style="color: #24292E"> </span><span style="color: #6F42C1"><data-lsp lsp='type SomeUser = {&#10;    name: string;&#10;    mail?: SomeUserMail | undefined;&#10;}' >SomeUser</data-lsp></span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> { </span><span style="color: #E36209"><data-lsp lsp='(property) name: string' >name</data-lsp></span><span style="color: #D73A49">:</span><span style="color: #24292E"> </span><span style="color: #005CC5">string</span><span style="color: #24292E">; </span><span style="color: #E36209"><data-lsp lsp='(property) mail?: SomeUserMail | undefined' >mail</data-lsp></span><span style="color: #D73A49">?:</span><span style="color: #24292E"> </span><span style="color: #6F42C1"><data-lsp lsp='type SomeUserMail = {&#10;    content: string;&#10;    verified: boolean;&#10;}' >SomeUserMail</data-lsp></span><span style="color: #24292E"> }</span></div><div class='line'><span style="color: #D73A49">type</span><span style="color: #24292E"> </span><span style="color: #6F42C1"><data-lsp lsp='type SomeUserMail = {&#10;    content: string;&#10;    verified: boolean;&#10;}' >SomeUserMail</data-lsp></span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> { </span><span style="color: #E36209"><data-lsp lsp='(property) content: string' >content</data-lsp></span><span style="color: #D73A49">:</span><span style="color: #24292E"> </span><span style="color: #005CC5">string</span><span style="color: #24292E">; </span><span style="color: #E36209"><data-lsp lsp='(property) verified: boolean' >verified</data-lsp></span><span style="color: #D73A49">:</span><span style="color: #24292E"> </span><span style="color: #005CC5">boolean</span><span style="color: #24292E"> }</span></div><div class='line'><span style="color: #D73A49">const</span><span style="color: #24292E"> </span><span style="color: #005CC5"><data-lsp lsp='const mail: SomeUserMail' >mail</data-lsp></span><span style="color: #D73A49">:</span><span style="color: #24292E"> </span><span style="color: #6F42C1"><data-lsp lsp='type SomeUserMail = {&#10;    content: string;&#10;    verified: boolean;&#10;}' >SomeUserMail</data-lsp></span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> { <data-lsp lsp='(property) content: string' >content</data-lsp>: </span><span style="color: #032F62">&apos;some-email&apos;</span><span style="color: #24292E">, <data-lsp lsp='(property) verified: boolean' >verified</data-lsp>: </span><span style="color: #005CC5">true</span><span style="color: #24292E"> }</span></div></code></div></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="language-md vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">md</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">```twoslash include myBlockWithSteps</span></span>
<span class="line"><span style="color: #ADBAC7">type SomeString = string</span></span>
<span class="line"><span style="color: #ADBAC7">// - base</span></span>
<span class="line"><span style="color: #ADBAC7">type SomeUser = { name: string; mail?: SomeUserMail }</span></span>
<span class="line"><span style="color: #ADBAC7">type SomeUserMail = { content: string; verified: boolean }</span></span>
<span class="line"><span style="color: #ADBAC7">// - afterUserDefinitions</span></span>
<span class="line"><span style="color: #ADBAC7">type SomeGroup = { name: string; members: SomeUser[] }</span></span>
<span class="line"><span style="color: #ADBAC7">// - afterGroupDefinitions</span></span>
<span class="line"><span style="color: #ADBAC7">```</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">```ts twoslash</span></span>
<span class="line"><span style="color: #768390">// @include: myBlockWithSteps-afterUserDefinitions</span></span>
<span class="line"><span style="color: #F47067">const</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">mail</span><span style="color: #F47067">:</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50">SomeUserMail</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> { content: </span><span style="color: #96D0FF">&#39;some-email&#39;</span><span style="color: #ADBAC7">, verified: </span><span style="color: #6CB6FF">true</span><span style="color: #ADBAC7"> }</span></span>
<span class="line"><span style="color: #ADBAC7">```</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">```twoslash include myBlockWithSteps</span></span>
<span class="line"><span style="color: #24292E">type SomeString = string</span></span>
<span class="line"><span style="color: #24292E">// - base</span></span>
<span class="line"><span style="color: #24292E">type SomeUser = { name: string; mail?: SomeUserMail }</span></span>
<span class="line"><span style="color: #24292E">type SomeUserMail = { content: string; verified: boolean }</span></span>
<span class="line"><span style="color: #24292E">// - afterUserDefinitions</span></span>
<span class="line"><span style="color: #24292E">type SomeGroup = { name: string; members: SomeUser[] }</span></span>
<span class="line"><span style="color: #24292E">// - afterGroupDefinitions</span></span>
<span class="line"><span style="color: #24292E">```</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">```ts twoslash</span></span>
<span class="line"><span style="color: #6A737D">// @include: myBlockWithSteps-afterUserDefinitions</span></span>
<span class="line"><span style="color: #D73A49">const</span><span style="color: #24292E"> </span><span style="color: #005CC5">mail</span><span style="color: #D73A49">:</span><span style="color: #24292E"> </span><span style="color: #6F42C1">SomeUserMail</span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> { content: </span><span style="color: #032F62">&#39;some-email&#39;</span><span style="color: #24292E">, verified: </span><span style="color: #005CC5">true</span><span style="color: #24292E"> }</span></span>
<span class="line"><span style="color: #24292E">```</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br></div></div></div></div>
<h2 id="hiding-re-used-code" tabindex="-1">Hiding re-used code <a class="header-anchor" href="#hiding-re-used-code" aria-label="Permalink to &quot;Hiding re-used code&quot;">&ZeroWidthSpace;</a></h2>
<p>Re-using a lot of TypeScript code can easily bloat your documentation and obstruct the main point of your code block. You can hide re-used code to keep your code blocks clean and concise by <a href="./cutting.html">cutting</a> right after the <code>@include</code> statement.</p>
<div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-cwJ3v" id="tab-HX3he0W" checked="checked"><label for="tab-HX3he0W">output</label><input type="radio" name="group-cwJ3v" id="tab-kiL-bbm" ><label for="tab-kiL-bbm">markdown</label></div><div class="blocks">
<div class="language-ts vp-adaptive-theme active line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki github-dark-dimmed twoslash lsp" style="background-color: #22272e; color: #adbac7"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #F47067">const</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF"><data-lsp lsp='const mail: SomeUserMail' >mail</data-lsp></span><span style="color: #F47067">:</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50"><data-lsp lsp='type SomeUserMail = {&#10;    content: string;&#10;    verified: boolean;&#10;}' >SomeUserMail</data-lsp></span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> { <data-lsp lsp='(property) content: string' >content</data-lsp>: </span><span style="color: #96D0FF">&apos;some-email&apos;</span><span style="color: #ADBAC7">, <data-lsp lsp='(property) verified: boolean' >verified</data-lsp>: </span><span style="color: #6CB6FF">true</span><span style="color: #ADBAC7"> }</span></div></code></div></pre>
<pre class="shiki github-light twoslash lsp" style="background-color: #fff; color: #24292e"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #D73A49">const</span><span style="color: #24292E"> </span><span style="color: #005CC5"><data-lsp lsp='const mail: SomeUserMail' >mail</data-lsp></span><span style="color: #D73A49">:</span><span style="color: #24292E"> </span><span style="color: #6F42C1"><data-lsp lsp='type SomeUserMail = {&#10;    content: string;&#10;    verified: boolean;&#10;}' >SomeUserMail</data-lsp></span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> { <data-lsp lsp='(property) content: string' >content</data-lsp>: </span><span style="color: #032F62">&apos;some-email&apos;</span><span style="color: #24292E">, <data-lsp lsp='(property) verified: boolean' >verified</data-lsp>: </span><span style="color: #005CC5">true</span><span style="color: #24292E"> }</span></div></code></div></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="language-md vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">md</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">```twoslash include myBlockWithSteps</span></span>
<span class="line"><span style="color: #ADBAC7">type SomeString = string</span></span>
<span class="line"><span style="color: #ADBAC7">// - base</span></span>
<span class="line"><span style="color: #ADBAC7">type SomeUser = { name: string; mail?: SomeUserMail }</span></span>
<span class="line"><span style="color: #ADBAC7">type SomeUserMail = { content: string; verified: boolean }</span></span>
<span class="line"><span style="color: #ADBAC7">// - afterUserDefinitions</span></span>
<span class="line"><span style="color: #ADBAC7">type SomeGroup = { name: string; members: SomeUser[] }</span></span>
<span class="line"><span style="color: #ADBAC7">// - afterGroupDefinitions</span></span>
<span class="line"><span style="color: #ADBAC7">```</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">```ts twoslash</span></span>
<span class="line"><span style="color: #768390">// @include: myBlockWithSteps-afterUserDefinitions</span></span>
<span class="line"><span style="color: #768390">// ---cut---</span></span>
<span class="line"><span style="color: #F47067">const</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">mail</span><span style="color: #F47067">:</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50">SomeUserMail</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> { content: </span><span style="color: #96D0FF">&#39;some-email&#39;</span><span style="color: #ADBAC7">, verified: </span><span style="color: #6CB6FF">true</span><span style="color: #ADBAC7"> }</span></span>
<span class="line"><span style="color: #ADBAC7">```</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">```twoslash include myBlockWithSteps</span></span>
<span class="line"><span style="color: #24292E">type SomeString = string</span></span>
<span class="line"><span style="color: #24292E">// - base</span></span>
<span class="line"><span style="color: #24292E">type SomeUser = { name: string; mail?: SomeUserMail }</span></span>
<span class="line"><span style="color: #24292E">type SomeUserMail = { content: string; verified: boolean }</span></span>
<span class="line"><span style="color: #24292E">// - afterUserDefinitions</span></span>
<span class="line"><span style="color: #24292E">type SomeGroup = { name: string; members: SomeUser[] }</span></span>
<span class="line"><span style="color: #24292E">// - afterGroupDefinitions</span></span>
<span class="line"><span style="color: #24292E">```</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">```ts twoslash</span></span>
<span class="line"><span style="color: #6A737D">// @include: myBlockWithSteps-afterUserDefinitions</span></span>
<span class="line"><span style="color: #6A737D">// ---cut---</span></span>
<span class="line"><span style="color: #D73A49">const</span><span style="color: #24292E"> </span><span style="color: #005CC5">mail</span><span style="color: #D73A49">:</span><span style="color: #24292E"> </span><span style="color: #6F42C1">SomeUserMail</span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> { content: </span><span style="color: #032F62">&#39;some-email&#39;</span><span style="color: #24292E">, verified: </span><span style="color: #005CC5">true</span><span style="color: #24292E"> }</span></span>
<span class="line"><span style="color: #24292E">```</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br></div></div></div></div>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Logging]]></title>
            <link>https://note.toshiki.devapplication/vitepress-plugin-shiki-twoslash/api/logging</link>
            <guid>https://note.toshiki.devapplication/vitepress-plugin-shiki-twoslash/api/logging</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="logging" tabindex="-1">Logging <a class="header-anchor" href="#logging" aria-label="Permalink to &quot;Logging&quot;">&ZeroWidthSpace;</a></h1>
<p>When you first see a Twoslash code example with an inline compiler error, you instinctively trust that the compiler error is correct because the design shows that it is not a part of the code sample. The logging tools lets you do that, but abuses the systemic trust because your code is not being evaluated to generate the logs.</p>
<p>This feature is effectively a facade, people will trust your output and it will look better.</p>
<h2 id="log-warn-error" tabindex="-1"><code>@log:</code>, <code>@warn:</code>, <code>@error:</code> <a class="header-anchor" href="#log-warn-error" aria-label="Permalink to &quot;`@log:`, `@warn:`, `@error:`&quot;">&ZeroWidthSpace;</a></h2>
<p>The names are based on the functions on the <code>console</code> object:</p>
<div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-StbB_" id="tab-g0PhNbi" checked="checked"><label for="tab-g0PhNbi">output</label><input type="radio" name="group-StbB_" id="tab-P3K1OBE" ><label for="tab-P3K1OBE">markdown</label></div><div class="blocks">
<div class="language-ts vp-adaptive-theme active line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre><code class="language-ts"><div class='tag-container'><pre class="shiki github-dark-dimmed twoslash lsp" style="background-color: #22272e; color: #adbac7"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #ADBAC7"><data-lsp lsp='var console: Console' >console</data-lsp>.</span><span style="color: #DCBDFB"><data-lsp lsp='(method) Console.log(...data: any[]): void' >log</data-lsp></span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&apos;Hello log&apos;</span><span style="color: #ADBAC7">)</span></div><div class='meta-line logger log-log'><svg width="12" height="15" viewBox="0 0 12 15" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M5.76822 0.359816C5.41466 -0.0644613 4.78409 -0.121785 4.35982 0.231779C3.93554 0.585343 3.87821 1.21591 4.23178 1.64018L5.76822 0.359816ZM10 7L10.7926 7.60971L11.2809 6.97499L10.7682 6.35982L10 7ZM4.20738 12.8903C3.87064 13.328 3.95254 13.9559 4.39029 14.2926C4.82804 14.6294 5.45589 14.5475 5.79262 14.1097L4.20738 12.8903ZM4.23178 1.64018L9.23178 7.64018L10.7682 6.35982L5.76822 0.359816L4.23178 1.64018ZM9.20738 6.39029L4.20738 12.8903L5.79262 14.1097L10.7926 7.60971L9.20738 6.39029Z" fill="#BDBDBD"/><line y1="3.5" x2="4" y2="3.5" stroke="#BDBDBD"/><path d="M0 7H4" stroke="#BDBDBD"/><line y1="10.5" x2="4" y2="10.5" stroke="#BDBDBD"/></svg><span class='message'>Hello log</span></div><div class='line'>&nbsp;</div><div class='line'><span style="color: #ADBAC7"><data-lsp lsp='var console: Console' >console</data-lsp>.</span><span style="color: #DCBDFB"><data-lsp lsp='(method) Console.warn(...data: any[]): void' >warn</data-lsp></span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&apos;Hello warn&apos;</span><span style="color: #ADBAC7">)</span></div><div class='meta-line logger warn-log'><svg width="21" height="18" viewBox="0 0 21 18" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M9.63401 0.5C10.0189 -0.166667 10.9812 -0.166667 11.3661 0.5L20.4593 16.25C20.8442 16.9167 20.3631 17.75 19.5933 17.75H1.40676C0.636965 17.75 0.15584 16.9167 0.54074 16.25L9.63401 0.5Z" fill="#E5A604"/><rect x="9" y="4" width="3" height="7" fill="white"/><rect x="9" y="13" width="3" height="3" fill="white"/></svg><span class='message'>Hello warn</span></div><div class='line'>&nbsp;</div><div class='line'><span style="color: #ADBAC7"><data-lsp lsp='var console: Console' >console</data-lsp>.</span><span style="color: #DCBDFB"><data-lsp lsp='(method) Console.error(...data: any[]): void' >error</data-lsp></span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&apos;Hello error&apos;</span><span style="color: #ADBAC7">)</span></div><div class='meta-line logger error-log'><svg width="19" height="19" viewBox="0 0 19 19" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M4.63018 1.29289L1.29289 4.63018C1.10536 4.81772 1 5.07207 1 5.33729V13.6627C1 13.9279 1.10536 14.1823 1.29289 14.3698L4.63018 17.7071C4.81772 17.8946 5.07207 18 5.33729 18H13.6627C13.9279 18 14.1823 17.8946 14.3698 17.7071L17.7071 14.3698C17.8946 14.1823 18 13.9279 18 13.6627V5.33729C18 5.07207 17.8946 4.81772 17.7071 4.63018L14.3698 1.29289C14.1823 1.10536 13.9279 1 13.6627 1H5.33729C5.07207 1 4.81772 1.10536 4.63018 1.29289Z" fill="#E72622" stroke="#E72622"/><rect x="8" y="4" width="3" height="7" fill="white"/><rect x="8" y="13" width="3" height="3" fill="white"/></svg><span class='message'>Hello error</span></div></code></div></pre></div>
<div class='tag-container'><pre class="shiki github-light twoslash lsp" style="background-color: #fff; color: #24292e"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #24292E"><data-lsp lsp='var console: Console' >console</data-lsp>.</span><span style="color: #6F42C1"><data-lsp lsp='(method) Console.log(...data: any[]): void' >log</data-lsp></span><span style="color: #24292E">(</span><span style="color: #032F62">&apos;Hello log&apos;</span><span style="color: #24292E">)</span></div><div class='meta-line logger log-log'><svg width="12" height="15" viewBox="0 0 12 15" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M5.76822 0.359816C5.41466 -0.0644613 4.78409 -0.121785 4.35982 0.231779C3.93554 0.585343 3.87821 1.21591 4.23178 1.64018L5.76822 0.359816ZM10 7L10.7926 7.60971L11.2809 6.97499L10.7682 6.35982L10 7ZM4.20738 12.8903C3.87064 13.328 3.95254 13.9559 4.39029 14.2926C4.82804 14.6294 5.45589 14.5475 5.79262 14.1097L4.20738 12.8903ZM4.23178 1.64018L9.23178 7.64018L10.7682 6.35982L5.76822 0.359816L4.23178 1.64018ZM9.20738 6.39029L4.20738 12.8903L5.79262 14.1097L10.7926 7.60971L9.20738 6.39029Z" fill="#BDBDBD"/><line y1="3.5" x2="4" y2="3.5" stroke="#BDBDBD"/><path d="M0 7H4" stroke="#BDBDBD"/><line y1="10.5" x2="4" y2="10.5" stroke="#BDBDBD"/></svg><span class='message'>Hello log</span></div><div class='line'>&nbsp;</div><div class='line'><span style="color: #24292E"><data-lsp lsp='var console: Console' >console</data-lsp>.</span><span style="color: #6F42C1"><data-lsp lsp='(method) Console.warn(...data: any[]): void' >warn</data-lsp></span><span style="color: #24292E">(</span><span style="color: #032F62">&apos;Hello warn&apos;</span><span style="color: #24292E">)</span></div><div class='meta-line logger warn-log'><svg width="21" height="18" viewBox="0 0 21 18" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M9.63401 0.5C10.0189 -0.166667 10.9812 -0.166667 11.3661 0.5L20.4593 16.25C20.8442 16.9167 20.3631 17.75 19.5933 17.75H1.40676C0.636965 17.75 0.15584 16.9167 0.54074 16.25L9.63401 0.5Z" fill="#E5A604"/><rect x="9" y="4" width="3" height="7" fill="white"/><rect x="9" y="13" width="3" height="3" fill="white"/></svg><span class='message'>Hello warn</span></div><div class='line'>&nbsp;</div><div class='line'><span style="color: #24292E"><data-lsp lsp='var console: Console' >console</data-lsp>.</span><span style="color: #6F42C1"><data-lsp lsp='(method) Console.error(...data: any[]): void' >error</data-lsp></span><span style="color: #24292E">(</span><span style="color: #032F62">&apos;Hello error&apos;</span><span style="color: #24292E">)</span></div><div class='meta-line logger error-log'><svg width="19" height="19" viewBox="0 0 19 19" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M4.63018 1.29289L1.29289 4.63018C1.10536 4.81772 1 5.07207 1 5.33729V13.6627C1 13.9279 1.10536 14.1823 1.29289 14.3698L4.63018 17.7071C4.81772 17.8946 5.07207 18 5.33729 18H13.6627C13.9279 18 14.1823 17.8946 14.3698 17.7071L17.7071 14.3698C17.8946 14.1823 18 13.9279 18 13.6627V5.33729C18 5.07207 17.8946 4.81772 17.7071 4.63018L14.3698 1.29289C14.1823 1.10536 13.9279 1 13.6627 1H5.33729C5.07207 1 4.81772 1.10536 4.63018 1.29289Z" fill="#E72622" stroke="#E72622"/><rect x="8" y="4" width="3" height="7" fill="white"/><rect x="8" y="13" width="3" height="3" fill="white"/></svg><span class='message'>Hello error</span></div></code></div></pre></div></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="language-md vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">md</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">```ts twoslash</span></span>
<span class="line"><span style="color: #ADBAC7">console.</span><span style="color: #DCBDFB">log</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&#39;Hello log&#39;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #768390">// @log: Hello log</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">console.</span><span style="color: #DCBDFB">warn</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&#39;Hello warn&#39;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #768390">// @warn: Hello warn</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">console.</span><span style="color: #DCBDFB">error</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&#39;Hello error&#39;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #768390">// @error: Hello error</span></span>
<span class="line"><span style="color: #ADBAC7">```</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">```ts twoslash</span></span>
<span class="line"><span style="color: #24292E">console.</span><span style="color: #6F42C1">log</span><span style="color: #24292E">(</span><span style="color: #032F62">&#39;Hello log&#39;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #6A737D">// @log: Hello log</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">console.</span><span style="color: #6F42C1">warn</span><span style="color: #24292E">(</span><span style="color: #032F62">&#39;Hello warn&#39;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #6A737D">// @warn: Hello warn</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">console.</span><span style="color: #6F42C1">error</span><span style="color: #24292E">(</span><span style="color: #032F62">&#39;Hello error&#39;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #6A737D">// @error: Hello error</span></span>
<span class="line"><span style="color: #24292E">```</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br></div></div></div></div>
]]></description>
            <content:encoded><![CDATA[<h1 id="logging" tabindex="-1">Logging <a class="header-anchor" href="#logging" aria-label="Permalink to &quot;Logging&quot;">&ZeroWidthSpace;</a></h1>
<p>When you first see a Twoslash code example with an inline compiler error, you instinctively trust that the compiler error is correct because the design shows that it is not a part of the code sample. The logging tools lets you do that, but abuses the systemic trust because your code is not being evaluated to generate the logs.</p>
<p>This feature is effectively a facade, people will trust your output and it will look better.</p>
<h2 id="log-warn-error" tabindex="-1"><code>@log:</code>, <code>@warn:</code>, <code>@error:</code> <a class="header-anchor" href="#log-warn-error" aria-label="Permalink to &quot;`@log:`, `@warn:`, `@error:`&quot;">&ZeroWidthSpace;</a></h2>
<p>The names are based on the functions on the <code>console</code> object:</p>
<div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-StbB_" id="tab-g0PhNbi" checked="checked"><label for="tab-g0PhNbi">output</label><input type="radio" name="group-StbB_" id="tab-P3K1OBE" ><label for="tab-P3K1OBE">markdown</label></div><div class="blocks">
<div class="language-ts vp-adaptive-theme active line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre><code class="language-ts"><div class='tag-container'><pre class="shiki github-dark-dimmed twoslash lsp" style="background-color: #22272e; color: #adbac7"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #ADBAC7"><data-lsp lsp='var console: Console' >console</data-lsp>.</span><span style="color: #DCBDFB"><data-lsp lsp='(method) Console.log(...data: any[]): void' >log</data-lsp></span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&apos;Hello log&apos;</span><span style="color: #ADBAC7">)</span></div><div class='meta-line logger log-log'><svg width="12" height="15" viewBox="0 0 12 15" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M5.76822 0.359816C5.41466 -0.0644613 4.78409 -0.121785 4.35982 0.231779C3.93554 0.585343 3.87821 1.21591 4.23178 1.64018L5.76822 0.359816ZM10 7L10.7926 7.60971L11.2809 6.97499L10.7682 6.35982L10 7ZM4.20738 12.8903C3.87064 13.328 3.95254 13.9559 4.39029 14.2926C4.82804 14.6294 5.45589 14.5475 5.79262 14.1097L4.20738 12.8903ZM4.23178 1.64018L9.23178 7.64018L10.7682 6.35982L5.76822 0.359816L4.23178 1.64018ZM9.20738 6.39029L4.20738 12.8903L5.79262 14.1097L10.7926 7.60971L9.20738 6.39029Z" fill="#BDBDBD"/><line y1="3.5" x2="4" y2="3.5" stroke="#BDBDBD"/><path d="M0 7H4" stroke="#BDBDBD"/><line y1="10.5" x2="4" y2="10.5" stroke="#BDBDBD"/></svg><span class='message'>Hello log</span></div><div class='line'>&nbsp;</div><div class='line'><span style="color: #ADBAC7"><data-lsp lsp='var console: Console' >console</data-lsp>.</span><span style="color: #DCBDFB"><data-lsp lsp='(method) Console.warn(...data: any[]): void' >warn</data-lsp></span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&apos;Hello warn&apos;</span><span style="color: #ADBAC7">)</span></div><div class='meta-line logger warn-log'><svg width="21" height="18" viewBox="0 0 21 18" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M9.63401 0.5C10.0189 -0.166667 10.9812 -0.166667 11.3661 0.5L20.4593 16.25C20.8442 16.9167 20.3631 17.75 19.5933 17.75H1.40676C0.636965 17.75 0.15584 16.9167 0.54074 16.25L9.63401 0.5Z" fill="#E5A604"/><rect x="9" y="4" width="3" height="7" fill="white"/><rect x="9" y="13" width="3" height="3" fill="white"/></svg><span class='message'>Hello warn</span></div><div class='line'>&nbsp;</div><div class='line'><span style="color: #ADBAC7"><data-lsp lsp='var console: Console' >console</data-lsp>.</span><span style="color: #DCBDFB"><data-lsp lsp='(method) Console.error(...data: any[]): void' >error</data-lsp></span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&apos;Hello error&apos;</span><span style="color: #ADBAC7">)</span></div><div class='meta-line logger error-log'><svg width="19" height="19" viewBox="0 0 19 19" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M4.63018 1.29289L1.29289 4.63018C1.10536 4.81772 1 5.07207 1 5.33729V13.6627C1 13.9279 1.10536 14.1823 1.29289 14.3698L4.63018 17.7071C4.81772 17.8946 5.07207 18 5.33729 18H13.6627C13.9279 18 14.1823 17.8946 14.3698 17.7071L17.7071 14.3698C17.8946 14.1823 18 13.9279 18 13.6627V5.33729C18 5.07207 17.8946 4.81772 17.7071 4.63018L14.3698 1.29289C14.1823 1.10536 13.9279 1 13.6627 1H5.33729C5.07207 1 4.81772 1.10536 4.63018 1.29289Z" fill="#E72622" stroke="#E72622"/><rect x="8" y="4" width="3" height="7" fill="white"/><rect x="8" y="13" width="3" height="3" fill="white"/></svg><span class='message'>Hello error</span></div></code></div></pre></div>
<div class='tag-container'><pre class="shiki github-light twoslash lsp" style="background-color: #fff; color: #24292e"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #24292E"><data-lsp lsp='var console: Console' >console</data-lsp>.</span><span style="color: #6F42C1"><data-lsp lsp='(method) Console.log(...data: any[]): void' >log</data-lsp></span><span style="color: #24292E">(</span><span style="color: #032F62">&apos;Hello log&apos;</span><span style="color: #24292E">)</span></div><div class='meta-line logger log-log'><svg width="12" height="15" viewBox="0 0 12 15" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M5.76822 0.359816C5.41466 -0.0644613 4.78409 -0.121785 4.35982 0.231779C3.93554 0.585343 3.87821 1.21591 4.23178 1.64018L5.76822 0.359816ZM10 7L10.7926 7.60971L11.2809 6.97499L10.7682 6.35982L10 7ZM4.20738 12.8903C3.87064 13.328 3.95254 13.9559 4.39029 14.2926C4.82804 14.6294 5.45589 14.5475 5.79262 14.1097L4.20738 12.8903ZM4.23178 1.64018L9.23178 7.64018L10.7682 6.35982L5.76822 0.359816L4.23178 1.64018ZM9.20738 6.39029L4.20738 12.8903L5.79262 14.1097L10.7926 7.60971L9.20738 6.39029Z" fill="#BDBDBD"/><line y1="3.5" x2="4" y2="3.5" stroke="#BDBDBD"/><path d="M0 7H4" stroke="#BDBDBD"/><line y1="10.5" x2="4" y2="10.5" stroke="#BDBDBD"/></svg><span class='message'>Hello log</span></div><div class='line'>&nbsp;</div><div class='line'><span style="color: #24292E"><data-lsp lsp='var console: Console' >console</data-lsp>.</span><span style="color: #6F42C1"><data-lsp lsp='(method) Console.warn(...data: any[]): void' >warn</data-lsp></span><span style="color: #24292E">(</span><span style="color: #032F62">&apos;Hello warn&apos;</span><span style="color: #24292E">)</span></div><div class='meta-line logger warn-log'><svg width="21" height="18" viewBox="0 0 21 18" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M9.63401 0.5C10.0189 -0.166667 10.9812 -0.166667 11.3661 0.5L20.4593 16.25C20.8442 16.9167 20.3631 17.75 19.5933 17.75H1.40676C0.636965 17.75 0.15584 16.9167 0.54074 16.25L9.63401 0.5Z" fill="#E5A604"/><rect x="9" y="4" width="3" height="7" fill="white"/><rect x="9" y="13" width="3" height="3" fill="white"/></svg><span class='message'>Hello warn</span></div><div class='line'>&nbsp;</div><div class='line'><span style="color: #24292E"><data-lsp lsp='var console: Console' >console</data-lsp>.</span><span style="color: #6F42C1"><data-lsp lsp='(method) Console.error(...data: any[]): void' >error</data-lsp></span><span style="color: #24292E">(</span><span style="color: #032F62">&apos;Hello error&apos;</span><span style="color: #24292E">)</span></div><div class='meta-line logger error-log'><svg width="19" height="19" viewBox="0 0 19 19" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M4.63018 1.29289L1.29289 4.63018C1.10536 4.81772 1 5.07207 1 5.33729V13.6627C1 13.9279 1.10536 14.1823 1.29289 14.3698L4.63018 17.7071C4.81772 17.8946 5.07207 18 5.33729 18H13.6627C13.9279 18 14.1823 17.8946 14.3698 17.7071L17.7071 14.3698C17.8946 14.1823 18 13.9279 18 13.6627V5.33729C18 5.07207 17.8946 4.81772 17.7071 4.63018L14.3698 1.29289C14.1823 1.10536 13.9279 1 13.6627 1H5.33729C5.07207 1 4.81772 1.10536 4.63018 1.29289Z" fill="#E72622" stroke="#E72622"/><rect x="8" y="4" width="3" height="7" fill="white"/><rect x="8" y="13" width="3" height="3" fill="white"/></svg><span class='message'>Hello error</span></div></code></div></pre></div></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="language-md vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">md</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">```ts twoslash</span></span>
<span class="line"><span style="color: #ADBAC7">console.</span><span style="color: #DCBDFB">log</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&#39;Hello log&#39;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #768390">// @log: Hello log</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">console.</span><span style="color: #DCBDFB">warn</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&#39;Hello warn&#39;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #768390">// @warn: Hello warn</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">console.</span><span style="color: #DCBDFB">error</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&#39;Hello error&#39;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #768390">// @error: Hello error</span></span>
<span class="line"><span style="color: #ADBAC7">```</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">```ts twoslash</span></span>
<span class="line"><span style="color: #24292E">console.</span><span style="color: #6F42C1">log</span><span style="color: #24292E">(</span><span style="color: #032F62">&#39;Hello log&#39;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #6A737D">// @log: Hello log</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">console.</span><span style="color: #6F42C1">warn</span><span style="color: #24292E">(</span><span style="color: #032F62">&#39;Hello warn&#39;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #6A737D">// @warn: Hello warn</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">console.</span><span style="color: #6F42C1">error</span><span style="color: #24292E">(</span><span style="color: #032F62">&#39;Hello error&#39;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #6A737D">// @error: Hello error</span></span>
<span class="line"><span style="color: #24292E">```</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br></div></div></div></div>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Multi-file]]></title>
            <link>https://note.toshiki.devapplication/vitepress-plugin-shiki-twoslash/api/multi-file</link>
            <guid>https://note.toshiki.devapplication/vitepress-plugin-shiki-twoslash/api/multi-file</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="multi-file" tabindex="-1">Multi-file <a class="header-anchor" href="#multi-file" aria-label="Permalink to &quot;Multi-file&quot;">&ZeroWidthSpace;</a></h1>
<p>Twoslash code examples aren't limited to creating a single file, by using <code>// @filename: [file]</code> you can write any file to the virtual file system used by TypeScript to power your code examples.</p>
<h2 id="filename-file" tabindex="-1"><code>@filename: [file]</code> <a class="header-anchor" href="#filename-file" aria-label="Permalink to &quot;`@filename: [file]`&quot;">&ZeroWidthSpace;</a></h2>
<p>Most of the time, you don't need to think about the underlaying virtual file system in a code example, but when you have imports between them it becomes important to know. Twoslash will default to creating an <code>index.[type]</code> based on the langauge passed to the code example:</p>
<div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-JYbTA" id="tab-_3hBfGr" checked="checked"><label for="tab-_3hBfGr">output</label><input type="radio" name="group-JYbTA" id="tab-iLUf-SA" ><label for="tab-iLUf-SA">markdown</label></div><div class="blocks">
<div class="language-ts vp-adaptive-theme active line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki github-dark-dimmed twoslash lsp" style="background-color: #22272e; color: #adbac7"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #768390">// I&apos;m index.ts</span></div></code></div></pre>
<pre class="shiki github-light twoslash lsp" style="background-color: #fff; color: #24292e"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #6A737D">// I&apos;m index.ts</span></div></code></div></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="language-md vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">md</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">```ts twoslash</span></span>
<span class="line"><span style="color: #768390">// I&#39;m index.ts</span></span>
<span class="line"><span style="color: #ADBAC7">```</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">```ts twoslash</span></span>
<span class="line"><span style="color: #6A737D">// I&#39;m index.ts</span></span>
<span class="line"><span style="color: #24292E">```</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div></div></div>
<div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-Uwtkr" id="tab-yxyo5fz" checked="checked"><label for="tab-yxyo5fz">output</label><input type="radio" name="group-Uwtkr" id="tab-sXwnTb4" ><label for="tab-sXwnTb4">markdown</label></div><div class="blocks">
<div class="language-tsx vp-adaptive-theme active line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">tsx</span><pre class="shiki github-dark-dimmed twoslash lsp" style="background-color: #22272e; color: #adbac7"><div class="language-id">tsx</div><div class='code-container'><code><div class='line'><span style="color: #768390">// I&apos;m index.tsx</span></div></code></div></pre>
<pre class="shiki github-light twoslash lsp" style="background-color: #fff; color: #24292e"><div class="language-id">tsx</div><div class='code-container'><code><div class='line'><span style="color: #6A737D">// I&apos;m index.tsx</span></div></code></div></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="language-md vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">md</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">```tsx twoslash</span></span>
<span class="line"><span style="color: #768390">// I&#39;m index.tsx</span></span>
<span class="line"><span style="color: #ADBAC7">```</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">```tsx twoslash</span></span>
<span class="line"><span style="color: #6A737D">// I&#39;m index.tsx</span></span>
<span class="line"><span style="color: #24292E">```</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div></div></div>
<div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-753eC" id="tab-Iw9O0a9" checked="checked"><label for="tab-Iw9O0a9">output</label><input type="radio" name="group-753eC" id="tab-f9nHsk2" ><label for="tab-f9nHsk2">markdown</label></div><div class="blocks">
<div class="language-js vp-adaptive-theme active line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">js</span><pre class="shiki github-dark-dimmed twoslash lsp" style="background-color: #22272e; color: #adbac7"><div class="language-id">js</div><div class='code-container'><code><div class='line'><span style="color: #768390">// I&apos;m index.tjs</span></div></code></div></pre>
<pre class="shiki github-light twoslash lsp" style="background-color: #fff; color: #24292e"><div class="language-id">js</div><div class='code-container'><code><div class='line'><span style="color: #6A737D">// I&apos;m index.tjs</span></div></code></div></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="language-md vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">md</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">```js twoslash</span></span>
<span class="line"><span style="color: #768390">// I&#39;m index.tjs</span></span>
<span class="line"><span style="color: #ADBAC7">```</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">```js twoslash</span></span>
<span class="line"><span style="color: #6A737D">// I&#39;m index.tjs</span></span>
<span class="line"><span style="color: #24292E">```</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div></div></div>
<p>Then until Twoslash hits another <code>// @filename: [file]</code>, the parser keeps adding new lines into the same file. After seeing <code>@filename</code> Twoslash creates a new virtual file-system file and adds the new lines to that. You can't edit a file after it was created, but you can overwrite it.</p>
<p>It can be any file. For example, if you want to quickly fake a node module:</p>
<div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-DbGDQ" id="tab-Jaw61ll" checked="checked"><label for="tab-Jaw61ll">output</label><input type="radio" name="group-DbGDQ" id="tab-N32UIIb" ><label for="tab-N32UIIb">markdown</label></div><div class="blocks">
<div class="language-ts vp-adaptive-theme active line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki github-dark-dimmed twoslash lsp" style="background-color: #22272e; color: #adbac7"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #768390">// @filename: node_modules/@types/mylib/index.d.ts</span></div><div class='line'><span style="color: #F47067">export</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">function</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB"><data-lsp lsp='function doit(): string' >doit</data-lsp></span><span style="color: #ADBAC7">()</span><span style="color: #F47067">:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">string</span></div><div class='line'>&nbsp;</div><div class='line'><span style="color: #768390">// @filename: index.ts</span></div><div class='line'><span style="color: #F47067">import</span><span style="color: #ADBAC7"> { <data-lsp lsp='(alias) function doit(): string&#10;import doit' >doit</data-lsp> } </span><span style="color: #F47067">from</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&apos;mylib&apos;</span></div><div class='line'><span style="color: #ADBAC7"><data-lsp lsp='var console: Console' >console</data-lsp>.</span><span style="color: #DCBDFB"><data-lsp lsp='(method) Console.log(...data: any[]): void' >log</data-lsp></span><span style="color: #ADBAC7">(<data-lsp lsp='(alias) function doit(): string&#10;import doit' >doit</data-lsp>)</span></div></code></div></pre>
<pre class="shiki github-light twoslash lsp" style="background-color: #fff; color: #24292e"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #6A737D">// @filename: node_modules/@types/mylib/index.d.ts</span></div><div class='line'><span style="color: #D73A49">export</span><span style="color: #24292E"> </span><span style="color: #D73A49">function</span><span style="color: #24292E"> </span><span style="color: #6F42C1"><data-lsp lsp='function doit(): string' >doit</data-lsp></span><span style="color: #24292E">()</span><span style="color: #D73A49">:</span><span style="color: #24292E"> </span><span style="color: #005CC5">string</span></div><div class='line'>&nbsp;</div><div class='line'><span style="color: #6A737D">// @filename: index.ts</span></div><div class='line'><span style="color: #D73A49">import</span><span style="color: #24292E"> { <data-lsp lsp='(alias) function doit(): string&#10;import doit' >doit</data-lsp> } </span><span style="color: #D73A49">from</span><span style="color: #24292E"> </span><span style="color: #032F62">&apos;mylib&apos;</span></div><div class='line'><span style="color: #24292E"><data-lsp lsp='var console: Console' >console</data-lsp>.</span><span style="color: #6F42C1"><data-lsp lsp='(method) Console.log(...data: any[]): void' >log</data-lsp></span><span style="color: #24292E">(<data-lsp lsp='(alias) function doit(): string&#10;import doit' >doit</data-lsp>)</span></div></code></div></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>This code example sets up the types for a non-existent npm module, and TypeScript picks it up as the definitions in the same way it would in a non-virtual TypeScript project.</p>
<div class="language-md vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">md</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">```ts twoslash</span></span>
<span class="line"><span style="color: #768390">// @filename: node_modules/@types/mylib/index.d.ts</span></span>
<span class="line"><span style="color: #F47067">export</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">function</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">doit</span><span style="color: #ADBAC7">()</span><span style="color: #F47067">:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">string</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390">// @filename: index.ts</span></span>
<span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> { doit } </span><span style="color: #F47067">from</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;mylib&#39;</span></span>
<span class="line"><span style="color: #ADBAC7">console.</span><span style="color: #DCBDFB">log</span><span style="color: #ADBAC7">(doit)</span></span>
<span class="line"><span style="color: #ADBAC7">```</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">```ts twoslash</span></span>
<span class="line"><span style="color: #6A737D">// @filename: node_modules/@types/mylib/index.d.ts</span></span>
<span class="line"><span style="color: #D73A49">export</span><span style="color: #24292E"> </span><span style="color: #D73A49">function</span><span style="color: #24292E"> </span><span style="color: #6F42C1">doit</span><span style="color: #24292E">()</span><span style="color: #D73A49">:</span><span style="color: #24292E"> </span><span style="color: #005CC5">string</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D">// @filename: index.ts</span></span>
<span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> { doit } </span><span style="color: #D73A49">from</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;mylib&#39;</span></span>
<span class="line"><span style="color: #24292E">console.</span><span style="color: #6F42C1">log</span><span style="color: #24292E">(doit)</span></span>
<span class="line"><span style="color: #24292E">```</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br></div></div></div></div>
<p>You can also set up a JSON object which can be imported in a TypeScript file:</p>
<div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-TGHgs" id="tab-BaDaa4Y" checked="checked"><label for="tab-BaDaa4Y">output</label><input type="radio" name="group-TGHgs" id="tab-cWqr-Rh" ><label for="tab-cWqr-Rh">markdown</label></div><div class="blocks">
<div class="language-ts vp-adaptive-theme active line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki github-dark-dimmed twoslash lsp" style="background-color: #22272e; color: #adbac7"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #768390">// @filename: app.json</span></div><div class='line'><span style="color: #ADBAC7">{ </span><span style="color: #96D0FF">"version"</span><span style="color: #ADBAC7">: </span><span style="color: #96D0FF">"23.2.3"</span><span style="color: #ADBAC7"> }</span></div><div class='line'>&nbsp;</div><div class='line'><span style="color: #768390">// @filename: index.ts</span></div><div class='line'><span style="color: #F47067">import</span><span style="color: #ADBAC7"> <data-lsp lsp='import appSettings' >appSettings</data-lsp> </span><span style="color: #F47067">from</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">"./app.json"</span></div><div class='line'><span style="color: #ADBAC7"><data-lsp lsp='import appSettings' >appSettings</data-lsp>.<data-lsp lsp='(property) "version": string' style='border-bottom: solid 2px lightgrey;'>version</data-lsp></span></div><div class='meta-line'><span class='popover-prefix'>              </span><span class='popover'><div class='arrow'></div>(property) "version": string</span></div></code></div></pre>
<pre class="shiki github-light twoslash lsp" style="background-color: #fff; color: #24292e"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #6A737D">// @filename: app.json</span></div><div class='line'><span style="color: #24292E">{ </span><span style="color: #032F62">"version"</span><span style="color: #24292E">: </span><span style="color: #032F62">"23.2.3"</span><span style="color: #24292E"> }</span></div><div class='line'>&nbsp;</div><div class='line'><span style="color: #6A737D">// @filename: index.ts</span></div><div class='line'><span style="color: #D73A49">import</span><span style="color: #24292E"> <data-lsp lsp='import appSettings' >appSettings</data-lsp> </span><span style="color: #D73A49">from</span><span style="color: #24292E"> </span><span style="color: #032F62">"./app.json"</span></div><div class='line'><span style="color: #24292E"><data-lsp lsp='import appSettings' >appSettings</data-lsp>.<data-lsp lsp='(property) "version": string' style='border-bottom: solid 2px lightgrey;'>version</data-lsp></span></div><div class='meta-line'><span class='popover-prefix'>              </span><span class='popover'><div class='arrow'></div>(property) "version": string</span></div></code></div></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="language-md vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">md</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">```ts twoslash</span></span>
<span class="line"><span style="color: #768390">// @resolveJsonModule</span></span>
<span class="line"><span style="color: #768390">// @filename: app.json</span></span>
<span class="line"><span style="color: #ADBAC7">{ </span><span style="color: #96D0FF">&quot;version&quot;</span><span style="color: #ADBAC7">: </span><span style="color: #96D0FF">&quot;23.2.3&quot;</span><span style="color: #ADBAC7"> }</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390">// @filename: index.ts</span></span>
<span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> appSettings </span><span style="color: #F47067">from</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;./app.json&quot;</span></span>
<span class="line"><span style="color: #ADBAC7">appSettings.version</span></span>
<span class="line"><span style="color: #768390">//           ^?</span></span>
<span class="line"><span style="color: #ADBAC7">```</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">```ts twoslash</span></span>
<span class="line"><span style="color: #6A737D">// @resolveJsonModule</span></span>
<span class="line"><span style="color: #6A737D">// @filename: app.json</span></span>
<span class="line"><span style="color: #24292E">{ </span><span style="color: #032F62">&quot;version&quot;</span><span style="color: #24292E">: </span><span style="color: #032F62">&quot;23.2.3&quot;</span><span style="color: #24292E"> }</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D">// @filename: index.ts</span></span>
<span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> appSettings </span><span style="color: #D73A49">from</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;./app.json&quot;</span></span>
<span class="line"><span style="color: #24292E">appSettings.version</span></span>
<span class="line"><span style="color: #6A737D">//           ^?</span></span>
<span class="line"><span style="color: #24292E">```</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br></div></div></div></div>
<p>Finally, the following code allows importing non-TypeScript content. There is a <code>.d.ts</code> file which globally says 'md files are OK to import' and 'the module &quot;react&quot; exists, but don't worry about the details'.</p>
<p>Then for a user, they only see the imports and exports inside <code>index.tsx</code>.</p>
<div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-4MvWT" id="tab-Wa5yA5x" checked="checked"><label for="tab-Wa5yA5x">output</label><input type="radio" name="group-4MvWT" id="tab-6k7IvyO" ><label for="tab-6k7IvyO">markdown</label></div><div class="blocks">
<div class="language-ts vp-adaptive-theme active line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki github-dark-dimmed twoslash lsp" style="background-color: #22272e; color: #adbac7"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #F47067">import</span><span style="color: #ADBAC7"> <data-lsp lsp='(alias) module "react"&#10;import React' >React</data-lsp> </span><span style="color: #F47067">from</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">"react"</span></div><div class='line'><span style="color: #F47067">import</span><span style="color: #ADBAC7"> <data-lsp lsp='import MultiFileDocs' >MultiFileDocs</data-lsp> </span><span style="color: #F47067">from</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">"./MultiFileDocs.mdx"</span></div><div class='line'>&nbsp;</div><div class='line'><span style="color: #F47067">export</span><span style="color: #F69D50"> </span><span style="color: #F47067">default</span><span style="color: #F69D50"> () </span><span style="color: #F47067">=&gt;</span><span style="color: #F69D50"> &lt;<data-lsp lsp='import MultiFileDocs' >MultiFileDocs</data-lsp>/></span></div></code></div></pre>
<pre class="shiki github-light twoslash lsp" style="background-color: #fff; color: #24292e"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #D73A49">import</span><span style="color: #24292E"> <data-lsp lsp='(alias) module "react"&#10;import React' >React</data-lsp> </span><span style="color: #D73A49">from</span><span style="color: #24292E"> </span><span style="color: #032F62">"react"</span></div><div class='line'><span style="color: #D73A49">import</span><span style="color: #24292E"> <data-lsp lsp='import MultiFileDocs' >MultiFileDocs</data-lsp> </span><span style="color: #D73A49">from</span><span style="color: #24292E"> </span><span style="color: #032F62">"./MultiFileDocs.mdx"</span></div><div class='line'>&nbsp;</div><div class='line'><span style="color: #D73A49">export</span><span style="color: #24292E"> </span><span style="color: #D73A49">default</span><span style="color: #24292E"> () </span><span style="color: #D73A49">=&gt;</span><span style="color: #24292E"> &lt;</span><span style="color: #6F42C1"><data-lsp lsp='import MultiFileDocs' >MultiFileDocs</data-lsp></span><span style="color: #24292E">/&gt;</span></div></code></div></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="language-md vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">md</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">```ts twoslash</span></span>
<span class="line"><span style="color: #768390">// @filename: ambient.d.ts</span></span>
<span class="line"><span style="color: #F47067">declare</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">module</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;*.mdx&#39;</span><span style="color: #ADBAC7"> {</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">export</span><span style="color: #F69D50"> </span><span style="color: #F47067">default</span><span style="color: #F69D50"> </span><span style="color: #ADBAC7">any</span></span>
<span class="line"><span style="color: #ADBAC7">}</span></span>
<span class="line"><span style="color: #F47067">declare</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">module</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;react&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390">// @filename: MultiFileDocs.mdx</span></span>
<span class="line"><span style="color: #ADBAC7">## </span><span style="color: #F69D50">Hello</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50">world</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390">// @filename: index.tsx</span></span>
<span class="line"><span style="color: #768390">// ---cut---</span></span>
<span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> React </span><span style="color: #F47067">from</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;react&quot;</span></span>
<span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> MultiFileDocs </span><span style="color: #F47067">from</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;./MultiFileDocs.mdx&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F47067">export</span><span style="color: #F69D50"> </span><span style="color: #F47067">default</span><span style="color: #F69D50"> () </span><span style="color: #F47067">=&gt;</span><span style="color: #F69D50"> &lt;MultiFileDocs/&gt;</span></span>
<span class="line"><span style="color: #ADBAC7">```</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">```ts twoslash</span></span>
<span class="line"><span style="color: #6A737D">// @filename: ambient.d.ts</span></span>
<span class="line"><span style="color: #D73A49">declare</span><span style="color: #24292E"> </span><span style="color: #D73A49">module</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;*.mdx&#39;</span><span style="color: #24292E"> {</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">export</span><span style="color: #24292E"> </span><span style="color: #D73A49">default</span><span style="color: #24292E"> any</span></span>
<span class="line"><span style="color: #24292E">}</span></span>
<span class="line"><span style="color: #D73A49">declare</span><span style="color: #24292E"> </span><span style="color: #D73A49">module</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;react&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D">// @filename: MultiFileDocs.mdx</span></span>
<span class="line"><span style="color: #24292E">## </span><span style="color: #6F42C1">Hello</span><span style="color: #24292E"> </span><span style="color: #6F42C1">world</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D">// @filename: index.tsx</span></span>
<span class="line"><span style="color: #6A737D">// ---cut---</span></span>
<span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> React </span><span style="color: #D73A49">from</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;react&quot;</span></span>
<span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> MultiFileDocs </span><span style="color: #D73A49">from</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;./MultiFileDocs.mdx&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D73A49">export</span><span style="color: #24292E"> </span><span style="color: #D73A49">default</span><span style="color: #24292E"> () </span><span style="color: #D73A49">=&gt;</span><span style="color: #24292E"> &lt;</span><span style="color: #6F42C1">MultiFileDocs</span><span style="color: #24292E">/&gt;</span></span>
<span class="line"><span style="color: #24292E">```</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br></div></div></div></div>
]]></description>
            <content:encoded><![CDATA[<h1 id="multi-file" tabindex="-1">Multi-file <a class="header-anchor" href="#multi-file" aria-label="Permalink to &quot;Multi-file&quot;">&ZeroWidthSpace;</a></h1>
<p>Twoslash code examples aren't limited to creating a single file, by using <code>// @filename: [file]</code> you can write any file to the virtual file system used by TypeScript to power your code examples.</p>
<h2 id="filename-file" tabindex="-1"><code>@filename: [file]</code> <a class="header-anchor" href="#filename-file" aria-label="Permalink to &quot;`@filename: [file]`&quot;">&ZeroWidthSpace;</a></h2>
<p>Most of the time, you don't need to think about the underlaying virtual file system in a code example, but when you have imports between them it becomes important to know. Twoslash will default to creating an <code>index.[type]</code> based on the langauge passed to the code example:</p>
<div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-JYbTA" id="tab-_3hBfGr" checked="checked"><label for="tab-_3hBfGr">output</label><input type="radio" name="group-JYbTA" id="tab-iLUf-SA" ><label for="tab-iLUf-SA">markdown</label></div><div class="blocks">
<div class="language-ts vp-adaptive-theme active line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki github-dark-dimmed twoslash lsp" style="background-color: #22272e; color: #adbac7"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #768390">// I&apos;m index.ts</span></div></code></div></pre>
<pre class="shiki github-light twoslash lsp" style="background-color: #fff; color: #24292e"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #6A737D">// I&apos;m index.ts</span></div></code></div></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="language-md vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">md</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">```ts twoslash</span></span>
<span class="line"><span style="color: #768390">// I&#39;m index.ts</span></span>
<span class="line"><span style="color: #ADBAC7">```</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">```ts twoslash</span></span>
<span class="line"><span style="color: #6A737D">// I&#39;m index.ts</span></span>
<span class="line"><span style="color: #24292E">```</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div></div></div>
<div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-Uwtkr" id="tab-yxyo5fz" checked="checked"><label for="tab-yxyo5fz">output</label><input type="radio" name="group-Uwtkr" id="tab-sXwnTb4" ><label for="tab-sXwnTb4">markdown</label></div><div class="blocks">
<div class="language-tsx vp-adaptive-theme active line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">tsx</span><pre class="shiki github-dark-dimmed twoslash lsp" style="background-color: #22272e; color: #adbac7"><div class="language-id">tsx</div><div class='code-container'><code><div class='line'><span style="color: #768390">// I&apos;m index.tsx</span></div></code></div></pre>
<pre class="shiki github-light twoslash lsp" style="background-color: #fff; color: #24292e"><div class="language-id">tsx</div><div class='code-container'><code><div class='line'><span style="color: #6A737D">// I&apos;m index.tsx</span></div></code></div></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="language-md vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">md</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">```tsx twoslash</span></span>
<span class="line"><span style="color: #768390">// I&#39;m index.tsx</span></span>
<span class="line"><span style="color: #ADBAC7">```</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">```tsx twoslash</span></span>
<span class="line"><span style="color: #6A737D">// I&#39;m index.tsx</span></span>
<span class="line"><span style="color: #24292E">```</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div></div></div>
<div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-753eC" id="tab-Iw9O0a9" checked="checked"><label for="tab-Iw9O0a9">output</label><input type="radio" name="group-753eC" id="tab-f9nHsk2" ><label for="tab-f9nHsk2">markdown</label></div><div class="blocks">
<div class="language-js vp-adaptive-theme active line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">js</span><pre class="shiki github-dark-dimmed twoslash lsp" style="background-color: #22272e; color: #adbac7"><div class="language-id">js</div><div class='code-container'><code><div class='line'><span style="color: #768390">// I&apos;m index.tjs</span></div></code></div></pre>
<pre class="shiki github-light twoslash lsp" style="background-color: #fff; color: #24292e"><div class="language-id">js</div><div class='code-container'><code><div class='line'><span style="color: #6A737D">// I&apos;m index.tjs</span></div></code></div></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="language-md vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">md</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">```js twoslash</span></span>
<span class="line"><span style="color: #768390">// I&#39;m index.tjs</span></span>
<span class="line"><span style="color: #ADBAC7">```</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">```js twoslash</span></span>
<span class="line"><span style="color: #6A737D">// I&#39;m index.tjs</span></span>
<span class="line"><span style="color: #24292E">```</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div></div></div>
<p>Then until Twoslash hits another <code>// @filename: [file]</code>, the parser keeps adding new lines into the same file. After seeing <code>@filename</code> Twoslash creates a new virtual file-system file and adds the new lines to that. You can't edit a file after it was created, but you can overwrite it.</p>
<p>It can be any file. For example, if you want to quickly fake a node module:</p>
<div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-DbGDQ" id="tab-Jaw61ll" checked="checked"><label for="tab-Jaw61ll">output</label><input type="radio" name="group-DbGDQ" id="tab-N32UIIb" ><label for="tab-N32UIIb">markdown</label></div><div class="blocks">
<div class="language-ts vp-adaptive-theme active line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki github-dark-dimmed twoslash lsp" style="background-color: #22272e; color: #adbac7"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #768390">// @filename: node_modules/@types/mylib/index.d.ts</span></div><div class='line'><span style="color: #F47067">export</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">function</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB"><data-lsp lsp='function doit(): string' >doit</data-lsp></span><span style="color: #ADBAC7">()</span><span style="color: #F47067">:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">string</span></div><div class='line'>&nbsp;</div><div class='line'><span style="color: #768390">// @filename: index.ts</span></div><div class='line'><span style="color: #F47067">import</span><span style="color: #ADBAC7"> { <data-lsp lsp='(alias) function doit(): string&#10;import doit' >doit</data-lsp> } </span><span style="color: #F47067">from</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&apos;mylib&apos;</span></div><div class='line'><span style="color: #ADBAC7"><data-lsp lsp='var console: Console' >console</data-lsp>.</span><span style="color: #DCBDFB"><data-lsp lsp='(method) Console.log(...data: any[]): void' >log</data-lsp></span><span style="color: #ADBAC7">(<data-lsp lsp='(alias) function doit(): string&#10;import doit' >doit</data-lsp>)</span></div></code></div></pre>
<pre class="shiki github-light twoslash lsp" style="background-color: #fff; color: #24292e"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #6A737D">// @filename: node_modules/@types/mylib/index.d.ts</span></div><div class='line'><span style="color: #D73A49">export</span><span style="color: #24292E"> </span><span style="color: #D73A49">function</span><span style="color: #24292E"> </span><span style="color: #6F42C1"><data-lsp lsp='function doit(): string' >doit</data-lsp></span><span style="color: #24292E">()</span><span style="color: #D73A49">:</span><span style="color: #24292E"> </span><span style="color: #005CC5">string</span></div><div class='line'>&nbsp;</div><div class='line'><span style="color: #6A737D">// @filename: index.ts</span></div><div class='line'><span style="color: #D73A49">import</span><span style="color: #24292E"> { <data-lsp lsp='(alias) function doit(): string&#10;import doit' >doit</data-lsp> } </span><span style="color: #D73A49">from</span><span style="color: #24292E"> </span><span style="color: #032F62">&apos;mylib&apos;</span></div><div class='line'><span style="color: #24292E"><data-lsp lsp='var console: Console' >console</data-lsp>.</span><span style="color: #6F42C1"><data-lsp lsp='(method) Console.log(...data: any[]): void' >log</data-lsp></span><span style="color: #24292E">(<data-lsp lsp='(alias) function doit(): string&#10;import doit' >doit</data-lsp>)</span></div></code></div></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>This code example sets up the types for a non-existent npm module, and TypeScript picks it up as the definitions in the same way it would in a non-virtual TypeScript project.</p>
<div class="language-md vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">md</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">```ts twoslash</span></span>
<span class="line"><span style="color: #768390">// @filename: node_modules/@types/mylib/index.d.ts</span></span>
<span class="line"><span style="color: #F47067">export</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">function</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">doit</span><span style="color: #ADBAC7">()</span><span style="color: #F47067">:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">string</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390">// @filename: index.ts</span></span>
<span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> { doit } </span><span style="color: #F47067">from</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;mylib&#39;</span></span>
<span class="line"><span style="color: #ADBAC7">console.</span><span style="color: #DCBDFB">log</span><span style="color: #ADBAC7">(doit)</span></span>
<span class="line"><span style="color: #ADBAC7">```</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">```ts twoslash</span></span>
<span class="line"><span style="color: #6A737D">// @filename: node_modules/@types/mylib/index.d.ts</span></span>
<span class="line"><span style="color: #D73A49">export</span><span style="color: #24292E"> </span><span style="color: #D73A49">function</span><span style="color: #24292E"> </span><span style="color: #6F42C1">doit</span><span style="color: #24292E">()</span><span style="color: #D73A49">:</span><span style="color: #24292E"> </span><span style="color: #005CC5">string</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D">// @filename: index.ts</span></span>
<span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> { doit } </span><span style="color: #D73A49">from</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;mylib&#39;</span></span>
<span class="line"><span style="color: #24292E">console.</span><span style="color: #6F42C1">log</span><span style="color: #24292E">(doit)</span></span>
<span class="line"><span style="color: #24292E">```</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br></div></div></div></div>
<p>You can also set up a JSON object which can be imported in a TypeScript file:</p>
<div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-TGHgs" id="tab-BaDaa4Y" checked="checked"><label for="tab-BaDaa4Y">output</label><input type="radio" name="group-TGHgs" id="tab-cWqr-Rh" ><label for="tab-cWqr-Rh">markdown</label></div><div class="blocks">
<div class="language-ts vp-adaptive-theme active line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki github-dark-dimmed twoslash lsp" style="background-color: #22272e; color: #adbac7"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #768390">// @filename: app.json</span></div><div class='line'><span style="color: #ADBAC7">{ </span><span style="color: #96D0FF">"version"</span><span style="color: #ADBAC7">: </span><span style="color: #96D0FF">"23.2.3"</span><span style="color: #ADBAC7"> }</span></div><div class='line'>&nbsp;</div><div class='line'><span style="color: #768390">// @filename: index.ts</span></div><div class='line'><span style="color: #F47067">import</span><span style="color: #ADBAC7"> <data-lsp lsp='import appSettings' >appSettings</data-lsp> </span><span style="color: #F47067">from</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">"./app.json"</span></div><div class='line'><span style="color: #ADBAC7"><data-lsp lsp='import appSettings' >appSettings</data-lsp>.<data-lsp lsp='(property) "version": string' style='border-bottom: solid 2px lightgrey;'>version</data-lsp></span></div><div class='meta-line'><span class='popover-prefix'>              </span><span class='popover'><div class='arrow'></div>(property) "version": string</span></div></code></div></pre>
<pre class="shiki github-light twoslash lsp" style="background-color: #fff; color: #24292e"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #6A737D">// @filename: app.json</span></div><div class='line'><span style="color: #24292E">{ </span><span style="color: #032F62">"version"</span><span style="color: #24292E">: </span><span style="color: #032F62">"23.2.3"</span><span style="color: #24292E"> }</span></div><div class='line'>&nbsp;</div><div class='line'><span style="color: #6A737D">// @filename: index.ts</span></div><div class='line'><span style="color: #D73A49">import</span><span style="color: #24292E"> <data-lsp lsp='import appSettings' >appSettings</data-lsp> </span><span style="color: #D73A49">from</span><span style="color: #24292E"> </span><span style="color: #032F62">"./app.json"</span></div><div class='line'><span style="color: #24292E"><data-lsp lsp='import appSettings' >appSettings</data-lsp>.<data-lsp lsp='(property) "version": string' style='border-bottom: solid 2px lightgrey;'>version</data-lsp></span></div><div class='meta-line'><span class='popover-prefix'>              </span><span class='popover'><div class='arrow'></div>(property) "version": string</span></div></code></div></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="language-md vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">md</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">```ts twoslash</span></span>
<span class="line"><span style="color: #768390">// @resolveJsonModule</span></span>
<span class="line"><span style="color: #768390">// @filename: app.json</span></span>
<span class="line"><span style="color: #ADBAC7">{ </span><span style="color: #96D0FF">&quot;version&quot;</span><span style="color: #ADBAC7">: </span><span style="color: #96D0FF">&quot;23.2.3&quot;</span><span style="color: #ADBAC7"> }</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390">// @filename: index.ts</span></span>
<span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> appSettings </span><span style="color: #F47067">from</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;./app.json&quot;</span></span>
<span class="line"><span style="color: #ADBAC7">appSettings.version</span></span>
<span class="line"><span style="color: #768390">//           ^?</span></span>
<span class="line"><span style="color: #ADBAC7">```</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">```ts twoslash</span></span>
<span class="line"><span style="color: #6A737D">// @resolveJsonModule</span></span>
<span class="line"><span style="color: #6A737D">// @filename: app.json</span></span>
<span class="line"><span style="color: #24292E">{ </span><span style="color: #032F62">&quot;version&quot;</span><span style="color: #24292E">: </span><span style="color: #032F62">&quot;23.2.3&quot;</span><span style="color: #24292E"> }</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D">// @filename: index.ts</span></span>
<span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> appSettings </span><span style="color: #D73A49">from</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;./app.json&quot;</span></span>
<span class="line"><span style="color: #24292E">appSettings.version</span></span>
<span class="line"><span style="color: #6A737D">//           ^?</span></span>
<span class="line"><span style="color: #24292E">```</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br></div></div></div></div>
<p>Finally, the following code allows importing non-TypeScript content. There is a <code>.d.ts</code> file which globally says 'md files are OK to import' and 'the module &quot;react&quot; exists, but don't worry about the details'.</p>
<p>Then for a user, they only see the imports and exports inside <code>index.tsx</code>.</p>
<div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-4MvWT" id="tab-Wa5yA5x" checked="checked"><label for="tab-Wa5yA5x">output</label><input type="radio" name="group-4MvWT" id="tab-6k7IvyO" ><label for="tab-6k7IvyO">markdown</label></div><div class="blocks">
<div class="language-ts vp-adaptive-theme active line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki github-dark-dimmed twoslash lsp" style="background-color: #22272e; color: #adbac7"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #F47067">import</span><span style="color: #ADBAC7"> <data-lsp lsp='(alias) module "react"&#10;import React' >React</data-lsp> </span><span style="color: #F47067">from</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">"react"</span></div><div class='line'><span style="color: #F47067">import</span><span style="color: #ADBAC7"> <data-lsp lsp='import MultiFileDocs' >MultiFileDocs</data-lsp> </span><span style="color: #F47067">from</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">"./MultiFileDocs.mdx"</span></div><div class='line'>&nbsp;</div><div class='line'><span style="color: #F47067">export</span><span style="color: #F69D50"> </span><span style="color: #F47067">default</span><span style="color: #F69D50"> () </span><span style="color: #F47067">=&gt;</span><span style="color: #F69D50"> &lt;<data-lsp lsp='import MultiFileDocs' >MultiFileDocs</data-lsp>/></span></div></code></div></pre>
<pre class="shiki github-light twoslash lsp" style="background-color: #fff; color: #24292e"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #D73A49">import</span><span style="color: #24292E"> <data-lsp lsp='(alias) module "react"&#10;import React' >React</data-lsp> </span><span style="color: #D73A49">from</span><span style="color: #24292E"> </span><span style="color: #032F62">"react"</span></div><div class='line'><span style="color: #D73A49">import</span><span style="color: #24292E"> <data-lsp lsp='import MultiFileDocs' >MultiFileDocs</data-lsp> </span><span style="color: #D73A49">from</span><span style="color: #24292E"> </span><span style="color: #032F62">"./MultiFileDocs.mdx"</span></div><div class='line'>&nbsp;</div><div class='line'><span style="color: #D73A49">export</span><span style="color: #24292E"> </span><span style="color: #D73A49">default</span><span style="color: #24292E"> () </span><span style="color: #D73A49">=&gt;</span><span style="color: #24292E"> &lt;</span><span style="color: #6F42C1"><data-lsp lsp='import MultiFileDocs' >MultiFileDocs</data-lsp></span><span style="color: #24292E">/&gt;</span></div></code></div></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="language-md vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">md</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">```ts twoslash</span></span>
<span class="line"><span style="color: #768390">// @filename: ambient.d.ts</span></span>
<span class="line"><span style="color: #F47067">declare</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">module</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;*.mdx&#39;</span><span style="color: #ADBAC7"> {</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">export</span><span style="color: #F69D50"> </span><span style="color: #F47067">default</span><span style="color: #F69D50"> </span><span style="color: #ADBAC7">any</span></span>
<span class="line"><span style="color: #ADBAC7">}</span></span>
<span class="line"><span style="color: #F47067">declare</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">module</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;react&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390">// @filename: MultiFileDocs.mdx</span></span>
<span class="line"><span style="color: #ADBAC7">## </span><span style="color: #F69D50">Hello</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50">world</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390">// @filename: index.tsx</span></span>
<span class="line"><span style="color: #768390">// ---cut---</span></span>
<span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> React </span><span style="color: #F47067">from</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;react&quot;</span></span>
<span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> MultiFileDocs </span><span style="color: #F47067">from</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;./MultiFileDocs.mdx&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F47067">export</span><span style="color: #F69D50"> </span><span style="color: #F47067">default</span><span style="color: #F69D50"> () </span><span style="color: #F47067">=&gt;</span><span style="color: #F69D50"> &lt;MultiFileDocs/&gt;</span></span>
<span class="line"><span style="color: #ADBAC7">```</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">```ts twoslash</span></span>
<span class="line"><span style="color: #6A737D">// @filename: ambient.d.ts</span></span>
<span class="line"><span style="color: #D73A49">declare</span><span style="color: #24292E"> </span><span style="color: #D73A49">module</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;*.mdx&#39;</span><span style="color: #24292E"> {</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">export</span><span style="color: #24292E"> </span><span style="color: #D73A49">default</span><span style="color: #24292E"> any</span></span>
<span class="line"><span style="color: #24292E">}</span></span>
<span class="line"><span style="color: #D73A49">declare</span><span style="color: #24292E"> </span><span style="color: #D73A49">module</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;react&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D">// @filename: MultiFileDocs.mdx</span></span>
<span class="line"><span style="color: #24292E">## </span><span style="color: #6F42C1">Hello</span><span style="color: #24292E"> </span><span style="color: #6F42C1">world</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D">// @filename: index.tsx</span></span>
<span class="line"><span style="color: #6A737D">// ---cut---</span></span>
<span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> React </span><span style="color: #D73A49">from</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;react&quot;</span></span>
<span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> MultiFileDocs </span><span style="color: #D73A49">from</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;./MultiFileDocs.mdx&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D73A49">export</span><span style="color: #24292E"> </span><span style="color: #D73A49">default</span><span style="color: #24292E"> () </span><span style="color: #D73A49">=&gt;</span><span style="color: #24292E"> &lt;</span><span style="color: #6F42C1">MultiFileDocs</span><span style="color: #24292E">/&gt;</span></span>
<span class="line"><span style="color: #24292E">```</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br></div></div></div></div>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Queries]]></title>
            <link>https://note.toshiki.devapplication/vitepress-plugin-shiki-twoslash/api/queries</link>
            <guid>https://note.toshiki.devapplication/vitepress-plugin-shiki-twoslash/api/queries</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="queries" tabindex="-1">Queries <a class="header-anchor" href="#queries" aria-label="Permalink to &quot;Queries&quot;">&ZeroWidthSpace;</a></h1>
<p>One of the key features of Twoslash is the ability to use the TypeScript compiler to pull out type information about your code. Twoslash comes with two different ways to query your code: <code>?^</code> and <code>?|</code>.</p>
<h2 id="extract-type" tabindex="-1">Extract Type <code>^?</code> <a class="header-anchor" href="#extract-type" aria-label="Permalink to &quot;Extract Type `^?`&quot;">&ZeroWidthSpace;</a></h2>
<p>Using <code>^?</code> you can pull out type information about a particular identifier in the line of code above it.</p>
<div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-Yp73v" id="tab-j48HyFB" checked="checked"><label for="tab-j48HyFB">output</label><input type="radio" name="group-Yp73v" id="tab-n-CmDge" ><label for="tab-n-CmDge">markdown</label></div><div class="blocks">
<div class="language-ts vp-adaptive-theme active line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki github-dark-dimmed twoslash lsp" style="background-color: #22272e; color: #adbac7"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #F47067">const</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF"><data-lsp lsp='const hi: "Hello"' >hi</data-lsp></span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&apos;Hello&apos;</span></div><div class='line'><span style="color: #F47067">const</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF"><data-lsp lsp='const msg: string' style='border-bottom: solid 2px lightgrey;'>msg</data-lsp></span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> <data-lsp lsp='const hi: "Hello"' >hi</data-lsp> </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&apos;, world&apos;</span></div><div class='meta-line'><span class='popover-prefix'>      </span><span class='popover'><div class='arrow'></div>const msg: string</span></div></code></div></pre>
<pre class="shiki github-light twoslash lsp" style="background-color: #fff; color: #24292e"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #D73A49">const</span><span style="color: #24292E"> </span><span style="color: #005CC5"><data-lsp lsp='const hi: "Hello"' >hi</data-lsp></span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #032F62">&apos;Hello&apos;</span></div><div class='line'><span style="color: #D73A49">const</span><span style="color: #24292E"> </span><span style="color: #005CC5"><data-lsp lsp='const msg: string' style='border-bottom: solid 2px lightgrey;'>msg</data-lsp></span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> <data-lsp lsp='const hi: "Hello"' >hi</data-lsp> </span><span style="color: #D73A49">+</span><span style="color: #24292E"> </span><span style="color: #032F62">&apos;, world&apos;</span></div><div class='meta-line'><span class='popover-prefix'>      </span><span class='popover'><div class='arrow'></div>const msg: string</span></div></code></div></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="language-md vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">md</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">```ts twoslash</span></span>
<span class="line"><span style="color: #F47067">const</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">hi</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;Hello&#39;</span></span>
<span class="line"><span style="color: #F47067">const</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">msg</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> hi </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;, world&#39;</span></span>
<span class="line"><span style="color: #768390">//    ^?</span></span>
<span class="line"><span style="color: #ADBAC7">```</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">```ts twoslash</span></span>
<span class="line"><span style="color: #D73A49">const</span><span style="color: #24292E"> </span><span style="color: #005CC5">hi</span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;Hello&#39;</span></span>
<span class="line"><span style="color: #D73A49">const</span><span style="color: #24292E"> </span><span style="color: #005CC5">msg</span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> hi </span><span style="color: #D73A49">+</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;, world&#39;</span></span>
<span class="line"><span style="color: #6A737D">//    ^?</span></span>
<span class="line"><span style="color: #24292E">```</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br></div></div></div></div>
<h2 id="completions" tabindex="-1">Completions <code>^|</code> <a class="header-anchor" href="#completions" aria-label="Permalink to &quot;Completions `^|`&quot;">&ZeroWidthSpace;</a></h2>
<p>Using <code>^|</code> you can pull out information about a what the auto-complete looks like at a particular location.</p>
<div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-G-kpf" id="tab-i2snNv4" checked="checked"><label for="tab-i2snNv4">output</label><input type="radio" name="group-G-kpf" id="tab-HEitcuj" ><label for="tab-HEitcuj">markdown</label></div><div class="blocks">
<div class="language-ts vp-adaptive-theme active line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki github-dark-dimmed twoslash lsp" style="background-color: #22272e; color: #adbac7"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #ADBAC7"><data-lsp lsp='var console: Console' >console</data-lsp>.<data-lsp lsp='any' >e</data-lsp></span></div><div class='meta-line'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class='inline-completions'><ul class='dropdown'><li class=''><span><span class='result-found'>e</span>rror</span></li></ul></span></div></code></div></pre>
<pre class="shiki github-light twoslash lsp" style="background-color: #fff; color: #24292e"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #24292E"><data-lsp lsp='var console: Console' >console</data-lsp>.<data-lsp lsp='any' >e</data-lsp></span></div><div class='meta-line'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class='inline-completions'><ul class='dropdown'><li class=''><span><span class='result-found'>e</span>rror</span></li></ul></span></div></code></div></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="language-md vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">md</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">```ts twoslash</span></span>
<span class="line"><span style="color: #768390">// @noErrors</span></span>
<span class="line"><span style="color: #ADBAC7">console.e</span></span>
<span class="line"><span style="color: #768390">//       ^|</span></span>
<span class="line"><span style="color: #ADBAC7">```</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">```ts twoslash</span></span>
<span class="line"><span style="color: #6A737D">// @noErrors</span></span>
<span class="line"><span style="color: #24292E">console.e</span></span>
<span class="line"><span style="color: #6A737D">//       ^|</span></span>
<span class="line"><span style="color: #24292E">```</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br></div></div></div></div>
<div class="info custom-block"><p class="custom-block-title">INFO</p>
<p>Note that the compiler flag for <a href="./errors.html#noerrors"><code>// @noErrors</code></a> is set, because <code>console.e</code> is a failing TypeScript code sample but we don't really care about that.</p>
</div>
]]></description>
            <content:encoded><![CDATA[<h1 id="queries" tabindex="-1">Queries <a class="header-anchor" href="#queries" aria-label="Permalink to &quot;Queries&quot;">&ZeroWidthSpace;</a></h1>
<p>One of the key features of Twoslash is the ability to use the TypeScript compiler to pull out type information about your code. Twoslash comes with two different ways to query your code: <code>?^</code> and <code>?|</code>.</p>
<h2 id="extract-type" tabindex="-1">Extract Type <code>^?</code> <a class="header-anchor" href="#extract-type" aria-label="Permalink to &quot;Extract Type `^?`&quot;">&ZeroWidthSpace;</a></h2>
<p>Using <code>^?</code> you can pull out type information about a particular identifier in the line of code above it.</p>
<div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-Yp73v" id="tab-j48HyFB" checked="checked"><label for="tab-j48HyFB">output</label><input type="radio" name="group-Yp73v" id="tab-n-CmDge" ><label for="tab-n-CmDge">markdown</label></div><div class="blocks">
<div class="language-ts vp-adaptive-theme active line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki github-dark-dimmed twoslash lsp" style="background-color: #22272e; color: #adbac7"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #F47067">const</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF"><data-lsp lsp='const hi: "Hello"' >hi</data-lsp></span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&apos;Hello&apos;</span></div><div class='line'><span style="color: #F47067">const</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF"><data-lsp lsp='const msg: string' style='border-bottom: solid 2px lightgrey;'>msg</data-lsp></span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> <data-lsp lsp='const hi: "Hello"' >hi</data-lsp> </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&apos;, world&apos;</span></div><div class='meta-line'><span class='popover-prefix'>      </span><span class='popover'><div class='arrow'></div>const msg: string</span></div></code></div></pre>
<pre class="shiki github-light twoslash lsp" style="background-color: #fff; color: #24292e"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #D73A49">const</span><span style="color: #24292E"> </span><span style="color: #005CC5"><data-lsp lsp='const hi: "Hello"' >hi</data-lsp></span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #032F62">&apos;Hello&apos;</span></div><div class='line'><span style="color: #D73A49">const</span><span style="color: #24292E"> </span><span style="color: #005CC5"><data-lsp lsp='const msg: string' style='border-bottom: solid 2px lightgrey;'>msg</data-lsp></span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> <data-lsp lsp='const hi: "Hello"' >hi</data-lsp> </span><span style="color: #D73A49">+</span><span style="color: #24292E"> </span><span style="color: #032F62">&apos;, world&apos;</span></div><div class='meta-line'><span class='popover-prefix'>      </span><span class='popover'><div class='arrow'></div>const msg: string</span></div></code></div></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="language-md vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">md</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">```ts twoslash</span></span>
<span class="line"><span style="color: #F47067">const</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">hi</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;Hello&#39;</span></span>
<span class="line"><span style="color: #F47067">const</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">msg</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> hi </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;, world&#39;</span></span>
<span class="line"><span style="color: #768390">//    ^?</span></span>
<span class="line"><span style="color: #ADBAC7">```</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">```ts twoslash</span></span>
<span class="line"><span style="color: #D73A49">const</span><span style="color: #24292E"> </span><span style="color: #005CC5">hi</span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;Hello&#39;</span></span>
<span class="line"><span style="color: #D73A49">const</span><span style="color: #24292E"> </span><span style="color: #005CC5">msg</span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> hi </span><span style="color: #D73A49">+</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;, world&#39;</span></span>
<span class="line"><span style="color: #6A737D">//    ^?</span></span>
<span class="line"><span style="color: #24292E">```</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br></div></div></div></div>
<h2 id="completions" tabindex="-1">Completions <code>^|</code> <a class="header-anchor" href="#completions" aria-label="Permalink to &quot;Completions `^|`&quot;">&ZeroWidthSpace;</a></h2>
<p>Using <code>^|</code> you can pull out information about a what the auto-complete looks like at a particular location.</p>
<div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-G-kpf" id="tab-i2snNv4" checked="checked"><label for="tab-i2snNv4">output</label><input type="radio" name="group-G-kpf" id="tab-HEitcuj" ><label for="tab-HEitcuj">markdown</label></div><div class="blocks">
<div class="language-ts vp-adaptive-theme active line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki github-dark-dimmed twoslash lsp" style="background-color: #22272e; color: #adbac7"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #ADBAC7"><data-lsp lsp='var console: Console' >console</data-lsp>.<data-lsp lsp='any' >e</data-lsp></span></div><div class='meta-line'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class='inline-completions'><ul class='dropdown'><li class=''><span><span class='result-found'>e</span>rror</span></li></ul></span></div></code></div></pre>
<pre class="shiki github-light twoslash lsp" style="background-color: #fff; color: #24292e"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #24292E"><data-lsp lsp='var console: Console' >console</data-lsp>.<data-lsp lsp='any' >e</data-lsp></span></div><div class='meta-line'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class='inline-completions'><ul class='dropdown'><li class=''><span><span class='result-found'>e</span>rror</span></li></ul></span></div></code></div></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="language-md vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">md</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">```ts twoslash</span></span>
<span class="line"><span style="color: #768390">// @noErrors</span></span>
<span class="line"><span style="color: #ADBAC7">console.e</span></span>
<span class="line"><span style="color: #768390">//       ^|</span></span>
<span class="line"><span style="color: #ADBAC7">```</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">```ts twoslash</span></span>
<span class="line"><span style="color: #6A737D">// @noErrors</span></span>
<span class="line"><span style="color: #24292E">console.e</span></span>
<span class="line"><span style="color: #6A737D">//       ^|</span></span>
<span class="line"><span style="color: #24292E">```</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br></div></div></div></div>
<div class="info custom-block"><p class="custom-block-title">INFO</p>
<p>Note that the compiler flag for <a href="./errors.html#noerrors"><code>// @noErrors</code></a> is set, because <code>console.e</code> is a failing TypeScript code sample but we don't really care about that.</p>
</div>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[@types]]></title>
            <link>https://note.toshiki.devapplication/vitepress-plugin-shiki-twoslash/api/types</link>
            <guid>https://note.toshiki.devapplication/vitepress-plugin-shiki-twoslash/api/types</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="types" tabindex="-1">@types <a class="header-anchor" href="#types" aria-label="Permalink to &quot;@types&quot;">&ZeroWidthSpace;</a></h1>
<p>For most examples, you probably need to import external libraries into your code examples.</p>
<p>Twoslash works by faking a virtual file system over your existing file system. This means any <code>@types</code> or libraries with TypeScript definitions should work out of the box with no config.</p>
<h2 id="local-sources" tabindex="-1">Local Sources <a class="header-anchor" href="#local-sources" aria-label="Permalink to &quot;Local Sources&quot;">&ZeroWidthSpace;</a></h2>
<p>Simply import locally installed libraries and Twoslash can pick up types:</p>
<div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-UV8e4" id="tab-w8XoTVL" checked="checked"><label for="tab-w8XoTVL">output</label><input type="radio" name="group-UV8e4" id="tab-FTBqtcH" ><label for="tab-FTBqtcH">markdown</label></div><div class="blocks">
<div class="language-ts vp-adaptive-theme active line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki github-dark-dimmed twoslash lsp" style="background-color: #22272e; color: #adbac7"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #F47067">import</span><span style="color: #ADBAC7"> { <data-lsp lsp='(alias) function defineConfig(config: UserConfig&lt;DefaultTheme.Config>): UserConfig&lt;DefaultTheme.Config>&#10;import defineConfig' >defineConfig</data-lsp> } </span><span style="color: #F47067">from</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&apos;vitepress&apos;</span></div><div class='line'><span style="color: #F47067">const</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF"><data-lsp lsp='const config: UserConfig&lt;DefaultTheme.Config>' style='border-bottom: solid 2px lightgrey;'>config</data-lsp></span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB"><data-lsp lsp='(alias) defineConfig(config: UserConfig&lt;DefaultTheme.Config>): UserConfig&lt;DefaultTheme.Config>&#10;import defineConfig' >defineConfig</data-lsp></span><span style="color: #ADBAC7">({})</span></div><div class='meta-line'><span class='popover-prefix'>        </span><span class='popover'><div class='arrow'></div>const config: UserConfig&lt;DefaultTheme.Config&gt;</span></div><div class='line'><span style="color: #F47067">export</span><span style="color: #F69D50"> </span><span style="color: #F47067">default</span><span style="color: #F69D50"> </span><span style="color: #ADBAC7"><data-lsp lsp='const config: UserConfig&lt;DefaultTheme.Config>' >config</data-lsp></span></div></code></div></pre>
<pre class="shiki github-light twoslash lsp" style="background-color: #fff; color: #24292e"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #D73A49">import</span><span style="color: #24292E"> { <data-lsp lsp='(alias) function defineConfig(config: UserConfig&lt;DefaultTheme.Config>): UserConfig&lt;DefaultTheme.Config>&#10;import defineConfig' >defineConfig</data-lsp> } </span><span style="color: #D73A49">from</span><span style="color: #24292E"> </span><span style="color: #032F62">&apos;vitepress&apos;</span></div><div class='line'><span style="color: #D73A49">const</span><span style="color: #24292E"> </span><span style="color: #005CC5"><data-lsp lsp='const config: UserConfig&lt;DefaultTheme.Config>' style='border-bottom: solid 2px lightgrey;'>config</data-lsp></span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #6F42C1"><data-lsp lsp='(alias) defineConfig(config: UserConfig&lt;DefaultTheme.Config>): UserConfig&lt;DefaultTheme.Config>&#10;import defineConfig' >defineConfig</data-lsp></span><span style="color: #24292E">({})</span></div><div class='meta-line'><span class='popover-prefix'>        </span><span class='popover'><div class='arrow'></div>const config: UserConfig&lt;DefaultTheme.Config&gt;</span></div><div class='line'><span style="color: #D73A49">export</span><span style="color: #24292E"> </span><span style="color: #D73A49">default</span><span style="color: #24292E"> <data-lsp lsp='const config: UserConfig&lt;DefaultTheme.Config>' >config</data-lsp></span></div></code></div></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="language-md vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">md</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">```ts twoslash</span></span>
<span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> { defineConfig } </span><span style="color: #F47067">from</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;vitepress&#39;</span></span>
<span class="line"><span style="color: #F47067">const</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">config</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">defineConfig</span><span style="color: #ADBAC7">({})</span></span>
<span class="line"><span style="color: #768390">//    ^?</span></span>
<span class="line"><span style="color: #F47067">export</span><span style="color: #F69D50"> </span><span style="color: #F47067">default</span><span style="color: #F69D50"> </span><span style="color: #ADBAC7">config</span></span>
<span class="line"><span style="color: #ADBAC7">```</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">```ts twoslash</span></span>
<span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> { defineConfig } </span><span style="color: #D73A49">from</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;vitepress&#39;</span></span>
<span class="line"><span style="color: #D73A49">const</span><span style="color: #24292E"> </span><span style="color: #005CC5">config</span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #6F42C1">defineConfig</span><span style="color: #24292E">({})</span></span>
<span class="line"><span style="color: #6A737D">//    ^?</span></span>
<span class="line"><span style="color: #D73A49">export</span><span style="color: #24292E"> </span><span style="color: #D73A49">default</span><span style="color: #24292E"> config</span></span>
<span class="line"><span style="color: #24292E">```</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br></div></div></div></div>
<h2 id="globals" tabindex="-1">Globals <a class="header-anchor" href="#globals" aria-label="Permalink to &quot;Globals&quot;">&ZeroWidthSpace;</a></h2>
<p>Setting up globals is a little bit more complex, but not drastically. You need to use the <a href="https://www.typescriptlang.org/docs/handbook/triple-slash-directives.html#-reference-types-" target="_blank" rel="noreferrer">triple slash reference</a> which adds a particular library to the global scope.</p>
<p>For example, setting up Node imports and globals etc.</p>
<div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-Astq8" id="tab-NNY6SJ7" checked="checked"><label for="tab-NNY6SJ7">output</label><input type="radio" name="group-Astq8" id="tab--Y7I3mK" ><label for="tab--Y7I3mK">markdown</label></div><div class="blocks">
<div class="language-ts vp-adaptive-theme active line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki github-dark-dimmed twoslash lsp" style="background-color: #22272e; color: #adbac7"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #F47067">import</span><span style="color: #ADBAC7"> { <data-lsp lsp='(alias) function writeFileSync(file: PathOrFileDescriptor, data: string | NodeJS.ArrayBufferView, options?: WriteFileOptions): void&#10;import writeFileSync' >writeFileSync</data-lsp> } </span><span style="color: #F47067">from</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&apos;fs&apos;</span></div><div class='line'><span style="color: #DCBDFB"><data-lsp lsp='(alias) writeFileSync(file: PathOrFileDescriptor, data: string | NodeJS.ArrayBufferView, options?: WriteFileOptions | undefined): void&#10;import writeFileSync' >writeFileSync</data-lsp></span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&apos;myfile.txt&apos;</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&apos;// TODO&apos;</span><span style="color: #ADBAC7">)</span></div></code></div></pre>
<pre class="shiki github-light twoslash lsp" style="background-color: #fff; color: #24292e"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #D73A49">import</span><span style="color: #24292E"> { <data-lsp lsp='(alias) function writeFileSync(file: PathOrFileDescriptor, data: string | NodeJS.ArrayBufferView, options?: WriteFileOptions): void&#10;import writeFileSync' >writeFileSync</data-lsp> } </span><span style="color: #D73A49">from</span><span style="color: #24292E"> </span><span style="color: #032F62">&apos;fs&apos;</span></div><div class='line'><span style="color: #6F42C1"><data-lsp lsp='(alias) writeFileSync(file: PathOrFileDescriptor, data: string | NodeJS.ArrayBufferView, options?: WriteFileOptions | undefined): void&#10;import writeFileSync' >writeFileSync</data-lsp></span><span style="color: #24292E">(</span><span style="color: #032F62">&apos;myfile.txt&apos;</span><span style="color: #24292E">, </span><span style="color: #032F62">&apos;// TODO&apos;</span><span style="color: #24292E">)</span></div></code></div></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="language-md vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">md</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">```ts twoslash</span></span>
<span class="line"><span style="color: #768390">/// &lt;</span><span style="color: #8DDB8C">reference</span><span style="color: #768390"> </span><span style="color: #6CB6FF">types</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;node&quot;</span><span style="color: #768390"> /&gt;</span></span>
<span class="line"><span style="color: #768390">// ---cut---</span></span>
<span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> { writeFileSync } </span><span style="color: #F47067">from</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;fs&#39;</span></span>
<span class="line"><span style="color: #DCBDFB">writeFileSync</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&#39;myfile.txt&#39;</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&#39;// TODO&#39;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">```</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">```ts twoslash</span></span>
<span class="line"><span style="color: #6A737D">/// &lt;</span><span style="color: #22863A">reference</span><span style="color: #6A737D"> </span><span style="color: #6F42C1">types</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;node&quot;</span><span style="color: #6A737D"> /&gt;</span></span>
<span class="line"><span style="color: #6A737D">// ---cut---</span></span>
<span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> { writeFileSync } </span><span style="color: #D73A49">from</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;fs&#39;</span></span>
<span class="line"><span style="color: #6F42C1">writeFileSync</span><span style="color: #24292E">(</span><span style="color: #032F62">&#39;myfile.txt&#39;</span><span style="color: #24292E">, </span><span style="color: #032F62">&#39;// TODO&#39;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">```</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br></div></div></div></div>
<p>APIs like <a href="https://vitest.dev" target="_blank" rel="noreferrer">Vitest</a> are similar cases where you would use a triple slash reference.</p>
<div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-qSKEc" id="tab-MPXJMqb" checked="checked"><label for="tab-MPXJMqb">output</label><input type="radio" name="group-qSKEc" id="tab-yGs3Hrd" ><label for="tab-yGs3Hrd">markdown</label></div><div class="blocks">
<div class="language-ts vp-adaptive-theme active line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki github-dark-dimmed twoslash lsp" style="background-color: #22272e; color: #adbac7"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #DCBDFB"><data-lsp lsp='const test: any' >test</data-lsp></span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&apos;my tests&apos;</span><span style="color: #ADBAC7">, () </span><span style="color: #F47067">=&gt;</span><span style="color: #ADBAC7"> {</span></div><div class='line'><span style="color: #ADBAC7">    </span><span style="color: #DCBDFB"><data-lsp lsp='const expect: ExpectStatic' style='border-bottom: solid 2px lightgrey;'>expect</data-lsp></span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&apos;hello&apos;</span><span style="color: #ADBAC7">).</span><span style="color: #DCBDFB"><data-lsp lsp='any' >toEqual</data-lsp></span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&apos;hello&apos;</span><span style="color: #ADBAC7">)</span></div><div class='meta-line'><span class='popover-prefix'>      </span><span class='popover'><div class='arrow'></div>const expect: ExpectStatic</span></div><div class='line'><span style="color: #ADBAC7">})</span></div></code></div></pre>
<pre class="shiki github-light twoslash lsp" style="background-color: #fff; color: #24292e"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #6F42C1"><data-lsp lsp='const test: any' >test</data-lsp></span><span style="color: #24292E">(</span><span style="color: #032F62">&apos;my tests&apos;</span><span style="color: #24292E">, () </span><span style="color: #D73A49">=&gt;</span><span style="color: #24292E"> {</span></div><div class='line'><span style="color: #24292E">    </span><span style="color: #6F42C1"><data-lsp lsp='const expect: ExpectStatic' style='border-bottom: solid 2px lightgrey;'>expect</data-lsp></span><span style="color: #24292E">(</span><span style="color: #032F62">&apos;hello&apos;</span><span style="color: #24292E">).</span><span style="color: #6F42C1"><data-lsp lsp='any' >toEqual</data-lsp></span><span style="color: #24292E">(</span><span style="color: #032F62">&apos;hello&apos;</span><span style="color: #24292E">)</span></div><div class='meta-line'><span class='popover-prefix'>      </span><span class='popover'><div class='arrow'></div>const expect: ExpectStatic</span></div><div class='line'><span style="color: #24292E">})</span></div></code></div></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="language-md vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">md</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">```ts twoslash</span></span>
<span class="line"><span style="color: #768390">/// &lt;</span><span style="color: #8DDB8C">reference</span><span style="color: #768390"> </span><span style="color: #6CB6FF">types</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;vitest/globals&quot;</span><span style="color: #768390"> /&gt;</span></span>
<span class="line"><span style="color: #768390">// ---cut---</span></span>
<span class="line"></span>
<span class="line"><span style="color: #DCBDFB">test</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&#39;my tests&#39;</span><span style="color: #ADBAC7">, () </span><span style="color: #F47067">=&gt;</span><span style="color: #ADBAC7"> {</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #DCBDFB">expect</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&#39;hello&#39;</span><span style="color: #ADBAC7">).</span><span style="color: #DCBDFB">toEqual</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&#39;hello&#39;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #768390">// ^?</span></span>
<span class="line"><span style="color: #ADBAC7">})</span></span>
<span class="line"><span style="color: #ADBAC7">```</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">```ts twoslash</span></span>
<span class="line"><span style="color: #6A737D">/// &lt;</span><span style="color: #22863A">reference</span><span style="color: #6A737D"> </span><span style="color: #6F42C1">types</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;vitest/globals&quot;</span><span style="color: #6A737D"> /&gt;</span></span>
<span class="line"><span style="color: #6A737D">// ---cut---</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6F42C1">test</span><span style="color: #24292E">(</span><span style="color: #032F62">&#39;my tests&#39;</span><span style="color: #24292E">, () </span><span style="color: #D73A49">=&gt;</span><span style="color: #24292E"> {</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #6F42C1">expect</span><span style="color: #24292E">(</span><span style="color: #032F62">&#39;hello&#39;</span><span style="color: #24292E">).</span><span style="color: #6F42C1">toEqual</span><span style="color: #24292E">(</span><span style="color: #032F62">&#39;hello&#39;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #6A737D">// ^?</span></span>
<span class="line"><span style="color: #24292E">})</span></span>
<span class="line"><span style="color: #24292E">```</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br></div></div></div></div>
]]></description>
            <content:encoded><![CDATA[<h1 id="types" tabindex="-1">@types <a class="header-anchor" href="#types" aria-label="Permalink to &quot;@types&quot;">&ZeroWidthSpace;</a></h1>
<p>For most examples, you probably need to import external libraries into your code examples.</p>
<p>Twoslash works by faking a virtual file system over your existing file system. This means any <code>@types</code> or libraries with TypeScript definitions should work out of the box with no config.</p>
<h2 id="local-sources" tabindex="-1">Local Sources <a class="header-anchor" href="#local-sources" aria-label="Permalink to &quot;Local Sources&quot;">&ZeroWidthSpace;</a></h2>
<p>Simply import locally installed libraries and Twoslash can pick up types:</p>
<div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-UV8e4" id="tab-w8XoTVL" checked="checked"><label for="tab-w8XoTVL">output</label><input type="radio" name="group-UV8e4" id="tab-FTBqtcH" ><label for="tab-FTBqtcH">markdown</label></div><div class="blocks">
<div class="language-ts vp-adaptive-theme active line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki github-dark-dimmed twoslash lsp" style="background-color: #22272e; color: #adbac7"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #F47067">import</span><span style="color: #ADBAC7"> { <data-lsp lsp='(alias) function defineConfig(config: UserConfig&lt;DefaultTheme.Config>): UserConfig&lt;DefaultTheme.Config>&#10;import defineConfig' >defineConfig</data-lsp> } </span><span style="color: #F47067">from</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&apos;vitepress&apos;</span></div><div class='line'><span style="color: #F47067">const</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF"><data-lsp lsp='const config: UserConfig&lt;DefaultTheme.Config>' style='border-bottom: solid 2px lightgrey;'>config</data-lsp></span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB"><data-lsp lsp='(alias) defineConfig(config: UserConfig&lt;DefaultTheme.Config>): UserConfig&lt;DefaultTheme.Config>&#10;import defineConfig' >defineConfig</data-lsp></span><span style="color: #ADBAC7">({})</span></div><div class='meta-line'><span class='popover-prefix'>        </span><span class='popover'><div class='arrow'></div>const config: UserConfig&lt;DefaultTheme.Config&gt;</span></div><div class='line'><span style="color: #F47067">export</span><span style="color: #F69D50"> </span><span style="color: #F47067">default</span><span style="color: #F69D50"> </span><span style="color: #ADBAC7"><data-lsp lsp='const config: UserConfig&lt;DefaultTheme.Config>' >config</data-lsp></span></div></code></div></pre>
<pre class="shiki github-light twoslash lsp" style="background-color: #fff; color: #24292e"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #D73A49">import</span><span style="color: #24292E"> { <data-lsp lsp='(alias) function defineConfig(config: UserConfig&lt;DefaultTheme.Config>): UserConfig&lt;DefaultTheme.Config>&#10;import defineConfig' >defineConfig</data-lsp> } </span><span style="color: #D73A49">from</span><span style="color: #24292E"> </span><span style="color: #032F62">&apos;vitepress&apos;</span></div><div class='line'><span style="color: #D73A49">const</span><span style="color: #24292E"> </span><span style="color: #005CC5"><data-lsp lsp='const config: UserConfig&lt;DefaultTheme.Config>' style='border-bottom: solid 2px lightgrey;'>config</data-lsp></span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #6F42C1"><data-lsp lsp='(alias) defineConfig(config: UserConfig&lt;DefaultTheme.Config>): UserConfig&lt;DefaultTheme.Config>&#10;import defineConfig' >defineConfig</data-lsp></span><span style="color: #24292E">({})</span></div><div class='meta-line'><span class='popover-prefix'>        </span><span class='popover'><div class='arrow'></div>const config: UserConfig&lt;DefaultTheme.Config&gt;</span></div><div class='line'><span style="color: #D73A49">export</span><span style="color: #24292E"> </span><span style="color: #D73A49">default</span><span style="color: #24292E"> <data-lsp lsp='const config: UserConfig&lt;DefaultTheme.Config>' >config</data-lsp></span></div></code></div></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="language-md vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">md</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">```ts twoslash</span></span>
<span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> { defineConfig } </span><span style="color: #F47067">from</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;vitepress&#39;</span></span>
<span class="line"><span style="color: #F47067">const</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">config</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">defineConfig</span><span style="color: #ADBAC7">({})</span></span>
<span class="line"><span style="color: #768390">//    ^?</span></span>
<span class="line"><span style="color: #F47067">export</span><span style="color: #F69D50"> </span><span style="color: #F47067">default</span><span style="color: #F69D50"> </span><span style="color: #ADBAC7">config</span></span>
<span class="line"><span style="color: #ADBAC7">```</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">```ts twoslash</span></span>
<span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> { defineConfig } </span><span style="color: #D73A49">from</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;vitepress&#39;</span></span>
<span class="line"><span style="color: #D73A49">const</span><span style="color: #24292E"> </span><span style="color: #005CC5">config</span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #6F42C1">defineConfig</span><span style="color: #24292E">({})</span></span>
<span class="line"><span style="color: #6A737D">//    ^?</span></span>
<span class="line"><span style="color: #D73A49">export</span><span style="color: #24292E"> </span><span style="color: #D73A49">default</span><span style="color: #24292E"> config</span></span>
<span class="line"><span style="color: #24292E">```</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br></div></div></div></div>
<h2 id="globals" tabindex="-1">Globals <a class="header-anchor" href="#globals" aria-label="Permalink to &quot;Globals&quot;">&ZeroWidthSpace;</a></h2>
<p>Setting up globals is a little bit more complex, but not drastically. You need to use the <a href="https://www.typescriptlang.org/docs/handbook/triple-slash-directives.html#-reference-types-" target="_blank" rel="noreferrer">triple slash reference</a> which adds a particular library to the global scope.</p>
<p>For example, setting up Node imports and globals etc.</p>
<div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-Astq8" id="tab-NNY6SJ7" checked="checked"><label for="tab-NNY6SJ7">output</label><input type="radio" name="group-Astq8" id="tab--Y7I3mK" ><label for="tab--Y7I3mK">markdown</label></div><div class="blocks">
<div class="language-ts vp-adaptive-theme active line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki github-dark-dimmed twoslash lsp" style="background-color: #22272e; color: #adbac7"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #F47067">import</span><span style="color: #ADBAC7"> { <data-lsp lsp='(alias) function writeFileSync(file: PathOrFileDescriptor, data: string | NodeJS.ArrayBufferView, options?: WriteFileOptions): void&#10;import writeFileSync' >writeFileSync</data-lsp> } </span><span style="color: #F47067">from</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&apos;fs&apos;</span></div><div class='line'><span style="color: #DCBDFB"><data-lsp lsp='(alias) writeFileSync(file: PathOrFileDescriptor, data: string | NodeJS.ArrayBufferView, options?: WriteFileOptions | undefined): void&#10;import writeFileSync' >writeFileSync</data-lsp></span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&apos;myfile.txt&apos;</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&apos;// TODO&apos;</span><span style="color: #ADBAC7">)</span></div></code></div></pre>
<pre class="shiki github-light twoslash lsp" style="background-color: #fff; color: #24292e"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #D73A49">import</span><span style="color: #24292E"> { <data-lsp lsp='(alias) function writeFileSync(file: PathOrFileDescriptor, data: string | NodeJS.ArrayBufferView, options?: WriteFileOptions): void&#10;import writeFileSync' >writeFileSync</data-lsp> } </span><span style="color: #D73A49">from</span><span style="color: #24292E"> </span><span style="color: #032F62">&apos;fs&apos;</span></div><div class='line'><span style="color: #6F42C1"><data-lsp lsp='(alias) writeFileSync(file: PathOrFileDescriptor, data: string | NodeJS.ArrayBufferView, options?: WriteFileOptions | undefined): void&#10;import writeFileSync' >writeFileSync</data-lsp></span><span style="color: #24292E">(</span><span style="color: #032F62">&apos;myfile.txt&apos;</span><span style="color: #24292E">, </span><span style="color: #032F62">&apos;// TODO&apos;</span><span style="color: #24292E">)</span></div></code></div></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="language-md vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">md</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">```ts twoslash</span></span>
<span class="line"><span style="color: #768390">/// &lt;</span><span style="color: #8DDB8C">reference</span><span style="color: #768390"> </span><span style="color: #6CB6FF">types</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;node&quot;</span><span style="color: #768390"> /&gt;</span></span>
<span class="line"><span style="color: #768390">// ---cut---</span></span>
<span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> { writeFileSync } </span><span style="color: #F47067">from</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;fs&#39;</span></span>
<span class="line"><span style="color: #DCBDFB">writeFileSync</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&#39;myfile.txt&#39;</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&#39;// TODO&#39;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">```</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">```ts twoslash</span></span>
<span class="line"><span style="color: #6A737D">/// &lt;</span><span style="color: #22863A">reference</span><span style="color: #6A737D"> </span><span style="color: #6F42C1">types</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;node&quot;</span><span style="color: #6A737D"> /&gt;</span></span>
<span class="line"><span style="color: #6A737D">// ---cut---</span></span>
<span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> { writeFileSync } </span><span style="color: #D73A49">from</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;fs&#39;</span></span>
<span class="line"><span style="color: #6F42C1">writeFileSync</span><span style="color: #24292E">(</span><span style="color: #032F62">&#39;myfile.txt&#39;</span><span style="color: #24292E">, </span><span style="color: #032F62">&#39;// TODO&#39;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">```</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br></div></div></div></div>
<p>APIs like <a href="https://vitest.dev" target="_blank" rel="noreferrer">Vitest</a> are similar cases where you would use a triple slash reference.</p>
<div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-qSKEc" id="tab-MPXJMqb" checked="checked"><label for="tab-MPXJMqb">output</label><input type="radio" name="group-qSKEc" id="tab-yGs3Hrd" ><label for="tab-yGs3Hrd">markdown</label></div><div class="blocks">
<div class="language-ts vp-adaptive-theme active line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki github-dark-dimmed twoslash lsp" style="background-color: #22272e; color: #adbac7"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #DCBDFB"><data-lsp lsp='const test: any' >test</data-lsp></span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&apos;my tests&apos;</span><span style="color: #ADBAC7">, () </span><span style="color: #F47067">=&gt;</span><span style="color: #ADBAC7"> {</span></div><div class='line'><span style="color: #ADBAC7">    </span><span style="color: #DCBDFB"><data-lsp lsp='const expect: ExpectStatic' style='border-bottom: solid 2px lightgrey;'>expect</data-lsp></span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&apos;hello&apos;</span><span style="color: #ADBAC7">).</span><span style="color: #DCBDFB"><data-lsp lsp='any' >toEqual</data-lsp></span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&apos;hello&apos;</span><span style="color: #ADBAC7">)</span></div><div class='meta-line'><span class='popover-prefix'>      </span><span class='popover'><div class='arrow'></div>const expect: ExpectStatic</span></div><div class='line'><span style="color: #ADBAC7">})</span></div></code></div></pre>
<pre class="shiki github-light twoslash lsp" style="background-color: #fff; color: #24292e"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #6F42C1"><data-lsp lsp='const test: any' >test</data-lsp></span><span style="color: #24292E">(</span><span style="color: #032F62">&apos;my tests&apos;</span><span style="color: #24292E">, () </span><span style="color: #D73A49">=&gt;</span><span style="color: #24292E"> {</span></div><div class='line'><span style="color: #24292E">    </span><span style="color: #6F42C1"><data-lsp lsp='const expect: ExpectStatic' style='border-bottom: solid 2px lightgrey;'>expect</data-lsp></span><span style="color: #24292E">(</span><span style="color: #032F62">&apos;hello&apos;</span><span style="color: #24292E">).</span><span style="color: #6F42C1"><data-lsp lsp='any' >toEqual</data-lsp></span><span style="color: #24292E">(</span><span style="color: #032F62">&apos;hello&apos;</span><span style="color: #24292E">)</span></div><div class='meta-line'><span class='popover-prefix'>      </span><span class='popover'><div class='arrow'></div>const expect: ExpectStatic</span></div><div class='line'><span style="color: #24292E">})</span></div></code></div></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="language-md vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">md</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">```ts twoslash</span></span>
<span class="line"><span style="color: #768390">/// &lt;</span><span style="color: #8DDB8C">reference</span><span style="color: #768390"> </span><span style="color: #6CB6FF">types</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;vitest/globals&quot;</span><span style="color: #768390"> /&gt;</span></span>
<span class="line"><span style="color: #768390">// ---cut---</span></span>
<span class="line"></span>
<span class="line"><span style="color: #DCBDFB">test</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&#39;my tests&#39;</span><span style="color: #ADBAC7">, () </span><span style="color: #F47067">=&gt;</span><span style="color: #ADBAC7"> {</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #DCBDFB">expect</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&#39;hello&#39;</span><span style="color: #ADBAC7">).</span><span style="color: #DCBDFB">toEqual</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&#39;hello&#39;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #768390">// ^?</span></span>
<span class="line"><span style="color: #ADBAC7">})</span></span>
<span class="line"><span style="color: #ADBAC7">```</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">```ts twoslash</span></span>
<span class="line"><span style="color: #6A737D">/// &lt;</span><span style="color: #22863A">reference</span><span style="color: #6A737D"> </span><span style="color: #6F42C1">types</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;vitest/globals&quot;</span><span style="color: #6A737D"> /&gt;</span></span>
<span class="line"><span style="color: #6A737D">// ---cut---</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6F42C1">test</span><span style="color: #24292E">(</span><span style="color: #032F62">&#39;my tests&#39;</span><span style="color: #24292E">, () </span><span style="color: #D73A49">=&gt;</span><span style="color: #24292E"> {</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #6F42C1">expect</span><span style="color: #24292E">(</span><span style="color: #032F62">&#39;hello&#39;</span><span style="color: #24292E">).</span><span style="color: #6F42C1">toEqual</span><span style="color: #24292E">(</span><span style="color: #032F62">&#39;hello&#39;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #6A737D">// ^?</span></span>
<span class="line"><span style="color: #24292E">})</span></span>
<span class="line"><span style="color: #24292E">```</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br></div></div></div></div>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Compiler Flags]]></title>
            <link>https://note.toshiki.devapplication/vitepress-plugin-shiki-twoslash/config/flags</link>
            <guid>https://note.toshiki.devapplication/vitepress-plugin-shiki-twoslash/config/flags</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="compiler-flags" tabindex="-1">Compiler Flags <a class="header-anchor" href="#compiler-flags" aria-label="Permalink to &quot;Compiler Flags&quot;">&ZeroWidthSpace;</a></h1>
<div class="language- vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #adbac7">// @allowJs</span></span>
<span class="line"><span style="color: #adbac7">Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @allowSyntheticDefaultImports</span></span>
<span class="line"><span style="color: #adbac7">Allow &#39;import x from y&#39; when a module doesn&#39;t have a default export..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @allowUmdGlobalAccess</span></span>
<span class="line"><span style="color: #adbac7">Allow accessing UMD globals from modules..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @allowUnreachableCode</span></span>
<span class="line"><span style="color: #adbac7">Disable error reporting for unreachable code..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @allowUnusedLabels</span></span>
<span class="line"><span style="color: #adbac7">Disable error reporting for unused labels..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @alwaysStrict</span></span>
<span class="line"><span style="color: #adbac7">Ensure &#39;use strict&#39; is always emitted..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @assumeChangesOnlyAffectDirectDependencies</span></span>
<span class="line"><span style="color: #adbac7">Have recompiles in projects that use `incremental` and `watch` mode assume that changes within a file will only affect files directly depending on it..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @baseUrl</span></span>
<span class="line"><span style="color: #adbac7">Specify the base directory to resolve non-relative module names..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @charset</span></span>
<span class="line"><span style="color: #adbac7">No longer supported. In early versions, manually set the text encoding for reading files..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @checkJs</span></span>
<span class="line"><span style="color: #adbac7">Enable error reporting in type-checked JavaScript files..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @composite</span></span>
<span class="line"><span style="color: #adbac7">Enable constraints that allow a TypeScript project to be used with project references..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @declaration</span></span>
<span class="line"><span style="color: #adbac7">Generate .d.ts files from TypeScript and JavaScript files in your project..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @declarationDir</span></span>
<span class="line"><span style="color: #adbac7">Specify the output directory for generated declaration files..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @declarationMap</span></span>
<span class="line"><span style="color: #adbac7">Create sourcemaps for d.ts files..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @diagnostics</span></span>
<span class="line"><span style="color: #adbac7">Output compiler performance information after building..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @disableReferencedProjectLoad</span></span>
<span class="line"><span style="color: #adbac7">Reduce the number of projects loaded automatically by TypeScript..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @disableSizeLimit</span></span>
<span class="line"><span style="color: #adbac7">Remove the 20mb cap on total source code size for JavaScript files in the TypeScript language server..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @disableSolutionSearching</span></span>
<span class="line"><span style="color: #adbac7">Opt a project out of multi-project reference checking when editing..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @disableSourceOfProjectReferenceRedirect</span></span>
<span class="line"><span style="color: #adbac7">Disable preferring source files instead of declaration files when referencing composite projects.</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @downlevelIteration</span></span>
<span class="line"><span style="color: #adbac7">Emit more compliant, but verbose and less performant JavaScript for iteration..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @emitBOM</span></span>
<span class="line"><span style="color: #adbac7">Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @emitDeclarationOnly</span></span>
<span class="line"><span style="color: #adbac7">Only output d.ts files and not JavaScript files..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @emitDecoratorMetadata</span></span>
<span class="line"><span style="color: #adbac7">Emit design-type metadata for decorated declarations in source files..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @esModuleInterop</span></span>
<span class="line"><span style="color: #adbac7">Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @exactOptionalPropertyTypes</span></span>
<span class="line"><span style="color: #adbac7">Interpret optional property types as written, rather than adding &#39;undefined&#39;..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @experimentalDecorators</span></span>
<span class="line"><span style="color: #adbac7">Enable experimental support for TC39 stage 2 draft decorators..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @explainFiles</span></span>
<span class="line"><span style="color: #adbac7">Print files read during the compilation including why it was included..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @extendedDiagnostics</span></span>
<span class="line"><span style="color: #adbac7">Output more detailed compiler performance information after building..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @forceConsistentCasingInFileNames</span></span>
<span class="line"><span style="color: #adbac7">Ensure that casing is correct in imports..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @generateCpuProfile</span></span>
<span class="line"><span style="color: #adbac7">Emit a v8 CPU profile of the compiler run for debugging..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @importHelpers</span></span>
<span class="line"><span style="color: #adbac7">Allow importing helper functions from tslib once per project, instead of including them per-file..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @importsNotUsedAsValues</span></span>
<span class="line"><span style="color: #adbac7">Specify emit/checking behavior for imports that are only used for types.</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @incremental</span></span>
<span class="line"><span style="color: #adbac7">Enable incremental compilation.</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @inlineSourceMap</span></span>
<span class="line"><span style="color: #adbac7">Include sourcemap files inside the emitted JavaScript..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @inlineSources</span></span>
<span class="line"><span style="color: #adbac7">Include source code in the sourcemaps inside the emitted JavaScript..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @isolatedModules</span></span>
<span class="line"><span style="color: #adbac7">Ensure that each file can be safely transpiled without relying on other imports..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @jsx</span></span>
<span class="line"><span style="color: #adbac7">Specify what JSX code is generated..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @jsxFactory</span></span>
<span class="line"><span style="color: #adbac7">Specify the JSX factory function used when targeting React JSX emit, e.g. &#39;React.createElement&#39; or &#39;h&#39;.</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @jsxFragmentFactory</span></span>
<span class="line"><span style="color: #adbac7">Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. &#39;React.Fragment&#39; or &#39;Fragment&#39;..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @jsxImportSource</span></span>
<span class="line"><span style="color: #adbac7">Specify module specifier used to import the JSX factory functions when using `jsx: react-jsx*`.`.</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @keyofStringsOnly</span></span>
<span class="line"><span style="color: #adbac7">Make keyof only return strings instead of string, numbers or symbols. Legacy option..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @lib</span></span>
<span class="line"><span style="color: #adbac7">Specify a set of bundled library declaration files that describe the target runtime environment..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @listEmittedFiles</span></span>
<span class="line"><span style="color: #adbac7">Print the names of emitted files after a compilation..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @listFiles</span></span>
<span class="line"><span style="color: #adbac7">Print all of the files read during the compilation..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @mapRoot</span></span>
<span class="line"><span style="color: #adbac7">Specify the location where debugger should locate map files instead of generated locations..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @maxNodeModuleJsDepth</span></span>
<span class="line"><span style="color: #adbac7">Specify the maximum folder depth used for checking JavaScript files from `node_modules`. Only applicable with `allowJs`..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @module</span></span>
<span class="line"><span style="color: #adbac7">Specify what module code is generated..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @moduleResolution</span></span>
<span class="line"><span style="color: #adbac7">Specify how TypeScript looks up a file from a given module specifier..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @newLine</span></span>
<span class="line"><span style="color: #adbac7">Set the newline character for emitting files..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @noEmit</span></span>
<span class="line"><span style="color: #adbac7">Disable emitting file from a compilation..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @noEmitHelpers</span></span>
<span class="line"><span style="color: #adbac7">Disable generating custom helper functions like `__extends` in compiled output..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @noEmitOnError</span></span>
<span class="line"><span style="color: #adbac7">Disable emitting files if any type checking errors are reported..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @noErrorTruncation</span></span>
<span class="line"><span style="color: #adbac7">Disable truncating types in error messages..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @noFallthroughCasesInSwitch</span></span>
<span class="line"><span style="color: #adbac7">Enable error reporting for fallthrough cases in switch statements..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @noImplicitAny</span></span>
<span class="line"><span style="color: #adbac7">Enable error reporting for expressions and declarations with an implied `any` type...</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @noImplicitOverride</span></span>
<span class="line"><span style="color: #adbac7">Add `undefined` to a type when accessed using an index..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @noImplicitReturns</span></span>
<span class="line"><span style="color: #adbac7">Enable error reporting for codepaths that do not explicitly return in a function..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @noImplicitThis</span></span>
<span class="line"><span style="color: #adbac7">Enable error reporting when `this` is given the type `any`..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @noImplicitUseStrict</span></span>
<span class="line"><span style="color: #adbac7">Disable adding &#39;use strict&#39; directives in emitted JavaScript files..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @noLib</span></span>
<span class="line"><span style="color: #adbac7">Disable including any library files, including the default lib.d.ts..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @noPropertyAccessFromIndexSignature</span></span>
<span class="line"><span style="color: #adbac7">Enforces using indexed accessors for keys declared using an indexed type.</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @noResolve</span></span>
<span class="line"><span style="color: #adbac7">Disallow `import`s, `require`s or ``s from expanding the number of files TypeScript should add to a project..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @noStrictGenericChecks</span></span>
<span class="line"><span style="color: #adbac7">Disable strict checking of generic signatures in function types..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @noUncheckedIndexedAccess</span></span>
<span class="line"><span style="color: #adbac7">Include &#39;undefined&#39; in index signature results.</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @noUnusedLocals</span></span>
<span class="line"><span style="color: #adbac7">Enable error reporting when a local variables aren&#39;t read..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @noUnusedParameters</span></span>
<span class="line"><span style="color: #adbac7">Raise an error when a function parameter isn&#39;t read.</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @out</span></span>
<span class="line"><span style="color: #adbac7">Deprecated setting. Use `outFile` instead..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @outDir</span></span>
<span class="line"><span style="color: #adbac7">Specify an output folder for all emitted files..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @outFile</span></span>
<span class="line"><span style="color: #adbac7">Specify a file that bundles all outputs into one JavaScript file. If `declaration` is true, also designates a file that bundles all .d.ts output..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @paths</span></span>
<span class="line"><span style="color: #adbac7">Specify a set of entries that re-map imports to additional lookup locations..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @plugins</span></span>
<span class="line"><span style="color: #adbac7">List of language service plugins..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @preserveConstEnums</span></span>
<span class="line"><span style="color: #adbac7">Disable erasing `const enum` declarations in generated code..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @preserveSymlinks</span></span>
<span class="line"><span style="color: #adbac7">Disable resolving symlinks to their realpath. This correlates to the same flag in node..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @preserveWatchOutput</span></span>
<span class="line"><span style="color: #adbac7">Disable wiping the console in watch mode.</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @pretty</span></span>
<span class="line"><span style="color: #adbac7">Enable color and formatting in output to make compiler errors easier to read.</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @reactNamespace</span></span>
<span class="line"><span style="color: #adbac7">Specify the object invoked for `createElement`. This only applies when targeting `react` JSX emit..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @removeComments</span></span>
<span class="line"><span style="color: #adbac7">Disable emitting comments..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @resolveJsonModule</span></span>
<span class="line"><span style="color: #adbac7">Enable importing .json files.</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @rootDir</span></span>
<span class="line"><span style="color: #adbac7">Specify the root folder within your source files..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @rootDirs</span></span>
<span class="line"><span style="color: #adbac7">Allow multiple folders to be treated as one when resolving modules..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @skipDefaultLibCheck</span></span>
<span class="line"><span style="color: #adbac7">Skip type checking .d.ts files that are included with TypeScript..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @skipLibCheck</span></span>
<span class="line"><span style="color: #adbac7">Skip type checking all .d.ts files..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @sourceMap</span></span>
<span class="line"><span style="color: #adbac7">Create source map files for emitted JavaScript files..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @sourceRoot</span></span>
<span class="line"><span style="color: #adbac7">Specify the root path for debuggers to find the reference source code..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @strict</span></span>
<span class="line"><span style="color: #adbac7">Enable all strict type-checking options..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @strictBindCallApply</span></span>
<span class="line"><span style="color: #adbac7">Check that the arguments for `bind`, `call`, and `apply` methods match the original function..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @strictFunctionTypes</span></span>
<span class="line"><span style="color: #adbac7">When assigning functions, check to ensure parameters and the return values are subtype-compatible..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @strictNullChecks</span></span>
<span class="line"><span style="color: #adbac7">When type checking, take into account `null` and `undefined`..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @strictPropertyInitialization</span></span>
<span class="line"><span style="color: #adbac7">Check for class properties that are declared but not set in the constructor..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @stripInternal</span></span>
<span class="line"><span style="color: #adbac7">Disable emitting declarations that have `@internal` in their JSDoc comments..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @suppressExcessPropertyErrors</span></span>
<span class="line"><span style="color: #adbac7">Disable reporting of excess property errors during the creation of object literals..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @suppressImplicitAnyIndexErrors</span></span>
<span class="line"><span style="color: #adbac7">Suppress `noImplicitAny` errors when indexing objects that lack index signatures..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @target</span></span>
<span class="line"><span style="color: #adbac7">Set the JavaScript language version for emitted JavaScript and include compatible library declarations..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @traceResolution</span></span>
<span class="line"><span style="color: #adbac7">Log paths used during the `moduleResolution` process..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @tsBuildInfoFile</span></span>
<span class="line"><span style="color: #adbac7">Specify the folder for .tsbuildinfo incremental compilation files..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @typeRoots</span></span>
<span class="line"><span style="color: #adbac7">Specify multiple folders that act like `./node_modules/@types`..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @types</span></span>
<span class="line"><span style="color: #adbac7">Specify type package names to be included without being referenced in a source file..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @useDefineForClassFields</span></span>
<span class="line"><span style="color: #adbac7">Emit ECMAScript-standard-compliant class fields..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @useUnknownInCatchVariables</span></span>
<span class="line"><span style="color: #adbac7">Type catch clause variables as &#39;unknown&#39; instead of &#39;any&#39;..</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292e">// @allowJs</span></span>
<span class="line"><span style="color: #24292e">Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @allowSyntheticDefaultImports</span></span>
<span class="line"><span style="color: #24292e">Allow &#39;import x from y&#39; when a module doesn&#39;t have a default export..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @allowUmdGlobalAccess</span></span>
<span class="line"><span style="color: #24292e">Allow accessing UMD globals from modules..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @allowUnreachableCode</span></span>
<span class="line"><span style="color: #24292e">Disable error reporting for unreachable code..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @allowUnusedLabels</span></span>
<span class="line"><span style="color: #24292e">Disable error reporting for unused labels..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @alwaysStrict</span></span>
<span class="line"><span style="color: #24292e">Ensure &#39;use strict&#39; is always emitted..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @assumeChangesOnlyAffectDirectDependencies</span></span>
<span class="line"><span style="color: #24292e">Have recompiles in projects that use `incremental` and `watch` mode assume that changes within a file will only affect files directly depending on it..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @baseUrl</span></span>
<span class="line"><span style="color: #24292e">Specify the base directory to resolve non-relative module names..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @charset</span></span>
<span class="line"><span style="color: #24292e">No longer supported. In early versions, manually set the text encoding for reading files..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @checkJs</span></span>
<span class="line"><span style="color: #24292e">Enable error reporting in type-checked JavaScript files..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @composite</span></span>
<span class="line"><span style="color: #24292e">Enable constraints that allow a TypeScript project to be used with project references..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @declaration</span></span>
<span class="line"><span style="color: #24292e">Generate .d.ts files from TypeScript and JavaScript files in your project..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @declarationDir</span></span>
<span class="line"><span style="color: #24292e">Specify the output directory for generated declaration files..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @declarationMap</span></span>
<span class="line"><span style="color: #24292e">Create sourcemaps for d.ts files..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @diagnostics</span></span>
<span class="line"><span style="color: #24292e">Output compiler performance information after building..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @disableReferencedProjectLoad</span></span>
<span class="line"><span style="color: #24292e">Reduce the number of projects loaded automatically by TypeScript..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @disableSizeLimit</span></span>
<span class="line"><span style="color: #24292e">Remove the 20mb cap on total source code size for JavaScript files in the TypeScript language server..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @disableSolutionSearching</span></span>
<span class="line"><span style="color: #24292e">Opt a project out of multi-project reference checking when editing..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @disableSourceOfProjectReferenceRedirect</span></span>
<span class="line"><span style="color: #24292e">Disable preferring source files instead of declaration files when referencing composite projects.</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @downlevelIteration</span></span>
<span class="line"><span style="color: #24292e">Emit more compliant, but verbose and less performant JavaScript for iteration..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @emitBOM</span></span>
<span class="line"><span style="color: #24292e">Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @emitDeclarationOnly</span></span>
<span class="line"><span style="color: #24292e">Only output d.ts files and not JavaScript files..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @emitDecoratorMetadata</span></span>
<span class="line"><span style="color: #24292e">Emit design-type metadata for decorated declarations in source files..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @esModuleInterop</span></span>
<span class="line"><span style="color: #24292e">Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @exactOptionalPropertyTypes</span></span>
<span class="line"><span style="color: #24292e">Interpret optional property types as written, rather than adding &#39;undefined&#39;..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @experimentalDecorators</span></span>
<span class="line"><span style="color: #24292e">Enable experimental support for TC39 stage 2 draft decorators..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @explainFiles</span></span>
<span class="line"><span style="color: #24292e">Print files read during the compilation including why it was included..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @extendedDiagnostics</span></span>
<span class="line"><span style="color: #24292e">Output more detailed compiler performance information after building..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @forceConsistentCasingInFileNames</span></span>
<span class="line"><span style="color: #24292e">Ensure that casing is correct in imports..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @generateCpuProfile</span></span>
<span class="line"><span style="color: #24292e">Emit a v8 CPU profile of the compiler run for debugging..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @importHelpers</span></span>
<span class="line"><span style="color: #24292e">Allow importing helper functions from tslib once per project, instead of including them per-file..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @importsNotUsedAsValues</span></span>
<span class="line"><span style="color: #24292e">Specify emit/checking behavior for imports that are only used for types.</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @incremental</span></span>
<span class="line"><span style="color: #24292e">Enable incremental compilation.</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @inlineSourceMap</span></span>
<span class="line"><span style="color: #24292e">Include sourcemap files inside the emitted JavaScript..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @inlineSources</span></span>
<span class="line"><span style="color: #24292e">Include source code in the sourcemaps inside the emitted JavaScript..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @isolatedModules</span></span>
<span class="line"><span style="color: #24292e">Ensure that each file can be safely transpiled without relying on other imports..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @jsx</span></span>
<span class="line"><span style="color: #24292e">Specify what JSX code is generated..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @jsxFactory</span></span>
<span class="line"><span style="color: #24292e">Specify the JSX factory function used when targeting React JSX emit, e.g. &#39;React.createElement&#39; or &#39;h&#39;.</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @jsxFragmentFactory</span></span>
<span class="line"><span style="color: #24292e">Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. &#39;React.Fragment&#39; or &#39;Fragment&#39;..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @jsxImportSource</span></span>
<span class="line"><span style="color: #24292e">Specify module specifier used to import the JSX factory functions when using `jsx: react-jsx*`.`.</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @keyofStringsOnly</span></span>
<span class="line"><span style="color: #24292e">Make keyof only return strings instead of string, numbers or symbols. Legacy option..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @lib</span></span>
<span class="line"><span style="color: #24292e">Specify a set of bundled library declaration files that describe the target runtime environment..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @listEmittedFiles</span></span>
<span class="line"><span style="color: #24292e">Print the names of emitted files after a compilation..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @listFiles</span></span>
<span class="line"><span style="color: #24292e">Print all of the files read during the compilation..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @mapRoot</span></span>
<span class="line"><span style="color: #24292e">Specify the location where debugger should locate map files instead of generated locations..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @maxNodeModuleJsDepth</span></span>
<span class="line"><span style="color: #24292e">Specify the maximum folder depth used for checking JavaScript files from `node_modules`. Only applicable with `allowJs`..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @module</span></span>
<span class="line"><span style="color: #24292e">Specify what module code is generated..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @moduleResolution</span></span>
<span class="line"><span style="color: #24292e">Specify how TypeScript looks up a file from a given module specifier..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @newLine</span></span>
<span class="line"><span style="color: #24292e">Set the newline character for emitting files..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @noEmit</span></span>
<span class="line"><span style="color: #24292e">Disable emitting file from a compilation..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @noEmitHelpers</span></span>
<span class="line"><span style="color: #24292e">Disable generating custom helper functions like `__extends` in compiled output..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @noEmitOnError</span></span>
<span class="line"><span style="color: #24292e">Disable emitting files if any type checking errors are reported..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @noErrorTruncation</span></span>
<span class="line"><span style="color: #24292e">Disable truncating types in error messages..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @noFallthroughCasesInSwitch</span></span>
<span class="line"><span style="color: #24292e">Enable error reporting for fallthrough cases in switch statements..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @noImplicitAny</span></span>
<span class="line"><span style="color: #24292e">Enable error reporting for expressions and declarations with an implied `any` type...</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @noImplicitOverride</span></span>
<span class="line"><span style="color: #24292e">Add `undefined` to a type when accessed using an index..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @noImplicitReturns</span></span>
<span class="line"><span style="color: #24292e">Enable error reporting for codepaths that do not explicitly return in a function..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @noImplicitThis</span></span>
<span class="line"><span style="color: #24292e">Enable error reporting when `this` is given the type `any`..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @noImplicitUseStrict</span></span>
<span class="line"><span style="color: #24292e">Disable adding &#39;use strict&#39; directives in emitted JavaScript files..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @noLib</span></span>
<span class="line"><span style="color: #24292e">Disable including any library files, including the default lib.d.ts..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @noPropertyAccessFromIndexSignature</span></span>
<span class="line"><span style="color: #24292e">Enforces using indexed accessors for keys declared using an indexed type.</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @noResolve</span></span>
<span class="line"><span style="color: #24292e">Disallow `import`s, `require`s or ``s from expanding the number of files TypeScript should add to a project..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @noStrictGenericChecks</span></span>
<span class="line"><span style="color: #24292e">Disable strict checking of generic signatures in function types..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @noUncheckedIndexedAccess</span></span>
<span class="line"><span style="color: #24292e">Include &#39;undefined&#39; in index signature results.</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @noUnusedLocals</span></span>
<span class="line"><span style="color: #24292e">Enable error reporting when a local variables aren&#39;t read..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @noUnusedParameters</span></span>
<span class="line"><span style="color: #24292e">Raise an error when a function parameter isn&#39;t read.</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @out</span></span>
<span class="line"><span style="color: #24292e">Deprecated setting. Use `outFile` instead..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @outDir</span></span>
<span class="line"><span style="color: #24292e">Specify an output folder for all emitted files..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @outFile</span></span>
<span class="line"><span style="color: #24292e">Specify a file that bundles all outputs into one JavaScript file. If `declaration` is true, also designates a file that bundles all .d.ts output..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @paths</span></span>
<span class="line"><span style="color: #24292e">Specify a set of entries that re-map imports to additional lookup locations..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @plugins</span></span>
<span class="line"><span style="color: #24292e">List of language service plugins..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @preserveConstEnums</span></span>
<span class="line"><span style="color: #24292e">Disable erasing `const enum` declarations in generated code..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @preserveSymlinks</span></span>
<span class="line"><span style="color: #24292e">Disable resolving symlinks to their realpath. This correlates to the same flag in node..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @preserveWatchOutput</span></span>
<span class="line"><span style="color: #24292e">Disable wiping the console in watch mode.</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @pretty</span></span>
<span class="line"><span style="color: #24292e">Enable color and formatting in output to make compiler errors easier to read.</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @reactNamespace</span></span>
<span class="line"><span style="color: #24292e">Specify the object invoked for `createElement`. This only applies when targeting `react` JSX emit..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @removeComments</span></span>
<span class="line"><span style="color: #24292e">Disable emitting comments..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @resolveJsonModule</span></span>
<span class="line"><span style="color: #24292e">Enable importing .json files.</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @rootDir</span></span>
<span class="line"><span style="color: #24292e">Specify the root folder within your source files..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @rootDirs</span></span>
<span class="line"><span style="color: #24292e">Allow multiple folders to be treated as one when resolving modules..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @skipDefaultLibCheck</span></span>
<span class="line"><span style="color: #24292e">Skip type checking .d.ts files that are included with TypeScript..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @skipLibCheck</span></span>
<span class="line"><span style="color: #24292e">Skip type checking all .d.ts files..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @sourceMap</span></span>
<span class="line"><span style="color: #24292e">Create source map files for emitted JavaScript files..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @sourceRoot</span></span>
<span class="line"><span style="color: #24292e">Specify the root path for debuggers to find the reference source code..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @strict</span></span>
<span class="line"><span style="color: #24292e">Enable all strict type-checking options..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @strictBindCallApply</span></span>
<span class="line"><span style="color: #24292e">Check that the arguments for `bind`, `call`, and `apply` methods match the original function..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @strictFunctionTypes</span></span>
<span class="line"><span style="color: #24292e">When assigning functions, check to ensure parameters and the return values are subtype-compatible..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @strictNullChecks</span></span>
<span class="line"><span style="color: #24292e">When type checking, take into account `null` and `undefined`..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @strictPropertyInitialization</span></span>
<span class="line"><span style="color: #24292e">Check for class properties that are declared but not set in the constructor..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @stripInternal</span></span>
<span class="line"><span style="color: #24292e">Disable emitting declarations that have `@internal` in their JSDoc comments..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @suppressExcessPropertyErrors</span></span>
<span class="line"><span style="color: #24292e">Disable reporting of excess property errors during the creation of object literals..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @suppressImplicitAnyIndexErrors</span></span>
<span class="line"><span style="color: #24292e">Suppress `noImplicitAny` errors when indexing objects that lack index signatures..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @target</span></span>
<span class="line"><span style="color: #24292e">Set the JavaScript language version for emitted JavaScript and include compatible library declarations..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @traceResolution</span></span>
<span class="line"><span style="color: #24292e">Log paths used during the `moduleResolution` process..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @tsBuildInfoFile</span></span>
<span class="line"><span style="color: #24292e">Specify the folder for .tsbuildinfo incremental compilation files..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @typeRoots</span></span>
<span class="line"><span style="color: #24292e">Specify multiple folders that act like `./node_modules/@types`..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @types</span></span>
<span class="line"><span style="color: #24292e">Specify type package names to be included without being referenced in a source file..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @useDefineForClassFields</span></span>
<span class="line"><span style="color: #24292e">Emit ECMAScript-standard-compliant class fields..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @useUnknownInCatchVariables</span></span>
<span class="line"><span style="color: #24292e">Type catch clause variables as &#39;unknown&#39; instead of &#39;any&#39;..</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br><span class="line-number">36</span><br><span class="line-number">37</span><br><span class="line-number">38</span><br><span class="line-number">39</span><br><span class="line-number">40</span><br><span class="line-number">41</span><br><span class="line-number">42</span><br><span class="line-number">43</span><br><span class="line-number">44</span><br><span class="line-number">45</span><br><span class="line-number">46</span><br><span class="line-number">47</span><br><span class="line-number">48</span><br><span class="line-number">49</span><br><span class="line-number">50</span><br><span class="line-number">51</span><br><span class="line-number">52</span><br><span class="line-number">53</span><br><span class="line-number">54</span><br><span class="line-number">55</span><br><span class="line-number">56</span><br><span class="line-number">57</span><br><span class="line-number">58</span><br><span class="line-number">59</span><br><span class="line-number">60</span><br><span class="line-number">61</span><br><span class="line-number">62</span><br><span class="line-number">63</span><br><span class="line-number">64</span><br><span class="line-number">65</span><br><span class="line-number">66</span><br><span class="line-number">67</span><br><span class="line-number">68</span><br><span class="line-number">69</span><br><span class="line-number">70</span><br><span class="line-number">71</span><br><span class="line-number">72</span><br><span class="line-number">73</span><br><span class="line-number">74</span><br><span class="line-number">75</span><br><span class="line-number">76</span><br><span class="line-number">77</span><br><span class="line-number">78</span><br><span class="line-number">79</span><br><span class="line-number">80</span><br><span class="line-number">81</span><br><span class="line-number">82</span><br><span class="line-number">83</span><br><span class="line-number">84</span><br><span class="line-number">85</span><br><span class="line-number">86</span><br><span class="line-number">87</span><br><span class="line-number">88</span><br><span class="line-number">89</span><br><span class="line-number">90</span><br><span class="line-number">91</span><br><span class="line-number">92</span><br><span class="line-number">93</span><br><span class="line-number">94</span><br><span class="line-number">95</span><br><span class="line-number">96</span><br><span class="line-number">97</span><br><span class="line-number">98</span><br><span class="line-number">99</span><br><span class="line-number">100</span><br><span class="line-number">101</span><br><span class="line-number">102</span><br><span class="line-number">103</span><br><span class="line-number">104</span><br><span class="line-number">105</span><br><span class="line-number">106</span><br><span class="line-number">107</span><br><span class="line-number">108</span><br><span class="line-number">109</span><br><span class="line-number">110</span><br><span class="line-number">111</span><br><span class="line-number">112</span><br><span class="line-number">113</span><br><span class="line-number">114</span><br><span class="line-number">115</span><br><span class="line-number">116</span><br><span class="line-number">117</span><br><span class="line-number">118</span><br><span class="line-number">119</span><br><span class="line-number">120</span><br><span class="line-number">121</span><br><span class="line-number">122</span><br><span class="line-number">123</span><br><span class="line-number">124</span><br><span class="line-number">125</span><br><span class="line-number">126</span><br><span class="line-number">127</span><br><span class="line-number">128</span><br><span class="line-number">129</span><br><span class="line-number">130</span><br><span class="line-number">131</span><br><span class="line-number">132</span><br><span class="line-number">133</span><br><span class="line-number">134</span><br><span class="line-number">135</span><br><span class="line-number">136</span><br><span class="line-number">137</span><br><span class="line-number">138</span><br><span class="line-number">139</span><br><span class="line-number">140</span><br><span class="line-number">141</span><br><span class="line-number">142</span><br><span class="line-number">143</span><br><span class="line-number">144</span><br><span class="line-number">145</span><br><span class="line-number">146</span><br><span class="line-number">147</span><br><span class="line-number">148</span><br><span class="line-number">149</span><br><span class="line-number">150</span><br><span class="line-number">151</span><br><span class="line-number">152</span><br><span class="line-number">153</span><br><span class="line-number">154</span><br><span class="line-number">155</span><br><span class="line-number">156</span><br><span class="line-number">157</span><br><span class="line-number">158</span><br><span class="line-number">159</span><br><span class="line-number">160</span><br><span class="line-number">161</span><br><span class="line-number">162</span><br><span class="line-number">163</span><br><span class="line-number">164</span><br><span class="line-number">165</span><br><span class="line-number">166</span><br><span class="line-number">167</span><br><span class="line-number">168</span><br><span class="line-number">169</span><br><span class="line-number">170</span><br><span class="line-number">171</span><br><span class="line-number">172</span><br><span class="line-number">173</span><br><span class="line-number">174</span><br><span class="line-number">175</span><br><span class="line-number">176</span><br><span class="line-number">177</span><br><span class="line-number">178</span><br><span class="line-number">179</span><br><span class="line-number">180</span><br><span class="line-number">181</span><br><span class="line-number">182</span><br><span class="line-number">183</span><br><span class="line-number">184</span><br><span class="line-number">185</span><br><span class="line-number">186</span><br><span class="line-number">187</span><br><span class="line-number">188</span><br><span class="line-number">189</span><br><span class="line-number">190</span><br><span class="line-number">191</span><br><span class="line-number">192</span><br><span class="line-number">193</span><br><span class="line-number">194</span><br><span class="line-number">195</span><br><span class="line-number">196</span><br><span class="line-number">197</span><br><span class="line-number">198</span><br><span class="line-number">199</span><br><span class="line-number">200</span><br><span class="line-number">201</span><br><span class="line-number">202</span><br><span class="line-number">203</span><br><span class="line-number">204</span><br><span class="line-number">205</span><br><span class="line-number">206</span><br><span class="line-number">207</span><br><span class="line-number">208</span><br><span class="line-number">209</span><br><span class="line-number">210</span><br><span class="line-number">211</span><br><span class="line-number">212</span><br><span class="line-number">213</span><br><span class="line-number">214</span><br><span class="line-number">215</span><br><span class="line-number">216</span><br><span class="line-number">217</span><br><span class="line-number">218</span><br><span class="line-number">219</span><br><span class="line-number">220</span><br><span class="line-number">221</span><br><span class="line-number">222</span><br><span class="line-number">223</span><br><span class="line-number">224</span><br><span class="line-number">225</span><br><span class="line-number">226</span><br><span class="line-number">227</span><br><span class="line-number">228</span><br><span class="line-number">229</span><br><span class="line-number">230</span><br><span class="line-number">231</span><br><span class="line-number">232</span><br><span class="line-number">233</span><br><span class="line-number">234</span><br><span class="line-number">235</span><br><span class="line-number">236</span><br><span class="line-number">237</span><br><span class="line-number">238</span><br><span class="line-number">239</span><br><span class="line-number">240</span><br><span class="line-number">241</span><br><span class="line-number">242</span><br><span class="line-number">243</span><br><span class="line-number">244</span><br><span class="line-number">245</span><br><span class="line-number">246</span><br><span class="line-number">247</span><br><span class="line-number">248</span><br><span class="line-number">249</span><br><span class="line-number">250</span><br><span class="line-number">251</span><br><span class="line-number">252</span><br><span class="line-number">253</span><br><span class="line-number">254</span><br><span class="line-number">255</span><br><span class="line-number">256</span><br><span class="line-number">257</span><br><span class="line-number">258</span><br><span class="line-number">259</span><br><span class="line-number">260</span><br><span class="line-number">261</span><br><span class="line-number">262</span><br><span class="line-number">263</span><br><span class="line-number">264</span><br><span class="line-number">265</span><br><span class="line-number">266</span><br><span class="line-number">267</span><br><span class="line-number">268</span><br><span class="line-number">269</span><br><span class="line-number">270</span><br><span class="line-number">271</span><br><span class="line-number">272</span><br><span class="line-number">273</span><br><span class="line-number">274</span><br><span class="line-number">275</span><br><span class="line-number">276</span><br><span class="line-number">277</span><br><span class="line-number">278</span><br><span class="line-number">279</span><br><span class="line-number">280</span><br><span class="line-number">281</span><br><span class="line-number">282</span><br><span class="line-number">283</span><br><span class="line-number">284</span><br><span class="line-number">285</span><br><span class="line-number">286</span><br><span class="line-number">287</span><br><span class="line-number">288</span><br><span class="line-number">289</span><br><span class="line-number">290</span><br><span class="line-number">291</span><br><span class="line-number">292</span><br><span class="line-number">293</span><br><span class="line-number">294</span><br><span class="line-number">295</span><br><span class="line-number">296</span><br></div></div>]]></description>
            <content:encoded><![CDATA[<h1 id="compiler-flags" tabindex="-1">Compiler Flags <a class="header-anchor" href="#compiler-flags" aria-label="Permalink to &quot;Compiler Flags&quot;">&ZeroWidthSpace;</a></h1>
<div class="language- vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #adbac7">// @allowJs</span></span>
<span class="line"><span style="color: #adbac7">Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @allowSyntheticDefaultImports</span></span>
<span class="line"><span style="color: #adbac7">Allow &#39;import x from y&#39; when a module doesn&#39;t have a default export..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @allowUmdGlobalAccess</span></span>
<span class="line"><span style="color: #adbac7">Allow accessing UMD globals from modules..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @allowUnreachableCode</span></span>
<span class="line"><span style="color: #adbac7">Disable error reporting for unreachable code..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @allowUnusedLabels</span></span>
<span class="line"><span style="color: #adbac7">Disable error reporting for unused labels..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @alwaysStrict</span></span>
<span class="line"><span style="color: #adbac7">Ensure &#39;use strict&#39; is always emitted..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @assumeChangesOnlyAffectDirectDependencies</span></span>
<span class="line"><span style="color: #adbac7">Have recompiles in projects that use `incremental` and `watch` mode assume that changes within a file will only affect files directly depending on it..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @baseUrl</span></span>
<span class="line"><span style="color: #adbac7">Specify the base directory to resolve non-relative module names..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @charset</span></span>
<span class="line"><span style="color: #adbac7">No longer supported. In early versions, manually set the text encoding for reading files..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @checkJs</span></span>
<span class="line"><span style="color: #adbac7">Enable error reporting in type-checked JavaScript files..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @composite</span></span>
<span class="line"><span style="color: #adbac7">Enable constraints that allow a TypeScript project to be used with project references..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @declaration</span></span>
<span class="line"><span style="color: #adbac7">Generate .d.ts files from TypeScript and JavaScript files in your project..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @declarationDir</span></span>
<span class="line"><span style="color: #adbac7">Specify the output directory for generated declaration files..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @declarationMap</span></span>
<span class="line"><span style="color: #adbac7">Create sourcemaps for d.ts files..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @diagnostics</span></span>
<span class="line"><span style="color: #adbac7">Output compiler performance information after building..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @disableReferencedProjectLoad</span></span>
<span class="line"><span style="color: #adbac7">Reduce the number of projects loaded automatically by TypeScript..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @disableSizeLimit</span></span>
<span class="line"><span style="color: #adbac7">Remove the 20mb cap on total source code size for JavaScript files in the TypeScript language server..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @disableSolutionSearching</span></span>
<span class="line"><span style="color: #adbac7">Opt a project out of multi-project reference checking when editing..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @disableSourceOfProjectReferenceRedirect</span></span>
<span class="line"><span style="color: #adbac7">Disable preferring source files instead of declaration files when referencing composite projects.</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @downlevelIteration</span></span>
<span class="line"><span style="color: #adbac7">Emit more compliant, but verbose and less performant JavaScript for iteration..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @emitBOM</span></span>
<span class="line"><span style="color: #adbac7">Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @emitDeclarationOnly</span></span>
<span class="line"><span style="color: #adbac7">Only output d.ts files and not JavaScript files..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @emitDecoratorMetadata</span></span>
<span class="line"><span style="color: #adbac7">Emit design-type metadata for decorated declarations in source files..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @esModuleInterop</span></span>
<span class="line"><span style="color: #adbac7">Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @exactOptionalPropertyTypes</span></span>
<span class="line"><span style="color: #adbac7">Interpret optional property types as written, rather than adding &#39;undefined&#39;..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @experimentalDecorators</span></span>
<span class="line"><span style="color: #adbac7">Enable experimental support for TC39 stage 2 draft decorators..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @explainFiles</span></span>
<span class="line"><span style="color: #adbac7">Print files read during the compilation including why it was included..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @extendedDiagnostics</span></span>
<span class="line"><span style="color: #adbac7">Output more detailed compiler performance information after building..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @forceConsistentCasingInFileNames</span></span>
<span class="line"><span style="color: #adbac7">Ensure that casing is correct in imports..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @generateCpuProfile</span></span>
<span class="line"><span style="color: #adbac7">Emit a v8 CPU profile of the compiler run for debugging..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @importHelpers</span></span>
<span class="line"><span style="color: #adbac7">Allow importing helper functions from tslib once per project, instead of including them per-file..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @importsNotUsedAsValues</span></span>
<span class="line"><span style="color: #adbac7">Specify emit/checking behavior for imports that are only used for types.</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @incremental</span></span>
<span class="line"><span style="color: #adbac7">Enable incremental compilation.</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @inlineSourceMap</span></span>
<span class="line"><span style="color: #adbac7">Include sourcemap files inside the emitted JavaScript..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @inlineSources</span></span>
<span class="line"><span style="color: #adbac7">Include source code in the sourcemaps inside the emitted JavaScript..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @isolatedModules</span></span>
<span class="line"><span style="color: #adbac7">Ensure that each file can be safely transpiled without relying on other imports..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @jsx</span></span>
<span class="line"><span style="color: #adbac7">Specify what JSX code is generated..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @jsxFactory</span></span>
<span class="line"><span style="color: #adbac7">Specify the JSX factory function used when targeting React JSX emit, e.g. &#39;React.createElement&#39; or &#39;h&#39;.</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @jsxFragmentFactory</span></span>
<span class="line"><span style="color: #adbac7">Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. &#39;React.Fragment&#39; or &#39;Fragment&#39;..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @jsxImportSource</span></span>
<span class="line"><span style="color: #adbac7">Specify module specifier used to import the JSX factory functions when using `jsx: react-jsx*`.`.</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @keyofStringsOnly</span></span>
<span class="line"><span style="color: #adbac7">Make keyof only return strings instead of string, numbers or symbols. Legacy option..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @lib</span></span>
<span class="line"><span style="color: #adbac7">Specify a set of bundled library declaration files that describe the target runtime environment..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @listEmittedFiles</span></span>
<span class="line"><span style="color: #adbac7">Print the names of emitted files after a compilation..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @listFiles</span></span>
<span class="line"><span style="color: #adbac7">Print all of the files read during the compilation..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @mapRoot</span></span>
<span class="line"><span style="color: #adbac7">Specify the location where debugger should locate map files instead of generated locations..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @maxNodeModuleJsDepth</span></span>
<span class="line"><span style="color: #adbac7">Specify the maximum folder depth used for checking JavaScript files from `node_modules`. Only applicable with `allowJs`..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @module</span></span>
<span class="line"><span style="color: #adbac7">Specify what module code is generated..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @moduleResolution</span></span>
<span class="line"><span style="color: #adbac7">Specify how TypeScript looks up a file from a given module specifier..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @newLine</span></span>
<span class="line"><span style="color: #adbac7">Set the newline character for emitting files..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @noEmit</span></span>
<span class="line"><span style="color: #adbac7">Disable emitting file from a compilation..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @noEmitHelpers</span></span>
<span class="line"><span style="color: #adbac7">Disable generating custom helper functions like `__extends` in compiled output..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @noEmitOnError</span></span>
<span class="line"><span style="color: #adbac7">Disable emitting files if any type checking errors are reported..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @noErrorTruncation</span></span>
<span class="line"><span style="color: #adbac7">Disable truncating types in error messages..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @noFallthroughCasesInSwitch</span></span>
<span class="line"><span style="color: #adbac7">Enable error reporting for fallthrough cases in switch statements..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @noImplicitAny</span></span>
<span class="line"><span style="color: #adbac7">Enable error reporting for expressions and declarations with an implied `any` type...</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @noImplicitOverride</span></span>
<span class="line"><span style="color: #adbac7">Add `undefined` to a type when accessed using an index..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @noImplicitReturns</span></span>
<span class="line"><span style="color: #adbac7">Enable error reporting for codepaths that do not explicitly return in a function..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @noImplicitThis</span></span>
<span class="line"><span style="color: #adbac7">Enable error reporting when `this` is given the type `any`..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @noImplicitUseStrict</span></span>
<span class="line"><span style="color: #adbac7">Disable adding &#39;use strict&#39; directives in emitted JavaScript files..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @noLib</span></span>
<span class="line"><span style="color: #adbac7">Disable including any library files, including the default lib.d.ts..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @noPropertyAccessFromIndexSignature</span></span>
<span class="line"><span style="color: #adbac7">Enforces using indexed accessors for keys declared using an indexed type.</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @noResolve</span></span>
<span class="line"><span style="color: #adbac7">Disallow `import`s, `require`s or ``s from expanding the number of files TypeScript should add to a project..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @noStrictGenericChecks</span></span>
<span class="line"><span style="color: #adbac7">Disable strict checking of generic signatures in function types..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @noUncheckedIndexedAccess</span></span>
<span class="line"><span style="color: #adbac7">Include &#39;undefined&#39; in index signature results.</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @noUnusedLocals</span></span>
<span class="line"><span style="color: #adbac7">Enable error reporting when a local variables aren&#39;t read..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @noUnusedParameters</span></span>
<span class="line"><span style="color: #adbac7">Raise an error when a function parameter isn&#39;t read.</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @out</span></span>
<span class="line"><span style="color: #adbac7">Deprecated setting. Use `outFile` instead..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @outDir</span></span>
<span class="line"><span style="color: #adbac7">Specify an output folder for all emitted files..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @outFile</span></span>
<span class="line"><span style="color: #adbac7">Specify a file that bundles all outputs into one JavaScript file. If `declaration` is true, also designates a file that bundles all .d.ts output..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @paths</span></span>
<span class="line"><span style="color: #adbac7">Specify a set of entries that re-map imports to additional lookup locations..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @plugins</span></span>
<span class="line"><span style="color: #adbac7">List of language service plugins..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @preserveConstEnums</span></span>
<span class="line"><span style="color: #adbac7">Disable erasing `const enum` declarations in generated code..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @preserveSymlinks</span></span>
<span class="line"><span style="color: #adbac7">Disable resolving symlinks to their realpath. This correlates to the same flag in node..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @preserveWatchOutput</span></span>
<span class="line"><span style="color: #adbac7">Disable wiping the console in watch mode.</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @pretty</span></span>
<span class="line"><span style="color: #adbac7">Enable color and formatting in output to make compiler errors easier to read.</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @reactNamespace</span></span>
<span class="line"><span style="color: #adbac7">Specify the object invoked for `createElement`. This only applies when targeting `react` JSX emit..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @removeComments</span></span>
<span class="line"><span style="color: #adbac7">Disable emitting comments..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @resolveJsonModule</span></span>
<span class="line"><span style="color: #adbac7">Enable importing .json files.</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @rootDir</span></span>
<span class="line"><span style="color: #adbac7">Specify the root folder within your source files..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @rootDirs</span></span>
<span class="line"><span style="color: #adbac7">Allow multiple folders to be treated as one when resolving modules..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @skipDefaultLibCheck</span></span>
<span class="line"><span style="color: #adbac7">Skip type checking .d.ts files that are included with TypeScript..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @skipLibCheck</span></span>
<span class="line"><span style="color: #adbac7">Skip type checking all .d.ts files..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @sourceMap</span></span>
<span class="line"><span style="color: #adbac7">Create source map files for emitted JavaScript files..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @sourceRoot</span></span>
<span class="line"><span style="color: #adbac7">Specify the root path for debuggers to find the reference source code..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @strict</span></span>
<span class="line"><span style="color: #adbac7">Enable all strict type-checking options..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @strictBindCallApply</span></span>
<span class="line"><span style="color: #adbac7">Check that the arguments for `bind`, `call`, and `apply` methods match the original function..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @strictFunctionTypes</span></span>
<span class="line"><span style="color: #adbac7">When assigning functions, check to ensure parameters and the return values are subtype-compatible..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @strictNullChecks</span></span>
<span class="line"><span style="color: #adbac7">When type checking, take into account `null` and `undefined`..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @strictPropertyInitialization</span></span>
<span class="line"><span style="color: #adbac7">Check for class properties that are declared but not set in the constructor..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @stripInternal</span></span>
<span class="line"><span style="color: #adbac7">Disable emitting declarations that have `@internal` in their JSDoc comments..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @suppressExcessPropertyErrors</span></span>
<span class="line"><span style="color: #adbac7">Disable reporting of excess property errors during the creation of object literals..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @suppressImplicitAnyIndexErrors</span></span>
<span class="line"><span style="color: #adbac7">Suppress `noImplicitAny` errors when indexing objects that lack index signatures..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @target</span></span>
<span class="line"><span style="color: #adbac7">Set the JavaScript language version for emitted JavaScript and include compatible library declarations..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @traceResolution</span></span>
<span class="line"><span style="color: #adbac7">Log paths used during the `moduleResolution` process..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @tsBuildInfoFile</span></span>
<span class="line"><span style="color: #adbac7">Specify the folder for .tsbuildinfo incremental compilation files..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @typeRoots</span></span>
<span class="line"><span style="color: #adbac7">Specify multiple folders that act like `./node_modules/@types`..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @types</span></span>
<span class="line"><span style="color: #adbac7">Specify type package names to be included without being referenced in a source file..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @useDefineForClassFields</span></span>
<span class="line"><span style="color: #adbac7">Emit ECMAScript-standard-compliant class fields..</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">// @useUnknownInCatchVariables</span></span>
<span class="line"><span style="color: #adbac7">Type catch clause variables as &#39;unknown&#39; instead of &#39;any&#39;..</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292e">// @allowJs</span></span>
<span class="line"><span style="color: #24292e">Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @allowSyntheticDefaultImports</span></span>
<span class="line"><span style="color: #24292e">Allow &#39;import x from y&#39; when a module doesn&#39;t have a default export..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @allowUmdGlobalAccess</span></span>
<span class="line"><span style="color: #24292e">Allow accessing UMD globals from modules..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @allowUnreachableCode</span></span>
<span class="line"><span style="color: #24292e">Disable error reporting for unreachable code..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @allowUnusedLabels</span></span>
<span class="line"><span style="color: #24292e">Disable error reporting for unused labels..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @alwaysStrict</span></span>
<span class="line"><span style="color: #24292e">Ensure &#39;use strict&#39; is always emitted..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @assumeChangesOnlyAffectDirectDependencies</span></span>
<span class="line"><span style="color: #24292e">Have recompiles in projects that use `incremental` and `watch` mode assume that changes within a file will only affect files directly depending on it..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @baseUrl</span></span>
<span class="line"><span style="color: #24292e">Specify the base directory to resolve non-relative module names..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @charset</span></span>
<span class="line"><span style="color: #24292e">No longer supported. In early versions, manually set the text encoding for reading files..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @checkJs</span></span>
<span class="line"><span style="color: #24292e">Enable error reporting in type-checked JavaScript files..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @composite</span></span>
<span class="line"><span style="color: #24292e">Enable constraints that allow a TypeScript project to be used with project references..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @declaration</span></span>
<span class="line"><span style="color: #24292e">Generate .d.ts files from TypeScript and JavaScript files in your project..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @declarationDir</span></span>
<span class="line"><span style="color: #24292e">Specify the output directory for generated declaration files..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @declarationMap</span></span>
<span class="line"><span style="color: #24292e">Create sourcemaps for d.ts files..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @diagnostics</span></span>
<span class="line"><span style="color: #24292e">Output compiler performance information after building..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @disableReferencedProjectLoad</span></span>
<span class="line"><span style="color: #24292e">Reduce the number of projects loaded automatically by TypeScript..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @disableSizeLimit</span></span>
<span class="line"><span style="color: #24292e">Remove the 20mb cap on total source code size for JavaScript files in the TypeScript language server..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @disableSolutionSearching</span></span>
<span class="line"><span style="color: #24292e">Opt a project out of multi-project reference checking when editing..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @disableSourceOfProjectReferenceRedirect</span></span>
<span class="line"><span style="color: #24292e">Disable preferring source files instead of declaration files when referencing composite projects.</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @downlevelIteration</span></span>
<span class="line"><span style="color: #24292e">Emit more compliant, but verbose and less performant JavaScript for iteration..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @emitBOM</span></span>
<span class="line"><span style="color: #24292e">Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @emitDeclarationOnly</span></span>
<span class="line"><span style="color: #24292e">Only output d.ts files and not JavaScript files..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @emitDecoratorMetadata</span></span>
<span class="line"><span style="color: #24292e">Emit design-type metadata for decorated declarations in source files..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @esModuleInterop</span></span>
<span class="line"><span style="color: #24292e">Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @exactOptionalPropertyTypes</span></span>
<span class="line"><span style="color: #24292e">Interpret optional property types as written, rather than adding &#39;undefined&#39;..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @experimentalDecorators</span></span>
<span class="line"><span style="color: #24292e">Enable experimental support for TC39 stage 2 draft decorators..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @explainFiles</span></span>
<span class="line"><span style="color: #24292e">Print files read during the compilation including why it was included..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @extendedDiagnostics</span></span>
<span class="line"><span style="color: #24292e">Output more detailed compiler performance information after building..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @forceConsistentCasingInFileNames</span></span>
<span class="line"><span style="color: #24292e">Ensure that casing is correct in imports..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @generateCpuProfile</span></span>
<span class="line"><span style="color: #24292e">Emit a v8 CPU profile of the compiler run for debugging..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @importHelpers</span></span>
<span class="line"><span style="color: #24292e">Allow importing helper functions from tslib once per project, instead of including them per-file..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @importsNotUsedAsValues</span></span>
<span class="line"><span style="color: #24292e">Specify emit/checking behavior for imports that are only used for types.</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @incremental</span></span>
<span class="line"><span style="color: #24292e">Enable incremental compilation.</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @inlineSourceMap</span></span>
<span class="line"><span style="color: #24292e">Include sourcemap files inside the emitted JavaScript..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @inlineSources</span></span>
<span class="line"><span style="color: #24292e">Include source code in the sourcemaps inside the emitted JavaScript..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @isolatedModules</span></span>
<span class="line"><span style="color: #24292e">Ensure that each file can be safely transpiled without relying on other imports..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @jsx</span></span>
<span class="line"><span style="color: #24292e">Specify what JSX code is generated..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @jsxFactory</span></span>
<span class="line"><span style="color: #24292e">Specify the JSX factory function used when targeting React JSX emit, e.g. &#39;React.createElement&#39; or &#39;h&#39;.</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @jsxFragmentFactory</span></span>
<span class="line"><span style="color: #24292e">Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. &#39;React.Fragment&#39; or &#39;Fragment&#39;..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @jsxImportSource</span></span>
<span class="line"><span style="color: #24292e">Specify module specifier used to import the JSX factory functions when using `jsx: react-jsx*`.`.</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @keyofStringsOnly</span></span>
<span class="line"><span style="color: #24292e">Make keyof only return strings instead of string, numbers or symbols. Legacy option..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @lib</span></span>
<span class="line"><span style="color: #24292e">Specify a set of bundled library declaration files that describe the target runtime environment..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @listEmittedFiles</span></span>
<span class="line"><span style="color: #24292e">Print the names of emitted files after a compilation..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @listFiles</span></span>
<span class="line"><span style="color: #24292e">Print all of the files read during the compilation..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @mapRoot</span></span>
<span class="line"><span style="color: #24292e">Specify the location where debugger should locate map files instead of generated locations..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @maxNodeModuleJsDepth</span></span>
<span class="line"><span style="color: #24292e">Specify the maximum folder depth used for checking JavaScript files from `node_modules`. Only applicable with `allowJs`..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @module</span></span>
<span class="line"><span style="color: #24292e">Specify what module code is generated..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @moduleResolution</span></span>
<span class="line"><span style="color: #24292e">Specify how TypeScript looks up a file from a given module specifier..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @newLine</span></span>
<span class="line"><span style="color: #24292e">Set the newline character for emitting files..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @noEmit</span></span>
<span class="line"><span style="color: #24292e">Disable emitting file from a compilation..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @noEmitHelpers</span></span>
<span class="line"><span style="color: #24292e">Disable generating custom helper functions like `__extends` in compiled output..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @noEmitOnError</span></span>
<span class="line"><span style="color: #24292e">Disable emitting files if any type checking errors are reported..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @noErrorTruncation</span></span>
<span class="line"><span style="color: #24292e">Disable truncating types in error messages..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @noFallthroughCasesInSwitch</span></span>
<span class="line"><span style="color: #24292e">Enable error reporting for fallthrough cases in switch statements..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @noImplicitAny</span></span>
<span class="line"><span style="color: #24292e">Enable error reporting for expressions and declarations with an implied `any` type...</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @noImplicitOverride</span></span>
<span class="line"><span style="color: #24292e">Add `undefined` to a type when accessed using an index..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @noImplicitReturns</span></span>
<span class="line"><span style="color: #24292e">Enable error reporting for codepaths that do not explicitly return in a function..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @noImplicitThis</span></span>
<span class="line"><span style="color: #24292e">Enable error reporting when `this` is given the type `any`..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @noImplicitUseStrict</span></span>
<span class="line"><span style="color: #24292e">Disable adding &#39;use strict&#39; directives in emitted JavaScript files..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @noLib</span></span>
<span class="line"><span style="color: #24292e">Disable including any library files, including the default lib.d.ts..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @noPropertyAccessFromIndexSignature</span></span>
<span class="line"><span style="color: #24292e">Enforces using indexed accessors for keys declared using an indexed type.</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @noResolve</span></span>
<span class="line"><span style="color: #24292e">Disallow `import`s, `require`s or ``s from expanding the number of files TypeScript should add to a project..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @noStrictGenericChecks</span></span>
<span class="line"><span style="color: #24292e">Disable strict checking of generic signatures in function types..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @noUncheckedIndexedAccess</span></span>
<span class="line"><span style="color: #24292e">Include &#39;undefined&#39; in index signature results.</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @noUnusedLocals</span></span>
<span class="line"><span style="color: #24292e">Enable error reporting when a local variables aren&#39;t read..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @noUnusedParameters</span></span>
<span class="line"><span style="color: #24292e">Raise an error when a function parameter isn&#39;t read.</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @out</span></span>
<span class="line"><span style="color: #24292e">Deprecated setting. Use `outFile` instead..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @outDir</span></span>
<span class="line"><span style="color: #24292e">Specify an output folder for all emitted files..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @outFile</span></span>
<span class="line"><span style="color: #24292e">Specify a file that bundles all outputs into one JavaScript file. If `declaration` is true, also designates a file that bundles all .d.ts output..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @paths</span></span>
<span class="line"><span style="color: #24292e">Specify a set of entries that re-map imports to additional lookup locations..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @plugins</span></span>
<span class="line"><span style="color: #24292e">List of language service plugins..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @preserveConstEnums</span></span>
<span class="line"><span style="color: #24292e">Disable erasing `const enum` declarations in generated code..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @preserveSymlinks</span></span>
<span class="line"><span style="color: #24292e">Disable resolving symlinks to their realpath. This correlates to the same flag in node..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @preserveWatchOutput</span></span>
<span class="line"><span style="color: #24292e">Disable wiping the console in watch mode.</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @pretty</span></span>
<span class="line"><span style="color: #24292e">Enable color and formatting in output to make compiler errors easier to read.</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @reactNamespace</span></span>
<span class="line"><span style="color: #24292e">Specify the object invoked for `createElement`. This only applies when targeting `react` JSX emit..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @removeComments</span></span>
<span class="line"><span style="color: #24292e">Disable emitting comments..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @resolveJsonModule</span></span>
<span class="line"><span style="color: #24292e">Enable importing .json files.</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @rootDir</span></span>
<span class="line"><span style="color: #24292e">Specify the root folder within your source files..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @rootDirs</span></span>
<span class="line"><span style="color: #24292e">Allow multiple folders to be treated as one when resolving modules..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @skipDefaultLibCheck</span></span>
<span class="line"><span style="color: #24292e">Skip type checking .d.ts files that are included with TypeScript..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @skipLibCheck</span></span>
<span class="line"><span style="color: #24292e">Skip type checking all .d.ts files..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @sourceMap</span></span>
<span class="line"><span style="color: #24292e">Create source map files for emitted JavaScript files..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @sourceRoot</span></span>
<span class="line"><span style="color: #24292e">Specify the root path for debuggers to find the reference source code..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @strict</span></span>
<span class="line"><span style="color: #24292e">Enable all strict type-checking options..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @strictBindCallApply</span></span>
<span class="line"><span style="color: #24292e">Check that the arguments for `bind`, `call`, and `apply` methods match the original function..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @strictFunctionTypes</span></span>
<span class="line"><span style="color: #24292e">When assigning functions, check to ensure parameters and the return values are subtype-compatible..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @strictNullChecks</span></span>
<span class="line"><span style="color: #24292e">When type checking, take into account `null` and `undefined`..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @strictPropertyInitialization</span></span>
<span class="line"><span style="color: #24292e">Check for class properties that are declared but not set in the constructor..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @stripInternal</span></span>
<span class="line"><span style="color: #24292e">Disable emitting declarations that have `@internal` in their JSDoc comments..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @suppressExcessPropertyErrors</span></span>
<span class="line"><span style="color: #24292e">Disable reporting of excess property errors during the creation of object literals..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @suppressImplicitAnyIndexErrors</span></span>
<span class="line"><span style="color: #24292e">Suppress `noImplicitAny` errors when indexing objects that lack index signatures..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @target</span></span>
<span class="line"><span style="color: #24292e">Set the JavaScript language version for emitted JavaScript and include compatible library declarations..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @traceResolution</span></span>
<span class="line"><span style="color: #24292e">Log paths used during the `moduleResolution` process..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @tsBuildInfoFile</span></span>
<span class="line"><span style="color: #24292e">Specify the folder for .tsbuildinfo incremental compilation files..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @typeRoots</span></span>
<span class="line"><span style="color: #24292e">Specify multiple folders that act like `./node_modules/@types`..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @types</span></span>
<span class="line"><span style="color: #24292e">Specify type package names to be included without being referenced in a source file..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @useDefineForClassFields</span></span>
<span class="line"><span style="color: #24292e">Emit ECMAScript-standard-compliant class fields..</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">// @useUnknownInCatchVariables</span></span>
<span class="line"><span style="color: #24292e">Type catch clause variables as &#39;unknown&#39; instead of &#39;any&#39;..</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br><span class="line-number">36</span><br><span class="line-number">37</span><br><span class="line-number">38</span><br><span class="line-number">39</span><br><span class="line-number">40</span><br><span class="line-number">41</span><br><span class="line-number">42</span><br><span class="line-number">43</span><br><span class="line-number">44</span><br><span class="line-number">45</span><br><span class="line-number">46</span><br><span class="line-number">47</span><br><span class="line-number">48</span><br><span class="line-number">49</span><br><span class="line-number">50</span><br><span class="line-number">51</span><br><span class="line-number">52</span><br><span class="line-number">53</span><br><span class="line-number">54</span><br><span class="line-number">55</span><br><span class="line-number">56</span><br><span class="line-number">57</span><br><span class="line-number">58</span><br><span class="line-number">59</span><br><span class="line-number">60</span><br><span class="line-number">61</span><br><span class="line-number">62</span><br><span class="line-number">63</span><br><span class="line-number">64</span><br><span class="line-number">65</span><br><span class="line-number">66</span><br><span class="line-number">67</span><br><span class="line-number">68</span><br><span class="line-number">69</span><br><span class="line-number">70</span><br><span class="line-number">71</span><br><span class="line-number">72</span><br><span class="line-number">73</span><br><span class="line-number">74</span><br><span class="line-number">75</span><br><span class="line-number">76</span><br><span class="line-number">77</span><br><span class="line-number">78</span><br><span class="line-number">79</span><br><span class="line-number">80</span><br><span class="line-number">81</span><br><span class="line-number">82</span><br><span class="line-number">83</span><br><span class="line-number">84</span><br><span class="line-number">85</span><br><span class="line-number">86</span><br><span class="line-number">87</span><br><span class="line-number">88</span><br><span class="line-number">89</span><br><span class="line-number">90</span><br><span class="line-number">91</span><br><span class="line-number">92</span><br><span class="line-number">93</span><br><span class="line-number">94</span><br><span class="line-number">95</span><br><span class="line-number">96</span><br><span class="line-number">97</span><br><span class="line-number">98</span><br><span class="line-number">99</span><br><span class="line-number">100</span><br><span class="line-number">101</span><br><span class="line-number">102</span><br><span class="line-number">103</span><br><span class="line-number">104</span><br><span class="line-number">105</span><br><span class="line-number">106</span><br><span class="line-number">107</span><br><span class="line-number">108</span><br><span class="line-number">109</span><br><span class="line-number">110</span><br><span class="line-number">111</span><br><span class="line-number">112</span><br><span class="line-number">113</span><br><span class="line-number">114</span><br><span class="line-number">115</span><br><span class="line-number">116</span><br><span class="line-number">117</span><br><span class="line-number">118</span><br><span class="line-number">119</span><br><span class="line-number">120</span><br><span class="line-number">121</span><br><span class="line-number">122</span><br><span class="line-number">123</span><br><span class="line-number">124</span><br><span class="line-number">125</span><br><span class="line-number">126</span><br><span class="line-number">127</span><br><span class="line-number">128</span><br><span class="line-number">129</span><br><span class="line-number">130</span><br><span class="line-number">131</span><br><span class="line-number">132</span><br><span class="line-number">133</span><br><span class="line-number">134</span><br><span class="line-number">135</span><br><span class="line-number">136</span><br><span class="line-number">137</span><br><span class="line-number">138</span><br><span class="line-number">139</span><br><span class="line-number">140</span><br><span class="line-number">141</span><br><span class="line-number">142</span><br><span class="line-number">143</span><br><span class="line-number">144</span><br><span class="line-number">145</span><br><span class="line-number">146</span><br><span class="line-number">147</span><br><span class="line-number">148</span><br><span class="line-number">149</span><br><span class="line-number">150</span><br><span class="line-number">151</span><br><span class="line-number">152</span><br><span class="line-number">153</span><br><span class="line-number">154</span><br><span class="line-number">155</span><br><span class="line-number">156</span><br><span class="line-number">157</span><br><span class="line-number">158</span><br><span class="line-number">159</span><br><span class="line-number">160</span><br><span class="line-number">161</span><br><span class="line-number">162</span><br><span class="line-number">163</span><br><span class="line-number">164</span><br><span class="line-number">165</span><br><span class="line-number">166</span><br><span class="line-number">167</span><br><span class="line-number">168</span><br><span class="line-number">169</span><br><span class="line-number">170</span><br><span class="line-number">171</span><br><span class="line-number">172</span><br><span class="line-number">173</span><br><span class="line-number">174</span><br><span class="line-number">175</span><br><span class="line-number">176</span><br><span class="line-number">177</span><br><span class="line-number">178</span><br><span class="line-number">179</span><br><span class="line-number">180</span><br><span class="line-number">181</span><br><span class="line-number">182</span><br><span class="line-number">183</span><br><span class="line-number">184</span><br><span class="line-number">185</span><br><span class="line-number">186</span><br><span class="line-number">187</span><br><span class="line-number">188</span><br><span class="line-number">189</span><br><span class="line-number">190</span><br><span class="line-number">191</span><br><span class="line-number">192</span><br><span class="line-number">193</span><br><span class="line-number">194</span><br><span class="line-number">195</span><br><span class="line-number">196</span><br><span class="line-number">197</span><br><span class="line-number">198</span><br><span class="line-number">199</span><br><span class="line-number">200</span><br><span class="line-number">201</span><br><span class="line-number">202</span><br><span class="line-number">203</span><br><span class="line-number">204</span><br><span class="line-number">205</span><br><span class="line-number">206</span><br><span class="line-number">207</span><br><span class="line-number">208</span><br><span class="line-number">209</span><br><span class="line-number">210</span><br><span class="line-number">211</span><br><span class="line-number">212</span><br><span class="line-number">213</span><br><span class="line-number">214</span><br><span class="line-number">215</span><br><span class="line-number">216</span><br><span class="line-number">217</span><br><span class="line-number">218</span><br><span class="line-number">219</span><br><span class="line-number">220</span><br><span class="line-number">221</span><br><span class="line-number">222</span><br><span class="line-number">223</span><br><span class="line-number">224</span><br><span class="line-number">225</span><br><span class="line-number">226</span><br><span class="line-number">227</span><br><span class="line-number">228</span><br><span class="line-number">229</span><br><span class="line-number">230</span><br><span class="line-number">231</span><br><span class="line-number">232</span><br><span class="line-number">233</span><br><span class="line-number">234</span><br><span class="line-number">235</span><br><span class="line-number">236</span><br><span class="line-number">237</span><br><span class="line-number">238</span><br><span class="line-number">239</span><br><span class="line-number">240</span><br><span class="line-number">241</span><br><span class="line-number">242</span><br><span class="line-number">243</span><br><span class="line-number">244</span><br><span class="line-number">245</span><br><span class="line-number">246</span><br><span class="line-number">247</span><br><span class="line-number">248</span><br><span class="line-number">249</span><br><span class="line-number">250</span><br><span class="line-number">251</span><br><span class="line-number">252</span><br><span class="line-number">253</span><br><span class="line-number">254</span><br><span class="line-number">255</span><br><span class="line-number">256</span><br><span class="line-number">257</span><br><span class="line-number">258</span><br><span class="line-number">259</span><br><span class="line-number">260</span><br><span class="line-number">261</span><br><span class="line-number">262</span><br><span class="line-number">263</span><br><span class="line-number">264</span><br><span class="line-number">265</span><br><span class="line-number">266</span><br><span class="line-number">267</span><br><span class="line-number">268</span><br><span class="line-number">269</span><br><span class="line-number">270</span><br><span class="line-number">271</span><br><span class="line-number">272</span><br><span class="line-number">273</span><br><span class="line-number">274</span><br><span class="line-number">275</span><br><span class="line-number">276</span><br><span class="line-number">277</span><br><span class="line-number">278</span><br><span class="line-number">279</span><br><span class="line-number">280</span><br><span class="line-number">281</span><br><span class="line-number">282</span><br><span class="line-number">283</span><br><span class="line-number">284</span><br><span class="line-number">285</span><br><span class="line-number">286</span><br><span class="line-number">287</span><br><span class="line-number">288</span><br><span class="line-number">289</span><br><span class="line-number">290</span><br><span class="line-number">291</span><br><span class="line-number">292</span><br><span class="line-number">293</span><br><span class="line-number">294</span><br><span class="line-number">295</span><br><span class="line-number">296</span><br></div></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Config]]></title>
            <link>https://note.toshiki.devapplication/vitepress-plugin-shiki-twoslash/config/reference</link>
            <guid>https://note.toshiki.devapplication/vitepress-plugin-shiki-twoslash/config/reference</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="config" tabindex="-1">Config <a class="header-anchor" href="#config" aria-label="Permalink to &quot;Config&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="overview" tabindex="-1">Overview <a class="header-anchor" href="#overview" aria-label="Permalink to &quot;Overview&quot;">&ZeroWidthSpace;</a></h2>
<p>You can configure VitePress Twoslash using the <code>twoslash</code> property added to <code>defineConfig</code>.</p>
<div class="language-ts vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki github-dark-dimmed twoslash lsp" style="background-color: #22272e; color: #adbac7"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #768390">// .vitepress/config.[ext]</span></div><div class='line'><span style="color: #F47067">import</span><span style="color: #ADBAC7"> { <data-lsp lsp='(alias) function defineConfig(config: UserConfig&lt;DefaultTheme.Config>): UserConfig&lt;DefaultTheme.Config>&#10;import defineConfig' >defineConfig</data-lsp> } </span><span style="color: #F47067">from</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&apos;vitepress&apos;</span></div><div class='line'><span style="color: #F47067">import</span><span style="color: #ADBAC7"> { <data-lsp lsp='(alias) function withTwoslash(config: UserConfig&lt;DefaultTheme.Config>): Promise&lt;UserConfig&lt;DefaultTheme.Config>>&#10;import withTwoslash' >withTwoslash</data-lsp>, <data-lsp lsp='(alias) type TwoslashConfigSettings = any&#10;import TwoslashConfigSettings' >TwoslashConfigSettings</data-lsp> } </span><span style="color: #F47067">from</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&apos;@andatoshiki/vitepress-plugin-shiki-twoslash&apos;</span></div><div class='line'>&nbsp;</div><div class='line'><span style="color: #F47067">export</span><span style="color: #F69D50"> </span><span style="color: #F47067">default</span><span style="color: #F69D50"> </span><span style="color: #DCBDFB"><data-lsp lsp='(alias) withTwoslash(config: UserConfig&lt;DefaultTheme.Config>): Promise&lt;UserConfig&lt;DefaultTheme.Config>>&#10;import withTwoslash' >withTwoslash</data-lsp></span><span style="color: #F69D50">(</span></div><div class='line'><span style="color: #F69D50">    </span><span style="color: #DCBDFB"><data-lsp lsp='(alias) defineConfig(config: UserConfig&lt;DefaultTheme.Config>): UserConfig&lt;DefaultTheme.Config>&#10;import defineConfig' >defineConfig</data-lsp></span><span style="color: #F69D50">({</span></div><div class='line'><span style="color: #F69D50">        </span><span style="color: #ADBAC7"><data-lsp lsp='(property) UserConfig&lt;DefaultTheme.Config>.twoslash?: any' >twoslash</data-lsp>: {</span></div><div class='line'><span style="color: #ADBAC7">            </span><span style="color: #768390">// Your VitePress Twoslash options</span></div><div class='line'><span style="color: #ADBAC7">        }</span><span style="color: #F69D50">,</span></div><div class='line'><span style="color: #F69D50">    })</span></div><div class='line'><span style="color: #F69D50">)</span></div></code></div></pre>
<pre class="shiki github-light twoslash lsp" style="background-color: #fff; color: #24292e"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #6A737D">// .vitepress/config.[ext]</span></div><div class='line'><span style="color: #D73A49">import</span><span style="color: #24292E"> { <data-lsp lsp='(alias) function defineConfig(config: UserConfig&lt;DefaultTheme.Config>): UserConfig&lt;DefaultTheme.Config>&#10;import defineConfig' >defineConfig</data-lsp> } </span><span style="color: #D73A49">from</span><span style="color: #24292E"> </span><span style="color: #032F62">&apos;vitepress&apos;</span></div><div class='line'><span style="color: #D73A49">import</span><span style="color: #24292E"> { <data-lsp lsp='(alias) function withTwoslash(config: UserConfig&lt;DefaultTheme.Config>): Promise&lt;UserConfig&lt;DefaultTheme.Config>>&#10;import withTwoslash' >withTwoslash</data-lsp>, <data-lsp lsp='(alias) type TwoslashConfigSettings = any&#10;import TwoslashConfigSettings' >TwoslashConfigSettings</data-lsp> } </span><span style="color: #D73A49">from</span><span style="color: #24292E"> </span><span style="color: #032F62">&apos;@andatoshiki/vitepress-plugin-shiki-twoslash&apos;</span></div><div class='line'>&nbsp;</div><div class='line'><span style="color: #D73A49">export</span><span style="color: #24292E"> </span><span style="color: #D73A49">default</span><span style="color: #24292E"> </span><span style="color: #6F42C1"><data-lsp lsp='(alias) withTwoslash(config: UserConfig&lt;DefaultTheme.Config>): Promise&lt;UserConfig&lt;DefaultTheme.Config>>&#10;import withTwoslash' >withTwoslash</data-lsp></span><span style="color: #24292E">(</span></div><div class='line'><span style="color: #24292E">    </span><span style="color: #6F42C1"><data-lsp lsp='(alias) defineConfig(config: UserConfig&lt;DefaultTheme.Config>): UserConfig&lt;DefaultTheme.Config>&#10;import defineConfig' >defineConfig</data-lsp></span><span style="color: #24292E">({</span></div><div class='line'><span style="color: #24292E">        <data-lsp lsp='(property) UserConfig&lt;DefaultTheme.Config>.twoslash?: any' >twoslash</data-lsp>: {</span></div><div class='line'><span style="color: #24292E">            </span><span style="color: #6A737D">// Your VitePress Twoslash options</span></div><div class='line'><span style="color: #24292E">        },</span></div><div class='line'><span style="color: #24292E">    })</span></div><div class='line'><span style="color: #24292E">)</span></div></code></div></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="info custom-block"><p class="custom-block-title">INFO</p>
<p>In addition to the below config options, VitePress Twoslash also supports all <a href="https://github.com/shikijs/shiki" target="_blank" rel="noreferrer"><code>shiki</code></a> <code>HighlighterOptions</code> and <a href="https://github.com/microsoft/TypeScript-Website/tree/v2/packages/ts-twoslasher" target="_blank" rel="noreferrer"><code>@typescript/twoslash</code></a> <code>TwoSlashOptions</code>.</p>
</div>
<h2 id="options" tabindex="-1">Options <a class="header-anchor" href="#options" aria-label="Permalink to &quot;Options&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="addtrybutton" tabindex="-1"><code>addTryButton</code> <a class="header-anchor" href="#addtrybutton" aria-label="Permalink to &quot;`addTryButton`&quot;">&ZeroWidthSpace;</a></h3>
<p>A way to turn on the try buttons seen on the TS website.</p>
<ul>
<li><strong>Type</strong>: <code>boolean</code></li>
<li><strong>Default</strong>: <code>false</code></li>
</ul>
<div class="language-ts vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre v-pre class="shiki github-dark-dimmed has-focused-lines vp-code-dark" ><code><span class="line"><span style="color: #F47067">export</span><span style="color: #F69D50"> </span><span style="color: #F47067">default</span><span style="color: #F69D50"> </span><span style="color: #DCBDFB">withTwoslash</span><span style="color: #F69D50">(</span></span>
<span class="line"><span style="color: #F69D50">    </span><span style="color: #DCBDFB">defineConfig</span><span style="color: #F69D50">({</span></span>
<span class="line"><span style="color: #F69D50">        </span><span style="color: #ADBAC7">twoslash: {</span></span>
<span class="line has-focus"><span style="color: #ADBAC7">            addTryButton: </span><span style="color: #6CB6FF">true</span><span style="color: #ADBAC7">, </span></span>
<span class="line"><span style="color: #ADBAC7">        }</span><span style="color: #F69D50">,</span></span>
<span class="line"><span style="color: #F69D50">    })</span></span>
<span class="line"><span style="color: #F69D50">)</span></span></code></pre><pre v-pre class="shiki github-light has-focused-lines vp-code-light" ><code><span class="line"><span style="color: #D73A49">export</span><span style="color: #24292E"> </span><span style="color: #D73A49">default</span><span style="color: #24292E"> </span><span style="color: #6F42C1">withTwoslash</span><span style="color: #24292E">(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #6F42C1">defineConfig</span><span style="color: #24292E">({</span></span>
<span class="line"><span style="color: #24292E">        twoslash: {</span></span>
<span class="line has-focus"><span style="color: #24292E">            addTryButton: </span><span style="color: #005CC5">true</span><span style="color: #24292E">, </span></span>
<span class="line"><span style="color: #24292E">        },</span></span>
<span class="line"><span style="color: #24292E">    })</span></span>
<span class="line"><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br></div></div><h3 id="alwayraisefortwoslashexceptions" tabindex="-1"><code>alwayRaiseForTwoslashExceptions</code> <a class="header-anchor" href="#alwayraisefortwoslashexceptions" aria-label="Permalink to &quot;`alwayRaiseForTwoslashExceptions`&quot;">&ZeroWidthSpace;</a></h3>
<p>Instead of showing twoslash exceptions inline, throw the entire process like it will on CI.</p>
<ul>
<li><strong>Type</strong>: <code>boolean</code></li>
<li><strong>Default</strong>: <code>false</code></li>
</ul>
<div class="language-ts vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre v-pre class="shiki github-dark-dimmed has-focused-lines vp-code-dark" ><code><span class="line"><span style="color: #F47067">export</span><span style="color: #F69D50"> </span><span style="color: #F47067">default</span><span style="color: #F69D50"> </span><span style="color: #DCBDFB">withTwoslash</span><span style="color: #F69D50">(</span></span>
<span class="line"><span style="color: #F69D50">    </span><span style="color: #DCBDFB">defineConfig</span><span style="color: #F69D50">({</span></span>
<span class="line"><span style="color: #F69D50">        </span><span style="color: #ADBAC7">twoslash: {</span></span>
<span class="line has-focus"><span style="color: #ADBAC7">            alwayRaiseForTwoslashExceptions: </span><span style="color: #6CB6FF">true</span><span style="color: #ADBAC7">, </span></span>
<span class="line"><span style="color: #ADBAC7">        }</span><span style="color: #F69D50">,</span></span>
<span class="line"><span style="color: #F69D50">    })</span></span>
<span class="line"><span style="color: #F69D50">)</span></span></code></pre><pre v-pre class="shiki github-light has-focused-lines vp-code-light" ><code><span class="line"><span style="color: #D73A49">export</span><span style="color: #24292E"> </span><span style="color: #D73A49">default</span><span style="color: #24292E"> </span><span style="color: #6F42C1">withTwoslash</span><span style="color: #24292E">(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #6F42C1">defineConfig</span><span style="color: #24292E">({</span></span>
<span class="line"><span style="color: #24292E">        twoslash: {</span></span>
<span class="line has-focus"><span style="color: #24292E">            alwayRaiseForTwoslashExceptions: </span><span style="color: #005CC5">true</span><span style="color: #24292E">, </span></span>
<span class="line"><span style="color: #24292E">        },</span></span>
<span class="line"><span style="color: #24292E">    })</span></span>
<span class="line"><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br></div></div><h3 id="disableimplicitreactimport" tabindex="-1"><code>disableImplicitReactImport</code> <a class="header-anchor" href="#disableimplicitreactimport" aria-label="Permalink to &quot;`disableImplicitReactImport`&quot;">&ZeroWidthSpace;</a></h3>
<p>A way to disable implicit React imports on tsx/jsx language codeblocks</p>
<ul>
<li><strong>Type</strong>: <code>boolean</code></li>
<li><strong>Default</strong>: <code>false</code></li>
</ul>
<div class="language-ts vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre v-pre class="shiki github-dark-dimmed has-focused-lines vp-code-dark" ><code><span class="line"><span style="color: #F47067">export</span><span style="color: #F69D50"> </span><span style="color: #F47067">default</span><span style="color: #F69D50"> </span><span style="color: #DCBDFB">withTwoslash</span><span style="color: #F69D50">(</span></span>
<span class="line"><span style="color: #F69D50">    </span><span style="color: #DCBDFB">defineConfig</span><span style="color: #F69D50">({</span></span>
<span class="line"><span style="color: #F69D50">        </span><span style="color: #ADBAC7">twoslash: {</span></span>
<span class="line has-focus"><span style="color: #ADBAC7">            disableImplicitReactImport: </span><span style="color: #6CB6FF">true</span><span style="color: #ADBAC7">, </span></span>
<span class="line"><span style="color: #ADBAC7">        }</span><span style="color: #F69D50">,</span></span>
<span class="line"><span style="color: #F69D50">    })</span></span>
<span class="line"><span style="color: #F69D50">)</span></span></code></pre><pre v-pre class="shiki github-light has-focused-lines vp-code-light" ><code><span class="line"><span style="color: #D73A49">export</span><span style="color: #24292E"> </span><span style="color: #D73A49">default</span><span style="color: #24292E"> </span><span style="color: #6F42C1">withTwoslash</span><span style="color: #24292E">(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #6F42C1">defineConfig</span><span style="color: #24292E">({</span></span>
<span class="line"><span style="color: #24292E">        twoslash: {</span></span>
<span class="line has-focus"><span style="color: #24292E">            disableImplicitReactImport: </span><span style="color: #005CC5">true</span><span style="color: #24292E">, </span></span>
<span class="line"><span style="color: #24292E">        },</span></span>
<span class="line"><span style="color: #24292E">    })</span></span>
<span class="line"><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br></div></div><h3 id="includejsdocinhover" tabindex="-1"><code>includeJSDocInHover</code> <a class="header-anchor" href="#includejsdocinhover" aria-label="Permalink to &quot;`includeJSDocInHover`&quot;">&ZeroWidthSpace;</a></h3>
<p>Include JSDoc comments in the hovers.</p>
<ul>
<li><strong>Type</strong>: <code>boolean</code></li>
<li><strong>Default</strong>: <code>false</code></li>
</ul>
<div class="language-ts vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre v-pre class="shiki github-dark-dimmed has-focused-lines vp-code-dark" ><code><span class="line"><span style="color: #F47067">export</span><span style="color: #F69D50"> </span><span style="color: #F47067">default</span><span style="color: #F69D50"> </span><span style="color: #DCBDFB">withTwoslash</span><span style="color: #F69D50">(</span></span>
<span class="line"><span style="color: #F69D50">    </span><span style="color: #DCBDFB">defineConfig</span><span style="color: #F69D50">({</span></span>
<span class="line"><span style="color: #F69D50">        </span><span style="color: #ADBAC7">twoslash: {</span></span>
<span class="line has-focus"><span style="color: #ADBAC7">            includeJSDocInHover: </span><span style="color: #6CB6FF">true</span><span style="color: #ADBAC7">, </span></span>
<span class="line"><span style="color: #ADBAC7">        }</span><span style="color: #F69D50">,</span></span>
<span class="line"><span style="color: #F69D50">    })</span></span>
<span class="line"><span style="color: #F69D50">)</span></span></code></pre><pre v-pre class="shiki github-light has-focused-lines vp-code-light" ><code><span class="line"><span style="color: #D73A49">export</span><span style="color: #24292E"> </span><span style="color: #D73A49">default</span><span style="color: #24292E"> </span><span style="color: #6F42C1">withTwoslash</span><span style="color: #24292E">(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #6F42C1">defineConfig</span><span style="color: #24292E">({</span></span>
<span class="line"><span style="color: #24292E">        twoslash: {</span></span>
<span class="line has-focus"><span style="color: #24292E">            includeJSDocInHover: </span><span style="color: #005CC5">true</span><span style="color: #24292E">, </span></span>
<span class="line"><span style="color: #24292E">        },</span></span>
<span class="line"><span style="color: #24292E">    })</span></span>
<span class="line"><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br></div></div><h3 id="ignorecodeblockswithcodefencemeta" tabindex="-1"><code>ignoreCodeblocksWithCodefenceMeta</code> <a class="header-anchor" href="#ignorecodeblockswithcodefencemeta" aria-label="Permalink to &quot;`ignoreCodeblocksWithCodefenceMeta`&quot;">&ZeroWidthSpace;</a></h3>
<p>Ignore transforming certain code blocks.</p>
<ul>
<li><strong>Type</strong>: <code>boolean</code></li>
<li><strong>Default</strong>: <code>false</code></li>
</ul>
<div class="language-ts vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre v-pre class="shiki github-dark-dimmed has-focused-lines vp-code-dark" ><code><span class="line"><span style="color: #F47067">export</span><span style="color: #F69D50"> </span><span style="color: #F47067">default</span><span style="color: #F69D50"> </span><span style="color: #DCBDFB">withTwoslash</span><span style="color: #F69D50">(</span></span>
<span class="line"><span style="color: #F69D50">    </span><span style="color: #DCBDFB">defineConfig</span><span style="color: #F69D50">({</span></span>
<span class="line"><span style="color: #F69D50">        </span><span style="color: #ADBAC7">twoslash: {</span></span>
<span class="line has-focus"><span style="color: #ADBAC7">            ignoreCodeblocksWithCodefenceMeta: </span><span style="color: #6CB6FF">true</span><span style="color: #ADBAC7">, </span></span>
<span class="line"><span style="color: #ADBAC7">        }</span><span style="color: #F69D50">,</span></span>
<span class="line"><span style="color: #F69D50">    })</span></span>
<span class="line"><span style="color: #F69D50">)</span></span></code></pre><pre v-pre class="shiki github-light has-focused-lines vp-code-light" ><code><span class="line"><span style="color: #D73A49">export</span><span style="color: #24292E"> </span><span style="color: #D73A49">default</span><span style="color: #24292E"> </span><span style="color: #6F42C1">withTwoslash</span><span style="color: #24292E">(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #6F42C1">defineConfig</span><span style="color: #24292E">({</span></span>
<span class="line"><span style="color: #24292E">        twoslash: {</span></span>
<span class="line has-focus"><span style="color: #24292E">            ignoreCodeblocksWithCodefenceMeta: </span><span style="color: #005CC5">true</span><span style="color: #24292E">, </span></span>
<span class="line"><span style="color: #24292E">        },</span></span>
<span class="line"><span style="color: #24292E">    })</span></span>
<span class="line"><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br></div></div><h3 id="wrapfragments" tabindex="-1"><code>wrapFragments</code> <a class="header-anchor" href="#wrapfragments" aria-label="Permalink to &quot;`wrapFragments`&quot;">&ZeroWidthSpace;</a></h3>
<p>A way to add a div wrapper for multi-theme outputs.</p>
<ul>
<li><strong>Type</strong>: <code>boolean</code></li>
<li><strong>Default</strong>: <code>false</code></li>
</ul>
<div class="language-ts vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre v-pre class="shiki github-dark-dimmed has-focused-lines vp-code-dark" ><code><span class="line"><span style="color: #F47067">export</span><span style="color: #F69D50"> </span><span style="color: #F47067">default</span><span style="color: #F69D50"> </span><span style="color: #DCBDFB">withTwoslash</span><span style="color: #F69D50">(</span></span>
<span class="line"><span style="color: #F69D50">    </span><span style="color: #DCBDFB">defineConfig</span><span style="color: #F69D50">({</span></span>
<span class="line"><span style="color: #F69D50">        </span><span style="color: #ADBAC7">twoslash: {</span></span>
<span class="line has-focus"><span style="color: #ADBAC7">            wrapFragments: </span><span style="color: #6CB6FF">true</span><span style="color: #ADBAC7">, </span></span>
<span class="line"><span style="color: #ADBAC7">        }</span><span style="color: #F69D50">,</span></span>
<span class="line"><span style="color: #F69D50">    })</span></span>
<span class="line"><span style="color: #F69D50">)</span></span></code></pre><pre v-pre class="shiki github-light has-focused-lines vp-code-light" ><code><span class="line"><span style="color: #D73A49">export</span><span style="color: #24292E"> </span><span style="color: #D73A49">default</span><span style="color: #24292E"> </span><span style="color: #6F42C1">withTwoslash</span><span style="color: #24292E">(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #6F42C1">defineConfig</span><span style="color: #24292E">({</span></span>
<span class="line"><span style="color: #24292E">        twoslash: {</span></span>
<span class="line has-focus"><span style="color: #24292E">            wrapFragments: </span><span style="color: #005CC5">true</span><span style="color: #24292E">, </span></span>
<span class="line"><span style="color: #24292E">        },</span></span>
<span class="line"><span style="color: #24292E">    })</span></span>
<span class="line"><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br></div></div>]]></description>
            <content:encoded><![CDATA[<h1 id="config" tabindex="-1">Config <a class="header-anchor" href="#config" aria-label="Permalink to &quot;Config&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="overview" tabindex="-1">Overview <a class="header-anchor" href="#overview" aria-label="Permalink to &quot;Overview&quot;">&ZeroWidthSpace;</a></h2>
<p>You can configure VitePress Twoslash using the <code>twoslash</code> property added to <code>defineConfig</code>.</p>
<div class="language-ts vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki github-dark-dimmed twoslash lsp" style="background-color: #22272e; color: #adbac7"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #768390">// .vitepress/config.[ext]</span></div><div class='line'><span style="color: #F47067">import</span><span style="color: #ADBAC7"> { <data-lsp lsp='(alias) function defineConfig(config: UserConfig&lt;DefaultTheme.Config>): UserConfig&lt;DefaultTheme.Config>&#10;import defineConfig' >defineConfig</data-lsp> } </span><span style="color: #F47067">from</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&apos;vitepress&apos;</span></div><div class='line'><span style="color: #F47067">import</span><span style="color: #ADBAC7"> { <data-lsp lsp='(alias) function withTwoslash(config: UserConfig&lt;DefaultTheme.Config>): Promise&lt;UserConfig&lt;DefaultTheme.Config>>&#10;import withTwoslash' >withTwoslash</data-lsp>, <data-lsp lsp='(alias) type TwoslashConfigSettings = any&#10;import TwoslashConfigSettings' >TwoslashConfigSettings</data-lsp> } </span><span style="color: #F47067">from</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&apos;@andatoshiki/vitepress-plugin-shiki-twoslash&apos;</span></div><div class='line'>&nbsp;</div><div class='line'><span style="color: #F47067">export</span><span style="color: #F69D50"> </span><span style="color: #F47067">default</span><span style="color: #F69D50"> </span><span style="color: #DCBDFB"><data-lsp lsp='(alias) withTwoslash(config: UserConfig&lt;DefaultTheme.Config>): Promise&lt;UserConfig&lt;DefaultTheme.Config>>&#10;import withTwoslash' >withTwoslash</data-lsp></span><span style="color: #F69D50">(</span></div><div class='line'><span style="color: #F69D50">    </span><span style="color: #DCBDFB"><data-lsp lsp='(alias) defineConfig(config: UserConfig&lt;DefaultTheme.Config>): UserConfig&lt;DefaultTheme.Config>&#10;import defineConfig' >defineConfig</data-lsp></span><span style="color: #F69D50">({</span></div><div class='line'><span style="color: #F69D50">        </span><span style="color: #ADBAC7"><data-lsp lsp='(property) UserConfig&lt;DefaultTheme.Config>.twoslash?: any' >twoslash</data-lsp>: {</span></div><div class='line'><span style="color: #ADBAC7">            </span><span style="color: #768390">// Your VitePress Twoslash options</span></div><div class='line'><span style="color: #ADBAC7">        }</span><span style="color: #F69D50">,</span></div><div class='line'><span style="color: #F69D50">    })</span></div><div class='line'><span style="color: #F69D50">)</span></div></code></div></pre>
<pre class="shiki github-light twoslash lsp" style="background-color: #fff; color: #24292e"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #6A737D">// .vitepress/config.[ext]</span></div><div class='line'><span style="color: #D73A49">import</span><span style="color: #24292E"> { <data-lsp lsp='(alias) function defineConfig(config: UserConfig&lt;DefaultTheme.Config>): UserConfig&lt;DefaultTheme.Config>&#10;import defineConfig' >defineConfig</data-lsp> } </span><span style="color: #D73A49">from</span><span style="color: #24292E"> </span><span style="color: #032F62">&apos;vitepress&apos;</span></div><div class='line'><span style="color: #D73A49">import</span><span style="color: #24292E"> { <data-lsp lsp='(alias) function withTwoslash(config: UserConfig&lt;DefaultTheme.Config>): Promise&lt;UserConfig&lt;DefaultTheme.Config>>&#10;import withTwoslash' >withTwoslash</data-lsp>, <data-lsp lsp='(alias) type TwoslashConfigSettings = any&#10;import TwoslashConfigSettings' >TwoslashConfigSettings</data-lsp> } </span><span style="color: #D73A49">from</span><span style="color: #24292E"> </span><span style="color: #032F62">&apos;@andatoshiki/vitepress-plugin-shiki-twoslash&apos;</span></div><div class='line'>&nbsp;</div><div class='line'><span style="color: #D73A49">export</span><span style="color: #24292E"> </span><span style="color: #D73A49">default</span><span style="color: #24292E"> </span><span style="color: #6F42C1"><data-lsp lsp='(alias) withTwoslash(config: UserConfig&lt;DefaultTheme.Config>): Promise&lt;UserConfig&lt;DefaultTheme.Config>>&#10;import withTwoslash' >withTwoslash</data-lsp></span><span style="color: #24292E">(</span></div><div class='line'><span style="color: #24292E">    </span><span style="color: #6F42C1"><data-lsp lsp='(alias) defineConfig(config: UserConfig&lt;DefaultTheme.Config>): UserConfig&lt;DefaultTheme.Config>&#10;import defineConfig' >defineConfig</data-lsp></span><span style="color: #24292E">({</span></div><div class='line'><span style="color: #24292E">        <data-lsp lsp='(property) UserConfig&lt;DefaultTheme.Config>.twoslash?: any' >twoslash</data-lsp>: {</span></div><div class='line'><span style="color: #24292E">            </span><span style="color: #6A737D">// Your VitePress Twoslash options</span></div><div class='line'><span style="color: #24292E">        },</span></div><div class='line'><span style="color: #24292E">    })</span></div><div class='line'><span style="color: #24292E">)</span></div></code></div></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="info custom-block"><p class="custom-block-title">INFO</p>
<p>In addition to the below config options, VitePress Twoslash also supports all <a href="https://github.com/shikijs/shiki" target="_blank" rel="noreferrer"><code>shiki</code></a> <code>HighlighterOptions</code> and <a href="https://github.com/microsoft/TypeScript-Website/tree/v2/packages/ts-twoslasher" target="_blank" rel="noreferrer"><code>@typescript/twoslash</code></a> <code>TwoSlashOptions</code>.</p>
</div>
<h2 id="options" tabindex="-1">Options <a class="header-anchor" href="#options" aria-label="Permalink to &quot;Options&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="addtrybutton" tabindex="-1"><code>addTryButton</code> <a class="header-anchor" href="#addtrybutton" aria-label="Permalink to &quot;`addTryButton`&quot;">&ZeroWidthSpace;</a></h3>
<p>A way to turn on the try buttons seen on the TS website.</p>
<ul>
<li><strong>Type</strong>: <code>boolean</code></li>
<li><strong>Default</strong>: <code>false</code></li>
</ul>
<div class="language-ts vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre v-pre class="shiki github-dark-dimmed has-focused-lines vp-code-dark" ><code><span class="line"><span style="color: #F47067">export</span><span style="color: #F69D50"> </span><span style="color: #F47067">default</span><span style="color: #F69D50"> </span><span style="color: #DCBDFB">withTwoslash</span><span style="color: #F69D50">(</span></span>
<span class="line"><span style="color: #F69D50">    </span><span style="color: #DCBDFB">defineConfig</span><span style="color: #F69D50">({</span></span>
<span class="line"><span style="color: #F69D50">        </span><span style="color: #ADBAC7">twoslash: {</span></span>
<span class="line has-focus"><span style="color: #ADBAC7">            addTryButton: </span><span style="color: #6CB6FF">true</span><span style="color: #ADBAC7">, </span></span>
<span class="line"><span style="color: #ADBAC7">        }</span><span style="color: #F69D50">,</span></span>
<span class="line"><span style="color: #F69D50">    })</span></span>
<span class="line"><span style="color: #F69D50">)</span></span></code></pre><pre v-pre class="shiki github-light has-focused-lines vp-code-light" ><code><span class="line"><span style="color: #D73A49">export</span><span style="color: #24292E"> </span><span style="color: #D73A49">default</span><span style="color: #24292E"> </span><span style="color: #6F42C1">withTwoslash</span><span style="color: #24292E">(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #6F42C1">defineConfig</span><span style="color: #24292E">({</span></span>
<span class="line"><span style="color: #24292E">        twoslash: {</span></span>
<span class="line has-focus"><span style="color: #24292E">            addTryButton: </span><span style="color: #005CC5">true</span><span style="color: #24292E">, </span></span>
<span class="line"><span style="color: #24292E">        },</span></span>
<span class="line"><span style="color: #24292E">    })</span></span>
<span class="line"><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br></div></div><h3 id="alwayraisefortwoslashexceptions" tabindex="-1"><code>alwayRaiseForTwoslashExceptions</code> <a class="header-anchor" href="#alwayraisefortwoslashexceptions" aria-label="Permalink to &quot;`alwayRaiseForTwoslashExceptions`&quot;">&ZeroWidthSpace;</a></h3>
<p>Instead of showing twoslash exceptions inline, throw the entire process like it will on CI.</p>
<ul>
<li><strong>Type</strong>: <code>boolean</code></li>
<li><strong>Default</strong>: <code>false</code></li>
</ul>
<div class="language-ts vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre v-pre class="shiki github-dark-dimmed has-focused-lines vp-code-dark" ><code><span class="line"><span style="color: #F47067">export</span><span style="color: #F69D50"> </span><span style="color: #F47067">default</span><span style="color: #F69D50"> </span><span style="color: #DCBDFB">withTwoslash</span><span style="color: #F69D50">(</span></span>
<span class="line"><span style="color: #F69D50">    </span><span style="color: #DCBDFB">defineConfig</span><span style="color: #F69D50">({</span></span>
<span class="line"><span style="color: #F69D50">        </span><span style="color: #ADBAC7">twoslash: {</span></span>
<span class="line has-focus"><span style="color: #ADBAC7">            alwayRaiseForTwoslashExceptions: </span><span style="color: #6CB6FF">true</span><span style="color: #ADBAC7">, </span></span>
<span class="line"><span style="color: #ADBAC7">        }</span><span style="color: #F69D50">,</span></span>
<span class="line"><span style="color: #F69D50">    })</span></span>
<span class="line"><span style="color: #F69D50">)</span></span></code></pre><pre v-pre class="shiki github-light has-focused-lines vp-code-light" ><code><span class="line"><span style="color: #D73A49">export</span><span style="color: #24292E"> </span><span style="color: #D73A49">default</span><span style="color: #24292E"> </span><span style="color: #6F42C1">withTwoslash</span><span style="color: #24292E">(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #6F42C1">defineConfig</span><span style="color: #24292E">({</span></span>
<span class="line"><span style="color: #24292E">        twoslash: {</span></span>
<span class="line has-focus"><span style="color: #24292E">            alwayRaiseForTwoslashExceptions: </span><span style="color: #005CC5">true</span><span style="color: #24292E">, </span></span>
<span class="line"><span style="color: #24292E">        },</span></span>
<span class="line"><span style="color: #24292E">    })</span></span>
<span class="line"><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br></div></div><h3 id="disableimplicitreactimport" tabindex="-1"><code>disableImplicitReactImport</code> <a class="header-anchor" href="#disableimplicitreactimport" aria-label="Permalink to &quot;`disableImplicitReactImport`&quot;">&ZeroWidthSpace;</a></h3>
<p>A way to disable implicit React imports on tsx/jsx language codeblocks</p>
<ul>
<li><strong>Type</strong>: <code>boolean</code></li>
<li><strong>Default</strong>: <code>false</code></li>
</ul>
<div class="language-ts vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre v-pre class="shiki github-dark-dimmed has-focused-lines vp-code-dark" ><code><span class="line"><span style="color: #F47067">export</span><span style="color: #F69D50"> </span><span style="color: #F47067">default</span><span style="color: #F69D50"> </span><span style="color: #DCBDFB">withTwoslash</span><span style="color: #F69D50">(</span></span>
<span class="line"><span style="color: #F69D50">    </span><span style="color: #DCBDFB">defineConfig</span><span style="color: #F69D50">({</span></span>
<span class="line"><span style="color: #F69D50">        </span><span style="color: #ADBAC7">twoslash: {</span></span>
<span class="line has-focus"><span style="color: #ADBAC7">            disableImplicitReactImport: </span><span style="color: #6CB6FF">true</span><span style="color: #ADBAC7">, </span></span>
<span class="line"><span style="color: #ADBAC7">        }</span><span style="color: #F69D50">,</span></span>
<span class="line"><span style="color: #F69D50">    })</span></span>
<span class="line"><span style="color: #F69D50">)</span></span></code></pre><pre v-pre class="shiki github-light has-focused-lines vp-code-light" ><code><span class="line"><span style="color: #D73A49">export</span><span style="color: #24292E"> </span><span style="color: #D73A49">default</span><span style="color: #24292E"> </span><span style="color: #6F42C1">withTwoslash</span><span style="color: #24292E">(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #6F42C1">defineConfig</span><span style="color: #24292E">({</span></span>
<span class="line"><span style="color: #24292E">        twoslash: {</span></span>
<span class="line has-focus"><span style="color: #24292E">            disableImplicitReactImport: </span><span style="color: #005CC5">true</span><span style="color: #24292E">, </span></span>
<span class="line"><span style="color: #24292E">        },</span></span>
<span class="line"><span style="color: #24292E">    })</span></span>
<span class="line"><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br></div></div><h3 id="includejsdocinhover" tabindex="-1"><code>includeJSDocInHover</code> <a class="header-anchor" href="#includejsdocinhover" aria-label="Permalink to &quot;`includeJSDocInHover`&quot;">&ZeroWidthSpace;</a></h3>
<p>Include JSDoc comments in the hovers.</p>
<ul>
<li><strong>Type</strong>: <code>boolean</code></li>
<li><strong>Default</strong>: <code>false</code></li>
</ul>
<div class="language-ts vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre v-pre class="shiki github-dark-dimmed has-focused-lines vp-code-dark" ><code><span class="line"><span style="color: #F47067">export</span><span style="color: #F69D50"> </span><span style="color: #F47067">default</span><span style="color: #F69D50"> </span><span style="color: #DCBDFB">withTwoslash</span><span style="color: #F69D50">(</span></span>
<span class="line"><span style="color: #F69D50">    </span><span style="color: #DCBDFB">defineConfig</span><span style="color: #F69D50">({</span></span>
<span class="line"><span style="color: #F69D50">        </span><span style="color: #ADBAC7">twoslash: {</span></span>
<span class="line has-focus"><span style="color: #ADBAC7">            includeJSDocInHover: </span><span style="color: #6CB6FF">true</span><span style="color: #ADBAC7">, </span></span>
<span class="line"><span style="color: #ADBAC7">        }</span><span style="color: #F69D50">,</span></span>
<span class="line"><span style="color: #F69D50">    })</span></span>
<span class="line"><span style="color: #F69D50">)</span></span></code></pre><pre v-pre class="shiki github-light has-focused-lines vp-code-light" ><code><span class="line"><span style="color: #D73A49">export</span><span style="color: #24292E"> </span><span style="color: #D73A49">default</span><span style="color: #24292E"> </span><span style="color: #6F42C1">withTwoslash</span><span style="color: #24292E">(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #6F42C1">defineConfig</span><span style="color: #24292E">({</span></span>
<span class="line"><span style="color: #24292E">        twoslash: {</span></span>
<span class="line has-focus"><span style="color: #24292E">            includeJSDocInHover: </span><span style="color: #005CC5">true</span><span style="color: #24292E">, </span></span>
<span class="line"><span style="color: #24292E">        },</span></span>
<span class="line"><span style="color: #24292E">    })</span></span>
<span class="line"><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br></div></div><h3 id="ignorecodeblockswithcodefencemeta" tabindex="-1"><code>ignoreCodeblocksWithCodefenceMeta</code> <a class="header-anchor" href="#ignorecodeblockswithcodefencemeta" aria-label="Permalink to &quot;`ignoreCodeblocksWithCodefenceMeta`&quot;">&ZeroWidthSpace;</a></h3>
<p>Ignore transforming certain code blocks.</p>
<ul>
<li><strong>Type</strong>: <code>boolean</code></li>
<li><strong>Default</strong>: <code>false</code></li>
</ul>
<div class="language-ts vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre v-pre class="shiki github-dark-dimmed has-focused-lines vp-code-dark" ><code><span class="line"><span style="color: #F47067">export</span><span style="color: #F69D50"> </span><span style="color: #F47067">default</span><span style="color: #F69D50"> </span><span style="color: #DCBDFB">withTwoslash</span><span style="color: #F69D50">(</span></span>
<span class="line"><span style="color: #F69D50">    </span><span style="color: #DCBDFB">defineConfig</span><span style="color: #F69D50">({</span></span>
<span class="line"><span style="color: #F69D50">        </span><span style="color: #ADBAC7">twoslash: {</span></span>
<span class="line has-focus"><span style="color: #ADBAC7">            ignoreCodeblocksWithCodefenceMeta: </span><span style="color: #6CB6FF">true</span><span style="color: #ADBAC7">, </span></span>
<span class="line"><span style="color: #ADBAC7">        }</span><span style="color: #F69D50">,</span></span>
<span class="line"><span style="color: #F69D50">    })</span></span>
<span class="line"><span style="color: #F69D50">)</span></span></code></pre><pre v-pre class="shiki github-light has-focused-lines vp-code-light" ><code><span class="line"><span style="color: #D73A49">export</span><span style="color: #24292E"> </span><span style="color: #D73A49">default</span><span style="color: #24292E"> </span><span style="color: #6F42C1">withTwoslash</span><span style="color: #24292E">(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #6F42C1">defineConfig</span><span style="color: #24292E">({</span></span>
<span class="line"><span style="color: #24292E">        twoslash: {</span></span>
<span class="line has-focus"><span style="color: #24292E">            ignoreCodeblocksWithCodefenceMeta: </span><span style="color: #005CC5">true</span><span style="color: #24292E">, </span></span>
<span class="line"><span style="color: #24292E">        },</span></span>
<span class="line"><span style="color: #24292E">    })</span></span>
<span class="line"><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br></div></div><h3 id="wrapfragments" tabindex="-1"><code>wrapFragments</code> <a class="header-anchor" href="#wrapfragments" aria-label="Permalink to &quot;`wrapFragments`&quot;">&ZeroWidthSpace;</a></h3>
<p>A way to add a div wrapper for multi-theme outputs.</p>
<ul>
<li><strong>Type</strong>: <code>boolean</code></li>
<li><strong>Default</strong>: <code>false</code></li>
</ul>
<div class="language-ts vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre v-pre class="shiki github-dark-dimmed has-focused-lines vp-code-dark" ><code><span class="line"><span style="color: #F47067">export</span><span style="color: #F69D50"> </span><span style="color: #F47067">default</span><span style="color: #F69D50"> </span><span style="color: #DCBDFB">withTwoslash</span><span style="color: #F69D50">(</span></span>
<span class="line"><span style="color: #F69D50">    </span><span style="color: #DCBDFB">defineConfig</span><span style="color: #F69D50">({</span></span>
<span class="line"><span style="color: #F69D50">        </span><span style="color: #ADBAC7">twoslash: {</span></span>
<span class="line has-focus"><span style="color: #ADBAC7">            wrapFragments: </span><span style="color: #6CB6FF">true</span><span style="color: #ADBAC7">, </span></span>
<span class="line"><span style="color: #ADBAC7">        }</span><span style="color: #F69D50">,</span></span>
<span class="line"><span style="color: #F69D50">    })</span></span>
<span class="line"><span style="color: #F69D50">)</span></span></code></pre><pre v-pre class="shiki github-light has-focused-lines vp-code-light" ><code><span class="line"><span style="color: #D73A49">export</span><span style="color: #24292E"> </span><span style="color: #D73A49">default</span><span style="color: #24292E"> </span><span style="color: #6F42C1">withTwoslash</span><span style="color: #24292E">(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #6F42C1">defineConfig</span><span style="color: #24292E">({</span></span>
<span class="line"><span style="color: #24292E">        twoslash: {</span></span>
<span class="line has-focus"><span style="color: #24292E">            wrapFragments: </span><span style="color: #005CC5">true</span><span style="color: #24292E">, </span></span>
<span class="line"><span style="color: #24292E">        },</span></span>
<span class="line"><span style="color: #24292E">    })</span></span>
<span class="line"><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br></div></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using a Custom Theme]]></title>
            <link>https://note.toshiki.devapplication/vitepress-plugin-shiki-twoslash/guide/custom-theme</link>
            <guid>https://note.toshiki.devapplication/vitepress-plugin-shiki-twoslash/guide/custom-theme</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="using-a-custom-theme" tabindex="-1">Using a Custom Theme <a class="header-anchor" href="#using-a-custom-theme" aria-label="Permalink to &quot;Using a Custom Theme&quot;">&ZeroWidthSpace;</a></h1>
<p>Twoslash uses your <code>markdown.theme</code> for syntax highlighting, but there are a few other things you can do to customize the look and feel of your code examples — particulary the generated Twoslash interface.</p>
<h2 id="css-variables" tabindex="-1">CSS Variables <a class="header-anchor" href="#css-variables" aria-label="Permalink to &quot;CSS Variables&quot;">&ZeroWidthSpace;</a></h2>
<p>The following CSS variables (and their defaults) are available to style Twoslash interface:</p>
<div class="language-css vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">css</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #6CB6FF">:root</span><span style="color: #ADBAC7"> {</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">--vp-twoslash-c-annotation-fg</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">var</span><span style="color: #ADBAC7">(</span><span style="color: #F69D50">--vp-c-text-1</span><span style="color: #ADBAC7">);</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">--vp-twoslash-c-brand</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">var</span><span style="color: #ADBAC7">(</span><span style="color: #F69D50">--vp-c-brand</span><span style="color: #ADBAC7">);</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">--vp-twoslash-c-error-bg</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">var</span><span style="color: #ADBAC7">(</span><span style="color: #F69D50">--vp-c-red-dimm-2</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">--vp-twoslash-c-error-fg</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">var</span><span style="color: #ADBAC7">(</span><span style="color: #F69D50">--vp-c-text-1</span><span style="color: #ADBAC7">);</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">--vp-twoslash-c-logger-error-bg</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">var</span><span style="color: #ADBAC7">(</span><span style="color: #F69D50">--vp-c-red-dimm-2</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">--vp-twoslash-c-logger-error-fg</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">var</span><span style="color: #ADBAC7">(</span><span style="color: #F69D50">--vp-c-red-dark</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">--vp-twoslash-c-logger-fg</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">var</span><span style="color: #ADBAC7">(</span><span style="color: #F69D50">--vp-c-text-1</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">--vp-twoslash-c-logger-log-bg</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">var</span><span style="color: #ADBAC7">(</span><span style="color: #F69D50">--vp-c-mute-dark</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">--vp-twoslash-c-logger-log-fg</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">var</span><span style="color: #ADBAC7">(</span><span style="color: #F69D50">--vp-c-gray</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">--vp-twoslash-c-logger-warn-bg</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">var</span><span style="color: #ADBAC7">(</span><span style="color: #F69D50">--vp-c-yellow-dimm-2</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">--vp-twoslash-c-logger-warn-fg</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">var</span><span style="color: #ADBAC7">(</span><span style="color: #F69D50">--vp-c-yellow-dark</span><span style="color: #ADBAC7">);</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">--vp-twoslash-c-lsp-bg</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">var</span><span style="color: #ADBAC7">(</span><span style="color: #F69D50">--vp-c-bg-elv</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">--vp-twoslash-c-lsp-border</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">var</span><span style="color: #ADBAC7">(</span><span style="color: #F69D50">--vp-c-divider</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">--vp-twoslash-c-lsp-fg</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">var</span><span style="color: #ADBAC7">(</span><span style="color: #F69D50">--vp-c-text-1</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">--vp-twoslash-c-lsp-underline</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">var</span><span style="color: #ADBAC7">(</span><span style="color: #F69D50">--vp-c-text-2</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">--vp-twoslash-lsp-shadow</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">var</span><span style="color: #ADBAC7">(</span><span style="color: #F69D50">--vp-shadow-2</span><span style="color: #ADBAC7">);</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">--vp-twoslash-c-query-bg</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">var</span><span style="color: #ADBAC7">(</span><span style="color: #F69D50">--vp-c-mute-darker</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">--vp-twoslash-c-query-fg-2</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">var</span><span style="color: #ADBAC7">(</span><span style="color: #F69D50">--vp-c-text-2</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">--vp-twoslash-c-query-fg</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">var</span><span style="color: #ADBAC7">(</span><span style="color: #F69D50">--vp-c-text-1</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">}</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">:root</span><span style="color: #24292E"> {</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">--vp-twoslash-c-annotation-fg</span><span style="color: #24292E">: </span><span style="color: #005CC5">var</span><span style="color: #24292E">(</span><span style="color: #E36209">--vp-c-text-1</span><span style="color: #24292E">);</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">--vp-twoslash-c-brand</span><span style="color: #24292E">: </span><span style="color: #005CC5">var</span><span style="color: #24292E">(</span><span style="color: #E36209">--vp-c-brand</span><span style="color: #24292E">);</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">--vp-twoslash-c-error-bg</span><span style="color: #24292E">: </span><span style="color: #005CC5">var</span><span style="color: #24292E">(</span><span style="color: #E36209">--vp-c-red-dimm-2</span><span style="color: #24292E">);</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">--vp-twoslash-c-error-fg</span><span style="color: #24292E">: </span><span style="color: #005CC5">var</span><span style="color: #24292E">(</span><span style="color: #E36209">--vp-c-text-1</span><span style="color: #24292E">);</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">--vp-twoslash-c-logger-error-bg</span><span style="color: #24292E">: </span><span style="color: #005CC5">var</span><span style="color: #24292E">(</span><span style="color: #E36209">--vp-c-red-dimm-2</span><span style="color: #24292E">);</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">--vp-twoslash-c-logger-error-fg</span><span style="color: #24292E">: </span><span style="color: #005CC5">var</span><span style="color: #24292E">(</span><span style="color: #E36209">--vp-c-red-dark</span><span style="color: #24292E">);</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">--vp-twoslash-c-logger-fg</span><span style="color: #24292E">: </span><span style="color: #005CC5">var</span><span style="color: #24292E">(</span><span style="color: #E36209">--vp-c-text-1</span><span style="color: #24292E">);</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">--vp-twoslash-c-logger-log-bg</span><span style="color: #24292E">: </span><span style="color: #005CC5">var</span><span style="color: #24292E">(</span><span style="color: #E36209">--vp-c-mute-dark</span><span style="color: #24292E">);</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">--vp-twoslash-c-logger-log-fg</span><span style="color: #24292E">: </span><span style="color: #005CC5">var</span><span style="color: #24292E">(</span><span style="color: #E36209">--vp-c-gray</span><span style="color: #24292E">);</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">--vp-twoslash-c-logger-warn-bg</span><span style="color: #24292E">: </span><span style="color: #005CC5">var</span><span style="color: #24292E">(</span><span style="color: #E36209">--vp-c-yellow-dimm-2</span><span style="color: #24292E">);</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">--vp-twoslash-c-logger-warn-fg</span><span style="color: #24292E">: </span><span style="color: #005CC5">var</span><span style="color: #24292E">(</span><span style="color: #E36209">--vp-c-yellow-dark</span><span style="color: #24292E">);</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">--vp-twoslash-c-lsp-bg</span><span style="color: #24292E">: </span><span style="color: #005CC5">var</span><span style="color: #24292E">(</span><span style="color: #E36209">--vp-c-bg-elv</span><span style="color: #24292E">);</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">--vp-twoslash-c-lsp-border</span><span style="color: #24292E">: </span><span style="color: #005CC5">var</span><span style="color: #24292E">(</span><span style="color: #E36209">--vp-c-divider</span><span style="color: #24292E">);</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">--vp-twoslash-c-lsp-fg</span><span style="color: #24292E">: </span><span style="color: #005CC5">var</span><span style="color: #24292E">(</span><span style="color: #E36209">--vp-c-text-1</span><span style="color: #24292E">);</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">--vp-twoslash-c-lsp-underline</span><span style="color: #24292E">: </span><span style="color: #005CC5">var</span><span style="color: #24292E">(</span><span style="color: #E36209">--vp-c-text-2</span><span style="color: #24292E">);</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">--vp-twoslash-lsp-shadow</span><span style="color: #24292E">: </span><span style="color: #005CC5">var</span><span style="color: #24292E">(</span><span style="color: #E36209">--vp-shadow-2</span><span style="color: #24292E">);</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">--vp-twoslash-c-query-bg</span><span style="color: #24292E">: </span><span style="color: #005CC5">var</span><span style="color: #24292E">(</span><span style="color: #E36209">--vp-c-mute-darker</span><span style="color: #24292E">);</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">--vp-twoslash-c-query-fg-2</span><span style="color: #24292E">: </span><span style="color: #005CC5">var</span><span style="color: #24292E">(</span><span style="color: #E36209">--vp-c-text-2</span><span style="color: #24292E">);</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">--vp-twoslash-c-query-fg</span><span style="color: #24292E">: </span><span style="color: #005CC5">var</span><span style="color: #24292E">(</span><span style="color: #E36209">--vp-c-text-1</span><span style="color: #24292E">);</span></span>
<span class="line"><span style="color: #24292E">}</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br></div></div><h2 id="dark-light-theme" tabindex="-1">Dark/Light Theme <a class="header-anchor" href="#dark-light-theme" aria-label="Permalink to &quot;Dark/Light Theme&quot;">&ZeroWidthSpace;</a></h2>
<p>If you pass a responsive theme to <code>markdown.theme</code>, you probably also want to hide/show the correct theme based on the user's settings.</p>
<div class="language-ts vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki github-dark-dimmed twoslash lsp" style="background-color: #22272e; color: #adbac7"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #F47067">export</span><span style="color: #F69D50"> </span><span style="color: #F47067">default</span><span style="color: #F69D50"> </span><span style="color: #DCBDFB"><data-lsp lsp='(alias) defineConfig(config: UserConfig&lt;DefaultTheme.Config>): UserConfig&lt;DefaultTheme.Config>&#10;import defineConfig' >defineConfig</data-lsp></span><span style="color: #F69D50">({</span></div><div class='line'><span style="color: #F69D50">    </span><span style="color: #ADBAC7"><data-lsp lsp='(property) UserConfig&lt;DefaultTheme.Config>.markdown?: MarkdownOptions | undefined' >markdown</data-lsp>: {</span></div><div class='line'><span style="color: #ADBAC7">        <data-lsp lsp='(property) MarkdownOptions.theme?: any' >theme</data-lsp>: { <data-lsp lsp='(property) dark: string' >dark</data-lsp>: </span><span style="color: #96D0FF">&apos;vitesse-dark&apos;</span><span style="color: #ADBAC7">, <data-lsp lsp='(property) light: string' >light</data-lsp>: </span><span style="color: #96D0FF">&apos;vitesse-light&apos;</span><span style="color: #ADBAC7"> },</span></div><div class='line'><span style="color: #ADBAC7">    }</span><span style="color: #F69D50">,</span></div><div class='line'><span style="color: #F69D50">})</span></div></code></div></pre>
<pre class="shiki github-light twoslash lsp" style="background-color: #fff; color: #24292e"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #D73A49">export</span><span style="color: #24292E"> </span><span style="color: #D73A49">default</span><span style="color: #24292E"> </span><span style="color: #6F42C1"><data-lsp lsp='(alias) defineConfig(config: UserConfig&lt;DefaultTheme.Config>): UserConfig&lt;DefaultTheme.Config>&#10;import defineConfig' >defineConfig</data-lsp></span><span style="color: #24292E">({</span></div><div class='line'><span style="color: #24292E">    <data-lsp lsp='(property) UserConfig&lt;DefaultTheme.Config>.markdown?: MarkdownOptions | undefined' >markdown</data-lsp>: {</span></div><div class='line'><span style="color: #24292E">        <data-lsp lsp='(property) MarkdownOptions.theme?: any' >theme</data-lsp>: { <data-lsp lsp='(property) dark: string' >dark</data-lsp>: </span><span style="color: #032F62">&apos;vitesse-dark&apos;</span><span style="color: #24292E">, <data-lsp lsp='(property) light: string' >light</data-lsp>: </span><span style="color: #032F62">&apos;vitesse-light&apos;</span><span style="color: #24292E"> },</span></div><div class='line'><span style="color: #24292E">    },</span></div><div class='line'><span style="color: #24292E">})</span></div></code></div></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>You can do this with the following CSS:</p>
<div class="language-css vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">css</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390">/*</span></span>
<span class="line"><span style="color: #768390"> * Hide block based on theme</span></span>
<span class="line"><span style="color: #768390"> * `[class*=&#39;-dark&#39;]` matches `&#39;vitesse-dark&#39;`</span></span>
<span class="line"><span style="color: #768390"> * `[class*=&#39;-light&#39;]` matches `&#39;vitesse-light&#39;`</span></span>
<span class="line"><span style="color: #768390"> */</span></span>
<span class="line"><span style="color: #8DDB8C">html</span><span style="color: #6CB6FF">:not</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">.dark</span><span style="color: #ADBAC7">) </span><span style="color: #8DDB8C">pre</span><span style="color: #6CB6FF">.shiki</span><span style="color: #ADBAC7">[</span><span style="color: #6CB6FF">class</span><span style="color: #F47067">*=</span><span style="color: #96D0FF">&#39;-dark&#39;</span><span style="color: #ADBAC7">] {</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">display</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">none</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">}</span></span>
<span class="line"><span style="color: #8DDB8C">html</span><span style="color: #6CB6FF">:not</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">.dark</span><span style="color: #ADBAC7">) </span><span style="color: #8DDB8C">pre</span><span style="color: #6CB6FF">.shiki</span><span style="color: #ADBAC7">[</span><span style="color: #6CB6FF">class</span><span style="color: #F47067">*=</span><span style="color: #96D0FF">&#39;-light&#39;</span><span style="color: #ADBAC7">] {</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">display</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">block</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">}</span></span>
<span class="line"><span style="color: #8DDB8C">html</span><span style="color: #6CB6FF">.dark</span><span style="color: #ADBAC7"> </span><span style="color: #8DDB8C">pre</span><span style="color: #6CB6FF">.shiki</span><span style="color: #ADBAC7">[</span><span style="color: #6CB6FF">class</span><span style="color: #F47067">*=</span><span style="color: #96D0FF">&#39;-dark&#39;</span><span style="color: #ADBAC7">] {</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">display</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">block</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">}</span></span>
<span class="line"><span style="color: #8DDB8C">html</span><span style="color: #6CB6FF">.dark</span><span style="color: #ADBAC7"> </span><span style="color: #8DDB8C">pre</span><span style="color: #6CB6FF">.shiki</span><span style="color: #ADBAC7">[</span><span style="color: #6CB6FF">class</span><span style="color: #F47067">*=</span><span style="color: #96D0FF">&#39;-light&#39;</span><span style="color: #ADBAC7">] {</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">display</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">none</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">}</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D">/*</span></span>
<span class="line"><span style="color: #6A737D"> * Hide block based on theme</span></span>
<span class="line"><span style="color: #6A737D"> * `[class*=&#39;-dark&#39;]` matches `&#39;vitesse-dark&#39;`</span></span>
<span class="line"><span style="color: #6A737D"> * `[class*=&#39;-light&#39;]` matches `&#39;vitesse-light&#39;`</span></span>
<span class="line"><span style="color: #6A737D"> */</span></span>
<span class="line"><span style="color: #22863A">html</span><span style="color: #6F42C1">:not</span><span style="color: #24292E">(</span><span style="color: #6F42C1">.dark</span><span style="color: #24292E">) </span><span style="color: #22863A">pre</span><span style="color: #6F42C1">.shiki</span><span style="color: #24292E">[</span><span style="color: #6F42C1">class</span><span style="color: #D73A49">*=</span><span style="color: #032F62">&#39;-dark&#39;</span><span style="color: #24292E">] {</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">display</span><span style="color: #24292E">: </span><span style="color: #005CC5">none</span><span style="color: #24292E">;</span></span>
<span class="line"><span style="color: #24292E">}</span></span>
<span class="line"><span style="color: #22863A">html</span><span style="color: #6F42C1">:not</span><span style="color: #24292E">(</span><span style="color: #6F42C1">.dark</span><span style="color: #24292E">) </span><span style="color: #22863A">pre</span><span style="color: #6F42C1">.shiki</span><span style="color: #24292E">[</span><span style="color: #6F42C1">class</span><span style="color: #D73A49">*=</span><span style="color: #032F62">&#39;-light&#39;</span><span style="color: #24292E">] {</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">display</span><span style="color: #24292E">: </span><span style="color: #005CC5">block</span><span style="color: #24292E">;</span></span>
<span class="line"><span style="color: #24292E">}</span></span>
<span class="line"><span style="color: #22863A">html</span><span style="color: #6F42C1">.dark</span><span style="color: #24292E"> </span><span style="color: #22863A">pre</span><span style="color: #6F42C1">.shiki</span><span style="color: #24292E">[</span><span style="color: #6F42C1">class</span><span style="color: #D73A49">*=</span><span style="color: #032F62">&#39;-dark&#39;</span><span style="color: #24292E">] {</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">display</span><span style="color: #24292E">: </span><span style="color: #005CC5">block</span><span style="color: #24292E">;</span></span>
<span class="line"><span style="color: #24292E">}</span></span>
<span class="line"><span style="color: #22863A">html</span><span style="color: #6F42C1">.dark</span><span style="color: #24292E"> </span><span style="color: #22863A">pre</span><span style="color: #6F42C1">.shiki</span><span style="color: #24292E">[</span><span style="color: #6F42C1">class</span><span style="color: #D73A49">*=</span><span style="color: #032F62">&#39;-light&#39;</span><span style="color: #24292E">] {</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">display</span><span style="color: #24292E">: </span><span style="color: #005CC5">none</span><span style="color: #24292E">;</span></span>
<span class="line"><span style="color: #24292E">}</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br></div></div>]]></description>
            <content:encoded><![CDATA[<h1 id="using-a-custom-theme" tabindex="-1">Using a Custom Theme <a class="header-anchor" href="#using-a-custom-theme" aria-label="Permalink to &quot;Using a Custom Theme&quot;">&ZeroWidthSpace;</a></h1>
<p>Twoslash uses your <code>markdown.theme</code> for syntax highlighting, but there are a few other things you can do to customize the look and feel of your code examples — particulary the generated Twoslash interface.</p>
<h2 id="css-variables" tabindex="-1">CSS Variables <a class="header-anchor" href="#css-variables" aria-label="Permalink to &quot;CSS Variables&quot;">&ZeroWidthSpace;</a></h2>
<p>The following CSS variables (and their defaults) are available to style Twoslash interface:</p>
<div class="language-css vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">css</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #6CB6FF">:root</span><span style="color: #ADBAC7"> {</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">--vp-twoslash-c-annotation-fg</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">var</span><span style="color: #ADBAC7">(</span><span style="color: #F69D50">--vp-c-text-1</span><span style="color: #ADBAC7">);</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">--vp-twoslash-c-brand</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">var</span><span style="color: #ADBAC7">(</span><span style="color: #F69D50">--vp-c-brand</span><span style="color: #ADBAC7">);</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">--vp-twoslash-c-error-bg</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">var</span><span style="color: #ADBAC7">(</span><span style="color: #F69D50">--vp-c-red-dimm-2</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">--vp-twoslash-c-error-fg</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">var</span><span style="color: #ADBAC7">(</span><span style="color: #F69D50">--vp-c-text-1</span><span style="color: #ADBAC7">);</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">--vp-twoslash-c-logger-error-bg</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">var</span><span style="color: #ADBAC7">(</span><span style="color: #F69D50">--vp-c-red-dimm-2</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">--vp-twoslash-c-logger-error-fg</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">var</span><span style="color: #ADBAC7">(</span><span style="color: #F69D50">--vp-c-red-dark</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">--vp-twoslash-c-logger-fg</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">var</span><span style="color: #ADBAC7">(</span><span style="color: #F69D50">--vp-c-text-1</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">--vp-twoslash-c-logger-log-bg</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">var</span><span style="color: #ADBAC7">(</span><span style="color: #F69D50">--vp-c-mute-dark</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">--vp-twoslash-c-logger-log-fg</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">var</span><span style="color: #ADBAC7">(</span><span style="color: #F69D50">--vp-c-gray</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">--vp-twoslash-c-logger-warn-bg</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">var</span><span style="color: #ADBAC7">(</span><span style="color: #F69D50">--vp-c-yellow-dimm-2</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">--vp-twoslash-c-logger-warn-fg</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">var</span><span style="color: #ADBAC7">(</span><span style="color: #F69D50">--vp-c-yellow-dark</span><span style="color: #ADBAC7">);</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">--vp-twoslash-c-lsp-bg</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">var</span><span style="color: #ADBAC7">(</span><span style="color: #F69D50">--vp-c-bg-elv</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">--vp-twoslash-c-lsp-border</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">var</span><span style="color: #ADBAC7">(</span><span style="color: #F69D50">--vp-c-divider</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">--vp-twoslash-c-lsp-fg</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">var</span><span style="color: #ADBAC7">(</span><span style="color: #F69D50">--vp-c-text-1</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">--vp-twoslash-c-lsp-underline</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">var</span><span style="color: #ADBAC7">(</span><span style="color: #F69D50">--vp-c-text-2</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">--vp-twoslash-lsp-shadow</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">var</span><span style="color: #ADBAC7">(</span><span style="color: #F69D50">--vp-shadow-2</span><span style="color: #ADBAC7">);</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">--vp-twoslash-c-query-bg</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">var</span><span style="color: #ADBAC7">(</span><span style="color: #F69D50">--vp-c-mute-darker</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">--vp-twoslash-c-query-fg-2</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">var</span><span style="color: #ADBAC7">(</span><span style="color: #F69D50">--vp-c-text-2</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">--vp-twoslash-c-query-fg</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">var</span><span style="color: #ADBAC7">(</span><span style="color: #F69D50">--vp-c-text-1</span><span style="color: #ADBAC7">);</span></span>
<span class="line"><span style="color: #ADBAC7">}</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">:root</span><span style="color: #24292E"> {</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">--vp-twoslash-c-annotation-fg</span><span style="color: #24292E">: </span><span style="color: #005CC5">var</span><span style="color: #24292E">(</span><span style="color: #E36209">--vp-c-text-1</span><span style="color: #24292E">);</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">--vp-twoslash-c-brand</span><span style="color: #24292E">: </span><span style="color: #005CC5">var</span><span style="color: #24292E">(</span><span style="color: #E36209">--vp-c-brand</span><span style="color: #24292E">);</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">--vp-twoslash-c-error-bg</span><span style="color: #24292E">: </span><span style="color: #005CC5">var</span><span style="color: #24292E">(</span><span style="color: #E36209">--vp-c-red-dimm-2</span><span style="color: #24292E">);</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">--vp-twoslash-c-error-fg</span><span style="color: #24292E">: </span><span style="color: #005CC5">var</span><span style="color: #24292E">(</span><span style="color: #E36209">--vp-c-text-1</span><span style="color: #24292E">);</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">--vp-twoslash-c-logger-error-bg</span><span style="color: #24292E">: </span><span style="color: #005CC5">var</span><span style="color: #24292E">(</span><span style="color: #E36209">--vp-c-red-dimm-2</span><span style="color: #24292E">);</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">--vp-twoslash-c-logger-error-fg</span><span style="color: #24292E">: </span><span style="color: #005CC5">var</span><span style="color: #24292E">(</span><span style="color: #E36209">--vp-c-red-dark</span><span style="color: #24292E">);</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">--vp-twoslash-c-logger-fg</span><span style="color: #24292E">: </span><span style="color: #005CC5">var</span><span style="color: #24292E">(</span><span style="color: #E36209">--vp-c-text-1</span><span style="color: #24292E">);</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">--vp-twoslash-c-logger-log-bg</span><span style="color: #24292E">: </span><span style="color: #005CC5">var</span><span style="color: #24292E">(</span><span style="color: #E36209">--vp-c-mute-dark</span><span style="color: #24292E">);</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">--vp-twoslash-c-logger-log-fg</span><span style="color: #24292E">: </span><span style="color: #005CC5">var</span><span style="color: #24292E">(</span><span style="color: #E36209">--vp-c-gray</span><span style="color: #24292E">);</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">--vp-twoslash-c-logger-warn-bg</span><span style="color: #24292E">: </span><span style="color: #005CC5">var</span><span style="color: #24292E">(</span><span style="color: #E36209">--vp-c-yellow-dimm-2</span><span style="color: #24292E">);</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">--vp-twoslash-c-logger-warn-fg</span><span style="color: #24292E">: </span><span style="color: #005CC5">var</span><span style="color: #24292E">(</span><span style="color: #E36209">--vp-c-yellow-dark</span><span style="color: #24292E">);</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">--vp-twoslash-c-lsp-bg</span><span style="color: #24292E">: </span><span style="color: #005CC5">var</span><span style="color: #24292E">(</span><span style="color: #E36209">--vp-c-bg-elv</span><span style="color: #24292E">);</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">--vp-twoslash-c-lsp-border</span><span style="color: #24292E">: </span><span style="color: #005CC5">var</span><span style="color: #24292E">(</span><span style="color: #E36209">--vp-c-divider</span><span style="color: #24292E">);</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">--vp-twoslash-c-lsp-fg</span><span style="color: #24292E">: </span><span style="color: #005CC5">var</span><span style="color: #24292E">(</span><span style="color: #E36209">--vp-c-text-1</span><span style="color: #24292E">);</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">--vp-twoslash-c-lsp-underline</span><span style="color: #24292E">: </span><span style="color: #005CC5">var</span><span style="color: #24292E">(</span><span style="color: #E36209">--vp-c-text-2</span><span style="color: #24292E">);</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">--vp-twoslash-lsp-shadow</span><span style="color: #24292E">: </span><span style="color: #005CC5">var</span><span style="color: #24292E">(</span><span style="color: #E36209">--vp-shadow-2</span><span style="color: #24292E">);</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">--vp-twoslash-c-query-bg</span><span style="color: #24292E">: </span><span style="color: #005CC5">var</span><span style="color: #24292E">(</span><span style="color: #E36209">--vp-c-mute-darker</span><span style="color: #24292E">);</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">--vp-twoslash-c-query-fg-2</span><span style="color: #24292E">: </span><span style="color: #005CC5">var</span><span style="color: #24292E">(</span><span style="color: #E36209">--vp-c-text-2</span><span style="color: #24292E">);</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">--vp-twoslash-c-query-fg</span><span style="color: #24292E">: </span><span style="color: #005CC5">var</span><span style="color: #24292E">(</span><span style="color: #E36209">--vp-c-text-1</span><span style="color: #24292E">);</span></span>
<span class="line"><span style="color: #24292E">}</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br></div></div><h2 id="dark-light-theme" tabindex="-1">Dark/Light Theme <a class="header-anchor" href="#dark-light-theme" aria-label="Permalink to &quot;Dark/Light Theme&quot;">&ZeroWidthSpace;</a></h2>
<p>If you pass a responsive theme to <code>markdown.theme</code>, you probably also want to hide/show the correct theme based on the user's settings.</p>
<div class="language-ts vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki github-dark-dimmed twoslash lsp" style="background-color: #22272e; color: #adbac7"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #F47067">export</span><span style="color: #F69D50"> </span><span style="color: #F47067">default</span><span style="color: #F69D50"> </span><span style="color: #DCBDFB"><data-lsp lsp='(alias) defineConfig(config: UserConfig&lt;DefaultTheme.Config>): UserConfig&lt;DefaultTheme.Config>&#10;import defineConfig' >defineConfig</data-lsp></span><span style="color: #F69D50">({</span></div><div class='line'><span style="color: #F69D50">    </span><span style="color: #ADBAC7"><data-lsp lsp='(property) UserConfig&lt;DefaultTheme.Config>.markdown?: MarkdownOptions | undefined' >markdown</data-lsp>: {</span></div><div class='line'><span style="color: #ADBAC7">        <data-lsp lsp='(property) MarkdownOptions.theme?: any' >theme</data-lsp>: { <data-lsp lsp='(property) dark: string' >dark</data-lsp>: </span><span style="color: #96D0FF">&apos;vitesse-dark&apos;</span><span style="color: #ADBAC7">, <data-lsp lsp='(property) light: string' >light</data-lsp>: </span><span style="color: #96D0FF">&apos;vitesse-light&apos;</span><span style="color: #ADBAC7"> },</span></div><div class='line'><span style="color: #ADBAC7">    }</span><span style="color: #F69D50">,</span></div><div class='line'><span style="color: #F69D50">})</span></div></code></div></pre>
<pre class="shiki github-light twoslash lsp" style="background-color: #fff; color: #24292e"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #D73A49">export</span><span style="color: #24292E"> </span><span style="color: #D73A49">default</span><span style="color: #24292E"> </span><span style="color: #6F42C1"><data-lsp lsp='(alias) defineConfig(config: UserConfig&lt;DefaultTheme.Config>): UserConfig&lt;DefaultTheme.Config>&#10;import defineConfig' >defineConfig</data-lsp></span><span style="color: #24292E">({</span></div><div class='line'><span style="color: #24292E">    <data-lsp lsp='(property) UserConfig&lt;DefaultTheme.Config>.markdown?: MarkdownOptions | undefined' >markdown</data-lsp>: {</span></div><div class='line'><span style="color: #24292E">        <data-lsp lsp='(property) MarkdownOptions.theme?: any' >theme</data-lsp>: { <data-lsp lsp='(property) dark: string' >dark</data-lsp>: </span><span style="color: #032F62">&apos;vitesse-dark&apos;</span><span style="color: #24292E">, <data-lsp lsp='(property) light: string' >light</data-lsp>: </span><span style="color: #032F62">&apos;vitesse-light&apos;</span><span style="color: #24292E"> },</span></div><div class='line'><span style="color: #24292E">    },</span></div><div class='line'><span style="color: #24292E">})</span></div></code></div></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>You can do this with the following CSS:</p>
<div class="language-css vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">css</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390">/*</span></span>
<span class="line"><span style="color: #768390"> * Hide block based on theme</span></span>
<span class="line"><span style="color: #768390"> * `[class*=&#39;-dark&#39;]` matches `&#39;vitesse-dark&#39;`</span></span>
<span class="line"><span style="color: #768390"> * `[class*=&#39;-light&#39;]` matches `&#39;vitesse-light&#39;`</span></span>
<span class="line"><span style="color: #768390"> */</span></span>
<span class="line"><span style="color: #8DDB8C">html</span><span style="color: #6CB6FF">:not</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">.dark</span><span style="color: #ADBAC7">) </span><span style="color: #8DDB8C">pre</span><span style="color: #6CB6FF">.shiki</span><span style="color: #ADBAC7">[</span><span style="color: #6CB6FF">class</span><span style="color: #F47067">*=</span><span style="color: #96D0FF">&#39;-dark&#39;</span><span style="color: #ADBAC7">] {</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">display</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">none</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">}</span></span>
<span class="line"><span style="color: #8DDB8C">html</span><span style="color: #6CB6FF">:not</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">.dark</span><span style="color: #ADBAC7">) </span><span style="color: #8DDB8C">pre</span><span style="color: #6CB6FF">.shiki</span><span style="color: #ADBAC7">[</span><span style="color: #6CB6FF">class</span><span style="color: #F47067">*=</span><span style="color: #96D0FF">&#39;-light&#39;</span><span style="color: #ADBAC7">] {</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">display</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">block</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">}</span></span>
<span class="line"><span style="color: #8DDB8C">html</span><span style="color: #6CB6FF">.dark</span><span style="color: #ADBAC7"> </span><span style="color: #8DDB8C">pre</span><span style="color: #6CB6FF">.shiki</span><span style="color: #ADBAC7">[</span><span style="color: #6CB6FF">class</span><span style="color: #F47067">*=</span><span style="color: #96D0FF">&#39;-dark&#39;</span><span style="color: #ADBAC7">] {</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">display</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">block</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">}</span></span>
<span class="line"><span style="color: #8DDB8C">html</span><span style="color: #6CB6FF">.dark</span><span style="color: #ADBAC7"> </span><span style="color: #8DDB8C">pre</span><span style="color: #6CB6FF">.shiki</span><span style="color: #ADBAC7">[</span><span style="color: #6CB6FF">class</span><span style="color: #F47067">*=</span><span style="color: #96D0FF">&#39;-light&#39;</span><span style="color: #ADBAC7">] {</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">display</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">none</span><span style="color: #ADBAC7">;</span></span>
<span class="line"><span style="color: #ADBAC7">}</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D">/*</span></span>
<span class="line"><span style="color: #6A737D"> * Hide block based on theme</span></span>
<span class="line"><span style="color: #6A737D"> * `[class*=&#39;-dark&#39;]` matches `&#39;vitesse-dark&#39;`</span></span>
<span class="line"><span style="color: #6A737D"> * `[class*=&#39;-light&#39;]` matches `&#39;vitesse-light&#39;`</span></span>
<span class="line"><span style="color: #6A737D"> */</span></span>
<span class="line"><span style="color: #22863A">html</span><span style="color: #6F42C1">:not</span><span style="color: #24292E">(</span><span style="color: #6F42C1">.dark</span><span style="color: #24292E">) </span><span style="color: #22863A">pre</span><span style="color: #6F42C1">.shiki</span><span style="color: #24292E">[</span><span style="color: #6F42C1">class</span><span style="color: #D73A49">*=</span><span style="color: #032F62">&#39;-dark&#39;</span><span style="color: #24292E">] {</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">display</span><span style="color: #24292E">: </span><span style="color: #005CC5">none</span><span style="color: #24292E">;</span></span>
<span class="line"><span style="color: #24292E">}</span></span>
<span class="line"><span style="color: #22863A">html</span><span style="color: #6F42C1">:not</span><span style="color: #24292E">(</span><span style="color: #6F42C1">.dark</span><span style="color: #24292E">) </span><span style="color: #22863A">pre</span><span style="color: #6F42C1">.shiki</span><span style="color: #24292E">[</span><span style="color: #6F42C1">class</span><span style="color: #D73A49">*=</span><span style="color: #032F62">&#39;-light&#39;</span><span style="color: #24292E">] {</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">display</span><span style="color: #24292E">: </span><span style="color: #005CC5">block</span><span style="color: #24292E">;</span></span>
<span class="line"><span style="color: #24292E">}</span></span>
<span class="line"><span style="color: #22863A">html</span><span style="color: #6F42C1">.dark</span><span style="color: #24292E"> </span><span style="color: #22863A">pre</span><span style="color: #6F42C1">.shiki</span><span style="color: #24292E">[</span><span style="color: #6F42C1">class</span><span style="color: #D73A49">*=</span><span style="color: #032F62">&#39;-dark&#39;</span><span style="color: #24292E">] {</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">display</span><span style="color: #24292E">: </span><span style="color: #005CC5">block</span><span style="color: #24292E">;</span></span>
<span class="line"><span style="color: #24292E">}</span></span>
<span class="line"><span style="color: #22863A">html</span><span style="color: #6F42C1">.dark</span><span style="color: #24292E"> </span><span style="color: #22863A">pre</span><span style="color: #6F42C1">.shiki</span><span style="color: #24292E">[</span><span style="color: #6F42C1">class</span><span style="color: #D73A49">*=</span><span style="color: #032F62">&#39;-light&#39;</span><span style="color: #24292E">] {</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">display</span><span style="color: #24292E">: </span><span style="color: #005CC5">none</span><span style="color: #24292E">;</span></span>
<span class="line"><span style="color: #24292E">}</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br></div></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Markdown Extensions]]></title>
            <link>https://note.toshiki.devapplication/vitepress-plugin-shiki-twoslash/guide/markdown-extensions</link>
            <guid>https://note.toshiki.devapplication/vitepress-plugin-shiki-twoslash/guide/markdown-extensions</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="markdown-extensions" tabindex="-1">Markdown Extensions <a class="header-anchor" href="#markdown-extensions" aria-label="Permalink to &quot;Markdown Extensions&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="code-groups" tabindex="-1">Code Groups <a class="header-anchor" href="#code-groups" aria-label="Permalink to &quot;Code Groups&quot;">&ZeroWidthSpace;</a></h2>
<p><a href="https://vitepress.dev/guide/markdown#code-groups" target="_blank" rel="noreferrer">Code Groups</a> and Twoslash <a href="/api/multi-file.html">multi-file</a> support.</p>
<div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-SjgnY" id="tab-cnwCd9P" checked="checked"><label for="tab-cnwCd9P">index.ts</label><input type="radio" name="group-SjgnY" id="tab-bVv3VyC" ><label for="tab-bVv3VyC">name.ts</label></div><div class="blocks">
<div class="language-ts vp-adaptive-theme active line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki github-dark-dimmed twoslash lsp" style="background-color: #22272e; color: #adbac7"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #F47067">import</span><span style="color: #ADBAC7"> { <data-lsp lsp='(alias) const name: "twoslash"&#10;import name' >name</data-lsp> } </span><span style="color: #F47067">from</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&apos;./name&apos;</span></div><div class='line'><span style="color: #F47067">export</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">function</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB"><data-lsp lsp='function hello(name: string): void' >hello</data-lsp></span><span style="color: #ADBAC7">(</span><span style="color: #F69D50"><data-lsp lsp='(parameter) name: string' >name</data-lsp></span><span style="color: #F47067">:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">string</span><span style="color: #ADBAC7">) {</span></div><div class='line'><span style="color: #ADBAC7">    <data-lsp lsp='var console: Console' >console</data-lsp>.</span><span style="color: #DCBDFB"><data-lsp lsp='(method) Console.log(...data: any[]): void' >log</data-lsp></span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">`Hello, ${</span><span style="color: #ADBAC7"><data-lsp lsp='(parameter) name: string' >name</data-lsp></span><span style="color: #96D0FF">}!`</span><span style="color: #ADBAC7">)</span></div><div class='line'><span style="color: #ADBAC7">}</span></div><div class='line'><span style="color: #DCBDFB"><data-lsp lsp='function hello(name: string): void' >hello</data-lsp></span><span style="color: #ADBAC7">(<data-lsp lsp='(alias) const name: "twoslash"&#10;import name' style='border-bottom: solid 2px lightgrey;'>name</data-lsp>)</span></div><div class='meta-line'><span class='popover-prefix'>       </span><span class='popover'><div class='arrow'></div>(alias) const name: "twoslash"
import name</span></div></code></div></pre>
<pre class="shiki github-light twoslash lsp" style="background-color: #fff; color: #24292e"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #D73A49">import</span><span style="color: #24292E"> { <data-lsp lsp='(alias) const name: "twoslash"&#10;import name' >name</data-lsp> } </span><span style="color: #D73A49">from</span><span style="color: #24292E"> </span><span style="color: #032F62">&apos;./name&apos;</span></div><div class='line'><span style="color: #D73A49">export</span><span style="color: #24292E"> </span><span style="color: #D73A49">function</span><span style="color: #24292E"> </span><span style="color: #6F42C1"><data-lsp lsp='function hello(name: string): void' >hello</data-lsp></span><span style="color: #24292E">(</span><span style="color: #E36209"><data-lsp lsp='(parameter) name: string' >name</data-lsp></span><span style="color: #D73A49">:</span><span style="color: #24292E"> </span><span style="color: #005CC5">string</span><span style="color: #24292E">) {</span></div><div class='line'><span style="color: #24292E">    <data-lsp lsp='var console: Console' >console</data-lsp>.</span><span style="color: #6F42C1"><data-lsp lsp='(method) Console.log(...data: any[]): void' >log</data-lsp></span><span style="color: #24292E">(</span><span style="color: #032F62">`Hello, ${</span><span style="color: #24292E"><data-lsp lsp='(parameter) name: string' >name</data-lsp></span><span style="color: #032F62">}!`</span><span style="color: #24292E">)</span></div><div class='line'><span style="color: #24292E">}</span></div><div class='line'><span style="color: #6F42C1"><data-lsp lsp='function hello(name: string): void' >hello</data-lsp></span><span style="color: #24292E">(<data-lsp lsp='(alias) const name: "twoslash"&#10;import name' style='border-bottom: solid 2px lightgrey;'>name</data-lsp>)</span></div><div class='meta-line'><span class='popover-prefix'>       </span><span class='popover'><div class='arrow'></div>(alias) const name: "twoslash"
import name</span></div></code></div></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><div class="language-ts vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki github-dark-dimmed twoslash lsp" style="background-color: #22272e; color: #adbac7"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #F47067">export</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">const</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF"><data-lsp lsp='const name: "twoslash"' >name</data-lsp></span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&apos;twoslash&apos;</span></div></code></div></pre>
<pre class="shiki github-light twoslash lsp" style="background-color: #fff; color: #24292e"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #D73A49">export</span><span style="color: #24292E"> </span><span style="color: #D73A49">const</span><span style="color: #24292E"> </span><span style="color: #005CC5"><data-lsp lsp='const name: "twoslash"' >name</data-lsp></span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #032F62">&apos;twoslash&apos;</span></div></code></div></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div></div></div>
<h2 id="unsupported-extensions" tabindex="-1">Unsupported Extensions <a class="header-anchor" href="#unsupported-extensions" aria-label="Permalink to &quot;Unsupported Extensions&quot;">&ZeroWidthSpace;</a></h2>
<p>Since VitePress Twoslash uses it's own <a href="https://github.com/shikijs/shiki" target="_blank" rel="noreferrer">Shiki</a> highlighter, the following syntax highlighting extensions are not currently compatible.</p>
<ul>
<li><a href="https://vitepress.dev/guide/markdown#line-highlighting-in-code-blocks" target="_blank" rel="noreferrer">Line Highlighting in Code Blocks</a></li>
<li><a href="https://vitepress.dev/guide/markdown#focus-in-code-blocks" target="_blank" rel="noreferrer">Focus in Code Blocks</a></li>
<li><a href="https://vitepress.dev/guide/markdown#colored-diffs-in-code-blocks" target="_blank" rel="noreferrer">Colored Diffs in Code Blocks</a></li>
<li><a href="https://vitepress.dev/guide/markdown#errors-and-warnings-in-code-blocks" target="_blank" rel="noreferrer">Errors and Warnings in Code Blocks</a></li>
<li><a href="https://vitepress.dev/guide/markdown#line-numbers" target="_blank" rel="noreferrer">Line Numbers</a></li>
<li><a href="https://vitepress.dev/guide/markdown#import-code-snippets" target="_blank" rel="noreferrer">Import Code Snippets</a></li>
</ul>
<p>If you are interested in adding support, please start a new <a href="https://github.com/andatoshiki/@andatoshiki/vitepress-plugin-shiki-twoslash" target="_blank" rel="noreferrer">GitHub Discussion</a>.</p>
]]></description>
            <content:encoded><![CDATA[<h1 id="markdown-extensions" tabindex="-1">Markdown Extensions <a class="header-anchor" href="#markdown-extensions" aria-label="Permalink to &quot;Markdown Extensions&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="code-groups" tabindex="-1">Code Groups <a class="header-anchor" href="#code-groups" aria-label="Permalink to &quot;Code Groups&quot;">&ZeroWidthSpace;</a></h2>
<p><a href="https://vitepress.dev/guide/markdown#code-groups" target="_blank" rel="noreferrer">Code Groups</a> and Twoslash <a href="/api/multi-file.html">multi-file</a> support.</p>
<div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-SjgnY" id="tab-cnwCd9P" checked="checked"><label for="tab-cnwCd9P">index.ts</label><input type="radio" name="group-SjgnY" id="tab-bVv3VyC" ><label for="tab-bVv3VyC">name.ts</label></div><div class="blocks">
<div class="language-ts vp-adaptive-theme active line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki github-dark-dimmed twoslash lsp" style="background-color: #22272e; color: #adbac7"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #F47067">import</span><span style="color: #ADBAC7"> { <data-lsp lsp='(alias) const name: "twoslash"&#10;import name' >name</data-lsp> } </span><span style="color: #F47067">from</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&apos;./name&apos;</span></div><div class='line'><span style="color: #F47067">export</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">function</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB"><data-lsp lsp='function hello(name: string): void' >hello</data-lsp></span><span style="color: #ADBAC7">(</span><span style="color: #F69D50"><data-lsp lsp='(parameter) name: string' >name</data-lsp></span><span style="color: #F47067">:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">string</span><span style="color: #ADBAC7">) {</span></div><div class='line'><span style="color: #ADBAC7">    <data-lsp lsp='var console: Console' >console</data-lsp>.</span><span style="color: #DCBDFB"><data-lsp lsp='(method) Console.log(...data: any[]): void' >log</data-lsp></span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">`Hello, ${</span><span style="color: #ADBAC7"><data-lsp lsp='(parameter) name: string' >name</data-lsp></span><span style="color: #96D0FF">}!`</span><span style="color: #ADBAC7">)</span></div><div class='line'><span style="color: #ADBAC7">}</span></div><div class='line'><span style="color: #DCBDFB"><data-lsp lsp='function hello(name: string): void' >hello</data-lsp></span><span style="color: #ADBAC7">(<data-lsp lsp='(alias) const name: "twoslash"&#10;import name' style='border-bottom: solid 2px lightgrey;'>name</data-lsp>)</span></div><div class='meta-line'><span class='popover-prefix'>       </span><span class='popover'><div class='arrow'></div>(alias) const name: "twoslash"
import name</span></div></code></div></pre>
<pre class="shiki github-light twoslash lsp" style="background-color: #fff; color: #24292e"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #D73A49">import</span><span style="color: #24292E"> { <data-lsp lsp='(alias) const name: "twoslash"&#10;import name' >name</data-lsp> } </span><span style="color: #D73A49">from</span><span style="color: #24292E"> </span><span style="color: #032F62">&apos;./name&apos;</span></div><div class='line'><span style="color: #D73A49">export</span><span style="color: #24292E"> </span><span style="color: #D73A49">function</span><span style="color: #24292E"> </span><span style="color: #6F42C1"><data-lsp lsp='function hello(name: string): void' >hello</data-lsp></span><span style="color: #24292E">(</span><span style="color: #E36209"><data-lsp lsp='(parameter) name: string' >name</data-lsp></span><span style="color: #D73A49">:</span><span style="color: #24292E"> </span><span style="color: #005CC5">string</span><span style="color: #24292E">) {</span></div><div class='line'><span style="color: #24292E">    <data-lsp lsp='var console: Console' >console</data-lsp>.</span><span style="color: #6F42C1"><data-lsp lsp='(method) Console.log(...data: any[]): void' >log</data-lsp></span><span style="color: #24292E">(</span><span style="color: #032F62">`Hello, ${</span><span style="color: #24292E"><data-lsp lsp='(parameter) name: string' >name</data-lsp></span><span style="color: #032F62">}!`</span><span style="color: #24292E">)</span></div><div class='line'><span style="color: #24292E">}</span></div><div class='line'><span style="color: #6F42C1"><data-lsp lsp='function hello(name: string): void' >hello</data-lsp></span><span style="color: #24292E">(<data-lsp lsp='(alias) const name: "twoslash"&#10;import name' style='border-bottom: solid 2px lightgrey;'>name</data-lsp>)</span></div><div class='meta-line'><span class='popover-prefix'>       </span><span class='popover'><div class='arrow'></div>(alias) const name: "twoslash"
import name</span></div></code></div></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><div class="language-ts vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki github-dark-dimmed twoslash lsp" style="background-color: #22272e; color: #adbac7"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #F47067">export</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">const</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF"><data-lsp lsp='const name: "twoslash"' >name</data-lsp></span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&apos;twoslash&apos;</span></div></code></div></pre>
<pre class="shiki github-light twoslash lsp" style="background-color: #fff; color: #24292e"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #D73A49">export</span><span style="color: #24292E"> </span><span style="color: #D73A49">const</span><span style="color: #24292E"> </span><span style="color: #005CC5"><data-lsp lsp='const name: "twoslash"' >name</data-lsp></span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #032F62">&apos;twoslash&apos;</span></div></code></div></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div></div></div>
<h2 id="unsupported-extensions" tabindex="-1">Unsupported Extensions <a class="header-anchor" href="#unsupported-extensions" aria-label="Permalink to &quot;Unsupported Extensions&quot;">&ZeroWidthSpace;</a></h2>
<p>Since VitePress Twoslash uses it's own <a href="https://github.com/shikijs/shiki" target="_blank" rel="noreferrer">Shiki</a> highlighter, the following syntax highlighting extensions are not currently compatible.</p>
<ul>
<li><a href="https://vitepress.dev/guide/markdown#line-highlighting-in-code-blocks" target="_blank" rel="noreferrer">Line Highlighting in Code Blocks</a></li>
<li><a href="https://vitepress.dev/guide/markdown#focus-in-code-blocks" target="_blank" rel="noreferrer">Focus in Code Blocks</a></li>
<li><a href="https://vitepress.dev/guide/markdown#colored-diffs-in-code-blocks" target="_blank" rel="noreferrer">Colored Diffs in Code Blocks</a></li>
<li><a href="https://vitepress.dev/guide/markdown#errors-and-warnings-in-code-blocks" target="_blank" rel="noreferrer">Errors and Warnings in Code Blocks</a></li>
<li><a href="https://vitepress.dev/guide/markdown#line-numbers" target="_blank" rel="noreferrer">Line Numbers</a></li>
<li><a href="https://vitepress.dev/guide/markdown#import-code-snippets" target="_blank" rel="noreferrer">Import Code Snippets</a></li>
</ul>
<p>If you are interested in adding support, please start a new <a href="https://github.com/andatoshiki/@andatoshiki/vitepress-plugin-shiki-twoslash" target="_blank" rel="noreferrer">GitHub Discussion</a>.</p>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[VitePress Twoslash: VitePress Plugin for Shiki Twoslash]]></title>
            <link>https://note.toshiki.devapplication/vitepress-plugin-shiki-twoslash/</link>
            <guid>https://note.toshiki.devapplication/vitepress-plugin-shiki-twoslash/</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="andatoshiki-vitepress-plugin-shiki-twoslash" tabindex="-1">@andatoshiki/vitepress-plugin-shiki-twoslash <a class="header-anchor" href="#andatoshiki-vitepress-plugin-shiki-twoslash" aria-label="Permalink to &quot;@andatoshiki/vitepress-plugin-shiki-twoslash&quot;">&ZeroWidthSpace;</a></h1>
<blockquote>
<p>Static code examples for <a href="https://vitepress.dev" target="_blank" rel="noreferrer">VitePress</a> using <a href="https://github.com/shikijs/twoslash" target="_blank" rel="noreferrer">Shiki Twoslash</a> — powered by the syntax engine of Visual Studio Code and the TypeScript compiler.</p>
</blockquote>
<h2 id="overview" tabindex="-1">Overview <a class="header-anchor" href="#overview" aria-label="Permalink to &quot;Overview&quot;">&ZeroWidthSpace;</a></h2>
<p>Try moving your cursor into the code block below:</p>
<div class="language-ts vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki github-dark-dimmed twoslash lsp" style="background-color: #22272e; color: #adbac7"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #768390">// Removes &apos;readonly&apos; attributes from a type&apos;s properties</span></div><div class='line'><span style="color: #F47067">type</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50"><data-lsp lsp='type CreateMutable&lt;Type> = { -readonly [Property in keyof Type]: Type[Property]; }' >CreateMutable</data-lsp></span><span style="color: #ADBAC7">&lt;</span><span style="color: #F69D50"><data-lsp lsp='(type parameter) Type in type CreateMutable&lt;Type>' >Type</data-lsp></span><span style="color: #ADBAC7">&gt; </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> {</span></div><div class='line'><span style="color: #ADBAC7">    </span><span style="color: #F47067">-readonly</span><span style="color: #ADBAC7"> [</span><span style="color: #F69D50"><data-lsp lsp='(type parameter) Property' >Property</data-lsp></span><span style="color: #ADBAC7"> </span><span style="color: #F47067">in</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">keyof</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50"><data-lsp lsp='(type parameter) Type in type CreateMutable&lt;Type>' >Type</data-lsp></span><span style="color: #ADBAC7">]</span><span style="color: #F47067">:</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50"><data-lsp lsp='(type parameter) Type in type CreateMutable&lt;Type>' >Type</data-lsp></span><span style="color: #ADBAC7">[</span><span style="color: #F69D50"><data-lsp lsp='(type parameter) Property' >Property</data-lsp></span><span style="color: #ADBAC7">]</span></div><div class='line'><span style="color: #ADBAC7">}</span></div><div class='line'>&nbsp;</div><div class='line'><span style="color: #F47067">type</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50"><data-lsp lsp='type LockedAccount = {&#10;    readonly id: string;&#10;    readonly name: string;&#10;}' >LockedAccount</data-lsp></span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> {</span></div><div class='line'><span style="color: #ADBAC7">    </span><span style="color: #F47067">readonly</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50"><data-lsp lsp='(property) id: string' >id</data-lsp></span><span style="color: #F47067">:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">string</span></div><div class='line'><span style="color: #ADBAC7">    </span><span style="color: #F47067">readonly</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50"><data-lsp lsp='(property) name: string' >name</data-lsp></span><span style="color: #F47067">:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">string</span></div><div class='line'><span style="color: #ADBAC7">}</span></div><div class='line'>&nbsp;</div><div class='line'><span style="color: #F47067">type</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50"><data-lsp lsp='type UnlockedAccount = {&#10;    id: string;&#10;    name: string;&#10;}' >UnlockedAccount</data-lsp></span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50"><data-lsp lsp='type CreateMutable&lt;Type> = { -readonly [Property in keyof Type]: Type[Property]; }' >CreateMutable</data-lsp></span><span style="color: #ADBAC7">&lt;</span><span style="color: #F69D50"><data-lsp lsp='type LockedAccount = {&#10;    readonly id: string;&#10;    readonly name: string;&#10;}' >LockedAccount</data-lsp></span><span style="color: #ADBAC7">&gt;</span></div></code></div></pre>
<pre class="shiki github-light twoslash lsp" style="background-color: #fff; color: #24292e"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #6A737D">// Removes &apos;readonly&apos; attributes from a type&apos;s properties</span></div><div class='line'><span style="color: #D73A49">type</span><span style="color: #24292E"> </span><span style="color: #6F42C1"><data-lsp lsp='type CreateMutable&lt;Type> = { -readonly [Property in keyof Type]: Type[Property]; }' >CreateMutable</data-lsp></span><span style="color: #24292E">&lt;</span><span style="color: #6F42C1"><data-lsp lsp='(type parameter) Type in type CreateMutable&lt;Type>' >Type</data-lsp></span><span style="color: #24292E">&gt; </span><span style="color: #D73A49">=</span><span style="color: #24292E"> {</span></div><div class='line'><span style="color: #24292E">    </span><span style="color: #D73A49">-readonly</span><span style="color: #24292E"> [</span><span style="color: #6F42C1"><data-lsp lsp='(type parameter) Property' >Property</data-lsp></span><span style="color: #24292E"> </span><span style="color: #D73A49">in</span><span style="color: #24292E"> </span><span style="color: #D73A49">keyof</span><span style="color: #24292E"> </span><span style="color: #6F42C1"><data-lsp lsp='(type parameter) Type in type CreateMutable&lt;Type>' >Type</data-lsp></span><span style="color: #24292E">]</span><span style="color: #D73A49">:</span><span style="color: #24292E"> </span><span style="color: #6F42C1"><data-lsp lsp='(type parameter) Type in type CreateMutable&lt;Type>' >Type</data-lsp></span><span style="color: #24292E">[</span><span style="color: #6F42C1"><data-lsp lsp='(type parameter) Property' >Property</data-lsp></span><span style="color: #24292E">]</span></div><div class='line'><span style="color: #24292E">}</span></div><div class='line'>&nbsp;</div><div class='line'><span style="color: #D73A49">type</span><span style="color: #24292E"> </span><span style="color: #6F42C1"><data-lsp lsp='type LockedAccount = {&#10;    readonly id: string;&#10;    readonly name: string;&#10;}' >LockedAccount</data-lsp></span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> {</span></div><div class='line'><span style="color: #24292E">    </span><span style="color: #D73A49">readonly</span><span style="color: #24292E"> </span><span style="color: #E36209"><data-lsp lsp='(property) id: string' >id</data-lsp></span><span style="color: #D73A49">:</span><span style="color: #24292E"> </span><span style="color: #005CC5">string</span></div><div class='line'><span style="color: #24292E">    </span><span style="color: #D73A49">readonly</span><span style="color: #24292E"> </span><span style="color: #E36209"><data-lsp lsp='(property) name: string' >name</data-lsp></span><span style="color: #D73A49">:</span><span style="color: #24292E"> </span><span style="color: #005CC5">string</span></div><div class='line'><span style="color: #24292E">}</span></div><div class='line'>&nbsp;</div><div class='line'><span style="color: #D73A49">type</span><span style="color: #24292E"> </span><span style="color: #6F42C1"><data-lsp lsp='type UnlockedAccount = {&#10;    id: string;&#10;    name: string;&#10;}' >UnlockedAccount</data-lsp></span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #6F42C1"><data-lsp lsp='type CreateMutable&lt;Type> = { -readonly [Property in keyof Type]: Type[Property]; }' >CreateMutable</data-lsp></span><span style="color: #24292E">&lt;</span><span style="color: #6F42C1"><data-lsp lsp='type LockedAccount = {&#10;    readonly id: string;&#10;    readonly name: string;&#10;}' >LockedAccount</data-lsp></span><span style="color: #24292E">&gt;</span></div></code></div></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>Pretty neat, right? To some extent, anything your editor can show you about code, Twoslash can show. For example, here is the real auto-complete for a VitePress config:</p>
<div class="language-ts vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki github-dark-dimmed twoslash lsp" style="background-color: #22272e; color: #adbac7"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #F47067">import</span><span style="color: #ADBAC7"> { <data-lsp lsp='(alias) function defineConfig(config: UserConfig&lt;DefaultTheme.Config>): UserConfig&lt;DefaultTheme.Config>&#10;import defineConfig' >defineConfig</data-lsp> } </span><span style="color: #F47067">from</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&apos;vitepress&apos;</span></div><div class='line'>&nbsp;</div><div class='line'><span style="color: #F47067">export</span><span style="color: #F69D50"> </span><span style="color: #F47067">default</span><span style="color: #F69D50"> </span><span style="color: #DCBDFB"><data-lsp lsp='(alias) defineConfig(config: UserConfig&lt;DefaultTheme.Config>): UserConfig&lt;DefaultTheme.Config>&#10;import defineConfig' >defineConfig</data-lsp></span><span style="color: #F69D50">({</span></div><div class='line'><span style="color: #F69D50">    </span><span style="color: #ADBAC7"><data-lsp lsp='(property) ti: any' >ti</data-lsp></span><span style="color: #F69D50">,</span></div><div class='meta-line'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class='inline-completions'><ul class='dropdown'><li class=''><span><span class='result-found'>ti</span>tle</span></li><li class=''><span><span class='result-found'>ti</span>tleTemplate</span></li></ul></span></div><div class='line'><span style="color: #F69D50">})</span></div></code></div></pre>
<pre class="shiki github-light twoslash lsp" style="background-color: #fff; color: #24292e"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #D73A49">import</span><span style="color: #24292E"> { <data-lsp lsp='(alias) function defineConfig(config: UserConfig&lt;DefaultTheme.Config>): UserConfig&lt;DefaultTheme.Config>&#10;import defineConfig' >defineConfig</data-lsp> } </span><span style="color: #D73A49">from</span><span style="color: #24292E"> </span><span style="color: #032F62">&apos;vitepress&apos;</span></div><div class='line'>&nbsp;</div><div class='line'><span style="color: #D73A49">export</span><span style="color: #24292E"> </span><span style="color: #D73A49">default</span><span style="color: #24292E"> </span><span style="color: #6F42C1"><data-lsp lsp='(alias) defineConfig(config: UserConfig&lt;DefaultTheme.Config>): UserConfig&lt;DefaultTheme.Config>&#10;import defineConfig' >defineConfig</data-lsp></span><span style="color: #24292E">({</span></div><div class='line'><span style="color: #24292E">    <data-lsp lsp='(property) ti: any' >ti</data-lsp>,</span></div><div class='meta-line'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class='inline-completions'><ul class='dropdown'><li class=''><span><span class='result-found'>ti</span>tle</span></li><li class=''><span><span class='result-found'>ti</span>tleTemplate</span></li></ul></span></div><div class='line'><span style="color: #24292E">})</span></div></code></div></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>The name Twoslash refers to specially formatted comments (e.g. <code>// ^?</code>) which can be used to set up your environment, like compiler flags or separate input files. It couldn't be easier to set up and start creating incredible code examples!</p>
<h2 id="install" tabindex="-1">Install <a class="header-anchor" href="#install" aria-label="Permalink to &quot;Install&quot;">&ZeroWidthSpace;</a></h2>
<p>Install <code>@andatoshiki/vitepress-plugin-shiki-twoslash</code> (requires <code>vitepress@&gt;=1.0.0-alpha.61</code>).</p>
<div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-8c9kv" id="tab-M1ru4zh" checked="checked"><label for="tab-M1ru4zh">pnpm</label><input type="radio" name="group-8c9kv" id="tab-aByCiYO" ><label for="tab-aByCiYO">npm</label><input type="radio" name="group-8c9kv" id="tab-G_UYEOj" ><label for="tab-G_UYEOj">yarn</label></div><div class="blocks">
<div class="language-bash vp-adaptive-theme active line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">pnpm</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">add</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">@andatoshiki/vitepress-plugin-shiki-twoslash</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">pnpm</span><span style="color: #24292E"> </span><span style="color: #032F62">add</span><span style="color: #24292E"> </span><span style="color: #032F62">@andatoshiki/vitepress-plugin-shiki-twoslash</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="language-bash vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">npm</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">i</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">@andatoshiki/vitepress-plugin-shiki-twoslash</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">npm</span><span style="color: #24292E"> </span><span style="color: #032F62">i</span><span style="color: #24292E"> </span><span style="color: #032F62">@andatoshiki/vitepress-plugin-shiki-twoslash</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="language-bash vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">yarn</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">add</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">@andatoshiki/vitepress-plugin-shiki-twoslash</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">yarn</span><span style="color: #24292E"> </span><span style="color: #032F62">add</span><span style="color: #24292E"> </span><span style="color: #032F62">@andatoshiki/vitepress-plugin-shiki-twoslash</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div></div></div>
<div class="warning custom-block"><p class="custom-block-title">WARNING</p>
<p>Until <code>shiki-twoslash</code> uses the same version of <code>shiki</code> as VitePress, you must override the following packages' <code>shiki</code> versions for syntax highlighting to look the same.</p>
<div class="language-json vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">json</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">{</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #8DDB8C">&quot;pnpm&quot;</span><span style="color: #ADBAC7">: {</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #8DDB8C">&quot;overrides&quot;</span><span style="color: #ADBAC7">: {</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #8DDB8C">&quot;remark-shiki-twoslash&gt;shiki&quot;</span><span style="color: #ADBAC7">: </span><span style="color: #96D0FF">&quot;^0.14.1&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #8DDB8C">&quot;shiki-twoslash&gt;shiki&quot;</span><span style="color: #ADBAC7">: </span><span style="color: #96D0FF">&quot;^0.14.1&quot;</span></span>
<span class="line"><span style="color: #ADBAC7">        }</span></span>
<span class="line"><span style="color: #ADBAC7">    }</span></span>
<span class="line"><span style="color: #ADBAC7">}</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">{</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">&quot;pnpm&quot;</span><span style="color: #24292E">: {</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #005CC5">&quot;overrides&quot;</span><span style="color: #24292E">: {</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">&quot;remark-shiki-twoslash&gt;shiki&quot;</span><span style="color: #24292E">: </span><span style="color: #032F62">&quot;^0.14.1&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">&quot;shiki-twoslash&gt;shiki&quot;</span><span style="color: #24292E">: </span><span style="color: #032F62">&quot;^0.14.1&quot;</span></span>
<span class="line"><span style="color: #24292E">        }</span></span>
<span class="line"><span style="color: #24292E">    }</span></span>
<span class="line"><span style="color: #24292E">}</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br></div></div><p>Tracked in an upstream issue: <a href="https://github.com/shikijs/twoslash/issues/180" target="_blank" rel="noreferrer">https://github.com/shikijs/twoslash/issues/180</a></p>
</div>
<h2 id="configure" tabindex="-1">Configure <a class="header-anchor" href="#configure" aria-label="Permalink to &quot;Configure&quot;">&ZeroWidthSpace;</a></h2>
<p>First, wrap your VitePress config file with the <code>withTwoslash</code> wrapper.</p>
<div class="language-ts vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki github-dark-dimmed twoslash lsp" style="background-color: #22272e; color: #adbac7"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #768390">// .vitepress/config.[ext]</span></div><div class='line'><span style="color: #F47067">import</span><span style="color: #ADBAC7"> { <data-lsp lsp='(alias) function defineConfig(config: UserConfig&lt;DefaultTheme.Config>): UserConfig&lt;DefaultTheme.Config>&#10;import defineConfig' >defineConfig</data-lsp> } </span><span style="color: #F47067">from</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&apos;vitepress&apos;</span></div><div class='line'><span style="color: #F47067">import</span><span style="color: #ADBAC7"> { <data-lsp lsp='(alias) function withTwoslash(config: UserConfig&lt;DefaultTheme.Config>): Promise&lt;UserConfig&lt;DefaultTheme.Config>>&#10;import withTwoslash' >withTwoslash</data-lsp> } </span><span style="color: #F47067">from</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&apos;@andatoshiki/vitepress-plugin-shiki-twoslash&apos;</span></div><div class='line'>&nbsp;</div><div class='line'><span style="color: #F47067">export</span><span style="color: #F69D50"> </span><span style="color: #F47067">default</span><span style="color: #F69D50"> </span><span style="color: #DCBDFB"><data-lsp lsp='(alias) withTwoslash(config: UserConfig&lt;DefaultTheme.Config>): Promise&lt;UserConfig&lt;DefaultTheme.Config>>&#10;import withTwoslash' >withTwoslash</data-lsp></span><span style="color: #F69D50">(</span></div><div class='line'><span style="color: #F69D50">    </span><span style="color: #DCBDFB"><data-lsp lsp='(alias) defineConfig(config: UserConfig&lt;DefaultTheme.Config>): UserConfig&lt;DefaultTheme.Config>&#10;import defineConfig' >defineConfig</data-lsp></span><span style="color: #F69D50">({</span></div><div class='line'><span style="color: #F69D50">        </span><span style="color: #768390">// Your VitePress config</span></div><div class='line'><span style="color: #F69D50">    })</span></div><div class='line'><span style="color: #F69D50">)</span></div></code></div></pre>
<pre class="shiki github-light twoslash lsp" style="background-color: #fff; color: #24292e"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #6A737D">// .vitepress/config.[ext]</span></div><div class='line'><span style="color: #D73A49">import</span><span style="color: #24292E"> { <data-lsp lsp='(alias) function defineConfig(config: UserConfig&lt;DefaultTheme.Config>): UserConfig&lt;DefaultTheme.Config>&#10;import defineConfig' >defineConfig</data-lsp> } </span><span style="color: #D73A49">from</span><span style="color: #24292E"> </span><span style="color: #032F62">&apos;vitepress&apos;</span></div><div class='line'><span style="color: #D73A49">import</span><span style="color: #24292E"> { <data-lsp lsp='(alias) function withTwoslash(config: UserConfig&lt;DefaultTheme.Config>): Promise&lt;UserConfig&lt;DefaultTheme.Config>>&#10;import withTwoslash' >withTwoslash</data-lsp> } </span><span style="color: #D73A49">from</span><span style="color: #24292E"> </span><span style="color: #032F62">&apos;@andatoshiki/vitepress-plugin-shiki-twoslash&apos;</span></div><div class='line'>&nbsp;</div><div class='line'><span style="color: #D73A49">export</span><span style="color: #24292E"> </span><span style="color: #D73A49">default</span><span style="color: #24292E"> </span><span style="color: #6F42C1"><data-lsp lsp='(alias) withTwoslash(config: UserConfig&lt;DefaultTheme.Config>): Promise&lt;UserConfig&lt;DefaultTheme.Config>>&#10;import withTwoslash' >withTwoslash</data-lsp></span><span style="color: #24292E">(</span></div><div class='line'><span style="color: #24292E">    </span><span style="color: #6F42C1"><data-lsp lsp='(alias) defineConfig(config: UserConfig&lt;DefaultTheme.Config>): UserConfig&lt;DefaultTheme.Config>&#10;import defineConfig' >defineConfig</data-lsp></span><span style="color: #24292E">({</span></div><div class='line'><span style="color: #24292E">        </span><span style="color: #6A737D">// Your VitePress config</span></div><div class='line'><span style="color: #24292E">    })</span></div><div class='line'><span style="color: #24292E">)</span></div></code></div></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>Then, import <code>@andatoshiki/vitepress-plugin-shiki-twoslash/styles.css</code> into your theme.</p>
<div class="language-ts vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki github-dark-dimmed twoslash lsp" style="background-color: #22272e; color: #adbac7"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #768390">// .vitepress/theme/index.ts</span></div><div class='line'><span style="color: #F47067">import</span><span style="color: #ADBAC7"> <data-lsp lsp='(alias) const defaultTheme: {&#10;    Layout: DefineComponent;&#10;    enhanceApp: (ctx: EnhanceAppContext) => void;&#10;}&#10;import defaultTheme' >defaultTheme</data-lsp> </span><span style="color: #F47067">from</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&apos;vitepress/theme&apos;</span></div><div class='line'><span style="color: #F47067">import</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&apos;@andatoshiki/vitepress-plugin-shiki-twoslash/styles.css&apos;</span></div><div class='line'>&nbsp;</div><div class='line'><span style="color: #F47067">export</span><span style="color: #F69D50"> </span><span style="color: #F47067">default</span><span style="color: #F69D50"> </span><span style="color: #ADBAC7"><data-lsp lsp='(alias) const defaultTheme: {&#10;    Layout: DefineComponent;&#10;    enhanceApp: (ctx: EnhanceAppContext) => void;&#10;}&#10;import defaultTheme' >defaultTheme</data-lsp></span></div></code></div></pre>
<pre class="shiki github-light twoslash lsp" style="background-color: #fff; color: #24292e"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #6A737D">// .vitepress/theme/index.ts</span></div><div class='line'><span style="color: #D73A49">import</span><span style="color: #24292E"> <data-lsp lsp='(alias) const defaultTheme: {&#10;    Layout: DefineComponent;&#10;    enhanceApp: (ctx: EnhanceAppContext) => void;&#10;}&#10;import defaultTheme' >defaultTheme</data-lsp> </span><span style="color: #D73A49">from</span><span style="color: #24292E"> </span><span style="color: #032F62">&apos;vitepress/theme&apos;</span></div><div class='line'><span style="color: #D73A49">import</span><span style="color: #24292E"> </span><span style="color: #032F62">&apos;@andatoshiki/vitepress-plugin-shiki-twoslash/styles.css&apos;</span></div><div class='line'>&nbsp;</div><div class='line'><span style="color: #D73A49">export</span><span style="color: #24292E"> </span><span style="color: #D73A49">default</span><span style="color: #24292E"> <data-lsp lsp='(alias) const defaultTheme: {&#10;    Layout: DefineComponent;&#10;    enhanceApp: (ctx: EnhanceAppContext) => void;&#10;}&#10;import defaultTheme' >defaultTheme</data-lsp></span></div></code></div></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="tip custom-block"><p class="custom-block-title">TIP</p>
<p>You can <a href="./config/reference.html">configure VitePress Twoslash</a> using the <code>twoslash</code> property added to <code>defineConfig</code>.</p>
</div>
<h2 id="add-twoslash" tabindex="-1">Add Twoslash <a class="header-anchor" href="#add-twoslash" aria-label="Permalink to &quot;Add Twoslash&quot;">&ZeroWidthSpace;</a></h2>
<p>Finally, add the <code>twoslash</code> attribute to markdown fenced code blocks.</p>
<div class="language-md vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">md</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">```ts twoslash</span></span>
<span class="line"><span style="color: #768390">// Removes &#39;readonly&#39; attributes from a type&#39;s properties</span></span>
<span class="line"><span style="color: #F47067">type</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50">CreateMutable</span><span style="color: #ADBAC7">&lt;</span><span style="color: #F69D50">Type</span><span style="color: #ADBAC7">&gt; </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> {</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">-readonly</span><span style="color: #ADBAC7"> [</span><span style="color: #F69D50">Property</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">in</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">keyof</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50">Type</span><span style="color: #ADBAC7">]</span><span style="color: #F47067">:</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50">Type</span><span style="color: #ADBAC7">[</span><span style="color: #F69D50">Property</span><span style="color: #ADBAC7">]</span></span>
<span class="line"><span style="color: #ADBAC7">}</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F47067">type</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50">LockedAccount</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> {</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">readonly</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50">id</span><span style="color: #F47067">:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">string</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">readonly</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50">name</span><span style="color: #F47067">:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">string</span></span>
<span class="line"><span style="color: #ADBAC7">}</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F47067">type</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50">UnlockedAccount</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50">CreateMutable</span><span style="color: #ADBAC7">&lt;</span><span style="color: #F69D50">LockedAccount</span><span style="color: #ADBAC7">&gt;</span></span>
<span class="line"><span style="color: #768390">//   ^?</span></span>
<span class="line"><span style="color: #ADBAC7">```</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">```ts twoslash</span></span>
<span class="line"><span style="color: #6A737D">// Removes &#39;readonly&#39; attributes from a type&#39;s properties</span></span>
<span class="line"><span style="color: #D73A49">type</span><span style="color: #24292E"> </span><span style="color: #6F42C1">CreateMutable</span><span style="color: #24292E">&lt;</span><span style="color: #6F42C1">Type</span><span style="color: #24292E">&gt; </span><span style="color: #D73A49">=</span><span style="color: #24292E"> {</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">-readonly</span><span style="color: #24292E"> [</span><span style="color: #6F42C1">Property</span><span style="color: #24292E"> </span><span style="color: #D73A49">in</span><span style="color: #24292E"> </span><span style="color: #D73A49">keyof</span><span style="color: #24292E"> </span><span style="color: #6F42C1">Type</span><span style="color: #24292E">]</span><span style="color: #D73A49">:</span><span style="color: #24292E"> </span><span style="color: #6F42C1">Type</span><span style="color: #24292E">[</span><span style="color: #6F42C1">Property</span><span style="color: #24292E">]</span></span>
<span class="line"><span style="color: #24292E">}</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D73A49">type</span><span style="color: #24292E"> </span><span style="color: #6F42C1">LockedAccount</span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> {</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">readonly</span><span style="color: #24292E"> </span><span style="color: #E36209">id</span><span style="color: #D73A49">:</span><span style="color: #24292E"> </span><span style="color: #005CC5">string</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">readonly</span><span style="color: #24292E"> </span><span style="color: #E36209">name</span><span style="color: #D73A49">:</span><span style="color: #24292E"> </span><span style="color: #005CC5">string</span></span>
<span class="line"><span style="color: #24292E">}</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D73A49">type</span><span style="color: #24292E"> </span><span style="color: #6F42C1">UnlockedAccount</span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #6F42C1">CreateMutable</span><span style="color: #24292E">&lt;</span><span style="color: #6F42C1">LockedAccount</span><span style="color: #24292E">&gt;</span></span>
<span class="line"><span style="color: #6A737D">//   ^?</span></span>
<span class="line"><span style="color: #24292E">```</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br></div></div><p>And your code blocks will be twoslashified!</p>
<div class="language-ts vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki github-dark-dimmed twoslash lsp" style="background-color: #22272e; color: #adbac7"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #768390">// Removes &apos;readonly&apos; attributes from a type&apos;s properties</span></div><div class='line'><span style="color: #F47067">type</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50"><data-lsp lsp='type CreateMutable&lt;Type> = { -readonly [Property in keyof Type]: Type[Property]; }' >CreateMutable</data-lsp></span><span style="color: #ADBAC7">&lt;</span><span style="color: #F69D50"><data-lsp lsp='(type parameter) Type in type CreateMutable&lt;Type>' >Type</data-lsp></span><span style="color: #ADBAC7">&gt; </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> {</span></div><div class='line'><span style="color: #ADBAC7">    </span><span style="color: #F47067">-readonly</span><span style="color: #ADBAC7"> [</span><span style="color: #F69D50"><data-lsp lsp='(type parameter) Property' >Property</data-lsp></span><span style="color: #ADBAC7"> </span><span style="color: #F47067">in</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">keyof</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50"><data-lsp lsp='(type parameter) Type in type CreateMutable&lt;Type>' >Type</data-lsp></span><span style="color: #ADBAC7">]</span><span style="color: #F47067">:</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50"><data-lsp lsp='(type parameter) Type in type CreateMutable&lt;Type>' >Type</data-lsp></span><span style="color: #ADBAC7">[</span><span style="color: #F69D50"><data-lsp lsp='(type parameter) Property' >Property</data-lsp></span><span style="color: #ADBAC7">]</span></div><div class='line'><span style="color: #ADBAC7">}</span></div><div class='line'>&nbsp;</div><div class='line'><span style="color: #F47067">type</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50"><data-lsp lsp='type LockedAccount = {&#10;    readonly id: string;&#10;    readonly name: string;&#10;}' >LockedAccount</data-lsp></span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> {</span></div><div class='line'><span style="color: #ADBAC7">    </span><span style="color: #F47067">readonly</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50"><data-lsp lsp='(property) id: string' >id</data-lsp></span><span style="color: #F47067">:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">string</span></div><div class='line'><span style="color: #ADBAC7">    </span><span style="color: #F47067">readonly</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50"><data-lsp lsp='(property) name: string' >name</data-lsp></span><span style="color: #F47067">:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">string</span></div><div class='line'><span style="color: #ADBAC7">}</span></div><div class='line'>&nbsp;</div><div class='line'><span style="color: #F47067">type</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50"><data-lsp lsp='type UnlockedAccount = {&#10;    id: string;&#10;    name: string;&#10;}' style='border-bottom: solid 2px lightgrey;'>UnlockedAccount</data-lsp></span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50"><data-lsp lsp='type CreateMutable&lt;Type> = { -readonly [Property in keyof Type]: Type[Property]; }' >CreateMutable</data-lsp></span><span style="color: #ADBAC7">&lt;</span><span style="color: #F69D50"><data-lsp lsp='type LockedAccount = {&#10;    readonly id: string;&#10;    readonly name: string;&#10;}' >LockedAccount</data-lsp></span><span style="color: #ADBAC7">&gt;</span></div><div class='meta-line'><span class='popover-prefix'>           </span><span class='popover'><div class='arrow'></div>type UnlockedAccount = {
    id: string;
    name: string;
}</span></div></code></div></pre>
<pre class="shiki github-light twoslash lsp" style="background-color: #fff; color: #24292e"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #6A737D">// Removes &apos;readonly&apos; attributes from a type&apos;s properties</span></div><div class='line'><span style="color: #D73A49">type</span><span style="color: #24292E"> </span><span style="color: #6F42C1"><data-lsp lsp='type CreateMutable&lt;Type> = { -readonly [Property in keyof Type]: Type[Property]; }' >CreateMutable</data-lsp></span><span style="color: #24292E">&lt;</span><span style="color: #6F42C1"><data-lsp lsp='(type parameter) Type in type CreateMutable&lt;Type>' >Type</data-lsp></span><span style="color: #24292E">&gt; </span><span style="color: #D73A49">=</span><span style="color: #24292E"> {</span></div><div class='line'><span style="color: #24292E">    </span><span style="color: #D73A49">-readonly</span><span style="color: #24292E"> [</span><span style="color: #6F42C1"><data-lsp lsp='(type parameter) Property' >Property</data-lsp></span><span style="color: #24292E"> </span><span style="color: #D73A49">in</span><span style="color: #24292E"> </span><span style="color: #D73A49">keyof</span><span style="color: #24292E"> </span><span style="color: #6F42C1"><data-lsp lsp='(type parameter) Type in type CreateMutable&lt;Type>' >Type</data-lsp></span><span style="color: #24292E">]</span><span style="color: #D73A49">:</span><span style="color: #24292E"> </span><span style="color: #6F42C1"><data-lsp lsp='(type parameter) Type in type CreateMutable&lt;Type>' >Type</data-lsp></span><span style="color: #24292E">[</span><span style="color: #6F42C1"><data-lsp lsp='(type parameter) Property' >Property</data-lsp></span><span style="color: #24292E">]</span></div><div class='line'><span style="color: #24292E">}</span></div><div class='line'>&nbsp;</div><div class='line'><span style="color: #D73A49">type</span><span style="color: #24292E"> </span><span style="color: #6F42C1"><data-lsp lsp='type LockedAccount = {&#10;    readonly id: string;&#10;    readonly name: string;&#10;}' >LockedAccount</data-lsp></span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> {</span></div><div class='line'><span style="color: #24292E">    </span><span style="color: #D73A49">readonly</span><span style="color: #24292E"> </span><span style="color: #E36209"><data-lsp lsp='(property) id: string' >id</data-lsp></span><span style="color: #D73A49">:</span><span style="color: #24292E"> </span><span style="color: #005CC5">string</span></div><div class='line'><span style="color: #24292E">    </span><span style="color: #D73A49">readonly</span><span style="color: #24292E"> </span><span style="color: #E36209"><data-lsp lsp='(property) name: string' >name</data-lsp></span><span style="color: #D73A49">:</span><span style="color: #24292E"> </span><span style="color: #005CC5">string</span></div><div class='line'><span style="color: #24292E">}</span></div><div class='line'>&nbsp;</div><div class='line'><span style="color: #D73A49">type</span><span style="color: #24292E"> </span><span style="color: #6F42C1"><data-lsp lsp='type UnlockedAccount = {&#10;    id: string;&#10;    name: string;&#10;}' style='border-bottom: solid 2px lightgrey;'>UnlockedAccount</data-lsp></span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #6F42C1"><data-lsp lsp='type CreateMutable&lt;Type> = { -readonly [Property in keyof Type]: Type[Property]; }' >CreateMutable</data-lsp></span><span style="color: #24292E">&lt;</span><span style="color: #6F42C1"><data-lsp lsp='type LockedAccount = {&#10;    readonly id: string;&#10;    readonly name: string;&#10;}' >LockedAccount</data-lsp></span><span style="color: #24292E">&gt;</span></div><div class='meta-line'><span class='popover-prefix'>           </span><span class='popover'><div class='arrow'></div>type UnlockedAccount = {
    id: string;
    name: string;
}</span></div></code></div></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br></div></div>]]></description>
            <content:encoded><![CDATA[<h1 id="andatoshiki-vitepress-plugin-shiki-twoslash" tabindex="-1">@andatoshiki/vitepress-plugin-shiki-twoslash <a class="header-anchor" href="#andatoshiki-vitepress-plugin-shiki-twoslash" aria-label="Permalink to &quot;@andatoshiki/vitepress-plugin-shiki-twoslash&quot;">&ZeroWidthSpace;</a></h1>
<blockquote>
<p>Static code examples for <a href="https://vitepress.dev" target="_blank" rel="noreferrer">VitePress</a> using <a href="https://github.com/shikijs/twoslash" target="_blank" rel="noreferrer">Shiki Twoslash</a> — powered by the syntax engine of Visual Studio Code and the TypeScript compiler.</p>
</blockquote>
<h2 id="overview" tabindex="-1">Overview <a class="header-anchor" href="#overview" aria-label="Permalink to &quot;Overview&quot;">&ZeroWidthSpace;</a></h2>
<p>Try moving your cursor into the code block below:</p>
<div class="language-ts vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki github-dark-dimmed twoslash lsp" style="background-color: #22272e; color: #adbac7"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #768390">// Removes &apos;readonly&apos; attributes from a type&apos;s properties</span></div><div class='line'><span style="color: #F47067">type</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50"><data-lsp lsp='type CreateMutable&lt;Type> = { -readonly [Property in keyof Type]: Type[Property]; }' >CreateMutable</data-lsp></span><span style="color: #ADBAC7">&lt;</span><span style="color: #F69D50"><data-lsp lsp='(type parameter) Type in type CreateMutable&lt;Type>' >Type</data-lsp></span><span style="color: #ADBAC7">&gt; </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> {</span></div><div class='line'><span style="color: #ADBAC7">    </span><span style="color: #F47067">-readonly</span><span style="color: #ADBAC7"> [</span><span style="color: #F69D50"><data-lsp lsp='(type parameter) Property' >Property</data-lsp></span><span style="color: #ADBAC7"> </span><span style="color: #F47067">in</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">keyof</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50"><data-lsp lsp='(type parameter) Type in type CreateMutable&lt;Type>' >Type</data-lsp></span><span style="color: #ADBAC7">]</span><span style="color: #F47067">:</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50"><data-lsp lsp='(type parameter) Type in type CreateMutable&lt;Type>' >Type</data-lsp></span><span style="color: #ADBAC7">[</span><span style="color: #F69D50"><data-lsp lsp='(type parameter) Property' >Property</data-lsp></span><span style="color: #ADBAC7">]</span></div><div class='line'><span style="color: #ADBAC7">}</span></div><div class='line'>&nbsp;</div><div class='line'><span style="color: #F47067">type</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50"><data-lsp lsp='type LockedAccount = {&#10;    readonly id: string;&#10;    readonly name: string;&#10;}' >LockedAccount</data-lsp></span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> {</span></div><div class='line'><span style="color: #ADBAC7">    </span><span style="color: #F47067">readonly</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50"><data-lsp lsp='(property) id: string' >id</data-lsp></span><span style="color: #F47067">:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">string</span></div><div class='line'><span style="color: #ADBAC7">    </span><span style="color: #F47067">readonly</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50"><data-lsp lsp='(property) name: string' >name</data-lsp></span><span style="color: #F47067">:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">string</span></div><div class='line'><span style="color: #ADBAC7">}</span></div><div class='line'>&nbsp;</div><div class='line'><span style="color: #F47067">type</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50"><data-lsp lsp='type UnlockedAccount = {&#10;    id: string;&#10;    name: string;&#10;}' >UnlockedAccount</data-lsp></span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50"><data-lsp lsp='type CreateMutable&lt;Type> = { -readonly [Property in keyof Type]: Type[Property]; }' >CreateMutable</data-lsp></span><span style="color: #ADBAC7">&lt;</span><span style="color: #F69D50"><data-lsp lsp='type LockedAccount = {&#10;    readonly id: string;&#10;    readonly name: string;&#10;}' >LockedAccount</data-lsp></span><span style="color: #ADBAC7">&gt;</span></div></code></div></pre>
<pre class="shiki github-light twoslash lsp" style="background-color: #fff; color: #24292e"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #6A737D">// Removes &apos;readonly&apos; attributes from a type&apos;s properties</span></div><div class='line'><span style="color: #D73A49">type</span><span style="color: #24292E"> </span><span style="color: #6F42C1"><data-lsp lsp='type CreateMutable&lt;Type> = { -readonly [Property in keyof Type]: Type[Property]; }' >CreateMutable</data-lsp></span><span style="color: #24292E">&lt;</span><span style="color: #6F42C1"><data-lsp lsp='(type parameter) Type in type CreateMutable&lt;Type>' >Type</data-lsp></span><span style="color: #24292E">&gt; </span><span style="color: #D73A49">=</span><span style="color: #24292E"> {</span></div><div class='line'><span style="color: #24292E">    </span><span style="color: #D73A49">-readonly</span><span style="color: #24292E"> [</span><span style="color: #6F42C1"><data-lsp lsp='(type parameter) Property' >Property</data-lsp></span><span style="color: #24292E"> </span><span style="color: #D73A49">in</span><span style="color: #24292E"> </span><span style="color: #D73A49">keyof</span><span style="color: #24292E"> </span><span style="color: #6F42C1"><data-lsp lsp='(type parameter) Type in type CreateMutable&lt;Type>' >Type</data-lsp></span><span style="color: #24292E">]</span><span style="color: #D73A49">:</span><span style="color: #24292E"> </span><span style="color: #6F42C1"><data-lsp lsp='(type parameter) Type in type CreateMutable&lt;Type>' >Type</data-lsp></span><span style="color: #24292E">[</span><span style="color: #6F42C1"><data-lsp lsp='(type parameter) Property' >Property</data-lsp></span><span style="color: #24292E">]</span></div><div class='line'><span style="color: #24292E">}</span></div><div class='line'>&nbsp;</div><div class='line'><span style="color: #D73A49">type</span><span style="color: #24292E"> </span><span style="color: #6F42C1"><data-lsp lsp='type LockedAccount = {&#10;    readonly id: string;&#10;    readonly name: string;&#10;}' >LockedAccount</data-lsp></span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> {</span></div><div class='line'><span style="color: #24292E">    </span><span style="color: #D73A49">readonly</span><span style="color: #24292E"> </span><span style="color: #E36209"><data-lsp lsp='(property) id: string' >id</data-lsp></span><span style="color: #D73A49">:</span><span style="color: #24292E"> </span><span style="color: #005CC5">string</span></div><div class='line'><span style="color: #24292E">    </span><span style="color: #D73A49">readonly</span><span style="color: #24292E"> </span><span style="color: #E36209"><data-lsp lsp='(property) name: string' >name</data-lsp></span><span style="color: #D73A49">:</span><span style="color: #24292E"> </span><span style="color: #005CC5">string</span></div><div class='line'><span style="color: #24292E">}</span></div><div class='line'>&nbsp;</div><div class='line'><span style="color: #D73A49">type</span><span style="color: #24292E"> </span><span style="color: #6F42C1"><data-lsp lsp='type UnlockedAccount = {&#10;    id: string;&#10;    name: string;&#10;}' >UnlockedAccount</data-lsp></span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #6F42C1"><data-lsp lsp='type CreateMutable&lt;Type> = { -readonly [Property in keyof Type]: Type[Property]; }' >CreateMutable</data-lsp></span><span style="color: #24292E">&lt;</span><span style="color: #6F42C1"><data-lsp lsp='type LockedAccount = {&#10;    readonly id: string;&#10;    readonly name: string;&#10;}' >LockedAccount</data-lsp></span><span style="color: #24292E">&gt;</span></div></code></div></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>Pretty neat, right? To some extent, anything your editor can show you about code, Twoslash can show. For example, here is the real auto-complete for a VitePress config:</p>
<div class="language-ts vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki github-dark-dimmed twoslash lsp" style="background-color: #22272e; color: #adbac7"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #F47067">import</span><span style="color: #ADBAC7"> { <data-lsp lsp='(alias) function defineConfig(config: UserConfig&lt;DefaultTheme.Config>): UserConfig&lt;DefaultTheme.Config>&#10;import defineConfig' >defineConfig</data-lsp> } </span><span style="color: #F47067">from</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&apos;vitepress&apos;</span></div><div class='line'>&nbsp;</div><div class='line'><span style="color: #F47067">export</span><span style="color: #F69D50"> </span><span style="color: #F47067">default</span><span style="color: #F69D50"> </span><span style="color: #DCBDFB"><data-lsp lsp='(alias) defineConfig(config: UserConfig&lt;DefaultTheme.Config>): UserConfig&lt;DefaultTheme.Config>&#10;import defineConfig' >defineConfig</data-lsp></span><span style="color: #F69D50">({</span></div><div class='line'><span style="color: #F69D50">    </span><span style="color: #ADBAC7"><data-lsp lsp='(property) ti: any' >ti</data-lsp></span><span style="color: #F69D50">,</span></div><div class='meta-line'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class='inline-completions'><ul class='dropdown'><li class=''><span><span class='result-found'>ti</span>tle</span></li><li class=''><span><span class='result-found'>ti</span>tleTemplate</span></li></ul></span></div><div class='line'><span style="color: #F69D50">})</span></div></code></div></pre>
<pre class="shiki github-light twoslash lsp" style="background-color: #fff; color: #24292e"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #D73A49">import</span><span style="color: #24292E"> { <data-lsp lsp='(alias) function defineConfig(config: UserConfig&lt;DefaultTheme.Config>): UserConfig&lt;DefaultTheme.Config>&#10;import defineConfig' >defineConfig</data-lsp> } </span><span style="color: #D73A49">from</span><span style="color: #24292E"> </span><span style="color: #032F62">&apos;vitepress&apos;</span></div><div class='line'>&nbsp;</div><div class='line'><span style="color: #D73A49">export</span><span style="color: #24292E"> </span><span style="color: #D73A49">default</span><span style="color: #24292E"> </span><span style="color: #6F42C1"><data-lsp lsp='(alias) defineConfig(config: UserConfig&lt;DefaultTheme.Config>): UserConfig&lt;DefaultTheme.Config>&#10;import defineConfig' >defineConfig</data-lsp></span><span style="color: #24292E">({</span></div><div class='line'><span style="color: #24292E">    <data-lsp lsp='(property) ti: any' >ti</data-lsp>,</span></div><div class='meta-line'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class='inline-completions'><ul class='dropdown'><li class=''><span><span class='result-found'>ti</span>tle</span></li><li class=''><span><span class='result-found'>ti</span>tleTemplate</span></li></ul></span></div><div class='line'><span style="color: #24292E">})</span></div></code></div></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>The name Twoslash refers to specially formatted comments (e.g. <code>// ^?</code>) which can be used to set up your environment, like compiler flags or separate input files. It couldn't be easier to set up and start creating incredible code examples!</p>
<h2 id="install" tabindex="-1">Install <a class="header-anchor" href="#install" aria-label="Permalink to &quot;Install&quot;">&ZeroWidthSpace;</a></h2>
<p>Install <code>@andatoshiki/vitepress-plugin-shiki-twoslash</code> (requires <code>vitepress@&gt;=1.0.0-alpha.61</code>).</p>
<div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-8c9kv" id="tab-M1ru4zh" checked="checked"><label for="tab-M1ru4zh">pnpm</label><input type="radio" name="group-8c9kv" id="tab-aByCiYO" ><label for="tab-aByCiYO">npm</label><input type="radio" name="group-8c9kv" id="tab-G_UYEOj" ><label for="tab-G_UYEOj">yarn</label></div><div class="blocks">
<div class="language-bash vp-adaptive-theme active line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">pnpm</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">add</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">@andatoshiki/vitepress-plugin-shiki-twoslash</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">pnpm</span><span style="color: #24292E"> </span><span style="color: #032F62">add</span><span style="color: #24292E"> </span><span style="color: #032F62">@andatoshiki/vitepress-plugin-shiki-twoslash</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="language-bash vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">npm</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">i</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">@andatoshiki/vitepress-plugin-shiki-twoslash</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">npm</span><span style="color: #24292E"> </span><span style="color: #032F62">i</span><span style="color: #24292E"> </span><span style="color: #032F62">@andatoshiki/vitepress-plugin-shiki-twoslash</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="language-bash vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">yarn</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">add</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">@andatoshiki/vitepress-plugin-shiki-twoslash</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">yarn</span><span style="color: #24292E"> </span><span style="color: #032F62">add</span><span style="color: #24292E"> </span><span style="color: #032F62">@andatoshiki/vitepress-plugin-shiki-twoslash</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div></div></div>
<div class="warning custom-block"><p class="custom-block-title">WARNING</p>
<p>Until <code>shiki-twoslash</code> uses the same version of <code>shiki</code> as VitePress, you must override the following packages' <code>shiki</code> versions for syntax highlighting to look the same.</p>
<div class="language-json vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">json</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">{</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #8DDB8C">&quot;pnpm&quot;</span><span style="color: #ADBAC7">: {</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #8DDB8C">&quot;overrides&quot;</span><span style="color: #ADBAC7">: {</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #8DDB8C">&quot;remark-shiki-twoslash&gt;shiki&quot;</span><span style="color: #ADBAC7">: </span><span style="color: #96D0FF">&quot;^0.14.1&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #8DDB8C">&quot;shiki-twoslash&gt;shiki&quot;</span><span style="color: #ADBAC7">: </span><span style="color: #96D0FF">&quot;^0.14.1&quot;</span></span>
<span class="line"><span style="color: #ADBAC7">        }</span></span>
<span class="line"><span style="color: #ADBAC7">    }</span></span>
<span class="line"><span style="color: #ADBAC7">}</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">{</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">&quot;pnpm&quot;</span><span style="color: #24292E">: {</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #005CC5">&quot;overrides&quot;</span><span style="color: #24292E">: {</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">&quot;remark-shiki-twoslash&gt;shiki&quot;</span><span style="color: #24292E">: </span><span style="color: #032F62">&quot;^0.14.1&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">&quot;shiki-twoslash&gt;shiki&quot;</span><span style="color: #24292E">: </span><span style="color: #032F62">&quot;^0.14.1&quot;</span></span>
<span class="line"><span style="color: #24292E">        }</span></span>
<span class="line"><span style="color: #24292E">    }</span></span>
<span class="line"><span style="color: #24292E">}</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br></div></div><p>Tracked in an upstream issue: <a href="https://github.com/shikijs/twoslash/issues/180" target="_blank" rel="noreferrer">https://github.com/shikijs/twoslash/issues/180</a></p>
</div>
<h2 id="configure" tabindex="-1">Configure <a class="header-anchor" href="#configure" aria-label="Permalink to &quot;Configure&quot;">&ZeroWidthSpace;</a></h2>
<p>First, wrap your VitePress config file with the <code>withTwoslash</code> wrapper.</p>
<div class="language-ts vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki github-dark-dimmed twoslash lsp" style="background-color: #22272e; color: #adbac7"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #768390">// .vitepress/config.[ext]</span></div><div class='line'><span style="color: #F47067">import</span><span style="color: #ADBAC7"> { <data-lsp lsp='(alias) function defineConfig(config: UserConfig&lt;DefaultTheme.Config>): UserConfig&lt;DefaultTheme.Config>&#10;import defineConfig' >defineConfig</data-lsp> } </span><span style="color: #F47067">from</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&apos;vitepress&apos;</span></div><div class='line'><span style="color: #F47067">import</span><span style="color: #ADBAC7"> { <data-lsp lsp='(alias) function withTwoslash(config: UserConfig&lt;DefaultTheme.Config>): Promise&lt;UserConfig&lt;DefaultTheme.Config>>&#10;import withTwoslash' >withTwoslash</data-lsp> } </span><span style="color: #F47067">from</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&apos;@andatoshiki/vitepress-plugin-shiki-twoslash&apos;</span></div><div class='line'>&nbsp;</div><div class='line'><span style="color: #F47067">export</span><span style="color: #F69D50"> </span><span style="color: #F47067">default</span><span style="color: #F69D50"> </span><span style="color: #DCBDFB"><data-lsp lsp='(alias) withTwoslash(config: UserConfig&lt;DefaultTheme.Config>): Promise&lt;UserConfig&lt;DefaultTheme.Config>>&#10;import withTwoslash' >withTwoslash</data-lsp></span><span style="color: #F69D50">(</span></div><div class='line'><span style="color: #F69D50">    </span><span style="color: #DCBDFB"><data-lsp lsp='(alias) defineConfig(config: UserConfig&lt;DefaultTheme.Config>): UserConfig&lt;DefaultTheme.Config>&#10;import defineConfig' >defineConfig</data-lsp></span><span style="color: #F69D50">({</span></div><div class='line'><span style="color: #F69D50">        </span><span style="color: #768390">// Your VitePress config</span></div><div class='line'><span style="color: #F69D50">    })</span></div><div class='line'><span style="color: #F69D50">)</span></div></code></div></pre>
<pre class="shiki github-light twoslash lsp" style="background-color: #fff; color: #24292e"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #6A737D">// .vitepress/config.[ext]</span></div><div class='line'><span style="color: #D73A49">import</span><span style="color: #24292E"> { <data-lsp lsp='(alias) function defineConfig(config: UserConfig&lt;DefaultTheme.Config>): UserConfig&lt;DefaultTheme.Config>&#10;import defineConfig' >defineConfig</data-lsp> } </span><span style="color: #D73A49">from</span><span style="color: #24292E"> </span><span style="color: #032F62">&apos;vitepress&apos;</span></div><div class='line'><span style="color: #D73A49">import</span><span style="color: #24292E"> { <data-lsp lsp='(alias) function withTwoslash(config: UserConfig&lt;DefaultTheme.Config>): Promise&lt;UserConfig&lt;DefaultTheme.Config>>&#10;import withTwoslash' >withTwoslash</data-lsp> } </span><span style="color: #D73A49">from</span><span style="color: #24292E"> </span><span style="color: #032F62">&apos;@andatoshiki/vitepress-plugin-shiki-twoslash&apos;</span></div><div class='line'>&nbsp;</div><div class='line'><span style="color: #D73A49">export</span><span style="color: #24292E"> </span><span style="color: #D73A49">default</span><span style="color: #24292E"> </span><span style="color: #6F42C1"><data-lsp lsp='(alias) withTwoslash(config: UserConfig&lt;DefaultTheme.Config>): Promise&lt;UserConfig&lt;DefaultTheme.Config>>&#10;import withTwoslash' >withTwoslash</data-lsp></span><span style="color: #24292E">(</span></div><div class='line'><span style="color: #24292E">    </span><span style="color: #6F42C1"><data-lsp lsp='(alias) defineConfig(config: UserConfig&lt;DefaultTheme.Config>): UserConfig&lt;DefaultTheme.Config>&#10;import defineConfig' >defineConfig</data-lsp></span><span style="color: #24292E">({</span></div><div class='line'><span style="color: #24292E">        </span><span style="color: #6A737D">// Your VitePress config</span></div><div class='line'><span style="color: #24292E">    })</span></div><div class='line'><span style="color: #24292E">)</span></div></code></div></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>Then, import <code>@andatoshiki/vitepress-plugin-shiki-twoslash/styles.css</code> into your theme.</p>
<div class="language-ts vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki github-dark-dimmed twoslash lsp" style="background-color: #22272e; color: #adbac7"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #768390">// .vitepress/theme/index.ts</span></div><div class='line'><span style="color: #F47067">import</span><span style="color: #ADBAC7"> <data-lsp lsp='(alias) const defaultTheme: {&#10;    Layout: DefineComponent;&#10;    enhanceApp: (ctx: EnhanceAppContext) => void;&#10;}&#10;import defaultTheme' >defaultTheme</data-lsp> </span><span style="color: #F47067">from</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&apos;vitepress/theme&apos;</span></div><div class='line'><span style="color: #F47067">import</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&apos;@andatoshiki/vitepress-plugin-shiki-twoslash/styles.css&apos;</span></div><div class='line'>&nbsp;</div><div class='line'><span style="color: #F47067">export</span><span style="color: #F69D50"> </span><span style="color: #F47067">default</span><span style="color: #F69D50"> </span><span style="color: #ADBAC7"><data-lsp lsp='(alias) const defaultTheme: {&#10;    Layout: DefineComponent;&#10;    enhanceApp: (ctx: EnhanceAppContext) => void;&#10;}&#10;import defaultTheme' >defaultTheme</data-lsp></span></div></code></div></pre>
<pre class="shiki github-light twoslash lsp" style="background-color: #fff; color: #24292e"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #6A737D">// .vitepress/theme/index.ts</span></div><div class='line'><span style="color: #D73A49">import</span><span style="color: #24292E"> <data-lsp lsp='(alias) const defaultTheme: {&#10;    Layout: DefineComponent;&#10;    enhanceApp: (ctx: EnhanceAppContext) => void;&#10;}&#10;import defaultTheme' >defaultTheme</data-lsp> </span><span style="color: #D73A49">from</span><span style="color: #24292E"> </span><span style="color: #032F62">&apos;vitepress/theme&apos;</span></div><div class='line'><span style="color: #D73A49">import</span><span style="color: #24292E"> </span><span style="color: #032F62">&apos;@andatoshiki/vitepress-plugin-shiki-twoslash/styles.css&apos;</span></div><div class='line'>&nbsp;</div><div class='line'><span style="color: #D73A49">export</span><span style="color: #24292E"> </span><span style="color: #D73A49">default</span><span style="color: #24292E"> <data-lsp lsp='(alias) const defaultTheme: {&#10;    Layout: DefineComponent;&#10;    enhanceApp: (ctx: EnhanceAppContext) => void;&#10;}&#10;import defaultTheme' >defaultTheme</data-lsp></span></div></code></div></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="tip custom-block"><p class="custom-block-title">TIP</p>
<p>You can <a href="./config/reference.html">configure VitePress Twoslash</a> using the <code>twoslash</code> property added to <code>defineConfig</code>.</p>
</div>
<h2 id="add-twoslash" tabindex="-1">Add Twoslash <a class="header-anchor" href="#add-twoslash" aria-label="Permalink to &quot;Add Twoslash&quot;">&ZeroWidthSpace;</a></h2>
<p>Finally, add the <code>twoslash</code> attribute to markdown fenced code blocks.</p>
<div class="language-md vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">md</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">```ts twoslash</span></span>
<span class="line"><span style="color: #768390">// Removes &#39;readonly&#39; attributes from a type&#39;s properties</span></span>
<span class="line"><span style="color: #F47067">type</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50">CreateMutable</span><span style="color: #ADBAC7">&lt;</span><span style="color: #F69D50">Type</span><span style="color: #ADBAC7">&gt; </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> {</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">-readonly</span><span style="color: #ADBAC7"> [</span><span style="color: #F69D50">Property</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">in</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">keyof</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50">Type</span><span style="color: #ADBAC7">]</span><span style="color: #F47067">:</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50">Type</span><span style="color: #ADBAC7">[</span><span style="color: #F69D50">Property</span><span style="color: #ADBAC7">]</span></span>
<span class="line"><span style="color: #ADBAC7">}</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F47067">type</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50">LockedAccount</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> {</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">readonly</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50">id</span><span style="color: #F47067">:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">string</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">readonly</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50">name</span><span style="color: #F47067">:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">string</span></span>
<span class="line"><span style="color: #ADBAC7">}</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F47067">type</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50">UnlockedAccount</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50">CreateMutable</span><span style="color: #ADBAC7">&lt;</span><span style="color: #F69D50">LockedAccount</span><span style="color: #ADBAC7">&gt;</span></span>
<span class="line"><span style="color: #768390">//   ^?</span></span>
<span class="line"><span style="color: #ADBAC7">```</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">```ts twoslash</span></span>
<span class="line"><span style="color: #6A737D">// Removes &#39;readonly&#39; attributes from a type&#39;s properties</span></span>
<span class="line"><span style="color: #D73A49">type</span><span style="color: #24292E"> </span><span style="color: #6F42C1">CreateMutable</span><span style="color: #24292E">&lt;</span><span style="color: #6F42C1">Type</span><span style="color: #24292E">&gt; </span><span style="color: #D73A49">=</span><span style="color: #24292E"> {</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">-readonly</span><span style="color: #24292E"> [</span><span style="color: #6F42C1">Property</span><span style="color: #24292E"> </span><span style="color: #D73A49">in</span><span style="color: #24292E"> </span><span style="color: #D73A49">keyof</span><span style="color: #24292E"> </span><span style="color: #6F42C1">Type</span><span style="color: #24292E">]</span><span style="color: #D73A49">:</span><span style="color: #24292E"> </span><span style="color: #6F42C1">Type</span><span style="color: #24292E">[</span><span style="color: #6F42C1">Property</span><span style="color: #24292E">]</span></span>
<span class="line"><span style="color: #24292E">}</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D73A49">type</span><span style="color: #24292E"> </span><span style="color: #6F42C1">LockedAccount</span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> {</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">readonly</span><span style="color: #24292E"> </span><span style="color: #E36209">id</span><span style="color: #D73A49">:</span><span style="color: #24292E"> </span><span style="color: #005CC5">string</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">readonly</span><span style="color: #24292E"> </span><span style="color: #E36209">name</span><span style="color: #D73A49">:</span><span style="color: #24292E"> </span><span style="color: #005CC5">string</span></span>
<span class="line"><span style="color: #24292E">}</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D73A49">type</span><span style="color: #24292E"> </span><span style="color: #6F42C1">UnlockedAccount</span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #6F42C1">CreateMutable</span><span style="color: #24292E">&lt;</span><span style="color: #6F42C1">LockedAccount</span><span style="color: #24292E">&gt;</span></span>
<span class="line"><span style="color: #6A737D">//   ^?</span></span>
<span class="line"><span style="color: #24292E">```</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br></div></div><p>And your code blocks will be twoslashified!</p>
<div class="language-ts vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki github-dark-dimmed twoslash lsp" style="background-color: #22272e; color: #adbac7"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #768390">// Removes &apos;readonly&apos; attributes from a type&apos;s properties</span></div><div class='line'><span style="color: #F47067">type</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50"><data-lsp lsp='type CreateMutable&lt;Type> = { -readonly [Property in keyof Type]: Type[Property]; }' >CreateMutable</data-lsp></span><span style="color: #ADBAC7">&lt;</span><span style="color: #F69D50"><data-lsp lsp='(type parameter) Type in type CreateMutable&lt;Type>' >Type</data-lsp></span><span style="color: #ADBAC7">&gt; </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> {</span></div><div class='line'><span style="color: #ADBAC7">    </span><span style="color: #F47067">-readonly</span><span style="color: #ADBAC7"> [</span><span style="color: #F69D50"><data-lsp lsp='(type parameter) Property' >Property</data-lsp></span><span style="color: #ADBAC7"> </span><span style="color: #F47067">in</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">keyof</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50"><data-lsp lsp='(type parameter) Type in type CreateMutable&lt;Type>' >Type</data-lsp></span><span style="color: #ADBAC7">]</span><span style="color: #F47067">:</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50"><data-lsp lsp='(type parameter) Type in type CreateMutable&lt;Type>' >Type</data-lsp></span><span style="color: #ADBAC7">[</span><span style="color: #F69D50"><data-lsp lsp='(type parameter) Property' >Property</data-lsp></span><span style="color: #ADBAC7">]</span></div><div class='line'><span style="color: #ADBAC7">}</span></div><div class='line'>&nbsp;</div><div class='line'><span style="color: #F47067">type</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50"><data-lsp lsp='type LockedAccount = {&#10;    readonly id: string;&#10;    readonly name: string;&#10;}' >LockedAccount</data-lsp></span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> {</span></div><div class='line'><span style="color: #ADBAC7">    </span><span style="color: #F47067">readonly</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50"><data-lsp lsp='(property) id: string' >id</data-lsp></span><span style="color: #F47067">:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">string</span></div><div class='line'><span style="color: #ADBAC7">    </span><span style="color: #F47067">readonly</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50"><data-lsp lsp='(property) name: string' >name</data-lsp></span><span style="color: #F47067">:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">string</span></div><div class='line'><span style="color: #ADBAC7">}</span></div><div class='line'>&nbsp;</div><div class='line'><span style="color: #F47067">type</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50"><data-lsp lsp='type UnlockedAccount = {&#10;    id: string;&#10;    name: string;&#10;}' style='border-bottom: solid 2px lightgrey;'>UnlockedAccount</data-lsp></span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50"><data-lsp lsp='type CreateMutable&lt;Type> = { -readonly [Property in keyof Type]: Type[Property]; }' >CreateMutable</data-lsp></span><span style="color: #ADBAC7">&lt;</span><span style="color: #F69D50"><data-lsp lsp='type LockedAccount = {&#10;    readonly id: string;&#10;    readonly name: string;&#10;}' >LockedAccount</data-lsp></span><span style="color: #ADBAC7">&gt;</span></div><div class='meta-line'><span class='popover-prefix'>           </span><span class='popover'><div class='arrow'></div>type UnlockedAccount = {
    id: string;
    name: string;
}</span></div></code></div></pre>
<pre class="shiki github-light twoslash lsp" style="background-color: #fff; color: #24292e"><div class="language-id">ts</div><div class='code-container'><code><div class='line'><span style="color: #6A737D">// Removes &apos;readonly&apos; attributes from a type&apos;s properties</span></div><div class='line'><span style="color: #D73A49">type</span><span style="color: #24292E"> </span><span style="color: #6F42C1"><data-lsp lsp='type CreateMutable&lt;Type> = { -readonly [Property in keyof Type]: Type[Property]; }' >CreateMutable</data-lsp></span><span style="color: #24292E">&lt;</span><span style="color: #6F42C1"><data-lsp lsp='(type parameter) Type in type CreateMutable&lt;Type>' >Type</data-lsp></span><span style="color: #24292E">&gt; </span><span style="color: #D73A49">=</span><span style="color: #24292E"> {</span></div><div class='line'><span style="color: #24292E">    </span><span style="color: #D73A49">-readonly</span><span style="color: #24292E"> [</span><span style="color: #6F42C1"><data-lsp lsp='(type parameter) Property' >Property</data-lsp></span><span style="color: #24292E"> </span><span style="color: #D73A49">in</span><span style="color: #24292E"> </span><span style="color: #D73A49">keyof</span><span style="color: #24292E"> </span><span style="color: #6F42C1"><data-lsp lsp='(type parameter) Type in type CreateMutable&lt;Type>' >Type</data-lsp></span><span style="color: #24292E">]</span><span style="color: #D73A49">:</span><span style="color: #24292E"> </span><span style="color: #6F42C1"><data-lsp lsp='(type parameter) Type in type CreateMutable&lt;Type>' >Type</data-lsp></span><span style="color: #24292E">[</span><span style="color: #6F42C1"><data-lsp lsp='(type parameter) Property' >Property</data-lsp></span><span style="color: #24292E">]</span></div><div class='line'><span style="color: #24292E">}</span></div><div class='line'>&nbsp;</div><div class='line'><span style="color: #D73A49">type</span><span style="color: #24292E"> </span><span style="color: #6F42C1"><data-lsp lsp='type LockedAccount = {&#10;    readonly id: string;&#10;    readonly name: string;&#10;}' >LockedAccount</data-lsp></span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> {</span></div><div class='line'><span style="color: #24292E">    </span><span style="color: #D73A49">readonly</span><span style="color: #24292E"> </span><span style="color: #E36209"><data-lsp lsp='(property) id: string' >id</data-lsp></span><span style="color: #D73A49">:</span><span style="color: #24292E"> </span><span style="color: #005CC5">string</span></div><div class='line'><span style="color: #24292E">    </span><span style="color: #D73A49">readonly</span><span style="color: #24292E"> </span><span style="color: #E36209"><data-lsp lsp='(property) name: string' >name</data-lsp></span><span style="color: #D73A49">:</span><span style="color: #24292E"> </span><span style="color: #005CC5">string</span></div><div class='line'><span style="color: #24292E">}</span></div><div class='line'>&nbsp;</div><div class='line'><span style="color: #D73A49">type</span><span style="color: #24292E"> </span><span style="color: #6F42C1"><data-lsp lsp='type UnlockedAccount = {&#10;    id: string;&#10;    name: string;&#10;}' style='border-bottom: solid 2px lightgrey;'>UnlockedAccount</data-lsp></span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #6F42C1"><data-lsp lsp='type CreateMutable&lt;Type> = { -readonly [Property in keyof Type]: Type[Property]; }' >CreateMutable</data-lsp></span><span style="color: #24292E">&lt;</span><span style="color: #6F42C1"><data-lsp lsp='type LockedAccount = {&#10;    readonly id: string;&#10;    readonly name: string;&#10;}' >LockedAccount</data-lsp></span><span style="color: #24292E">&gt;</span></div><div class='meta-line'><span class='popover-prefix'>           </span><span class='popover'><div class='arrow'></div>type UnlockedAccount = {
    id: string;
    name: string;
}</span></div></code></div></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br></div></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[謝辞 ]]></title>
            <link>https://note.toshiki.devdevelopment/aws/acknowledgement</link>
            <guid>https://note.toshiki.devdevelopment/aws/acknowledgement</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="謝辞" tabindex="-1">謝辞 <a class="header-anchor" href="#謝辞" aria-label="Permalink to &quot;謝辞&quot;">&ZeroWidthSpace;</a></h1>
<p>本原稿の執筆にあたり，以下の方々からの協力を得た．この場を借りて，感謝を表したい．</p>
<p><strong>2021 年バージョンの contributors</strong></p>
<ul>
<li>香取真知子氏 - ハンズオンプログラムの動作確認，文章校閲</li>
</ul>
<p><strong><a href="https://gitlab.com/tomomano/intro-aws" target="_blank" rel="noreferrer">2020 年バージョン</a>の contributors</strong></p>
<ul>
<li>
<p>勝俣敬寛氏 - Docker イメージの作成</p>
</li>
<li>
<p>香取真知子氏 - ハンズオンプログラムの動作確認</p>
</li>
<li>
<p><a href="https://gitlab.com/shuuji3" target="_blank" rel="noreferrer">@shuuji3</a> - MR <a href="https://gitlab.com/tomomano/intro-aws/-/merge_requests/15" target="_blank" rel="noreferrer">!15</a></p>
</li>
<li>
<p><a href="https://gitlab.com/takatama_jp" target="_blank" rel="noreferrer">@takatama_jp</a> - MR <a href="https://gitlab.com/tomomano/intro-aws/-/merge_requests/14" target="_blank" rel="noreferrer">!14</a></p>
</li>
</ul>
<p>本書の執筆には <a href="https://asciidoctor.org/" target="_blank" rel="noreferrer">Asciidoctor</a> を使用した．</p>
<p>また，本書はオープンソースの教科書として，すべての読者・ディベロッパーからのフィードバックを受け付けている． 誤植や記述の誤り，改善点など見つかったら，ぜひ <a href="https://github.com/andatoshiki/toshiki-notebookissues" target="_blank" rel="noreferrer">Issues</a> や <a href="https://github.com/andatoshiki/toshiki-notebookpulls" target="_blank" rel="noreferrer">Pull request</a> を投稿していただきたい．</p>
]]></description>
            <content:encoded><![CDATA[<h1 id="謝辞" tabindex="-1">謝辞 <a class="header-anchor" href="#謝辞" aria-label="Permalink to &quot;謝辞&quot;">&ZeroWidthSpace;</a></h1>
<p>本原稿の執筆にあたり，以下の方々からの協力を得た．この場を借りて，感謝を表したい．</p>
<p><strong>2021 年バージョンの contributors</strong></p>
<ul>
<li>香取真知子氏 - ハンズオンプログラムの動作確認，文章校閲</li>
</ul>
<p><strong><a href="https://gitlab.com/tomomano/intro-aws" target="_blank" rel="noreferrer">2020 年バージョン</a>の contributors</strong></p>
<ul>
<li>
<p>勝俣敬寛氏 - Docker イメージの作成</p>
</li>
<li>
<p>香取真知子氏 - ハンズオンプログラムの動作確認</p>
</li>
<li>
<p><a href="https://gitlab.com/shuuji3" target="_blank" rel="noreferrer">@shuuji3</a> - MR <a href="https://gitlab.com/tomomano/intro-aws/-/merge_requests/15" target="_blank" rel="noreferrer">!15</a></p>
</li>
<li>
<p><a href="https://gitlab.com/takatama_jp" target="_blank" rel="noreferrer">@takatama_jp</a> - MR <a href="https://gitlab.com/tomomano/intro-aws/-/merge_requests/14" target="_blank" rel="noreferrer">!14</a></p>
</li>
</ul>
<p>本書の執筆には <a href="https://asciidoctor.org/" target="_blank" rel="noreferrer">Asciidoctor</a> を使用した．</p>
<p>また，本書はオープンソースの教科書として，すべての読者・ディベロッパーからのフィードバックを受け付けている． 誤植や記述の誤り，改善点など見つかったら，ぜひ <a href="https://github.com/andatoshiki/toshiki-notebookissues" target="_blank" rel="noreferrer">Issues</a> や <a href="https://github.com/andatoshiki/toshiki-notebookpulls" target="_blank" rel="noreferrer">Pull request</a> を投稿していただきたい．</p>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Appendix: 環境構築 ]]></title>
            <link>https://note.toshiki.devdevelopment/aws/appendix</link>
            <guid>https://note.toshiki.devdevelopment/aws/appendix</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="appendix-環境構築" tabindex="-1">Appendix: 環境構築 <a class="header-anchor" href="#appendix-環境構築" aria-label="Permalink to &quot;Appendix: 環境構築&quot;">&ZeroWidthSpace;</a></h1>
<p>本書を読み進めるにあたって，ハンズオンのプログラムを実行するための環境を自分のローカルマシンにセットアップしなければならない． ここでは， AWS やコマンドラインの初心者を想定して，本章で必要なソフトウェアやライブラリのインストールなどを簡単に解説する． 以下に簡単な目次を示そう． 既に環境構築が済んでいる場合は適宜読み飛ばしていただき，関係のある箇所のみ目を通せば良い．</p>
<ul>
<li>
<p>AWS アカウントの取得 (<a href="#sec:create_aws_account">AWS アカウントの取得</a>)</p>
</li>
<li>
<p>AWS シークレットキーの作成 (<a href="#aws_secrets">AWS のシークレットキーの作成</a>)</p>
</li>
<li>
<p>AWS CLI のインストール (<a href="#aws_cli_install">AWS CLI のインストール</a>)</p>
</li>
<li>
<p>AWS CDK のインストール (<a href="#aws_cdk_install">AWS CDK のインストール</a>)</p>
</li>
<li>
<p>WSL のインストール (<a href="#sec:install_wsl">WSL のインストール</a>)</p>
</li>
<li>
<p>Docker のインストール (<a href="#sec:install_docker">Docker のインストール</a>)</p>
</li>
<li>
<p>Python venv クイックガイド (<a href="#venv_quick_guide">Python クイックガイド</a>)</p>
</li>
<li>
<p>ハンズオン実行用の Docker image の使い方 (<a href="#sec_handson_docker">ハンズオン実行用の Docker image の使い方</a>)</p>
</li>
</ul>
<p>使用する OS は Linux/Mac/Windows のどれを用いても構わない． Windows のユーザーは， Windows Subsytem for Linux (WSL) を使用することを想定している (<a href="#sec:install_wsl">WSL のインストール</a>)．</p>
<p>また，本書のハンズオンを実行するための <a href="https://hub.docker.com/repository/docker/tomomano/labc" target="_blank" rel="noreferrer">Docker イメージ</a> を提供している． これを用いると， AWS CLI/CDK や Python の設定などをスキップできるので， Docker の使用方法を知っている読者には便利だろう．</p>
<h2 id="aws-アカウントの取得" tabindex="-1">AWS アカウントの取得 <a class="header-anchor" href="#aws-アカウントの取得" aria-label="Permalink to &quot;AWS アカウントの取得&quot;">&ZeroWidthSpace;</a></h2>
<p>本書で提供するハンズオンを実際に自分で試すには，読者自身で AWS のアカウントの作成をする必要がある． 詳しいアカウントの作成の手順は <a href="https://aws.amazon.com/jp/register-flow/" target="_blank" rel="noreferrer">公式のドキュメンテーション</a> に書かれているので，そちらも参照していただきたい． 以下の手順に従ってアカウントの作成を行う．</p>
<p>まず，ウェブブラウザから <a href="https://aws.amazon.com/console/" target="_blank" rel="noreferrer">AWS コンソール</a> にアクセスし，右上の <code>Create an AWS Account</code> をクリックする (<a href="#fig:aws-signup-1">figure_title</a> で実線で囲った部分)．</p>
<p><img src="./assets/signup-1.png" alt="サインアップ (1): AWS コンソールにアクセス"></p>
<p>次に，遷移した先のページでメールアドレスとパスワードなどの登録を行う (<a href="#fig:aws-signup-3">figure_title</a>)．</p>
<p><img src="./assets/signup-3.png" alt="サインアップ (2): メールアドレス・パスワードなどの登録．"></p>
<p>続いて，住所や電話番号などを訊かれるので，すべて入力しよう (<a href="#fig:aws-signup-4">figure_title</a>)．</p>
<p><img src="./assets/signup-4.png" alt="サインアップ (3): 住所・電話番号の入力"></p>
<p>次に，クレジットカードの情報の登録を求められる (<a href="#fig:aws-signup-5">figure_title</a>)． 個人で AWS を利用する場合は，利用料金の請求はクレジットカードを経由して行われる． クレジットカードの登録なしには AWS を使い始めることはできないことに注意．</p>
<p><img src="./assets/signup-5.png" alt="サインアップ (4): クレジットカードの登録"></p>
<p>次の画面では，携帯電話の SMS またはボイスメッセージを利用した本人確認が求められる (<a href="#fig:aws-signup-6">figure_title</a>)． 希望の認証方法を選択し，自分の携帯電話番号を入力しよう．</p>
<p><img src="./assets/signup-6.png" alt="サインアップ (5): 携帯電話による本人確認"></p>
<p>無事に本人確認が完了すると，最後にサポートプランの選択を求められる (<a href="#fig:aws-signup-8">figure_title</a>)． 無料の Basic support を選択しておけば問題ない．</p>
<p><img src="./assets/signup-8.png" alt="サインアップ (6): サポートプランの選択"></p>
<p>以上のステップにより，アカウントの作成が完了する (<a href="#fig:aws-signup-9">figure_title</a>)． 早速ログインをして， AWS コンソールにアクセスできるか確認しておこう．</p>
<p><img src="./assets/signup-9.png" alt="サインアップ (7): アカウントの作成が完了した"></p>
<h2 id="aws-のシークレットキーの作成" tabindex="-1">AWS のシークレットキーの作成 <a class="header-anchor" href="#aws-のシークレットキーの作成" aria-label="Permalink to &quot;AWS のシークレットキーの作成&quot;">&ZeroWidthSpace;</a></h2>
<p>AWS シークレットキーとは， AWS CLI や AWS CDK から AWS の API を操作するときに，ユーザー認証を行うための鍵のことである． AWS CLI/CDK を使うには，最初にシークレットキーを発行する必要がある． AWS シークレットキーの詳細は <a href="https://docs.aws.amazon.com/general/latest/gr/aws-sec-cred-types.html" target="_blank" rel="noreferrer">公式ドキュメンテーション &quot;Understanding and getting your AWS credentials&quot;</a> を参照．</p>
<ol>
<li>
<p>AWS コンソールにログインする．</p>
</li>
<li>
<p>画面右上のアカウント名をクリックし，表示されるプルダウンメニューから &quot;My Security Credentials&quot; を選択 (<a href="#fig:aws_secret_key_1">figure_title</a>)</p>
</li>
<li>
<p>&quot;Access keys for CLI, SDK, &amp; API access&quot; の下にある &quot;Create accesss key&quot; のボタンをクリックする (<a href="#fig:aws_secret_key_2">figure_title</a>)</p>
</li>
<li>
<p>表示された Access key ID, Secret access key を記録しておく (画面を閉じると二度と表示されない)．</p>
</li>
<li>
<p>鍵を忘れてしまった場合などは，同じ手順で再発行が可能である．</p>
</li>
<li>
<p>発行したシークレットキーは， <code>~/.aws/credentials</code> のファイルに書き込むか，環境変数に設定するなどして使う (詳しくは <a href="#aws_cli_install">AWS CLI のインストール</a>)．</p>
</li>
</ol>
<p><img src="./assets/aws_secret_key_1.png" alt="AWS シークレットキーの発行1"></p>
<p><img src="./assets/aws_secret_key_2.png" alt="AWS シークレットキーの発行2"></p>
<p><strong>AWS Educate Starter Account</strong> を用いている場合は，次の手順でシークレットキーを確認する．</p>
<ul>
<li>
<p>AWS Educate のコンソール画面から， <code>vocareum</code> のコンソールに移動する (<a href="#fig:vocareum_console">figure_title</a>)．</p>
</li>
<li>
<p><code>Account Details</code> をクリックし，続いて <code>AWS CLI: Show</code> をクリックする．</p>
</li>
<li>
<p><code>aws_access_key_id</code>, <code>aws_secret_access_key</code>, <code>aws_session_token</code> が表示される (<a href="#fig:vocareum_secret">figure_title</a>)． ここで表示された内容を <code>~/.aws/credentials</code> にコピーする (<a href="#aws_cli_install">AWS CLI のインストール</a> 参照)． <code>aws_session_token</code> の箇所も漏らさずコピーすること．</p>
</li>
<li>
<p>続いて， <code>~/.aws/config</code> というファイルを用意し，次の内容を書き込む． 現時点では AWS Starter Account は <code>us-east-1</code> リージョンでしか利用できないためである．</p>
</li>
</ul>
<div class="language-toml vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">toml</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">[</span><span style="color: #F69D50">default</span><span style="color: #ADBAC7">]</span></span>
<span class="line"><span style="color: #ADBAC7">    region = u</span><span style="color: #FF938A; font-style: italic">s-east-1</span></span>
<span class="line"><span style="color: #ADBAC7">    output = j</span><span style="color: #FF938A; font-style: italic">son</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">[</span><span style="color: #6F42C1">default</span><span style="color: #24292E">]</span></span>
<span class="line"><span style="color: #24292E">    region = u</span><span style="color: #B31D28; font-style: italic">s-east-1</span></span>
<span class="line"><span style="color: #24292E">    output = j</span><span style="color: #B31D28; font-style: italic">son</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><ul>
<li>上記の説明ではプロファイル名が <code>default</code> となっていたが，これは自分の好きな名前に変更してもよい． <code>default</code> 以外の名前を使用する場合は，コマンドを実行するときにプロファイル名を指定する必要がある (詳しくは <a href="#aws_cli_install">AWS CLI のインストール</a>)．</li>
</ul>
<p><img src="./assets/vocareum_console.png" alt="vocareum コンソール"></p>
<p><img src="./assets/vocareum_secret.png" alt="vocareum から AWS シークレットキーの発行"></p>
<h2 id="aws-cli-のインストール" tabindex="-1">AWS CLI のインストール <a class="header-anchor" href="#aws-cli-のインストール" aria-label="Permalink to &quot;AWS CLI のインストール&quot;">&ZeroWidthSpace;</a></h2>
<p>読者のために，執筆時点におけるインストールの手順 (Linux 向け) を簡単に記述する． 将来のバージョンでは変更される可能性があるので，常に <a href="https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html" target="_blank" rel="noreferrer">公式のドキュメンテーション</a> で最新の情報をチェックすることを忘れずに．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">curl</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-o</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;awscliv2.zip&quot;</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">unzip</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">awscliv2.zip</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">sudo</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">./aws/install</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">curl</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip&quot;</span><span style="color: #24292E"> </span><span style="color: #005CC5">-o</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;awscliv2.zip&quot;</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">unzip</span><span style="color: #24292E"> </span><span style="color: #032F62">awscliv2.zip</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">sudo</span><span style="color: #24292E"> </span><span style="color: #032F62">./aws/install</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><p>インストールできたか確認するため，次のコマンドを打ってバージョン情報が出力されることを確認する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--version</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">aws</span><span style="color: #24292E"> </span><span style="color: #005CC5">--version</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>インストールができたら，次のコマンドにより初期設定を行う (<a href="https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html" target="_blank" rel="noreferrer">参照</a>)．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">configure</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">aws</span><span style="color: #24292E"> </span><span style="color: #032F62">configure</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>コマンドを実行すると， <code>AWS Access Key ID</code>, <code>AWS Secret Access Key</code> を入力するよう指示される． シークレットキーの発行については <a href="#aws_secrets">AWS のシークレットキーの作成</a> を参照． コマンドは加えて，<code>Default region name</code> を訊いてくる． ここには自分の好きな地域 (例えば <code>ap-northeast-1</code> =東京リージョン) を指定すればよい． 最後の <code>Default output format</code> は <code>json</code> としておくとよい．</p>
<p>このコマンドを完了すると， <code>~/.aws/credentials</code> と <code>~/.aws/config</code>　という名前のファイルが生成されているはずである． 念のため， <code>cat</code> コマンドを使って中身を確認してみるとよい．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cat</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">~/.aws/credentials</span></span>
<span class="line"><span style="color: #ADBAC7">[default]</span></span>
<span class="line"><span style="color: #F69D50">aws_access_key_id</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">XXXXXXXXXXXXXXXXXX</span></span>
<span class="line"><span style="color: #F69D50">aws_secret_access_key</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">YYYYYYYYYYYYYYYYYYY</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cat</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">~/.aws/config</span></span>
<span class="line"><span style="color: #ADBAC7">[profile default]</span></span>
<span class="line"><span style="color: #F69D50">region</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ap-northeast-1</span></span>
<span class="line"><span style="color: #F69D50">output</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">json</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cat</span><span style="color: #24292E"> </span><span style="color: #032F62">~/.aws/credentials</span></span>
<span class="line"><span style="color: #24292E">[default]</span></span>
<span class="line"><span style="color: #6F42C1">aws_access_key_id</span><span style="color: #24292E"> </span><span style="color: #032F62">=</span><span style="color: #24292E"> </span><span style="color: #032F62">XXXXXXXXXXXXXXXXXX</span></span>
<span class="line"><span style="color: #6F42C1">aws_secret_access_key</span><span style="color: #24292E"> </span><span style="color: #032F62">=</span><span style="color: #24292E"> </span><span style="color: #032F62">YYYYYYYYYYYYYYYYYYY</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cat</span><span style="color: #24292E"> </span><span style="color: #032F62">~/.aws/config</span></span>
<span class="line"><span style="color: #24292E">[profile default]</span></span>
<span class="line"><span style="color: #6F42C1">region</span><span style="color: #24292E"> </span><span style="color: #032F62">=</span><span style="color: #24292E"> </span><span style="color: #032F62">ap-northeast-1</span></span>
<span class="line"><span style="color: #6F42C1">output</span><span style="color: #24292E"> </span><span style="color: #032F62">=</span><span style="color: #24292E"> </span><span style="color: #032F62">json</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br></div></div><p><code>~/.aws/credentials</code> には認証鍵の情報が， <code>~/.aws/config</code> には AWS CLI の設定が記録されている．</p>
<p>デフォルトでは， <code>[default]</code> という名前でプロファイルが保存される． いくつかのプロファイルを使い分けたければ， default の例に従って，たとえば <code>[myprofile]</code> などという名前でプロファイルを追加すればよい．</p>
<p>AWS CLI でコマンドを打つときに，プロファイルを使い分けるには，</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">s3</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ls</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--profile</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">myprofile</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">aws</span><span style="color: #24292E"> </span><span style="color: #032F62">s3</span><span style="color: #24292E"> </span><span style="color: #032F62">ls</span><span style="color: #24292E"> </span><span style="color: #005CC5">--profile</span><span style="color: #24292E"> </span><span style="color: #032F62">myprofile</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>のように， <code>--profile</code> というオプションをつけてコマンドを実行する．</p>
<p>いちいち <code>--profile</code> オプションをつけるのが面倒だと感じる場合は， <code>AWS_PROFILE</code> という環境変数を設定するとよい．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">export</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">AWS_PROFILE=myprofile</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">export</span><span style="color: #24292E"> </span><span style="color: #032F62">AWS_PROFILE=myprofile</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>あるいは，認証情報などを環境変数に設定するテクニックもある．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">export</span><span style="color: #ADBAC7"> AWS_ACCESS_KEY_ID</span><span style="color: #F47067">=</span><span style="color: #96D0FF">XXXXXX</span></span>
<span class="line"><span style="color: #F47067">export</span><span style="color: #ADBAC7"> AWS_SECRET_ACCESS_KEY</span><span style="color: #F47067">=</span><span style="color: #96D0FF">YYYYYY</span></span>
<span class="line"><span style="color: #F47067">export</span><span style="color: #ADBAC7"> AWS_DEFAULT_REGION</span><span style="color: #F47067">=</span><span style="color: #96D0FF">ap-northeast-1</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">export</span><span style="color: #24292E"> AWS_ACCESS_KEY_ID</span><span style="color: #D73A49">=</span><span style="color: #032F62">XXXXXX</span></span>
<span class="line"><span style="color: #D73A49">export</span><span style="color: #24292E"> AWS_SECRET_ACCESS_KEY</span><span style="color: #D73A49">=</span><span style="color: #032F62">YYYYYY</span></span>
<span class="line"><span style="color: #D73A49">export</span><span style="color: #24292E"> AWS_DEFAULT_REGION</span><span style="color: #D73A49">=</span><span style="color: #032F62">ap-northeast-1</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><p>これらの環境変数は， <code>~/.aws/credentials</code> よりも高い優先度をもつので，環境変数が設定されていればそちらの情報が使用される (<a href="https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html" target="_blank" rel="noreferrer">参照</a>)．</p>
<p><strong>AWS Educate Starter Account</strong> は <code>us-east-1</code> のリージョンのみ利用可能である (執筆時点での情報)． よって， AWS Educate Starter Account を使用している場合は， default region を <code>us-east-1</code> に設定する必要がある．</p>
<h2 id="aws-cdk-のインストール" tabindex="-1">AWS CDK のインストール <a class="header-anchor" href="#aws-cdk-のインストール" aria-label="Permalink to &quot;AWS CDK のインストール&quot;">&ZeroWidthSpace;</a></h2>
<p>読者のために，執筆時点におけるインストールの手順 (Linux 向け) を簡単に記述する． 将来のバージョンでは変更される可能性があるので，常に <a href="https://docs.aws.amazon.com/cdk/latest/guide/getting_started.html" target="_blank" rel="noreferrer">公式のドキュメンテーション</a> で最新の情報をチェックすることを忘れずに．</p>
<p>Node.js がインストールされていれば，基本的に次のコマンドを実行すればよい．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">sudo</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">npm</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">install</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-g</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws-cdk</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">sudo</span><span style="color: #24292E"> </span><span style="color: #032F62">npm</span><span style="color: #24292E"> </span><span style="color: #032F62">install</span><span style="color: #24292E"> </span><span style="color: #005CC5">-g</span><span style="color: #24292E"> </span><span style="color: #032F62">aws-cdk</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>本書のハンズオンは AWS CDK version 1.100.0 で開発した． CDK は開発途上のライブラリなので，将来的に API が変更される可能性がある． API の変更によりエラーが生じた場合は， version 1.100.0 を使用することを推奨する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">npm</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">install</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-g</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws-cdk@1.100</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">npm</span><span style="color: #24292E"> </span><span style="color: #032F62">install</span><span style="color: #24292E"> </span><span style="color: #005CC5">-g</span><span style="color: #24292E"> </span><span style="color: #032F62">aws-cdk@1.100</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>インストールできたか確認するため，次のコマンドを打って正しくバージョンが表示されることを確認する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cdk</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--version</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cdk</span><span style="color: #24292E"> </span><span style="color: #005CC5">--version</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>インストールができたら，次のコマンドにより AWS 側の初期設定を行う． これは一度実行すれば OK．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cdk</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">bootstrap</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cdk</span><span style="color: #24292E"> </span><span style="color: #032F62">bootstrap</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p><code>cdk bootstrap</code> を実行するときは，AWS の認証情報とリージョンが正しく設定されていることを確認する． デフォルトでは <code>~/.aws/config</code> にあるデフォルトのプロファイルが使用される． デフォルト以外のプロファイルを用いるときは <a href="#aws_cli_install">AWS CLI のインストール</a> で紹介したテクニックを使って切り替える．</p>
<p>AWS CDK の認証情報の設定は AWS CLI と基本的に同じである．詳しくは <a href="#aws_cli_install">AWS CLI のインストール</a> を参照．</p>
<h2 id="wsl-のインストール" tabindex="-1">WSL のインストール <a class="header-anchor" href="#wsl-のインストール" aria-label="Permalink to &quot;WSL のインストール&quot;">&ZeroWidthSpace;</a></h2>
<p>本書のハンズオンではコマンドラインから AWS CLI のコマンドを実行したり， Python で書かれたプログラムを実行する． コマンドは基本的に UNIX のターミナルを想定して書かれている． Linux や Mac のユーザーは OS に標準搭載されているターミナルを用いれば良い． Windows を利用している読者は， <a href="https://docs.microsoft.com/en-us/windows/wsl/" target="_blank" rel="noreferrer">Windows Subsystem for Linux (WSL)</a> を利用することで，仮想の Linux 環境を構築することを推奨する． <a href="https://www.cygwin.com/" target="_blank" rel="noreferrer">Cygwin</a> などの Linux 環境をエミュレートするほかのツールでも構わないが，本書のプログラムは WSL でのみ動作確認を行っている．</p>
<p>WSL とは， Windows の OS 上で Linux の仮想環境を起動するための， Microsoft 社が公式で提供しているソフトウェアである． Ubuntu など希望の Linux distribution が選択でき，基本的にすべての Linux 向けに作られたプログラム・ソフトウェアを使用することができる．</p>
<p>執筆時点では <a href="https://docs.microsoft.com/en-us/windows/wsl/compare-versions#whats-new-in-wsl-2" target="_blank" rel="noreferrer">WSL 2</a> が最新版として提供されているので，以下では WSL 2 のインストール手順を簡単に説明する． 細かな詳細などは， <a href="https://docs.microsoft.com/en-us/windows/wsl/install-win10" target="_blank" rel="noreferrer">公式ドキュメンテーション</a> を参照のこと．</p>
<p>前提として，使用される OS は Windows 10 (Pro または Home エディション) でなければならない． さらに，使用している Windows 10 のバージョンが WSL に対応するバージョンであるかを確認する． X64 のシステムでは Version 1903, Build 18362 以上でなければならない． バージョンが対応していない場合は、 Windows のアップデートを行う．</p>
<p>まず最初に， Administrator 権限で PowerShell を起動する (<a href="#fig:powershell">figure_title</a>)． 左下の Windows メニューの検索バーに <code>powershell</code> と入力すると， PowerShell のプログラムが見つかるはずである， これを右クリックし、 <code>Run as administrator</code> を選択し起動する．</p>
<p><img src="./assets/wsl/powershell.png" alt="管理者権限での PowerShell の起動"></p>
<p>PowerShell が起動したら、次のコマンドを実行する．</p>
<div class="language-powershell vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">powershell</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #6CB6FF">dism.exe</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">/</span><span style="color: #ADBAC7">online </span><span style="color: #F47067">/</span><span style="color: #6CB6FF">enable-feature</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">/</span><span style="color: #ADBAC7">featurename:Microsoft</span><span style="color: #F47067">-</span><span style="color: #ADBAC7">Windows</span><span style="color: #F47067">-</span><span style="color: #ADBAC7">Subsystem</span><span style="color: #F47067">-</span><span style="color: #ADBAC7">Linux </span><span style="color: #F47067">/</span><span style="color: #ADBAC7">all </span><span style="color: #F47067">/</span><span style="color: #ADBAC7">norestart</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #005CC5">dism.exe</span><span style="color: #24292E"> </span><span style="color: #D73A49">/</span><span style="color: #24292E">online </span><span style="color: #D73A49">/</span><span style="color: #005CC5">enable-feature</span><span style="color: #24292E"> </span><span style="color: #D73A49">/</span><span style="color: #24292E">featurename:Microsoft</span><span style="color: #D73A49">-</span><span style="color: #24292E">Windows</span><span style="color: #D73A49">-</span><span style="color: #24292E">Subsystem</span><span style="color: #D73A49">-</span><span style="color: #24292E">Linux </span><span style="color: #D73A49">/</span><span style="color: #24292E">all </span><span style="color: #D73A49">/</span><span style="color: #24292E">norestart</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>実行して、“The operation completed successfully.” と出力されるのを確認する． これで WSL が enable される．</p>
<p>次に，先ほどと同じ Administrator 権限で開いた PowerShell で次のコマンドを実行する。</p>
<div class="language-powershell vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">powershell</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #6CB6FF">dism.exe</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">/</span><span style="color: #ADBAC7">online </span><span style="color: #F47067">/</span><span style="color: #6CB6FF">enable-feature</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">/</span><span style="color: #ADBAC7">featurename:VirtualMachinePlatform </span><span style="color: #F47067">/</span><span style="color: #ADBAC7">all </span><span style="color: #F47067">/</span><span style="color: #ADBAC7">norestart</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #005CC5">dism.exe</span><span style="color: #24292E"> </span><span style="color: #D73A49">/</span><span style="color: #24292E">online </span><span style="color: #D73A49">/</span><span style="color: #005CC5">enable-feature</span><span style="color: #24292E"> </span><span style="color: #D73A49">/</span><span style="color: #24292E">featurename:VirtualMachinePlatform </span><span style="color: #D73A49">/</span><span style="color: #24292E">all </span><span style="color: #D73A49">/</span><span style="color: #24292E">norestart</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>実行して， “The operation completed successfully.” と出力されるのを確認する． これが確認出来たら、一度コンピュータを再起動する．</p>
<p>続いて， Linux kernel update package を次のリンクからダウンロードする． <a href="https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi" target="_blank" rel="noreferrer">https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi</a></p>
<p>ダウンロードしたファイルをダブルクリックして実行する． ダイアログに従ってインストールを完了させる．</p>
<p>そうしたら，再び PowerShell を開き次のコマンドを実行する。</p>
<div class="language-powershell vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">powershell</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">wsl </span><span style="color: #F47067">--</span><span style="color: #6CB6FF">set-default</span><span style="color: #F47067">-</span><span style="color: #ADBAC7">version </span><span style="color: #6CB6FF">2</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">wsl </span><span style="color: #D73A49">--</span><span style="color: #005CC5">set-default</span><span style="color: #D73A49">-</span><span style="color: #24292E">version </span><span style="color: #005CC5">2</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>最後に、自分の好みの Linux distribution をインストールする． ここでは Ubuntu 20.04 をインストールしよう．</p>
<p>Microsoft store のアプリを起動し，検索バーに <code>Ubuntu</code> と入力する． Ubuntu 20.04 LTS という項目が見つかるはずなので，それを開き， “Get” ボタンをクリックする (<a href="#fig:microsoft_store">figure_title</a>)． しばらく待つと， Ubuntu 20.04 のインストールが完了する．</p>
<p><img src="./assets/wsl/microsoft_store.png" alt="Microsoft store から Ubuntu 20.04 をインストール"></p>
<p>Ubuntu 20.04 を初回に起動すると，初期設定が自動で開始され，数分待つことになる． 初期設定が終わると，ユーザー名・パスワードを設定するようプロンプトが出るので，プロンプトに従い入力する．</p>
<p>これで WSL2 のインストールが完了した． 早速 WSL2 を起動してみよう． 左下の Windows メニューの検索バーに <code>Ubuntu</code> と入力すると， Ubuntu 20.04 のプログラムが見つかるはずである (<a href="#fig:ubuntu">figure_title</a>)． クリックして起動しよう．</p>
<p><img src="./assets/wsl/ubuntu2004.png" alt="Ubuntu 20.04 の起動"></p>
<p>すると，ターミナルの黒い画面が立ち上がるだろう (<a href="#fig:wsl_window">figure_title</a>)． <code>ls</code>, <code>top</code> などのコマンドを打ってみて， WSL がきちんと動作していることを確認しよう．</p>
<p><img src="./assets/wsl/wsl_window.png" alt="WSL の起動画面"></p>
<p>オプションとして， <a href="https://docs.microsoft.com/en-us/windows/terminal/get-started" target="_blank" rel="noreferrer">Windows Terminal</a> というマイクロソフトから提供されているツールを使うと，より快適に WSL を使用することができる． 興味のある読者はこちらのインストールも推奨する．</p>
<h2 id="docker-のインストール" tabindex="-1">Docker のインストール <a class="header-anchor" href="#docker-のインストール" aria-label="Permalink to &quot;Docker のインストール&quot;">&ZeroWidthSpace;</a></h2>
<p>Docker のインストールの方法は OS によって異なる．</p>
<p>Mac ユーザーは， Docker Desktop をインストールする． インストールの方法は， <a href="https://docs.docker.com/docker-for-mac/install/" target="_blank" rel="noreferrer">Docker のウェブサイト</a> から， Mac 版の Docker Desktop をダウンロードし，ダウンロードされたファイルをダブルクリックし， <code>Applications</code> のフォルダにドラッグするだけで良い． 詳細は <a href="https://docs.docker.com/docker-for-mac/install/" target="_blank" rel="noreferrer">公式ドキュメンテーション</a> を参照のこと．</p>
<p>Windows のユーザーは，Docker Desktop をインストールする． その際， WSL 2 が事前にインストールされていなければならない． 詳細は <a href="https://docs.docker.com/desktop/windows/install/" target="_blank" rel="noreferrer">公式ドキュメンテーション</a> を参照のこと． Docker Desktop をインストールすると， WSL からも <code>docker</code> コマンドが使用できるようになる．</p>
<p>Linux ユーザー (特に Ubuntu ユーザー) については，インストールの方法はいくつかのアプローチがある． <a href="https://docs.docker.com/engine/install/ubuntu/" target="_blank" rel="noreferrer">公式ドキュメンテーション</a> にいくつかのインストールの方法が示されているので，詳しい情報はそちらを参照いただきたい．</p>
<p>最も簡単な方法は， Docker が公式で提供しているインストールスクリプトを用いる方法である． この場合，次のコマンドを実行することで Docker がインストールされる．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">curl</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-fsSL</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">https://get.docker.com</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-o</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">get-docker.sh</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">sudo</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">sh</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">get-docker.sh</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">curl</span><span style="color: #24292E"> </span><span style="color: #005CC5">-fsSL</span><span style="color: #24292E"> </span><span style="color: #032F62">https://get.docker.com</span><span style="color: #24292E"> </span><span style="color: #005CC5">-o</span><span style="color: #24292E"> </span><span style="color: #032F62">get-docker.sh</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">sudo</span><span style="color: #24292E"> </span><span style="color: #032F62">sh</span><span style="color: #24292E"> </span><span style="color: #032F62">get-docker.sh</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>デフォルトのインストールでは， root ユーザーのみが <code>docker</code> コマンドを使用できる設定になっている． 従って，コマンドには毎回 <code>sudo</code> を付け加える必要がある． これが面倒だと感じる場合は，次のステップにより，使用するユーザーを <code>docker</code> というグループに追加する (詳細は <a href="https://docs.docker.com/engine/install/linux-postinstall/#manage-docker-as-a-non-root-user" target="_blank" rel="noreferrer">公式ドキュメンテーション &quot;Post-installation steps for Linux&quot;</a> を参照)．</p>
<p>まず最初に， <code>docker</code> という名前にグループを追加する． インストールによっては，既に <code>docker</code> グループが作られている場合もある．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">sudo</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">groupadd</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">docker</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">sudo</span><span style="color: #24292E"> </span><span style="color: #032F62">groupadd</span><span style="color: #24292E"> </span><span style="color: #032F62">docker</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>次に，現在使用しているユーザーを <code>docker</code> グループに加える．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">sudo</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">usermod</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-aG</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">docker</span><span style="color: #ADBAC7"> $USER</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">sudo</span><span style="color: #24292E"> </span><span style="color: #032F62">usermod</span><span style="color: #24292E"> </span><span style="color: #005CC5">-aG</span><span style="color: #24292E"> </span><span style="color: #032F62">docker</span><span style="color: #24292E"> $USER</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>ここまでできたら，一度ログアウトし，再度ログインする． これによって，グループの変更がターミナルのセッションに反映される．</p>
<p>設定が正しくできているかを確認するため，次のコマンドを実行してみる．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">docker</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">run</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">hello-world</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">docker</span><span style="color: #24292E"> </span><span style="color: #032F62">run</span><span style="color: #24292E"> </span><span style="color: #032F62">hello-world</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p><code>sudo</code> なしでコンテナが実行できたならば，設定は完了である．</p>
<h2 id="python-venv-クイックガイド" tabindex="-1">Python <code>venv</code> クイックガイド <a class="header-anchor" href="#python-venv-クイックガイド" aria-label="Permalink to &quot;Python `venv` クイックガイド&quot;">&ZeroWidthSpace;</a></h2>
<p>他人からもらったプログラムで， numpy や scipy のバージョンが違う！などの理由で，プログラムが動かない，という経験をしたことがある人は多いのではないだろうか． もし，自分の計算機の中に一つしか Python 環境がないとすると，プロジェクトを切り替えるごとに正しいバージョンをインストールし直さなければならず，これは大変な手間である．</p>
<p>コードのシェアをよりスムーズにするためには，ライブラリのバージョンはプロジェクトごとに管理されるべきである． それを可能にするのが Python 仮想環境とよばれるツールであり， <a href="https://docs.python.org/3/tutorial/venv.html" target="_blank" rel="noreferrer">venv</a>, <a href="https://github.com/pyenv/pyenv" target="_blank" rel="noreferrer">pyenv</a>, <a href="https://docs.conda.io/en/latest/" target="_blank" rel="noreferrer">conda</a> などがよく使われる．</p>
<p>そのなかでも， <code>venv</code> は Python に標準搭載されているのでとても便利である． <code>pyenv</code> や <code>conda</code> は，別途インストールの必要があるが，それぞれの長所もある．</p>
<p><code>venv</code> を使って仮想環境を作成するには，</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-m</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">venv</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.env</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python</span><span style="color: #24292E"> </span><span style="color: #005CC5">-m</span><span style="color: #24292E"> </span><span style="color: #032F62">venv</span><span style="color: #24292E"> </span><span style="color: #032F62">.env</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>と実行する． これにより <code>.env/</code> というディレクトリが作られ，このディレクトリに依存するライブラリが保存されることになる．</p>
<p>この新たな仮想環境を起動するには</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">source</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.env/bin/activate</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">source</span><span style="color: #24292E"> </span><span style="color: #032F62">.env/bin/activate</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>と実行する．</p>
<p>シェルのプロンプトに <code>(.env)</code> という文字が追加されていることを確認しよう (<a href="#fig_venv_prompt">figure_title</a>)． これが， &quot;いまあなたは venv の中にいますよ&quot; というしるしになる．</p>
<p><img src="./assets/venv_shell.png" alt="venv を起動したときのプロンプト"></p>
<p>仮想環境を起動すると，それ以降実行する <code>pip</code> コマンドは， <code>.env/</code> 以下にインストールされる．このようにして，プロジェクトごとに使うライブラリのバージョンを切り分けることができる．</p>
<p>Python では <code>requirements.txt</code> というファイルに依存ライブラリを記述するのが一般的な慣例である．他人からもらったプログラムに， <code>requirements.txt</code> が定義されていれば，</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">pip</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">install</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-r</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">requirements.txt</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">pip</span><span style="color: #24292E"> </span><span style="color: #032F62">install</span><span style="color: #24292E"> </span><span style="color: #005CC5">-r</span><span style="color: #24292E"> </span><span style="color: #032F62">requirements.txt</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>と実行することで，必要なライブラリをインストールし，瞬時に Python 環境を再現することができる．</p>
<p>venv による仮想環境を保存するディレクトリの名前は任意に選べることができるが， <code>.env</code> という名前を用いるのが一般的である．</p>
<h2 id="ハンズオン実行用の-docker-image-の使い方" tabindex="-1">ハンズオン実行用の Docker image の使い方 <a class="header-anchor" href="#ハンズオン実行用の-docker-image-の使い方" aria-label="Permalink to &quot;ハンズオン実行用の Docker image の使い方&quot;">&ZeroWidthSpace;</a></h2>
<p>ハンズオンを実行するために必要な， Node.js, Python, AWS CDK などがインストールされた Docker image を用意した． これを使用することで，自分のローカルマシンに諸々をインストールする必要なく，すぐにハンズオンのコードが実行できる．</p>
<p>ハンズオンのいくつかのコマンドは Docker の外 = ローカルマシンのリアル環境で実行されなければならない． それらについてはハンズオンの該当箇所に注意書きとして記してある．</p>
<p>Docker イメージは <a href="https://hub.docker.com/repository/docker/tomomano/labc" target="_blank" rel="noreferrer">Docker Hub</a> においてある． Docker イメージのビルドファイルは GitHub の <a href="https://github.com/tomomano/learn-aws-by-coding-source-code/blob/main/docker/Dockerfile" target="_blank" rel="noreferrer">docker/Dockerfile</a> にある．</p>
<p>次のコマンドでコンテナを起動する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">docker</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">run</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-it</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">tomomano/labc:latest</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">docker</span><span style="color: #24292E"> </span><span style="color: #032F62">run</span><span style="color: #24292E"> </span><span style="color: #005CC5">-it</span><span style="color: #24292E"> </span><span style="color: #032F62">tomomano/labc:latest</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>初回にコマンドを実行したときのみ，イメージが Docker Hub からダウンロード (pull) される． 二回目以降はローカルにダウンロードされたイメージが使用される．</p>
<p>コンテナが起動すると，次のようなインタラクティブシェルが表示されるはずである (起動時に <code>-it</code> のオプションをつけたのがポイントである)．</p>
<p>root@aws-handson:~$&lt;/programlisting&gt;</p>
<p>この状態で <code>ls</code> コマンドを打つと， <code>handson/</code> というディレクトリがあるはずである． ここに <code>cd</code> する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cd</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">handson</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cd</span><span style="color: #24292E"> </span><span style="color: #032F62">handson</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>すると，各ハンズオンごとのディレクトリが見つかるはずである．</p>
<p>あとは，ハンズオンごとにディレクトリを移動し，ハンズオンごとの virtualenv を作成し，スタックのデプロイを行えばよい ( (#sec_handson_ec2_run) など参照)． ハンズオンごとに使用する依存ライブラリが異なるので，それぞれのハンズオンごとに virtualenv を作成するという設計になっている．</p>
<p>AWS の認証情報を設定することも忘れずに． <a href="#aws_cli_install">AWS CLI のインストール</a> で記述したように， <code>AWS_ACCESS_KEY_ID</code> などの環境変数を設定するのが簡単な方法である． あるいは，<strong>ローカルマシンの</strong> <code>~/.aws/credentials</code> に認証情報が書き込まれているなら，このディレクトリをコンテナに<strong>マウント</strong>することで，同じ認証ファイルをコンテナ内部から参照することが可能である． この選択肢を取る場合は，次のコマンドでコンテナを起動する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">docker</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">run</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-it</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-v</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">~/.aws:/root/.aws:ro</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">tomomano/labc:latest</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">docker</span><span style="color: #24292E"> </span><span style="color: #032F62">run</span><span style="color: #24292E"> </span><span style="color: #005CC5">-it</span><span style="color: #24292E"> </span><span style="color: #005CC5">-v</span><span style="color: #24292E"> </span><span style="color: #032F62">~/.aws:/root/.aws:ro</span><span style="color: #24292E"> </span><span style="color: #032F62">tomomano/labc:latest</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>これにより，ローカルマシンの <code>~/.aws</code> をコンテナの <code>/root/.aws</code> にマウントすることができる． 最後の <code>:ro</code> は read-only を意味する． 大切な認証ファイルが誤って書き換えられてしまわないように， read-only のフラグをつけることをおすすめする．</p>
<p><code>/root/</code> がコンテナ環境におけるホームディレクトリである． ここで紹介した認証ファイルをマウントするテクニックは， SSH 鍵をコンテナに渡すときなどにも使える．</p>
]]></description>
            <content:encoded><![CDATA[<h1 id="appendix-環境構築" tabindex="-1">Appendix: 環境構築 <a class="header-anchor" href="#appendix-環境構築" aria-label="Permalink to &quot;Appendix: 環境構築&quot;">&ZeroWidthSpace;</a></h1>
<p>本書を読み進めるにあたって，ハンズオンのプログラムを実行するための環境を自分のローカルマシンにセットアップしなければならない． ここでは， AWS やコマンドラインの初心者を想定して，本章で必要なソフトウェアやライブラリのインストールなどを簡単に解説する． 以下に簡単な目次を示そう． 既に環境構築が済んでいる場合は適宜読み飛ばしていただき，関係のある箇所のみ目を通せば良い．</p>
<ul>
<li>
<p>AWS アカウントの取得 (<a href="#sec:create_aws_account">AWS アカウントの取得</a>)</p>
</li>
<li>
<p>AWS シークレットキーの作成 (<a href="#aws_secrets">AWS のシークレットキーの作成</a>)</p>
</li>
<li>
<p>AWS CLI のインストール (<a href="#aws_cli_install">AWS CLI のインストール</a>)</p>
</li>
<li>
<p>AWS CDK のインストール (<a href="#aws_cdk_install">AWS CDK のインストール</a>)</p>
</li>
<li>
<p>WSL のインストール (<a href="#sec:install_wsl">WSL のインストール</a>)</p>
</li>
<li>
<p>Docker のインストール (<a href="#sec:install_docker">Docker のインストール</a>)</p>
</li>
<li>
<p>Python venv クイックガイド (<a href="#venv_quick_guide">Python クイックガイド</a>)</p>
</li>
<li>
<p>ハンズオン実行用の Docker image の使い方 (<a href="#sec_handson_docker">ハンズオン実行用の Docker image の使い方</a>)</p>
</li>
</ul>
<p>使用する OS は Linux/Mac/Windows のどれを用いても構わない． Windows のユーザーは， Windows Subsytem for Linux (WSL) を使用することを想定している (<a href="#sec:install_wsl">WSL のインストール</a>)．</p>
<p>また，本書のハンズオンを実行するための <a href="https://hub.docker.com/repository/docker/tomomano/labc" target="_blank" rel="noreferrer">Docker イメージ</a> を提供している． これを用いると， AWS CLI/CDK や Python の設定などをスキップできるので， Docker の使用方法を知っている読者には便利だろう．</p>
<h2 id="aws-アカウントの取得" tabindex="-1">AWS アカウントの取得 <a class="header-anchor" href="#aws-アカウントの取得" aria-label="Permalink to &quot;AWS アカウントの取得&quot;">&ZeroWidthSpace;</a></h2>
<p>本書で提供するハンズオンを実際に自分で試すには，読者自身で AWS のアカウントの作成をする必要がある． 詳しいアカウントの作成の手順は <a href="https://aws.amazon.com/jp/register-flow/" target="_blank" rel="noreferrer">公式のドキュメンテーション</a> に書かれているので，そちらも参照していただきたい． 以下の手順に従ってアカウントの作成を行う．</p>
<p>まず，ウェブブラウザから <a href="https://aws.amazon.com/console/" target="_blank" rel="noreferrer">AWS コンソール</a> にアクセスし，右上の <code>Create an AWS Account</code> をクリックする (<a href="#fig:aws-signup-1">figure_title</a> で実線で囲った部分)．</p>
<p><img src="./assets/signup-1.png" alt="サインアップ (1): AWS コンソールにアクセス"></p>
<p>次に，遷移した先のページでメールアドレスとパスワードなどの登録を行う (<a href="#fig:aws-signup-3">figure_title</a>)．</p>
<p><img src="./assets/signup-3.png" alt="サインアップ (2): メールアドレス・パスワードなどの登録．"></p>
<p>続いて，住所や電話番号などを訊かれるので，すべて入力しよう (<a href="#fig:aws-signup-4">figure_title</a>)．</p>
<p><img src="./assets/signup-4.png" alt="サインアップ (3): 住所・電話番号の入力"></p>
<p>次に，クレジットカードの情報の登録を求められる (<a href="#fig:aws-signup-5">figure_title</a>)． 個人で AWS を利用する場合は，利用料金の請求はクレジットカードを経由して行われる． クレジットカードの登録なしには AWS を使い始めることはできないことに注意．</p>
<p><img src="./assets/signup-5.png" alt="サインアップ (4): クレジットカードの登録"></p>
<p>次の画面では，携帯電話の SMS またはボイスメッセージを利用した本人確認が求められる (<a href="#fig:aws-signup-6">figure_title</a>)． 希望の認証方法を選択し，自分の携帯電話番号を入力しよう．</p>
<p><img src="./assets/signup-6.png" alt="サインアップ (5): 携帯電話による本人確認"></p>
<p>無事に本人確認が完了すると，最後にサポートプランの選択を求められる (<a href="#fig:aws-signup-8">figure_title</a>)． 無料の Basic support を選択しておけば問題ない．</p>
<p><img src="./assets/signup-8.png" alt="サインアップ (6): サポートプランの選択"></p>
<p>以上のステップにより，アカウントの作成が完了する (<a href="#fig:aws-signup-9">figure_title</a>)． 早速ログインをして， AWS コンソールにアクセスできるか確認しておこう．</p>
<p><img src="./assets/signup-9.png" alt="サインアップ (7): アカウントの作成が完了した"></p>
<h2 id="aws-のシークレットキーの作成" tabindex="-1">AWS のシークレットキーの作成 <a class="header-anchor" href="#aws-のシークレットキーの作成" aria-label="Permalink to &quot;AWS のシークレットキーの作成&quot;">&ZeroWidthSpace;</a></h2>
<p>AWS シークレットキーとは， AWS CLI や AWS CDK から AWS の API を操作するときに，ユーザー認証を行うための鍵のことである． AWS CLI/CDK を使うには，最初にシークレットキーを発行する必要がある． AWS シークレットキーの詳細は <a href="https://docs.aws.amazon.com/general/latest/gr/aws-sec-cred-types.html" target="_blank" rel="noreferrer">公式ドキュメンテーション &quot;Understanding and getting your AWS credentials&quot;</a> を参照．</p>
<ol>
<li>
<p>AWS コンソールにログインする．</p>
</li>
<li>
<p>画面右上のアカウント名をクリックし，表示されるプルダウンメニューから &quot;My Security Credentials&quot; を選択 (<a href="#fig:aws_secret_key_1">figure_title</a>)</p>
</li>
<li>
<p>&quot;Access keys for CLI, SDK, &amp; API access&quot; の下にある &quot;Create accesss key&quot; のボタンをクリックする (<a href="#fig:aws_secret_key_2">figure_title</a>)</p>
</li>
<li>
<p>表示された Access key ID, Secret access key を記録しておく (画面を閉じると二度と表示されない)．</p>
</li>
<li>
<p>鍵を忘れてしまった場合などは，同じ手順で再発行が可能である．</p>
</li>
<li>
<p>発行したシークレットキーは， <code>~/.aws/credentials</code> のファイルに書き込むか，環境変数に設定するなどして使う (詳しくは <a href="#aws_cli_install">AWS CLI のインストール</a>)．</p>
</li>
</ol>
<p><img src="./assets/aws_secret_key_1.png" alt="AWS シークレットキーの発行1"></p>
<p><img src="./assets/aws_secret_key_2.png" alt="AWS シークレットキーの発行2"></p>
<p><strong>AWS Educate Starter Account</strong> を用いている場合は，次の手順でシークレットキーを確認する．</p>
<ul>
<li>
<p>AWS Educate のコンソール画面から， <code>vocareum</code> のコンソールに移動する (<a href="#fig:vocareum_console">figure_title</a>)．</p>
</li>
<li>
<p><code>Account Details</code> をクリックし，続いて <code>AWS CLI: Show</code> をクリックする．</p>
</li>
<li>
<p><code>aws_access_key_id</code>, <code>aws_secret_access_key</code>, <code>aws_session_token</code> が表示される (<a href="#fig:vocareum_secret">figure_title</a>)． ここで表示された内容を <code>~/.aws/credentials</code> にコピーする (<a href="#aws_cli_install">AWS CLI のインストール</a> 参照)． <code>aws_session_token</code> の箇所も漏らさずコピーすること．</p>
</li>
<li>
<p>続いて， <code>~/.aws/config</code> というファイルを用意し，次の内容を書き込む． 現時点では AWS Starter Account は <code>us-east-1</code> リージョンでしか利用できないためである．</p>
</li>
</ul>
<div class="language-toml vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">toml</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">[</span><span style="color: #F69D50">default</span><span style="color: #ADBAC7">]</span></span>
<span class="line"><span style="color: #ADBAC7">    region = u</span><span style="color: #FF938A; font-style: italic">s-east-1</span></span>
<span class="line"><span style="color: #ADBAC7">    output = j</span><span style="color: #FF938A; font-style: italic">son</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">[</span><span style="color: #6F42C1">default</span><span style="color: #24292E">]</span></span>
<span class="line"><span style="color: #24292E">    region = u</span><span style="color: #B31D28; font-style: italic">s-east-1</span></span>
<span class="line"><span style="color: #24292E">    output = j</span><span style="color: #B31D28; font-style: italic">son</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><ul>
<li>上記の説明ではプロファイル名が <code>default</code> となっていたが，これは自分の好きな名前に変更してもよい． <code>default</code> 以外の名前を使用する場合は，コマンドを実行するときにプロファイル名を指定する必要がある (詳しくは <a href="#aws_cli_install">AWS CLI のインストール</a>)．</li>
</ul>
<p><img src="./assets/vocareum_console.png" alt="vocareum コンソール"></p>
<p><img src="./assets/vocareum_secret.png" alt="vocareum から AWS シークレットキーの発行"></p>
<h2 id="aws-cli-のインストール" tabindex="-1">AWS CLI のインストール <a class="header-anchor" href="#aws-cli-のインストール" aria-label="Permalink to &quot;AWS CLI のインストール&quot;">&ZeroWidthSpace;</a></h2>
<p>読者のために，執筆時点におけるインストールの手順 (Linux 向け) を簡単に記述する． 将来のバージョンでは変更される可能性があるので，常に <a href="https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html" target="_blank" rel="noreferrer">公式のドキュメンテーション</a> で最新の情報をチェックすることを忘れずに．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">curl</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-o</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;awscliv2.zip&quot;</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">unzip</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">awscliv2.zip</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">sudo</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">./aws/install</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">curl</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip&quot;</span><span style="color: #24292E"> </span><span style="color: #005CC5">-o</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;awscliv2.zip&quot;</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">unzip</span><span style="color: #24292E"> </span><span style="color: #032F62">awscliv2.zip</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">sudo</span><span style="color: #24292E"> </span><span style="color: #032F62">./aws/install</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><p>インストールできたか確認するため，次のコマンドを打ってバージョン情報が出力されることを確認する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--version</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">aws</span><span style="color: #24292E"> </span><span style="color: #005CC5">--version</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>インストールができたら，次のコマンドにより初期設定を行う (<a href="https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html" target="_blank" rel="noreferrer">参照</a>)．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">configure</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">aws</span><span style="color: #24292E"> </span><span style="color: #032F62">configure</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>コマンドを実行すると， <code>AWS Access Key ID</code>, <code>AWS Secret Access Key</code> を入力するよう指示される． シークレットキーの発行については <a href="#aws_secrets">AWS のシークレットキーの作成</a> を参照． コマンドは加えて，<code>Default region name</code> を訊いてくる． ここには自分の好きな地域 (例えば <code>ap-northeast-1</code> =東京リージョン) を指定すればよい． 最後の <code>Default output format</code> は <code>json</code> としておくとよい．</p>
<p>このコマンドを完了すると， <code>~/.aws/credentials</code> と <code>~/.aws/config</code>　という名前のファイルが生成されているはずである． 念のため， <code>cat</code> コマンドを使って中身を確認してみるとよい．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cat</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">~/.aws/credentials</span></span>
<span class="line"><span style="color: #ADBAC7">[default]</span></span>
<span class="line"><span style="color: #F69D50">aws_access_key_id</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">XXXXXXXXXXXXXXXXXX</span></span>
<span class="line"><span style="color: #F69D50">aws_secret_access_key</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">YYYYYYYYYYYYYYYYYYY</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cat</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">~/.aws/config</span></span>
<span class="line"><span style="color: #ADBAC7">[profile default]</span></span>
<span class="line"><span style="color: #F69D50">region</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ap-northeast-1</span></span>
<span class="line"><span style="color: #F69D50">output</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">json</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cat</span><span style="color: #24292E"> </span><span style="color: #032F62">~/.aws/credentials</span></span>
<span class="line"><span style="color: #24292E">[default]</span></span>
<span class="line"><span style="color: #6F42C1">aws_access_key_id</span><span style="color: #24292E"> </span><span style="color: #032F62">=</span><span style="color: #24292E"> </span><span style="color: #032F62">XXXXXXXXXXXXXXXXXX</span></span>
<span class="line"><span style="color: #6F42C1">aws_secret_access_key</span><span style="color: #24292E"> </span><span style="color: #032F62">=</span><span style="color: #24292E"> </span><span style="color: #032F62">YYYYYYYYYYYYYYYYYYY</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cat</span><span style="color: #24292E"> </span><span style="color: #032F62">~/.aws/config</span></span>
<span class="line"><span style="color: #24292E">[profile default]</span></span>
<span class="line"><span style="color: #6F42C1">region</span><span style="color: #24292E"> </span><span style="color: #032F62">=</span><span style="color: #24292E"> </span><span style="color: #032F62">ap-northeast-1</span></span>
<span class="line"><span style="color: #6F42C1">output</span><span style="color: #24292E"> </span><span style="color: #032F62">=</span><span style="color: #24292E"> </span><span style="color: #032F62">json</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br></div></div><p><code>~/.aws/credentials</code> には認証鍵の情報が， <code>~/.aws/config</code> には AWS CLI の設定が記録されている．</p>
<p>デフォルトでは， <code>[default]</code> という名前でプロファイルが保存される． いくつかのプロファイルを使い分けたければ， default の例に従って，たとえば <code>[myprofile]</code> などという名前でプロファイルを追加すればよい．</p>
<p>AWS CLI でコマンドを打つときに，プロファイルを使い分けるには，</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">s3</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ls</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--profile</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">myprofile</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">aws</span><span style="color: #24292E"> </span><span style="color: #032F62">s3</span><span style="color: #24292E"> </span><span style="color: #032F62">ls</span><span style="color: #24292E"> </span><span style="color: #005CC5">--profile</span><span style="color: #24292E"> </span><span style="color: #032F62">myprofile</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>のように， <code>--profile</code> というオプションをつけてコマンドを実行する．</p>
<p>いちいち <code>--profile</code> オプションをつけるのが面倒だと感じる場合は， <code>AWS_PROFILE</code> という環境変数を設定するとよい．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">export</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">AWS_PROFILE=myprofile</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">export</span><span style="color: #24292E"> </span><span style="color: #032F62">AWS_PROFILE=myprofile</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>あるいは，認証情報などを環境変数に設定するテクニックもある．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">export</span><span style="color: #ADBAC7"> AWS_ACCESS_KEY_ID</span><span style="color: #F47067">=</span><span style="color: #96D0FF">XXXXXX</span></span>
<span class="line"><span style="color: #F47067">export</span><span style="color: #ADBAC7"> AWS_SECRET_ACCESS_KEY</span><span style="color: #F47067">=</span><span style="color: #96D0FF">YYYYYY</span></span>
<span class="line"><span style="color: #F47067">export</span><span style="color: #ADBAC7"> AWS_DEFAULT_REGION</span><span style="color: #F47067">=</span><span style="color: #96D0FF">ap-northeast-1</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">export</span><span style="color: #24292E"> AWS_ACCESS_KEY_ID</span><span style="color: #D73A49">=</span><span style="color: #032F62">XXXXXX</span></span>
<span class="line"><span style="color: #D73A49">export</span><span style="color: #24292E"> AWS_SECRET_ACCESS_KEY</span><span style="color: #D73A49">=</span><span style="color: #032F62">YYYYYY</span></span>
<span class="line"><span style="color: #D73A49">export</span><span style="color: #24292E"> AWS_DEFAULT_REGION</span><span style="color: #D73A49">=</span><span style="color: #032F62">ap-northeast-1</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><p>これらの環境変数は， <code>~/.aws/credentials</code> よりも高い優先度をもつので，環境変数が設定されていればそちらの情報が使用される (<a href="https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html" target="_blank" rel="noreferrer">参照</a>)．</p>
<p><strong>AWS Educate Starter Account</strong> は <code>us-east-1</code> のリージョンのみ利用可能である (執筆時点での情報)． よって， AWS Educate Starter Account を使用している場合は， default region を <code>us-east-1</code> に設定する必要がある．</p>
<h2 id="aws-cdk-のインストール" tabindex="-1">AWS CDK のインストール <a class="header-anchor" href="#aws-cdk-のインストール" aria-label="Permalink to &quot;AWS CDK のインストール&quot;">&ZeroWidthSpace;</a></h2>
<p>読者のために，執筆時点におけるインストールの手順 (Linux 向け) を簡単に記述する． 将来のバージョンでは変更される可能性があるので，常に <a href="https://docs.aws.amazon.com/cdk/latest/guide/getting_started.html" target="_blank" rel="noreferrer">公式のドキュメンテーション</a> で最新の情報をチェックすることを忘れずに．</p>
<p>Node.js がインストールされていれば，基本的に次のコマンドを実行すればよい．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">sudo</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">npm</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">install</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-g</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws-cdk</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">sudo</span><span style="color: #24292E"> </span><span style="color: #032F62">npm</span><span style="color: #24292E"> </span><span style="color: #032F62">install</span><span style="color: #24292E"> </span><span style="color: #005CC5">-g</span><span style="color: #24292E"> </span><span style="color: #032F62">aws-cdk</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>本書のハンズオンは AWS CDK version 1.100.0 で開発した． CDK は開発途上のライブラリなので，将来的に API が変更される可能性がある． API の変更によりエラーが生じた場合は， version 1.100.0 を使用することを推奨する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">npm</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">install</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-g</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws-cdk@1.100</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">npm</span><span style="color: #24292E"> </span><span style="color: #032F62">install</span><span style="color: #24292E"> </span><span style="color: #005CC5">-g</span><span style="color: #24292E"> </span><span style="color: #032F62">aws-cdk@1.100</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>インストールできたか確認するため，次のコマンドを打って正しくバージョンが表示されることを確認する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cdk</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--version</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cdk</span><span style="color: #24292E"> </span><span style="color: #005CC5">--version</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>インストールができたら，次のコマンドにより AWS 側の初期設定を行う． これは一度実行すれば OK．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cdk</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">bootstrap</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cdk</span><span style="color: #24292E"> </span><span style="color: #032F62">bootstrap</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p><code>cdk bootstrap</code> を実行するときは，AWS の認証情報とリージョンが正しく設定されていることを確認する． デフォルトでは <code>~/.aws/config</code> にあるデフォルトのプロファイルが使用される． デフォルト以外のプロファイルを用いるときは <a href="#aws_cli_install">AWS CLI のインストール</a> で紹介したテクニックを使って切り替える．</p>
<p>AWS CDK の認証情報の設定は AWS CLI と基本的に同じである．詳しくは <a href="#aws_cli_install">AWS CLI のインストール</a> を参照．</p>
<h2 id="wsl-のインストール" tabindex="-1">WSL のインストール <a class="header-anchor" href="#wsl-のインストール" aria-label="Permalink to &quot;WSL のインストール&quot;">&ZeroWidthSpace;</a></h2>
<p>本書のハンズオンではコマンドラインから AWS CLI のコマンドを実行したり， Python で書かれたプログラムを実行する． コマンドは基本的に UNIX のターミナルを想定して書かれている． Linux や Mac のユーザーは OS に標準搭載されているターミナルを用いれば良い． Windows を利用している読者は， <a href="https://docs.microsoft.com/en-us/windows/wsl/" target="_blank" rel="noreferrer">Windows Subsystem for Linux (WSL)</a> を利用することで，仮想の Linux 環境を構築することを推奨する． <a href="https://www.cygwin.com/" target="_blank" rel="noreferrer">Cygwin</a> などの Linux 環境をエミュレートするほかのツールでも構わないが，本書のプログラムは WSL でのみ動作確認を行っている．</p>
<p>WSL とは， Windows の OS 上で Linux の仮想環境を起動するための， Microsoft 社が公式で提供しているソフトウェアである． Ubuntu など希望の Linux distribution が選択でき，基本的にすべての Linux 向けに作られたプログラム・ソフトウェアを使用することができる．</p>
<p>執筆時点では <a href="https://docs.microsoft.com/en-us/windows/wsl/compare-versions#whats-new-in-wsl-2" target="_blank" rel="noreferrer">WSL 2</a> が最新版として提供されているので，以下では WSL 2 のインストール手順を簡単に説明する． 細かな詳細などは， <a href="https://docs.microsoft.com/en-us/windows/wsl/install-win10" target="_blank" rel="noreferrer">公式ドキュメンテーション</a> を参照のこと．</p>
<p>前提として，使用される OS は Windows 10 (Pro または Home エディション) でなければならない． さらに，使用している Windows 10 のバージョンが WSL に対応するバージョンであるかを確認する． X64 のシステムでは Version 1903, Build 18362 以上でなければならない． バージョンが対応していない場合は、 Windows のアップデートを行う．</p>
<p>まず最初に， Administrator 権限で PowerShell を起動する (<a href="#fig:powershell">figure_title</a>)． 左下の Windows メニューの検索バーに <code>powershell</code> と入力すると， PowerShell のプログラムが見つかるはずである， これを右クリックし、 <code>Run as administrator</code> を選択し起動する．</p>
<p><img src="./assets/wsl/powershell.png" alt="管理者権限での PowerShell の起動"></p>
<p>PowerShell が起動したら、次のコマンドを実行する．</p>
<div class="language-powershell vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">powershell</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #6CB6FF">dism.exe</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">/</span><span style="color: #ADBAC7">online </span><span style="color: #F47067">/</span><span style="color: #6CB6FF">enable-feature</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">/</span><span style="color: #ADBAC7">featurename:Microsoft</span><span style="color: #F47067">-</span><span style="color: #ADBAC7">Windows</span><span style="color: #F47067">-</span><span style="color: #ADBAC7">Subsystem</span><span style="color: #F47067">-</span><span style="color: #ADBAC7">Linux </span><span style="color: #F47067">/</span><span style="color: #ADBAC7">all </span><span style="color: #F47067">/</span><span style="color: #ADBAC7">norestart</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #005CC5">dism.exe</span><span style="color: #24292E"> </span><span style="color: #D73A49">/</span><span style="color: #24292E">online </span><span style="color: #D73A49">/</span><span style="color: #005CC5">enable-feature</span><span style="color: #24292E"> </span><span style="color: #D73A49">/</span><span style="color: #24292E">featurename:Microsoft</span><span style="color: #D73A49">-</span><span style="color: #24292E">Windows</span><span style="color: #D73A49">-</span><span style="color: #24292E">Subsystem</span><span style="color: #D73A49">-</span><span style="color: #24292E">Linux </span><span style="color: #D73A49">/</span><span style="color: #24292E">all </span><span style="color: #D73A49">/</span><span style="color: #24292E">norestart</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>実行して、“The operation completed successfully.” と出力されるのを確認する． これで WSL が enable される．</p>
<p>次に，先ほどと同じ Administrator 権限で開いた PowerShell で次のコマンドを実行する。</p>
<div class="language-powershell vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">powershell</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #6CB6FF">dism.exe</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">/</span><span style="color: #ADBAC7">online </span><span style="color: #F47067">/</span><span style="color: #6CB6FF">enable-feature</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">/</span><span style="color: #ADBAC7">featurename:VirtualMachinePlatform </span><span style="color: #F47067">/</span><span style="color: #ADBAC7">all </span><span style="color: #F47067">/</span><span style="color: #ADBAC7">norestart</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #005CC5">dism.exe</span><span style="color: #24292E"> </span><span style="color: #D73A49">/</span><span style="color: #24292E">online </span><span style="color: #D73A49">/</span><span style="color: #005CC5">enable-feature</span><span style="color: #24292E"> </span><span style="color: #D73A49">/</span><span style="color: #24292E">featurename:VirtualMachinePlatform </span><span style="color: #D73A49">/</span><span style="color: #24292E">all </span><span style="color: #D73A49">/</span><span style="color: #24292E">norestart</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>実行して， “The operation completed successfully.” と出力されるのを確認する． これが確認出来たら、一度コンピュータを再起動する．</p>
<p>続いて， Linux kernel update package を次のリンクからダウンロードする． <a href="https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi" target="_blank" rel="noreferrer">https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi</a></p>
<p>ダウンロードしたファイルをダブルクリックして実行する． ダイアログに従ってインストールを完了させる．</p>
<p>そうしたら，再び PowerShell を開き次のコマンドを実行する。</p>
<div class="language-powershell vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">powershell</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">wsl </span><span style="color: #F47067">--</span><span style="color: #6CB6FF">set-default</span><span style="color: #F47067">-</span><span style="color: #ADBAC7">version </span><span style="color: #6CB6FF">2</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">wsl </span><span style="color: #D73A49">--</span><span style="color: #005CC5">set-default</span><span style="color: #D73A49">-</span><span style="color: #24292E">version </span><span style="color: #005CC5">2</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>最後に、自分の好みの Linux distribution をインストールする． ここでは Ubuntu 20.04 をインストールしよう．</p>
<p>Microsoft store のアプリを起動し，検索バーに <code>Ubuntu</code> と入力する． Ubuntu 20.04 LTS という項目が見つかるはずなので，それを開き， “Get” ボタンをクリックする (<a href="#fig:microsoft_store">figure_title</a>)． しばらく待つと， Ubuntu 20.04 のインストールが完了する．</p>
<p><img src="./assets/wsl/microsoft_store.png" alt="Microsoft store から Ubuntu 20.04 をインストール"></p>
<p>Ubuntu 20.04 を初回に起動すると，初期設定が自動で開始され，数分待つことになる． 初期設定が終わると，ユーザー名・パスワードを設定するようプロンプトが出るので，プロンプトに従い入力する．</p>
<p>これで WSL2 のインストールが完了した． 早速 WSL2 を起動してみよう． 左下の Windows メニューの検索バーに <code>Ubuntu</code> と入力すると， Ubuntu 20.04 のプログラムが見つかるはずである (<a href="#fig:ubuntu">figure_title</a>)． クリックして起動しよう．</p>
<p><img src="./assets/wsl/ubuntu2004.png" alt="Ubuntu 20.04 の起動"></p>
<p>すると，ターミナルの黒い画面が立ち上がるだろう (<a href="#fig:wsl_window">figure_title</a>)． <code>ls</code>, <code>top</code> などのコマンドを打ってみて， WSL がきちんと動作していることを確認しよう．</p>
<p><img src="./assets/wsl/wsl_window.png" alt="WSL の起動画面"></p>
<p>オプションとして， <a href="https://docs.microsoft.com/en-us/windows/terminal/get-started" target="_blank" rel="noreferrer">Windows Terminal</a> というマイクロソフトから提供されているツールを使うと，より快適に WSL を使用することができる． 興味のある読者はこちらのインストールも推奨する．</p>
<h2 id="docker-のインストール" tabindex="-1">Docker のインストール <a class="header-anchor" href="#docker-のインストール" aria-label="Permalink to &quot;Docker のインストール&quot;">&ZeroWidthSpace;</a></h2>
<p>Docker のインストールの方法は OS によって異なる．</p>
<p>Mac ユーザーは， Docker Desktop をインストールする． インストールの方法は， <a href="https://docs.docker.com/docker-for-mac/install/" target="_blank" rel="noreferrer">Docker のウェブサイト</a> から， Mac 版の Docker Desktop をダウンロードし，ダウンロードされたファイルをダブルクリックし， <code>Applications</code> のフォルダにドラッグするだけで良い． 詳細は <a href="https://docs.docker.com/docker-for-mac/install/" target="_blank" rel="noreferrer">公式ドキュメンテーション</a> を参照のこと．</p>
<p>Windows のユーザーは，Docker Desktop をインストールする． その際， WSL 2 が事前にインストールされていなければならない． 詳細は <a href="https://docs.docker.com/desktop/windows/install/" target="_blank" rel="noreferrer">公式ドキュメンテーション</a> を参照のこと． Docker Desktop をインストールすると， WSL からも <code>docker</code> コマンドが使用できるようになる．</p>
<p>Linux ユーザー (特に Ubuntu ユーザー) については，インストールの方法はいくつかのアプローチがある． <a href="https://docs.docker.com/engine/install/ubuntu/" target="_blank" rel="noreferrer">公式ドキュメンテーション</a> にいくつかのインストールの方法が示されているので，詳しい情報はそちらを参照いただきたい．</p>
<p>最も簡単な方法は， Docker が公式で提供しているインストールスクリプトを用いる方法である． この場合，次のコマンドを実行することで Docker がインストールされる．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">curl</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-fsSL</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">https://get.docker.com</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-o</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">get-docker.sh</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">sudo</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">sh</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">get-docker.sh</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">curl</span><span style="color: #24292E"> </span><span style="color: #005CC5">-fsSL</span><span style="color: #24292E"> </span><span style="color: #032F62">https://get.docker.com</span><span style="color: #24292E"> </span><span style="color: #005CC5">-o</span><span style="color: #24292E"> </span><span style="color: #032F62">get-docker.sh</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">sudo</span><span style="color: #24292E"> </span><span style="color: #032F62">sh</span><span style="color: #24292E"> </span><span style="color: #032F62">get-docker.sh</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>デフォルトのインストールでは， root ユーザーのみが <code>docker</code> コマンドを使用できる設定になっている． 従って，コマンドには毎回 <code>sudo</code> を付け加える必要がある． これが面倒だと感じる場合は，次のステップにより，使用するユーザーを <code>docker</code> というグループに追加する (詳細は <a href="https://docs.docker.com/engine/install/linux-postinstall/#manage-docker-as-a-non-root-user" target="_blank" rel="noreferrer">公式ドキュメンテーション &quot;Post-installation steps for Linux&quot;</a> を参照)．</p>
<p>まず最初に， <code>docker</code> という名前にグループを追加する． インストールによっては，既に <code>docker</code> グループが作られている場合もある．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">sudo</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">groupadd</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">docker</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">sudo</span><span style="color: #24292E"> </span><span style="color: #032F62">groupadd</span><span style="color: #24292E"> </span><span style="color: #032F62">docker</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>次に，現在使用しているユーザーを <code>docker</code> グループに加える．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">sudo</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">usermod</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-aG</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">docker</span><span style="color: #ADBAC7"> $USER</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">sudo</span><span style="color: #24292E"> </span><span style="color: #032F62">usermod</span><span style="color: #24292E"> </span><span style="color: #005CC5">-aG</span><span style="color: #24292E"> </span><span style="color: #032F62">docker</span><span style="color: #24292E"> $USER</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>ここまでできたら，一度ログアウトし，再度ログインする． これによって，グループの変更がターミナルのセッションに反映される．</p>
<p>設定が正しくできているかを確認するため，次のコマンドを実行してみる．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">docker</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">run</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">hello-world</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">docker</span><span style="color: #24292E"> </span><span style="color: #032F62">run</span><span style="color: #24292E"> </span><span style="color: #032F62">hello-world</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p><code>sudo</code> なしでコンテナが実行できたならば，設定は完了である．</p>
<h2 id="python-venv-クイックガイド" tabindex="-1">Python <code>venv</code> クイックガイド <a class="header-anchor" href="#python-venv-クイックガイド" aria-label="Permalink to &quot;Python `venv` クイックガイド&quot;">&ZeroWidthSpace;</a></h2>
<p>他人からもらったプログラムで， numpy や scipy のバージョンが違う！などの理由で，プログラムが動かない，という経験をしたことがある人は多いのではないだろうか． もし，自分の計算機の中に一つしか Python 環境がないとすると，プロジェクトを切り替えるごとに正しいバージョンをインストールし直さなければならず，これは大変な手間である．</p>
<p>コードのシェアをよりスムーズにするためには，ライブラリのバージョンはプロジェクトごとに管理されるべきである． それを可能にするのが Python 仮想環境とよばれるツールであり， <a href="https://docs.python.org/3/tutorial/venv.html" target="_blank" rel="noreferrer">venv</a>, <a href="https://github.com/pyenv/pyenv" target="_blank" rel="noreferrer">pyenv</a>, <a href="https://docs.conda.io/en/latest/" target="_blank" rel="noreferrer">conda</a> などがよく使われる．</p>
<p>そのなかでも， <code>venv</code> は Python に標準搭載されているのでとても便利である． <code>pyenv</code> や <code>conda</code> は，別途インストールの必要があるが，それぞれの長所もある．</p>
<p><code>venv</code> を使って仮想環境を作成するには，</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-m</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">venv</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.env</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python</span><span style="color: #24292E"> </span><span style="color: #005CC5">-m</span><span style="color: #24292E"> </span><span style="color: #032F62">venv</span><span style="color: #24292E"> </span><span style="color: #032F62">.env</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>と実行する． これにより <code>.env/</code> というディレクトリが作られ，このディレクトリに依存するライブラリが保存されることになる．</p>
<p>この新たな仮想環境を起動するには</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">source</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.env/bin/activate</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">source</span><span style="color: #24292E"> </span><span style="color: #032F62">.env/bin/activate</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>と実行する．</p>
<p>シェルのプロンプトに <code>(.env)</code> という文字が追加されていることを確認しよう (<a href="#fig_venv_prompt">figure_title</a>)． これが， &quot;いまあなたは venv の中にいますよ&quot; というしるしになる．</p>
<p><img src="./assets/venv_shell.png" alt="venv を起動したときのプロンプト"></p>
<p>仮想環境を起動すると，それ以降実行する <code>pip</code> コマンドは， <code>.env/</code> 以下にインストールされる．このようにして，プロジェクトごとに使うライブラリのバージョンを切り分けることができる．</p>
<p>Python では <code>requirements.txt</code> というファイルに依存ライブラリを記述するのが一般的な慣例である．他人からもらったプログラムに， <code>requirements.txt</code> が定義されていれば，</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">pip</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">install</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-r</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">requirements.txt</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">pip</span><span style="color: #24292E"> </span><span style="color: #032F62">install</span><span style="color: #24292E"> </span><span style="color: #005CC5">-r</span><span style="color: #24292E"> </span><span style="color: #032F62">requirements.txt</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>と実行することで，必要なライブラリをインストールし，瞬時に Python 環境を再現することができる．</p>
<p>venv による仮想環境を保存するディレクトリの名前は任意に選べることができるが， <code>.env</code> という名前を用いるのが一般的である．</p>
<h2 id="ハンズオン実行用の-docker-image-の使い方" tabindex="-1">ハンズオン実行用の Docker image の使い方 <a class="header-anchor" href="#ハンズオン実行用の-docker-image-の使い方" aria-label="Permalink to &quot;ハンズオン実行用の Docker image の使い方&quot;">&ZeroWidthSpace;</a></h2>
<p>ハンズオンを実行するために必要な， Node.js, Python, AWS CDK などがインストールされた Docker image を用意した． これを使用することで，自分のローカルマシンに諸々をインストールする必要なく，すぐにハンズオンのコードが実行できる．</p>
<p>ハンズオンのいくつかのコマンドは Docker の外 = ローカルマシンのリアル環境で実行されなければならない． それらについてはハンズオンの該当箇所に注意書きとして記してある．</p>
<p>Docker イメージは <a href="https://hub.docker.com/repository/docker/tomomano/labc" target="_blank" rel="noreferrer">Docker Hub</a> においてある． Docker イメージのビルドファイルは GitHub の <a href="https://github.com/tomomano/learn-aws-by-coding-source-code/blob/main/docker/Dockerfile" target="_blank" rel="noreferrer">docker/Dockerfile</a> にある．</p>
<p>次のコマンドでコンテナを起動する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">docker</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">run</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-it</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">tomomano/labc:latest</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">docker</span><span style="color: #24292E"> </span><span style="color: #032F62">run</span><span style="color: #24292E"> </span><span style="color: #005CC5">-it</span><span style="color: #24292E"> </span><span style="color: #032F62">tomomano/labc:latest</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>初回にコマンドを実行したときのみ，イメージが Docker Hub からダウンロード (pull) される． 二回目以降はローカルにダウンロードされたイメージが使用される．</p>
<p>コンテナが起動すると，次のようなインタラクティブシェルが表示されるはずである (起動時に <code>-it</code> のオプションをつけたのがポイントである)．</p>
<p>root@aws-handson:~$&lt;/programlisting&gt;</p>
<p>この状態で <code>ls</code> コマンドを打つと， <code>handson/</code> というディレクトリがあるはずである． ここに <code>cd</code> する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cd</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">handson</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cd</span><span style="color: #24292E"> </span><span style="color: #032F62">handson</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>すると，各ハンズオンごとのディレクトリが見つかるはずである．</p>
<p>あとは，ハンズオンごとにディレクトリを移動し，ハンズオンごとの virtualenv を作成し，スタックのデプロイを行えばよい ( (#sec_handson_ec2_run) など参照)． ハンズオンごとに使用する依存ライブラリが異なるので，それぞれのハンズオンごとに virtualenv を作成するという設計になっている．</p>
<p>AWS の認証情報を設定することも忘れずに． <a href="#aws_cli_install">AWS CLI のインストール</a> で記述したように， <code>AWS_ACCESS_KEY_ID</code> などの環境変数を設定するのが簡単な方法である． あるいは，<strong>ローカルマシンの</strong> <code>~/.aws/credentials</code> に認証情報が書き込まれているなら，このディレクトリをコンテナに<strong>マウント</strong>することで，同じ認証ファイルをコンテナ内部から参照することが可能である． この選択肢を取る場合は，次のコマンドでコンテナを起動する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">docker</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">run</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-it</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-v</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">~/.aws:/root/.aws:ro</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">tomomano/labc:latest</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">docker</span><span style="color: #24292E"> </span><span style="color: #032F62">run</span><span style="color: #24292E"> </span><span style="color: #005CC5">-it</span><span style="color: #24292E"> </span><span style="color: #005CC5">-v</span><span style="color: #24292E"> </span><span style="color: #032F62">~/.aws:/root/.aws:ro</span><span style="color: #24292E"> </span><span style="color: #032F62">tomomano/labc:latest</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>これにより，ローカルマシンの <code>~/.aws</code> をコンテナの <code>/root/.aws</code> にマウントすることができる． 最後の <code>:ro</code> は read-only を意味する． 大切な認証ファイルが誤って書き換えられてしまわないように， read-only のフラグをつけることをおすすめする．</p>
<p><code>/root/</code> がコンテナ環境におけるホームディレクトリである． ここで紹介した認証ファイルをマウントするテクニックは， SSH 鍵をコンテナに渡すときなどにも使える．</p>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[課題 ]]></title>
            <link>https://note.toshiki.devdevelopment/aws/assignments</link>
            <guid>https://note.toshiki.devdevelopment/aws/assignments</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="課題" tabindex="-1">課題 <a class="header-anchor" href="#課題" aria-label="Permalink to &quot;課題&quot;">&ZeroWidthSpace;</a></h1>
<p>以下の課題を提出．</p>
]]></description>
            <content:encoded><![CDATA[<h1 id="課題" tabindex="-1">課題 <a class="header-anchor" href="#課題" aria-label="Permalink to &quot;課題&quot;">&ZeroWidthSpace;</a></h1>
<p>以下の課題を提出．</p>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[著者紹介 ]]></title>
            <link>https://note.toshiki.devdevelopment/aws/author</link>
            <guid>https://note.toshiki.devdevelopment/aws/author</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="著者紹介" tabindex="-1">著者紹介 <a class="header-anchor" href="#著者紹介" aria-label="Permalink to &quot;著者紹介&quot;">&ZeroWidthSpace;</a></h1>
<p>真野 智之 (Tomoyuki Mano)</p>
<p>情報理工学博士 (東京大学大学院情報理工学系研究科システム情報学専攻)． 2021 年より日本学術振興会特別研究員 (PD) (現職)． 沖縄科学技術大学院大学 (OIST) にてポスドク研究員として働く． 現在の研究分野は神経科学・神経情報学． 趣味は料理・ランニング・鉄道・アニメ，村上春樹の熱烈な愛読家．</p>
<p>連絡先　<a href="mailto:tomoyukimano@gmail.com" target="_blank" rel="noreferrer">tomoyukimano@gmail.com</a></p>
<p>GitHub <a href="https://github.com/tomomano" target="_blank" rel="noreferrer">https://github.com/tomomano</a></p>
]]></description>
            <content:encoded><![CDATA[<h1 id="著者紹介" tabindex="-1">著者紹介 <a class="header-anchor" href="#著者紹介" aria-label="Permalink to &quot;著者紹介&quot;">&ZeroWidthSpace;</a></h1>
<p>真野 智之 (Tomoyuki Mano)</p>
<p>情報理工学博士 (東京大学大学院情報理工学系研究科システム情報学専攻)． 2021 年より日本学術振興会特別研究員 (PD) (現職)． 沖縄科学技術大学院大学 (OIST) にてポスドク研究員として働く． 現在の研究分野は神経科学・神経情報学． 趣味は料理・ランニング・鉄道・アニメ，村上春樹の熱烈な愛読家．</p>
<p>連絡先　<a href="mailto:tomoyukimano@gmail.com" target="_blank" rel="noreferrer">tomoyukimano@gmail.com</a></p>
<p>GitHub <a href="https://github.com/tomomano" target="_blank" rel="noreferrer">https://github.com/tomomano</a></p>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hands-on #4: AWS Batch を使って機械学習のハイパーパラメータサーチを並列化する ]]></title>
            <link>https://note.toshiki.devdevelopment/aws/aws-batch</link>
            <guid>https://note.toshiki.devdevelopment/aws/aws-batch</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="hands-on-4-aws-batch-を使って機械学習のハイパーパラメータサーチを並列化する" tabindex="-1">Hands-on #4: AWS Batch を使って機械学習のハイパーパラメータサーチを並列化する <a class="header-anchor" href="#hands-on-4-aws-batch-を使って機械学習のハイパーパラメータサーチを並列化する" aria-label="Permalink to &quot;Hands-on \#4: AWS Batch を使って機械学習のハイパーパラメータサーチを並列化する&quot;">&ZeroWidthSpace;</a></h1>
<p>ハンズオン第三回では， ECS と Fargate を使って自動質問回答システムを構築した． シンプルながらも，複数の質問が送られた場合には並列にジョブが実行され，ユーザーに答えが返されるシステムを作ることができた． ここでは，すでに学習済みの言語モデルを用いてアプリケーションを構築した． しかし，一般的に言って，機械学習のワークフローでは自分で作ったモデルを訓練することが最初のステップにあるはずである． そこで，ハンズオン第四回では，クラウドを用いて機械学習の訓練を並列化・高速化することを考える．</p>
<p>本ハンズオンでは深層学習におけるハイパーパラメータ最適化を取り上げる． ハイパーパラメータとは，勾配降下法によって最適化されるニューラルネットのパラメータの外にあるパラメータのことであり，具体的にはモデルの層の幅・深さなどネットワークのアーキテクチャに関わるもの，学習率やモメンタムなどパラメータの更新則に関わるものなどが含まる． 深層学習においてハイパーパラメータの調整はとても重要なタスクである． しかしながら，ハイパーパラメータを調整するには，少しずつ条件を変えながら何度もニューラルネットを学習させる必要があり，多くの計算時間がかかる． 研究・開発においては，スループットよくたくさんのモデルの可能性を探索することが生産性を決める重要なファクターであり，ハイパーパラメータ探索を高速に解くという問題は極めて関心が高い． 本ハンズオンでは，クラウドの強力な計算リソースを利用して並列的にニューラルネットの訓練を実行することで，この問題を解く方法を学んでいこう．</p>
<h2 id="auto-scaling-groups-asg" tabindex="-1">Auto scaling groups (ASG) <a class="header-anchor" href="#auto-scaling-groups-asg" aria-label="Permalink to &quot;Auto scaling groups (ASG)&quot;">&ZeroWidthSpace;</a></h2>
<p>ハンズオンに入っていく前に， <strong>Auto scaling groups (ASG)</strong> とよばれる EC2 の概念を知っておく必要がある．</p>
<p>ECS の概要を示した (#ecs_overview) を振り返って見てほしい． 前章 ( (#sec_fargate_qabot)) でも説明したが， ECS のクラスターで計算を担う実体としては EC2 と Fargate を指定することができる． Fargate については前章で記述した． Fargate を用いると，自在にスケールする計算環境をとても簡単な設定で構築することができた． しかし， GPU を利用することができないなど，いくつかの制約があった． EC2 を使用した計算環境を指定することで，プログラミングの複雑度は増すが， GPU やその他のより高度かつ複雑な設定を伴ったクラスターを構築することができる．</p>
<p>EC2 クラスターには <strong>ASG</strong> と呼ばれるサービスが配置される． ASG は複数の EC2 インスタンスをロジカルな単位でグループ化することでクラスターを構成する． ASG はクラスター内に新しいインスタンスを起動する，あるいは不要になったインスタンスを停止するなどのスケーリングを担う． ASG で重要な概念として， <strong>desired capacity</strong>, <strong>minimum capacity</strong>, <strong>maximum capacity</strong> というパラメータがある． minimum capacity， maximum capacity は，それぞれクラスター内に配置できるインスタンスの数の最小値・最大値を指定するパラメータである． 前者は，クラスターに負荷がかかっていない場合でもアイドリング状態にあるインスタンスを維持することで，急に負荷が増大した時などのバッファーとして作用することができる． 後者は，負荷が急に増えたときに，過剰な数のインスタンスが起動する事態を防ぎ，経済的なコストの上限を定める役割を果たす．</p>
<p>desired capacity が，その時々でシステムが要求するインスタンスの数を指定する． desired capacity は，例えば 24 時間のリズムに合わせてインスタンスの数を増減させる (昼は多く夜は少なくなど) などの決まったスケジュールに基づいた設定を適用することができる． あるいはクラスター全体にかかっている負荷に応じて， desired capacity を動的に制御することも可能である． どのような基準でクラスターのスケーリングを行うかを定めるルールのことを，<strong>スケーリングポリシー</strong>とよぶ． たとえば，クラスター全体の稼働率 (負荷) を常に 80% に維持する，などのスケーリングポリシーが想定できる． この場合，クラスター全体の負荷が 80%を下回ったときにはクラスターからインスタンスが削除され，80%を超える (あるいは超えると予測される) 場合はインスタンスを追加する，という操作が ASG によって自動的に行われる．</p>
<p>上記のようなパラメータを検討し，ユーザーは ASG を作成する． ASG を作成したのち， ECS との連携をプログラムしてあげることで， ECS を介して ASG による EC2 クラスターにタスクを投入することが可能になる．</p>
<h2 id="aws-batch" tabindex="-1">AWS Batch <a class="header-anchor" href="#aws-batch" aria-label="Permalink to &quot;AWS Batch&quot;">&ZeroWidthSpace;</a></h2>
<p><img src="./assets/aws_logos/Batch.png" alt="AWS Batch のアイコン"></p>
<p>先に説明したように， ECS と ASG を組み合わせることで，所望の計算クラスターを構築することが可能である． しかしながら， ECS と ASG にはかなり込み入った設定が必要であり，初心者にとっても経験者にとってもなかなか面倒なプログラミングが要求される． そこで， ECS と ASG によるクラスターの設計を自動化してくれるサービスが提供されている． それが <strong>AWS Batch</strong> である．</p>
<p>AWS Batch はその名のとおりバッチ (Batch) 化されたジョブ (入力データだけが異なる独立した演算が繰り返し実行されること) を想定している． 多くの科学計算や機械学習がバッチ計算に当てはまる． たとえば，初期値のパラメータを変えて複数のシミュレーションを走らせる，といったケースだ． AWS Batch を用いることの利点は，クラスターのスケーリングやジョブの割り振りはすべて自動で実行され， ユーザーはクラウドの舞台裏の詳細を気にすることなく，大量のジョブを投入できるシステムが手に入る点である． が，知識として背後では ECS/ASG/EC2 の三つ巴が協調して動作しているという点は知っておいてほしい．</p>
<p>AWS Batch では，ジョブの投入・管理をスムーズに行うため，次のような概念が定義されている (<a href="#fig_batch_concept">figure_title</a>)． まず， <strong>ジョブ (Job)</strong> というのが，AWS Batch によって実行される一つの計算の単位である． <strong>Job definitions</strong> とはジョブの内容を定義するものであり，これには実行されるべき Docker のイメージのアドレスや，割り当てる CPU・RAM の容量，環境変数などの設定が含まれる． Job definition に基づいて個々のジョブが実行される． ジョブが実行されると，ジョブは <strong>Job queues</strong> に入る． Job queues とは，実行待ち状態にあるジョブの列のことであり，時間的に最も先頭に投入されたジョブが最初に実行される． また，複数の queue を配置し， queue ごとに priority (優先度) を設定することが可能であり， priority の高い queue に溜まったジョブが優先的に実行される (筆者はこれをディズニーランドの&quot;ファストパス&quot;を連想して捉えている)． <strong>Compute environment</strong> とは，先述したクラスターとほぼ同義の概念であり，計算が実行される場所 (EC2 や Fargate からなるクラスター) を指す． Compute environment には，使用する EC2 のインスタンスタイプや同時に起動するインスタンス数の上限などの簡易なスケーリングポリシーが指定されている． Job queues は Compute environment の空き状況を監視しており， それに応じてジョブを Compute environment に投下する．</p>
<p>以上が AWS Batch を使用するうえで理解しておかなければならない概念であるが，くどくど言葉で説明してもなかなかピンとこないだろう． ここからは，実際に自分で手を動かしながら学んでいこう．</p>
<p><img src="./assets/aws_batch/batch_concepts.png" alt="AWS Batch の主要な概念"></p>
<p><strong>EC2 or Fargate?</strong></p>
<p>ECS でクラスターを構成する際，計算を実行する場として EC2 と Fargate の二つの選択肢があることを説明した． それぞれ長所と短所を抱えているのだが，どのような場合にどちらを使うべきだろうか？ それを検討するため，まずは <a href="#tab:ec2_vs_fargate">table_title</a> を見てみよう． これは EC2 と Fargate の特徴をまとめたものである． 説明の都合上，大幅な粗視化が行われている点は留意していただきたい．</p>
<table><caption>EC2 vs Fargate</caption><colgroup><col style="width: 33%" /><col style="width: 33%" /><col style="width: 33%" /></colgroup><thead><tr class="header"><th></th><th>EC2</th><th>Fargate</th></tr></thead><tbody><tr class="odd"><td><p>Compute capacity</p></td><td><p>Medium to large</p></td><td><p>Small to medium</p></td></tr><tr class="even"><td><p>GPU</p></td><td><p>Yes</p></td><td><p>No</p></td></tr><tr class="odd"><td><p>Launch speed</p></td><td><p>Slow</p></td><td><p>Fast</p></td></tr><tr class="even"><td><p>Task placement flexibility</p></td><td><p>Low</p></td><td><p>High</p></td></tr><tr class="odd"><td><p>Programming complexity</p></td><td><p>High</p></td><td><p>Low</p></td></tr></tbody></table>
<p>これまでに見てきたように， EC2 は最大の CPU 数・メモリーサイズが大きかったり， GPU を利用できたりするなど，単一のインスタンスでの計算能力は高い． 対して， Fargate は単一インスタンスの最大 CPU 数は 4 コアが上限である． その一方で，インスタンスの起動に要する時間は Fargate のほうが圧倒的に早く，より俊敏にクラスターのスケーリングを行うことができる． また，タスクをクラスターに投入する際のフレキシビリティも Fargate のほうが高い． フレキシビリティというのは，例えば一つのインスタンスで 2 つ以上のコンテナを走らせる，などの状況である． 単位 CPU あたりで処理されるタスクの数を最大化する際には，このような設計がしばしば採用される． プログラミングの複雑さという観点からは， Fargate のほうが一般的にシンプルな実装になる．</p>
<p>このように， EC2 と Fargate は互いに相補的な特性を有しており，アプリケーションによって最適な計算環境は検討される必要がある． また，EC2 と Fargate を両方用いたハイブリッドクラスターというのも定義可能であり，そのような選択肢もしばしば用いられる．</p>
<h2 id="準備" tabindex="-1">準備 <a class="header-anchor" href="#準備" aria-label="Permalink to &quot;準備&quot;">&ZeroWidthSpace;</a></h2>
<p>ハンズオンのソースコードは GitHub の <a href="https://github.com/andatoshiki/toshiki-notebooktree/main/handson/aws-batch" target="_blank" rel="noreferrer">handson/aws-batch</a> にある．</p>
<p>本ハンズオンの実行には，第一回ハンズオンで説明した準備 ( (#handson_01_prep)) が整っていることを前提とする． また， Docker が自身のローカルマシンにインストール済みであることも必要である．</p>
<p>このハンズオンは， <code>g4dn.xlarge</code> タイプの EC2 インスタンスを使うので，アメリカ東部 (<code>us-east-1</code>) リージョンでは 0.526 $/hour のコストが発生する． 東京 (<code>ap-northeast-1</code>) を選択した場合は 0.71 $/hour のコストが発生する．</p>
<p>(#sec:jupyter_and_deep_learning_setup) でも注意したが，このハンズオンを始める前に G タイプインスタンスの起動上限を AWS コンソールの EC2 管理画面から確認しよう． もし上限が 0 になっていた場合は，上限緩和の申請を行う必要がある． <a href="#sec:aws_batch_code">アプリケーションの説明</a> にも関連した情報を記載しているので，併せて参照されたい．</p>
<h2 id="mnist-手書き文字認識-再訪" tabindex="-1">MNIST 手書き文字認識 (再訪) <a class="header-anchor" href="#mnist-手書き文字認識-再訪" aria-label="Permalink to &quot;MNIST 手書き文字認識 (再訪)&quot;">&ZeroWidthSpace;</a></h2>
<p>今回のハンズオンでは，機械学習のハイパーパラメータ調整を取り上げると冒頭で述べた． その最もシンプルな例題として， (#sec_mnist_using_jupyter) で扱った MNIST 手書き文字認識の問題を再度取り上げよう． (#sec_mnist_using_jupyter) では，適当にチョイスしたハイパーパラメータを用いてモデルの訓練を行った． ここで使用したプログラムのハイパーパラメータとしては，確率的勾配降下法 (SGD) における学習率やモメンタムが含まれる． コードでいうと，次の行が該当する．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">optimizer </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> optim.SGD(model.parameters(), </span><span style="color: #F69D50">lr</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">0.01</span><span style="color: #ADBAC7">, </span><span style="color: #F69D50">momentum</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">0.5</span><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">optimizer </span><span style="color: #D73A49">=</span><span style="color: #24292E"> optim.SGD(model.parameters(), </span><span style="color: #E36209">lr</span><span style="color: #D73A49">=</span><span style="color: #005CC5">0.01</span><span style="color: #24292E">, </span><span style="color: #E36209">momentum</span><span style="color: #D73A49">=</span><span style="color: #005CC5">0.5</span><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>ここで使用された 学習率 (<code>lr=0.01</code>) やモメンタム (<code>momentum=0.5</code>) は恣意的に選択された値であり，これがベストな数値であるのかはわからない． たまたまこのチョイスが最適であるかもしれないし，もっと高い精度を出すハイパーパラメータの組が存在するかもしれない． この問題に答えるため，ハイパーパラメータサーチを行おう． 今回は，最もシンプルなアプローチとして，<strong>グリッドサーチ</strong>によるハイパーパラメータサーチを行おう．</p>
<p>機械学習のハイパーパラメータの最適化には大きく３つのアプローチが挙げられる． グリッドサーチ，ランダムサーチ，そしてベイズ最適化による方法である．</p>
<p>グリッドサーチとは，ハイパーパラメータの組をある範囲の中で可能な組み合わせをすべて計算し，最適なパラメータの組を見出す方法である． 最もシンプルかつ確実な方法であるが，すべての組み合わせの可能性を愚直に計算するので計算コストが大きい．</p>
<p>ランダムサーチ法とは，ハイパーパラメータの組をある範囲の中でランダムに抽出し，大量に試行されたランダムな組の中から最適なパラメータの組を見出す方法である． すべての可能性を網羅的に探索できるわけではないが，調整すべきパラメータの数が多数ある場合に，グリッドサーチよりも効率的に広い探索空間をカバーすることができる．</p>
<p>ベイズ最適化を用いた方法では，過去の探索結果から次にどの組み合わせを探索すべきかという指標を計算し，次に探索するパラメータを決定する． これにより，理論的にはグリッドサーチやランダムサーチ法よりも少ない試行回数で最適なパラメータにたどり着くことができる．</p>
<p>並列化の観点でいうと，グリッドサーチとランダムサーチは各ハイパーパラメータの組の計算は独立に実行することができるため並列化が容易である． このように独立したジョブとして分割・並列化可能な問題を Embarrassingly parallel な問題とよぶ (直訳すると&quot;恥ずかしいほど並列化可能な問題&quot;，ということになる)． Embarrassingly parallel な問題はクラウドの強力な計算リソースを用いることで，非常なシンプルな実装で解くことができる． この章ではこのようなタイプの並列計算を取り上げる．</p>
<p>一方，ベイズ最適化による方法は，過去の結果をもとに次の探索が決定されるので，並列化はそれほど単純ではない． 最近では <a href="https://optuna.org/" target="_blank" rel="noreferrer">optuna</a> などのハイパーパラメータ探索のためのライブラリが発達しており，ベイズ最適化の数理的な処理を自動で実行してくれるので便利である． これらのライブラリを使うと，もし一台のコンピュータ (ノード) の中に複数の GPU が存在する場合は，並列に計算を実行することができる． しかしながら，一台のノードにとどまらず，複数のノードをまたいだ並列化は，高度なプログラミングテクニックが必要とされるだけでなく，ノード間の接続様式などクラウドのアーキテクチャにも深く依存するものである． 本書ではここまで高度なクラウドの使用方法には立ち入らない．</p>
<p>まずは，本ハンズオンで使用する Docker イメージをローカルで実行してみよう．</p>
<p>Docker イメージのソースコードは <a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/aws-batch/docker" target="_blank" rel="noreferrer">handson/aws-batch/docker</a> にある． 基本的に (#sec_mnist_using_jupyter) のハンズオンを元にし，本ハンズオン専用の軽微な変更が施してある． 興味のある読者はソースコードも含めて読んでいただきたい．</p>
<p>練習として，この Docker イメージを手元でビルドするところからはじめてみよう． <code>Dockerfile</code> が保存されているディレクトリに移動し， <code>mymnist</code> という名前 (Tag) をつけてビルドを実行する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cd</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">handson/aws-batch/docker</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">docker</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">build</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-t</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">mymnist</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cd</span><span style="color: #24292E"> </span><span style="color: #032F62">handson/aws-batch/docker</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">docker</span><span style="color: #24292E"> </span><span style="color: #032F62">build</span><span style="color: #24292E"> </span><span style="color: #005CC5">-t</span><span style="color: #24292E"> </span><span style="color: #032F62">mymnist</span><span style="color: #24292E"> </span><span style="color: #032F62">.</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p><code>docker build</code> でエラーが出たときは次の可能性を疑ってほしい． ビルドの中で， MNIST の画像データセットを <a href="http://yann.lecun.com/exdb/mnist/" target="_blank" rel="noreferrer">http://yann.lecun.com/exdb/mnist/</a> からダウンロードするのだが，ダウンロード先のサーバーがしばしばダウンしている． 世界中の機械学習ユーザーがアクセスするので，これはしばしば発生するようである． サーバーがダウンしているとビルドも失敗してしまう． エラーメッセージにそれらしい文言が含まれていたら，この可能性を疑おう．</p>
<p>手元でビルドするかわりに， Docker Hub から pull することも可能である． その場合は次のコマンドを実行する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">docker</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">pull</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">tomomano/mymnist:latest</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">docker</span><span style="color: #24292E"> </span><span style="color: #032F62">pull</span><span style="color: #24292E"> </span><span style="color: #032F62">tomomano/mymnist:latest</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>イメージの準備ができたら，次のコマンドでコンテナを起動し， MNIST の学習を実行する．．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">docker</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">run</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">mymnist</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--lr</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0.1</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--momentum</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0.5</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--epochs</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">10</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">docker</span><span style="color: #24292E"> </span><span style="color: #032F62">run</span><span style="color: #24292E"> </span><span style="color: #032F62">mymnist</span><span style="color: #24292E"> </span><span style="color: #005CC5">--lr</span><span style="color: #24292E"> </span><span style="color: #005CC5">0.1</span><span style="color: #24292E"> </span><span style="color: #005CC5">--momentum</span><span style="color: #24292E"> </span><span style="color: #005CC5">0.5</span><span style="color: #24292E"> </span><span style="color: #005CC5">--epochs</span><span style="color: #24292E"> </span><span style="color: #005CC5">10</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>このコマンドを実行すると，指定したハイパーパラメータ (<code>--lr</code> で与えられる学習率と <code>--momentum</code> で与えられるモメンタム) を使ってニューラルネットの最適化が始まる． 学習を行う最大のエポック数は <code>--epochs</code> パラメータで指定する． (#sec_jupyter_and_deep_learning) のハンズオンで見たような， Loss の低下がコマンドライン上に出力されるだろう (<a href="#fig_mnist_log_output">figure_title</a>)．</p>
<p><img src="./assets/aws_batch/mnist_log_output.png" alt="Docker を実行した際の出力"></p>
<p>上に示したコマンドを使うと，計算は CPU を使って実行される． もし，ローカルの計算機に GPU が備わっており， <a href="https://github.com/NVIDIA/nvidia-docker" target="_blank" rel="noreferrer">nvidia-docker</a> の設定が済んでいるならば， 次のコマンドにより GPU を使って計算を実行できる．</p>
<pre><code>$ docker run --gpus all mymnist --lr 0.1 --momentum 0.5 --epochs 10
</code></pre>
<p>このコマンドでは，<code>--gpus all</code> というパラメータが加わった．</p>
<p>CPU/GPU どちらで実行した場合でも，エポックを重ねるにつれて訓練データ (Train データ) の Loss は単調に減少していくのが見て取れるだろう． 一方，<strong>検証データ (Validation データ) の Loss および Accuracy は，ある程度まで減少した後，それ以上性能が向上しない</strong>ことに気がつくだろう． これを実際にプロットしてみると <a href="#fig_loss_epoch_profile">figure_title</a> のようになるはずである．</p>
<p><img src="./assets/aws_batch/loss_epoch_profile.png" alt="(左) Train/Validation データそれぞれの Loss のエポックごとの変化． (右) Validation データの Accuracy のエポックごとの変化"></p>
<p>これは<strong>オーバーフィッティング</strong>とよばれる現象で，ニューラルネットが訓練データに過度に最適化され，訓練データの外のデータに対しての精度 (汎化性能) が向上していないことを示している． このような場合の対処法として， <strong>Early stopping</strong> とよばれるテクニックが知られている． Early stopping とは，検証データの Loss を追跡し，それが減少から増加に転じるエポックで学習をうち止め，そのエポックでのウェイトパラメータを採用する，というものである． 本ハンズオンでも， Early stopping によって訓練の終了を判断し，モデルの性能評価を行っていく．</p>
<p>MNIST 手書き文字データセットでは，訓練データとして 60,000 枚，テストデータとして 10,000 枚の画像が与えられている． 本ハンズオンで使用するコードでは，訓練データのうち 80% の 48,000 枚を訓練データとして使用し，残り 20% の 12,000 枚を検証データとして用いている． 詳しくはソースコードを参照のこと．</p>
<h2 id="アプリケーションの説明" tabindex="-1">アプリケーションの説明 <a class="header-anchor" href="#アプリケーションの説明" aria-label="Permalink to &quot;アプリケーションの説明&quot;">&ZeroWidthSpace;</a></h2>
<p>このハンズオンで作成するアプリケーションの概要を <a href="#fig_batch_architecture">figure_title</a> に示す．</p>
<p><img src="./assets/aws_batch/architecture.png" alt="アプリケーションのアーキテクチャ"></p>
<p>簡単にまとめると，次のような設計である．</p>
<ul>
<li>
<p>クライアントは，あるハイパーパラメータの組を指定して Batch にジョブを提出する</p>
</li>
<li>
<p>Batch はジョブを受け取ると， EC2 からなるクラスターで計算を実行する</p>
</li>
<li>
<p>クラスター内では <code>g4dn.xlarge</code> インスタンスが起動する</p>
</li>
<li>
<p>Docker イメージは， AWS 内に用意された ECR (Elastic Container Registry) から取得される</p>
</li>
<li>
<p>複数のジョブが投下された場合は，その数だけのインスタンスが起動し並列に実行される</p>
</li>
<li>
<p>各ジョブによる計算の結果は S3 に保存される</p>
</li>
<li>
<p>最後にクライアントは S3 から結果をダウンロードし，最適なハイパーパラメータの組を決定する</p>
</li>
</ul>
<p>それでは，プログラムのソースコードを見てみよう (<a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/aws-batch/app.py" target="_blank" rel="noreferrer">handson/aws-batch/app.py</a>)．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">class</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50">SimpleBatch</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">core</span><span style="color: #ADBAC7">.</span><span style="color: #6CB6FF">Stack</span><span style="color: #ADBAC7">):</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">def</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">__init__</span><span style="color: #ADBAC7">(self, scope: core.App, name: </span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">, </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">kwargs) -&gt; </span><span style="color: #6CB6FF">None</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #6CB6FF">super</span><span style="color: #ADBAC7">().</span><span style="color: #6CB6FF">__init__</span><span style="color: #ADBAC7">(scope, name, </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">kwargs)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        bucket </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> s3.Bucket(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;bucket&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">removal_policy</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">core.RemovalPolicy.</span><span style="color: #6CB6FF">DESTROY</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">auto_delete_objects</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">True</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        vpc </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ec2.Vpc(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;vpc&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #768390"># other parameters...</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        managed_env </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> batch.ComputeEnvironment(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;managed-env&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">compute_resources</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">batch.ComputeResources(</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">vpc</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">vpc,</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">allocation_strategy</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">batch.AllocationStrategy.</span><span style="color: #6CB6FF">BEST_FIT</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">desiredv_cpus</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">maxv_cpus</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">64</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">minv_cpus</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">instance_types</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">[</span></span>
<span class="line"><span style="color: #ADBAC7">                    ec2.InstanceType(</span><span style="color: #96D0FF">&quot;g4dn.xlarge&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">                ],</span></span>
<span class="line"><span style="color: #ADBAC7">            ),</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">managed</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">True</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">compute_environment_name</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">.stack_name </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;compute-env&quot;</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        job_queue </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> batch.JobQueue(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;job-queue&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">compute_environments</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">[</span></span>
<span class="line"><span style="color: #ADBAC7">                batch.JobQueueComputeEnvironment(</span></span>
<span class="line"><span style="color: #ADBAC7">                    </span><span style="color: #F69D50">compute_environment</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">managed_env,</span></span>
<span class="line"><span style="color: #ADBAC7">                    </span><span style="color: #F69D50">order</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">100</span></span>
<span class="line"><span style="color: #ADBAC7">                )</span></span>
<span class="line"><span style="color: #ADBAC7">            ],</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">job_queue_name</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">.stack_name </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;job-queue&quot;</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        job_role </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> iam.Role(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;job-role&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">assumed_by</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">iam.CompositePrincipal(</span></span>
<span class="line"><span style="color: #ADBAC7">                iam.ServicePrincipal(</span><span style="color: #96D0FF">&quot;ecs-tasks.amazonaws.com&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">            )</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390"># allow read and write access to S3 bucket</span></span>
<span class="line"><span style="color: #ADBAC7">        bucket.grant_read_write(job_role)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        repo </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ecr.Repository(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;repository&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">removal_policy</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">core.RemovalPolicy.</span><span style="color: #6CB6FF">DESTROY</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        job_def </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> batch.JobDefinition(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;job-definition&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">container</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">batch.JobDefinitionContainer(</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">image</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ecs.ContainerImage.from_ecr_repository(repo),</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">command</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">[</span><span style="color: #96D0FF">&quot;python3&quot;</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;main.py&quot;</span><span style="color: #ADBAC7">],</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">vcpus</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">4</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">gpu_count</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">memory_limit_mib</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">12000</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">job_role</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">job_role,</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">environment</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">{</span></span>
<span class="line"><span style="color: #ADBAC7">                    </span><span style="color: #96D0FF">&quot;BUCKET_NAME&quot;</span><span style="color: #ADBAC7">: bucket.bucket_name</span></span>
<span class="line"><span style="color: #ADBAC7">                }</span></span>
<span class="line"><span style="color: #ADBAC7">            ),</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">job_definition_name</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">.stack_name </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;job-definition&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">timeout</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">core.Duration.hours(</span><span style="color: #6CB6FF">2</span><span style="color: #ADBAC7">),</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">class</span><span style="color: #24292E"> </span><span style="color: #6F42C1">SimpleBatch</span><span style="color: #24292E">(</span><span style="color: #6F42C1">core</span><span style="color: #24292E">.</span><span style="color: #6F42C1">Stack</span><span style="color: #24292E">):</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">def</span><span style="color: #24292E"> </span><span style="color: #005CC5">__init__</span><span style="color: #24292E">(self, scope: core.App, name: </span><span style="color: #005CC5">str</span><span style="color: #24292E">, </span><span style="color: #D73A49">**</span><span style="color: #24292E">kwargs) -&gt; </span><span style="color: #005CC5">None</span><span style="color: #24292E">:</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #005CC5">super</span><span style="color: #24292E">().</span><span style="color: #005CC5">__init__</span><span style="color: #24292E">(scope, name, </span><span style="color: #D73A49">**</span><span style="color: #24292E">kwargs)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        bucket </span><span style="color: #D73A49">=</span><span style="color: #24292E"> s3.Bucket(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;bucket&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">removal_policy</span><span style="color: #D73A49">=</span><span style="color: #24292E">core.RemovalPolicy.</span><span style="color: #005CC5">DESTROY</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">auto_delete_objects</span><span style="color: #D73A49">=</span><span style="color: #005CC5">True</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        vpc </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ec2.Vpc(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;vpc&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #6A737D"># other parameters...</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        managed_env </span><span style="color: #D73A49">=</span><span style="color: #24292E"> batch.ComputeEnvironment(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;managed-env&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">compute_resources</span><span style="color: #D73A49">=</span><span style="color: #24292E">batch.ComputeResources(</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">vpc</span><span style="color: #D73A49">=</span><span style="color: #24292E">vpc,</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">allocation_strategy</span><span style="color: #D73A49">=</span><span style="color: #24292E">batch.AllocationStrategy.</span><span style="color: #005CC5">BEST_FIT</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">desiredv_cpus</span><span style="color: #D73A49">=</span><span style="color: #005CC5">0</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">maxv_cpus</span><span style="color: #D73A49">=</span><span style="color: #005CC5">64</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">minv_cpus</span><span style="color: #D73A49">=</span><span style="color: #005CC5">0</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">instance_types</span><span style="color: #D73A49">=</span><span style="color: #24292E">[</span></span>
<span class="line"><span style="color: #24292E">                    ec2.InstanceType(</span><span style="color: #032F62">&quot;g4dn.xlarge&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">                ],</span></span>
<span class="line"><span style="color: #24292E">            ),</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">managed</span><span style="color: #D73A49">=</span><span style="color: #005CC5">True</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">compute_environment_name</span><span style="color: #D73A49">=</span><span style="color: #005CC5">self</span><span style="color: #24292E">.stack_name </span><span style="color: #D73A49">+</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;compute-env&quot;</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        job_queue </span><span style="color: #D73A49">=</span><span style="color: #24292E"> batch.JobQueue(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;job-queue&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">compute_environments</span><span style="color: #D73A49">=</span><span style="color: #24292E">[</span></span>
<span class="line"><span style="color: #24292E">                batch.JobQueueComputeEnvironment(</span></span>
<span class="line"><span style="color: #24292E">                    </span><span style="color: #E36209">compute_environment</span><span style="color: #D73A49">=</span><span style="color: #24292E">managed_env,</span></span>
<span class="line"><span style="color: #24292E">                    </span><span style="color: #E36209">order</span><span style="color: #D73A49">=</span><span style="color: #005CC5">100</span></span>
<span class="line"><span style="color: #24292E">                )</span></span>
<span class="line"><span style="color: #24292E">            ],</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">job_queue_name</span><span style="color: #D73A49">=</span><span style="color: #005CC5">self</span><span style="color: #24292E">.stack_name </span><span style="color: #D73A49">+</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;job-queue&quot;</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        job_role </span><span style="color: #D73A49">=</span><span style="color: #24292E"> iam.Role(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;job-role&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">assumed_by</span><span style="color: #D73A49">=</span><span style="color: #24292E">iam.CompositePrincipal(</span></span>
<span class="line"><span style="color: #24292E">                iam.ServicePrincipal(</span><span style="color: #032F62">&quot;ecs-tasks.amazonaws.com&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">            )</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D"># allow read and write access to S3 bucket</span></span>
<span class="line"><span style="color: #24292E">        bucket.grant_read_write(job_role)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        repo </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ecr.Repository(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;repository&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">removal_policy</span><span style="color: #D73A49">=</span><span style="color: #24292E">core.RemovalPolicy.</span><span style="color: #005CC5">DESTROY</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        job_def </span><span style="color: #D73A49">=</span><span style="color: #24292E"> batch.JobDefinition(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;job-definition&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">container</span><span style="color: #D73A49">=</span><span style="color: #24292E">batch.JobDefinitionContainer(</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">image</span><span style="color: #D73A49">=</span><span style="color: #24292E">ecs.ContainerImage.from_ecr_repository(repo),</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">command</span><span style="color: #D73A49">=</span><span style="color: #24292E">[</span><span style="color: #032F62">&quot;python3&quot;</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;main.py&quot;</span><span style="color: #24292E">],</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">vcpus</span><span style="color: #D73A49">=</span><span style="color: #005CC5">4</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">gpu_count</span><span style="color: #D73A49">=</span><span style="color: #005CC5">1</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">memory_limit_mib</span><span style="color: #D73A49">=</span><span style="color: #005CC5">12000</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">job_role</span><span style="color: #D73A49">=</span><span style="color: #24292E">job_role,</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">environment</span><span style="color: #D73A49">=</span><span style="color: #24292E">{</span></span>
<span class="line"><span style="color: #24292E">                    </span><span style="color: #032F62">&quot;BUCKET_NAME&quot;</span><span style="color: #24292E">: bucket.bucket_name</span></span>
<span class="line"><span style="color: #24292E">                }</span></span>
<span class="line"><span style="color: #24292E">            ),</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">job_definition_name</span><span style="color: #D73A49">=</span><span style="color: #005CC5">self</span><span style="color: #24292E">.stack_name </span><span style="color: #D73A49">+</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;job-definition&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">timeout</span><span style="color: #D73A49">=</span><span style="color: #24292E">core.Duration.hours(</span><span style="color: #005CC5">2</span><span style="color: #24292E">),</span></span>
<span class="line"><span style="color: #24292E">        )</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br><span class="line-number">36</span><br><span class="line-number">37</span><br><span class="line-number">38</span><br><span class="line-number">39</span><br><span class="line-number">40</span><br><span class="line-number">41</span><br><span class="line-number">42</span><br><span class="line-number">43</span><br><span class="line-number">44</span><br><span class="line-number">45</span><br><span class="line-number">46</span><br><span class="line-number">47</span><br><span class="line-number">48</span><br><span class="line-number">49</span><br><span class="line-number">50</span><br><span class="line-number">51</span><br><span class="line-number">52</span><br><span class="line-number">53</span><br><span class="line-number">54</span><br><span class="line-number">55</span><br><span class="line-number">56</span><br><span class="line-number">57</span><br><span class="line-number">58</span><br><span class="line-number">59</span><br><span class="line-number">60</span><br><span class="line-number">61</span><br><span class="line-number">62</span><br><span class="line-number">63</span><br><span class="line-number">64</span><br><span class="line-number">65</span><br><span class="line-number">66</span><br><span class="line-number">67</span><br><span class="line-number">68</span><br><span class="line-number">69</span><br><span class="line-number">70</span><br><span class="line-number">71</span><br><span class="line-number">72</span><br><span class="line-number">73</span><br><span class="line-number">74</span><br><span class="line-number">75</span><br><span class="line-number">76</span><br><span class="line-number">77</span><br><span class="line-number">78</span><br><span class="line-number">79</span><br></div></div><ul>
<li>
<p>で，計算結果を保存するための S3 バケットを用意している</p>
</li>
<li>
<p>で， Compute environment を定義している． ここでは <code>g4dn.xlarge</code> のインスタンスタイプを使用するとし，最大の vCPU 使用数は 64 と指定している． また，最小の vCPU は 0 である． 今回は，負荷がかかっていないときにアイドリング状態にあるインスタンスを用意する利点は全くないので，ここは 0 にするのが望ましい．</p>
</li>
<li>
<p>で， &lt;2&gt; で作成した Compute environment と紐付いた Job queue を定義している．</p>
</li>
<li>
<p>で，ジョブが計算結果を S3 に書き込むことができるよう， IAM ロールを定義している． (IAM とはリソースがもつ権限を管理する仕組みである．詳しくは (#sec:bashoutter_iam) を参照)</p>
</li>
<li>
<p>では， Docker image を配置するための ECR を定義している．</p>
</li>
<li>
<p>で Job definition を作成している． ここでは，4 vCPU， 12000 MB (=12GB) の RAM を使用するように指定している． また，今後必要となる環境変数 (<code>BUCKET_NAME</code>) を設定している． さらに， &lt;4&gt; で作った IAM を付与している．</p>
</li>
</ul>
<p><code>g4dn.xlarge</code> は 1 台あたり 4 vCPU が割り当てられている． このプログラムでは Compute environment の maximum vCPUs を 64 と指定しているので，最大で 16 台のインスタンスが同時に起動することになる． ここで maxium vCPUs を 64 に限定しているのは，なんらかのミスで意図せぬジョブを大量にクラスターに投入してしまった事態で，高額の AWS 利用料金が発生するのを防ぐためである． もし，自分のアプリケーションで必要と判断したならば自己責任において 64 よりも大きな数を設定して構わない．</p>
<p>ここで注意が一点ある． AWS では各アカウントごとに EC2 で起動できるインスタンスの上限が設定されている． この上限は AWS コンソールにログインし， EC2 コンソールの左側メニューバーの <code>Limits</code> をクリックすることで確認できる (<a href="#fig_ec2_limits">figure_title</a>)． <code>g4dn.xlarge</code> (EC2 の区分でいうと G ファミリーに属する) の制限を確認するには， <code>Running On-Demand All G instances</code> という名前の項目を見る． ここにある数字が， AWS によって課されたアカウントの上限であり，この上限を超えたインスタンスを起動することはできない． もし，自分の用途に対して上限が低すぎる場合は，上限の緩和申請を行うことができる． 詳しくは <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-resource-limits.html" target="_blank" rel="noreferrer">公式ドキュメンテーション &quot;Amazon EC2 service quotas&quot;</a> を参照のこと．</p>
<p><img src="./assets/aws_batch/ec2_limits.png" alt="EC2コンソールから各種の上限を確認する"></p>
<h2 id="スタックのデプロイ" tabindex="-1">スタックのデプロイ <a class="header-anchor" href="#スタックのデプロイ" aria-label="Permalink to &quot;スタックのデプロイ&quot;">&ZeroWidthSpace;</a></h2>
<p>スタックの中身が理解できたところで，早速スタックをデプロイしてみよう．</p>
<p>デプロイの手順は，これまでのハンズオンとほとんど共通である． ここでは，コマンドのみ列挙する (# で始まる行はコメントである)． シークレットキーの設定も忘れずに ( (#aws_cli_install))．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390"># プロジェクトのディレクトリに移動</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cd</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">handson/aws-batch</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># venv を作成し，依存ライブラリのインストールを行う</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python3</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-m</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">venv</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.env</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">source</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.env/bin/activate</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">pip</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">install</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-r</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">requirements.txt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># デプロイを実行</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cdk</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">deploy</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D"># プロジェクトのディレクトリに移動</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cd</span><span style="color: #24292E"> </span><span style="color: #032F62">handson/aws-batch</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># venv を作成し，依存ライブラリのインストールを行う</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python3</span><span style="color: #24292E"> </span><span style="color: #005CC5">-m</span><span style="color: #24292E"> </span><span style="color: #032F62">venv</span><span style="color: #24292E"> </span><span style="color: #032F62">.env</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">source</span><span style="color: #24292E"> </span><span style="color: #032F62">.env/bin/activate</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">pip</span><span style="color: #24292E"> </span><span style="color: #032F62">install</span><span style="color: #24292E"> </span><span style="color: #005CC5">-r</span><span style="color: #24292E"> </span><span style="color: #032F62">requirements.txt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># デプロイを実行</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cdk</span><span style="color: #24292E"> </span><span style="color: #032F62">deploy</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br></div></div><p>デプロイのコマンドが無事に実行されたことが確認できたら，AWS コンソールにログインして，デプロイされたスタックを確認してみよう． コンソールの検索バーで <code>batch</code> と入力し， AWS Batch の管理画面を開く (<a href="#fig_batch_console">figure_title</a>)．</p>
<p><img src="./assets/aws_batch/batch_console.png" alt="AWS Batch のコンソール画面 (ダッシュボード)"></p>
<p>まず目を向けてほしいのが，画面の一番下にある Compute environment overview の中の <code>SimpleBatchcompute-env</code> という名前の項目だ． Compute environment とは，先ほど述べたとおり，計算が実行される環境 (クラスターと読み替えてもよい) である． プログラムで指定したとおり， <code>g4dn.xlarge</code> が実際に使用されるインスタンスタイプとして表示されている． また， <code>Minimum vCPUs</code> が 0，<code>Maximum vCPUs</code> が 64 と設定されていることも見て取れる． 加えて，この時点では一つもジョブが走っていないので， <code>Desired vCPUs</code> は 0 になっている． より詳細な Compute environment の情報を閲覧したい場合は，名前をクリックすることで詳細画面が開く．</p>
<p>次に，Job queue overview にある <code>SimpleBatch-queue</code> という項目に注目してほしい． ここでは実行待ちのジョブ・実行中のジョブ・実行が完了したジョブを一覧で確認することができる． <code>PENDING</code>, <code>RUNNING</code>, <code>SUCCEEDED</code>, <code>FAILED</code> などのカラムがあることが確認できる．ジョブが進行するにつれて，ジョブの状態がこのカラムにしたがって遷移していく． 後でジョブを実際にサブミットしたときに戻ってこよう．</p>
<p>最後に，今回作成した Job definition を確認しよう． 左側のメニューから　<code>Job definitions</code> を選択し，次の画面で <code>SimpleBatchjob-definition</code> という項目を見つけて開く． ここから Job definition の詳細を閲覧することができる (<a href="#fig:batch_job_definition">figure_title</a>)． 中でも重要な情報としては，　<code>vCPUs</code>, <code>Memory</code>, <code>GPU</code> がそれぞれ Docker に割り当てられる vCPU・メモリー・ GPU の量を規定している． また， <code>Image</code> と書いてあるところに，ジョブで使用される Docker イメージが指定されている． ここでは， ECR のレポジトリを参照している． 現時点ではこの ECR は空である． 次のステップとして，この ECR にイメージを配置する作業を行おう．</p>
<p><img src="./assets/aws_batch/batch_job_definition.png" alt="AWS Batch から Job definition を確認"></p>
<h2 id="docker-image-を-ecr-に配置する" tabindex="-1">Docker image を ECR に配置する <a class="header-anchor" href="#docker-image-を-ecr-に配置する" aria-label="Permalink to &quot;Docker image を ECR に配置する&quot;">&ZeroWidthSpace;</a></h2>
<p>さて， Batch がジョブを実行するには，どこか指定された場所から Docker イメージをダウンロード (pull) してくる必要がある． 前回のハンズオン ( (#sec_fargate_qabot)) では，公開設定にしてある Docker Hub からイメージを pull してきた． 今回のハンズオンでは， AWS から提供されているレジストリである <strong>ECR (Elastic Container Registry)</strong> に image を配置するという設計を採用する． ECR を利用する利点は，自分だけがアクセスすることのできるプライベートなイメージの置き場所を用意できる点である． Batch は ECR からイメージを pull してくることで，タスクを実行する (<a href="#fig_batch_architecture">figure_title</a>)．</p>
<p>スタックのソースコードでいうと，次の箇所が ECR を定義している．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">repo </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ecr.Repository(</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;repository&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">removal_policy</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">core.RemovalPolicy.</span><span style="color: #6CB6FF">DESTROY</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">job_def </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> batch.JobDefinition(</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;job-definition&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">container</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">batch.JobDefinitionContainer(</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #F69D50">image</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ecs.ContainerImage.from_ecr_repository(repo), </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #6CB6FF">...</span></span>
<span class="line"><span style="color: #ADBAC7">    ),</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">...</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">repo </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ecr.Repository(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;repository&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">removal_policy</span><span style="color: #D73A49">=</span><span style="color: #24292E">core.RemovalPolicy.</span><span style="color: #005CC5">DESTROY</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">job_def </span><span style="color: #D73A49">=</span><span style="color: #24292E"> batch.JobDefinition(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;job-definition&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">container</span><span style="color: #D73A49">=</span><span style="color: #24292E">batch.JobDefinitionContainer(</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #E36209">image</span><span style="color: #D73A49">=</span><span style="color: #24292E">ecs.ContainerImage.from_ecr_repository(repo), </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #005CC5">...</span></span>
<span class="line"><span style="color: #24292E">    ),</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">...</span></span>
<span class="line"><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br></div></div><ul>
<li>
<p>で，新規の ECR を作成している．</p>
</li>
<li>
<p>で Job definition を定義する中で，イメージを &lt;1&gt; で作った ECR から取得するように指定している． これと同時に， Job definition には ECR へのアクセス権限が IAM を通じて自動的に付与される．</p>
</li>
</ul>
<p>さて，スタックをデプロイした時点では， ECR は空っぽである． ここに自分のアプリケーションで使う Docker イメージを push してあげる必要がある．</p>
<p>そのために，まずは AWS コンソールから ECR の画面を開こう (検索バーに <code>Elastic Container Registry</code> と入力すると出てくる)． <code>Private</code> というタブを選択すると， <code>simplebatch-repositoryXXXXXX</code> という名前のレポジトリが見つかるだろう (<a href="#fig_ecr_console1">figure_title</a>)．</p>
<p><img src="./assets/aws_batch/ecr_console1.png" alt="ECR のコンソール画面"></p>
<p>次に，このレポジトリの名前をクリックするとレポジトリの詳細画面に遷移する． そうしたら，画面右上にある <code>View push commands</code> というボタンをクリックする． すると <a href="#fig_ecr_push_command">figure_title</a> のようなポップアップ画面が立ち上がる．</p>
<p><img src="./assets/aws_batch/ecr_push_command.png" alt="ECR への push コマンド"></p>
<p>このポップアップ画面で表示されている四つのコマンドを順番に実行していくことで，手元の Docker イメージを ECR に push することができる． <strong>push を実行する前に， AWS の認証情報が設定されている</strong>ことを確認しよう． そのうえで，ハンズオンのソースコードの中にある <strong><code>docker/</code> という名前のディレクトリに移動</strong>する． そうしたら，ポップアップ画面で表示されたコマンドを上から順に実行していく．</p>
<p>ポップアップで表示されるコマンドの 2 つめを見てみると <code>docker build -t XXXXX .</code> となっている． 最後の <code>.</code> が重要で，これは <em>現在のディレクトリにある Dockerfile を使ってイメージをビルドせよ</em> という意味である． このような理由で， <code>Dockerfile</code> が置いてあるディレクトリに移動する必要がある．</p>
<p>四つ目のコマンドは，数 GB あるイメージを ECR にアップロードするので少し時間がかかるかもしれないが，これが完了するとめでたくイメージが ECR に配置されたことになる． もう一度 ECR のコンソールを見てみると，確かにイメージが配置されていることが確認できる (<a href="#fig_ecr_console2">figure_title</a>)． これで，AWS Batch を使ってジョブを実行させるための最後の準備が完了した．</p>
<p><img src="./assets/aws_batch/ecr_console2.png" alt="ECR へ image の配置が完了した"></p>
<h2 id="単一のジョブを実行する" tabindex="-1">単一のジョブを実行する <a class="header-anchor" href="#単一のジョブを実行する" aria-label="Permalink to &quot;単一のジョブを実行する&quot;">&ZeroWidthSpace;</a></h2>
<p>さて，ここからは実際に AWS Batch にジョブを投入する方法を見ていこう．</p>
<p>ハンズオンのディレクトリの <code>notebook/</code> というディレクトリの中に， <a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/aws-batch/notebook/run_single.ipynb" target="_blank" rel="noreferrer">run_single.ipynb</a> というファイルが見つかるはずである (<code>.ipynb</code> は Jupyter notebook のファイル形式)． これを Jupyter notebook から開こう．</p>
<p>今回のハンズオンでは， <code>venv</code> による仮想環境の中に Jupyter notebook もインストール済みである． なので，ローカルマシンから以下のコマンドで Jupyter notebook を立ち上げる．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390"># .env の仮想環境にいることを確認</span></span>
<span class="line"><span style="color: #ADBAC7">(</span><span style="color: #F69D50">.env</span><span style="color: #ADBAC7">) $ cd notebook</span></span>
<span class="line"><span style="color: #ADBAC7">(</span><span style="color: #F69D50">.env</span><span style="color: #ADBAC7">) $ jupyter notebook</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D"># .env の仮想環境にいることを確認</span></span>
<span class="line"><span style="color: #24292E">(</span><span style="color: #6F42C1">.env</span><span style="color: #24292E">) $ cd notebook</span></span>
<span class="line"><span style="color: #24292E">(</span><span style="color: #6F42C1">.env</span><span style="color: #24292E">) $ jupyter notebook</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><p>Jupyter notebook が起動したら， <code>run_single.ipynb</code> を開く．</p>
<p>最初の [1], [2], [3] 番のセルは，ジョブをサブミットするための関数 (<code>submit_job()</code>) を定義している．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390"># [1]</span></span>
<span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> boto3</span></span>
<span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> argparse</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># [2]</span></span>
<span class="line"><span style="color: #768390"># AWS 認証ヘルパー ...省略...</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># [3]</span></span>
<span class="line"><span style="color: #F47067">def</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">submit_job</span><span style="color: #ADBAC7">(lr:</span><span style="color: #6CB6FF">float</span><span style="color: #ADBAC7">, momentum:</span><span style="color: #6CB6FF">float</span><span style="color: #ADBAC7">, epochs:</span><span style="color: #6CB6FF">int</span><span style="color: #ADBAC7">, profile_name</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;default&quot;</span><span style="color: #ADBAC7">):</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> profile_name </span><span style="color: #F47067">is</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">None</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">        session </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> boto3.Session()</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">else</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">        session </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> boto3.Session(</span><span style="color: #F69D50">profile_name</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">profile_name)</span></span>
<span class="line"><span style="color: #ADBAC7">    client </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> session.client(</span><span style="color: #96D0FF">&quot;batch&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    title </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;lr&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">(lr).replace(</span><span style="color: #96D0FF">&quot;.&quot;</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;&quot;</span><span style="color: #ADBAC7">) </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;_m&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">(momentum).replace(</span><span style="color: #96D0FF">&quot;.&quot;</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">    resp </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> client.submit_job(</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #F69D50">jobName</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">title,</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #F69D50">jobQueue</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;SimpleBatchjob-queue&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #F69D50">jobDefinition</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;SimpleBatchjob-definition&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #F69D50">containerOverrides</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">{</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #96D0FF">&quot;command&quot;</span><span style="color: #ADBAC7">: [</span><span style="color: #96D0FF">&quot;--lr&quot;</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">(lr),</span></span>
<span class="line"><span style="color: #ADBAC7">                        </span><span style="color: #96D0FF">&quot;--momentum&quot;</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">(momentum),</span></span>
<span class="line"><span style="color: #ADBAC7">                        </span><span style="color: #96D0FF">&quot;--epochs&quot;</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">(epochs),</span></span>
<span class="line"><span style="color: #ADBAC7">                        </span><span style="color: #96D0FF">&quot;--uploadS3&quot;</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;true&quot;</span><span style="color: #ADBAC7">]</span></span>
<span class="line"><span style="color: #ADBAC7">        }</span></span>
<span class="line"><span style="color: #ADBAC7">    )</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">print</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;Job submitted!&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">print</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;job name&quot;</span><span style="color: #ADBAC7">, resp[</span><span style="color: #96D0FF">&quot;jobName&quot;</span><span style="color: #ADBAC7">], </span><span style="color: #96D0FF">&quot;job ID&quot;</span><span style="color: #ADBAC7">, resp[</span><span style="color: #96D0FF">&quot;jobId&quot;</span><span style="color: #ADBAC7">])</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D"># [1]</span></span>
<span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> boto3</span></span>
<span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> argparse</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># [2]</span></span>
<span class="line"><span style="color: #6A737D"># AWS 認証ヘルパー ...省略...</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># [3]</span></span>
<span class="line"><span style="color: #D73A49">def</span><span style="color: #24292E"> </span><span style="color: #6F42C1">submit_job</span><span style="color: #24292E">(lr:</span><span style="color: #005CC5">float</span><span style="color: #24292E">, momentum:</span><span style="color: #005CC5">float</span><span style="color: #24292E">, epochs:</span><span style="color: #005CC5">int</span><span style="color: #24292E">, profile_name</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;default&quot;</span><span style="color: #24292E">):</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">if</span><span style="color: #24292E"> profile_name </span><span style="color: #D73A49">is</span><span style="color: #24292E"> </span><span style="color: #005CC5">None</span><span style="color: #24292E">:</span></span>
<span class="line"><span style="color: #24292E">        session </span><span style="color: #D73A49">=</span><span style="color: #24292E"> boto3.Session()</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">else</span><span style="color: #24292E">:</span></span>
<span class="line"><span style="color: #24292E">        session </span><span style="color: #D73A49">=</span><span style="color: #24292E"> boto3.Session(</span><span style="color: #E36209">profile_name</span><span style="color: #D73A49">=</span><span style="color: #24292E">profile_name)</span></span>
<span class="line"><span style="color: #24292E">    client </span><span style="color: #D73A49">=</span><span style="color: #24292E"> session.client(</span><span style="color: #032F62">&quot;batch&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">    title </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;lr&quot;</span><span style="color: #24292E"> </span><span style="color: #D73A49">+</span><span style="color: #24292E"> </span><span style="color: #005CC5">str</span><span style="color: #24292E">(lr).replace(</span><span style="color: #032F62">&quot;.&quot;</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;&quot;</span><span style="color: #24292E">) </span><span style="color: #D73A49">+</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;_m&quot;</span><span style="color: #24292E"> </span><span style="color: #D73A49">+</span><span style="color: #24292E"> </span><span style="color: #005CC5">str</span><span style="color: #24292E">(momentum).replace(</span><span style="color: #032F62">&quot;.&quot;</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">    resp </span><span style="color: #D73A49">=</span><span style="color: #24292E"> client.submit_job(</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #E36209">jobName</span><span style="color: #D73A49">=</span><span style="color: #24292E">title,</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #E36209">jobQueue</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;SimpleBatchjob-queue&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #E36209">jobDefinition</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;SimpleBatchjob-definition&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #E36209">containerOverrides</span><span style="color: #D73A49">=</span><span style="color: #24292E">{</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #032F62">&quot;command&quot;</span><span style="color: #24292E">: [</span><span style="color: #032F62">&quot;--lr&quot;</span><span style="color: #24292E">, </span><span style="color: #005CC5">str</span><span style="color: #24292E">(lr),</span></span>
<span class="line"><span style="color: #24292E">                        </span><span style="color: #032F62">&quot;--momentum&quot;</span><span style="color: #24292E">, </span><span style="color: #005CC5">str</span><span style="color: #24292E">(momentum),</span></span>
<span class="line"><span style="color: #24292E">                        </span><span style="color: #032F62">&quot;--epochs&quot;</span><span style="color: #24292E">, </span><span style="color: #005CC5">str</span><span style="color: #24292E">(epochs),</span></span>
<span class="line"><span style="color: #24292E">                        </span><span style="color: #032F62">&quot;--uploadS3&quot;</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;true&quot;</span><span style="color: #24292E">]</span></span>
<span class="line"><span style="color: #24292E">        }</span></span>
<span class="line"><span style="color: #24292E">    )</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">print</span><span style="color: #24292E">(</span><span style="color: #032F62">&quot;Job submitted!&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">print</span><span style="color: #24292E">(</span><span style="color: #032F62">&quot;job name&quot;</span><span style="color: #24292E">, resp[</span><span style="color: #032F62">&quot;jobName&quot;</span><span style="color: #24292E">], </span><span style="color: #032F62">&quot;job ID&quot;</span><span style="color: #24292E">, resp[</span><span style="color: #032F62">&quot;jobId&quot;</span><span style="color: #24292E">])</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br></div></div><p><code>submit_job()</code> 関数について簡単に説明しよう． <a href="#sec_run_mnist_docker_local">MNIST 手書き文字認識 (再訪)</a> で， MNIST の Docker をローカルで実行したとき，次のようなコマンドを使用した．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">docker</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">run</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-it</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">mymnist</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--lr</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0.1</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--momentum</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0.5</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--epochs</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">10</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">docker</span><span style="color: #24292E"> </span><span style="color: #032F62">run</span><span style="color: #24292E"> </span><span style="color: #005CC5">-it</span><span style="color: #24292E"> </span><span style="color: #032F62">mymnist</span><span style="color: #24292E"> </span><span style="color: #005CC5">--lr</span><span style="color: #24292E"> </span><span style="color: #005CC5">0.1</span><span style="color: #24292E"> </span><span style="color: #005CC5">--momentum</span><span style="color: #24292E"> </span><span style="color: #005CC5">0.5</span><span style="color: #24292E"> </span><span style="color: #005CC5">--epochs</span><span style="color: #24292E"> </span><span style="color: #005CC5">10</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>ここで， <code>--lr 0.1 --momentum 0.5 --epochs 10</code> の部分が，コンテナに渡されるコマンドである．</p>
<p>AWS Batch でジョブを実行する際も，<code>ContainerOverrides</code> の <code>command</code> というパラメータを使用することで，コンテナに渡されるコマンドを指定することができる． コードでは以下の部分が該当する．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">containerOverrides</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">{</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #96D0FF">&quot;command&quot;</span><span style="color: #ADBAC7">: [</span><span style="color: #96D0FF">&quot;--lr&quot;</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">(lr),</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #96D0FF">&quot;--momentum&quot;</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">(momentum),</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #96D0FF">&quot;--epochs&quot;</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">(epochs),</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #96D0FF">&quot;--uploadS3&quot;</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;true&quot;</span><span style="color: #ADBAC7">]</span></span>
<span class="line"><span style="color: #ADBAC7">}</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">containerOverrides</span><span style="color: #D73A49">=</span><span style="color: #24292E">{</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #032F62">&quot;command&quot;</span><span style="color: #24292E">: [</span><span style="color: #032F62">&quot;--lr&quot;</span><span style="color: #24292E">, </span><span style="color: #005CC5">str</span><span style="color: #24292E">(lr),</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #032F62">&quot;--momentum&quot;</span><span style="color: #24292E">, </span><span style="color: #005CC5">str</span><span style="color: #24292E">(momentum),</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #032F62">&quot;--epochs&quot;</span><span style="color: #24292E">, </span><span style="color: #005CC5">str</span><span style="color: #24292E">(epochs),</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #032F62">&quot;--uploadS3&quot;</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;true&quot;</span><span style="color: #24292E">]</span></span>
<span class="line"><span style="color: #24292E">}</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br></div></div><p>続いて， [4] 番のセルに移ろう． ここでは，上記の <code>submit_job()</code> 関数を用いて， 学習率 = 0.01, モメンタム=0.1, エポック数=100 を指定したジョブを投入する．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390"># [4]</span></span>
<span class="line"><span style="color: #ADBAC7">submit_job(</span><span style="color: #6CB6FF">0.01</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">0.1</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">100</span><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D"># [4]</span></span>
<span class="line"><span style="color: #24292E">submit_job(</span><span style="color: #005CC5">0.01</span><span style="color: #24292E">, </span><span style="color: #005CC5">0.1</span><span style="color: #24292E">, </span><span style="color: #005CC5">100</span><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>AWS の認証情報は， Jupyter Notebook の内部から再度定義する必要がある． これを手助けするため， Notebook の [2] 番のセル (デフォルトではすべてコメントアウトされている) を用意した． これを使うにはコメントアウトを解除すればよい． このセルを実行すると， AWS の認証情報を入力する対話的なプロンプトが表示される． プロンプトに従って aws secret key などを入力することで， (Jupyter のセッションに固有な) 環境変数に AWS の認証情報が記録される．</p>
<p>もう一つの認証方法として， <code>submit_job()</code> 関数に <code>profile_name</code> というパラメータを用意した． もし <code>~/.aws/credentials</code> に認証情報が書き込まれているのならば (詳しくは (#aws_cli_install))， <code>profile_name</code> に使用したいプロファイルの名前を渡すだけで， 認証を行うことができる． 慣れている読者は後者のほうが便利であると感じるだろう．</p>
<p>[4] 番のセルを実行したら，ジョブが実際に投入されたかどうかを AWS コンソールから確認してみよう． AWS Batch の管理コンソールを開くと， <a href="#fig_batch_running_job">figure_title</a> のような画面が表示されるだろう．</p>
<p><img src="./assets/aws_batch/batch_running_job.png" alt="AWS Batch でジョブが実行されている様子"></p>
<p><a href="#fig_batch_running_job">figure_title</a> で赤で囲った箇所に注目してほしい． 一つのジョブが投入されると，それは <code>SUBMITTED</code> という状態を経て <code>RUNNABLE</code> という状態に遷移する． <code>RUNNABLE</code> とは， ジョブを実行するためのインスタンスが Compute environment に不足しているため，新たなインスタンスが起動されるのを待っている状態に相当する． インスタンスの準備が整うと，ジョブの状態は <code>STARTING</code> を経て <code>RUNNING</code> に至る．</p>
<p>次に，ジョブのステータスが <code>RUNNING</code> のときの Compute environment の <code>Desired vCPU</code> を見てみよう (<a href="#fig_batch_running_job">figure_title</a> で紫で囲った箇所)． ここで 4 と表示されているのは， <code>g4dn.xlarge</code> インスタンス一つ分の vCPU の数である． ジョブの投入に応じて，それを実行するのに最低限必要な EC2 インスタンスが起動されたことが確認できる (興味のある人は， EC2 コンソールも同時に覗いてみるとよい)．</p>
<p>しばらく経つと，ジョブの状態は <code>RUNNING</code> から <code>SUCCEEDED</code> (あるいは何らかの理由でエラーが発生したときには <code>FAILED</code>) に遷移する． 今回のハンズオンで使っている MNIST の学習はだいたい 10 分くらいで完了するはずである． ジョブの状態が <code>SUCCEEDED</code> になるまで見届けよう．</p>
<p>ジョブが完了すると，学習の結果 (エポックごとの Loss と Accuracy を記録した CSV ファイル) は S3 に保存される． AWS コンソールからこれを確認しよう．</p>
<p>S3 のコンソールに行くと <code>simplebatch-bucketXXXX</code> (XXXX の部分はユーザーによって異なる) という名前のバケットが見つかるはずである． これをクリックして中身を見てみると， <code>metrics_lr0.0100_m0.1000.csv</code> という名前の CSV があることが確認できるだろう (<a href="#fig_s3_saved_file">figure_title</a>)． これが， 学習率 = 0.01, モメンタム = 0.1 として学習を行ったときの結果である．</p>
<p><img src="./assets/aws_batch/s3_saved_file.png" alt="ジョブの実行結果は S3 に保存される"></p>
<p>さて，ここで <code>run_single.ipynb</code> に戻ってこよう． [5] から [7] 番のセルでは，学習結果の CSV ファイルのダウンロードを行っている．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390"># [5]</span></span>
<span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> pandas </span><span style="color: #F47067">as</span><span style="color: #ADBAC7"> pd</span></span>
<span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> io</span></span>
<span class="line"><span style="color: #F47067">from</span><span style="color: #ADBAC7"> matplotlib </span><span style="color: #F47067">import</span><span style="color: #ADBAC7"> pyplot </span><span style="color: #F47067">as</span><span style="color: #ADBAC7"> plt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># [6]</span></span>
<span class="line"><span style="color: #F47067">def</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">read_table_from_s3</span><span style="color: #ADBAC7">(bucket_name, key, profile_name</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">None</span><span style="color: #ADBAC7">):</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> profile_name </span><span style="color: #F47067">is</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">None</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">        session </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> boto3.Session()</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">else</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">        session </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> boto3.Session(</span><span style="color: #F69D50">profile_name</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">profile_name)</span></span>
<span class="line"><span style="color: #ADBAC7">    s3 </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> session.resource(</span><span style="color: #96D0FF">&quot;s3&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">    bucket </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> s3.Bucket(bucket_name)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    obj </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> bucket.Object(key).get().get(</span><span style="color: #96D0FF">&quot;Body&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">    df </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> pd.read_csv(obj)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">return</span><span style="color: #ADBAC7"> df</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># [7]</span></span>
<span class="line"><span style="color: #ADBAC7">bucket_name </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;simplebatch-bucket43879c71-mbqaltx441fu&quot;</span></span>
<span class="line"><span style="color: #ADBAC7">df </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> read_table_from_s3(</span></span>
<span class="line"><span style="color: #ADBAC7">    bucket_name,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #96D0FF">&quot;metrics_lr0.0100_m0.1000.csv&quot;</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D"># [5]</span></span>
<span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> pandas </span><span style="color: #D73A49">as</span><span style="color: #24292E"> pd</span></span>
<span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> io</span></span>
<span class="line"><span style="color: #D73A49">from</span><span style="color: #24292E"> matplotlib </span><span style="color: #D73A49">import</span><span style="color: #24292E"> pyplot </span><span style="color: #D73A49">as</span><span style="color: #24292E"> plt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># [6]</span></span>
<span class="line"><span style="color: #D73A49">def</span><span style="color: #24292E"> </span><span style="color: #6F42C1">read_table_from_s3</span><span style="color: #24292E">(bucket_name, key, profile_name</span><span style="color: #D73A49">=</span><span style="color: #005CC5">None</span><span style="color: #24292E">):</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">if</span><span style="color: #24292E"> profile_name </span><span style="color: #D73A49">is</span><span style="color: #24292E"> </span><span style="color: #005CC5">None</span><span style="color: #24292E">:</span></span>
<span class="line"><span style="color: #24292E">        session </span><span style="color: #D73A49">=</span><span style="color: #24292E"> boto3.Session()</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">else</span><span style="color: #24292E">:</span></span>
<span class="line"><span style="color: #24292E">        session </span><span style="color: #D73A49">=</span><span style="color: #24292E"> boto3.Session(</span><span style="color: #E36209">profile_name</span><span style="color: #D73A49">=</span><span style="color: #24292E">profile_name)</span></span>
<span class="line"><span style="color: #24292E">    s3 </span><span style="color: #D73A49">=</span><span style="color: #24292E"> session.resource(</span><span style="color: #032F62">&quot;s3&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">    bucket </span><span style="color: #D73A49">=</span><span style="color: #24292E"> s3.Bucket(bucket_name)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">    obj </span><span style="color: #D73A49">=</span><span style="color: #24292E"> bucket.Object(key).get().get(</span><span style="color: #032F62">&quot;Body&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">    df </span><span style="color: #D73A49">=</span><span style="color: #24292E"> pd.read_csv(obj)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">return</span><span style="color: #24292E"> df</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># [7]</span></span>
<span class="line"><span style="color: #24292E">bucket_name </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;simplebatch-bucket43879c71-mbqaltx441fu&quot;</span></span>
<span class="line"><span style="color: #24292E">df </span><span style="color: #D73A49">=</span><span style="color: #24292E"> read_table_from_s3(</span></span>
<span class="line"><span style="color: #24292E">    bucket_name,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #032F62">&quot;metrics_lr0.0100_m0.1000.csv&quot;</span></span>
<span class="line"><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br></div></div><p>[6] で S3 から CSV データをダウンロードし， pandas の <code>DataFrame</code> オブジェクトとしてロードする関数を定義している． [7] を実行する際， <code>bucket_name</code> という変数の値を，<strong>自分自身のバケットの名前に置き換える</strong>ことに注意しよう (先ほど S3 コンソールから確認した <code>simplebatch-bucketXXXX</code> のことである)．</p>
<p>続いて， [9] 番のセルで， CSV のデータをプロットしている (<a href="#fig_loss_epoch_profile2">figure_title</a>)． ローカルで実行したときと同じように， AWS Batch を用いて MNIST モデルを訓練することに成功した！</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390"># [9]</span></span>
<span class="line"><span style="color: #ADBAC7">fig, (ax1, ax2) </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> plt.subplots(</span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">2</span><span style="color: #ADBAC7">, </span><span style="color: #F69D50">figsize</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">9</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">4</span><span style="color: #ADBAC7">))</span></span>
<span class="line"><span style="color: #ADBAC7">x </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> [i </span><span style="color: #F47067">for</span><span style="color: #ADBAC7"> i </span><span style="color: #F47067">in</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">range</span><span style="color: #ADBAC7">(df.shape[</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">])]</span></span>
<span class="line"><span style="color: #ADBAC7">ax1.plot(x, df[</span><span style="color: #96D0FF">&quot;train_loss&quot;</span><span style="color: #ADBAC7">], </span><span style="color: #F69D50">label</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;Train&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">ax1.plot(x, df[</span><span style="color: #96D0FF">&quot;val_loss&quot;</span><span style="color: #ADBAC7">], </span><span style="color: #F69D50">label</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;Val&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">ax2.plot(x, df[</span><span style="color: #96D0FF">&quot;val_accuracy&quot;</span><span style="color: #ADBAC7">])</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">ax1.set_xlabel(</span><span style="color: #96D0FF">&quot;Epochs&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">ax1.set_ylabel(</span><span style="color: #96D0FF">&quot;Loss&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">ax1.legend()</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">ax2.set_xlabel(</span><span style="color: #96D0FF">&quot;Epochs&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">ax2.set_ylabel(</span><span style="color: #96D0FF">&quot;Accuracy&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6CB6FF">print</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;Best loss:&quot;</span><span style="color: #ADBAC7">, df[</span><span style="color: #96D0FF">&quot;val_loss&quot;</span><span style="color: #ADBAC7">].min())</span></span>
<span class="line"><span style="color: #6CB6FF">print</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;Best loss epoch:&quot;</span><span style="color: #ADBAC7">, df[</span><span style="color: #96D0FF">&quot;val_loss&quot;</span><span style="color: #ADBAC7">].argmin())</span></span>
<span class="line"><span style="color: #6CB6FF">print</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;Best accuracy:&quot;</span><span style="color: #ADBAC7">, df[</span><span style="color: #96D0FF">&quot;val_accuracy&quot;</span><span style="color: #ADBAC7">].max())</span></span>
<span class="line"><span style="color: #6CB6FF">print</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;Best accuracy epoch:&quot;</span><span style="color: #ADBAC7">, df[</span><span style="color: #96D0FF">&quot;val_accuracy&quot;</span><span style="color: #ADBAC7">].argmax())</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D"># [9]</span></span>
<span class="line"><span style="color: #24292E">fig, (ax1, ax2) </span><span style="color: #D73A49">=</span><span style="color: #24292E"> plt.subplots(</span><span style="color: #005CC5">1</span><span style="color: #24292E">,</span><span style="color: #005CC5">2</span><span style="color: #24292E">, </span><span style="color: #E36209">figsize</span><span style="color: #D73A49">=</span><span style="color: #24292E">(</span><span style="color: #005CC5">9</span><span style="color: #24292E">,</span><span style="color: #005CC5">4</span><span style="color: #24292E">))</span></span>
<span class="line"><span style="color: #24292E">x </span><span style="color: #D73A49">=</span><span style="color: #24292E"> [i </span><span style="color: #D73A49">for</span><span style="color: #24292E"> i </span><span style="color: #D73A49">in</span><span style="color: #24292E"> </span><span style="color: #005CC5">range</span><span style="color: #24292E">(df.shape[</span><span style="color: #005CC5">0</span><span style="color: #24292E">])]</span></span>
<span class="line"><span style="color: #24292E">ax1.plot(x, df[</span><span style="color: #032F62">&quot;train_loss&quot;</span><span style="color: #24292E">], </span><span style="color: #E36209">label</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;Train&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">ax1.plot(x, df[</span><span style="color: #032F62">&quot;val_loss&quot;</span><span style="color: #24292E">], </span><span style="color: #E36209">label</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;Val&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">ax2.plot(x, df[</span><span style="color: #032F62">&quot;val_accuracy&quot;</span><span style="color: #24292E">])</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">ax1.set_xlabel(</span><span style="color: #032F62">&quot;Epochs&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">ax1.set_ylabel(</span><span style="color: #032F62">&quot;Loss&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">ax1.legend()</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">ax2.set_xlabel(</span><span style="color: #032F62">&quot;Epochs&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">ax2.set_ylabel(</span><span style="color: #032F62">&quot;Accuracy&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #005CC5">print</span><span style="color: #24292E">(</span><span style="color: #032F62">&quot;Best loss:&quot;</span><span style="color: #24292E">, df[</span><span style="color: #032F62">&quot;val_loss&quot;</span><span style="color: #24292E">].min())</span></span>
<span class="line"><span style="color: #005CC5">print</span><span style="color: #24292E">(</span><span style="color: #032F62">&quot;Best loss epoch:&quot;</span><span style="color: #24292E">, df[</span><span style="color: #032F62">&quot;val_loss&quot;</span><span style="color: #24292E">].argmin())</span></span>
<span class="line"><span style="color: #005CC5">print</span><span style="color: #24292E">(</span><span style="color: #032F62">&quot;Best accuracy:&quot;</span><span style="color: #24292E">, df[</span><span style="color: #032F62">&quot;val_accuracy&quot;</span><span style="color: #24292E">].max())</span></span>
<span class="line"><span style="color: #005CC5">print</span><span style="color: #24292E">(</span><span style="color: #032F62">&quot;Best accuracy epoch:&quot;</span><span style="color: #24292E">, df[</span><span style="color: #032F62">&quot;val_accuracy&quot;</span><span style="color: #24292E">].argmax())</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br></div></div><p><img src="./assets/aws_batch/loss_epoch_profile2.png" alt="AWS Batch で行った MNIST モデルの学習の結果"></p>
<h2 id="並列に複数の-job-を実行する" tabindex="-1">並列に複数の Job を実行する <a class="header-anchor" href="#並列に複数の-job-を実行する" aria-label="Permalink to &quot;並列に複数の Job を実行する&quot;">&ZeroWidthSpace;</a></h2>
<p>さて，ここからが最後の仕上げである． ここまでのハンズオンで構築した AWS Batch のシステムを使って，ハイパーパラメータサーチを実際に行おう．</p>
<p>先ほど実行した <code>run_single.ipynb</code> と同じディレクトリにある <code>run_sweep.ipynb</code> を開く．</p>
<p>セル [1], [2], [3] は <code>run_single.ipynb</code> と同一である．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390"># [1]</span></span>
<span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> boto3</span></span>
<span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> argparse</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># [2]</span></span>
<span class="line"><span style="color: #768390"># AWS 認証ヘルパー ...省略...</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># [3]</span></span>
<span class="line"><span style="color: #F47067">def</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">submit_job</span><span style="color: #ADBAC7">(lr:</span><span style="color: #6CB6FF">float</span><span style="color: #ADBAC7">, momentum:</span><span style="color: #6CB6FF">float</span><span style="color: #ADBAC7">, epochs:</span><span style="color: #6CB6FF">int</span><span style="color: #ADBAC7">, profile_name</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">None</span><span style="color: #ADBAC7">):</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #768390"># ...省略...</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D"># [1]</span></span>
<span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> boto3</span></span>
<span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> argparse</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># [2]</span></span>
<span class="line"><span style="color: #6A737D"># AWS 認証ヘルパー ...省略...</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># [3]</span></span>
<span class="line"><span style="color: #D73A49">def</span><span style="color: #24292E"> </span><span style="color: #6F42C1">submit_job</span><span style="color: #24292E">(lr:</span><span style="color: #005CC5">float</span><span style="color: #24292E">, momentum:</span><span style="color: #005CC5">float</span><span style="color: #24292E">, epochs:</span><span style="color: #005CC5">int</span><span style="color: #24292E">, profile_name</span><span style="color: #D73A49">=</span><span style="color: #005CC5">None</span><span style="color: #24292E">):</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #6A737D"># ...省略...</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br></div></div><p>セル [4] の for ループを使って，グリッド状にハイパーパラメータの組み合わせを用意し， batch にジョブを投入している． ここでは 3x3=9 個のジョブを作成した．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390"># [4]</span></span>
<span class="line"><span style="color: #F47067">for</span><span style="color: #ADBAC7"> lr </span><span style="color: #F47067">in</span><span style="color: #ADBAC7"> [</span><span style="color: #6CB6FF">0.1</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">0.01</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">0.001</span><span style="color: #ADBAC7">]:</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">for</span><span style="color: #ADBAC7"> m </span><span style="color: #F47067">in</span><span style="color: #ADBAC7"> [</span><span style="color: #6CB6FF">0.5</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">0.1</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">0.05</span><span style="color: #ADBAC7">]:</span></span>
<span class="line"><span style="color: #ADBAC7">        submit_job(lr, m, </span><span style="color: #6CB6FF">100</span><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D"># [4]</span></span>
<span class="line"><span style="color: #D73A49">for</span><span style="color: #24292E"> lr </span><span style="color: #D73A49">in</span><span style="color: #24292E"> [</span><span style="color: #005CC5">0.1</span><span style="color: #24292E">, </span><span style="color: #005CC5">0.01</span><span style="color: #24292E">, </span><span style="color: #005CC5">0.001</span><span style="color: #24292E">]:</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">for</span><span style="color: #24292E"> m </span><span style="color: #D73A49">in</span><span style="color: #24292E"> [</span><span style="color: #005CC5">0.5</span><span style="color: #24292E">, </span><span style="color: #005CC5">0.1</span><span style="color: #24292E">, </span><span style="color: #005CC5">0.05</span><span style="color: #24292E">]:</span></span>
<span class="line"><span style="color: #24292E">        submit_job(lr, m, </span><span style="color: #005CC5">100</span><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br></div></div><p>セル [4] を実行したら， Batch のコンソールを開こう． 先ほどと同様に，ジョブのステータスは <code>SUBMITTED</code> &gt; <code>RUNNABLE</code> &gt; <code>STARTING</code> &gt; <code>RUNNING</code> と移り変わっていくことがわかるだろう． 最終的に 9 個のジョブがすべて <code>RUNNING</code> の状態になることを確認しよう (<a href="#fig_batch_many_parallel_jobs">figure_title</a>)． また，このとき Compute environment の <code>Desired vCPUs</code> は 4x9=36 となっていることを確認しよう (<a href="#fig_batch_many_parallel_jobs">figure_title</a>)．</p>
<p><img src="./assets/aws_batch/batch_many_parallel_jobs.png" alt="複数のジョブを同時投入したときの Batch コンソール"></p>
<p>次に，Batch のコンソールの左側のメニューから <code>Jobs</code> をクリックしてみよう． ここでは，実行中のジョブの一覧が確認することができる (<a href="#fig_batch_parallel_job_list">figure_title</a>)． ジョブのステータスでフィルタリングをすることも可能である． 9 個のジョブがどれも <code>RUNNING</code> 状態にあることが確認できるだろう．</p>
<p><img src="./assets/aws_batch/batch_parallel_job_list.png" alt="複数のジョブを同時投入したときの Job 一覧"></p>
<p>今度は EC2 コンソールを見てみよう． 左のメニューから <code>Instances</code> を選択すると， <a href="#fig_ec2_instances_list">figure_title</a> に示すような起動中のインスタンスの一覧が表示される． <code>g4dn.xlarge</code> が 9 台稼働しているのが確認できる． Batch がジョブの投下に合わせて必要な数のインスタンスを起動してくれたのだ！</p>
<p><img src="./assets/aws_batch/ec2_instances_list.png" alt="複数のジョブを同時投入したときの EC2 インスタンスの一覧"></p>
<p>ここまで確認できたら，それぞれの Job が終了するまでしばらく待とう (だいたい 10-15 分くらいで終わる)． すべてのジョブが終了すると，ダッシュボードの <code>SUCCEEDED</code> が 9 となっているはずだ． また， Compute environment の <code>Desired vCPUs</code> も 0 に落ちていることを確認しよう． 最後に EC2 コンソールに行って，すべての g4dn インスタンスが停止していることを確認しよう．</p>
<p>以上から， AWS Batch を使うことで，<strong>ジョブの投入に応じて自動的に EC2 インスタンスが起動され，ジョブの完了とともに，ただちにインスタンスの停止が行われる</strong>一連の挙動を観察することができた． 一つのジョブの完了におよそ 10 分の時間がかかるので，9 個のハイパーパラメータの組を逐次的に計算していた場合は 90 分の時間を要することになる． AWS Batch を使ってこれらの計算を並列に実行することで，ジョブ一個分の計算時間 (=10 分) ですべての計算を終えることができた！</p>
<p>さて，再び <code>run_sweep.ipynb</code> に戻ってこよう． [5] 以降のセルでは，グリッドサーチの結果を可視化している．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390"># [5]</span></span>
<span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> pandas </span><span style="color: #F47067">as</span><span style="color: #ADBAC7"> pd</span></span>
<span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> numpy </span><span style="color: #F47067">as</span><span style="color: #ADBAC7"> np</span></span>
<span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> io</span></span>
<span class="line"><span style="color: #F47067">from</span><span style="color: #ADBAC7"> matplotlib </span><span style="color: #F47067">import</span><span style="color: #ADBAC7"> pyplot </span><span style="color: #F47067">as</span><span style="color: #ADBAC7"> plt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># [6]</span></span>
<span class="line"><span style="color: #F47067">def</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">read_table_from_s3</span><span style="color: #ADBAC7">(bucket_name, key, profile_name</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">None</span><span style="color: #ADBAC7">):</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> profile_name </span><span style="color: #F47067">is</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">None</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">        session </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> boto3.Session()</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">else</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">        session </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> boto3.Session(</span><span style="color: #F69D50">profile_name</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">profile_name)</span></span>
<span class="line"><span style="color: #ADBAC7">    s3 </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> session.resource(</span><span style="color: #96D0FF">&quot;s3&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">    bucket </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> s3.Bucket(bucket_name)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    obj </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> bucket.Object(key).get().get(</span><span style="color: #96D0FF">&quot;Body&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">    df </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> pd.read_csv(obj)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">return</span><span style="color: #ADBAC7"> df</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># [7]</span></span>
<span class="line"><span style="color: #ADBAC7">grid </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> np.zeros((</span><span style="color: #6CB6FF">3</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">3</span><span style="color: #ADBAC7">))</span></span>
<span class="line"><span style="color: #F47067">for</span><span style="color: #ADBAC7"> (i, lr) </span><span style="color: #F47067">in</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">enumerate</span><span style="color: #ADBAC7">([</span><span style="color: #6CB6FF">0.1</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">0.01</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">0.001</span><span style="color: #ADBAC7">]):</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">for</span><span style="color: #ADBAC7"> (j, m) </span><span style="color: #F47067">in</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">enumerate</span><span style="color: #ADBAC7">([</span><span style="color: #6CB6FF">0.5</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">0.1</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">0.05</span><span style="color: #ADBAC7">]):</span></span>
<span class="line"><span style="color: #ADBAC7">        key </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">f</span><span style="color: #96D0FF">&quot;metrics_lr</span><span style="color: #F47067">{</span><span style="color: #ADBAC7">lr</span><span style="color: #F47067">:0.4f}</span><span style="color: #96D0FF">_m</span><span style="color: #F47067">{</span><span style="color: #ADBAC7">m</span><span style="color: #F47067">:0.4f}</span><span style="color: #96D0FF">.csv&quot;</span></span>
<span class="line"><span style="color: #ADBAC7">        df </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> read_table_from_s3(</span><span style="color: #96D0FF">&quot;simplebatch-bucket43879c71-mbqaltx441fu&quot;</span><span style="color: #ADBAC7">, key)</span></span>
<span class="line"><span style="color: #ADBAC7">        grid[i,j] </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> df[</span><span style="color: #96D0FF">&quot;val_accuracy&quot;</span><span style="color: #ADBAC7">].max()</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># [8]</span></span>
<span class="line"><span style="color: #ADBAC7">fig, ax </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> plt.subplots(</span><span style="color: #F69D50">figsize</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">6</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">6</span><span style="color: #ADBAC7">))</span></span>
<span class="line"><span style="color: #ADBAC7">ax.set_aspect(</span><span style="color: #96D0FF">&#39;equal&#39;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">c </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ax.pcolor(grid, </span><span style="color: #F69D50">edgecolors</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&#39;w&#39;</span><span style="color: #ADBAC7">, </span><span style="color: #F69D50">linewidths</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">2</span><span style="color: #ADBAC7">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F47067">for</span><span style="color: #ADBAC7"> i </span><span style="color: #F47067">in</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">range</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">3</span><span style="color: #ADBAC7">):</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">for</span><span style="color: #ADBAC7"> j </span><span style="color: #F47067">in</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">range</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">3</span><span style="color: #ADBAC7">):</span></span>
<span class="line"><span style="color: #ADBAC7">        text </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ax.text(j</span><span style="color: #F47067">+</span><span style="color: #6CB6FF">0.5</span><span style="color: #ADBAC7">, i</span><span style="color: #F47067">+</span><span style="color: #6CB6FF">0.5</span><span style="color: #ADBAC7">, </span><span style="color: #F47067">f</span><span style="color: #96D0FF">&quot;</span><span style="color: #F47067">{</span><span style="color: #ADBAC7">grid[i, j]</span><span style="color: #F47067">:0.1f}</span><span style="color: #96D0FF">&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                       </span><span style="color: #F69D50">ha</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;center&quot;</span><span style="color: #ADBAC7">, </span><span style="color: #F69D50">va</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;center&quot;</span><span style="color: #ADBAC7">, </span><span style="color: #F69D50">color</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;w&quot;</span><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D"># [5]</span></span>
<span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> pandas </span><span style="color: #D73A49">as</span><span style="color: #24292E"> pd</span></span>
<span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> numpy </span><span style="color: #D73A49">as</span><span style="color: #24292E"> np</span></span>
<span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> io</span></span>
<span class="line"><span style="color: #D73A49">from</span><span style="color: #24292E"> matplotlib </span><span style="color: #D73A49">import</span><span style="color: #24292E"> pyplot </span><span style="color: #D73A49">as</span><span style="color: #24292E"> plt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># [6]</span></span>
<span class="line"><span style="color: #D73A49">def</span><span style="color: #24292E"> </span><span style="color: #6F42C1">read_table_from_s3</span><span style="color: #24292E">(bucket_name, key, profile_name</span><span style="color: #D73A49">=</span><span style="color: #005CC5">None</span><span style="color: #24292E">):</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">if</span><span style="color: #24292E"> profile_name </span><span style="color: #D73A49">is</span><span style="color: #24292E"> </span><span style="color: #005CC5">None</span><span style="color: #24292E">:</span></span>
<span class="line"><span style="color: #24292E">        session </span><span style="color: #D73A49">=</span><span style="color: #24292E"> boto3.Session()</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">else</span><span style="color: #24292E">:</span></span>
<span class="line"><span style="color: #24292E">        session </span><span style="color: #D73A49">=</span><span style="color: #24292E"> boto3.Session(</span><span style="color: #E36209">profile_name</span><span style="color: #D73A49">=</span><span style="color: #24292E">profile_name)</span></span>
<span class="line"><span style="color: #24292E">    s3 </span><span style="color: #D73A49">=</span><span style="color: #24292E"> session.resource(</span><span style="color: #032F62">&quot;s3&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">    bucket </span><span style="color: #D73A49">=</span><span style="color: #24292E"> s3.Bucket(bucket_name)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">    obj </span><span style="color: #D73A49">=</span><span style="color: #24292E"> bucket.Object(key).get().get(</span><span style="color: #032F62">&quot;Body&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">    df </span><span style="color: #D73A49">=</span><span style="color: #24292E"> pd.read_csv(obj)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">return</span><span style="color: #24292E"> df</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># [7]</span></span>
<span class="line"><span style="color: #24292E">grid </span><span style="color: #D73A49">=</span><span style="color: #24292E"> np.zeros((</span><span style="color: #005CC5">3</span><span style="color: #24292E">,</span><span style="color: #005CC5">3</span><span style="color: #24292E">))</span></span>
<span class="line"><span style="color: #D73A49">for</span><span style="color: #24292E"> (i, lr) </span><span style="color: #D73A49">in</span><span style="color: #24292E"> </span><span style="color: #005CC5">enumerate</span><span style="color: #24292E">([</span><span style="color: #005CC5">0.1</span><span style="color: #24292E">, </span><span style="color: #005CC5">0.01</span><span style="color: #24292E">, </span><span style="color: #005CC5">0.001</span><span style="color: #24292E">]):</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">for</span><span style="color: #24292E"> (j, m) </span><span style="color: #D73A49">in</span><span style="color: #24292E"> </span><span style="color: #005CC5">enumerate</span><span style="color: #24292E">([</span><span style="color: #005CC5">0.5</span><span style="color: #24292E">, </span><span style="color: #005CC5">0.1</span><span style="color: #24292E">, </span><span style="color: #005CC5">0.05</span><span style="color: #24292E">]):</span></span>
<span class="line"><span style="color: #24292E">        key </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #D73A49">f</span><span style="color: #032F62">&quot;metrics_lr</span><span style="color: #005CC5">{</span><span style="color: #24292E">lr</span><span style="color: #D73A49">:0.4f</span><span style="color: #005CC5">}</span><span style="color: #032F62">_m</span><span style="color: #005CC5">{</span><span style="color: #24292E">m</span><span style="color: #D73A49">:0.4f</span><span style="color: #005CC5">}</span><span style="color: #032F62">.csv&quot;</span></span>
<span class="line"><span style="color: #24292E">        df </span><span style="color: #D73A49">=</span><span style="color: #24292E"> read_table_from_s3(</span><span style="color: #032F62">&quot;simplebatch-bucket43879c71-mbqaltx441fu&quot;</span><span style="color: #24292E">, key)</span></span>
<span class="line"><span style="color: #24292E">        grid[i,j] </span><span style="color: #D73A49">=</span><span style="color: #24292E"> df[</span><span style="color: #032F62">&quot;val_accuracy&quot;</span><span style="color: #24292E">].max()</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># [8]</span></span>
<span class="line"><span style="color: #24292E">fig, ax </span><span style="color: #D73A49">=</span><span style="color: #24292E"> plt.subplots(</span><span style="color: #E36209">figsize</span><span style="color: #D73A49">=</span><span style="color: #24292E">(</span><span style="color: #005CC5">6</span><span style="color: #24292E">,</span><span style="color: #005CC5">6</span><span style="color: #24292E">))</span></span>
<span class="line"><span style="color: #24292E">ax.set_aspect(</span><span style="color: #032F62">&#39;equal&#39;</span><span style="color: #24292E">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">c </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ax.pcolor(grid, </span><span style="color: #E36209">edgecolors</span><span style="color: #D73A49">=</span><span style="color: #032F62">&#39;w&#39;</span><span style="color: #24292E">, </span><span style="color: #E36209">linewidths</span><span style="color: #D73A49">=</span><span style="color: #005CC5">2</span><span style="color: #24292E">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D73A49">for</span><span style="color: #24292E"> i </span><span style="color: #D73A49">in</span><span style="color: #24292E"> </span><span style="color: #005CC5">range</span><span style="color: #24292E">(</span><span style="color: #005CC5">3</span><span style="color: #24292E">):</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">for</span><span style="color: #24292E"> j </span><span style="color: #D73A49">in</span><span style="color: #24292E"> </span><span style="color: #005CC5">range</span><span style="color: #24292E">(</span><span style="color: #005CC5">3</span><span style="color: #24292E">):</span></span>
<span class="line"><span style="color: #24292E">        text </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ax.text(j</span><span style="color: #D73A49">+</span><span style="color: #005CC5">0.5</span><span style="color: #24292E">, i</span><span style="color: #D73A49">+</span><span style="color: #005CC5">0.5</span><span style="color: #24292E">, </span><span style="color: #D73A49">f</span><span style="color: #032F62">&quot;</span><span style="color: #005CC5">{</span><span style="color: #24292E">grid[i, j]</span><span style="color: #D73A49">:0.1f</span><span style="color: #005CC5">}</span><span style="color: #032F62">&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                       </span><span style="color: #E36209">ha</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;center&quot;</span><span style="color: #24292E">, </span><span style="color: #E36209">va</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;center&quot;</span><span style="color: #24292E">, </span><span style="color: #E36209">color</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;w&quot;</span><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br><span class="line-number">36</span><br><span class="line-number">37</span><br><span class="line-number">38</span><br></div></div><p>最終的に出力されるプロットが <a href="#fig_grid_search_result">figure_title</a> である．</p>
<p><img src="./assets/aws_batch/grid_search_result.png" alt="ハイパーパラメータのグリッドサーチの結果"></p>
<p>このプロットから，差は僅かであるが，学習率が 0.1 のときに精度は最大となることがわかる． また，学習率 0.1 のときはモメンタムを変えても大きな差は生じないことが見て取れる．</p>
<p>今回のパラメータサーチは勉強用に極めて単純化されたものである点は承知いただきたい．</p>
<p>たとえば，今回は学習率が 0.1 が最も良いとされたが，それは訓練のエポックを 100 に限定しているからかもしれない． 学習率が低いとその分訓練に必要なエポック数も多くなる． 訓練のエポック数をもっと増やせばまた違った結果が観察される可能性はある．</p>
<p>また，今回は MNIST の訓練データ 60,000 枚のうち， 48,000 枚を訓練データ，残り 12,000 枚を検証データとして用いた． この分割は乱数を固定してランダムに行ったが，もしこの分割によるデータのバイアスを気にするならば， k 個の異なる学習・検証データの分割をあらかじめ用意して，複数回モデルの評価を行う (<strong>k-fold cross-validation</strong>) 方法も，より精緻なアプローチとして考えられる．</p>
<p>以上のようにして， CNN を用いた MNIST 分類モデルのハイパーパラメータの最適化の一連の流れを体験した． AWS Batch を利用することで，比較的少ないプログラミングで，動的に EC2 クラスターを制御し，並列にジョブを処理するシステムが構築できた． ここまで EC2 を使いこなすことができれば，多くの問題を自力で解くことが可能になるだろう！</p>
<h2 id="スタックの削除" tabindex="-1">スタックの削除 <a class="header-anchor" href="#スタックの削除" aria-label="Permalink to &quot;スタックの削除&quot;">&ZeroWidthSpace;</a></h2>
<p>これにて，本ハンズオンは終了である．最後にスタックを削除しよう． 今回のスタックを削除するにあたり，ECR に配置された Docker のイメージは手動で削除されなければならない (これをしないと， <code>cdk destroy</code> を実行したときにエラーになってしまう． これは CloudFormation の仕様なので従うしかない)．</p>
<p>ECR の Docker image を削除するには， ECR のコンソールに行き，イメージが配置されたレポジトリを開く． そして，画面右上の <code>DELETE</code> ボタンを押して削除する (<a href="#fig_delete_ecr">figure_title</a>)．</p>
<p><img src="./assets/aws_batch/delete_ecr.png" alt="ECR から Docker image を削除する"></p>
<p>あるいは， AWS CLI から同様の操作を行うには，以下のコマンドを用いる (<code>XXXX</code> は自分の ECR レポジトリ名に置き換える)．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ecr</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">batch-delete-image</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--repository-name</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">XXXX</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--image-ids</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">imageTag=latest</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">aws</span><span style="color: #24292E"> </span><span style="color: #032F62">ecr</span><span style="color: #24292E"> </span><span style="color: #032F62">batch-delete-image</span><span style="color: #24292E"> </span><span style="color: #005CC5">--repository-name</span><span style="color: #24292E"> </span><span style="color: #032F62">XXXX</span><span style="color: #24292E"> </span><span style="color: #005CC5">--image-ids</span><span style="color: #24292E"> </span><span style="color: #032F62">imageTag=latest</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>image の削除が完了したうえで，次のコマンドでスタックを削除する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cdk</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">destroy</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cdk</span><span style="color: #24292E"> </span><span style="color: #032F62">destroy</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>(#sec:batch_development_and_debug) === クラウドを用いた機械学習アプリケーションの開発とデバッグ</p>
<p>本章で紹介したハンズオンでは， AWS Batch を使用することでニューラルネットの学習を複数並列に実行し，高速化を実現した． 本章の最後の話題として，クラウドを用いた機械学習アプリケーションの開発とデバッグの方法について述べよう．</p>
<p>ローカルに GPU を搭載した強力なマシンがなく，クラウドを利用する予算が確保されているのであれば， <a href="#fig:cloud_development">figure_title</a> のような開発のスキームが理想的であると考える． 最初の段階では， (#sec_jupyter_and_deep_learning) で見たような方法で， GPU 搭載型の EC2 インスタンスを作成し， Jupyter Notebook などのインタラクティブな環境で様々なモデルを試し実験を行う． Jupyter である程度アプリケーションが完成してきたタイミングで，作成したアプリケーションを Docker イメージにパッケージングする． そして， EC2 上で <code>docker run</code> を行い，作成したイメージがバグなく動作するか確認を行う． その次に，ハイパーパラメータの最適化などのチューニングを， <a href="#sec_aws_batch">Hands-on #4: AWS Batch を使って機械学習のハイパーパラメータサーチを並列化する</a> のハンズオンで学んだ AWS Batch などの計算システムを利用して行う． よい深層学習モデルが完成したら，仕上げに大規模データへの推論処理を行うシステムを (#sec_fargate_qabot) を参考に構築する．</p>
<p>実際，本書ではこの流れに沿って演習を進めてきた． MNIST タスクを解くモデルを，最初 Jupyter Notebook を使用して実験し，そのコードをほとんどそのまま Docker にパッケージし， AWS Batch を用いてハイパーパラメータサーチを行った． このサイクルを繰り返すことで，クラウドを最大限に活用した機械学習アプリケーションの開発を進めることができる．</p>
<p><img src="./assets/aws_batch/cloud_development.png" alt="クラウドを活用した機械学習アプリケーションの開発フロー"></p>
<h2 id="小括" tabindex="-1">小括 <a class="header-anchor" href="#小括" aria-label="Permalink to &quot;小括&quot;">&ZeroWidthSpace;</a></h2>
<p>ここまでが，本書第二部の内容である． 第一部に引き続き盛りだくさんの内容であったが，ついてこれたであろうか？</p>
<p>第二部ではまず最初に，深層学習の計算をクラウドで実行するため， GPU 搭載型の EC2 インスタンスの起動について解説した． さらに，ハンズオンでは，クラウドに起動した仮想サーバーを使って MNIST 文字認識タスクを解くニューラルネットを訓練した ( (#sec_jupyter_and_deep_learning))．</p>
<p>また，より大規模な機械学習アプリケーションを作るための手段として， Docker と ECS によるクラスターの初歩を説明した ( (#sec_docker_introduction))． その応用として，英語で与えられた文章問題への回答を自動で生成するボットをクラウドに展開した ( (#sec_fargate_qabot))． タスクの投入に応じて動的に計算リソースが作成・削除される様子を実際に体験できただろう．</p>
<p>さらに， <a href="#sec_aws_batch">Hands-on #4: AWS Batch を使って機械学習のハイパーパラメータサーチを並列化する</a> では AWS Batch を用いてニューラルネットの学習を並列に実行する方法を紹介した． ここで紹介した方法は，ミニマムであるが，計算機システムを大規模化していくためのエッセンスが網羅されている． これらのハンズオン体験から，クラウド技術を応用してどのように現実世界の問題を解いていくのか，なんとなくイメージが伝わっただろうか？</p>
<p>本書の第三部では，さらにレベルアップし，サーバーレスアーキテクチャという最新のクラウドの設計手法について解説する． その応用として，ハンズオンでは簡単な SNS サービスをゼロから実装する． 引き続きクラウドの最先端の世界を楽しんでいこう！</p>
]]></description>
            <content:encoded><![CDATA[<h1 id="hands-on-4-aws-batch-を使って機械学習のハイパーパラメータサーチを並列化する" tabindex="-1">Hands-on #4: AWS Batch を使って機械学習のハイパーパラメータサーチを並列化する <a class="header-anchor" href="#hands-on-4-aws-batch-を使って機械学習のハイパーパラメータサーチを並列化する" aria-label="Permalink to &quot;Hands-on \#4: AWS Batch を使って機械学習のハイパーパラメータサーチを並列化する&quot;">&ZeroWidthSpace;</a></h1>
<p>ハンズオン第三回では， ECS と Fargate を使って自動質問回答システムを構築した． シンプルながらも，複数の質問が送られた場合には並列にジョブが実行され，ユーザーに答えが返されるシステムを作ることができた． ここでは，すでに学習済みの言語モデルを用いてアプリケーションを構築した． しかし，一般的に言って，機械学習のワークフローでは自分で作ったモデルを訓練することが最初のステップにあるはずである． そこで，ハンズオン第四回では，クラウドを用いて機械学習の訓練を並列化・高速化することを考える．</p>
<p>本ハンズオンでは深層学習におけるハイパーパラメータ最適化を取り上げる． ハイパーパラメータとは，勾配降下法によって最適化されるニューラルネットのパラメータの外にあるパラメータのことであり，具体的にはモデルの層の幅・深さなどネットワークのアーキテクチャに関わるもの，学習率やモメンタムなどパラメータの更新則に関わるものなどが含まる． 深層学習においてハイパーパラメータの調整はとても重要なタスクである． しかしながら，ハイパーパラメータを調整するには，少しずつ条件を変えながら何度もニューラルネットを学習させる必要があり，多くの計算時間がかかる． 研究・開発においては，スループットよくたくさんのモデルの可能性を探索することが生産性を決める重要なファクターであり，ハイパーパラメータ探索を高速に解くという問題は極めて関心が高い． 本ハンズオンでは，クラウドの強力な計算リソースを利用して並列的にニューラルネットの訓練を実行することで，この問題を解く方法を学んでいこう．</p>
<h2 id="auto-scaling-groups-asg" tabindex="-1">Auto scaling groups (ASG) <a class="header-anchor" href="#auto-scaling-groups-asg" aria-label="Permalink to &quot;Auto scaling groups (ASG)&quot;">&ZeroWidthSpace;</a></h2>
<p>ハンズオンに入っていく前に， <strong>Auto scaling groups (ASG)</strong> とよばれる EC2 の概念を知っておく必要がある．</p>
<p>ECS の概要を示した (#ecs_overview) を振り返って見てほしい． 前章 ( (#sec_fargate_qabot)) でも説明したが， ECS のクラスターで計算を担う実体としては EC2 と Fargate を指定することができる． Fargate については前章で記述した． Fargate を用いると，自在にスケールする計算環境をとても簡単な設定で構築することができた． しかし， GPU を利用することができないなど，いくつかの制約があった． EC2 を使用した計算環境を指定することで，プログラミングの複雑度は増すが， GPU やその他のより高度かつ複雑な設定を伴ったクラスターを構築することができる．</p>
<p>EC2 クラスターには <strong>ASG</strong> と呼ばれるサービスが配置される． ASG は複数の EC2 インスタンスをロジカルな単位でグループ化することでクラスターを構成する． ASG はクラスター内に新しいインスタンスを起動する，あるいは不要になったインスタンスを停止するなどのスケーリングを担う． ASG で重要な概念として， <strong>desired capacity</strong>, <strong>minimum capacity</strong>, <strong>maximum capacity</strong> というパラメータがある． minimum capacity， maximum capacity は，それぞれクラスター内に配置できるインスタンスの数の最小値・最大値を指定するパラメータである． 前者は，クラスターに負荷がかかっていない場合でもアイドリング状態にあるインスタンスを維持することで，急に負荷が増大した時などのバッファーとして作用することができる． 後者は，負荷が急に増えたときに，過剰な数のインスタンスが起動する事態を防ぎ，経済的なコストの上限を定める役割を果たす．</p>
<p>desired capacity が，その時々でシステムが要求するインスタンスの数を指定する． desired capacity は，例えば 24 時間のリズムに合わせてインスタンスの数を増減させる (昼は多く夜は少なくなど) などの決まったスケジュールに基づいた設定を適用することができる． あるいはクラスター全体にかかっている負荷に応じて， desired capacity を動的に制御することも可能である． どのような基準でクラスターのスケーリングを行うかを定めるルールのことを，<strong>スケーリングポリシー</strong>とよぶ． たとえば，クラスター全体の稼働率 (負荷) を常に 80% に維持する，などのスケーリングポリシーが想定できる． この場合，クラスター全体の負荷が 80%を下回ったときにはクラスターからインスタンスが削除され，80%を超える (あるいは超えると予測される) 場合はインスタンスを追加する，という操作が ASG によって自動的に行われる．</p>
<p>上記のようなパラメータを検討し，ユーザーは ASG を作成する． ASG を作成したのち， ECS との連携をプログラムしてあげることで， ECS を介して ASG による EC2 クラスターにタスクを投入することが可能になる．</p>
<h2 id="aws-batch" tabindex="-1">AWS Batch <a class="header-anchor" href="#aws-batch" aria-label="Permalink to &quot;AWS Batch&quot;">&ZeroWidthSpace;</a></h2>
<p><img src="./assets/aws_logos/Batch.png" alt="AWS Batch のアイコン"></p>
<p>先に説明したように， ECS と ASG を組み合わせることで，所望の計算クラスターを構築することが可能である． しかしながら， ECS と ASG にはかなり込み入った設定が必要であり，初心者にとっても経験者にとってもなかなか面倒なプログラミングが要求される． そこで， ECS と ASG によるクラスターの設計を自動化してくれるサービスが提供されている． それが <strong>AWS Batch</strong> である．</p>
<p>AWS Batch はその名のとおりバッチ (Batch) 化されたジョブ (入力データだけが異なる独立した演算が繰り返し実行されること) を想定している． 多くの科学計算や機械学習がバッチ計算に当てはまる． たとえば，初期値のパラメータを変えて複数のシミュレーションを走らせる，といったケースだ． AWS Batch を用いることの利点は，クラスターのスケーリングやジョブの割り振りはすべて自動で実行され， ユーザーはクラウドの舞台裏の詳細を気にすることなく，大量のジョブを投入できるシステムが手に入る点である． が，知識として背後では ECS/ASG/EC2 の三つ巴が協調して動作しているという点は知っておいてほしい．</p>
<p>AWS Batch では，ジョブの投入・管理をスムーズに行うため，次のような概念が定義されている (<a href="#fig_batch_concept">figure_title</a>)． まず， <strong>ジョブ (Job)</strong> というのが，AWS Batch によって実行される一つの計算の単位である． <strong>Job definitions</strong> とはジョブの内容を定義するものであり，これには実行されるべき Docker のイメージのアドレスや，割り当てる CPU・RAM の容量，環境変数などの設定が含まれる． Job definition に基づいて個々のジョブが実行される． ジョブが実行されると，ジョブは <strong>Job queues</strong> に入る． Job queues とは，実行待ち状態にあるジョブの列のことであり，時間的に最も先頭に投入されたジョブが最初に実行される． また，複数の queue を配置し， queue ごとに priority (優先度) を設定することが可能であり， priority の高い queue に溜まったジョブが優先的に実行される (筆者はこれをディズニーランドの&quot;ファストパス&quot;を連想して捉えている)． <strong>Compute environment</strong> とは，先述したクラスターとほぼ同義の概念であり，計算が実行される場所 (EC2 や Fargate からなるクラスター) を指す． Compute environment には，使用する EC2 のインスタンスタイプや同時に起動するインスタンス数の上限などの簡易なスケーリングポリシーが指定されている． Job queues は Compute environment の空き状況を監視しており， それに応じてジョブを Compute environment に投下する．</p>
<p>以上が AWS Batch を使用するうえで理解しておかなければならない概念であるが，くどくど言葉で説明してもなかなかピンとこないだろう． ここからは，実際に自分で手を動かしながら学んでいこう．</p>
<p><img src="./assets/aws_batch/batch_concepts.png" alt="AWS Batch の主要な概念"></p>
<p><strong>EC2 or Fargate?</strong></p>
<p>ECS でクラスターを構成する際，計算を実行する場として EC2 と Fargate の二つの選択肢があることを説明した． それぞれ長所と短所を抱えているのだが，どのような場合にどちらを使うべきだろうか？ それを検討するため，まずは <a href="#tab:ec2_vs_fargate">table_title</a> を見てみよう． これは EC2 と Fargate の特徴をまとめたものである． 説明の都合上，大幅な粗視化が行われている点は留意していただきたい．</p>
<table><caption>EC2 vs Fargate</caption><colgroup><col style="width: 33%" /><col style="width: 33%" /><col style="width: 33%" /></colgroup><thead><tr class="header"><th></th><th>EC2</th><th>Fargate</th></tr></thead><tbody><tr class="odd"><td><p>Compute capacity</p></td><td><p>Medium to large</p></td><td><p>Small to medium</p></td></tr><tr class="even"><td><p>GPU</p></td><td><p>Yes</p></td><td><p>No</p></td></tr><tr class="odd"><td><p>Launch speed</p></td><td><p>Slow</p></td><td><p>Fast</p></td></tr><tr class="even"><td><p>Task placement flexibility</p></td><td><p>Low</p></td><td><p>High</p></td></tr><tr class="odd"><td><p>Programming complexity</p></td><td><p>High</p></td><td><p>Low</p></td></tr></tbody></table>
<p>これまでに見てきたように， EC2 は最大の CPU 数・メモリーサイズが大きかったり， GPU を利用できたりするなど，単一のインスタンスでの計算能力は高い． 対して， Fargate は単一インスタンスの最大 CPU 数は 4 コアが上限である． その一方で，インスタンスの起動に要する時間は Fargate のほうが圧倒的に早く，より俊敏にクラスターのスケーリングを行うことができる． また，タスクをクラスターに投入する際のフレキシビリティも Fargate のほうが高い． フレキシビリティというのは，例えば一つのインスタンスで 2 つ以上のコンテナを走らせる，などの状況である． 単位 CPU あたりで処理されるタスクの数を最大化する際には，このような設計がしばしば採用される． プログラミングの複雑さという観点からは， Fargate のほうが一般的にシンプルな実装になる．</p>
<p>このように， EC2 と Fargate は互いに相補的な特性を有しており，アプリケーションによって最適な計算環境は検討される必要がある． また，EC2 と Fargate を両方用いたハイブリッドクラスターというのも定義可能であり，そのような選択肢もしばしば用いられる．</p>
<h2 id="準備" tabindex="-1">準備 <a class="header-anchor" href="#準備" aria-label="Permalink to &quot;準備&quot;">&ZeroWidthSpace;</a></h2>
<p>ハンズオンのソースコードは GitHub の <a href="https://github.com/andatoshiki/toshiki-notebooktree/main/handson/aws-batch" target="_blank" rel="noreferrer">handson/aws-batch</a> にある．</p>
<p>本ハンズオンの実行には，第一回ハンズオンで説明した準備 ( (#handson_01_prep)) が整っていることを前提とする． また， Docker が自身のローカルマシンにインストール済みであることも必要である．</p>
<p>このハンズオンは， <code>g4dn.xlarge</code> タイプの EC2 インスタンスを使うので，アメリカ東部 (<code>us-east-1</code>) リージョンでは 0.526 $/hour のコストが発生する． 東京 (<code>ap-northeast-1</code>) を選択した場合は 0.71 $/hour のコストが発生する．</p>
<p>(#sec:jupyter_and_deep_learning_setup) でも注意したが，このハンズオンを始める前に G タイプインスタンスの起動上限を AWS コンソールの EC2 管理画面から確認しよう． もし上限が 0 になっていた場合は，上限緩和の申請を行う必要がある． <a href="#sec:aws_batch_code">アプリケーションの説明</a> にも関連した情報を記載しているので，併せて参照されたい．</p>
<h2 id="mnist-手書き文字認識-再訪" tabindex="-1">MNIST 手書き文字認識 (再訪) <a class="header-anchor" href="#mnist-手書き文字認識-再訪" aria-label="Permalink to &quot;MNIST 手書き文字認識 (再訪)&quot;">&ZeroWidthSpace;</a></h2>
<p>今回のハンズオンでは，機械学習のハイパーパラメータ調整を取り上げると冒頭で述べた． その最もシンプルな例題として， (#sec_mnist_using_jupyter) で扱った MNIST 手書き文字認識の問題を再度取り上げよう． (#sec_mnist_using_jupyter) では，適当にチョイスしたハイパーパラメータを用いてモデルの訓練を行った． ここで使用したプログラムのハイパーパラメータとしては，確率的勾配降下法 (SGD) における学習率やモメンタムが含まれる． コードでいうと，次の行が該当する．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">optimizer </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> optim.SGD(model.parameters(), </span><span style="color: #F69D50">lr</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">0.01</span><span style="color: #ADBAC7">, </span><span style="color: #F69D50">momentum</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">0.5</span><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">optimizer </span><span style="color: #D73A49">=</span><span style="color: #24292E"> optim.SGD(model.parameters(), </span><span style="color: #E36209">lr</span><span style="color: #D73A49">=</span><span style="color: #005CC5">0.01</span><span style="color: #24292E">, </span><span style="color: #E36209">momentum</span><span style="color: #D73A49">=</span><span style="color: #005CC5">0.5</span><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>ここで使用された 学習率 (<code>lr=0.01</code>) やモメンタム (<code>momentum=0.5</code>) は恣意的に選択された値であり，これがベストな数値であるのかはわからない． たまたまこのチョイスが最適であるかもしれないし，もっと高い精度を出すハイパーパラメータの組が存在するかもしれない． この問題に答えるため，ハイパーパラメータサーチを行おう． 今回は，最もシンプルなアプローチとして，<strong>グリッドサーチ</strong>によるハイパーパラメータサーチを行おう．</p>
<p>機械学習のハイパーパラメータの最適化には大きく３つのアプローチが挙げられる． グリッドサーチ，ランダムサーチ，そしてベイズ最適化による方法である．</p>
<p>グリッドサーチとは，ハイパーパラメータの組をある範囲の中で可能な組み合わせをすべて計算し，最適なパラメータの組を見出す方法である． 最もシンプルかつ確実な方法であるが，すべての組み合わせの可能性を愚直に計算するので計算コストが大きい．</p>
<p>ランダムサーチ法とは，ハイパーパラメータの組をある範囲の中でランダムに抽出し，大量に試行されたランダムな組の中から最適なパラメータの組を見出す方法である． すべての可能性を網羅的に探索できるわけではないが，調整すべきパラメータの数が多数ある場合に，グリッドサーチよりも効率的に広い探索空間をカバーすることができる．</p>
<p>ベイズ最適化を用いた方法では，過去の探索結果から次にどの組み合わせを探索すべきかという指標を計算し，次に探索するパラメータを決定する． これにより，理論的にはグリッドサーチやランダムサーチ法よりも少ない試行回数で最適なパラメータにたどり着くことができる．</p>
<p>並列化の観点でいうと，グリッドサーチとランダムサーチは各ハイパーパラメータの組の計算は独立に実行することができるため並列化が容易である． このように独立したジョブとして分割・並列化可能な問題を Embarrassingly parallel な問題とよぶ (直訳すると&quot;恥ずかしいほど並列化可能な問題&quot;，ということになる)． Embarrassingly parallel な問題はクラウドの強力な計算リソースを用いることで，非常なシンプルな実装で解くことができる． この章ではこのようなタイプの並列計算を取り上げる．</p>
<p>一方，ベイズ最適化による方法は，過去の結果をもとに次の探索が決定されるので，並列化はそれほど単純ではない． 最近では <a href="https://optuna.org/" target="_blank" rel="noreferrer">optuna</a> などのハイパーパラメータ探索のためのライブラリが発達しており，ベイズ最適化の数理的な処理を自動で実行してくれるので便利である． これらのライブラリを使うと，もし一台のコンピュータ (ノード) の中に複数の GPU が存在する場合は，並列に計算を実行することができる． しかしながら，一台のノードにとどまらず，複数のノードをまたいだ並列化は，高度なプログラミングテクニックが必要とされるだけでなく，ノード間の接続様式などクラウドのアーキテクチャにも深く依存するものである． 本書ではここまで高度なクラウドの使用方法には立ち入らない．</p>
<p>まずは，本ハンズオンで使用する Docker イメージをローカルで実行してみよう．</p>
<p>Docker イメージのソースコードは <a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/aws-batch/docker" target="_blank" rel="noreferrer">handson/aws-batch/docker</a> にある． 基本的に (#sec_mnist_using_jupyter) のハンズオンを元にし，本ハンズオン専用の軽微な変更が施してある． 興味のある読者はソースコードも含めて読んでいただきたい．</p>
<p>練習として，この Docker イメージを手元でビルドするところからはじめてみよう． <code>Dockerfile</code> が保存されているディレクトリに移動し， <code>mymnist</code> という名前 (Tag) をつけてビルドを実行する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cd</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">handson/aws-batch/docker</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">docker</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">build</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-t</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">mymnist</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cd</span><span style="color: #24292E"> </span><span style="color: #032F62">handson/aws-batch/docker</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">docker</span><span style="color: #24292E"> </span><span style="color: #032F62">build</span><span style="color: #24292E"> </span><span style="color: #005CC5">-t</span><span style="color: #24292E"> </span><span style="color: #032F62">mymnist</span><span style="color: #24292E"> </span><span style="color: #032F62">.</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p><code>docker build</code> でエラーが出たときは次の可能性を疑ってほしい． ビルドの中で， MNIST の画像データセットを <a href="http://yann.lecun.com/exdb/mnist/" target="_blank" rel="noreferrer">http://yann.lecun.com/exdb/mnist/</a> からダウンロードするのだが，ダウンロード先のサーバーがしばしばダウンしている． 世界中の機械学習ユーザーがアクセスするので，これはしばしば発生するようである． サーバーがダウンしているとビルドも失敗してしまう． エラーメッセージにそれらしい文言が含まれていたら，この可能性を疑おう．</p>
<p>手元でビルドするかわりに， Docker Hub から pull することも可能である． その場合は次のコマンドを実行する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">docker</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">pull</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">tomomano/mymnist:latest</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">docker</span><span style="color: #24292E"> </span><span style="color: #032F62">pull</span><span style="color: #24292E"> </span><span style="color: #032F62">tomomano/mymnist:latest</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>イメージの準備ができたら，次のコマンドでコンテナを起動し， MNIST の学習を実行する．．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">docker</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">run</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">mymnist</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--lr</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0.1</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--momentum</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0.5</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--epochs</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">10</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">docker</span><span style="color: #24292E"> </span><span style="color: #032F62">run</span><span style="color: #24292E"> </span><span style="color: #032F62">mymnist</span><span style="color: #24292E"> </span><span style="color: #005CC5">--lr</span><span style="color: #24292E"> </span><span style="color: #005CC5">0.1</span><span style="color: #24292E"> </span><span style="color: #005CC5">--momentum</span><span style="color: #24292E"> </span><span style="color: #005CC5">0.5</span><span style="color: #24292E"> </span><span style="color: #005CC5">--epochs</span><span style="color: #24292E"> </span><span style="color: #005CC5">10</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>このコマンドを実行すると，指定したハイパーパラメータ (<code>--lr</code> で与えられる学習率と <code>--momentum</code> で与えられるモメンタム) を使ってニューラルネットの最適化が始まる． 学習を行う最大のエポック数は <code>--epochs</code> パラメータで指定する． (#sec_jupyter_and_deep_learning) のハンズオンで見たような， Loss の低下がコマンドライン上に出力されるだろう (<a href="#fig_mnist_log_output">figure_title</a>)．</p>
<p><img src="./assets/aws_batch/mnist_log_output.png" alt="Docker を実行した際の出力"></p>
<p>上に示したコマンドを使うと，計算は CPU を使って実行される． もし，ローカルの計算機に GPU が備わっており， <a href="https://github.com/NVIDIA/nvidia-docker" target="_blank" rel="noreferrer">nvidia-docker</a> の設定が済んでいるならば， 次のコマンドにより GPU を使って計算を実行できる．</p>
<pre><code>$ docker run --gpus all mymnist --lr 0.1 --momentum 0.5 --epochs 10
</code></pre>
<p>このコマンドでは，<code>--gpus all</code> というパラメータが加わった．</p>
<p>CPU/GPU どちらで実行した場合でも，エポックを重ねるにつれて訓練データ (Train データ) の Loss は単調に減少していくのが見て取れるだろう． 一方，<strong>検証データ (Validation データ) の Loss および Accuracy は，ある程度まで減少した後，それ以上性能が向上しない</strong>ことに気がつくだろう． これを実際にプロットしてみると <a href="#fig_loss_epoch_profile">figure_title</a> のようになるはずである．</p>
<p><img src="./assets/aws_batch/loss_epoch_profile.png" alt="(左) Train/Validation データそれぞれの Loss のエポックごとの変化． (右) Validation データの Accuracy のエポックごとの変化"></p>
<p>これは<strong>オーバーフィッティング</strong>とよばれる現象で，ニューラルネットが訓練データに過度に最適化され，訓練データの外のデータに対しての精度 (汎化性能) が向上していないことを示している． このような場合の対処法として， <strong>Early stopping</strong> とよばれるテクニックが知られている． Early stopping とは，検証データの Loss を追跡し，それが減少から増加に転じるエポックで学習をうち止め，そのエポックでのウェイトパラメータを採用する，というものである． 本ハンズオンでも， Early stopping によって訓練の終了を判断し，モデルの性能評価を行っていく．</p>
<p>MNIST 手書き文字データセットでは，訓練データとして 60,000 枚，テストデータとして 10,000 枚の画像が与えられている． 本ハンズオンで使用するコードでは，訓練データのうち 80% の 48,000 枚を訓練データとして使用し，残り 20% の 12,000 枚を検証データとして用いている． 詳しくはソースコードを参照のこと．</p>
<h2 id="アプリケーションの説明" tabindex="-1">アプリケーションの説明 <a class="header-anchor" href="#アプリケーションの説明" aria-label="Permalink to &quot;アプリケーションの説明&quot;">&ZeroWidthSpace;</a></h2>
<p>このハンズオンで作成するアプリケーションの概要を <a href="#fig_batch_architecture">figure_title</a> に示す．</p>
<p><img src="./assets/aws_batch/architecture.png" alt="アプリケーションのアーキテクチャ"></p>
<p>簡単にまとめると，次のような設計である．</p>
<ul>
<li>
<p>クライアントは，あるハイパーパラメータの組を指定して Batch にジョブを提出する</p>
</li>
<li>
<p>Batch はジョブを受け取ると， EC2 からなるクラスターで計算を実行する</p>
</li>
<li>
<p>クラスター内では <code>g4dn.xlarge</code> インスタンスが起動する</p>
</li>
<li>
<p>Docker イメージは， AWS 内に用意された ECR (Elastic Container Registry) から取得される</p>
</li>
<li>
<p>複数のジョブが投下された場合は，その数だけのインスタンスが起動し並列に実行される</p>
</li>
<li>
<p>各ジョブによる計算の結果は S3 に保存される</p>
</li>
<li>
<p>最後にクライアントは S3 から結果をダウンロードし，最適なハイパーパラメータの組を決定する</p>
</li>
</ul>
<p>それでは，プログラムのソースコードを見てみよう (<a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/aws-batch/app.py" target="_blank" rel="noreferrer">handson/aws-batch/app.py</a>)．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">class</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50">SimpleBatch</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">core</span><span style="color: #ADBAC7">.</span><span style="color: #6CB6FF">Stack</span><span style="color: #ADBAC7">):</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">def</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">__init__</span><span style="color: #ADBAC7">(self, scope: core.App, name: </span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">, </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">kwargs) -&gt; </span><span style="color: #6CB6FF">None</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #6CB6FF">super</span><span style="color: #ADBAC7">().</span><span style="color: #6CB6FF">__init__</span><span style="color: #ADBAC7">(scope, name, </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">kwargs)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        bucket </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> s3.Bucket(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;bucket&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">removal_policy</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">core.RemovalPolicy.</span><span style="color: #6CB6FF">DESTROY</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">auto_delete_objects</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">True</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        vpc </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ec2.Vpc(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;vpc&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #768390"># other parameters...</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        managed_env </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> batch.ComputeEnvironment(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;managed-env&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">compute_resources</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">batch.ComputeResources(</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">vpc</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">vpc,</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">allocation_strategy</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">batch.AllocationStrategy.</span><span style="color: #6CB6FF">BEST_FIT</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">desiredv_cpus</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">maxv_cpus</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">64</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">minv_cpus</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">instance_types</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">[</span></span>
<span class="line"><span style="color: #ADBAC7">                    ec2.InstanceType(</span><span style="color: #96D0FF">&quot;g4dn.xlarge&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">                ],</span></span>
<span class="line"><span style="color: #ADBAC7">            ),</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">managed</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">True</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">compute_environment_name</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">.stack_name </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;compute-env&quot;</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        job_queue </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> batch.JobQueue(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;job-queue&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">compute_environments</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">[</span></span>
<span class="line"><span style="color: #ADBAC7">                batch.JobQueueComputeEnvironment(</span></span>
<span class="line"><span style="color: #ADBAC7">                    </span><span style="color: #F69D50">compute_environment</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">managed_env,</span></span>
<span class="line"><span style="color: #ADBAC7">                    </span><span style="color: #F69D50">order</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">100</span></span>
<span class="line"><span style="color: #ADBAC7">                )</span></span>
<span class="line"><span style="color: #ADBAC7">            ],</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">job_queue_name</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">.stack_name </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;job-queue&quot;</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        job_role </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> iam.Role(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;job-role&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">assumed_by</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">iam.CompositePrincipal(</span></span>
<span class="line"><span style="color: #ADBAC7">                iam.ServicePrincipal(</span><span style="color: #96D0FF">&quot;ecs-tasks.amazonaws.com&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">            )</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390"># allow read and write access to S3 bucket</span></span>
<span class="line"><span style="color: #ADBAC7">        bucket.grant_read_write(job_role)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        repo </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ecr.Repository(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;repository&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">removal_policy</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">core.RemovalPolicy.</span><span style="color: #6CB6FF">DESTROY</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        job_def </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> batch.JobDefinition(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;job-definition&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">container</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">batch.JobDefinitionContainer(</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">image</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ecs.ContainerImage.from_ecr_repository(repo),</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">command</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">[</span><span style="color: #96D0FF">&quot;python3&quot;</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;main.py&quot;</span><span style="color: #ADBAC7">],</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">vcpus</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">4</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">gpu_count</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">memory_limit_mib</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">12000</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">job_role</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">job_role,</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">environment</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">{</span></span>
<span class="line"><span style="color: #ADBAC7">                    </span><span style="color: #96D0FF">&quot;BUCKET_NAME&quot;</span><span style="color: #ADBAC7">: bucket.bucket_name</span></span>
<span class="line"><span style="color: #ADBAC7">                }</span></span>
<span class="line"><span style="color: #ADBAC7">            ),</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">job_definition_name</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">.stack_name </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;job-definition&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">timeout</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">core.Duration.hours(</span><span style="color: #6CB6FF">2</span><span style="color: #ADBAC7">),</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">class</span><span style="color: #24292E"> </span><span style="color: #6F42C1">SimpleBatch</span><span style="color: #24292E">(</span><span style="color: #6F42C1">core</span><span style="color: #24292E">.</span><span style="color: #6F42C1">Stack</span><span style="color: #24292E">):</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">def</span><span style="color: #24292E"> </span><span style="color: #005CC5">__init__</span><span style="color: #24292E">(self, scope: core.App, name: </span><span style="color: #005CC5">str</span><span style="color: #24292E">, </span><span style="color: #D73A49">**</span><span style="color: #24292E">kwargs) -&gt; </span><span style="color: #005CC5">None</span><span style="color: #24292E">:</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #005CC5">super</span><span style="color: #24292E">().</span><span style="color: #005CC5">__init__</span><span style="color: #24292E">(scope, name, </span><span style="color: #D73A49">**</span><span style="color: #24292E">kwargs)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        bucket </span><span style="color: #D73A49">=</span><span style="color: #24292E"> s3.Bucket(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;bucket&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">removal_policy</span><span style="color: #D73A49">=</span><span style="color: #24292E">core.RemovalPolicy.</span><span style="color: #005CC5">DESTROY</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">auto_delete_objects</span><span style="color: #D73A49">=</span><span style="color: #005CC5">True</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        vpc </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ec2.Vpc(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;vpc&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #6A737D"># other parameters...</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        managed_env </span><span style="color: #D73A49">=</span><span style="color: #24292E"> batch.ComputeEnvironment(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;managed-env&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">compute_resources</span><span style="color: #D73A49">=</span><span style="color: #24292E">batch.ComputeResources(</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">vpc</span><span style="color: #D73A49">=</span><span style="color: #24292E">vpc,</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">allocation_strategy</span><span style="color: #D73A49">=</span><span style="color: #24292E">batch.AllocationStrategy.</span><span style="color: #005CC5">BEST_FIT</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">desiredv_cpus</span><span style="color: #D73A49">=</span><span style="color: #005CC5">0</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">maxv_cpus</span><span style="color: #D73A49">=</span><span style="color: #005CC5">64</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">minv_cpus</span><span style="color: #D73A49">=</span><span style="color: #005CC5">0</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">instance_types</span><span style="color: #D73A49">=</span><span style="color: #24292E">[</span></span>
<span class="line"><span style="color: #24292E">                    ec2.InstanceType(</span><span style="color: #032F62">&quot;g4dn.xlarge&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">                ],</span></span>
<span class="line"><span style="color: #24292E">            ),</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">managed</span><span style="color: #D73A49">=</span><span style="color: #005CC5">True</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">compute_environment_name</span><span style="color: #D73A49">=</span><span style="color: #005CC5">self</span><span style="color: #24292E">.stack_name </span><span style="color: #D73A49">+</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;compute-env&quot;</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        job_queue </span><span style="color: #D73A49">=</span><span style="color: #24292E"> batch.JobQueue(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;job-queue&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">compute_environments</span><span style="color: #D73A49">=</span><span style="color: #24292E">[</span></span>
<span class="line"><span style="color: #24292E">                batch.JobQueueComputeEnvironment(</span></span>
<span class="line"><span style="color: #24292E">                    </span><span style="color: #E36209">compute_environment</span><span style="color: #D73A49">=</span><span style="color: #24292E">managed_env,</span></span>
<span class="line"><span style="color: #24292E">                    </span><span style="color: #E36209">order</span><span style="color: #D73A49">=</span><span style="color: #005CC5">100</span></span>
<span class="line"><span style="color: #24292E">                )</span></span>
<span class="line"><span style="color: #24292E">            ],</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">job_queue_name</span><span style="color: #D73A49">=</span><span style="color: #005CC5">self</span><span style="color: #24292E">.stack_name </span><span style="color: #D73A49">+</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;job-queue&quot;</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        job_role </span><span style="color: #D73A49">=</span><span style="color: #24292E"> iam.Role(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;job-role&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">assumed_by</span><span style="color: #D73A49">=</span><span style="color: #24292E">iam.CompositePrincipal(</span></span>
<span class="line"><span style="color: #24292E">                iam.ServicePrincipal(</span><span style="color: #032F62">&quot;ecs-tasks.amazonaws.com&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">            )</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D"># allow read and write access to S3 bucket</span></span>
<span class="line"><span style="color: #24292E">        bucket.grant_read_write(job_role)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        repo </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ecr.Repository(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;repository&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">removal_policy</span><span style="color: #D73A49">=</span><span style="color: #24292E">core.RemovalPolicy.</span><span style="color: #005CC5">DESTROY</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        job_def </span><span style="color: #D73A49">=</span><span style="color: #24292E"> batch.JobDefinition(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;job-definition&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">container</span><span style="color: #D73A49">=</span><span style="color: #24292E">batch.JobDefinitionContainer(</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">image</span><span style="color: #D73A49">=</span><span style="color: #24292E">ecs.ContainerImage.from_ecr_repository(repo),</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">command</span><span style="color: #D73A49">=</span><span style="color: #24292E">[</span><span style="color: #032F62">&quot;python3&quot;</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;main.py&quot;</span><span style="color: #24292E">],</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">vcpus</span><span style="color: #D73A49">=</span><span style="color: #005CC5">4</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">gpu_count</span><span style="color: #D73A49">=</span><span style="color: #005CC5">1</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">memory_limit_mib</span><span style="color: #D73A49">=</span><span style="color: #005CC5">12000</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">job_role</span><span style="color: #D73A49">=</span><span style="color: #24292E">job_role,</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">environment</span><span style="color: #D73A49">=</span><span style="color: #24292E">{</span></span>
<span class="line"><span style="color: #24292E">                    </span><span style="color: #032F62">&quot;BUCKET_NAME&quot;</span><span style="color: #24292E">: bucket.bucket_name</span></span>
<span class="line"><span style="color: #24292E">                }</span></span>
<span class="line"><span style="color: #24292E">            ),</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">job_definition_name</span><span style="color: #D73A49">=</span><span style="color: #005CC5">self</span><span style="color: #24292E">.stack_name </span><span style="color: #D73A49">+</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;job-definition&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">timeout</span><span style="color: #D73A49">=</span><span style="color: #24292E">core.Duration.hours(</span><span style="color: #005CC5">2</span><span style="color: #24292E">),</span></span>
<span class="line"><span style="color: #24292E">        )</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br><span class="line-number">36</span><br><span class="line-number">37</span><br><span class="line-number">38</span><br><span class="line-number">39</span><br><span class="line-number">40</span><br><span class="line-number">41</span><br><span class="line-number">42</span><br><span class="line-number">43</span><br><span class="line-number">44</span><br><span class="line-number">45</span><br><span class="line-number">46</span><br><span class="line-number">47</span><br><span class="line-number">48</span><br><span class="line-number">49</span><br><span class="line-number">50</span><br><span class="line-number">51</span><br><span class="line-number">52</span><br><span class="line-number">53</span><br><span class="line-number">54</span><br><span class="line-number">55</span><br><span class="line-number">56</span><br><span class="line-number">57</span><br><span class="line-number">58</span><br><span class="line-number">59</span><br><span class="line-number">60</span><br><span class="line-number">61</span><br><span class="line-number">62</span><br><span class="line-number">63</span><br><span class="line-number">64</span><br><span class="line-number">65</span><br><span class="line-number">66</span><br><span class="line-number">67</span><br><span class="line-number">68</span><br><span class="line-number">69</span><br><span class="line-number">70</span><br><span class="line-number">71</span><br><span class="line-number">72</span><br><span class="line-number">73</span><br><span class="line-number">74</span><br><span class="line-number">75</span><br><span class="line-number">76</span><br><span class="line-number">77</span><br><span class="line-number">78</span><br><span class="line-number">79</span><br></div></div><ul>
<li>
<p>で，計算結果を保存するための S3 バケットを用意している</p>
</li>
<li>
<p>で， Compute environment を定義している． ここでは <code>g4dn.xlarge</code> のインスタンスタイプを使用するとし，最大の vCPU 使用数は 64 と指定している． また，最小の vCPU は 0 である． 今回は，負荷がかかっていないときにアイドリング状態にあるインスタンスを用意する利点は全くないので，ここは 0 にするのが望ましい．</p>
</li>
<li>
<p>で， &lt;2&gt; で作成した Compute environment と紐付いた Job queue を定義している．</p>
</li>
<li>
<p>で，ジョブが計算結果を S3 に書き込むことができるよう， IAM ロールを定義している． (IAM とはリソースがもつ権限を管理する仕組みである．詳しくは (#sec:bashoutter_iam) を参照)</p>
</li>
<li>
<p>では， Docker image を配置するための ECR を定義している．</p>
</li>
<li>
<p>で Job definition を作成している． ここでは，4 vCPU， 12000 MB (=12GB) の RAM を使用するように指定している． また，今後必要となる環境変数 (<code>BUCKET_NAME</code>) を設定している． さらに， &lt;4&gt; で作った IAM を付与している．</p>
</li>
</ul>
<p><code>g4dn.xlarge</code> は 1 台あたり 4 vCPU が割り当てられている． このプログラムでは Compute environment の maximum vCPUs を 64 と指定しているので，最大で 16 台のインスタンスが同時に起動することになる． ここで maxium vCPUs を 64 に限定しているのは，なんらかのミスで意図せぬジョブを大量にクラスターに投入してしまった事態で，高額の AWS 利用料金が発生するのを防ぐためである． もし，自分のアプリケーションで必要と判断したならば自己責任において 64 よりも大きな数を設定して構わない．</p>
<p>ここで注意が一点ある． AWS では各アカウントごとに EC2 で起動できるインスタンスの上限が設定されている． この上限は AWS コンソールにログインし， EC2 コンソールの左側メニューバーの <code>Limits</code> をクリックすることで確認できる (<a href="#fig_ec2_limits">figure_title</a>)． <code>g4dn.xlarge</code> (EC2 の区分でいうと G ファミリーに属する) の制限を確認するには， <code>Running On-Demand All G instances</code> という名前の項目を見る． ここにある数字が， AWS によって課されたアカウントの上限であり，この上限を超えたインスタンスを起動することはできない． もし，自分の用途に対して上限が低すぎる場合は，上限の緩和申請を行うことができる． 詳しくは <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-resource-limits.html" target="_blank" rel="noreferrer">公式ドキュメンテーション &quot;Amazon EC2 service quotas&quot;</a> を参照のこと．</p>
<p><img src="./assets/aws_batch/ec2_limits.png" alt="EC2コンソールから各種の上限を確認する"></p>
<h2 id="スタックのデプロイ" tabindex="-1">スタックのデプロイ <a class="header-anchor" href="#スタックのデプロイ" aria-label="Permalink to &quot;スタックのデプロイ&quot;">&ZeroWidthSpace;</a></h2>
<p>スタックの中身が理解できたところで，早速スタックをデプロイしてみよう．</p>
<p>デプロイの手順は，これまでのハンズオンとほとんど共通である． ここでは，コマンドのみ列挙する (# で始まる行はコメントである)． シークレットキーの設定も忘れずに ( (#aws_cli_install))．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390"># プロジェクトのディレクトリに移動</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cd</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">handson/aws-batch</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># venv を作成し，依存ライブラリのインストールを行う</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python3</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-m</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">venv</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.env</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">source</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.env/bin/activate</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">pip</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">install</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-r</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">requirements.txt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># デプロイを実行</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cdk</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">deploy</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D"># プロジェクトのディレクトリに移動</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cd</span><span style="color: #24292E"> </span><span style="color: #032F62">handson/aws-batch</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># venv を作成し，依存ライブラリのインストールを行う</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python3</span><span style="color: #24292E"> </span><span style="color: #005CC5">-m</span><span style="color: #24292E"> </span><span style="color: #032F62">venv</span><span style="color: #24292E"> </span><span style="color: #032F62">.env</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">source</span><span style="color: #24292E"> </span><span style="color: #032F62">.env/bin/activate</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">pip</span><span style="color: #24292E"> </span><span style="color: #032F62">install</span><span style="color: #24292E"> </span><span style="color: #005CC5">-r</span><span style="color: #24292E"> </span><span style="color: #032F62">requirements.txt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># デプロイを実行</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cdk</span><span style="color: #24292E"> </span><span style="color: #032F62">deploy</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br></div></div><p>デプロイのコマンドが無事に実行されたことが確認できたら，AWS コンソールにログインして，デプロイされたスタックを確認してみよう． コンソールの検索バーで <code>batch</code> と入力し， AWS Batch の管理画面を開く (<a href="#fig_batch_console">figure_title</a>)．</p>
<p><img src="./assets/aws_batch/batch_console.png" alt="AWS Batch のコンソール画面 (ダッシュボード)"></p>
<p>まず目を向けてほしいのが，画面の一番下にある Compute environment overview の中の <code>SimpleBatchcompute-env</code> という名前の項目だ． Compute environment とは，先ほど述べたとおり，計算が実行される環境 (クラスターと読み替えてもよい) である． プログラムで指定したとおり， <code>g4dn.xlarge</code> が実際に使用されるインスタンスタイプとして表示されている． また， <code>Minimum vCPUs</code> が 0，<code>Maximum vCPUs</code> が 64 と設定されていることも見て取れる． 加えて，この時点では一つもジョブが走っていないので， <code>Desired vCPUs</code> は 0 になっている． より詳細な Compute environment の情報を閲覧したい場合は，名前をクリックすることで詳細画面が開く．</p>
<p>次に，Job queue overview にある <code>SimpleBatch-queue</code> という項目に注目してほしい． ここでは実行待ちのジョブ・実行中のジョブ・実行が完了したジョブを一覧で確認することができる． <code>PENDING</code>, <code>RUNNING</code>, <code>SUCCEEDED</code>, <code>FAILED</code> などのカラムがあることが確認できる．ジョブが進行するにつれて，ジョブの状態がこのカラムにしたがって遷移していく． 後でジョブを実際にサブミットしたときに戻ってこよう．</p>
<p>最後に，今回作成した Job definition を確認しよう． 左側のメニューから　<code>Job definitions</code> を選択し，次の画面で <code>SimpleBatchjob-definition</code> という項目を見つけて開く． ここから Job definition の詳細を閲覧することができる (<a href="#fig:batch_job_definition">figure_title</a>)． 中でも重要な情報としては，　<code>vCPUs</code>, <code>Memory</code>, <code>GPU</code> がそれぞれ Docker に割り当てられる vCPU・メモリー・ GPU の量を規定している． また， <code>Image</code> と書いてあるところに，ジョブで使用される Docker イメージが指定されている． ここでは， ECR のレポジトリを参照している． 現時点ではこの ECR は空である． 次のステップとして，この ECR にイメージを配置する作業を行おう．</p>
<p><img src="./assets/aws_batch/batch_job_definition.png" alt="AWS Batch から Job definition を確認"></p>
<h2 id="docker-image-を-ecr-に配置する" tabindex="-1">Docker image を ECR に配置する <a class="header-anchor" href="#docker-image-を-ecr-に配置する" aria-label="Permalink to &quot;Docker image を ECR に配置する&quot;">&ZeroWidthSpace;</a></h2>
<p>さて， Batch がジョブを実行するには，どこか指定された場所から Docker イメージをダウンロード (pull) してくる必要がある． 前回のハンズオン ( (#sec_fargate_qabot)) では，公開設定にしてある Docker Hub からイメージを pull してきた． 今回のハンズオンでは， AWS から提供されているレジストリである <strong>ECR (Elastic Container Registry)</strong> に image を配置するという設計を採用する． ECR を利用する利点は，自分だけがアクセスすることのできるプライベートなイメージの置き場所を用意できる点である． Batch は ECR からイメージを pull してくることで，タスクを実行する (<a href="#fig_batch_architecture">figure_title</a>)．</p>
<p>スタックのソースコードでいうと，次の箇所が ECR を定義している．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">repo </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ecr.Repository(</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;repository&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">removal_policy</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">core.RemovalPolicy.</span><span style="color: #6CB6FF">DESTROY</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">job_def </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> batch.JobDefinition(</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;job-definition&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">container</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">batch.JobDefinitionContainer(</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #F69D50">image</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ecs.ContainerImage.from_ecr_repository(repo), </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #6CB6FF">...</span></span>
<span class="line"><span style="color: #ADBAC7">    ),</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">...</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">repo </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ecr.Repository(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;repository&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">removal_policy</span><span style="color: #D73A49">=</span><span style="color: #24292E">core.RemovalPolicy.</span><span style="color: #005CC5">DESTROY</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">job_def </span><span style="color: #D73A49">=</span><span style="color: #24292E"> batch.JobDefinition(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;job-definition&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">container</span><span style="color: #D73A49">=</span><span style="color: #24292E">batch.JobDefinitionContainer(</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #E36209">image</span><span style="color: #D73A49">=</span><span style="color: #24292E">ecs.ContainerImage.from_ecr_repository(repo), </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #005CC5">...</span></span>
<span class="line"><span style="color: #24292E">    ),</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">...</span></span>
<span class="line"><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br></div></div><ul>
<li>
<p>で，新規の ECR を作成している．</p>
</li>
<li>
<p>で Job definition を定義する中で，イメージを &lt;1&gt; で作った ECR から取得するように指定している． これと同時に， Job definition には ECR へのアクセス権限が IAM を通じて自動的に付与される．</p>
</li>
</ul>
<p>さて，スタックをデプロイした時点では， ECR は空っぽである． ここに自分のアプリケーションで使う Docker イメージを push してあげる必要がある．</p>
<p>そのために，まずは AWS コンソールから ECR の画面を開こう (検索バーに <code>Elastic Container Registry</code> と入力すると出てくる)． <code>Private</code> というタブを選択すると， <code>simplebatch-repositoryXXXXXX</code> という名前のレポジトリが見つかるだろう (<a href="#fig_ecr_console1">figure_title</a>)．</p>
<p><img src="./assets/aws_batch/ecr_console1.png" alt="ECR のコンソール画面"></p>
<p>次に，このレポジトリの名前をクリックするとレポジトリの詳細画面に遷移する． そうしたら，画面右上にある <code>View push commands</code> というボタンをクリックする． すると <a href="#fig_ecr_push_command">figure_title</a> のようなポップアップ画面が立ち上がる．</p>
<p><img src="./assets/aws_batch/ecr_push_command.png" alt="ECR への push コマンド"></p>
<p>このポップアップ画面で表示されている四つのコマンドを順番に実行していくことで，手元の Docker イメージを ECR に push することができる． <strong>push を実行する前に， AWS の認証情報が設定されている</strong>ことを確認しよう． そのうえで，ハンズオンのソースコードの中にある <strong><code>docker/</code> という名前のディレクトリに移動</strong>する． そうしたら，ポップアップ画面で表示されたコマンドを上から順に実行していく．</p>
<p>ポップアップで表示されるコマンドの 2 つめを見てみると <code>docker build -t XXXXX .</code> となっている． 最後の <code>.</code> が重要で，これは <em>現在のディレクトリにある Dockerfile を使ってイメージをビルドせよ</em> という意味である． このような理由で， <code>Dockerfile</code> が置いてあるディレクトリに移動する必要がある．</p>
<p>四つ目のコマンドは，数 GB あるイメージを ECR にアップロードするので少し時間がかかるかもしれないが，これが完了するとめでたくイメージが ECR に配置されたことになる． もう一度 ECR のコンソールを見てみると，確かにイメージが配置されていることが確認できる (<a href="#fig_ecr_console2">figure_title</a>)． これで，AWS Batch を使ってジョブを実行させるための最後の準備が完了した．</p>
<p><img src="./assets/aws_batch/ecr_console2.png" alt="ECR へ image の配置が完了した"></p>
<h2 id="単一のジョブを実行する" tabindex="-1">単一のジョブを実行する <a class="header-anchor" href="#単一のジョブを実行する" aria-label="Permalink to &quot;単一のジョブを実行する&quot;">&ZeroWidthSpace;</a></h2>
<p>さて，ここからは実際に AWS Batch にジョブを投入する方法を見ていこう．</p>
<p>ハンズオンのディレクトリの <code>notebook/</code> というディレクトリの中に， <a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/aws-batch/notebook/run_single.ipynb" target="_blank" rel="noreferrer">run_single.ipynb</a> というファイルが見つかるはずである (<code>.ipynb</code> は Jupyter notebook のファイル形式)． これを Jupyter notebook から開こう．</p>
<p>今回のハンズオンでは， <code>venv</code> による仮想環境の中に Jupyter notebook もインストール済みである． なので，ローカルマシンから以下のコマンドで Jupyter notebook を立ち上げる．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390"># .env の仮想環境にいることを確認</span></span>
<span class="line"><span style="color: #ADBAC7">(</span><span style="color: #F69D50">.env</span><span style="color: #ADBAC7">) $ cd notebook</span></span>
<span class="line"><span style="color: #ADBAC7">(</span><span style="color: #F69D50">.env</span><span style="color: #ADBAC7">) $ jupyter notebook</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D"># .env の仮想環境にいることを確認</span></span>
<span class="line"><span style="color: #24292E">(</span><span style="color: #6F42C1">.env</span><span style="color: #24292E">) $ cd notebook</span></span>
<span class="line"><span style="color: #24292E">(</span><span style="color: #6F42C1">.env</span><span style="color: #24292E">) $ jupyter notebook</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><p>Jupyter notebook が起動したら， <code>run_single.ipynb</code> を開く．</p>
<p>最初の [1], [2], [3] 番のセルは，ジョブをサブミットするための関数 (<code>submit_job()</code>) を定義している．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390"># [1]</span></span>
<span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> boto3</span></span>
<span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> argparse</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># [2]</span></span>
<span class="line"><span style="color: #768390"># AWS 認証ヘルパー ...省略...</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># [3]</span></span>
<span class="line"><span style="color: #F47067">def</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">submit_job</span><span style="color: #ADBAC7">(lr:</span><span style="color: #6CB6FF">float</span><span style="color: #ADBAC7">, momentum:</span><span style="color: #6CB6FF">float</span><span style="color: #ADBAC7">, epochs:</span><span style="color: #6CB6FF">int</span><span style="color: #ADBAC7">, profile_name</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;default&quot;</span><span style="color: #ADBAC7">):</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> profile_name </span><span style="color: #F47067">is</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">None</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">        session </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> boto3.Session()</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">else</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">        session </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> boto3.Session(</span><span style="color: #F69D50">profile_name</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">profile_name)</span></span>
<span class="line"><span style="color: #ADBAC7">    client </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> session.client(</span><span style="color: #96D0FF">&quot;batch&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    title </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;lr&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">(lr).replace(</span><span style="color: #96D0FF">&quot;.&quot;</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;&quot;</span><span style="color: #ADBAC7">) </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;_m&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">(momentum).replace(</span><span style="color: #96D0FF">&quot;.&quot;</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">    resp </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> client.submit_job(</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #F69D50">jobName</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">title,</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #F69D50">jobQueue</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;SimpleBatchjob-queue&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #F69D50">jobDefinition</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;SimpleBatchjob-definition&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #F69D50">containerOverrides</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">{</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #96D0FF">&quot;command&quot;</span><span style="color: #ADBAC7">: [</span><span style="color: #96D0FF">&quot;--lr&quot;</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">(lr),</span></span>
<span class="line"><span style="color: #ADBAC7">                        </span><span style="color: #96D0FF">&quot;--momentum&quot;</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">(momentum),</span></span>
<span class="line"><span style="color: #ADBAC7">                        </span><span style="color: #96D0FF">&quot;--epochs&quot;</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">(epochs),</span></span>
<span class="line"><span style="color: #ADBAC7">                        </span><span style="color: #96D0FF">&quot;--uploadS3&quot;</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;true&quot;</span><span style="color: #ADBAC7">]</span></span>
<span class="line"><span style="color: #ADBAC7">        }</span></span>
<span class="line"><span style="color: #ADBAC7">    )</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">print</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;Job submitted!&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">print</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;job name&quot;</span><span style="color: #ADBAC7">, resp[</span><span style="color: #96D0FF">&quot;jobName&quot;</span><span style="color: #ADBAC7">], </span><span style="color: #96D0FF">&quot;job ID&quot;</span><span style="color: #ADBAC7">, resp[</span><span style="color: #96D0FF">&quot;jobId&quot;</span><span style="color: #ADBAC7">])</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D"># [1]</span></span>
<span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> boto3</span></span>
<span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> argparse</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># [2]</span></span>
<span class="line"><span style="color: #6A737D"># AWS 認証ヘルパー ...省略...</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># [3]</span></span>
<span class="line"><span style="color: #D73A49">def</span><span style="color: #24292E"> </span><span style="color: #6F42C1">submit_job</span><span style="color: #24292E">(lr:</span><span style="color: #005CC5">float</span><span style="color: #24292E">, momentum:</span><span style="color: #005CC5">float</span><span style="color: #24292E">, epochs:</span><span style="color: #005CC5">int</span><span style="color: #24292E">, profile_name</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;default&quot;</span><span style="color: #24292E">):</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">if</span><span style="color: #24292E"> profile_name </span><span style="color: #D73A49">is</span><span style="color: #24292E"> </span><span style="color: #005CC5">None</span><span style="color: #24292E">:</span></span>
<span class="line"><span style="color: #24292E">        session </span><span style="color: #D73A49">=</span><span style="color: #24292E"> boto3.Session()</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">else</span><span style="color: #24292E">:</span></span>
<span class="line"><span style="color: #24292E">        session </span><span style="color: #D73A49">=</span><span style="color: #24292E"> boto3.Session(</span><span style="color: #E36209">profile_name</span><span style="color: #D73A49">=</span><span style="color: #24292E">profile_name)</span></span>
<span class="line"><span style="color: #24292E">    client </span><span style="color: #D73A49">=</span><span style="color: #24292E"> session.client(</span><span style="color: #032F62">&quot;batch&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">    title </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;lr&quot;</span><span style="color: #24292E"> </span><span style="color: #D73A49">+</span><span style="color: #24292E"> </span><span style="color: #005CC5">str</span><span style="color: #24292E">(lr).replace(</span><span style="color: #032F62">&quot;.&quot;</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;&quot;</span><span style="color: #24292E">) </span><span style="color: #D73A49">+</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;_m&quot;</span><span style="color: #24292E"> </span><span style="color: #D73A49">+</span><span style="color: #24292E"> </span><span style="color: #005CC5">str</span><span style="color: #24292E">(momentum).replace(</span><span style="color: #032F62">&quot;.&quot;</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">    resp </span><span style="color: #D73A49">=</span><span style="color: #24292E"> client.submit_job(</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #E36209">jobName</span><span style="color: #D73A49">=</span><span style="color: #24292E">title,</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #E36209">jobQueue</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;SimpleBatchjob-queue&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #E36209">jobDefinition</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;SimpleBatchjob-definition&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #E36209">containerOverrides</span><span style="color: #D73A49">=</span><span style="color: #24292E">{</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #032F62">&quot;command&quot;</span><span style="color: #24292E">: [</span><span style="color: #032F62">&quot;--lr&quot;</span><span style="color: #24292E">, </span><span style="color: #005CC5">str</span><span style="color: #24292E">(lr),</span></span>
<span class="line"><span style="color: #24292E">                        </span><span style="color: #032F62">&quot;--momentum&quot;</span><span style="color: #24292E">, </span><span style="color: #005CC5">str</span><span style="color: #24292E">(momentum),</span></span>
<span class="line"><span style="color: #24292E">                        </span><span style="color: #032F62">&quot;--epochs&quot;</span><span style="color: #24292E">, </span><span style="color: #005CC5">str</span><span style="color: #24292E">(epochs),</span></span>
<span class="line"><span style="color: #24292E">                        </span><span style="color: #032F62">&quot;--uploadS3&quot;</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;true&quot;</span><span style="color: #24292E">]</span></span>
<span class="line"><span style="color: #24292E">        }</span></span>
<span class="line"><span style="color: #24292E">    )</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">print</span><span style="color: #24292E">(</span><span style="color: #032F62">&quot;Job submitted!&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">print</span><span style="color: #24292E">(</span><span style="color: #032F62">&quot;job name&quot;</span><span style="color: #24292E">, resp[</span><span style="color: #032F62">&quot;jobName&quot;</span><span style="color: #24292E">], </span><span style="color: #032F62">&quot;job ID&quot;</span><span style="color: #24292E">, resp[</span><span style="color: #032F62">&quot;jobId&quot;</span><span style="color: #24292E">])</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br></div></div><p><code>submit_job()</code> 関数について簡単に説明しよう． <a href="#sec_run_mnist_docker_local">MNIST 手書き文字認識 (再訪)</a> で， MNIST の Docker をローカルで実行したとき，次のようなコマンドを使用した．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">docker</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">run</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-it</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">mymnist</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--lr</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0.1</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--momentum</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0.5</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--epochs</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">10</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">docker</span><span style="color: #24292E"> </span><span style="color: #032F62">run</span><span style="color: #24292E"> </span><span style="color: #005CC5">-it</span><span style="color: #24292E"> </span><span style="color: #032F62">mymnist</span><span style="color: #24292E"> </span><span style="color: #005CC5">--lr</span><span style="color: #24292E"> </span><span style="color: #005CC5">0.1</span><span style="color: #24292E"> </span><span style="color: #005CC5">--momentum</span><span style="color: #24292E"> </span><span style="color: #005CC5">0.5</span><span style="color: #24292E"> </span><span style="color: #005CC5">--epochs</span><span style="color: #24292E"> </span><span style="color: #005CC5">10</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>ここで， <code>--lr 0.1 --momentum 0.5 --epochs 10</code> の部分が，コンテナに渡されるコマンドである．</p>
<p>AWS Batch でジョブを実行する際も，<code>ContainerOverrides</code> の <code>command</code> というパラメータを使用することで，コンテナに渡されるコマンドを指定することができる． コードでは以下の部分が該当する．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">containerOverrides</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">{</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #96D0FF">&quot;command&quot;</span><span style="color: #ADBAC7">: [</span><span style="color: #96D0FF">&quot;--lr&quot;</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">(lr),</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #96D0FF">&quot;--momentum&quot;</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">(momentum),</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #96D0FF">&quot;--epochs&quot;</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">(epochs),</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #96D0FF">&quot;--uploadS3&quot;</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;true&quot;</span><span style="color: #ADBAC7">]</span></span>
<span class="line"><span style="color: #ADBAC7">}</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">containerOverrides</span><span style="color: #D73A49">=</span><span style="color: #24292E">{</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #032F62">&quot;command&quot;</span><span style="color: #24292E">: [</span><span style="color: #032F62">&quot;--lr&quot;</span><span style="color: #24292E">, </span><span style="color: #005CC5">str</span><span style="color: #24292E">(lr),</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #032F62">&quot;--momentum&quot;</span><span style="color: #24292E">, </span><span style="color: #005CC5">str</span><span style="color: #24292E">(momentum),</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #032F62">&quot;--epochs&quot;</span><span style="color: #24292E">, </span><span style="color: #005CC5">str</span><span style="color: #24292E">(epochs),</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #032F62">&quot;--uploadS3&quot;</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;true&quot;</span><span style="color: #24292E">]</span></span>
<span class="line"><span style="color: #24292E">}</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br></div></div><p>続いて， [4] 番のセルに移ろう． ここでは，上記の <code>submit_job()</code> 関数を用いて， 学習率 = 0.01, モメンタム=0.1, エポック数=100 を指定したジョブを投入する．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390"># [4]</span></span>
<span class="line"><span style="color: #ADBAC7">submit_job(</span><span style="color: #6CB6FF">0.01</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">0.1</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">100</span><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D"># [4]</span></span>
<span class="line"><span style="color: #24292E">submit_job(</span><span style="color: #005CC5">0.01</span><span style="color: #24292E">, </span><span style="color: #005CC5">0.1</span><span style="color: #24292E">, </span><span style="color: #005CC5">100</span><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>AWS の認証情報は， Jupyter Notebook の内部から再度定義する必要がある． これを手助けするため， Notebook の [2] 番のセル (デフォルトではすべてコメントアウトされている) を用意した． これを使うにはコメントアウトを解除すればよい． このセルを実行すると， AWS の認証情報を入力する対話的なプロンプトが表示される． プロンプトに従って aws secret key などを入力することで， (Jupyter のセッションに固有な) 環境変数に AWS の認証情報が記録される．</p>
<p>もう一つの認証方法として， <code>submit_job()</code> 関数に <code>profile_name</code> というパラメータを用意した． もし <code>~/.aws/credentials</code> に認証情報が書き込まれているのならば (詳しくは (#aws_cli_install))， <code>profile_name</code> に使用したいプロファイルの名前を渡すだけで， 認証を行うことができる． 慣れている読者は後者のほうが便利であると感じるだろう．</p>
<p>[4] 番のセルを実行したら，ジョブが実際に投入されたかどうかを AWS コンソールから確認してみよう． AWS Batch の管理コンソールを開くと， <a href="#fig_batch_running_job">figure_title</a> のような画面が表示されるだろう．</p>
<p><img src="./assets/aws_batch/batch_running_job.png" alt="AWS Batch でジョブが実行されている様子"></p>
<p><a href="#fig_batch_running_job">figure_title</a> で赤で囲った箇所に注目してほしい． 一つのジョブが投入されると，それは <code>SUBMITTED</code> という状態を経て <code>RUNNABLE</code> という状態に遷移する． <code>RUNNABLE</code> とは， ジョブを実行するためのインスタンスが Compute environment に不足しているため，新たなインスタンスが起動されるのを待っている状態に相当する． インスタンスの準備が整うと，ジョブの状態は <code>STARTING</code> を経て <code>RUNNING</code> に至る．</p>
<p>次に，ジョブのステータスが <code>RUNNING</code> のときの Compute environment の <code>Desired vCPU</code> を見てみよう (<a href="#fig_batch_running_job">figure_title</a> で紫で囲った箇所)． ここで 4 と表示されているのは， <code>g4dn.xlarge</code> インスタンス一つ分の vCPU の数である． ジョブの投入に応じて，それを実行するのに最低限必要な EC2 インスタンスが起動されたことが確認できる (興味のある人は， EC2 コンソールも同時に覗いてみるとよい)．</p>
<p>しばらく経つと，ジョブの状態は <code>RUNNING</code> から <code>SUCCEEDED</code> (あるいは何らかの理由でエラーが発生したときには <code>FAILED</code>) に遷移する． 今回のハンズオンで使っている MNIST の学習はだいたい 10 分くらいで完了するはずである． ジョブの状態が <code>SUCCEEDED</code> になるまで見届けよう．</p>
<p>ジョブが完了すると，学習の結果 (エポックごとの Loss と Accuracy を記録した CSV ファイル) は S3 に保存される． AWS コンソールからこれを確認しよう．</p>
<p>S3 のコンソールに行くと <code>simplebatch-bucketXXXX</code> (XXXX の部分はユーザーによって異なる) という名前のバケットが見つかるはずである． これをクリックして中身を見てみると， <code>metrics_lr0.0100_m0.1000.csv</code> という名前の CSV があることが確認できるだろう (<a href="#fig_s3_saved_file">figure_title</a>)． これが， 学習率 = 0.01, モメンタム = 0.1 として学習を行ったときの結果である．</p>
<p><img src="./assets/aws_batch/s3_saved_file.png" alt="ジョブの実行結果は S3 に保存される"></p>
<p>さて，ここで <code>run_single.ipynb</code> に戻ってこよう． [5] から [7] 番のセルでは，学習結果の CSV ファイルのダウンロードを行っている．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390"># [5]</span></span>
<span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> pandas </span><span style="color: #F47067">as</span><span style="color: #ADBAC7"> pd</span></span>
<span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> io</span></span>
<span class="line"><span style="color: #F47067">from</span><span style="color: #ADBAC7"> matplotlib </span><span style="color: #F47067">import</span><span style="color: #ADBAC7"> pyplot </span><span style="color: #F47067">as</span><span style="color: #ADBAC7"> plt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># [6]</span></span>
<span class="line"><span style="color: #F47067">def</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">read_table_from_s3</span><span style="color: #ADBAC7">(bucket_name, key, profile_name</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">None</span><span style="color: #ADBAC7">):</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> profile_name </span><span style="color: #F47067">is</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">None</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">        session </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> boto3.Session()</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">else</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">        session </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> boto3.Session(</span><span style="color: #F69D50">profile_name</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">profile_name)</span></span>
<span class="line"><span style="color: #ADBAC7">    s3 </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> session.resource(</span><span style="color: #96D0FF">&quot;s3&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">    bucket </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> s3.Bucket(bucket_name)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    obj </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> bucket.Object(key).get().get(</span><span style="color: #96D0FF">&quot;Body&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">    df </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> pd.read_csv(obj)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">return</span><span style="color: #ADBAC7"> df</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># [7]</span></span>
<span class="line"><span style="color: #ADBAC7">bucket_name </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;simplebatch-bucket43879c71-mbqaltx441fu&quot;</span></span>
<span class="line"><span style="color: #ADBAC7">df </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> read_table_from_s3(</span></span>
<span class="line"><span style="color: #ADBAC7">    bucket_name,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #96D0FF">&quot;metrics_lr0.0100_m0.1000.csv&quot;</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D"># [5]</span></span>
<span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> pandas </span><span style="color: #D73A49">as</span><span style="color: #24292E"> pd</span></span>
<span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> io</span></span>
<span class="line"><span style="color: #D73A49">from</span><span style="color: #24292E"> matplotlib </span><span style="color: #D73A49">import</span><span style="color: #24292E"> pyplot </span><span style="color: #D73A49">as</span><span style="color: #24292E"> plt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># [6]</span></span>
<span class="line"><span style="color: #D73A49">def</span><span style="color: #24292E"> </span><span style="color: #6F42C1">read_table_from_s3</span><span style="color: #24292E">(bucket_name, key, profile_name</span><span style="color: #D73A49">=</span><span style="color: #005CC5">None</span><span style="color: #24292E">):</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">if</span><span style="color: #24292E"> profile_name </span><span style="color: #D73A49">is</span><span style="color: #24292E"> </span><span style="color: #005CC5">None</span><span style="color: #24292E">:</span></span>
<span class="line"><span style="color: #24292E">        session </span><span style="color: #D73A49">=</span><span style="color: #24292E"> boto3.Session()</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">else</span><span style="color: #24292E">:</span></span>
<span class="line"><span style="color: #24292E">        session </span><span style="color: #D73A49">=</span><span style="color: #24292E"> boto3.Session(</span><span style="color: #E36209">profile_name</span><span style="color: #D73A49">=</span><span style="color: #24292E">profile_name)</span></span>
<span class="line"><span style="color: #24292E">    s3 </span><span style="color: #D73A49">=</span><span style="color: #24292E"> session.resource(</span><span style="color: #032F62">&quot;s3&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">    bucket </span><span style="color: #D73A49">=</span><span style="color: #24292E"> s3.Bucket(bucket_name)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">    obj </span><span style="color: #D73A49">=</span><span style="color: #24292E"> bucket.Object(key).get().get(</span><span style="color: #032F62">&quot;Body&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">    df </span><span style="color: #D73A49">=</span><span style="color: #24292E"> pd.read_csv(obj)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">return</span><span style="color: #24292E"> df</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># [7]</span></span>
<span class="line"><span style="color: #24292E">bucket_name </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;simplebatch-bucket43879c71-mbqaltx441fu&quot;</span></span>
<span class="line"><span style="color: #24292E">df </span><span style="color: #D73A49">=</span><span style="color: #24292E"> read_table_from_s3(</span></span>
<span class="line"><span style="color: #24292E">    bucket_name,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #032F62">&quot;metrics_lr0.0100_m0.1000.csv&quot;</span></span>
<span class="line"><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br></div></div><p>[6] で S3 から CSV データをダウンロードし， pandas の <code>DataFrame</code> オブジェクトとしてロードする関数を定義している． [7] を実行する際， <code>bucket_name</code> という変数の値を，<strong>自分自身のバケットの名前に置き換える</strong>ことに注意しよう (先ほど S3 コンソールから確認した <code>simplebatch-bucketXXXX</code> のことである)．</p>
<p>続いて， [9] 番のセルで， CSV のデータをプロットしている (<a href="#fig_loss_epoch_profile2">figure_title</a>)． ローカルで実行したときと同じように， AWS Batch を用いて MNIST モデルを訓練することに成功した！</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390"># [9]</span></span>
<span class="line"><span style="color: #ADBAC7">fig, (ax1, ax2) </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> plt.subplots(</span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">2</span><span style="color: #ADBAC7">, </span><span style="color: #F69D50">figsize</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">9</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">4</span><span style="color: #ADBAC7">))</span></span>
<span class="line"><span style="color: #ADBAC7">x </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> [i </span><span style="color: #F47067">for</span><span style="color: #ADBAC7"> i </span><span style="color: #F47067">in</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">range</span><span style="color: #ADBAC7">(df.shape[</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">])]</span></span>
<span class="line"><span style="color: #ADBAC7">ax1.plot(x, df[</span><span style="color: #96D0FF">&quot;train_loss&quot;</span><span style="color: #ADBAC7">], </span><span style="color: #F69D50">label</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;Train&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">ax1.plot(x, df[</span><span style="color: #96D0FF">&quot;val_loss&quot;</span><span style="color: #ADBAC7">], </span><span style="color: #F69D50">label</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;Val&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">ax2.plot(x, df[</span><span style="color: #96D0FF">&quot;val_accuracy&quot;</span><span style="color: #ADBAC7">])</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">ax1.set_xlabel(</span><span style="color: #96D0FF">&quot;Epochs&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">ax1.set_ylabel(</span><span style="color: #96D0FF">&quot;Loss&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">ax1.legend()</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">ax2.set_xlabel(</span><span style="color: #96D0FF">&quot;Epochs&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">ax2.set_ylabel(</span><span style="color: #96D0FF">&quot;Accuracy&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6CB6FF">print</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;Best loss:&quot;</span><span style="color: #ADBAC7">, df[</span><span style="color: #96D0FF">&quot;val_loss&quot;</span><span style="color: #ADBAC7">].min())</span></span>
<span class="line"><span style="color: #6CB6FF">print</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;Best loss epoch:&quot;</span><span style="color: #ADBAC7">, df[</span><span style="color: #96D0FF">&quot;val_loss&quot;</span><span style="color: #ADBAC7">].argmin())</span></span>
<span class="line"><span style="color: #6CB6FF">print</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;Best accuracy:&quot;</span><span style="color: #ADBAC7">, df[</span><span style="color: #96D0FF">&quot;val_accuracy&quot;</span><span style="color: #ADBAC7">].max())</span></span>
<span class="line"><span style="color: #6CB6FF">print</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;Best accuracy epoch:&quot;</span><span style="color: #ADBAC7">, df[</span><span style="color: #96D0FF">&quot;val_accuracy&quot;</span><span style="color: #ADBAC7">].argmax())</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D"># [9]</span></span>
<span class="line"><span style="color: #24292E">fig, (ax1, ax2) </span><span style="color: #D73A49">=</span><span style="color: #24292E"> plt.subplots(</span><span style="color: #005CC5">1</span><span style="color: #24292E">,</span><span style="color: #005CC5">2</span><span style="color: #24292E">, </span><span style="color: #E36209">figsize</span><span style="color: #D73A49">=</span><span style="color: #24292E">(</span><span style="color: #005CC5">9</span><span style="color: #24292E">,</span><span style="color: #005CC5">4</span><span style="color: #24292E">))</span></span>
<span class="line"><span style="color: #24292E">x </span><span style="color: #D73A49">=</span><span style="color: #24292E"> [i </span><span style="color: #D73A49">for</span><span style="color: #24292E"> i </span><span style="color: #D73A49">in</span><span style="color: #24292E"> </span><span style="color: #005CC5">range</span><span style="color: #24292E">(df.shape[</span><span style="color: #005CC5">0</span><span style="color: #24292E">])]</span></span>
<span class="line"><span style="color: #24292E">ax1.plot(x, df[</span><span style="color: #032F62">&quot;train_loss&quot;</span><span style="color: #24292E">], </span><span style="color: #E36209">label</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;Train&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">ax1.plot(x, df[</span><span style="color: #032F62">&quot;val_loss&quot;</span><span style="color: #24292E">], </span><span style="color: #E36209">label</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;Val&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">ax2.plot(x, df[</span><span style="color: #032F62">&quot;val_accuracy&quot;</span><span style="color: #24292E">])</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">ax1.set_xlabel(</span><span style="color: #032F62">&quot;Epochs&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">ax1.set_ylabel(</span><span style="color: #032F62">&quot;Loss&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">ax1.legend()</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">ax2.set_xlabel(</span><span style="color: #032F62">&quot;Epochs&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">ax2.set_ylabel(</span><span style="color: #032F62">&quot;Accuracy&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #005CC5">print</span><span style="color: #24292E">(</span><span style="color: #032F62">&quot;Best loss:&quot;</span><span style="color: #24292E">, df[</span><span style="color: #032F62">&quot;val_loss&quot;</span><span style="color: #24292E">].min())</span></span>
<span class="line"><span style="color: #005CC5">print</span><span style="color: #24292E">(</span><span style="color: #032F62">&quot;Best loss epoch:&quot;</span><span style="color: #24292E">, df[</span><span style="color: #032F62">&quot;val_loss&quot;</span><span style="color: #24292E">].argmin())</span></span>
<span class="line"><span style="color: #005CC5">print</span><span style="color: #24292E">(</span><span style="color: #032F62">&quot;Best accuracy:&quot;</span><span style="color: #24292E">, df[</span><span style="color: #032F62">&quot;val_accuracy&quot;</span><span style="color: #24292E">].max())</span></span>
<span class="line"><span style="color: #005CC5">print</span><span style="color: #24292E">(</span><span style="color: #032F62">&quot;Best accuracy epoch:&quot;</span><span style="color: #24292E">, df[</span><span style="color: #032F62">&quot;val_accuracy&quot;</span><span style="color: #24292E">].argmax())</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br></div></div><p><img src="./assets/aws_batch/loss_epoch_profile2.png" alt="AWS Batch で行った MNIST モデルの学習の結果"></p>
<h2 id="並列に複数の-job-を実行する" tabindex="-1">並列に複数の Job を実行する <a class="header-anchor" href="#並列に複数の-job-を実行する" aria-label="Permalink to &quot;並列に複数の Job を実行する&quot;">&ZeroWidthSpace;</a></h2>
<p>さて，ここからが最後の仕上げである． ここまでのハンズオンで構築した AWS Batch のシステムを使って，ハイパーパラメータサーチを実際に行おう．</p>
<p>先ほど実行した <code>run_single.ipynb</code> と同じディレクトリにある <code>run_sweep.ipynb</code> を開く．</p>
<p>セル [1], [2], [3] は <code>run_single.ipynb</code> と同一である．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390"># [1]</span></span>
<span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> boto3</span></span>
<span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> argparse</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># [2]</span></span>
<span class="line"><span style="color: #768390"># AWS 認証ヘルパー ...省略...</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># [3]</span></span>
<span class="line"><span style="color: #F47067">def</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">submit_job</span><span style="color: #ADBAC7">(lr:</span><span style="color: #6CB6FF">float</span><span style="color: #ADBAC7">, momentum:</span><span style="color: #6CB6FF">float</span><span style="color: #ADBAC7">, epochs:</span><span style="color: #6CB6FF">int</span><span style="color: #ADBAC7">, profile_name</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">None</span><span style="color: #ADBAC7">):</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #768390"># ...省略...</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D"># [1]</span></span>
<span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> boto3</span></span>
<span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> argparse</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># [2]</span></span>
<span class="line"><span style="color: #6A737D"># AWS 認証ヘルパー ...省略...</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># [3]</span></span>
<span class="line"><span style="color: #D73A49">def</span><span style="color: #24292E"> </span><span style="color: #6F42C1">submit_job</span><span style="color: #24292E">(lr:</span><span style="color: #005CC5">float</span><span style="color: #24292E">, momentum:</span><span style="color: #005CC5">float</span><span style="color: #24292E">, epochs:</span><span style="color: #005CC5">int</span><span style="color: #24292E">, profile_name</span><span style="color: #D73A49">=</span><span style="color: #005CC5">None</span><span style="color: #24292E">):</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #6A737D"># ...省略...</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br></div></div><p>セル [4] の for ループを使って，グリッド状にハイパーパラメータの組み合わせを用意し， batch にジョブを投入している． ここでは 3x3=9 個のジョブを作成した．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390"># [4]</span></span>
<span class="line"><span style="color: #F47067">for</span><span style="color: #ADBAC7"> lr </span><span style="color: #F47067">in</span><span style="color: #ADBAC7"> [</span><span style="color: #6CB6FF">0.1</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">0.01</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">0.001</span><span style="color: #ADBAC7">]:</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">for</span><span style="color: #ADBAC7"> m </span><span style="color: #F47067">in</span><span style="color: #ADBAC7"> [</span><span style="color: #6CB6FF">0.5</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">0.1</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">0.05</span><span style="color: #ADBAC7">]:</span></span>
<span class="line"><span style="color: #ADBAC7">        submit_job(lr, m, </span><span style="color: #6CB6FF">100</span><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D"># [4]</span></span>
<span class="line"><span style="color: #D73A49">for</span><span style="color: #24292E"> lr </span><span style="color: #D73A49">in</span><span style="color: #24292E"> [</span><span style="color: #005CC5">0.1</span><span style="color: #24292E">, </span><span style="color: #005CC5">0.01</span><span style="color: #24292E">, </span><span style="color: #005CC5">0.001</span><span style="color: #24292E">]:</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">for</span><span style="color: #24292E"> m </span><span style="color: #D73A49">in</span><span style="color: #24292E"> [</span><span style="color: #005CC5">0.5</span><span style="color: #24292E">, </span><span style="color: #005CC5">0.1</span><span style="color: #24292E">, </span><span style="color: #005CC5">0.05</span><span style="color: #24292E">]:</span></span>
<span class="line"><span style="color: #24292E">        submit_job(lr, m, </span><span style="color: #005CC5">100</span><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br></div></div><p>セル [4] を実行したら， Batch のコンソールを開こう． 先ほどと同様に，ジョブのステータスは <code>SUBMITTED</code> &gt; <code>RUNNABLE</code> &gt; <code>STARTING</code> &gt; <code>RUNNING</code> と移り変わっていくことがわかるだろう． 最終的に 9 個のジョブがすべて <code>RUNNING</code> の状態になることを確認しよう (<a href="#fig_batch_many_parallel_jobs">figure_title</a>)． また，このとき Compute environment の <code>Desired vCPUs</code> は 4x9=36 となっていることを確認しよう (<a href="#fig_batch_many_parallel_jobs">figure_title</a>)．</p>
<p><img src="./assets/aws_batch/batch_many_parallel_jobs.png" alt="複数のジョブを同時投入したときの Batch コンソール"></p>
<p>次に，Batch のコンソールの左側のメニューから <code>Jobs</code> をクリックしてみよう． ここでは，実行中のジョブの一覧が確認することができる (<a href="#fig_batch_parallel_job_list">figure_title</a>)． ジョブのステータスでフィルタリングをすることも可能である． 9 個のジョブがどれも <code>RUNNING</code> 状態にあることが確認できるだろう．</p>
<p><img src="./assets/aws_batch/batch_parallel_job_list.png" alt="複数のジョブを同時投入したときの Job 一覧"></p>
<p>今度は EC2 コンソールを見てみよう． 左のメニューから <code>Instances</code> を選択すると， <a href="#fig_ec2_instances_list">figure_title</a> に示すような起動中のインスタンスの一覧が表示される． <code>g4dn.xlarge</code> が 9 台稼働しているのが確認できる． Batch がジョブの投下に合わせて必要な数のインスタンスを起動してくれたのだ！</p>
<p><img src="./assets/aws_batch/ec2_instances_list.png" alt="複数のジョブを同時投入したときの EC2 インスタンスの一覧"></p>
<p>ここまで確認できたら，それぞれの Job が終了するまでしばらく待とう (だいたい 10-15 分くらいで終わる)． すべてのジョブが終了すると，ダッシュボードの <code>SUCCEEDED</code> が 9 となっているはずだ． また， Compute environment の <code>Desired vCPUs</code> も 0 に落ちていることを確認しよう． 最後に EC2 コンソールに行って，すべての g4dn インスタンスが停止していることを確認しよう．</p>
<p>以上から， AWS Batch を使うことで，<strong>ジョブの投入に応じて自動的に EC2 インスタンスが起動され，ジョブの完了とともに，ただちにインスタンスの停止が行われる</strong>一連の挙動を観察することができた． 一つのジョブの完了におよそ 10 分の時間がかかるので，9 個のハイパーパラメータの組を逐次的に計算していた場合は 90 分の時間を要することになる． AWS Batch を使ってこれらの計算を並列に実行することで，ジョブ一個分の計算時間 (=10 分) ですべての計算を終えることができた！</p>
<p>さて，再び <code>run_sweep.ipynb</code> に戻ってこよう． [5] 以降のセルでは，グリッドサーチの結果を可視化している．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390"># [5]</span></span>
<span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> pandas </span><span style="color: #F47067">as</span><span style="color: #ADBAC7"> pd</span></span>
<span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> numpy </span><span style="color: #F47067">as</span><span style="color: #ADBAC7"> np</span></span>
<span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> io</span></span>
<span class="line"><span style="color: #F47067">from</span><span style="color: #ADBAC7"> matplotlib </span><span style="color: #F47067">import</span><span style="color: #ADBAC7"> pyplot </span><span style="color: #F47067">as</span><span style="color: #ADBAC7"> plt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># [6]</span></span>
<span class="line"><span style="color: #F47067">def</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">read_table_from_s3</span><span style="color: #ADBAC7">(bucket_name, key, profile_name</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">None</span><span style="color: #ADBAC7">):</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> profile_name </span><span style="color: #F47067">is</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">None</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">        session </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> boto3.Session()</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">else</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">        session </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> boto3.Session(</span><span style="color: #F69D50">profile_name</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">profile_name)</span></span>
<span class="line"><span style="color: #ADBAC7">    s3 </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> session.resource(</span><span style="color: #96D0FF">&quot;s3&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">    bucket </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> s3.Bucket(bucket_name)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    obj </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> bucket.Object(key).get().get(</span><span style="color: #96D0FF">&quot;Body&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">    df </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> pd.read_csv(obj)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">return</span><span style="color: #ADBAC7"> df</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># [7]</span></span>
<span class="line"><span style="color: #ADBAC7">grid </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> np.zeros((</span><span style="color: #6CB6FF">3</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">3</span><span style="color: #ADBAC7">))</span></span>
<span class="line"><span style="color: #F47067">for</span><span style="color: #ADBAC7"> (i, lr) </span><span style="color: #F47067">in</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">enumerate</span><span style="color: #ADBAC7">([</span><span style="color: #6CB6FF">0.1</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">0.01</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">0.001</span><span style="color: #ADBAC7">]):</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">for</span><span style="color: #ADBAC7"> (j, m) </span><span style="color: #F47067">in</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">enumerate</span><span style="color: #ADBAC7">([</span><span style="color: #6CB6FF">0.5</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">0.1</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">0.05</span><span style="color: #ADBAC7">]):</span></span>
<span class="line"><span style="color: #ADBAC7">        key </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">f</span><span style="color: #96D0FF">&quot;metrics_lr</span><span style="color: #F47067">{</span><span style="color: #ADBAC7">lr</span><span style="color: #F47067">:0.4f}</span><span style="color: #96D0FF">_m</span><span style="color: #F47067">{</span><span style="color: #ADBAC7">m</span><span style="color: #F47067">:0.4f}</span><span style="color: #96D0FF">.csv&quot;</span></span>
<span class="line"><span style="color: #ADBAC7">        df </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> read_table_from_s3(</span><span style="color: #96D0FF">&quot;simplebatch-bucket43879c71-mbqaltx441fu&quot;</span><span style="color: #ADBAC7">, key)</span></span>
<span class="line"><span style="color: #ADBAC7">        grid[i,j] </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> df[</span><span style="color: #96D0FF">&quot;val_accuracy&quot;</span><span style="color: #ADBAC7">].max()</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># [8]</span></span>
<span class="line"><span style="color: #ADBAC7">fig, ax </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> plt.subplots(</span><span style="color: #F69D50">figsize</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">6</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">6</span><span style="color: #ADBAC7">))</span></span>
<span class="line"><span style="color: #ADBAC7">ax.set_aspect(</span><span style="color: #96D0FF">&#39;equal&#39;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">c </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ax.pcolor(grid, </span><span style="color: #F69D50">edgecolors</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&#39;w&#39;</span><span style="color: #ADBAC7">, </span><span style="color: #F69D50">linewidths</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">2</span><span style="color: #ADBAC7">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F47067">for</span><span style="color: #ADBAC7"> i </span><span style="color: #F47067">in</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">range</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">3</span><span style="color: #ADBAC7">):</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">for</span><span style="color: #ADBAC7"> j </span><span style="color: #F47067">in</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">range</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">3</span><span style="color: #ADBAC7">):</span></span>
<span class="line"><span style="color: #ADBAC7">        text </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ax.text(j</span><span style="color: #F47067">+</span><span style="color: #6CB6FF">0.5</span><span style="color: #ADBAC7">, i</span><span style="color: #F47067">+</span><span style="color: #6CB6FF">0.5</span><span style="color: #ADBAC7">, </span><span style="color: #F47067">f</span><span style="color: #96D0FF">&quot;</span><span style="color: #F47067">{</span><span style="color: #ADBAC7">grid[i, j]</span><span style="color: #F47067">:0.1f}</span><span style="color: #96D0FF">&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                       </span><span style="color: #F69D50">ha</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;center&quot;</span><span style="color: #ADBAC7">, </span><span style="color: #F69D50">va</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;center&quot;</span><span style="color: #ADBAC7">, </span><span style="color: #F69D50">color</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;w&quot;</span><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D"># [5]</span></span>
<span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> pandas </span><span style="color: #D73A49">as</span><span style="color: #24292E"> pd</span></span>
<span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> numpy </span><span style="color: #D73A49">as</span><span style="color: #24292E"> np</span></span>
<span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> io</span></span>
<span class="line"><span style="color: #D73A49">from</span><span style="color: #24292E"> matplotlib </span><span style="color: #D73A49">import</span><span style="color: #24292E"> pyplot </span><span style="color: #D73A49">as</span><span style="color: #24292E"> plt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># [6]</span></span>
<span class="line"><span style="color: #D73A49">def</span><span style="color: #24292E"> </span><span style="color: #6F42C1">read_table_from_s3</span><span style="color: #24292E">(bucket_name, key, profile_name</span><span style="color: #D73A49">=</span><span style="color: #005CC5">None</span><span style="color: #24292E">):</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">if</span><span style="color: #24292E"> profile_name </span><span style="color: #D73A49">is</span><span style="color: #24292E"> </span><span style="color: #005CC5">None</span><span style="color: #24292E">:</span></span>
<span class="line"><span style="color: #24292E">        session </span><span style="color: #D73A49">=</span><span style="color: #24292E"> boto3.Session()</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">else</span><span style="color: #24292E">:</span></span>
<span class="line"><span style="color: #24292E">        session </span><span style="color: #D73A49">=</span><span style="color: #24292E"> boto3.Session(</span><span style="color: #E36209">profile_name</span><span style="color: #D73A49">=</span><span style="color: #24292E">profile_name)</span></span>
<span class="line"><span style="color: #24292E">    s3 </span><span style="color: #D73A49">=</span><span style="color: #24292E"> session.resource(</span><span style="color: #032F62">&quot;s3&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">    bucket </span><span style="color: #D73A49">=</span><span style="color: #24292E"> s3.Bucket(bucket_name)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">    obj </span><span style="color: #D73A49">=</span><span style="color: #24292E"> bucket.Object(key).get().get(</span><span style="color: #032F62">&quot;Body&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">    df </span><span style="color: #D73A49">=</span><span style="color: #24292E"> pd.read_csv(obj)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">return</span><span style="color: #24292E"> df</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># [7]</span></span>
<span class="line"><span style="color: #24292E">grid </span><span style="color: #D73A49">=</span><span style="color: #24292E"> np.zeros((</span><span style="color: #005CC5">3</span><span style="color: #24292E">,</span><span style="color: #005CC5">3</span><span style="color: #24292E">))</span></span>
<span class="line"><span style="color: #D73A49">for</span><span style="color: #24292E"> (i, lr) </span><span style="color: #D73A49">in</span><span style="color: #24292E"> </span><span style="color: #005CC5">enumerate</span><span style="color: #24292E">([</span><span style="color: #005CC5">0.1</span><span style="color: #24292E">, </span><span style="color: #005CC5">0.01</span><span style="color: #24292E">, </span><span style="color: #005CC5">0.001</span><span style="color: #24292E">]):</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">for</span><span style="color: #24292E"> (j, m) </span><span style="color: #D73A49">in</span><span style="color: #24292E"> </span><span style="color: #005CC5">enumerate</span><span style="color: #24292E">([</span><span style="color: #005CC5">0.5</span><span style="color: #24292E">, </span><span style="color: #005CC5">0.1</span><span style="color: #24292E">, </span><span style="color: #005CC5">0.05</span><span style="color: #24292E">]):</span></span>
<span class="line"><span style="color: #24292E">        key </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #D73A49">f</span><span style="color: #032F62">&quot;metrics_lr</span><span style="color: #005CC5">{</span><span style="color: #24292E">lr</span><span style="color: #D73A49">:0.4f</span><span style="color: #005CC5">}</span><span style="color: #032F62">_m</span><span style="color: #005CC5">{</span><span style="color: #24292E">m</span><span style="color: #D73A49">:0.4f</span><span style="color: #005CC5">}</span><span style="color: #032F62">.csv&quot;</span></span>
<span class="line"><span style="color: #24292E">        df </span><span style="color: #D73A49">=</span><span style="color: #24292E"> read_table_from_s3(</span><span style="color: #032F62">&quot;simplebatch-bucket43879c71-mbqaltx441fu&quot;</span><span style="color: #24292E">, key)</span></span>
<span class="line"><span style="color: #24292E">        grid[i,j] </span><span style="color: #D73A49">=</span><span style="color: #24292E"> df[</span><span style="color: #032F62">&quot;val_accuracy&quot;</span><span style="color: #24292E">].max()</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># [8]</span></span>
<span class="line"><span style="color: #24292E">fig, ax </span><span style="color: #D73A49">=</span><span style="color: #24292E"> plt.subplots(</span><span style="color: #E36209">figsize</span><span style="color: #D73A49">=</span><span style="color: #24292E">(</span><span style="color: #005CC5">6</span><span style="color: #24292E">,</span><span style="color: #005CC5">6</span><span style="color: #24292E">))</span></span>
<span class="line"><span style="color: #24292E">ax.set_aspect(</span><span style="color: #032F62">&#39;equal&#39;</span><span style="color: #24292E">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">c </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ax.pcolor(grid, </span><span style="color: #E36209">edgecolors</span><span style="color: #D73A49">=</span><span style="color: #032F62">&#39;w&#39;</span><span style="color: #24292E">, </span><span style="color: #E36209">linewidths</span><span style="color: #D73A49">=</span><span style="color: #005CC5">2</span><span style="color: #24292E">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D73A49">for</span><span style="color: #24292E"> i </span><span style="color: #D73A49">in</span><span style="color: #24292E"> </span><span style="color: #005CC5">range</span><span style="color: #24292E">(</span><span style="color: #005CC5">3</span><span style="color: #24292E">):</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">for</span><span style="color: #24292E"> j </span><span style="color: #D73A49">in</span><span style="color: #24292E"> </span><span style="color: #005CC5">range</span><span style="color: #24292E">(</span><span style="color: #005CC5">3</span><span style="color: #24292E">):</span></span>
<span class="line"><span style="color: #24292E">        text </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ax.text(j</span><span style="color: #D73A49">+</span><span style="color: #005CC5">0.5</span><span style="color: #24292E">, i</span><span style="color: #D73A49">+</span><span style="color: #005CC5">0.5</span><span style="color: #24292E">, </span><span style="color: #D73A49">f</span><span style="color: #032F62">&quot;</span><span style="color: #005CC5">{</span><span style="color: #24292E">grid[i, j]</span><span style="color: #D73A49">:0.1f</span><span style="color: #005CC5">}</span><span style="color: #032F62">&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                       </span><span style="color: #E36209">ha</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;center&quot;</span><span style="color: #24292E">, </span><span style="color: #E36209">va</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;center&quot;</span><span style="color: #24292E">, </span><span style="color: #E36209">color</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;w&quot;</span><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br><span class="line-number">36</span><br><span class="line-number">37</span><br><span class="line-number">38</span><br></div></div><p>最終的に出力されるプロットが <a href="#fig_grid_search_result">figure_title</a> である．</p>
<p><img src="./assets/aws_batch/grid_search_result.png" alt="ハイパーパラメータのグリッドサーチの結果"></p>
<p>このプロットから，差は僅かであるが，学習率が 0.1 のときに精度は最大となることがわかる． また，学習率 0.1 のときはモメンタムを変えても大きな差は生じないことが見て取れる．</p>
<p>今回のパラメータサーチは勉強用に極めて単純化されたものである点は承知いただきたい．</p>
<p>たとえば，今回は学習率が 0.1 が最も良いとされたが，それは訓練のエポックを 100 に限定しているからかもしれない． 学習率が低いとその分訓練に必要なエポック数も多くなる． 訓練のエポック数をもっと増やせばまた違った結果が観察される可能性はある．</p>
<p>また，今回は MNIST の訓練データ 60,000 枚のうち， 48,000 枚を訓練データ，残り 12,000 枚を検証データとして用いた． この分割は乱数を固定してランダムに行ったが，もしこの分割によるデータのバイアスを気にするならば， k 個の異なる学習・検証データの分割をあらかじめ用意して，複数回モデルの評価を行う (<strong>k-fold cross-validation</strong>) 方法も，より精緻なアプローチとして考えられる．</p>
<p>以上のようにして， CNN を用いた MNIST 分類モデルのハイパーパラメータの最適化の一連の流れを体験した． AWS Batch を利用することで，比較的少ないプログラミングで，動的に EC2 クラスターを制御し，並列にジョブを処理するシステムが構築できた． ここまで EC2 を使いこなすことができれば，多くの問題を自力で解くことが可能になるだろう！</p>
<h2 id="スタックの削除" tabindex="-1">スタックの削除 <a class="header-anchor" href="#スタックの削除" aria-label="Permalink to &quot;スタックの削除&quot;">&ZeroWidthSpace;</a></h2>
<p>これにて，本ハンズオンは終了である．最後にスタックを削除しよう． 今回のスタックを削除するにあたり，ECR に配置された Docker のイメージは手動で削除されなければならない (これをしないと， <code>cdk destroy</code> を実行したときにエラーになってしまう． これは CloudFormation の仕様なので従うしかない)．</p>
<p>ECR の Docker image を削除するには， ECR のコンソールに行き，イメージが配置されたレポジトリを開く． そして，画面右上の <code>DELETE</code> ボタンを押して削除する (<a href="#fig_delete_ecr">figure_title</a>)．</p>
<p><img src="./assets/aws_batch/delete_ecr.png" alt="ECR から Docker image を削除する"></p>
<p>あるいは， AWS CLI から同様の操作を行うには，以下のコマンドを用いる (<code>XXXX</code> は自分の ECR レポジトリ名に置き換える)．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ecr</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">batch-delete-image</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--repository-name</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">XXXX</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--image-ids</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">imageTag=latest</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">aws</span><span style="color: #24292E"> </span><span style="color: #032F62">ecr</span><span style="color: #24292E"> </span><span style="color: #032F62">batch-delete-image</span><span style="color: #24292E"> </span><span style="color: #005CC5">--repository-name</span><span style="color: #24292E"> </span><span style="color: #032F62">XXXX</span><span style="color: #24292E"> </span><span style="color: #005CC5">--image-ids</span><span style="color: #24292E"> </span><span style="color: #032F62">imageTag=latest</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>image の削除が完了したうえで，次のコマンドでスタックを削除する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cdk</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">destroy</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cdk</span><span style="color: #24292E"> </span><span style="color: #032F62">destroy</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>(#sec:batch_development_and_debug) === クラウドを用いた機械学習アプリケーションの開発とデバッグ</p>
<p>本章で紹介したハンズオンでは， AWS Batch を使用することでニューラルネットの学習を複数並列に実行し，高速化を実現した． 本章の最後の話題として，クラウドを用いた機械学習アプリケーションの開発とデバッグの方法について述べよう．</p>
<p>ローカルに GPU を搭載した強力なマシンがなく，クラウドを利用する予算が確保されているのであれば， <a href="#fig:cloud_development">figure_title</a> のような開発のスキームが理想的であると考える． 最初の段階では， (#sec_jupyter_and_deep_learning) で見たような方法で， GPU 搭載型の EC2 インスタンスを作成し， Jupyter Notebook などのインタラクティブな環境で様々なモデルを試し実験を行う． Jupyter である程度アプリケーションが完成してきたタイミングで，作成したアプリケーションを Docker イメージにパッケージングする． そして， EC2 上で <code>docker run</code> を行い，作成したイメージがバグなく動作するか確認を行う． その次に，ハイパーパラメータの最適化などのチューニングを， <a href="#sec_aws_batch">Hands-on #4: AWS Batch を使って機械学習のハイパーパラメータサーチを並列化する</a> のハンズオンで学んだ AWS Batch などの計算システムを利用して行う． よい深層学習モデルが完成したら，仕上げに大規模データへの推論処理を行うシステムを (#sec_fargate_qabot) を参考に構築する．</p>
<p>実際，本書ではこの流れに沿って演習を進めてきた． MNIST タスクを解くモデルを，最初 Jupyter Notebook を使用して実験し，そのコードをほとんどそのまま Docker にパッケージし， AWS Batch を用いてハイパーパラメータサーチを行った． このサイクルを繰り返すことで，クラウドを最大限に活用した機械学習アプリケーションの開発を進めることができる．</p>
<p><img src="./assets/aws_batch/cloud_development.png" alt="クラウドを活用した機械学習アプリケーションの開発フロー"></p>
<h2 id="小括" tabindex="-1">小括 <a class="header-anchor" href="#小括" aria-label="Permalink to &quot;小括&quot;">&ZeroWidthSpace;</a></h2>
<p>ここまでが，本書第二部の内容である． 第一部に引き続き盛りだくさんの内容であったが，ついてこれたであろうか？</p>
<p>第二部ではまず最初に，深層学習の計算をクラウドで実行するため， GPU 搭載型の EC2 インスタンスの起動について解説した． さらに，ハンズオンでは，クラウドに起動した仮想サーバーを使って MNIST 文字認識タスクを解くニューラルネットを訓練した ( (#sec_jupyter_and_deep_learning))．</p>
<p>また，より大規模な機械学習アプリケーションを作るための手段として， Docker と ECS によるクラスターの初歩を説明した ( (#sec_docker_introduction))． その応用として，英語で与えられた文章問題への回答を自動で生成するボットをクラウドに展開した ( (#sec_fargate_qabot))． タスクの投入に応じて動的に計算リソースが作成・削除される様子を実際に体験できただろう．</p>
<p>さらに， <a href="#sec_aws_batch">Hands-on #4: AWS Batch を使って機械学習のハイパーパラメータサーチを並列化する</a> では AWS Batch を用いてニューラルネットの学習を並列に実行する方法を紹介した． ここで紹介した方法は，ミニマムであるが，計算機システムを大規模化していくためのエッセンスが網羅されている． これらのハンズオン体験から，クラウド技術を応用してどのように現実世界の問題を解いていくのか，なんとなくイメージが伝わっただろうか？</p>
<p>本書の第三部では，さらにレベルアップし，サーバーレスアーキテクチャという最新のクラウドの設計手法について解説する． その応用として，ハンズオンでは簡単な SNS サービスをゼロから実装する． 引き続きクラウドの最先端の世界を楽しんでいこう！</p>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS 入門 ]]></title>
            <link>https://note.toshiki.devdevelopment/aws/aws-get-started</link>
            <guid>https://note.toshiki.devdevelopment/aws/aws-get-started</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="aws-入門" tabindex="-1">AWS 入門 <a class="header-anchor" href="#aws-入門" aria-label="Permalink to &quot;AWS 入門&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="aws-とは" tabindex="-1">AWS とは？ <a class="header-anchor" href="#aws-とは" aria-label="Permalink to &quot;AWS とは？&quot;">&ZeroWidthSpace;</a></h2>
<p>本書では，クラウドの実践を行うプラットフォームとして， AWS を用いる． 実践にあたって，最低限必要な AWS の知識を本章では解説しよう．</p>
<p><a href="https://aws.amazon.com" target="_blank" rel="noreferrer">AWS (Amazon Web Services)</a> は Amazon 社が提供する総合的なクラウドプラットフォームである． AWS は Amazon 社が持つ膨大な計算リソースを貸し出すクラウドサービスとして，2006 年に誕生した． 2021 年では，クラウドプロバイダーとして最大のマーケットシェア (約 32%) を保持している (<a href="https://www.canalys.com/newsroom/global-cloud-market-Q121" target="_blank" rel="noreferrer">参照</a>)． Netflix や Slack をはじめとした多くのウェブ関連のサービスで，一部または全てのサーバーリソースが AWS から提供されているとのことである． よって，知らないうちに AWS の恩恵にあずかっている人も少なくないはずだ．</p>
<p>最大のシェアをもつだけに，機能・サービスの幅広さはほかのクラウドプラットフォームと比べ抜きんでている． また，利用者数が多いことを反映して，公式あるいはサードパーティによる技術紹介記事が数多くウェブ上に存在しているだけでなく，ライブラリのユーザーコミュニティも大きく問題解決が捗るのも魅力の一つだ． 初期のころウェブビジネスを行う企業がユーザーの大半を占めていたが，最近は大学などでの科学研究用途としても頻繁に用いられるようになってきている．</p>
<h2 id="aws-の機能・サービス" tabindex="-1">AWS の機能・サービス <a class="header-anchor" href="#aws-の機能・サービス" aria-label="Permalink to &quot;AWS の機能・サービス&quot;">&ZeroWidthSpace;</a></h2>
<p><a href="#fig_aws_services">figure_title</a> は，執筆時点において AWS で提供されている主要な機能・サービスの一覧である．</p>
<p><img src="./assets/aws_services.png" alt="AWSで提供されている主要なサービス一覧"></p>
<p>計算，ストレージ，データベース，ネットワーク，セキュリティなど，クラウドの構築に必要な様々な要素が<strong>独立したコンポーネント</strong>として提供されている． 基本的に，これらを組み合わせることで一つのクラウドシステムができあがる．</p>
<p>また，機械学習・音声認識・AR/VR など，特定のアプリケーションにパッケージ済みのサービスも提供されている． これらを合計すると全部で 170 個以上のサービスが提供されているとのことである (<a href="https://dev.classmethod.jp/articles/aws-summary-2020/" target="_blank" rel="noreferrer">参照</a>)．</p>
<p>AWS の初心者が陥りがちなのは，<strong>大量のサービスの数に圧倒され，どこから手をつけたらよいのかわからなくなる</strong>，という状況である． たくさんのサービスの中から，どのサービスをどの順番で学んでいったらいいのか，その道筋すら明らかでなく，大きな参入障壁となっていることは間違いない． だが実のところ， AWS の<strong>基本的な構成要素はそのうちの数個</strong>のみに限られる． 基本要素となる機能の使い方を知れば， AWS のおおよそのリソースを使いこなすことが可能になる． ほかの機能の多くは，基本の要素を組み合わせて特定のアプリケーションに特化したパッケージとして AWS が用意したものである． そのポイントを認知することが， AWS の学習の最初のステップである．</p>
<p>ここでは， AWS 上でクラウドシステムを構築するときの基本となる構成要素を列挙する． これらは後のハンズオンで実際にプログラムを書きながら体験する． 現時点では，名前だけでも頭の片隅に記憶してもらえればよい．</p>
<h3 id="計算" tabindex="-1">計算 <a class="header-anchor" href="#計算" aria-label="Permalink to &quot;計算&quot;">&ZeroWidthSpace;</a></h3>
<p><img src="./assets/aws_logos/EC2.png" alt="S3"> <strong>EC2 (Elastic Compute Cloud)</strong> 様々なスペックの仮想マシンを作成し，計算を実行することができる． クラウドの最も基本となる構成要素である． (#sec_first_ec2), (#sec_jupyter_and_deep_learning), (#sec_aws_batch) で詳しく触れる．</p>
<p><img src="./assets/aws_logos/Lambda.png" alt="S3"> <strong>Lambda</strong> Function as a Service (FaaS) とよばれる，小さな計算を<strong>サーバーなし</strong>で実行するためのサービス． サーバーレスアーキテクチャの章 ( (#sec_serverless)) で詳しく解説する．</p>
<h3 id="ストレージ" tabindex="-1">ストレージ <a class="header-anchor" href="#ストレージ" aria-label="Permalink to &quot;ストレージ&quot;">&ZeroWidthSpace;</a></h3>
<p><img src="./assets/aws_logos/EBS.png" alt="S3">
<strong>EBS (Elastic Block Store)</strong> EC2 に付与することのできる仮想データドライブ． いわゆる&quot;普通の&quot;(一般的な OS で使われている)ファイルシステムを思い浮かべてくれたらよい．</p>
<p><img src="./assets/aws_logos/S3.png" alt="S3"></p>
<p><strong>S3 (Simple Storage Service)</strong> Object Storage とよばれる，API を使ってデータの読み書きを行う，いうなれば”クラウド・ネイティブ”なデータの格納システムである． サーバーレスアーキテクチャの章 ( (#sec_serverless)) で詳しく解説する．</p>
<h3 id="データベース" tabindex="-1">データベース <a class="header-anchor" href="#データベース" aria-label="Permalink to &quot;データベース&quot;">&ZeroWidthSpace;</a></h3>
<p><img src="./assets/aws_logos/DynamoDB.png" alt="S3"></p>
<p><strong>DynamoDB</strong> NoSQL 型のデータベースサービス (知っている人は <code>mongoDB</code> などを思い浮かべたらよい)． サーバーレスアーキテクチャの章 ( (#sec_serverless)) で詳しく解説する．</p>
<h3 id="ネットワーク" tabindex="-1">ネットワーク <a class="header-anchor" href="#ネットワーク" aria-label="Permalink to &quot;ネットワーク&quot;">&ZeroWidthSpace;</a></h3>
<p><img src="./assets/aws_logos/VPC.png" alt="S3"> <strong>VPC(Virtual Private Cloud)</strong> AWS 上に仮想ネットワーク環境を作成し，仮想サーバー間の接続を定義したり，外部からのアクセスなどを管理する． EC2 は VPC の内部に配置されなければならない．</p>
<p><strong>API Gateway</strong> <img src="./assets/aws_logos/APIGateway.png" alt="S3"></p>
<p>API のエンドポイントとバックエンドのサービス (Lambda など) を接続する際に用いる，リバースプロキシとしての役割を担う． (#sec_bashoutter) で詳しく解説する．</p>
<h2 id="region-と-availability-zone" tabindex="-1">Region と Availability Zone <a class="header-anchor" href="#region-と-availability-zone" aria-label="Permalink to &quot;Region と Availability Zone&quot;">&ZeroWidthSpace;</a></h2>
<p>AWS を使用する際に知っておかなければならない重要な概念として， <strong>リージョン (Region)</strong> と <strong>Availability Zone (AZ)</strong> がある (<a href="#fig_aws_regions_and_azs">figure_title</a>)． 以下ではこの概念について簡単に記述する．</p>
<p><img src="./assets/aws_region_and_az.png" alt="AWSにおける Region と Availability Zones"></p>
<p><strong>リージョン (Region)</strong> とは，おおまかに言うとデータセンターの所在地のことである． 執筆時点において， AWS は世界の 25 の国と地域でデータセンターを所有している． <a href="#fig_aws_regions">figure_title</a> は執筆時点で利用できるリージョンの世界地図を示している． 日本では東京と大阪にデータセンターがある． 各リージョンには固有の ID がついており，例えば東京は <code>ap-northeast-1</code>, 米国オハイオ州は <code>us-east-2</code>，などと定義されている．</p>
<p><img src="./assets/aws_regions.png" alt="Regions in AWS(出典: https://aws.amazon.com/about-aws/global-infrastructure/)"></p>
<p>AWS コンソールにログインすると，画面右上のメニューバーでリージョンを選択することができる(<a href="#fig_aws_console_regions">figure_title</a>, 赤丸で囲った箇所)． EC2, S3 などの AWS のリソースは，リージョンごとに完全に独立である． したがって，<strong>リソースを新たにデプロイする際，あるいはデプロイ済みのリソースを閲覧する際は，コンソールのリージョンが正しく設定されているか，確認する必要がある</strong>． ウェブビジネスを展開する場合などは，世界の各地にクラウドを展開する必要があるが，個人的な研究用途として用いる場合は，最寄りのリージョン (i.e. 東京) を使えば基本的に問題ない．</p>
<p><img src="./assets/aws_regions2.png" alt="AWSコンソールでリージョンを選択"></p>
<p><code>Avaialibity Zone (AZ)</code> とは，リージョン内で地理的に隔離されたデータセンターのことである． それぞれのリージョンは 2 個以上の AZ を有しており，もし一つの AZ で火災や停電などが起きた場合でも，ほかの AZ がその障害をカバーすることができる． また， AZ 間は高速な AWS 専用ネットワーク回線で結ばれているため， AZ 間のデータ転送は極めて早い． AZ は，ビジネスなどでサーバーダウンが許容されない場合などに注意すべき概念であり，個人的な用途で使う限りにおいてはあまり深く考慮する必要はない．言葉の意味だけ知っておけば十分である．</p>
<p>AWS を使用する際，どこのリージョンを指定するのがよいのだろうか？ インターネットの接続速度の観点からは，地理的に一番近いリージョンを使用するのが一般的によいだろう． 一方， EC2 の利用料などはリージョンごとに価格設定が若干 (10-20%程度) 異なる． したがって，自分が最も頻繁に利用するサービスの価格が最も安く設定されているリージョンを選択する，というのも重要な視点である． また，いくつかのサービスは，特定のリージョンで利用できない場合もある． これらのポイントから総合的に判断して使用するリージョンを決めると良い．</p>
<p>AWS Educate を利用している読者へ</p>
<p>執筆時点において，AWS Educate による Starter Account を使用している場合は <code>us-east-1</code> region のみ利用できる (<a href="https://awseducate-starter-account-services.s3.amazonaws.com/AWS_Educate_Starter_Account_Services_Supported.pdf" target="_blank" rel="noreferrer">参照</a>)．</p>
<ul>
<li><a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-regions-availability-zones.html" target="_blank" rel="noreferrer">AWS documentation &quot;Regions, Availability Zones, and Local Zones&quot;</a></li>
</ul>
<h2 id="aws-でのクラウド開発" tabindex="-1">AWS でのクラウド開発 <a class="header-anchor" href="#aws-でのクラウド開発" aria-label="Permalink to &quot;AWS でのクラウド開発&quot;">&ZeroWidthSpace;</a></h2>
<p>AWS のクラウドの全体像がわかってきたところで，次のトピックとして，どのようにして AWS 上にクラウドの開発を行い，展開していくかについての概略を解説しよう．</p>
<p>AWS のリソースを追加・編集・削除するなどの操作を実行するには，<strong>コンソールを用いる</strong>方法と，<strong>API を用いる方法</strong>の，二つの経路がある．</p>
<h3 id="コンソール画面からリソースを操作する" tabindex="-1">コンソール画面からリソースを操作する <a class="header-anchor" href="#コンソール画面からリソースを操作する" aria-label="Permalink to &quot;コンソール画面からリソースを操作する&quot;">&ZeroWidthSpace;</a></h3>
<p>AWS のアカウントにログインすると，まず最初に表示されるのが<strong>AWS コンソール</strong>である (<a href="#aws_console_window">figure_title</a>)．</p>
<p><img src="./assets/aws_console.png" alt="AWSマネージメントコンソール画面"></p>
<p>コンソールを使うことで， EC2 のインスタンスを立ち上げたり，S3 のデータを追加・削除したり，ログを閲覧したりなど，AWS 上のあらゆるリソースの操作を GUI (Graphical User Interface) を通して実行することができる． <strong>初めて触る機能をポチポチと試したり，デバッグを行うときなどにとても便利である</strong>．</p>
<p>コンソールはさらっと機能を試したり，開発中のクラウドのデバッグをするときには便利なのであるが，実際にクラウドの開発をする場面でこれを直接いじることはあまりない． むしろ，次に紹介する API を使用して，プログラムとしてクラウドのリソースを記述することで開発を行うのが一般的である． そのような理由で，本書では AWS コンソールを使った AWS の使い方はあまり触れない． AWS のドキュメンテーションには，たくさんの <a href="https://aws.amazon.com/getting-started/hands-on/" target="_blank" rel="noreferrer">チュートリアル</a> が用意されており，コンソール画面から様々な操作を行う方法が記述されているので，興味がある読者はそちらを参照されたい．</p>
<h3 id="api-からリソースを操作する" tabindex="-1">API からリソースを操作する <a class="header-anchor" href="#api-からリソースを操作する" aria-label="Permalink to &quot;API からリソースを操作する&quot;">&ZeroWidthSpace;</a></h3>
<p><strong>API (Application Programming Interface)</strong> を使うことで，コマンドを AWS に送信し，クラウドのリソースの操作をすることができる． API とは，端的に言えば AWS が公開しているコマンドの一覧であり，<code>GET</code>, <code>POST</code>, <code>DELETE</code> などの <strong>REST API</strong> から構成されている (REST API については (#sec_rest_api) で簡単に解説する)． が，直接 REST API を入力するのは面倒であるので，その手間を解消するための様々なツールが提供されている．</p>
<p>例えば， <a href="https://docs.aws.amazon.com/cli/latest/index.html" target="_blank" rel="noreferrer">AWS CLI</a> は， UNIX コンソールから AWS API を実行するための CLI (Command Line Interface) である． CLI に加えて，いろいろなプログラミング言語での SDK (Software Development Kit) が提供されている．以下に一例を挙げる．</p>
<ul>
<li>
<p>Python ⇒ <a href="https://boto3.amazonaws.com/v1/documentation/api/latest/index.html" target="_blank" rel="noreferrer">boto3</a></p>
</li>
<li>
<p>Ruby ⇒ <a href="https://aws.amazon.com/sdk-for-ruby/" target="_blank" rel="noreferrer">AWS SDK for Ruby</a></p>
</li>
<li>
<p>Node.js ⇒ <a href="https://aws.amazon.com/sdk-for-node-js/" target="_blank" rel="noreferrer">AWS SDK for Node.js</a></p>
</li>
</ul>
<p>具体的な API の使用例を見てみよう．</p>
<p>S3 に新しい保存領域 (<code>Bucket (バケット)</code> とよばれる) を追加したいとしよう． AWS CLI を使った場合は，次のようなコマンドを打てばよい．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">s3</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">mb</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">s3://my-bucket</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--region</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ap-northeast-1</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">aws</span><span style="color: #24292E"> </span><span style="color: #032F62">s3</span><span style="color: #24292E"> </span><span style="color: #032F62">mb</span><span style="color: #24292E"> </span><span style="color: #032F62">s3://my-bucket</span><span style="color: #24292E"> </span><span style="color: #005CC5">--region</span><span style="color: #24292E"> </span><span style="color: #032F62">ap-northeast-1</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>上記のコマンドは， <code>my-bucket</code> という名前のバケットを， <code>ap-northeast-1</code> のリージョンに作成する．</p>
<p>Python からこれと同じ操作を実行するには， <code>boto3</code> ライブラリを使って，次のようなスクリプトを実行する．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> boto3</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">s3_client </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> boto3.client(</span><span style="color: #96D0FF">&quot;s3&quot;</span><span style="color: #ADBAC7">, </span><span style="color: #F69D50">region_name</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;ap-northeast-1&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">s3_client.create_bucket(</span><span style="color: #F69D50">Bucket</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;my-bucket&quot;</span><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> boto3</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">s3_client </span><span style="color: #D73A49">=</span><span style="color: #24292E"> boto3.client(</span><span style="color: #032F62">&quot;s3&quot;</span><span style="color: #24292E">, </span><span style="color: #E36209">region_name</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;ap-northeast-1&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">s3_client.create_bucket(</span><span style="color: #E36209">Bucket</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;my-bucket&quot;</span><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br></div></div><p>もう一つ例をあげよう．</p>
<p>新しい EC2 のインスタンス(インスタンスとは，起動状態にある仮想サーバーの意味である)を起動するには，次のようなコマンドを打てば良い．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ec2</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">run-instances</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--image-id</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ami-xxxxxxxx</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--count</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--instance-type</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">t2.micro</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--key-name</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">MyKeyPair</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--security-group-ids</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">sg-903004f8</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--subnet-id</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">subnet-6e7f829e</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">aws</span><span style="color: #24292E"> </span><span style="color: #032F62">ec2</span><span style="color: #24292E"> </span><span style="color: #032F62">run-instances</span><span style="color: #24292E"> </span><span style="color: #005CC5">--image-id</span><span style="color: #24292E"> </span><span style="color: #032F62">ami-xxxxxxxx</span><span style="color: #24292E"> </span><span style="color: #005CC5">--count</span><span style="color: #24292E"> </span><span style="color: #005CC5">1</span><span style="color: #24292E"> </span><span style="color: #005CC5">--instance-type</span><span style="color: #24292E"> </span><span style="color: #032F62">t2.micro</span><span style="color: #24292E"> </span><span style="color: #005CC5">--key-name</span><span style="color: #24292E"> </span><span style="color: #032F62">MyKeyPair</span><span style="color: #24292E"> </span><span style="color: #005CC5">--security-group-ids</span><span style="color: #24292E"> </span><span style="color: #032F62">sg-903004f8</span><span style="color: #24292E"> </span><span style="color: #005CC5">--subnet-id</span><span style="color: #24292E"> </span><span style="color: #032F62">subnet-6e7f829e</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>このコマンドにより， <a href="https://aws.amazon.com/ec2/instance-types/t2/" target="_blank" rel="noreferrer">t2.micro</a> というタイプ (1 vCPU, 1.0 GB RAM) のインスタンスが起動する． ここではその他のパラメータの詳細の説明は省略する (ハンズオン ( (#sec_first_ec2)) で詳しく解説する)．</p>
<p>Python から上記と同じ操作を実行するには，以下のようなスクリプトを使う．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> boto3</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">ec2_client </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> boto3.client(</span><span style="color: #96D0FF">&quot;ec2&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">ec2_client.run_instances(</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">ImageId</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;ami-xxxxxxxxx&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">MinCount</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">MaxCount</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">KeyName</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;MyKeyPair&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">InstanceType</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;t2.micro&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">SecurityGroupIds</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">[</span><span style="color: #96D0FF">&quot;sg-903004f8&quot;</span><span style="color: #ADBAC7">],</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">SubnetId</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;subnet-6e7f829e&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> boto3</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">ec2_client </span><span style="color: #D73A49">=</span><span style="color: #24292E"> boto3.client(</span><span style="color: #032F62">&quot;ec2&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">ec2_client.run_instances(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">ImageId</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;ami-xxxxxxxxx&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">MinCount</span><span style="color: #D73A49">=</span><span style="color: #005CC5">1</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">MaxCount</span><span style="color: #D73A49">=</span><span style="color: #005CC5">1</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">KeyName</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;MyKeyPair&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">InstanceType</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;t2.micro&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">SecurityGroupIds</span><span style="color: #D73A49">=</span><span style="color: #24292E">[</span><span style="color: #032F62">&quot;sg-903004f8&quot;</span><span style="color: #24292E">],</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">SubnetId</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;subnet-6e7f829e&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br></div></div><p>以上の例を通じて，API によるクラウドのリソースの操作のイメージがつかめてきただろうか？ コマンド一つで，新しい仮想サーバーを起動したり，データの保存領域を追加したり，任意の操作を実行できるわけである． 基本的に，このようなコマンドを複数組み合わせていくことで，自分の望む CPU・RAM・ネットワーク・ストレージが備わった計算環境を構築することができる． もちろん，逆の操作 (リソースの削除) も API を使って実行できる．</p>
<h3 id="ミニ・ハンズオン-aws-cli-を使ってみよう" tabindex="-1">ミニ・ハンズオン: AWS CLI を使ってみよう <a class="header-anchor" href="#ミニ・ハンズオン-aws-cli-を使ってみよう" aria-label="Permalink to &quot;ミニ・ハンズオン: AWS CLI を使ってみよう&quot;">&ZeroWidthSpace;</a></h3>
<p>ここでは，ミニ・ハンズオンとして，AWS CLI を実際に使ってみる． AWS CLI は先述のとおり， AWS 上の任意のリソースの操作が可能であるが，ここでは一番シンプルな，<strong>S3 を使ったファイルの読み書きを実践する</strong> (EC2 の操作は少し複雑なので，第一回ハンズオンで行う)． <code>aws s3</code> コマンドの詳しい使い方は <a href="https://docs.aws.amazon.com/cli/latest/reference/s3/index.html#cli-aws-s3" target="_blank" rel="noreferrer">公式ドキュメンテーション</a>を参照．</p>
<p>AWS CLI のインストールについては， (#aws_cli_install) を参照．</p>
<p>以下に紹介するハンズオンは，基本的に <a href="https://aws.amazon.com/free/?all-free-tier.sort-by=item.additionalFields.SortRank&amp;all-free-tier.sort-order=asc" target="_blank" rel="noreferrer">S3 の無料枠</a> の範囲内で実行することができる．</p>
<p>以下のコマンドを実行する前に，AWS の認証情報が正しく設定されていることを確認する． これには <code>~/.aws/credentials</code> のファイルに設定が書き込まれているか，環境変数 (<code>AWS_ACCESS_KEY_ID</code>, <code>AWS_SECRET_ACCESS_KEY</code>, <code>AWS_DEFAULT_REGION</code>) が定義されている必要がある． 詳しくは (#aws_cli_install) を参照．</p>
<p>まずは，S3 にデータの格納領域 (<code>Bucket</code> とよばれる．一般的な OS での&quot;ドライブ&quot;に相当する) を作成するところから始めよう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">bucketName=&quot;mybucket-$(</span><span style="color: #F69D50">openssl</span><span style="color: #96D0FF"> rand </span><span style="color: #6CB6FF">-hex</span><span style="color: #96D0FF"> </span><span style="color: #6CB6FF">12</span><span style="color: #96D0FF">)&quot;</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">echo</span><span style="color: #ADBAC7"> $bucketName</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">s3</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">mb</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;s3://${</span><span style="color: #ADBAC7">bucketName</span><span style="color: #96D0FF">}&quot;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">bucketName=&quot;mybucket-$(</span><span style="color: #6F42C1">openssl</span><span style="color: #032F62"> rand </span><span style="color: #005CC5">-hex</span><span style="color: #032F62"> </span><span style="color: #005CC5">12</span><span style="color: #032F62">)&quot;</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">echo</span><span style="color: #24292E"> $bucketName</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">aws</span><span style="color: #24292E"> </span><span style="color: #032F62">s3</span><span style="color: #24292E"> </span><span style="color: #032F62">mb</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;s3://${</span><span style="color: #24292E">bucketName</span><span style="color: #032F62">}&quot;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><p>S3 のバケットの名前は， AWS 全体で一意的でなければならないことから，前述のコマンドではランダムな文字列を含んだバケットの名前を生成し，<code>bucketName</code> という変数に格納している． そして， <code>aws s3 mb</code> (<code>mb</code> は make bucket の略) によって，新しいバケットを作成する．</p>
<p>次に，バケットの一覧を取得してみよう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">s3</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ls</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F69D50">2020-06-07</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">23</span><span style="color: #96D0FF">:45:44</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">mybucket-c6f93855550a72b5b66f5efe</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">aws</span><span style="color: #24292E"> </span><span style="color: #032F62">s3</span><span style="color: #24292E"> </span><span style="color: #032F62">ls</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6F42C1">2020-06-07</span><span style="color: #24292E"> </span><span style="color: #005CC5">23</span><span style="color: #032F62">:45:44</span><span style="color: #24292E"> </span><span style="color: #032F62">mybucket-c6f93855550a72b5b66f5efe</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><p>先ほど作成したバケットがリストにあることを確認できる．</p>
<p>本書のノーテーションとして，コマンドラインに入力するコマンドは，それがコマンドであると明示する目的で先頭に <code>$</code> がつけてある． <code>$</code> はコマンドをコピー&amp;ペーストするときは除かなければならない． 逆に，コマンドの出力は <code>$</code> なしで表示されている．</p>
<p>次に，バケットにファイルをアップロードする．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">echo</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;Hello world&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">&gt;</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">hello_world.txt</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">s3</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cp</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">hello_world.txt</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;s3://${</span><span style="color: #ADBAC7">bucketName</span><span style="color: #96D0FF">}/hello_world.txt&quot;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">echo</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;Hello world&quot;</span><span style="color: #24292E"> </span><span style="color: #D73A49">&gt;</span><span style="color: #24292E"> </span><span style="color: #032F62">hello_world.txt</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">aws</span><span style="color: #24292E"> </span><span style="color: #032F62">s3</span><span style="color: #24292E"> </span><span style="color: #032F62">cp</span><span style="color: #24292E"> </span><span style="color: #032F62">hello_world.txt</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;s3://${</span><span style="color: #24292E">bucketName</span><span style="color: #032F62">}/hello_world.txt&quot;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>上では <code>hello_world.txt</code> というダミーのファイルを作成して，それをアップロードした．</p>
<p>それでは，バケットの中にあるファイルの一覧を取得してみる．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">s3</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ls</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;s3://${</span><span style="color: #ADBAC7">bucketName</span><span style="color: #96D0FF">}&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--human-readable</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F69D50">2020-06-07</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">23</span><span style="color: #96D0FF">:54:19</span><span style="color: #ADBAC7">   </span><span style="color: #6CB6FF">13</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">Bytes</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">hello_world.txt</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">aws</span><span style="color: #24292E"> </span><span style="color: #032F62">s3</span><span style="color: #24292E"> </span><span style="color: #032F62">ls</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;s3://${</span><span style="color: #24292E">bucketName</span><span style="color: #032F62">}&quot;</span><span style="color: #24292E"> </span><span style="color: #005CC5">--human-readable</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6F42C1">2020-06-07</span><span style="color: #24292E"> </span><span style="color: #005CC5">23</span><span style="color: #032F62">:54:19</span><span style="color: #24292E">   </span><span style="color: #005CC5">13</span><span style="color: #24292E"> </span><span style="color: #032F62">Bytes</span><span style="color: #24292E"> </span><span style="color: #032F62">hello_world.txt</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><p>先ほどアップロードしたファイルがたしかに存在することがわかる．</p>
<p>最後に，使い終わったバケットを削除する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">s3</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">rb</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;s3://${</span><span style="color: #ADBAC7">bucketName</span><span style="color: #96D0FF">}&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--force</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">aws</span><span style="color: #24292E"> </span><span style="color: #032F62">s3</span><span style="color: #24292E"> </span><span style="color: #032F62">rb</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;s3://${</span><span style="color: #24292E">bucketName</span><span style="color: #032F62">}&quot;</span><span style="color: #24292E"> </span><span style="color: #005CC5">--force</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p><code>rb</code> は remove bucket の略である． デフォルトでは，バケットの中にファイルが存在すると削除できない． 空でないバケットを強制的に削除するには <code>--force</code> のオプションを付ける．</p>
<p>以上のように，AWS CLI を使って S3 バケットに対しての一連の操作を実行できた． EC2 や Lambda, DynamoDB などについても同様に AWS CLI を使ってあらゆる操作を実行できる．</p>
<p><strong>Amazon Resource Name (ARN)</strong></p>
<p>AWS 上のあらゆるリソースには， Amazon Resource Name (ARN) という固有の ID が付与されている． ARN は <code>arn:aws:s3:::my_bucket/</code> のようなフォーマットで記述され，ARN を使用することで，特定の AWS リソース (S3 のバケットや EC2 のインスタンス) を一意的に参照することができる．</p>
<p>S3 バケットや EC2 インスタンスなどには ARN に加えて，人間が読みやすい名前を定義することも可能である． この場合は，ARN または名前のどちらを用いても同じリソースを参照することが可能である．</p>
<h2 id="cloudformation-と-aws-cdk" tabindex="-1">CloudFormation と AWS CDK <a class="header-anchor" href="#cloudformation-と-aws-cdk" aria-label="Permalink to &quot;CloudFormation と AWS CDK&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="cloudformation-による-infrastructure-as-code-iac" tabindex="-1">CloudFormation による Infrastructure as Code (IaC) <a class="header-anchor" href="#cloudformation-による-infrastructure-as-code-iac" aria-label="Permalink to &quot;CloudFormation による Infrastructure as Code (IaC)&quot;">&ZeroWidthSpace;</a></h3>
<p>前節で述べたように，AWS API を使うことでクラウドの<strong>あらゆる</strong>リソースの作成・管理が可能である． よって，原理上は， API のコマンドを組み合わせていくことで，自分の作りたいクラウドを設計することができる．</p>
<p>しかし，ここで実用上考慮しなければならない点が一つある． AWS API には大きく分けて，<strong>リソースを操作する</strong>コマンドと，<strong>タスクを実行する</strong>コマンドがあることである (<a href="#fig_aws_iac">figure_title</a>)．</p>
<p><img src="./assets/iac.png" alt="AWS APIはリソースを操作するコマンドとタスクを実行するコマンドに大きく分けられる．リソースを記述・管理するのに使われるのが， CloudFormation と CDK である．"></p>
<p><strong>リソースを操作する</strong>とは，EC2 のインスタンスを起動したり，S3 のバケットを作成したり，データベースに新たなテーブルを追加する，などの<strong>静的なリソースを準備する</strong> 操作を指す． &quot;ハコ&quot;を作る操作とよんでも良いだろう． このようなコマンドは，<strong>クラウドのデプロイ時にのみ，一度だけ実行されればよい</strong>．</p>
<p><strong>タスクを実行するコマンド</strong> とは， EC2 のインスタンスにジョブを投入したり， S3 のバケットにデータを読み書きするなどの操作を指す． これは， EC2 や S3 などのリソース (&quot;ハコ&quot;) を前提として，その内部で実行されるべき計算を記述するものである． 前者に比べてこちらは<strong>動的な操作</strong>を担当する，と捉えることもできる．</p>
<p>そのような観点から，<strong>インフラを記述するプログラム</strong>と<strong>タスクを実行するプログラム</strong>はある程度分けて管理されるべきである． クラウドの開発は，クラウドの(静的な)リソースを記述するプログラムを作成するステップと，インフラ上で動く動的な操作を行うプログラムを作成するステップの二段階に分けて考えることができる．</p>
<p>AWS での静的リソースを管理するための仕組みが， <a href="https://aws.amazon.com/cloudformation/" target="_blank" rel="noreferrer">CloudFormation</a> である． CloudFormation とは， CloudFormation の文法に従ったテキストファイルを使って，AWS のインフラを記述する仕組みである． CloudFormation を使って，たとえば，EC2 のインスタンスをどれくらいのスペックで，何個起動するか，インスタンス間はどのようなネットワークで結び，どのようなアクセス権限を付与するか，などのリソースの要件を逐次的に記述することができる． 一度 CloudFormation ファイルができ上がれば，それにしたがったクラウドシステムをコマンド一つで AWS 上に展開することができる． また，CloudFormation ファイルを交換することで，全く同一のクラウド環境を他者が簡単に再現することも可能になる． このように，本来は物理的な実体のあるハードウェアを，プログラムによって記述し，管理するという考え方を，**Infrastructure as Code (IaC)**とよぶ．</p>
<p>CloudFormation を記述するには，基本的に <strong>JSON</strong> (JavaScript Object Notation) とよばれるフォーマットを使う． 次のコードは，JSON で記述された CloudFormation ファイルの一例 (抜粋) である．</p>
<div class="language-json vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">json</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #96D0FF">&quot;Resources&quot;</span><span style="color: #ADBAC7"> : {</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #FF938A; font-style: italic">...</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #8DDB8C">&quot;WebServer&quot;</span><span style="color: #ADBAC7">: {</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #8DDB8C">&quot;Type&quot;</span><span style="color: #ADBAC7"> : </span><span style="color: #96D0FF">&quot;AWS::EC2::Instance&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #8DDB8C">&quot;Properties&quot;</span><span style="color: #ADBAC7">: {</span></span>
<span class="line"><span style="color: #ADBAC7">      </span><span style="color: #8DDB8C">&quot;ImageId&quot;</span><span style="color: #ADBAC7"> : { </span><span style="color: #8DDB8C">&quot;Fn::FindInMap&quot;</span><span style="color: #ADBAC7"> : [ </span><span style="color: #96D0FF">&quot;AWSRegionArch2AMI&quot;</span><span style="color: #ADBAC7">, { </span><span style="color: #8DDB8C">&quot;Ref&quot;</span><span style="color: #ADBAC7"> : </span><span style="color: #96D0FF">&quot;AWS::Region&quot;</span><span style="color: #ADBAC7"> },</span></span>
<span class="line"><span style="color: #ADBAC7">                        { </span><span style="color: #8DDB8C">&quot;Fn::FindInMap&quot;</span><span style="color: #ADBAC7"> : [ </span><span style="color: #96D0FF">&quot;AWSInstanceType2Arch&quot;</span><span style="color: #ADBAC7">, { </span><span style="color: #8DDB8C">&quot;Ref&quot;</span><span style="color: #ADBAC7"> : </span><span style="color: #96D0FF">&quot;InstanceType&quot;</span><span style="color: #ADBAC7"> }, </span><span style="color: #96D0FF">&quot;Arch&quot;</span><span style="color: #ADBAC7"> ] } ] },</span></span>
<span class="line"><span style="color: #ADBAC7">      </span><span style="color: #8DDB8C">&quot;InstanceType&quot;</span><span style="color: #ADBAC7">   : { </span><span style="color: #8DDB8C">&quot;Ref&quot;</span><span style="color: #ADBAC7"> : </span><span style="color: #96D0FF">&quot;InstanceType&quot;</span><span style="color: #ADBAC7"> },</span></span>
<span class="line"><span style="color: #ADBAC7">      </span><span style="color: #8DDB8C">&quot;SecurityGroups&quot;</span><span style="color: #ADBAC7"> : [ {</span><span style="color: #8DDB8C">&quot;Ref&quot;</span><span style="color: #ADBAC7"> : </span><span style="color: #96D0FF">&quot;WebServerSecurityGroup&quot;</span><span style="color: #ADBAC7">} ],</span></span>
<span class="line"><span style="color: #ADBAC7">      </span><span style="color: #8DDB8C">&quot;KeyName&quot;</span><span style="color: #ADBAC7">        : { </span><span style="color: #8DDB8C">&quot;Ref&quot;</span><span style="color: #ADBAC7"> : </span><span style="color: #96D0FF">&quot;KeyName&quot;</span><span style="color: #ADBAC7"> },</span></span>
<span class="line"><span style="color: #ADBAC7">      </span><span style="color: #8DDB8C">&quot;UserData&quot;</span><span style="color: #ADBAC7"> : { </span><span style="color: #8DDB8C">&quot;Fn::Base64&quot;</span><span style="color: #ADBAC7"> : { </span><span style="color: #8DDB8C">&quot;Fn::Join&quot;</span><span style="color: #ADBAC7"> : [</span><span style="color: #96D0FF">&quot;&quot;</span><span style="color: #ADBAC7">, [</span></span>
<span class="line"><span style="color: #ADBAC7">                     </span><span style="color: #96D0FF">&quot;#!/bin/bash -xe</span><span style="color: #F47067">\n</span><span style="color: #96D0FF">&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                     </span><span style="color: #96D0FF">&quot;yum update -y aws-cfn-bootstrap</span><span style="color: #F47067">\n</span><span style="color: #96D0FF">&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">                     </span><span style="color: #96D0FF">&quot;/opt/aws/bin/cfn-init -v &quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                     </span><span style="color: #96D0FF">&quot;         --stack &quot;</span><span style="color: #ADBAC7">, { </span><span style="color: #8DDB8C">&quot;Ref&quot;</span><span style="color: #ADBAC7"> : </span><span style="color: #96D0FF">&quot;AWS::StackName&quot;</span><span style="color: #ADBAC7"> },</span></span>
<span class="line"><span style="color: #ADBAC7">                     </span><span style="color: #96D0FF">&quot;         --resource WebServer &quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                     </span><span style="color: #96D0FF">&quot;         --configsets wordpress_install &quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                     </span><span style="color: #96D0FF">&quot;         --region &quot;</span><span style="color: #ADBAC7">, { </span><span style="color: #8DDB8C">&quot;Ref&quot;</span><span style="color: #ADBAC7"> : </span><span style="color: #96D0FF">&quot;AWS::Region&quot;</span><span style="color: #ADBAC7"> }, </span><span style="color: #96D0FF">&quot;</span><span style="color: #F47067">\n</span><span style="color: #96D0FF">&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">                     </span><span style="color: #96D0FF">&quot;/opt/aws/bin/cfn-signal -e $? &quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                     </span><span style="color: #96D0FF">&quot;         --stack &quot;</span><span style="color: #ADBAC7">, { </span><span style="color: #8DDB8C">&quot;Ref&quot;</span><span style="color: #ADBAC7"> : </span><span style="color: #96D0FF">&quot;AWS::StackName&quot;</span><span style="color: #ADBAC7"> },</span></span>
<span class="line"><span style="color: #ADBAC7">                     </span><span style="color: #96D0FF">&quot;         --resource WebServer &quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                     </span><span style="color: #96D0FF">&quot;         --region &quot;</span><span style="color: #ADBAC7">, { </span><span style="color: #8DDB8C">&quot;Ref&quot;</span><span style="color: #ADBAC7"> : </span><span style="color: #96D0FF">&quot;AWS::Region&quot;</span><span style="color: #ADBAC7"> }, </span><span style="color: #96D0FF">&quot;</span><span style="color: #F47067">\n</span><span style="color: #96D0FF">&quot;</span></span>
<span class="line"><span style="color: #ADBAC7">      ]]}}</span></span>
<span class="line"><span style="color: #ADBAC7">    },</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #FF938A; font-style: italic">...</span></span>
<span class="line"><span style="color: #ADBAC7">  },</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #FF938A; font-style: italic">...</span></span>
<span class="line"><span style="color: #ADBAC7">},</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #032F62">&quot;Resources&quot;</span><span style="color: #24292E"> : {</span></span>
<span class="line"><span style="color: #24292E">  </span><span style="color: #B31D28; font-style: italic">...</span></span>
<span class="line"><span style="color: #24292E">  </span><span style="color: #005CC5">&quot;WebServer&quot;</span><span style="color: #24292E">: {</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">&quot;Type&quot;</span><span style="color: #24292E"> : </span><span style="color: #032F62">&quot;AWS::EC2::Instance&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">&quot;Properties&quot;</span><span style="color: #24292E">: {</span></span>
<span class="line"><span style="color: #24292E">      </span><span style="color: #005CC5">&quot;ImageId&quot;</span><span style="color: #24292E"> : { </span><span style="color: #005CC5">&quot;Fn::FindInMap&quot;</span><span style="color: #24292E"> : [ </span><span style="color: #032F62">&quot;AWSRegionArch2AMI&quot;</span><span style="color: #24292E">, { </span><span style="color: #005CC5">&quot;Ref&quot;</span><span style="color: #24292E"> : </span><span style="color: #032F62">&quot;AWS::Region&quot;</span><span style="color: #24292E"> },</span></span>
<span class="line"><span style="color: #24292E">                        { </span><span style="color: #005CC5">&quot;Fn::FindInMap&quot;</span><span style="color: #24292E"> : [ </span><span style="color: #032F62">&quot;AWSInstanceType2Arch&quot;</span><span style="color: #24292E">, { </span><span style="color: #005CC5">&quot;Ref&quot;</span><span style="color: #24292E"> : </span><span style="color: #032F62">&quot;InstanceType&quot;</span><span style="color: #24292E"> }, </span><span style="color: #032F62">&quot;Arch&quot;</span><span style="color: #24292E"> ] } ] },</span></span>
<span class="line"><span style="color: #24292E">      </span><span style="color: #005CC5">&quot;InstanceType&quot;</span><span style="color: #24292E">   : { </span><span style="color: #005CC5">&quot;Ref&quot;</span><span style="color: #24292E"> : </span><span style="color: #032F62">&quot;InstanceType&quot;</span><span style="color: #24292E"> },</span></span>
<span class="line"><span style="color: #24292E">      </span><span style="color: #005CC5">&quot;SecurityGroups&quot;</span><span style="color: #24292E"> : [ {</span><span style="color: #005CC5">&quot;Ref&quot;</span><span style="color: #24292E"> : </span><span style="color: #032F62">&quot;WebServerSecurityGroup&quot;</span><span style="color: #24292E">} ],</span></span>
<span class="line"><span style="color: #24292E">      </span><span style="color: #005CC5">&quot;KeyName&quot;</span><span style="color: #24292E">        : { </span><span style="color: #005CC5">&quot;Ref&quot;</span><span style="color: #24292E"> : </span><span style="color: #032F62">&quot;KeyName&quot;</span><span style="color: #24292E"> },</span></span>
<span class="line"><span style="color: #24292E">      </span><span style="color: #005CC5">&quot;UserData&quot;</span><span style="color: #24292E"> : { </span><span style="color: #005CC5">&quot;Fn::Base64&quot;</span><span style="color: #24292E"> : { </span><span style="color: #005CC5">&quot;Fn::Join&quot;</span><span style="color: #24292E"> : [</span><span style="color: #032F62">&quot;&quot;</span><span style="color: #24292E">, [</span></span>
<span class="line"><span style="color: #24292E">                     </span><span style="color: #032F62">&quot;#!/bin/bash -xe</span><span style="color: #005CC5">\n</span><span style="color: #032F62">&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                     </span><span style="color: #032F62">&quot;yum update -y aws-cfn-bootstrap</span><span style="color: #005CC5">\n</span><span style="color: #032F62">&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">                     </span><span style="color: #032F62">&quot;/opt/aws/bin/cfn-init -v &quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                     </span><span style="color: #032F62">&quot;         --stack &quot;</span><span style="color: #24292E">, { </span><span style="color: #005CC5">&quot;Ref&quot;</span><span style="color: #24292E"> : </span><span style="color: #032F62">&quot;AWS::StackName&quot;</span><span style="color: #24292E"> },</span></span>
<span class="line"><span style="color: #24292E">                     </span><span style="color: #032F62">&quot;         --resource WebServer &quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                     </span><span style="color: #032F62">&quot;         --configsets wordpress_install &quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                     </span><span style="color: #032F62">&quot;         --region &quot;</span><span style="color: #24292E">, { </span><span style="color: #005CC5">&quot;Ref&quot;</span><span style="color: #24292E"> : </span><span style="color: #032F62">&quot;AWS::Region&quot;</span><span style="color: #24292E"> }, </span><span style="color: #032F62">&quot;</span><span style="color: #005CC5">\n</span><span style="color: #032F62">&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">                     </span><span style="color: #032F62">&quot;/opt/aws/bin/cfn-signal -e $? &quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                     </span><span style="color: #032F62">&quot;         --stack &quot;</span><span style="color: #24292E">, { </span><span style="color: #005CC5">&quot;Ref&quot;</span><span style="color: #24292E"> : </span><span style="color: #032F62">&quot;AWS::StackName&quot;</span><span style="color: #24292E"> },</span></span>
<span class="line"><span style="color: #24292E">                     </span><span style="color: #032F62">&quot;         --resource WebServer &quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                     </span><span style="color: #032F62">&quot;         --region &quot;</span><span style="color: #24292E">, { </span><span style="color: #005CC5">&quot;Ref&quot;</span><span style="color: #24292E"> : </span><span style="color: #032F62">&quot;AWS::Region&quot;</span><span style="color: #24292E"> }, </span><span style="color: #032F62">&quot;</span><span style="color: #005CC5">\n</span><span style="color: #032F62">&quot;</span></span>
<span class="line"><span style="color: #24292E">      ]]}}</span></span>
<span class="line"><span style="color: #24292E">    },</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #B31D28; font-style: italic">...</span></span>
<span class="line"><span style="color: #24292E">  },</span></span>
<span class="line"><span style="color: #24292E">  </span><span style="color: #B31D28; font-style: italic">...</span></span>
<span class="line"><span style="color: #24292E">},</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br></div></div><p>ここでは， &quot;WebServer&quot; という名前のつけられた EC2 インスタンスを定義している．かなり長大で複雑な記述であるが，これによって所望のスペック・OS をもつ EC2 インスタンスを自動的に生成することが可能になる．</p>
<h3 id="aws-cdk" tabindex="-1">AWS CDK <a class="header-anchor" href="#aws-cdk" aria-label="Permalink to &quot;AWS CDK&quot;">&ZeroWidthSpace;</a></h3>
<p>前節で紹介した CloudFormation は，見てわかるとおり大変記述が複雑であり，またそれのどれか一つにでも誤りがあってはいけない． また，基本的に&quot;テキスト&quot;を書いていくことになるので，プログラミング言語で使うような変数やクラスといった便利な概念が使えない　(厳密には， CloudFormation にも変数に相当するような機能は存在する)． また，記述の多くの部分は繰り返しが多く，自動化できる部分も多い．</p>
<p>そのような悩みを解決してくれるのが， <a href="https://aws.amazon.com/cdk/" target="_blank" rel="noreferrer">AWS Cloud Development Kit (CDK)</a> である． <strong>CDK は Python などのプログラミング言語を使って CloudFormation を自動的に生成してくれるツールである．</strong> CDK は 2019 年にリリースされたばかりの比較的新しいツールで，日々改良が進められている (<a href="https://github.com/aws/aws-cdk/releases" target="_blank" rel="noreferrer">GitHub リポジトリ</a> のリリースを見ればその開発のスピードの速さがわかるだろう)． CDK は TypeScript (JavaScript), Python, Java など複数の言語でサポートされている．</p>
<p>CDK を使うことで，CloudFormation に相当するクラウドリソースの記述を，より親しみのあるプログラミング言語を使って行うことができる． かつ，典型的なリソース操作に関してはパラメータの多くの部分を自動で決定してくれるので，記述しなければならない量もかなり削減される．</p>
<p>以下に Python を使った CDK のコードの一例 (抜粋) を示す．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">from</span><span style="color: #ADBAC7"> aws_cdk </span><span style="color: #F47067">import</span><span style="color: #ADBAC7"> (</span></span>
<span class="line"><span style="color: #ADBAC7">    core,</span></span>
<span class="line"><span style="color: #ADBAC7">    aws_ec2 </span><span style="color: #F47067">as</span><span style="color: #ADBAC7"> ec2,</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F47067">class</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50">MyFirstEc2</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">core</span><span style="color: #ADBAC7">.</span><span style="color: #6CB6FF">Stack</span><span style="color: #ADBAC7">):</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">def</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">__init__</span><span style="color: #ADBAC7">(self, scope, name, </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">kwargs):</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #6CB6FF">super</span><span style="color: #ADBAC7">().</span><span style="color: #6CB6FF">__init__</span><span style="color: #ADBAC7">(scope, name, </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">kwargs)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        vpc </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ec2.Vpc(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">...</span><span style="color: #ADBAC7"> </span><span style="color: #768390"># some parameters</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        sg </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ec2.SecurityGroup(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">...</span><span style="color: #ADBAC7"> </span><span style="color: #768390"># some parameters</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        host </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ec2.Instance(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;MyGreatEc2&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">instance_type</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.InstanceType(</span><span style="color: #96D0FF">&quot;t2.micro&quot;</span><span style="color: #ADBAC7">),</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">machine_image</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.MachineImage.latest_amazon_linux(),</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">vpc</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">vpc,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">...</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">from</span><span style="color: #24292E"> aws_cdk </span><span style="color: #D73A49">import</span><span style="color: #24292E"> (</span></span>
<span class="line"><span style="color: #24292E">    core,</span></span>
<span class="line"><span style="color: #24292E">    aws_ec2 </span><span style="color: #D73A49">as</span><span style="color: #24292E"> ec2,</span></span>
<span class="line"><span style="color: #24292E">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D73A49">class</span><span style="color: #24292E"> </span><span style="color: #6F42C1">MyFirstEc2</span><span style="color: #24292E">(</span><span style="color: #6F42C1">core</span><span style="color: #24292E">.</span><span style="color: #6F42C1">Stack</span><span style="color: #24292E">):</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">def</span><span style="color: #24292E"> </span><span style="color: #005CC5">__init__</span><span style="color: #24292E">(self, scope, name, </span><span style="color: #D73A49">**</span><span style="color: #24292E">kwargs):</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #005CC5">super</span><span style="color: #24292E">().</span><span style="color: #005CC5">__init__</span><span style="color: #24292E">(scope, name, </span><span style="color: #D73A49">**</span><span style="color: #24292E">kwargs)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        vpc </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ec2.Vpc(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">...</span><span style="color: #24292E"> </span><span style="color: #6A737D"># some parameters</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        sg </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ec2.SecurityGroup(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">...</span><span style="color: #24292E"> </span><span style="color: #6A737D"># some parameters</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        host </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ec2.Instance(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;MyGreatEc2&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">instance_type</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.InstanceType(</span><span style="color: #032F62">&quot;t2.micro&quot;</span><span style="color: #24292E">),</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">machine_image</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.MachineImage.latest_amazon_linux(),</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">vpc</span><span style="color: #D73A49">=</span><span style="color: #24292E">vpc,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">...</span></span>
<span class="line"><span style="color: #24292E">        )</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br></div></div><p>このコードは，一つ前に示した JSON を使った CloudFormation と実質的に同じことを記述している． とても煩雑だった CloudFormation ファイルに比べて， CDK と Python を使うことで格段に短く，わかりやすく記述できることができるのがわかるだろう．</p>
<p>本書の主題は，<strong>CDK を使って，コードを書きながら AWS の概念や開発方法を学んでいくことである</strong>． 後の章では CDK を使って様々なハンズオンを実施していく． 早速，最初のハンズオンでは， CDK を使って EC2 インスタンスを作成する方法を学んでいこう．</p>
<ul>
<li><a href="https://github.com/aws-samples/aws-cdk-examples" target="_blank" rel="noreferrer">AWS CDK Examples</a>: CDK を使ったプロジェクトの例が多数紹介されている． ここにある例をテンプレートに自分のアプリケーションの開発を進めるとよい．</li>
</ul>
]]></description>
            <content:encoded><![CDATA[<h1 id="aws-入門" tabindex="-1">AWS 入門 <a class="header-anchor" href="#aws-入門" aria-label="Permalink to &quot;AWS 入門&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="aws-とは" tabindex="-1">AWS とは？ <a class="header-anchor" href="#aws-とは" aria-label="Permalink to &quot;AWS とは？&quot;">&ZeroWidthSpace;</a></h2>
<p>本書では，クラウドの実践を行うプラットフォームとして， AWS を用いる． 実践にあたって，最低限必要な AWS の知識を本章では解説しよう．</p>
<p><a href="https://aws.amazon.com" target="_blank" rel="noreferrer">AWS (Amazon Web Services)</a> は Amazon 社が提供する総合的なクラウドプラットフォームである． AWS は Amazon 社が持つ膨大な計算リソースを貸し出すクラウドサービスとして，2006 年に誕生した． 2021 年では，クラウドプロバイダーとして最大のマーケットシェア (約 32%) を保持している (<a href="https://www.canalys.com/newsroom/global-cloud-market-Q121" target="_blank" rel="noreferrer">参照</a>)． Netflix や Slack をはじめとした多くのウェブ関連のサービスで，一部または全てのサーバーリソースが AWS から提供されているとのことである． よって，知らないうちに AWS の恩恵にあずかっている人も少なくないはずだ．</p>
<p>最大のシェアをもつだけに，機能・サービスの幅広さはほかのクラウドプラットフォームと比べ抜きんでている． また，利用者数が多いことを反映して，公式あるいはサードパーティによる技術紹介記事が数多くウェブ上に存在しているだけでなく，ライブラリのユーザーコミュニティも大きく問題解決が捗るのも魅力の一つだ． 初期のころウェブビジネスを行う企業がユーザーの大半を占めていたが，最近は大学などでの科学研究用途としても頻繁に用いられるようになってきている．</p>
<h2 id="aws-の機能・サービス" tabindex="-1">AWS の機能・サービス <a class="header-anchor" href="#aws-の機能・サービス" aria-label="Permalink to &quot;AWS の機能・サービス&quot;">&ZeroWidthSpace;</a></h2>
<p><a href="#fig_aws_services">figure_title</a> は，執筆時点において AWS で提供されている主要な機能・サービスの一覧である．</p>
<p><img src="./assets/aws_services.png" alt="AWSで提供されている主要なサービス一覧"></p>
<p>計算，ストレージ，データベース，ネットワーク，セキュリティなど，クラウドの構築に必要な様々な要素が<strong>独立したコンポーネント</strong>として提供されている． 基本的に，これらを組み合わせることで一つのクラウドシステムができあがる．</p>
<p>また，機械学習・音声認識・AR/VR など，特定のアプリケーションにパッケージ済みのサービスも提供されている． これらを合計すると全部で 170 個以上のサービスが提供されているとのことである (<a href="https://dev.classmethod.jp/articles/aws-summary-2020/" target="_blank" rel="noreferrer">参照</a>)．</p>
<p>AWS の初心者が陥りがちなのは，<strong>大量のサービスの数に圧倒され，どこから手をつけたらよいのかわからなくなる</strong>，という状況である． たくさんのサービスの中から，どのサービスをどの順番で学んでいったらいいのか，その道筋すら明らかでなく，大きな参入障壁となっていることは間違いない． だが実のところ， AWS の<strong>基本的な構成要素はそのうちの数個</strong>のみに限られる． 基本要素となる機能の使い方を知れば， AWS のおおよそのリソースを使いこなすことが可能になる． ほかの機能の多くは，基本の要素を組み合わせて特定のアプリケーションに特化したパッケージとして AWS が用意したものである． そのポイントを認知することが， AWS の学習の最初のステップである．</p>
<p>ここでは， AWS 上でクラウドシステムを構築するときの基本となる構成要素を列挙する． これらは後のハンズオンで実際にプログラムを書きながら体験する． 現時点では，名前だけでも頭の片隅に記憶してもらえればよい．</p>
<h3 id="計算" tabindex="-1">計算 <a class="header-anchor" href="#計算" aria-label="Permalink to &quot;計算&quot;">&ZeroWidthSpace;</a></h3>
<p><img src="./assets/aws_logos/EC2.png" alt="S3"> <strong>EC2 (Elastic Compute Cloud)</strong> 様々なスペックの仮想マシンを作成し，計算を実行することができる． クラウドの最も基本となる構成要素である． (#sec_first_ec2), (#sec_jupyter_and_deep_learning), (#sec_aws_batch) で詳しく触れる．</p>
<p><img src="./assets/aws_logos/Lambda.png" alt="S3"> <strong>Lambda</strong> Function as a Service (FaaS) とよばれる，小さな計算を<strong>サーバーなし</strong>で実行するためのサービス． サーバーレスアーキテクチャの章 ( (#sec_serverless)) で詳しく解説する．</p>
<h3 id="ストレージ" tabindex="-1">ストレージ <a class="header-anchor" href="#ストレージ" aria-label="Permalink to &quot;ストレージ&quot;">&ZeroWidthSpace;</a></h3>
<p><img src="./assets/aws_logos/EBS.png" alt="S3">
<strong>EBS (Elastic Block Store)</strong> EC2 に付与することのできる仮想データドライブ． いわゆる&quot;普通の&quot;(一般的な OS で使われている)ファイルシステムを思い浮かべてくれたらよい．</p>
<p><img src="./assets/aws_logos/S3.png" alt="S3"></p>
<p><strong>S3 (Simple Storage Service)</strong> Object Storage とよばれる，API を使ってデータの読み書きを行う，いうなれば”クラウド・ネイティブ”なデータの格納システムである． サーバーレスアーキテクチャの章 ( (#sec_serverless)) で詳しく解説する．</p>
<h3 id="データベース" tabindex="-1">データベース <a class="header-anchor" href="#データベース" aria-label="Permalink to &quot;データベース&quot;">&ZeroWidthSpace;</a></h3>
<p><img src="./assets/aws_logos/DynamoDB.png" alt="S3"></p>
<p><strong>DynamoDB</strong> NoSQL 型のデータベースサービス (知っている人は <code>mongoDB</code> などを思い浮かべたらよい)． サーバーレスアーキテクチャの章 ( (#sec_serverless)) で詳しく解説する．</p>
<h3 id="ネットワーク" tabindex="-1">ネットワーク <a class="header-anchor" href="#ネットワーク" aria-label="Permalink to &quot;ネットワーク&quot;">&ZeroWidthSpace;</a></h3>
<p><img src="./assets/aws_logos/VPC.png" alt="S3"> <strong>VPC(Virtual Private Cloud)</strong> AWS 上に仮想ネットワーク環境を作成し，仮想サーバー間の接続を定義したり，外部からのアクセスなどを管理する． EC2 は VPC の内部に配置されなければならない．</p>
<p><strong>API Gateway</strong> <img src="./assets/aws_logos/APIGateway.png" alt="S3"></p>
<p>API のエンドポイントとバックエンドのサービス (Lambda など) を接続する際に用いる，リバースプロキシとしての役割を担う． (#sec_bashoutter) で詳しく解説する．</p>
<h2 id="region-と-availability-zone" tabindex="-1">Region と Availability Zone <a class="header-anchor" href="#region-と-availability-zone" aria-label="Permalink to &quot;Region と Availability Zone&quot;">&ZeroWidthSpace;</a></h2>
<p>AWS を使用する際に知っておかなければならない重要な概念として， <strong>リージョン (Region)</strong> と <strong>Availability Zone (AZ)</strong> がある (<a href="#fig_aws_regions_and_azs">figure_title</a>)． 以下ではこの概念について簡単に記述する．</p>
<p><img src="./assets/aws_region_and_az.png" alt="AWSにおける Region と Availability Zones"></p>
<p><strong>リージョン (Region)</strong> とは，おおまかに言うとデータセンターの所在地のことである． 執筆時点において， AWS は世界の 25 の国と地域でデータセンターを所有している． <a href="#fig_aws_regions">figure_title</a> は執筆時点で利用できるリージョンの世界地図を示している． 日本では東京と大阪にデータセンターがある． 各リージョンには固有の ID がついており，例えば東京は <code>ap-northeast-1</code>, 米国オハイオ州は <code>us-east-2</code>，などと定義されている．</p>
<p><img src="./assets/aws_regions.png" alt="Regions in AWS(出典: https://aws.amazon.com/about-aws/global-infrastructure/)"></p>
<p>AWS コンソールにログインすると，画面右上のメニューバーでリージョンを選択することができる(<a href="#fig_aws_console_regions">figure_title</a>, 赤丸で囲った箇所)． EC2, S3 などの AWS のリソースは，リージョンごとに完全に独立である． したがって，<strong>リソースを新たにデプロイする際，あるいはデプロイ済みのリソースを閲覧する際は，コンソールのリージョンが正しく設定されているか，確認する必要がある</strong>． ウェブビジネスを展開する場合などは，世界の各地にクラウドを展開する必要があるが，個人的な研究用途として用いる場合は，最寄りのリージョン (i.e. 東京) を使えば基本的に問題ない．</p>
<p><img src="./assets/aws_regions2.png" alt="AWSコンソールでリージョンを選択"></p>
<p><code>Avaialibity Zone (AZ)</code> とは，リージョン内で地理的に隔離されたデータセンターのことである． それぞれのリージョンは 2 個以上の AZ を有しており，もし一つの AZ で火災や停電などが起きた場合でも，ほかの AZ がその障害をカバーすることができる． また， AZ 間は高速な AWS 専用ネットワーク回線で結ばれているため， AZ 間のデータ転送は極めて早い． AZ は，ビジネスなどでサーバーダウンが許容されない場合などに注意すべき概念であり，個人的な用途で使う限りにおいてはあまり深く考慮する必要はない．言葉の意味だけ知っておけば十分である．</p>
<p>AWS を使用する際，どこのリージョンを指定するのがよいのだろうか？ インターネットの接続速度の観点からは，地理的に一番近いリージョンを使用するのが一般的によいだろう． 一方， EC2 の利用料などはリージョンごとに価格設定が若干 (10-20%程度) 異なる． したがって，自分が最も頻繁に利用するサービスの価格が最も安く設定されているリージョンを選択する，というのも重要な視点である． また，いくつかのサービスは，特定のリージョンで利用できない場合もある． これらのポイントから総合的に判断して使用するリージョンを決めると良い．</p>
<p>AWS Educate を利用している読者へ</p>
<p>執筆時点において，AWS Educate による Starter Account を使用している場合は <code>us-east-1</code> region のみ利用できる (<a href="https://awseducate-starter-account-services.s3.amazonaws.com/AWS_Educate_Starter_Account_Services_Supported.pdf" target="_blank" rel="noreferrer">参照</a>)．</p>
<ul>
<li><a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-regions-availability-zones.html" target="_blank" rel="noreferrer">AWS documentation &quot;Regions, Availability Zones, and Local Zones&quot;</a></li>
</ul>
<h2 id="aws-でのクラウド開発" tabindex="-1">AWS でのクラウド開発 <a class="header-anchor" href="#aws-でのクラウド開発" aria-label="Permalink to &quot;AWS でのクラウド開発&quot;">&ZeroWidthSpace;</a></h2>
<p>AWS のクラウドの全体像がわかってきたところで，次のトピックとして，どのようにして AWS 上にクラウドの開発を行い，展開していくかについての概略を解説しよう．</p>
<p>AWS のリソースを追加・編集・削除するなどの操作を実行するには，<strong>コンソールを用いる</strong>方法と，<strong>API を用いる方法</strong>の，二つの経路がある．</p>
<h3 id="コンソール画面からリソースを操作する" tabindex="-1">コンソール画面からリソースを操作する <a class="header-anchor" href="#コンソール画面からリソースを操作する" aria-label="Permalink to &quot;コンソール画面からリソースを操作する&quot;">&ZeroWidthSpace;</a></h3>
<p>AWS のアカウントにログインすると，まず最初に表示されるのが<strong>AWS コンソール</strong>である (<a href="#aws_console_window">figure_title</a>)．</p>
<p><img src="./assets/aws_console.png" alt="AWSマネージメントコンソール画面"></p>
<p>コンソールを使うことで， EC2 のインスタンスを立ち上げたり，S3 のデータを追加・削除したり，ログを閲覧したりなど，AWS 上のあらゆるリソースの操作を GUI (Graphical User Interface) を通して実行することができる． <strong>初めて触る機能をポチポチと試したり，デバッグを行うときなどにとても便利である</strong>．</p>
<p>コンソールはさらっと機能を試したり，開発中のクラウドのデバッグをするときには便利なのであるが，実際にクラウドの開発をする場面でこれを直接いじることはあまりない． むしろ，次に紹介する API を使用して，プログラムとしてクラウドのリソースを記述することで開発を行うのが一般的である． そのような理由で，本書では AWS コンソールを使った AWS の使い方はあまり触れない． AWS のドキュメンテーションには，たくさんの <a href="https://aws.amazon.com/getting-started/hands-on/" target="_blank" rel="noreferrer">チュートリアル</a> が用意されており，コンソール画面から様々な操作を行う方法が記述されているので，興味がある読者はそちらを参照されたい．</p>
<h3 id="api-からリソースを操作する" tabindex="-1">API からリソースを操作する <a class="header-anchor" href="#api-からリソースを操作する" aria-label="Permalink to &quot;API からリソースを操作する&quot;">&ZeroWidthSpace;</a></h3>
<p><strong>API (Application Programming Interface)</strong> を使うことで，コマンドを AWS に送信し，クラウドのリソースの操作をすることができる． API とは，端的に言えば AWS が公開しているコマンドの一覧であり，<code>GET</code>, <code>POST</code>, <code>DELETE</code> などの <strong>REST API</strong> から構成されている (REST API については (#sec_rest_api) で簡単に解説する)． が，直接 REST API を入力するのは面倒であるので，その手間を解消するための様々なツールが提供されている．</p>
<p>例えば， <a href="https://docs.aws.amazon.com/cli/latest/index.html" target="_blank" rel="noreferrer">AWS CLI</a> は， UNIX コンソールから AWS API を実行するための CLI (Command Line Interface) である． CLI に加えて，いろいろなプログラミング言語での SDK (Software Development Kit) が提供されている．以下に一例を挙げる．</p>
<ul>
<li>
<p>Python ⇒ <a href="https://boto3.amazonaws.com/v1/documentation/api/latest/index.html" target="_blank" rel="noreferrer">boto3</a></p>
</li>
<li>
<p>Ruby ⇒ <a href="https://aws.amazon.com/sdk-for-ruby/" target="_blank" rel="noreferrer">AWS SDK for Ruby</a></p>
</li>
<li>
<p>Node.js ⇒ <a href="https://aws.amazon.com/sdk-for-node-js/" target="_blank" rel="noreferrer">AWS SDK for Node.js</a></p>
</li>
</ul>
<p>具体的な API の使用例を見てみよう．</p>
<p>S3 に新しい保存領域 (<code>Bucket (バケット)</code> とよばれる) を追加したいとしよう． AWS CLI を使った場合は，次のようなコマンドを打てばよい．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">s3</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">mb</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">s3://my-bucket</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--region</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ap-northeast-1</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">aws</span><span style="color: #24292E"> </span><span style="color: #032F62">s3</span><span style="color: #24292E"> </span><span style="color: #032F62">mb</span><span style="color: #24292E"> </span><span style="color: #032F62">s3://my-bucket</span><span style="color: #24292E"> </span><span style="color: #005CC5">--region</span><span style="color: #24292E"> </span><span style="color: #032F62">ap-northeast-1</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>上記のコマンドは， <code>my-bucket</code> という名前のバケットを， <code>ap-northeast-1</code> のリージョンに作成する．</p>
<p>Python からこれと同じ操作を実行するには， <code>boto3</code> ライブラリを使って，次のようなスクリプトを実行する．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> boto3</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">s3_client </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> boto3.client(</span><span style="color: #96D0FF">&quot;s3&quot;</span><span style="color: #ADBAC7">, </span><span style="color: #F69D50">region_name</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;ap-northeast-1&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">s3_client.create_bucket(</span><span style="color: #F69D50">Bucket</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;my-bucket&quot;</span><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> boto3</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">s3_client </span><span style="color: #D73A49">=</span><span style="color: #24292E"> boto3.client(</span><span style="color: #032F62">&quot;s3&quot;</span><span style="color: #24292E">, </span><span style="color: #E36209">region_name</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;ap-northeast-1&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">s3_client.create_bucket(</span><span style="color: #E36209">Bucket</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;my-bucket&quot;</span><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br></div></div><p>もう一つ例をあげよう．</p>
<p>新しい EC2 のインスタンス(インスタンスとは，起動状態にある仮想サーバーの意味である)を起動するには，次のようなコマンドを打てば良い．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ec2</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">run-instances</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--image-id</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ami-xxxxxxxx</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--count</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--instance-type</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">t2.micro</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--key-name</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">MyKeyPair</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--security-group-ids</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">sg-903004f8</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--subnet-id</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">subnet-6e7f829e</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">aws</span><span style="color: #24292E"> </span><span style="color: #032F62">ec2</span><span style="color: #24292E"> </span><span style="color: #032F62">run-instances</span><span style="color: #24292E"> </span><span style="color: #005CC5">--image-id</span><span style="color: #24292E"> </span><span style="color: #032F62">ami-xxxxxxxx</span><span style="color: #24292E"> </span><span style="color: #005CC5">--count</span><span style="color: #24292E"> </span><span style="color: #005CC5">1</span><span style="color: #24292E"> </span><span style="color: #005CC5">--instance-type</span><span style="color: #24292E"> </span><span style="color: #032F62">t2.micro</span><span style="color: #24292E"> </span><span style="color: #005CC5">--key-name</span><span style="color: #24292E"> </span><span style="color: #032F62">MyKeyPair</span><span style="color: #24292E"> </span><span style="color: #005CC5">--security-group-ids</span><span style="color: #24292E"> </span><span style="color: #032F62">sg-903004f8</span><span style="color: #24292E"> </span><span style="color: #005CC5">--subnet-id</span><span style="color: #24292E"> </span><span style="color: #032F62">subnet-6e7f829e</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>このコマンドにより， <a href="https://aws.amazon.com/ec2/instance-types/t2/" target="_blank" rel="noreferrer">t2.micro</a> というタイプ (1 vCPU, 1.0 GB RAM) のインスタンスが起動する． ここではその他のパラメータの詳細の説明は省略する (ハンズオン ( (#sec_first_ec2)) で詳しく解説する)．</p>
<p>Python から上記と同じ操作を実行するには，以下のようなスクリプトを使う．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> boto3</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">ec2_client </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> boto3.client(</span><span style="color: #96D0FF">&quot;ec2&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">ec2_client.run_instances(</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">ImageId</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;ami-xxxxxxxxx&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">MinCount</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">MaxCount</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">KeyName</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;MyKeyPair&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">InstanceType</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;t2.micro&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">SecurityGroupIds</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">[</span><span style="color: #96D0FF">&quot;sg-903004f8&quot;</span><span style="color: #ADBAC7">],</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">SubnetId</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;subnet-6e7f829e&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> boto3</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">ec2_client </span><span style="color: #D73A49">=</span><span style="color: #24292E"> boto3.client(</span><span style="color: #032F62">&quot;ec2&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">ec2_client.run_instances(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">ImageId</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;ami-xxxxxxxxx&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">MinCount</span><span style="color: #D73A49">=</span><span style="color: #005CC5">1</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">MaxCount</span><span style="color: #D73A49">=</span><span style="color: #005CC5">1</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">KeyName</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;MyKeyPair&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">InstanceType</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;t2.micro&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">SecurityGroupIds</span><span style="color: #D73A49">=</span><span style="color: #24292E">[</span><span style="color: #032F62">&quot;sg-903004f8&quot;</span><span style="color: #24292E">],</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">SubnetId</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;subnet-6e7f829e&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br></div></div><p>以上の例を通じて，API によるクラウドのリソースの操作のイメージがつかめてきただろうか？ コマンド一つで，新しい仮想サーバーを起動したり，データの保存領域を追加したり，任意の操作を実行できるわけである． 基本的に，このようなコマンドを複数組み合わせていくことで，自分の望む CPU・RAM・ネットワーク・ストレージが備わった計算環境を構築することができる． もちろん，逆の操作 (リソースの削除) も API を使って実行できる．</p>
<h3 id="ミニ・ハンズオン-aws-cli-を使ってみよう" tabindex="-1">ミニ・ハンズオン: AWS CLI を使ってみよう <a class="header-anchor" href="#ミニ・ハンズオン-aws-cli-を使ってみよう" aria-label="Permalink to &quot;ミニ・ハンズオン: AWS CLI を使ってみよう&quot;">&ZeroWidthSpace;</a></h3>
<p>ここでは，ミニ・ハンズオンとして，AWS CLI を実際に使ってみる． AWS CLI は先述のとおり， AWS 上の任意のリソースの操作が可能であるが，ここでは一番シンプルな，<strong>S3 を使ったファイルの読み書きを実践する</strong> (EC2 の操作は少し複雑なので，第一回ハンズオンで行う)． <code>aws s3</code> コマンドの詳しい使い方は <a href="https://docs.aws.amazon.com/cli/latest/reference/s3/index.html#cli-aws-s3" target="_blank" rel="noreferrer">公式ドキュメンテーション</a>を参照．</p>
<p>AWS CLI のインストールについては， (#aws_cli_install) を参照．</p>
<p>以下に紹介するハンズオンは，基本的に <a href="https://aws.amazon.com/free/?all-free-tier.sort-by=item.additionalFields.SortRank&amp;all-free-tier.sort-order=asc" target="_blank" rel="noreferrer">S3 の無料枠</a> の範囲内で実行することができる．</p>
<p>以下のコマンドを実行する前に，AWS の認証情報が正しく設定されていることを確認する． これには <code>~/.aws/credentials</code> のファイルに設定が書き込まれているか，環境変数 (<code>AWS_ACCESS_KEY_ID</code>, <code>AWS_SECRET_ACCESS_KEY</code>, <code>AWS_DEFAULT_REGION</code>) が定義されている必要がある． 詳しくは (#aws_cli_install) を参照．</p>
<p>まずは，S3 にデータの格納領域 (<code>Bucket</code> とよばれる．一般的な OS での&quot;ドライブ&quot;に相当する) を作成するところから始めよう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">bucketName=&quot;mybucket-$(</span><span style="color: #F69D50">openssl</span><span style="color: #96D0FF"> rand </span><span style="color: #6CB6FF">-hex</span><span style="color: #96D0FF"> </span><span style="color: #6CB6FF">12</span><span style="color: #96D0FF">)&quot;</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">echo</span><span style="color: #ADBAC7"> $bucketName</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">s3</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">mb</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;s3://${</span><span style="color: #ADBAC7">bucketName</span><span style="color: #96D0FF">}&quot;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">bucketName=&quot;mybucket-$(</span><span style="color: #6F42C1">openssl</span><span style="color: #032F62"> rand </span><span style="color: #005CC5">-hex</span><span style="color: #032F62"> </span><span style="color: #005CC5">12</span><span style="color: #032F62">)&quot;</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">echo</span><span style="color: #24292E"> $bucketName</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">aws</span><span style="color: #24292E"> </span><span style="color: #032F62">s3</span><span style="color: #24292E"> </span><span style="color: #032F62">mb</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;s3://${</span><span style="color: #24292E">bucketName</span><span style="color: #032F62">}&quot;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><p>S3 のバケットの名前は， AWS 全体で一意的でなければならないことから，前述のコマンドではランダムな文字列を含んだバケットの名前を生成し，<code>bucketName</code> という変数に格納している． そして， <code>aws s3 mb</code> (<code>mb</code> は make bucket の略) によって，新しいバケットを作成する．</p>
<p>次に，バケットの一覧を取得してみよう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">s3</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ls</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F69D50">2020-06-07</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">23</span><span style="color: #96D0FF">:45:44</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">mybucket-c6f93855550a72b5b66f5efe</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">aws</span><span style="color: #24292E"> </span><span style="color: #032F62">s3</span><span style="color: #24292E"> </span><span style="color: #032F62">ls</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6F42C1">2020-06-07</span><span style="color: #24292E"> </span><span style="color: #005CC5">23</span><span style="color: #032F62">:45:44</span><span style="color: #24292E"> </span><span style="color: #032F62">mybucket-c6f93855550a72b5b66f5efe</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><p>先ほど作成したバケットがリストにあることを確認できる．</p>
<p>本書のノーテーションとして，コマンドラインに入力するコマンドは，それがコマンドであると明示する目的で先頭に <code>$</code> がつけてある． <code>$</code> はコマンドをコピー&amp;ペーストするときは除かなければならない． 逆に，コマンドの出力は <code>$</code> なしで表示されている．</p>
<p>次に，バケットにファイルをアップロードする．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">echo</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;Hello world&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">&gt;</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">hello_world.txt</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">s3</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cp</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">hello_world.txt</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;s3://${</span><span style="color: #ADBAC7">bucketName</span><span style="color: #96D0FF">}/hello_world.txt&quot;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">echo</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;Hello world&quot;</span><span style="color: #24292E"> </span><span style="color: #D73A49">&gt;</span><span style="color: #24292E"> </span><span style="color: #032F62">hello_world.txt</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">aws</span><span style="color: #24292E"> </span><span style="color: #032F62">s3</span><span style="color: #24292E"> </span><span style="color: #032F62">cp</span><span style="color: #24292E"> </span><span style="color: #032F62">hello_world.txt</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;s3://${</span><span style="color: #24292E">bucketName</span><span style="color: #032F62">}/hello_world.txt&quot;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>上では <code>hello_world.txt</code> というダミーのファイルを作成して，それをアップロードした．</p>
<p>それでは，バケットの中にあるファイルの一覧を取得してみる．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">s3</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ls</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;s3://${</span><span style="color: #ADBAC7">bucketName</span><span style="color: #96D0FF">}&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--human-readable</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F69D50">2020-06-07</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">23</span><span style="color: #96D0FF">:54:19</span><span style="color: #ADBAC7">   </span><span style="color: #6CB6FF">13</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">Bytes</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">hello_world.txt</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">aws</span><span style="color: #24292E"> </span><span style="color: #032F62">s3</span><span style="color: #24292E"> </span><span style="color: #032F62">ls</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;s3://${</span><span style="color: #24292E">bucketName</span><span style="color: #032F62">}&quot;</span><span style="color: #24292E"> </span><span style="color: #005CC5">--human-readable</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6F42C1">2020-06-07</span><span style="color: #24292E"> </span><span style="color: #005CC5">23</span><span style="color: #032F62">:54:19</span><span style="color: #24292E">   </span><span style="color: #005CC5">13</span><span style="color: #24292E"> </span><span style="color: #032F62">Bytes</span><span style="color: #24292E"> </span><span style="color: #032F62">hello_world.txt</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><p>先ほどアップロードしたファイルがたしかに存在することがわかる．</p>
<p>最後に，使い終わったバケットを削除する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">s3</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">rb</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;s3://${</span><span style="color: #ADBAC7">bucketName</span><span style="color: #96D0FF">}&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--force</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">aws</span><span style="color: #24292E"> </span><span style="color: #032F62">s3</span><span style="color: #24292E"> </span><span style="color: #032F62">rb</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;s3://${</span><span style="color: #24292E">bucketName</span><span style="color: #032F62">}&quot;</span><span style="color: #24292E"> </span><span style="color: #005CC5">--force</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p><code>rb</code> は remove bucket の略である． デフォルトでは，バケットの中にファイルが存在すると削除できない． 空でないバケットを強制的に削除するには <code>--force</code> のオプションを付ける．</p>
<p>以上のように，AWS CLI を使って S3 バケットに対しての一連の操作を実行できた． EC2 や Lambda, DynamoDB などについても同様に AWS CLI を使ってあらゆる操作を実行できる．</p>
<p><strong>Amazon Resource Name (ARN)</strong></p>
<p>AWS 上のあらゆるリソースには， Amazon Resource Name (ARN) という固有の ID が付与されている． ARN は <code>arn:aws:s3:::my_bucket/</code> のようなフォーマットで記述され，ARN を使用することで，特定の AWS リソース (S3 のバケットや EC2 のインスタンス) を一意的に参照することができる．</p>
<p>S3 バケットや EC2 インスタンスなどには ARN に加えて，人間が読みやすい名前を定義することも可能である． この場合は，ARN または名前のどちらを用いても同じリソースを参照することが可能である．</p>
<h2 id="cloudformation-と-aws-cdk" tabindex="-1">CloudFormation と AWS CDK <a class="header-anchor" href="#cloudformation-と-aws-cdk" aria-label="Permalink to &quot;CloudFormation と AWS CDK&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="cloudformation-による-infrastructure-as-code-iac" tabindex="-1">CloudFormation による Infrastructure as Code (IaC) <a class="header-anchor" href="#cloudformation-による-infrastructure-as-code-iac" aria-label="Permalink to &quot;CloudFormation による Infrastructure as Code (IaC)&quot;">&ZeroWidthSpace;</a></h3>
<p>前節で述べたように，AWS API を使うことでクラウドの<strong>あらゆる</strong>リソースの作成・管理が可能である． よって，原理上は， API のコマンドを組み合わせていくことで，自分の作りたいクラウドを設計することができる．</p>
<p>しかし，ここで実用上考慮しなければならない点が一つある． AWS API には大きく分けて，<strong>リソースを操作する</strong>コマンドと，<strong>タスクを実行する</strong>コマンドがあることである (<a href="#fig_aws_iac">figure_title</a>)．</p>
<p><img src="./assets/iac.png" alt="AWS APIはリソースを操作するコマンドとタスクを実行するコマンドに大きく分けられる．リソースを記述・管理するのに使われるのが， CloudFormation と CDK である．"></p>
<p><strong>リソースを操作する</strong>とは，EC2 のインスタンスを起動したり，S3 のバケットを作成したり，データベースに新たなテーブルを追加する，などの<strong>静的なリソースを準備する</strong> 操作を指す． &quot;ハコ&quot;を作る操作とよんでも良いだろう． このようなコマンドは，<strong>クラウドのデプロイ時にのみ，一度だけ実行されればよい</strong>．</p>
<p><strong>タスクを実行するコマンド</strong> とは， EC2 のインスタンスにジョブを投入したり， S3 のバケットにデータを読み書きするなどの操作を指す． これは， EC2 や S3 などのリソース (&quot;ハコ&quot;) を前提として，その内部で実行されるべき計算を記述するものである． 前者に比べてこちらは<strong>動的な操作</strong>を担当する，と捉えることもできる．</p>
<p>そのような観点から，<strong>インフラを記述するプログラム</strong>と<strong>タスクを実行するプログラム</strong>はある程度分けて管理されるべきである． クラウドの開発は，クラウドの(静的な)リソースを記述するプログラムを作成するステップと，インフラ上で動く動的な操作を行うプログラムを作成するステップの二段階に分けて考えることができる．</p>
<p>AWS での静的リソースを管理するための仕組みが， <a href="https://aws.amazon.com/cloudformation/" target="_blank" rel="noreferrer">CloudFormation</a> である． CloudFormation とは， CloudFormation の文法に従ったテキストファイルを使って，AWS のインフラを記述する仕組みである． CloudFormation を使って，たとえば，EC2 のインスタンスをどれくらいのスペックで，何個起動するか，インスタンス間はどのようなネットワークで結び，どのようなアクセス権限を付与するか，などのリソースの要件を逐次的に記述することができる． 一度 CloudFormation ファイルができ上がれば，それにしたがったクラウドシステムをコマンド一つで AWS 上に展開することができる． また，CloudFormation ファイルを交換することで，全く同一のクラウド環境を他者が簡単に再現することも可能になる． このように，本来は物理的な実体のあるハードウェアを，プログラムによって記述し，管理するという考え方を，**Infrastructure as Code (IaC)**とよぶ．</p>
<p>CloudFormation を記述するには，基本的に <strong>JSON</strong> (JavaScript Object Notation) とよばれるフォーマットを使う． 次のコードは，JSON で記述された CloudFormation ファイルの一例 (抜粋) である．</p>
<div class="language-json vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">json</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #96D0FF">&quot;Resources&quot;</span><span style="color: #ADBAC7"> : {</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #FF938A; font-style: italic">...</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #8DDB8C">&quot;WebServer&quot;</span><span style="color: #ADBAC7">: {</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #8DDB8C">&quot;Type&quot;</span><span style="color: #ADBAC7"> : </span><span style="color: #96D0FF">&quot;AWS::EC2::Instance&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #8DDB8C">&quot;Properties&quot;</span><span style="color: #ADBAC7">: {</span></span>
<span class="line"><span style="color: #ADBAC7">      </span><span style="color: #8DDB8C">&quot;ImageId&quot;</span><span style="color: #ADBAC7"> : { </span><span style="color: #8DDB8C">&quot;Fn::FindInMap&quot;</span><span style="color: #ADBAC7"> : [ </span><span style="color: #96D0FF">&quot;AWSRegionArch2AMI&quot;</span><span style="color: #ADBAC7">, { </span><span style="color: #8DDB8C">&quot;Ref&quot;</span><span style="color: #ADBAC7"> : </span><span style="color: #96D0FF">&quot;AWS::Region&quot;</span><span style="color: #ADBAC7"> },</span></span>
<span class="line"><span style="color: #ADBAC7">                        { </span><span style="color: #8DDB8C">&quot;Fn::FindInMap&quot;</span><span style="color: #ADBAC7"> : [ </span><span style="color: #96D0FF">&quot;AWSInstanceType2Arch&quot;</span><span style="color: #ADBAC7">, { </span><span style="color: #8DDB8C">&quot;Ref&quot;</span><span style="color: #ADBAC7"> : </span><span style="color: #96D0FF">&quot;InstanceType&quot;</span><span style="color: #ADBAC7"> }, </span><span style="color: #96D0FF">&quot;Arch&quot;</span><span style="color: #ADBAC7"> ] } ] },</span></span>
<span class="line"><span style="color: #ADBAC7">      </span><span style="color: #8DDB8C">&quot;InstanceType&quot;</span><span style="color: #ADBAC7">   : { </span><span style="color: #8DDB8C">&quot;Ref&quot;</span><span style="color: #ADBAC7"> : </span><span style="color: #96D0FF">&quot;InstanceType&quot;</span><span style="color: #ADBAC7"> },</span></span>
<span class="line"><span style="color: #ADBAC7">      </span><span style="color: #8DDB8C">&quot;SecurityGroups&quot;</span><span style="color: #ADBAC7"> : [ {</span><span style="color: #8DDB8C">&quot;Ref&quot;</span><span style="color: #ADBAC7"> : </span><span style="color: #96D0FF">&quot;WebServerSecurityGroup&quot;</span><span style="color: #ADBAC7">} ],</span></span>
<span class="line"><span style="color: #ADBAC7">      </span><span style="color: #8DDB8C">&quot;KeyName&quot;</span><span style="color: #ADBAC7">        : { </span><span style="color: #8DDB8C">&quot;Ref&quot;</span><span style="color: #ADBAC7"> : </span><span style="color: #96D0FF">&quot;KeyName&quot;</span><span style="color: #ADBAC7"> },</span></span>
<span class="line"><span style="color: #ADBAC7">      </span><span style="color: #8DDB8C">&quot;UserData&quot;</span><span style="color: #ADBAC7"> : { </span><span style="color: #8DDB8C">&quot;Fn::Base64&quot;</span><span style="color: #ADBAC7"> : { </span><span style="color: #8DDB8C">&quot;Fn::Join&quot;</span><span style="color: #ADBAC7"> : [</span><span style="color: #96D0FF">&quot;&quot;</span><span style="color: #ADBAC7">, [</span></span>
<span class="line"><span style="color: #ADBAC7">                     </span><span style="color: #96D0FF">&quot;#!/bin/bash -xe</span><span style="color: #F47067">\n</span><span style="color: #96D0FF">&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                     </span><span style="color: #96D0FF">&quot;yum update -y aws-cfn-bootstrap</span><span style="color: #F47067">\n</span><span style="color: #96D0FF">&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">                     </span><span style="color: #96D0FF">&quot;/opt/aws/bin/cfn-init -v &quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                     </span><span style="color: #96D0FF">&quot;         --stack &quot;</span><span style="color: #ADBAC7">, { </span><span style="color: #8DDB8C">&quot;Ref&quot;</span><span style="color: #ADBAC7"> : </span><span style="color: #96D0FF">&quot;AWS::StackName&quot;</span><span style="color: #ADBAC7"> },</span></span>
<span class="line"><span style="color: #ADBAC7">                     </span><span style="color: #96D0FF">&quot;         --resource WebServer &quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                     </span><span style="color: #96D0FF">&quot;         --configsets wordpress_install &quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                     </span><span style="color: #96D0FF">&quot;         --region &quot;</span><span style="color: #ADBAC7">, { </span><span style="color: #8DDB8C">&quot;Ref&quot;</span><span style="color: #ADBAC7"> : </span><span style="color: #96D0FF">&quot;AWS::Region&quot;</span><span style="color: #ADBAC7"> }, </span><span style="color: #96D0FF">&quot;</span><span style="color: #F47067">\n</span><span style="color: #96D0FF">&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">                     </span><span style="color: #96D0FF">&quot;/opt/aws/bin/cfn-signal -e $? &quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                     </span><span style="color: #96D0FF">&quot;         --stack &quot;</span><span style="color: #ADBAC7">, { </span><span style="color: #8DDB8C">&quot;Ref&quot;</span><span style="color: #ADBAC7"> : </span><span style="color: #96D0FF">&quot;AWS::StackName&quot;</span><span style="color: #ADBAC7"> },</span></span>
<span class="line"><span style="color: #ADBAC7">                     </span><span style="color: #96D0FF">&quot;         --resource WebServer &quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                     </span><span style="color: #96D0FF">&quot;         --region &quot;</span><span style="color: #ADBAC7">, { </span><span style="color: #8DDB8C">&quot;Ref&quot;</span><span style="color: #ADBAC7"> : </span><span style="color: #96D0FF">&quot;AWS::Region&quot;</span><span style="color: #ADBAC7"> }, </span><span style="color: #96D0FF">&quot;</span><span style="color: #F47067">\n</span><span style="color: #96D0FF">&quot;</span></span>
<span class="line"><span style="color: #ADBAC7">      ]]}}</span></span>
<span class="line"><span style="color: #ADBAC7">    },</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #FF938A; font-style: italic">...</span></span>
<span class="line"><span style="color: #ADBAC7">  },</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #FF938A; font-style: italic">...</span></span>
<span class="line"><span style="color: #ADBAC7">},</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #032F62">&quot;Resources&quot;</span><span style="color: #24292E"> : {</span></span>
<span class="line"><span style="color: #24292E">  </span><span style="color: #B31D28; font-style: italic">...</span></span>
<span class="line"><span style="color: #24292E">  </span><span style="color: #005CC5">&quot;WebServer&quot;</span><span style="color: #24292E">: {</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">&quot;Type&quot;</span><span style="color: #24292E"> : </span><span style="color: #032F62">&quot;AWS::EC2::Instance&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">&quot;Properties&quot;</span><span style="color: #24292E">: {</span></span>
<span class="line"><span style="color: #24292E">      </span><span style="color: #005CC5">&quot;ImageId&quot;</span><span style="color: #24292E"> : { </span><span style="color: #005CC5">&quot;Fn::FindInMap&quot;</span><span style="color: #24292E"> : [ </span><span style="color: #032F62">&quot;AWSRegionArch2AMI&quot;</span><span style="color: #24292E">, { </span><span style="color: #005CC5">&quot;Ref&quot;</span><span style="color: #24292E"> : </span><span style="color: #032F62">&quot;AWS::Region&quot;</span><span style="color: #24292E"> },</span></span>
<span class="line"><span style="color: #24292E">                        { </span><span style="color: #005CC5">&quot;Fn::FindInMap&quot;</span><span style="color: #24292E"> : [ </span><span style="color: #032F62">&quot;AWSInstanceType2Arch&quot;</span><span style="color: #24292E">, { </span><span style="color: #005CC5">&quot;Ref&quot;</span><span style="color: #24292E"> : </span><span style="color: #032F62">&quot;InstanceType&quot;</span><span style="color: #24292E"> }, </span><span style="color: #032F62">&quot;Arch&quot;</span><span style="color: #24292E"> ] } ] },</span></span>
<span class="line"><span style="color: #24292E">      </span><span style="color: #005CC5">&quot;InstanceType&quot;</span><span style="color: #24292E">   : { </span><span style="color: #005CC5">&quot;Ref&quot;</span><span style="color: #24292E"> : </span><span style="color: #032F62">&quot;InstanceType&quot;</span><span style="color: #24292E"> },</span></span>
<span class="line"><span style="color: #24292E">      </span><span style="color: #005CC5">&quot;SecurityGroups&quot;</span><span style="color: #24292E"> : [ {</span><span style="color: #005CC5">&quot;Ref&quot;</span><span style="color: #24292E"> : </span><span style="color: #032F62">&quot;WebServerSecurityGroup&quot;</span><span style="color: #24292E">} ],</span></span>
<span class="line"><span style="color: #24292E">      </span><span style="color: #005CC5">&quot;KeyName&quot;</span><span style="color: #24292E">        : { </span><span style="color: #005CC5">&quot;Ref&quot;</span><span style="color: #24292E"> : </span><span style="color: #032F62">&quot;KeyName&quot;</span><span style="color: #24292E"> },</span></span>
<span class="line"><span style="color: #24292E">      </span><span style="color: #005CC5">&quot;UserData&quot;</span><span style="color: #24292E"> : { </span><span style="color: #005CC5">&quot;Fn::Base64&quot;</span><span style="color: #24292E"> : { </span><span style="color: #005CC5">&quot;Fn::Join&quot;</span><span style="color: #24292E"> : [</span><span style="color: #032F62">&quot;&quot;</span><span style="color: #24292E">, [</span></span>
<span class="line"><span style="color: #24292E">                     </span><span style="color: #032F62">&quot;#!/bin/bash -xe</span><span style="color: #005CC5">\n</span><span style="color: #032F62">&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                     </span><span style="color: #032F62">&quot;yum update -y aws-cfn-bootstrap</span><span style="color: #005CC5">\n</span><span style="color: #032F62">&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">                     </span><span style="color: #032F62">&quot;/opt/aws/bin/cfn-init -v &quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                     </span><span style="color: #032F62">&quot;         --stack &quot;</span><span style="color: #24292E">, { </span><span style="color: #005CC5">&quot;Ref&quot;</span><span style="color: #24292E"> : </span><span style="color: #032F62">&quot;AWS::StackName&quot;</span><span style="color: #24292E"> },</span></span>
<span class="line"><span style="color: #24292E">                     </span><span style="color: #032F62">&quot;         --resource WebServer &quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                     </span><span style="color: #032F62">&quot;         --configsets wordpress_install &quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                     </span><span style="color: #032F62">&quot;         --region &quot;</span><span style="color: #24292E">, { </span><span style="color: #005CC5">&quot;Ref&quot;</span><span style="color: #24292E"> : </span><span style="color: #032F62">&quot;AWS::Region&quot;</span><span style="color: #24292E"> }, </span><span style="color: #032F62">&quot;</span><span style="color: #005CC5">\n</span><span style="color: #032F62">&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">                     </span><span style="color: #032F62">&quot;/opt/aws/bin/cfn-signal -e $? &quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                     </span><span style="color: #032F62">&quot;         --stack &quot;</span><span style="color: #24292E">, { </span><span style="color: #005CC5">&quot;Ref&quot;</span><span style="color: #24292E"> : </span><span style="color: #032F62">&quot;AWS::StackName&quot;</span><span style="color: #24292E"> },</span></span>
<span class="line"><span style="color: #24292E">                     </span><span style="color: #032F62">&quot;         --resource WebServer &quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                     </span><span style="color: #032F62">&quot;         --region &quot;</span><span style="color: #24292E">, { </span><span style="color: #005CC5">&quot;Ref&quot;</span><span style="color: #24292E"> : </span><span style="color: #032F62">&quot;AWS::Region&quot;</span><span style="color: #24292E"> }, </span><span style="color: #032F62">&quot;</span><span style="color: #005CC5">\n</span><span style="color: #032F62">&quot;</span></span>
<span class="line"><span style="color: #24292E">      ]]}}</span></span>
<span class="line"><span style="color: #24292E">    },</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #B31D28; font-style: italic">...</span></span>
<span class="line"><span style="color: #24292E">  },</span></span>
<span class="line"><span style="color: #24292E">  </span><span style="color: #B31D28; font-style: italic">...</span></span>
<span class="line"><span style="color: #24292E">},</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br></div></div><p>ここでは， &quot;WebServer&quot; という名前のつけられた EC2 インスタンスを定義している．かなり長大で複雑な記述であるが，これによって所望のスペック・OS をもつ EC2 インスタンスを自動的に生成することが可能になる．</p>
<h3 id="aws-cdk" tabindex="-1">AWS CDK <a class="header-anchor" href="#aws-cdk" aria-label="Permalink to &quot;AWS CDK&quot;">&ZeroWidthSpace;</a></h3>
<p>前節で紹介した CloudFormation は，見てわかるとおり大変記述が複雑であり，またそれのどれか一つにでも誤りがあってはいけない． また，基本的に&quot;テキスト&quot;を書いていくことになるので，プログラミング言語で使うような変数やクラスといった便利な概念が使えない　(厳密には， CloudFormation にも変数に相当するような機能は存在する)． また，記述の多くの部分は繰り返しが多く，自動化できる部分も多い．</p>
<p>そのような悩みを解決してくれるのが， <a href="https://aws.amazon.com/cdk/" target="_blank" rel="noreferrer">AWS Cloud Development Kit (CDK)</a> である． <strong>CDK は Python などのプログラミング言語を使って CloudFormation を自動的に生成してくれるツールである．</strong> CDK は 2019 年にリリースされたばかりの比較的新しいツールで，日々改良が進められている (<a href="https://github.com/aws/aws-cdk/releases" target="_blank" rel="noreferrer">GitHub リポジトリ</a> のリリースを見ればその開発のスピードの速さがわかるだろう)． CDK は TypeScript (JavaScript), Python, Java など複数の言語でサポートされている．</p>
<p>CDK を使うことで，CloudFormation に相当するクラウドリソースの記述を，より親しみのあるプログラミング言語を使って行うことができる． かつ，典型的なリソース操作に関してはパラメータの多くの部分を自動で決定してくれるので，記述しなければならない量もかなり削減される．</p>
<p>以下に Python を使った CDK のコードの一例 (抜粋) を示す．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">from</span><span style="color: #ADBAC7"> aws_cdk </span><span style="color: #F47067">import</span><span style="color: #ADBAC7"> (</span></span>
<span class="line"><span style="color: #ADBAC7">    core,</span></span>
<span class="line"><span style="color: #ADBAC7">    aws_ec2 </span><span style="color: #F47067">as</span><span style="color: #ADBAC7"> ec2,</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F47067">class</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50">MyFirstEc2</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">core</span><span style="color: #ADBAC7">.</span><span style="color: #6CB6FF">Stack</span><span style="color: #ADBAC7">):</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">def</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">__init__</span><span style="color: #ADBAC7">(self, scope, name, </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">kwargs):</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #6CB6FF">super</span><span style="color: #ADBAC7">().</span><span style="color: #6CB6FF">__init__</span><span style="color: #ADBAC7">(scope, name, </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">kwargs)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        vpc </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ec2.Vpc(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">...</span><span style="color: #ADBAC7"> </span><span style="color: #768390"># some parameters</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        sg </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ec2.SecurityGroup(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">...</span><span style="color: #ADBAC7"> </span><span style="color: #768390"># some parameters</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        host </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ec2.Instance(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;MyGreatEc2&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">instance_type</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.InstanceType(</span><span style="color: #96D0FF">&quot;t2.micro&quot;</span><span style="color: #ADBAC7">),</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">machine_image</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.MachineImage.latest_amazon_linux(),</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">vpc</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">vpc,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">...</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">from</span><span style="color: #24292E"> aws_cdk </span><span style="color: #D73A49">import</span><span style="color: #24292E"> (</span></span>
<span class="line"><span style="color: #24292E">    core,</span></span>
<span class="line"><span style="color: #24292E">    aws_ec2 </span><span style="color: #D73A49">as</span><span style="color: #24292E"> ec2,</span></span>
<span class="line"><span style="color: #24292E">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D73A49">class</span><span style="color: #24292E"> </span><span style="color: #6F42C1">MyFirstEc2</span><span style="color: #24292E">(</span><span style="color: #6F42C1">core</span><span style="color: #24292E">.</span><span style="color: #6F42C1">Stack</span><span style="color: #24292E">):</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">def</span><span style="color: #24292E"> </span><span style="color: #005CC5">__init__</span><span style="color: #24292E">(self, scope, name, </span><span style="color: #D73A49">**</span><span style="color: #24292E">kwargs):</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #005CC5">super</span><span style="color: #24292E">().</span><span style="color: #005CC5">__init__</span><span style="color: #24292E">(scope, name, </span><span style="color: #D73A49">**</span><span style="color: #24292E">kwargs)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        vpc </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ec2.Vpc(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">...</span><span style="color: #24292E"> </span><span style="color: #6A737D"># some parameters</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        sg </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ec2.SecurityGroup(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">...</span><span style="color: #24292E"> </span><span style="color: #6A737D"># some parameters</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        host </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ec2.Instance(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;MyGreatEc2&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">instance_type</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.InstanceType(</span><span style="color: #032F62">&quot;t2.micro&quot;</span><span style="color: #24292E">),</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">machine_image</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.MachineImage.latest_amazon_linux(),</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">vpc</span><span style="color: #D73A49">=</span><span style="color: #24292E">vpc,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">...</span></span>
<span class="line"><span style="color: #24292E">        )</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br></div></div><p>このコードは，一つ前に示した JSON を使った CloudFormation と実質的に同じことを記述している． とても煩雑だった CloudFormation ファイルに比べて， CDK と Python を使うことで格段に短く，わかりやすく記述できることができるのがわかるだろう．</p>
<p>本書の主題は，<strong>CDK を使って，コードを書きながら AWS の概念や開発方法を学んでいくことである</strong>． 後の章では CDK を使って様々なハンズオンを実施していく． 早速，最初のハンズオンでは， CDK を使って EC2 インスタンスを作成する方法を学んでいこう．</p>
<ul>
<li><a href="https://github.com/aws-samples/aws-cdk-examples" target="_blank" rel="noreferrer">AWS CDK Examples</a>: CDK を使ったプロジェクトの例が多数紹介されている． ここにある例をテンプレートに自分のアプリケーションの開発を進めるとよい．</li>
</ul>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[まとめ ]]></title>
            <link>https://note.toshiki.devdevelopment/aws/closing</link>
            <guid>https://note.toshiki.devdevelopment/aws/closing</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="まとめ" tabindex="-1">まとめ <a class="header-anchor" href="#まとめ" aria-label="Permalink to &quot;まとめ&quot;">&ZeroWidthSpace;</a></h1>
]]></description>
            <content:encoded><![CDATA[<h1 id="まとめ" tabindex="-1">まとめ <a class="header-anchor" href="#まとめ" aria-label="Permalink to &quot;まとめ&quot;">&ZeroWidthSpace;</a></h1>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[クラウド概論 ]]></title>
            <link>https://note.toshiki.devdevelopment/aws/cloud</link>
            <guid>https://note.toshiki.devdevelopment/aws/cloud</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="クラウド概論" tabindex="-1">クラウド概論 <a class="header-anchor" href="#クラウド概論" aria-label="Permalink to &quot;クラウド概論&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="クラウドとは" tabindex="-1">クラウドとは？ <a class="header-anchor" href="#クラウドとは" aria-label="Permalink to &quot;クラウドとは？&quot;">&ZeroWidthSpace;</a></h2>
<p><img src="./assets/cloud_word_art.png" alt="Cloud"></p>
<p>クラウドとはなにか？ クラウドという言葉は，それ自身がとても広い意味をもつので，厳密な定義付けを行うことは難しい．</p>
<p>学術的な意味でのクラウドの定義づけをするとしたら，NIST(米国・国立標準技術研究所) による <a href="https://csrc.nist.gov/publications/detail/sp/800-145/final" target="_blank" rel="noreferrer">The NIST Definition of Cloud Computing</a> が引用されることが多い． ここに記載されたクラウドの定義・モデルを図示したのが <a href="#fig:nist_cloud_definition">figure_title</a> である．</p>
<p><img src="./assets/nist_cloud_definition.png" alt="The NIST Definition of Cloud Computing"></p>
<p>これによると，クラウドとは以下の要件が満たされたハードウェア/ソフトウェアの総体のことをいう．</p>
<ul>
<li>
<p><strong>On-demand self-service</strong> 利用者のリクエストに応じて計算資源が自動的に割り当てられる．</p>
</li>
<li>
<p><strong>Broad network access</strong> 利用者はネットワークを通じてクラウドにアクセスできる．</p>
</li>
<li>
<p><strong>Resource pooling</strong> クラウドプロバイダーは，所有する計算資源を分割することで複数の利用者に計算資源を割り当てる．</p>
</li>
<li>
<p><strong>Rapid elasticity</strong> 利用者のリクエストに応じて，迅速に計算資源の拡大あるいは縮小を行うことができる．</p>
</li>
<li>
<p><strong>Measured service</strong> 計算資源の利用量を計測・監視することができる．</p>
</li>
</ul>
<p>…と，いわれても抽象的でよくわからないかもしれない．もう少し具体的な話をする．</p>
<p>個人が所有する計算機で， CPU をアップグレードしようと思ったら，物理的に筐体を開け，CPU ソケットを露出させ，新しい CPU に交換する必要があるだろう． あるいは，ストレージがいっぱいになってしまったら，古いディスクを抜き取り，新しいディスクを挿入する必要がある． 計算機の場所を移動させたときには，新しい部屋の LAN ケーブルを差し込まないとネットワークには接続できない．</p>
<p>クラウドでは，これらの操作が<strong>プログラムからのコマンドによって実行できる</strong>． CPU が 1000 個欲しいと思ったならば，そのようにクラウドプロバイダーにリクエストを送れば良い． すると，数分もしないうちに 1000 CPU の計算資源が割り当てられる． ストレージを 1TB から 10TB に拡張しようと思ったならば，そのようにコマンドを送ればよい (これは，Google Drive や Dropbox などのサービスなどで馴染みのある人も多いだろう)． 計算資源を使い終わったら，そのことをプロバイダーに伝えれば，割り当て分はすぐさま削除される． クラウドプロバイダーは，使った計算資源の量を正確にモニタリングしており，その量をもとに利用料金の計算が行われる．</p>
<p>このように，クラウドの本質は物理的なハードウェアの仮想化・抽象化であり，利用者はコマンドを通じて，<strong>まるでソフトウェアの一部かのように，物理的なハードウェアの管理・運用を行うことができる</strong>． もちろん，背後では，データセンターに置かれた膨大な数の計算機が大量の電力を消費しながら稼働している． クラウドプロバイダーはデータセンターの計算資源を上手にやりくりし，ソフトウェアとしてのインターフェースをユーザーに提供することで，このような仮想化・抽象化を達成しているわけである． クラウドプロバイダーの視点からすると，大勢のユーザーに計算機を貸し出し，データセンターの稼働率を常時 100%に近づけることで，利益率の最大化を図っているのである．</p>
<p>著者の言葉で，クラウドの重要な特性を定義するならば，以下のようになる．</p>
<blockquote>
<p>クラウドとは計算機ハードウェアの抽象化である．つまり，物理的なハードウェアをソフトウェアの一部かのように自在に操作・拡大・接続することを可能にする技術である．</p>
</blockquote>
<p>先述の The NIST Definition of Cloud Computing に戻ると，クラウドプロバイダーによるクラウドサービスの形態としては，次の三つが定義されている (<a href="#fig:nist_cloud_definition">figure_title</a>)．</p>
<ul>
<li>
<p>Software as a Service (SaaS): クラウド上で実行されるアプリケーションをサービスとして利用者に提供する形態． 例として， Google Drive や Slack などが挙げられる． 利用者は，背後にあるクラウドのインフラ (ネットワークやサーバーなど) には直接触れず，アプリケーションとして提供されているクラウドサービスを享受する．</p>
</li>
<li>
<p>Platform as a Service (PaaS): 顧客の作成したアプリケーション (多くの場合データベースと API リクエスト処理を行うサーバーのコードから構成される) をデプロイする環境をサービスとして利用者に提供する形態． PaaS では利用者はクラウドのインフラに直接触れることはなく，計算負荷が増減した際のサーバーのスケーリングはクラウドプロバイダーによってなされる． 例としては， Google App Engine や Heroku などがある．</p>
</li>
<li>
<p>Infrastructure as a Service (IaaS): クラウド上の計算インフラストラクチャーを従量課金制で利用者に提供する形態． 利用者は必要なネットワーク・サーバー・ストレージをプロバイダーから借り受け，そこに自身のアプリケーションを展開し運用する． IaaS の例としては AWS EC2 などが挙げられる．</p>
</li>
</ul>
<p>本書が扱うのは，主に IaaS におけるクラウド開発である． すなわち，開発者がクラウドのインフラを直接操作し，所望のネットワーク・サーバー・ストレージなどを一から構成し，そこにアプリケーションを展開するというクラウド開発である． この意味において，クラウドの開発とは<strong>クラウドインフラストラクチャーを定義・展開するプログラムを構築するステップ</strong>と<strong>インフラ上で実際に走るアプリケーションを作成するステップ</strong>の二つに分けることができる． この二つは，プログラマーの技術としてはある程度分業を行うことが可能であるが，最も効率化・最適化されたクラウドシステムを構築するためには両方の理解が必須である． 本書では，前者 (クラウドインフラの記述) に重きを置きつつ，アプリケーションレイヤーの話題も取り扱う． PaaS とは，開発者はアプリケーションレイヤーの開発に注力し，クラウドインフラの部分はクラウドプロバイダーに依存するという概念である． PaaS は，クラウドインフラの開発が不要になることで開発の時間が短縮されるが，細かなインフラの挙動はコントロールできないという限界がある． 本書では PaaS についてはとくに取り扱わない．</p>
<p>SaaS は本書の文脈では開発による&quot;成果物&quot;と捉えられるだろう． すなわち， IaaS を構成するプログラムを作成し展開することによって，一般の人が利用できるようなウェブ上の計算サービスやデータベースを提供することが開発の最終ゴールである． 本書のハンズオンではその実例として，シンプルな SNS の作成 ( (#sec_bashoutter)) などの演習を提供する．</p>
<p>なお，最近では Function as a Service (FaaS) やサーバーレスコンピューティングなども新たなクラウドのカテゴリとして認知されている． これらの概念については (#sec_intro_serverless) などの章で詳しく触れていく． 本書を読み進める中で明らかになるように，クラウドの技術は日進月歩である． 本書では実用的・教育的な観点から，従来的なクラウドの設計概念に触れたあと，サーバーレスなどの最新の技術も網羅するので，楽しみにしながら読み進めていただきたい．</p>
<p>最後に，The NIST Definition of Cloud Computing によると，クラウドの運用形態について次のような定義がなされている (<a href="#fig:nist_cloud_definition">figure_title</a>)． 特定の組織・団体・企業の内部のみで使用されるクラウドを，<strong>プライベートクラウド (private cloud)</strong> とよぶ． 例えば，大学や研究機関では，その機関の構成員向けの大規模計算機サーバーが運用されていることが多い． プライベートクラウドは，組織の構成員ならば無料もしくは極めて割安のコストで計算を実行できる． しかし，使用できる計算資源の上限は限られる場合が多く，拡張時の柔軟性に欠ける場合もある．</p>
<p>一方，商用のサービスとして一般の顧客に向けたクラウドのことを，<strong>パブリッククラウド (public cloud)</strong> とよぶ． 有名なパブリッククラウドプラットフォームの例を挙げると， Google 社が提供する <a href="https://cloud.google.com/" target="_blank" rel="noreferrer">Google Cloud Platform (GCP)</a>， Microsoft 社が提供する <a href="https://azure.microsoft.com" target="_blank" rel="noreferrer">Azure</a>， Amazon 社が提供する <a href="https://aws.amazon.com" target="_blank" rel="noreferrer">Amazon Web Services (AWS)</a> などがある． パブリッククラウドを利用する場合は，プロバイダーの設定した利用料金を支払うことになる． その分，巨大なデータセンターを運用する企業の計算資源にアクセスすることができるので，計算のキャパシティは無尽蔵にあるといって過言でない．</p>
<p>第三のクラウドの運用形態として，コミュニティクラウド (community cloud) が挙げられる． これは，例えば政府の省庁・機関など目的・役割を共有する団体・組織が共有して運用するクラウドを指す． 最後に，ハイブリッドクラウド (hybrid cloud) という形態もあり，これはプライベート・パブリック・コミュニティクラウドの二つ以上の組み合わせによって構成されるクラウドのことである． データ保護の観点から，いくつかの機密データやプライバシーに関わる情報はプライベートクラウドに保持し，残りのシステムをパブリッククラウドに依存する，などの形態が想定される．</p>
<p>本書で説明するのは，基本的にパブリッククラウドを使ったクラウド開発である． 特に，Amazon Web Services (AWS) を使用して，具体的な技術と概念を学んでいく． 一方で，サーバーのスケーリングや仮想計算環境などのテクニックはすべてのクラウドに共通な概念であるので，クラウドのプラットフォームが変わろうと一般に通用する知識も同時に身につくはずだ．</p>
<h2 id="なぜクラウドを使うのか" tabindex="-1">なぜクラウドを使うのか？ <a class="header-anchor" href="#なぜクラウドを使うのか" aria-label="Permalink to &quot;なぜクラウドを使うのか？&quot;">&ZeroWidthSpace;</a></h2>
<p>上述のように，クラウドとはプログラムを通じて自由に計算資源を操作することのできる計算環境である． ここでは，リアルなローカル計算環境と比べて，なぜクラウドを使うと良いことがあるのかについて述べたい．</p>
<ol>
<li>
<p><strong>自由にサーバーのサイズをスケールできる</strong></p>
<p>なにか新しいプロジェクトを始めるとき，あらかじめ必要なサーバーのスペックを知るのは難しい． いきなり大きなサーバーを買うのはリスクが高い． 一方で，小さすぎるサーバーでは，後のアップグレードが面倒である． クラウドを利用すれば，プロジェクトを進めながら，必要な分だけの計算資源を確保することができる． 2. <strong>自分でサーバーをメンテナンスする必要がない</strong></p>
<p>悲しいことに，コンピュータとは古くなるものである．最近の技術の進歩の速度からすると，5 年も経てば，もはや当時の最新コンピュータも化石と同じである． 5 年ごとにサーバーを入れ替えるのは相当な手間である． またサーバーの停電や故障など不意の障害への対応も必要である． クラウドでは，そのようなインフラの整備やメンテナンスはプロバイダーが自動でやってくれるので，ユーザーが心配する必要がない． 3. <strong>初期コスト 0</strong></p>
<p>自前の計算環境とクラウドの，経済的なコストのイメージを示したのが <a href="#cloud_economic_curve">figure_title</a> である． クラウドを利用する場合の初期コストは基本的に 0 である． その後，使った利用量に応じてコストが増大していく． 一方，自前の計算環境では，大きな初期コストが生じる． その分，初期投資後のコストの増加は，電気利用料やサーバー維持費などに留まるため，クラウドを利用した場合よりも傾きは小さくなる． 自前の計算機では，ある一定期間後，サーバーのアップグレードなどによる支出が生じることがある． 一方，クラウドを利用する場合は，そのような非連続なコストの増大は基本的に生じない． クラウドのコストのカーブが，自前計算環境のコストのカーブの下にある範囲においては，クラウドを使うことは経済的なコスト削減につながる．</p>
<p><img src="./assets/cloud_cost.png" alt="クラウドと自前計算機環境の経済的コストの比較"></p>
</li>
</ol>
<p>とくに，**1.**の点は研究の場面では重要であると筆者は感じる． 研究をやっていて，四六時中計算を走らせ続けるという場合は少ない． むしろ，新しいアルゴリズムが完成したとき・新しいデータが届いたとき，集中的・突発的に計算タスクが増大することが多いだろう． そういったときに，フレキシブルに計算力を増強させることができるのは，クラウドを使う大きなメリットである．</p>
<p>ここまでクラウドを使うメリットを述べたが，逆に，デメリットというのも当然存在する．</p>
<ol>
<li>
<p><strong>クラウドは賢く使わないといけない</strong></p>
<p><a href="#cloud_economic_curve">figure_title</a> で示したコストのカーブにあるとおり，使い方によっては自前の計算環境のほうがコスト的に有利な場面は存在しうる． クラウドを利用する際は，使い終わった計算資源はすぐに削除するなど，利用者が賢く管理を行う必要があり，これを怠ると思いもしない額の請求が届く可能性がある． 2. <strong>セキュリティ</strong></p>
<p>クラウドは，インターネットを通じて世界のどこからでもアクセスできる状態にあり，セキュリティ管理を怠ると簡単にハッキングの対象となりうる． ハッキングを受けると，情報流出だけでなく，経済的な損失を被る可能性がある． 3. <strong>ラーニングカーブ</strong></p>
<p>上記のように，コスト・セキュリティなど，クラウドを利用する際に留意しなければならない点は多い． 賢くクラウドを使うには，十分なクラウドの理解が必要であり，そのラーニングカーブを乗り越える必要がある．</p>
</li>
</ol>
<p>Mac/Linux などでコマンドを入力するときに使用する，あの黒い画面のことを Terminal とよんだりする． この言葉の語源をご存知だろうか？</p>
<p><img src="./assets/terminal.png" alt="Terminal"></p>
<p>この言葉の語源は，コンピュータが誕生して間もない頃の時代に遡る． その頃のコンピュータというと，何千何万のという数の真空管が接続された，会議室一個分くらいのサイズのマシンであった． そのような高価でメンテが大変な機材であるから，当然みんなでシェアして使うことが前提となる． ユーザーがコンピュータにアクセスするため，マシンからは何本かのケーブルが伸び，それぞれにキーボードとスクリーンが接続されていた… これを <strong>Terminal</strong> とよんでいたのである． 人々は，代わる代わる Terminal の前に座って，計算機との対話を行っていた．</p>
<p>時代は流れ，Windows や Mac などのいわゆるパーソナルコンピュータの出現により，コンピュータはみんなで共有するものではなく，個人が所有するものになった．</p>
<p>最近のクラウドの台頭は，みんなで大きなコンピュータをシェアするという，最初のコンピュータの使われ方に原点回帰していると捉えることもできる． 一方で，スマートフォンやウェアラブルなどのエッジデバイスの普及も盛んであり，個人が複数の&quot;小さな&quot;コンピュータを所有する，という流れも同時に進行しているのである．</p>
]]></description>
            <content:encoded><![CDATA[<h1 id="クラウド概論" tabindex="-1">クラウド概論 <a class="header-anchor" href="#クラウド概論" aria-label="Permalink to &quot;クラウド概論&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="クラウドとは" tabindex="-1">クラウドとは？ <a class="header-anchor" href="#クラウドとは" aria-label="Permalink to &quot;クラウドとは？&quot;">&ZeroWidthSpace;</a></h2>
<p><img src="./assets/cloud_word_art.png" alt="Cloud"></p>
<p>クラウドとはなにか？ クラウドという言葉は，それ自身がとても広い意味をもつので，厳密な定義付けを行うことは難しい．</p>
<p>学術的な意味でのクラウドの定義づけをするとしたら，NIST(米国・国立標準技術研究所) による <a href="https://csrc.nist.gov/publications/detail/sp/800-145/final" target="_blank" rel="noreferrer">The NIST Definition of Cloud Computing</a> が引用されることが多い． ここに記載されたクラウドの定義・モデルを図示したのが <a href="#fig:nist_cloud_definition">figure_title</a> である．</p>
<p><img src="./assets/nist_cloud_definition.png" alt="The NIST Definition of Cloud Computing"></p>
<p>これによると，クラウドとは以下の要件が満たされたハードウェア/ソフトウェアの総体のことをいう．</p>
<ul>
<li>
<p><strong>On-demand self-service</strong> 利用者のリクエストに応じて計算資源が自動的に割り当てられる．</p>
</li>
<li>
<p><strong>Broad network access</strong> 利用者はネットワークを通じてクラウドにアクセスできる．</p>
</li>
<li>
<p><strong>Resource pooling</strong> クラウドプロバイダーは，所有する計算資源を分割することで複数の利用者に計算資源を割り当てる．</p>
</li>
<li>
<p><strong>Rapid elasticity</strong> 利用者のリクエストに応じて，迅速に計算資源の拡大あるいは縮小を行うことができる．</p>
</li>
<li>
<p><strong>Measured service</strong> 計算資源の利用量を計測・監視することができる．</p>
</li>
</ul>
<p>…と，いわれても抽象的でよくわからないかもしれない．もう少し具体的な話をする．</p>
<p>個人が所有する計算機で， CPU をアップグレードしようと思ったら，物理的に筐体を開け，CPU ソケットを露出させ，新しい CPU に交換する必要があるだろう． あるいは，ストレージがいっぱいになってしまったら，古いディスクを抜き取り，新しいディスクを挿入する必要がある． 計算機の場所を移動させたときには，新しい部屋の LAN ケーブルを差し込まないとネットワークには接続できない．</p>
<p>クラウドでは，これらの操作が<strong>プログラムからのコマンドによって実行できる</strong>． CPU が 1000 個欲しいと思ったならば，そのようにクラウドプロバイダーにリクエストを送れば良い． すると，数分もしないうちに 1000 CPU の計算資源が割り当てられる． ストレージを 1TB から 10TB に拡張しようと思ったならば，そのようにコマンドを送ればよい (これは，Google Drive や Dropbox などのサービスなどで馴染みのある人も多いだろう)． 計算資源を使い終わったら，そのことをプロバイダーに伝えれば，割り当て分はすぐさま削除される． クラウドプロバイダーは，使った計算資源の量を正確にモニタリングしており，その量をもとに利用料金の計算が行われる．</p>
<p>このように，クラウドの本質は物理的なハードウェアの仮想化・抽象化であり，利用者はコマンドを通じて，<strong>まるでソフトウェアの一部かのように，物理的なハードウェアの管理・運用を行うことができる</strong>． もちろん，背後では，データセンターに置かれた膨大な数の計算機が大量の電力を消費しながら稼働している． クラウドプロバイダーはデータセンターの計算資源を上手にやりくりし，ソフトウェアとしてのインターフェースをユーザーに提供することで，このような仮想化・抽象化を達成しているわけである． クラウドプロバイダーの視点からすると，大勢のユーザーに計算機を貸し出し，データセンターの稼働率を常時 100%に近づけることで，利益率の最大化を図っているのである．</p>
<p>著者の言葉で，クラウドの重要な特性を定義するならば，以下のようになる．</p>
<blockquote>
<p>クラウドとは計算機ハードウェアの抽象化である．つまり，物理的なハードウェアをソフトウェアの一部かのように自在に操作・拡大・接続することを可能にする技術である．</p>
</blockquote>
<p>先述の The NIST Definition of Cloud Computing に戻ると，クラウドプロバイダーによるクラウドサービスの形態としては，次の三つが定義されている (<a href="#fig:nist_cloud_definition">figure_title</a>)．</p>
<ul>
<li>
<p>Software as a Service (SaaS): クラウド上で実行されるアプリケーションをサービスとして利用者に提供する形態． 例として， Google Drive や Slack などが挙げられる． 利用者は，背後にあるクラウドのインフラ (ネットワークやサーバーなど) には直接触れず，アプリケーションとして提供されているクラウドサービスを享受する．</p>
</li>
<li>
<p>Platform as a Service (PaaS): 顧客の作成したアプリケーション (多くの場合データベースと API リクエスト処理を行うサーバーのコードから構成される) をデプロイする環境をサービスとして利用者に提供する形態． PaaS では利用者はクラウドのインフラに直接触れることはなく，計算負荷が増減した際のサーバーのスケーリングはクラウドプロバイダーによってなされる． 例としては， Google App Engine や Heroku などがある．</p>
</li>
<li>
<p>Infrastructure as a Service (IaaS): クラウド上の計算インフラストラクチャーを従量課金制で利用者に提供する形態． 利用者は必要なネットワーク・サーバー・ストレージをプロバイダーから借り受け，そこに自身のアプリケーションを展開し運用する． IaaS の例としては AWS EC2 などが挙げられる．</p>
</li>
</ul>
<p>本書が扱うのは，主に IaaS におけるクラウド開発である． すなわち，開発者がクラウドのインフラを直接操作し，所望のネットワーク・サーバー・ストレージなどを一から構成し，そこにアプリケーションを展開するというクラウド開発である． この意味において，クラウドの開発とは<strong>クラウドインフラストラクチャーを定義・展開するプログラムを構築するステップ</strong>と<strong>インフラ上で実際に走るアプリケーションを作成するステップ</strong>の二つに分けることができる． この二つは，プログラマーの技術としてはある程度分業を行うことが可能であるが，最も効率化・最適化されたクラウドシステムを構築するためには両方の理解が必須である． 本書では，前者 (クラウドインフラの記述) に重きを置きつつ，アプリケーションレイヤーの話題も取り扱う． PaaS とは，開発者はアプリケーションレイヤーの開発に注力し，クラウドインフラの部分はクラウドプロバイダーに依存するという概念である． PaaS は，クラウドインフラの開発が不要になることで開発の時間が短縮されるが，細かなインフラの挙動はコントロールできないという限界がある． 本書では PaaS についてはとくに取り扱わない．</p>
<p>SaaS は本書の文脈では開発による&quot;成果物&quot;と捉えられるだろう． すなわち， IaaS を構成するプログラムを作成し展開することによって，一般の人が利用できるようなウェブ上の計算サービスやデータベースを提供することが開発の最終ゴールである． 本書のハンズオンではその実例として，シンプルな SNS の作成 ( (#sec_bashoutter)) などの演習を提供する．</p>
<p>なお，最近では Function as a Service (FaaS) やサーバーレスコンピューティングなども新たなクラウドのカテゴリとして認知されている． これらの概念については (#sec_intro_serverless) などの章で詳しく触れていく． 本書を読み進める中で明らかになるように，クラウドの技術は日進月歩である． 本書では実用的・教育的な観点から，従来的なクラウドの設計概念に触れたあと，サーバーレスなどの最新の技術も網羅するので，楽しみにしながら読み進めていただきたい．</p>
<p>最後に，The NIST Definition of Cloud Computing によると，クラウドの運用形態について次のような定義がなされている (<a href="#fig:nist_cloud_definition">figure_title</a>)． 特定の組織・団体・企業の内部のみで使用されるクラウドを，<strong>プライベートクラウド (private cloud)</strong> とよぶ． 例えば，大学や研究機関では，その機関の構成員向けの大規模計算機サーバーが運用されていることが多い． プライベートクラウドは，組織の構成員ならば無料もしくは極めて割安のコストで計算を実行できる． しかし，使用できる計算資源の上限は限られる場合が多く，拡張時の柔軟性に欠ける場合もある．</p>
<p>一方，商用のサービスとして一般の顧客に向けたクラウドのことを，<strong>パブリッククラウド (public cloud)</strong> とよぶ． 有名なパブリッククラウドプラットフォームの例を挙げると， Google 社が提供する <a href="https://cloud.google.com/" target="_blank" rel="noreferrer">Google Cloud Platform (GCP)</a>， Microsoft 社が提供する <a href="https://azure.microsoft.com" target="_blank" rel="noreferrer">Azure</a>， Amazon 社が提供する <a href="https://aws.amazon.com" target="_blank" rel="noreferrer">Amazon Web Services (AWS)</a> などがある． パブリッククラウドを利用する場合は，プロバイダーの設定した利用料金を支払うことになる． その分，巨大なデータセンターを運用する企業の計算資源にアクセスすることができるので，計算のキャパシティは無尽蔵にあるといって過言でない．</p>
<p>第三のクラウドの運用形態として，コミュニティクラウド (community cloud) が挙げられる． これは，例えば政府の省庁・機関など目的・役割を共有する団体・組織が共有して運用するクラウドを指す． 最後に，ハイブリッドクラウド (hybrid cloud) という形態もあり，これはプライベート・パブリック・コミュニティクラウドの二つ以上の組み合わせによって構成されるクラウドのことである． データ保護の観点から，いくつかの機密データやプライバシーに関わる情報はプライベートクラウドに保持し，残りのシステムをパブリッククラウドに依存する，などの形態が想定される．</p>
<p>本書で説明するのは，基本的にパブリッククラウドを使ったクラウド開発である． 特に，Amazon Web Services (AWS) を使用して，具体的な技術と概念を学んでいく． 一方で，サーバーのスケーリングや仮想計算環境などのテクニックはすべてのクラウドに共通な概念であるので，クラウドのプラットフォームが変わろうと一般に通用する知識も同時に身につくはずだ．</p>
<h2 id="なぜクラウドを使うのか" tabindex="-1">なぜクラウドを使うのか？ <a class="header-anchor" href="#なぜクラウドを使うのか" aria-label="Permalink to &quot;なぜクラウドを使うのか？&quot;">&ZeroWidthSpace;</a></h2>
<p>上述のように，クラウドとはプログラムを通じて自由に計算資源を操作することのできる計算環境である． ここでは，リアルなローカル計算環境と比べて，なぜクラウドを使うと良いことがあるのかについて述べたい．</p>
<ol>
<li>
<p><strong>自由にサーバーのサイズをスケールできる</strong></p>
<p>なにか新しいプロジェクトを始めるとき，あらかじめ必要なサーバーのスペックを知るのは難しい． いきなり大きなサーバーを買うのはリスクが高い． 一方で，小さすぎるサーバーでは，後のアップグレードが面倒である． クラウドを利用すれば，プロジェクトを進めながら，必要な分だけの計算資源を確保することができる． 2. <strong>自分でサーバーをメンテナンスする必要がない</strong></p>
<p>悲しいことに，コンピュータとは古くなるものである．最近の技術の進歩の速度からすると，5 年も経てば，もはや当時の最新コンピュータも化石と同じである． 5 年ごとにサーバーを入れ替えるのは相当な手間である． またサーバーの停電や故障など不意の障害への対応も必要である． クラウドでは，そのようなインフラの整備やメンテナンスはプロバイダーが自動でやってくれるので，ユーザーが心配する必要がない． 3. <strong>初期コスト 0</strong></p>
<p>自前の計算環境とクラウドの，経済的なコストのイメージを示したのが <a href="#cloud_economic_curve">figure_title</a> である． クラウドを利用する場合の初期コストは基本的に 0 である． その後，使った利用量に応じてコストが増大していく． 一方，自前の計算環境では，大きな初期コストが生じる． その分，初期投資後のコストの増加は，電気利用料やサーバー維持費などに留まるため，クラウドを利用した場合よりも傾きは小さくなる． 自前の計算機では，ある一定期間後，サーバーのアップグレードなどによる支出が生じることがある． 一方，クラウドを利用する場合は，そのような非連続なコストの増大は基本的に生じない． クラウドのコストのカーブが，自前計算環境のコストのカーブの下にある範囲においては，クラウドを使うことは経済的なコスト削減につながる．</p>
<p><img src="./assets/cloud_cost.png" alt="クラウドと自前計算機環境の経済的コストの比較"></p>
</li>
</ol>
<p>とくに，**1.**の点は研究の場面では重要であると筆者は感じる． 研究をやっていて，四六時中計算を走らせ続けるという場合は少ない． むしろ，新しいアルゴリズムが完成したとき・新しいデータが届いたとき，集中的・突発的に計算タスクが増大することが多いだろう． そういったときに，フレキシブルに計算力を増強させることができるのは，クラウドを使う大きなメリットである．</p>
<p>ここまでクラウドを使うメリットを述べたが，逆に，デメリットというのも当然存在する．</p>
<ol>
<li>
<p><strong>クラウドは賢く使わないといけない</strong></p>
<p><a href="#cloud_economic_curve">figure_title</a> で示したコストのカーブにあるとおり，使い方によっては自前の計算環境のほうがコスト的に有利な場面は存在しうる． クラウドを利用する際は，使い終わった計算資源はすぐに削除するなど，利用者が賢く管理を行う必要があり，これを怠ると思いもしない額の請求が届く可能性がある． 2. <strong>セキュリティ</strong></p>
<p>クラウドは，インターネットを通じて世界のどこからでもアクセスできる状態にあり，セキュリティ管理を怠ると簡単にハッキングの対象となりうる． ハッキングを受けると，情報流出だけでなく，経済的な損失を被る可能性がある． 3. <strong>ラーニングカーブ</strong></p>
<p>上記のように，コスト・セキュリティなど，クラウドを利用する際に留意しなければならない点は多い． 賢くクラウドを使うには，十分なクラウドの理解が必要であり，そのラーニングカーブを乗り越える必要がある．</p>
</li>
</ol>
<p>Mac/Linux などでコマンドを入力するときに使用する，あの黒い画面のことを Terminal とよんだりする． この言葉の語源をご存知だろうか？</p>
<p><img src="./assets/terminal.png" alt="Terminal"></p>
<p>この言葉の語源は，コンピュータが誕生して間もない頃の時代に遡る． その頃のコンピュータというと，何千何万のという数の真空管が接続された，会議室一個分くらいのサイズのマシンであった． そのような高価でメンテが大変な機材であるから，当然みんなでシェアして使うことが前提となる． ユーザーがコンピュータにアクセスするため，マシンからは何本かのケーブルが伸び，それぞれにキーボードとスクリーンが接続されていた… これを <strong>Terminal</strong> とよんでいたのである． 人々は，代わる代わる Terminal の前に座って，計算機との対話を行っていた．</p>
<p>時代は流れ，Windows や Mac などのいわゆるパーソナルコンピュータの出現により，コンピュータはみんなで共有するものではなく，個人が所有するものになった．</p>
<p>最近のクラウドの台頭は，みんなで大きなコンピュータをシェアするという，最初のコンピュータの使われ方に原点回帰していると捉えることもできる． 一方で，スマートフォンやウェアラブルなどのエッジデバイスの普及も盛んであり，個人が複数の&quot;小さな&quot;コンピュータを所有する，という流れも同時に進行しているのである．</p>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Docker 入門 ]]></title>
            <link>https://note.toshiki.devdevelopment/aws/docker-system</link>
            <guid>https://note.toshiki.devdevelopment/aws/docker-system</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="docker-入門" tabindex="-1">Docker 入門 <a class="header-anchor" href="#docker-入門" aria-label="Permalink to &quot;Docker 入門&quot;">&ZeroWidthSpace;</a></h1>
<p>ここまでの章で扱ってきたハンズオンでは，<strong>単一のサーバー</strong>を立ち上げ，それに SSH でログインをして，コマンドを叩くことで計算を行ってきた． いわば，<em>パーソナルコンピュータの延長</em>のような形でクラウドを使ってきたわけである． このような，インターネットのどこからでもアクセスできるパーソナルコンピュータとしてのクラウドという使い方も，もちろん便利であるし，いろいろな応用の可能性がある． しかし，これだけではクラウドの本当の価値は十分に発揮されていないと言うべきだろう． (#chap_cloud_basics) で述べたように，現代的なクラウドの一番の強みは自由に計算機の規模を拡大できることにある． すなわち，<strong>多数のサーバーを同時に起動し，複数のジョブを分散並列的に実行させることで大量のデータを処理してこそ，クラウドの本領が発揮される</strong>のである．</p>
<p>本章からはじまる 3 章分 (<a href="#sec_docker_introduction">Docker 入門</a>, (#sec_fargate_qabot), (#sec_aws_batch)) を使って，クラウドを利用することでどのように大規模な計算システムを構築しビッグデータの解析に立ち向かうのか，その片鱗をお見せしたい． とくに，前章で扱った深層学習をどのようにビッグデータに適用していくかという点に焦点を絞って議論していきたい． そのための前準備として，本章では <a href="https://www.docker.com/" target="_blank" rel="noreferrer">Docker</a> とよばれる計算機環境の仮想化ソフトウェアを紹介する (<a href="#fig:docker_logo">figure_title</a>)． 現代のクラウドは Docker なしには成り立たないといっても過言ではないだろう． クラウドに限らず，ローカルで行う計算処理にも Docker は大変便利である． AWS からは少し話が離れるが，しっかりと理解して前に進んでもらいたい．</p>
<h2 id="機械学習の大規模化" tabindex="-1">機械学習の大規模化 <a class="header-anchor" href="#機械学習の大規模化" aria-label="Permalink to &quot;機械学習の大規模化&quot;">&ZeroWidthSpace;</a></h2>
<p>先ほどから&quot;計算システムの大規模化&quot;と繰り返し唱えているが，それは具体的にはどのようなものを指しているのか？ ここでは大規模データを処理するための計算機システムを，機械学習を例にとって見てみよう．</p>
<p>(#sec_scientific_computing) で紹介した <a href="https://github.com/openai/gpt-3" target="_blank" rel="noreferrer">GPT-3</a> のような，超巨大な数のパラメータを有する深層学習モデルを学習させたいとしよう． そのような計算を行いたい場合，一つのサーバーでは計算力が到底足りない． したがって，典型的には <a href="#big_dnn_training">figure_title</a> に示すような計算システムの設計がなされる． すなわち，大量の教師データを小さなチャンクとして複数のマシンに分散し，並列的にニューラルネットのパラメータを最適化していくという構造である．</p>
<p><img src="./assets/big_dnn_training.png" alt="複数の計算機を使った大規模な深層学習モデルの訓練"></p>
<p>あるいは，学習済みのモデルを大量のデータに適用し，解析を行いたいとしよう． たとえば， SNS のプラットフォームで大量の画像が与えられて，それぞれの写真に何が写っているのかをラベルづけする，などのアプリケーションを想定できる． そのような場合は， <a href="#big_dnn_inference">figure_title</a> のようなアーキテクチャが考えられるだろう． すなわち，大量のデータを複数のマシンで分割し，それぞれのマシンで推論の計算を行うというような構造である．</p>
<p><img src="./assets/big_dnn_inference.png" alt="複数の計算機による深層学習モデルを使った推論計算"></p>
<p>このような複数の計算機を同時に走らせるようなアプリケーションをクラウド上で実現するには，どのようにすればよいのだろうか？</p>
<p>重要なポイントとして， <a href="#big_dnn_training">figure_title</a> や <a href="#big_dnn_inference">figure_title</a> で起動している複数のマシンは，<strong>基本的に全く同一の OS・計算環境を有している</strong>点である． ここで，個人のコンピュータで行うようなインストールの操作を，各マシンで行うこともできるが，それは大変な手間であるし，メンテナンスも面倒だろう． すなわち，大規模な計算システムを構築するには，<strong>簡単に計算環境を複製できるような仕組み</strong>が必要であるということがわかる．</p>
<p>そのような目的を実現するために使われるのが， <a href="https://www.docker.com/" target="_blank" rel="noreferrer">Docker</a> とよばれるソフトウェアである．</p>
<h2 id="docker-とは" tabindex="-1">Docker とは <a class="header-anchor" href="#docker-とは" aria-label="Permalink to &quot;Docker とは&quot;">&ZeroWidthSpace;</a></h2>
<p><img src="./assets/docker_log.png" alt="Docker のアイコン"></p>
<p>Docker とは， <strong>コンテナ (Container)</strong> とよばれる仮想環境下で，ホスト OS とは独立した別の計算環境を走らせるためのソフトウェアである． Docker を使うことで， OS を含めたすべてのプログラムをコンパクトにパッケージングすることが可能になる (パッケージされた一つの計算環境のことを **イメージ (Image)**とよぶ)． Docker を使うことで，クラウドのサーバー上に瞬時に計算環境を複製することが可能になり， <a href="#big_dnn_inference">figure_title</a> で見たような複数の計算機を同時に走らせるためのシステムが実現できる．</p>
<p>Docker は 2013 年に Solomon Hykes らを中心に開発され，それ以降爆発的に普及し，クラウドコンピューティングだけでなく，機械学習・科学計算の文脈などでも欠かすことのできないソフトウェアとなった． Docker はエンタープライズ向けの製品を除き無料で使用することができ，コアの部分は <a href="https://github.com/moby/moby" target="_blank" rel="noreferrer">オープンソースプロジェクト</a> として公開されている． Docker は Linux, Windows, Mac いずれの OS でも提供されている． 概念としては， Docker は仮想マシン (Virtual machine; VM) にとても近い． ここでは， VM との対比をしながら，Docker とはなにかを簡単に説明しよう．</p>
<p>仮想マシン (VM) とは，ホストとなるマシンの上に，仮想化された OS を走らせる技術である (<a href="#docker_vs_vm">figure_title</a>)． VM には <strong>ハイパーバイザー (Hypervisor)</strong> とよばれるレイヤーが存在する． Hypervisor はまず，物理的な計算機リソース (CPU, RAM, network など) を分割し，仮想化する． たとえば， ホストマシンに物理的な CPU が 4 コアあるとして，ハイパーバイザーはそれを (2,2) 個の組に仮想的に分割することができる． VM 上で起動する OS には，ハイパーバイザーによって仮想化されたハードウェアが割り当てられる． VM 上で起動する OS は基本的に完全に独立であり，たとえば OS-A は OS-B に割り当てられた CPU やメモリー領域にアクセスすることはできない (これを isolation とよぶ)． VM を作成するための有名なソフトウェアとしては， <a href="https://www.vmware.com/" target="_blank" rel="noreferrer">VMware</a>， <a href="https://www.virtualbox.org/" target="_blank" rel="noreferrer">VirtualBox</a>， <a href="https://xenproject.org/" target="_blank" rel="noreferrer">Xen</a> などがある． また，これまで触ってきた EC2 も，基本的に VM 技術を使うことで所望のスペックをもった仮想マシンがユーザーに提示される．</p>
<p>Docker も， VM と同様に，仮想化された OS をホストの OS 上に走らせるための技術である． VM に対し， Docker ではハードウェアレベルの仮想化は行われておらず，すべての<strong>仮想化はソフトウェアレベルで実現されている</strong> (<a href="#docker_vs_vm">figure_title</a>)． Docker で走る仮想 OS は，<strong>多くの部分をホストの OS に依存しており，結果として非常にコンパクトである</strong>． その結果， Docker で仮想 OS を起動するために要する時間は， VM に比べて圧倒的に早い． また， パッケージ化された環境 (=イメージ) のサイズも完全な OS に比べ圧倒的に小さくなるので，ネットワークを通じたやり取りが非常に高速化される点も重要である 加えて， VM のいくつかの実装では，メタル (仮想化マシンに対して，物理的なハードウェア上で直接起動する場合のこと) と比べ，ハイパーバイザーレイヤーでのオーバーヘッドなどにより性能が低下することが知られているが， Docker ではメタルとほぼ同様の性能を引き出すことができるとされている．</p>
<p>その他， VM との相違点などはたくさんあるのだが，ここではこれ以上詳細には立ち入らない． 大事なのは， <strong>Docker とはとてもコンパクトかつハイパフォーマンスな仮想計算環境を作るツールである</strong>，という点である． その手軽さゆえに，2013 年の登場以降，クラウドシステムでの利用が急速に増加し，現代のクラウドでは欠くことのできない中心的な技術になっている．</p>
<p><img src="./assets/docker_vs_vm.png" alt="Docker (左) と VM (右) の比較 (画像出典: https://www.docker.com/blog/containers-replacing-virtual-machines/)"></p>
<p>職業的プログラマーにとっての&quot;三種の神器&quot;とはなんだろうか？ 多様な意見があると思うが，筆者は <strong>Git</strong>, <strong>Vim</strong> そして <strong>Docker</strong> を挙げたい．</p>
<p>Git は多くの読者がご存じの通り，コードの変更を追跡するためのシステムである． Linux の作成者である Linus Torvalds によって 2005 年に誕生した． チームでの開発を進める際には欠かせないツールだ．</p>
<p>Vim は 1991 年から 30 年以上の間プログラマーたちに愛されてきたテキストエディターである． <a href="https://insights.stackoverflow.com/survey/2019#technology-development-environments-and-tools-all-respondents" target="_blank" rel="noreferrer">Stackoverflow が行った 2019 年のアンケート</a> によると，開発環境の部門で 5 位の人気を獲得している． たくさんのショートカットと様々なカスタム設定が提供されているので，初見の人にはなかなかハードルが高いが，一度マスターすれば他のモダンなエディターや統合開発環境に負けない，あるいはそれ以上の開発体験を実現することができる．</p>
<p>これらの十年以上の歴史あるツールに並んで，第三番目の三種の神器として挙げたいのが Docker だ． Docker はプログラマーの開発のワークフローを一変させた． たとえば，プロジェクトごとに Docker イメージを作成することで，どの OS・コンピュータ でも全く同じ計算環境で開発・テストを実行することができるようになった． また， <a href="https://en.wikipedia.org/wiki/DevOps" target="_blank" rel="noreferrer">DevOps</a> や <a href="https://en.wikipedia.org/wiki/Continuous_integration" target="_blank" rel="noreferrer">CI</a> / <a href="https://en.wikipedia.org/wiki/Continuous_delivery" target="_blank" rel="noreferrer">CD</a> (Continuous Integration / Continuous Deployment) といった最近の開発ワークフローも Docker のようなコンテナ技術の存在に立脚している． さらにはサーバーレスコンピューティング ( (#sec_serverless)) といった概念も，コンテナ技術の生んだ大きな技術革新といえる．</p>
<p>あなたにとっての三種の神器はなんだろうか？ また，これからの未来ではどんな新しいツールが三種の神器としてプログラマーのワークフローを革新していくだろうか？</p>
<h2 id="docker-チュートリアル" tabindex="-1">Docker チュートリアル <a class="header-anchor" href="#docker-チュートリアル" aria-label="Permalink to &quot;Docker チュートリアル&quot;">&ZeroWidthSpace;</a></h2>
<p>Docker とはなにかを理解するためには，実際に触って動かしてみるのが一番有効な手立てである． ここでは， Docker の簡単なチュートリアルを行っていく．</p>
<p>Docker のインストールについては， (#sec:install_docker) および <a href="https://docs.docker.com/engine/install/" target="_blank" rel="noreferrer">公式のドキュメンテーション</a> を参照してもらいたい． Docker のインストールが完了している前提で，以下は話を進めるものとする．</p>
<h3 id="docker-用語集" tabindex="-1">Docker 用語集 <a class="header-anchor" href="#docker-用語集" aria-label="Permalink to &quot;Docker 用語集&quot;">&ZeroWidthSpace;</a></h3>
<p>Docker を使い始めるに当たり，最初に主要な用語を解説しよう． 次のパラグラフで太字で強調された用語を頭に入れた上で，続くチュートリアルに取り組んでいただきたい．</p>
<p>Docker を起動する際の大まかなステップを示したのが <a href="#fig:docker_image_container">figure_title</a> である． パッケージされた一つの計算環境のことを **イメージ (Image)**とよぶ． イメージは， Docker Hub などのリポジトリで配布されているものをダウンロードするか，自分でカスタムのイメージを作成することも可能である． イメージを作成するための”レシピ”を記述したファイルが <strong>Dockerfile</strong> である． Dockerfile からイメージを作成する操作を <strong>build</strong> とよぶ． イメージがホストマシンのメモリにロードされ，起動状態にある計算環境のことを <strong>コンテナ (Container)</strong> とよぶ． Container を起動するために使用されるコマンドが <strong>run</strong> である．</p>
<p><img src="./assets/docker_image_container.png" alt="Image と Container"></p>
<h3 id="イメージをダウンロード" tabindex="-1">イメージをダウンロード <a class="header-anchor" href="#イメージをダウンロード" aria-label="Permalink to &quot;イメージをダウンロード&quot;">&ZeroWidthSpace;</a></h3>
<p>パッケージ化された Docker の仮想環境 (= <strong>イメージ (Image)</strong>) は， <a href="https://hub.docker.com/" target="_blank" rel="noreferrer">Docker Hub</a> からダウンロードできる． Docker Hub には，個人や企業・団体が作成した Docker イメージが集められており， GitHub などと同じ感覚で，オープンな形で公開されている．</p>
<p>たとえば， Ubuntu のイメージは <a href="https://hub.docker.com/_/ubuntu" target="_blank" rel="noreferrer">Ubuntu の公式リポジトリ</a> で公開されており， <code>pull</code> コマンドを使うことでローカルにダウンロードすることができる．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">docker</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">pull</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ubuntu:18.04</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">docker</span><span style="color: #24292E"> </span><span style="color: #032F62">pull</span><span style="color: #24292E"> </span><span style="color: #032F62">ubuntu:18.04</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>ここで，イメージ名の <code>:</code> (コロン) 以降に続く文字列を <strong>タグ (tag)</strong> と呼び，主にバージョンを指定するなどの目的で使われる．</p>
<p><code>pull</code> コマンドはデフォルトでは Docker Hub でイメージを検索し，ダウンロードを行う． Docker イメージを公開するためのデータベース (レジストリ (registry) とよぶ) は Docker Hub だけではなく，たとえば GitLab や GitHub は独自のレジストリ機能を提供しているし，個人のサーバーでレジストリを立ち上げることも可能である． Docker Hub 以外のレジストリから pull するには， <code>myregistry.local:5000/testing/test-image</code> のように，イメージ名の先頭につける形でレジストリのアドレス (さらにオプションとしてポート番号) を指定する．</p>
<h3 id="コンテナを起動" tabindex="-1">コンテナを起動 <a class="header-anchor" href="#コンテナを起動" aria-label="Permalink to &quot;コンテナを起動&quot;">&ZeroWidthSpace;</a></h3>
<p>Pull してきたイメージを起動するには， <code>run</code> コマンドを使う．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">docker</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">run</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-it</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ubuntu:18.04</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">docker</span><span style="color: #24292E"> </span><span style="color: #032F62">run</span><span style="color: #24292E"> </span><span style="color: #005CC5">-it</span><span style="color: #24292E"> </span><span style="color: #032F62">ubuntu:18.04</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>ここで， <code>-it</code> とは，インタラクティブな shell のセッションを開始するために必要なオプションである．</p>
<p>このコマンドを実行すると，仮想化された Ubuntu が起動され，コマンドラインからコマンドが打ち込めるようになる (<a href="#docker_shell">figure_title</a>)． このように起動状態にある計算環境 (ランタイム) のことを <strong>Container (コンテナ)</strong> とよぶ．</p>
<p><img src="./assets/docker_shell.png" alt="Docker を使って ubuntu:18.04 イメージを起動"></p>
<p>ここで使用した <code>ubuntu:18.04</code> のイメージは，空の Ubuntu OS だが，すでにプログラムがインストール済みのものもある． これは， (#sec_jupyter_and_deep_learning) でみた DLAMI と概念として似ている． たとえば， PyTorch がインストール済みのイメージは <a href="https://hub.docker.com/r/pytorch/pytorch" target="_blank" rel="noreferrer">PyTorch 公式の Docker Hub リポジトリ</a> で公開されている．</p>
<p>これを起動してみよう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">docker</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">run</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-it</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">pytorch/pytorch</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">docker</span><span style="color: #24292E"> </span><span style="color: #032F62">run</span><span style="color: #24292E"> </span><span style="color: #005CC5">-it</span><span style="color: #24292E"> </span><span style="color: #032F62">pytorch/pytorch</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p><code>docker run</code> を実行したとき，ローカルに該当するイメージが見つからない場合は，自動的に Docker Hub からダウンロードされる．</p>
<p>pytorch のコンテナが起動したら， Python のシェルを立ち上げて， pytorch をインポートしてみよう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python3</span></span>
<span class="line"><span style="color: #F69D50">Python</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">3.7</span><span style="color: #96D0FF">.7</span><span style="color: #ADBAC7"> (default, </span><span style="color: #96D0FF">May</span><span style="color: #ADBAC7">  </span><span style="color: #6CB6FF">7</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">2020</span><span style="color: #96D0FF">,</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">21</span><span style="color: #96D0FF">:25:33</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">[GCC </span><span style="color: #6CB6FF">7.3</span><span style="color: #ADBAC7">.0] :: Anaconda, Inc. on linux</span></span>
<span class="line"><span style="color: #F69D50">Type</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;help&quot;,</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;copyright&quot;,</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;credits&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">or</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;license&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">for</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">more</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">information.</span></span>
<span class="line"><span style="color: #ADBAC7">&gt;&gt;&gt; </span><span style="color: #F69D50">import</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">torch</span></span>
<span class="line"><span style="color: #ADBAC7">&gt;&gt;&gt; </span><span style="color: #DCBDFB">torch.cuda.is_available</span><span style="color: #ADBAC7">()</span></span>
<span class="line"><span style="color: #ADBAC7">False</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python3</span></span>
<span class="line"><span style="color: #6F42C1">Python</span><span style="color: #24292E"> </span><span style="color: #005CC5">3.7</span><span style="color: #032F62">.7</span><span style="color: #24292E"> (default, </span><span style="color: #032F62">May</span><span style="color: #24292E">  </span><span style="color: #005CC5">7</span><span style="color: #24292E"> </span><span style="color: #005CC5">2020</span><span style="color: #032F62">,</span><span style="color: #24292E"> </span><span style="color: #005CC5">21</span><span style="color: #032F62">:25:33</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">[GCC </span><span style="color: #005CC5">7.3</span><span style="color: #24292E">.0] :: Anaconda, Inc. on linux</span></span>
<span class="line"><span style="color: #6F42C1">Type</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;help&quot;,</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;copyright&quot;,</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;credits&quot;</span><span style="color: #24292E"> </span><span style="color: #032F62">or</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;license&quot;</span><span style="color: #24292E"> </span><span style="color: #032F62">for</span><span style="color: #24292E"> </span><span style="color: #032F62">more</span><span style="color: #24292E"> </span><span style="color: #032F62">information.</span></span>
<span class="line"><span style="color: #24292E">&gt;&gt;&gt; </span><span style="color: #6F42C1">import</span><span style="color: #24292E"> </span><span style="color: #032F62">torch</span></span>
<span class="line"><span style="color: #24292E">&gt;&gt;&gt; </span><span style="color: #6F42C1">torch.cuda.is_available</span><span style="color: #24292E">()</span></span>
<span class="line"><span style="color: #24292E">False</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br></div></div><p>このように， Docker を使うことで簡単に特定の OS・プログラムの入った計算環境を再現することが可能になる．</p>
<h3 id="自分だけのイメージを作る" tabindex="-1">自分だけのイメージを作る <a class="header-anchor" href="#自分だけのイメージを作る" aria-label="Permalink to &quot;自分だけのイメージを作る&quot;">&ZeroWidthSpace;</a></h3>
<p>自分の使うソフトウェア・ライブラリがインストールされた，自分だけのイメージを作ることも可能である．</p>
<p>たとえば， <a href="https://hub.docker.com/repository/docker/tomomano/labc" target="_blank" rel="noreferrer">本書のハンズオン実行用に提供している docker イメージ</a> には， Python, Node.js, AWS CLI, AWS CDK などのソフトウェアがインストール済みであり，ダウンロードしてくるだけですぐにハンズオンのプログラムが実行できるようになっている．</p>
<p>カスタムの docker イメージを作るには， <code>Dockerfile</code> という名前のついたファイルを用意し，その中にどんなプログラムをインストールするかなどを記述していく．</p>
<p>具体例として，本書で提供している Docker イメージのレシピを見てみよう (<a href="https://github.com/andatoshiki/toshiki-notebookblob/main/docker/Dockerfile" target="_blank" rel="noreferrer">docker/Dockerfile</a>)．</p>
<div class="language-dockerfile vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">dockerfile</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">FROM</span><span style="color: #ADBAC7"> node:12</span></span>
<span class="line"><span style="color: #F47067">LABEL</span><span style="color: #ADBAC7"> maintainer=</span><span style="color: #96D0FF">&quot;Tomoyuki Mano&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F47067">RUN</span><span style="color: #ADBAC7"> apt-get update \</span></span>
<span class="line"><span style="color: #ADBAC7">    &amp;&amp; apt-get install nano</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #F47067">RUN</span><span style="color: #ADBAC7"> cd /opt \</span></span>
<span class="line"><span style="color: #ADBAC7">    &amp;&amp; curl -q </span><span style="color: #96D0FF">&quot;https://www.python.org/ftp/python/3.7.6/Python-3.7.6.tgz&quot;</span><span style="color: #ADBAC7"> -o Python-3.7.6.tgz \</span></span>
<span class="line"><span style="color: #ADBAC7">    &amp;&amp; tar -xzf Python-3.7.6.tgz \</span></span>
<span class="line"><span style="color: #ADBAC7">    &amp;&amp; cd Python-3.7.6 \</span></span>
<span class="line"><span style="color: #ADBAC7">    &amp;&amp; ./configure --enable-optimizations \</span></span>
<span class="line"><span style="color: #ADBAC7">    &amp;&amp; make install</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F47067">RUN</span><span style="color: #ADBAC7"> cd /opt \</span></span>
<span class="line"><span style="color: #ADBAC7">    &amp;&amp; curl </span><span style="color: #96D0FF">&quot;https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip&quot;</span><span style="color: #ADBAC7"> -o </span><span style="color: #96D0FF">&quot;awscliv2.zip&quot;</span><span style="color: #ADBAC7"> \</span></span>
<span class="line"><span style="color: #ADBAC7">    &amp;&amp; unzip awscliv2.zip \</span></span>
<span class="line"><span style="color: #ADBAC7">    &amp;&amp; ./aws/install</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #F47067">RUN</span><span style="color: #ADBAC7"> npm install -g aws-cdk@1.100</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># clean up unnecessary files</span></span>
<span class="line"><span style="color: #F47067">RUN</span><span style="color: #ADBAC7"> rm -rf /opt/*</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># copy hands-on source code in /root/</span></span>
<span class="line"><span style="color: #F47067">COPY</span><span style="color: #ADBAC7"> handson/ /root/handson</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">FROM</span><span style="color: #24292E"> node:12</span></span>
<span class="line"><span style="color: #D73A49">LABEL</span><span style="color: #24292E"> maintainer=</span><span style="color: #032F62">&quot;Tomoyuki Mano&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D73A49">RUN</span><span style="color: #24292E"> apt-get update \</span></span>
<span class="line"><span style="color: #24292E">    &amp;&amp; apt-get install nano</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #D73A49">RUN</span><span style="color: #24292E"> cd /opt \</span></span>
<span class="line"><span style="color: #24292E">    &amp;&amp; curl -q </span><span style="color: #032F62">&quot;https://www.python.org/ftp/python/3.7.6/Python-3.7.6.tgz&quot;</span><span style="color: #24292E"> -o Python-3.7.6.tgz \</span></span>
<span class="line"><span style="color: #24292E">    &amp;&amp; tar -xzf Python-3.7.6.tgz \</span></span>
<span class="line"><span style="color: #24292E">    &amp;&amp; cd Python-3.7.6 \</span></span>
<span class="line"><span style="color: #24292E">    &amp;&amp; ./configure --enable-optimizations \</span></span>
<span class="line"><span style="color: #24292E">    &amp;&amp; make install</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D73A49">RUN</span><span style="color: #24292E"> cd /opt \</span></span>
<span class="line"><span style="color: #24292E">    &amp;&amp; curl </span><span style="color: #032F62">&quot;https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip&quot;</span><span style="color: #24292E"> -o </span><span style="color: #032F62">&quot;awscliv2.zip&quot;</span><span style="color: #24292E"> \</span></span>
<span class="line"><span style="color: #24292E">    &amp;&amp; unzip awscliv2.zip \</span></span>
<span class="line"><span style="color: #24292E">    &amp;&amp; ./aws/install</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #D73A49">RUN</span><span style="color: #24292E"> npm install -g aws-cdk@1.100</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># clean up unnecessary files</span></span>
<span class="line"><span style="color: #D73A49">RUN</span><span style="color: #24292E"> rm -rf /opt/*</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># copy hands-on source code in /root/</span></span>
<span class="line"><span style="color: #D73A49">COPY</span><span style="color: #24292E"> handson/ /root/handson</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br></div></div><p><code>Dockerfile</code> の中身の説明は詳しくは行わないが，たとえば上のコードで &lt;1&gt; で示したところは， Python 3.7 のインストールを実行している． また， &lt;2&gt; で示したところは， AWS CDK のインストールを行っていることがわかるだろう． このように，リアルな OS で行うのと同じ流れでインストールのコマンドを逐一記述していくことで，自分だけの Docker イメージを作成することができる． 一度イメージを作成すれば，それを配布することで，他者も同一の計算環境を簡単に再構成することができる．</p>
<p>&quot;ぼくの環境ではそのプログラム走ったのにな…&quot; というのは，プログラミング初心者ではよく耳にする会話だが， Docker を使いこなせばそのような心配とは無縁である． そのような意味で，クラウド以外の場面でも， Docker の有用性・汎用性は極めて高い．</p>
<p>コンテナを用いた仮想計算環境ツールとして Docker を紹介したが， ほかに選択肢はないのか？ よくぞ聞いてくれた！ Docker の登場以降，複数のコンテナベースの仮想環境ツールが開発されてきた． いずれのツールも，概念や API については Docker と共通するものが多いが，Docker にはない独自の特徴を提供している． ここではその中でも有名ないくつかを紹介しよう．</p>
<p><a href="https://github.com/hpcng/singularity" target="_blank" rel="noreferrer">Singularity</a> は科学計算や HPC (High Performance Computing) の分野で人気の高いコンテナプラットフォームである． Singularity では大学・研究機関の HPC クラスターでの運用に適したような設計が施されている． たとえば， Docker は基本的には root 権限で実行されるのに対し， Singularity はユーザー権限 (コマンドを実行したユーザー自身) でプログラムが実行される． root 権限での実行は Web サーバーのように個人・企業がある特定のサービスのために運用するサーバーでは問題ないが，多数のユーザーが多様な目的で計算を実行する HPC クラスターでは問題となる． また，Singularity は独自のイメージの作成方法・エコシステムをもっているが， Docker イメージを Singularity のイメージに変換し実行する機能も有している．</p>
<p><a href="https://github.com/containers/podman" target="_blank" rel="noreferrer">podman</a> は Red Hat 社によって開発されたもう一つのコンテナプラットフォームである． podman は基本的に Docker と同一のコマンドを採用しているが，実装は Red Hat によってスクラッチから行われた． podman では， Singularity と同様にユーザー権限でのプログラムの実行を可能であり，クラウドおよび HPC の両方の環境に対応するコンテナプラットフォームを目指して作られた． また，その名前にあるとおり pod とよばれる独自の概念が導入されている．</p>
<p>著者の個人的な意見としては，現時点では Docker をマスターしておけば当面は困ることはないと考えるが，興味のある読者はぜひこれらのツールも試してみてはいかがだろうか？</p>
<h2 id="elastic-container-service-ecs" tabindex="-1">Elastic Container Service (ECS) <a class="header-anchor" href="#elastic-container-service-ecs" aria-label="Permalink to &quot;Elastic Container Service (ECS)&quot;">&ZeroWidthSpace;</a></h2>
<p><img src="./assets/aws_logos/ECS.png" alt="ECS のアイコン"></p>
<p>ここまでに説明してきたように， Docker を使うことで仮想計算環境を簡単に複製・起動することが可能になる． 本章の最後の話題として， AWS 上で Docker を使った計算システムを構築する方法を解説しよう．</p>
<p><strong>Elastic Container Service (ECS)</strong> とは， Docker を使った計算機クラスターを AWS 上に作成するためのツールである (<a href="#fig:logo_ecs">figure_title</a>)． ECS を使用することで， Docker にパッケージされたアプリケーションを計算機クラスターに投入したり，計算機クラスターのインスタンスを追加・削除する操作 (=スケーリング) を行うことができる．</p>
<p>ECS の概要を示したのが <a href="#ecs_overview">figure_title</a> である． ECS は，<strong>タスク (Task)</strong> と呼ばれる単位で管理された計算ジョブを受け付ける． システムにタスクが投入されると，ECS は最初にタスクで指定された Docker イメージを外部レジストリからダウンロードしてくる． 外部レジストリとしては， Docker Hub や AWS 独自の Docker レジストリである <strong>ECR (Elastic Container Registry)</strong> を指定することができる．</p>
<p>ECS の次の重要な役割はタスクの配置である． あらかじめ定義されたクラスター内で，計算負荷が小さい仮想インスタンスを選び出し，そこに Docker イメージを配置することで指定された計算タスクが開始される． &quot;計算負荷が小さい仮想インスタンスを選び出す&quot; と言ったが，具体的にどのような戦略・ポリシーでこの選択を行うかは，ユーザーの指定したパラメータに従う．</p>
<p>また，クラスターのスケーリングも ECS における重要な概念である． スケーリングとは，クラスター内のインスタンスの計算負荷をモニタリングし，計算負荷に応じてインスタンスの起動・停止を行う操作を指す． クラスター全体の計算負荷が指定された閾値 (たとえば 80%の稼働率) を超えていた場合，新たな仮想インスタンスをクラスター内に立ち上げる操作を scale-out (スケールアウト) とよび， 負荷が減った場合に不要なインスタンスを停止する操作を scale-in (スケールイン) とよぶ． クラスターのスケーリングは， ECS がほかの AWS のサービスと連携することで実現される． 具体的には， EC2 の <strong>Auto scaling group (ASG)</strong> や <strong>Fargate</strong> の２つの選択肢が多くの場合選択される． <strong>ASG</strong> については (#sec_aws_batch), Fargate については (#sec_fargate_qabot) でより詳細に解説する．</p>
<p>これら一連のタスクの管理を， ECS は自動でやってくれる． クラスターのスケーリングやタスクの配置に関してのパラメータを一度指定してしまえば，ユーザーは (ほとんどなにも考えずに) 大量のタスクを投入することができる． クラスターのスケーリングによってタスクの量にちょうど十分なだけのインスタンスが起動し，タスクが完了した後は不要なインスタンスはすべて停止される．</p>
<p>さて，ここまで説明的な話が続いてしまったが，次章からは早速 Docker と AWS を使って大規模な並列計算システムを構築していこう！</p>
<p><img src="./assets/ecs.png" alt="ECS の概要"></p>
]]></description>
            <content:encoded><![CDATA[<h1 id="docker-入門" tabindex="-1">Docker 入門 <a class="header-anchor" href="#docker-入門" aria-label="Permalink to &quot;Docker 入門&quot;">&ZeroWidthSpace;</a></h1>
<p>ここまでの章で扱ってきたハンズオンでは，<strong>単一のサーバー</strong>を立ち上げ，それに SSH でログインをして，コマンドを叩くことで計算を行ってきた． いわば，<em>パーソナルコンピュータの延長</em>のような形でクラウドを使ってきたわけである． このような，インターネットのどこからでもアクセスできるパーソナルコンピュータとしてのクラウドという使い方も，もちろん便利であるし，いろいろな応用の可能性がある． しかし，これだけではクラウドの本当の価値は十分に発揮されていないと言うべきだろう． (#chap_cloud_basics) で述べたように，現代的なクラウドの一番の強みは自由に計算機の規模を拡大できることにある． すなわち，<strong>多数のサーバーを同時に起動し，複数のジョブを分散並列的に実行させることで大量のデータを処理してこそ，クラウドの本領が発揮される</strong>のである．</p>
<p>本章からはじまる 3 章分 (<a href="#sec_docker_introduction">Docker 入門</a>, (#sec_fargate_qabot), (#sec_aws_batch)) を使って，クラウドを利用することでどのように大規模な計算システムを構築しビッグデータの解析に立ち向かうのか，その片鱗をお見せしたい． とくに，前章で扱った深層学習をどのようにビッグデータに適用していくかという点に焦点を絞って議論していきたい． そのための前準備として，本章では <a href="https://www.docker.com/" target="_blank" rel="noreferrer">Docker</a> とよばれる計算機環境の仮想化ソフトウェアを紹介する (<a href="#fig:docker_logo">figure_title</a>)． 現代のクラウドは Docker なしには成り立たないといっても過言ではないだろう． クラウドに限らず，ローカルで行う計算処理にも Docker は大変便利である． AWS からは少し話が離れるが，しっかりと理解して前に進んでもらいたい．</p>
<h2 id="機械学習の大規模化" tabindex="-1">機械学習の大規模化 <a class="header-anchor" href="#機械学習の大規模化" aria-label="Permalink to &quot;機械学習の大規模化&quot;">&ZeroWidthSpace;</a></h2>
<p>先ほどから&quot;計算システムの大規模化&quot;と繰り返し唱えているが，それは具体的にはどのようなものを指しているのか？ ここでは大規模データを処理するための計算機システムを，機械学習を例にとって見てみよう．</p>
<p>(#sec_scientific_computing) で紹介した <a href="https://github.com/openai/gpt-3" target="_blank" rel="noreferrer">GPT-3</a> のような，超巨大な数のパラメータを有する深層学習モデルを学習させたいとしよう． そのような計算を行いたい場合，一つのサーバーでは計算力が到底足りない． したがって，典型的には <a href="#big_dnn_training">figure_title</a> に示すような計算システムの設計がなされる． すなわち，大量の教師データを小さなチャンクとして複数のマシンに分散し，並列的にニューラルネットのパラメータを最適化していくという構造である．</p>
<p><img src="./assets/big_dnn_training.png" alt="複数の計算機を使った大規模な深層学習モデルの訓練"></p>
<p>あるいは，学習済みのモデルを大量のデータに適用し，解析を行いたいとしよう． たとえば， SNS のプラットフォームで大量の画像が与えられて，それぞれの写真に何が写っているのかをラベルづけする，などのアプリケーションを想定できる． そのような場合は， <a href="#big_dnn_inference">figure_title</a> のようなアーキテクチャが考えられるだろう． すなわち，大量のデータを複数のマシンで分割し，それぞれのマシンで推論の計算を行うというような構造である．</p>
<p><img src="./assets/big_dnn_inference.png" alt="複数の計算機による深層学習モデルを使った推論計算"></p>
<p>このような複数の計算機を同時に走らせるようなアプリケーションをクラウド上で実現するには，どのようにすればよいのだろうか？</p>
<p>重要なポイントとして， <a href="#big_dnn_training">figure_title</a> や <a href="#big_dnn_inference">figure_title</a> で起動している複数のマシンは，<strong>基本的に全く同一の OS・計算環境を有している</strong>点である． ここで，個人のコンピュータで行うようなインストールの操作を，各マシンで行うこともできるが，それは大変な手間であるし，メンテナンスも面倒だろう． すなわち，大規模な計算システムを構築するには，<strong>簡単に計算環境を複製できるような仕組み</strong>が必要であるということがわかる．</p>
<p>そのような目的を実現するために使われるのが， <a href="https://www.docker.com/" target="_blank" rel="noreferrer">Docker</a> とよばれるソフトウェアである．</p>
<h2 id="docker-とは" tabindex="-1">Docker とは <a class="header-anchor" href="#docker-とは" aria-label="Permalink to &quot;Docker とは&quot;">&ZeroWidthSpace;</a></h2>
<p><img src="./assets/docker_log.png" alt="Docker のアイコン"></p>
<p>Docker とは， <strong>コンテナ (Container)</strong> とよばれる仮想環境下で，ホスト OS とは独立した別の計算環境を走らせるためのソフトウェアである． Docker を使うことで， OS を含めたすべてのプログラムをコンパクトにパッケージングすることが可能になる (パッケージされた一つの計算環境のことを **イメージ (Image)**とよぶ)． Docker を使うことで，クラウドのサーバー上に瞬時に計算環境を複製することが可能になり， <a href="#big_dnn_inference">figure_title</a> で見たような複数の計算機を同時に走らせるためのシステムが実現できる．</p>
<p>Docker は 2013 年に Solomon Hykes らを中心に開発され，それ以降爆発的に普及し，クラウドコンピューティングだけでなく，機械学習・科学計算の文脈などでも欠かすことのできないソフトウェアとなった． Docker はエンタープライズ向けの製品を除き無料で使用することができ，コアの部分は <a href="https://github.com/moby/moby" target="_blank" rel="noreferrer">オープンソースプロジェクト</a> として公開されている． Docker は Linux, Windows, Mac いずれの OS でも提供されている． 概念としては， Docker は仮想マシン (Virtual machine; VM) にとても近い． ここでは， VM との対比をしながら，Docker とはなにかを簡単に説明しよう．</p>
<p>仮想マシン (VM) とは，ホストとなるマシンの上に，仮想化された OS を走らせる技術である (<a href="#docker_vs_vm">figure_title</a>)． VM には <strong>ハイパーバイザー (Hypervisor)</strong> とよばれるレイヤーが存在する． Hypervisor はまず，物理的な計算機リソース (CPU, RAM, network など) を分割し，仮想化する． たとえば， ホストマシンに物理的な CPU が 4 コアあるとして，ハイパーバイザーはそれを (2,2) 個の組に仮想的に分割することができる． VM 上で起動する OS には，ハイパーバイザーによって仮想化されたハードウェアが割り当てられる． VM 上で起動する OS は基本的に完全に独立であり，たとえば OS-A は OS-B に割り当てられた CPU やメモリー領域にアクセスすることはできない (これを isolation とよぶ)． VM を作成するための有名なソフトウェアとしては， <a href="https://www.vmware.com/" target="_blank" rel="noreferrer">VMware</a>， <a href="https://www.virtualbox.org/" target="_blank" rel="noreferrer">VirtualBox</a>， <a href="https://xenproject.org/" target="_blank" rel="noreferrer">Xen</a> などがある． また，これまで触ってきた EC2 も，基本的に VM 技術を使うことで所望のスペックをもった仮想マシンがユーザーに提示される．</p>
<p>Docker も， VM と同様に，仮想化された OS をホストの OS 上に走らせるための技術である． VM に対し， Docker ではハードウェアレベルの仮想化は行われておらず，すべての<strong>仮想化はソフトウェアレベルで実現されている</strong> (<a href="#docker_vs_vm">figure_title</a>)． Docker で走る仮想 OS は，<strong>多くの部分をホストの OS に依存しており，結果として非常にコンパクトである</strong>． その結果， Docker で仮想 OS を起動するために要する時間は， VM に比べて圧倒的に早い． また， パッケージ化された環境 (=イメージ) のサイズも完全な OS に比べ圧倒的に小さくなるので，ネットワークを通じたやり取りが非常に高速化される点も重要である 加えて， VM のいくつかの実装では，メタル (仮想化マシンに対して，物理的なハードウェア上で直接起動する場合のこと) と比べ，ハイパーバイザーレイヤーでのオーバーヘッドなどにより性能が低下することが知られているが， Docker ではメタルとほぼ同様の性能を引き出すことができるとされている．</p>
<p>その他， VM との相違点などはたくさんあるのだが，ここではこれ以上詳細には立ち入らない． 大事なのは， <strong>Docker とはとてもコンパクトかつハイパフォーマンスな仮想計算環境を作るツールである</strong>，という点である． その手軽さゆえに，2013 年の登場以降，クラウドシステムでの利用が急速に増加し，現代のクラウドでは欠くことのできない中心的な技術になっている．</p>
<p><img src="./assets/docker_vs_vm.png" alt="Docker (左) と VM (右) の比較 (画像出典: https://www.docker.com/blog/containers-replacing-virtual-machines/)"></p>
<p>職業的プログラマーにとっての&quot;三種の神器&quot;とはなんだろうか？ 多様な意見があると思うが，筆者は <strong>Git</strong>, <strong>Vim</strong> そして <strong>Docker</strong> を挙げたい．</p>
<p>Git は多くの読者がご存じの通り，コードの変更を追跡するためのシステムである． Linux の作成者である Linus Torvalds によって 2005 年に誕生した． チームでの開発を進める際には欠かせないツールだ．</p>
<p>Vim は 1991 年から 30 年以上の間プログラマーたちに愛されてきたテキストエディターである． <a href="https://insights.stackoverflow.com/survey/2019#technology-development-environments-and-tools-all-respondents" target="_blank" rel="noreferrer">Stackoverflow が行った 2019 年のアンケート</a> によると，開発環境の部門で 5 位の人気を獲得している． たくさんのショートカットと様々なカスタム設定が提供されているので，初見の人にはなかなかハードルが高いが，一度マスターすれば他のモダンなエディターや統合開発環境に負けない，あるいはそれ以上の開発体験を実現することができる．</p>
<p>これらの十年以上の歴史あるツールに並んで，第三番目の三種の神器として挙げたいのが Docker だ． Docker はプログラマーの開発のワークフローを一変させた． たとえば，プロジェクトごとに Docker イメージを作成することで，どの OS・コンピュータ でも全く同じ計算環境で開発・テストを実行することができるようになった． また， <a href="https://en.wikipedia.org/wiki/DevOps" target="_blank" rel="noreferrer">DevOps</a> や <a href="https://en.wikipedia.org/wiki/Continuous_integration" target="_blank" rel="noreferrer">CI</a> / <a href="https://en.wikipedia.org/wiki/Continuous_delivery" target="_blank" rel="noreferrer">CD</a> (Continuous Integration / Continuous Deployment) といった最近の開発ワークフローも Docker のようなコンテナ技術の存在に立脚している． さらにはサーバーレスコンピューティング ( (#sec_serverless)) といった概念も，コンテナ技術の生んだ大きな技術革新といえる．</p>
<p>あなたにとっての三種の神器はなんだろうか？ また，これからの未来ではどんな新しいツールが三種の神器としてプログラマーのワークフローを革新していくだろうか？</p>
<h2 id="docker-チュートリアル" tabindex="-1">Docker チュートリアル <a class="header-anchor" href="#docker-チュートリアル" aria-label="Permalink to &quot;Docker チュートリアル&quot;">&ZeroWidthSpace;</a></h2>
<p>Docker とはなにかを理解するためには，実際に触って動かしてみるのが一番有効な手立てである． ここでは， Docker の簡単なチュートリアルを行っていく．</p>
<p>Docker のインストールについては， (#sec:install_docker) および <a href="https://docs.docker.com/engine/install/" target="_blank" rel="noreferrer">公式のドキュメンテーション</a> を参照してもらいたい． Docker のインストールが完了している前提で，以下は話を進めるものとする．</p>
<h3 id="docker-用語集" tabindex="-1">Docker 用語集 <a class="header-anchor" href="#docker-用語集" aria-label="Permalink to &quot;Docker 用語集&quot;">&ZeroWidthSpace;</a></h3>
<p>Docker を使い始めるに当たり，最初に主要な用語を解説しよう． 次のパラグラフで太字で強調された用語を頭に入れた上で，続くチュートリアルに取り組んでいただきたい．</p>
<p>Docker を起動する際の大まかなステップを示したのが <a href="#fig:docker_image_container">figure_title</a> である． パッケージされた一つの計算環境のことを **イメージ (Image)**とよぶ． イメージは， Docker Hub などのリポジトリで配布されているものをダウンロードするか，自分でカスタムのイメージを作成することも可能である． イメージを作成するための”レシピ”を記述したファイルが <strong>Dockerfile</strong> である． Dockerfile からイメージを作成する操作を <strong>build</strong> とよぶ． イメージがホストマシンのメモリにロードされ，起動状態にある計算環境のことを <strong>コンテナ (Container)</strong> とよぶ． Container を起動するために使用されるコマンドが <strong>run</strong> である．</p>
<p><img src="./assets/docker_image_container.png" alt="Image と Container"></p>
<h3 id="イメージをダウンロード" tabindex="-1">イメージをダウンロード <a class="header-anchor" href="#イメージをダウンロード" aria-label="Permalink to &quot;イメージをダウンロード&quot;">&ZeroWidthSpace;</a></h3>
<p>パッケージ化された Docker の仮想環境 (= <strong>イメージ (Image)</strong>) は， <a href="https://hub.docker.com/" target="_blank" rel="noreferrer">Docker Hub</a> からダウンロードできる． Docker Hub には，個人や企業・団体が作成した Docker イメージが集められており， GitHub などと同じ感覚で，オープンな形で公開されている．</p>
<p>たとえば， Ubuntu のイメージは <a href="https://hub.docker.com/_/ubuntu" target="_blank" rel="noreferrer">Ubuntu の公式リポジトリ</a> で公開されており， <code>pull</code> コマンドを使うことでローカルにダウンロードすることができる．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">docker</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">pull</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ubuntu:18.04</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">docker</span><span style="color: #24292E"> </span><span style="color: #032F62">pull</span><span style="color: #24292E"> </span><span style="color: #032F62">ubuntu:18.04</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>ここで，イメージ名の <code>:</code> (コロン) 以降に続く文字列を <strong>タグ (tag)</strong> と呼び，主にバージョンを指定するなどの目的で使われる．</p>
<p><code>pull</code> コマンドはデフォルトでは Docker Hub でイメージを検索し，ダウンロードを行う． Docker イメージを公開するためのデータベース (レジストリ (registry) とよぶ) は Docker Hub だけではなく，たとえば GitLab や GitHub は独自のレジストリ機能を提供しているし，個人のサーバーでレジストリを立ち上げることも可能である． Docker Hub 以外のレジストリから pull するには， <code>myregistry.local:5000/testing/test-image</code> のように，イメージ名の先頭につける形でレジストリのアドレス (さらにオプションとしてポート番号) を指定する．</p>
<h3 id="コンテナを起動" tabindex="-1">コンテナを起動 <a class="header-anchor" href="#コンテナを起動" aria-label="Permalink to &quot;コンテナを起動&quot;">&ZeroWidthSpace;</a></h3>
<p>Pull してきたイメージを起動するには， <code>run</code> コマンドを使う．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">docker</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">run</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-it</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ubuntu:18.04</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">docker</span><span style="color: #24292E"> </span><span style="color: #032F62">run</span><span style="color: #24292E"> </span><span style="color: #005CC5">-it</span><span style="color: #24292E"> </span><span style="color: #032F62">ubuntu:18.04</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>ここで， <code>-it</code> とは，インタラクティブな shell のセッションを開始するために必要なオプションである．</p>
<p>このコマンドを実行すると，仮想化された Ubuntu が起動され，コマンドラインからコマンドが打ち込めるようになる (<a href="#docker_shell">figure_title</a>)． このように起動状態にある計算環境 (ランタイム) のことを <strong>Container (コンテナ)</strong> とよぶ．</p>
<p><img src="./assets/docker_shell.png" alt="Docker を使って ubuntu:18.04 イメージを起動"></p>
<p>ここで使用した <code>ubuntu:18.04</code> のイメージは，空の Ubuntu OS だが，すでにプログラムがインストール済みのものもある． これは， (#sec_jupyter_and_deep_learning) でみた DLAMI と概念として似ている． たとえば， PyTorch がインストール済みのイメージは <a href="https://hub.docker.com/r/pytorch/pytorch" target="_blank" rel="noreferrer">PyTorch 公式の Docker Hub リポジトリ</a> で公開されている．</p>
<p>これを起動してみよう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">docker</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">run</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-it</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">pytorch/pytorch</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">docker</span><span style="color: #24292E"> </span><span style="color: #032F62">run</span><span style="color: #24292E"> </span><span style="color: #005CC5">-it</span><span style="color: #24292E"> </span><span style="color: #032F62">pytorch/pytorch</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p><code>docker run</code> を実行したとき，ローカルに該当するイメージが見つからない場合は，自動的に Docker Hub からダウンロードされる．</p>
<p>pytorch のコンテナが起動したら， Python のシェルを立ち上げて， pytorch をインポートしてみよう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python3</span></span>
<span class="line"><span style="color: #F69D50">Python</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">3.7</span><span style="color: #96D0FF">.7</span><span style="color: #ADBAC7"> (default, </span><span style="color: #96D0FF">May</span><span style="color: #ADBAC7">  </span><span style="color: #6CB6FF">7</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">2020</span><span style="color: #96D0FF">,</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">21</span><span style="color: #96D0FF">:25:33</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">[GCC </span><span style="color: #6CB6FF">7.3</span><span style="color: #ADBAC7">.0] :: Anaconda, Inc. on linux</span></span>
<span class="line"><span style="color: #F69D50">Type</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;help&quot;,</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;copyright&quot;,</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;credits&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">or</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;license&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">for</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">more</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">information.</span></span>
<span class="line"><span style="color: #ADBAC7">&gt;&gt;&gt; </span><span style="color: #F69D50">import</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">torch</span></span>
<span class="line"><span style="color: #ADBAC7">&gt;&gt;&gt; </span><span style="color: #DCBDFB">torch.cuda.is_available</span><span style="color: #ADBAC7">()</span></span>
<span class="line"><span style="color: #ADBAC7">False</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python3</span></span>
<span class="line"><span style="color: #6F42C1">Python</span><span style="color: #24292E"> </span><span style="color: #005CC5">3.7</span><span style="color: #032F62">.7</span><span style="color: #24292E"> (default, </span><span style="color: #032F62">May</span><span style="color: #24292E">  </span><span style="color: #005CC5">7</span><span style="color: #24292E"> </span><span style="color: #005CC5">2020</span><span style="color: #032F62">,</span><span style="color: #24292E"> </span><span style="color: #005CC5">21</span><span style="color: #032F62">:25:33</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">[GCC </span><span style="color: #005CC5">7.3</span><span style="color: #24292E">.0] :: Anaconda, Inc. on linux</span></span>
<span class="line"><span style="color: #6F42C1">Type</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;help&quot;,</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;copyright&quot;,</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;credits&quot;</span><span style="color: #24292E"> </span><span style="color: #032F62">or</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;license&quot;</span><span style="color: #24292E"> </span><span style="color: #032F62">for</span><span style="color: #24292E"> </span><span style="color: #032F62">more</span><span style="color: #24292E"> </span><span style="color: #032F62">information.</span></span>
<span class="line"><span style="color: #24292E">&gt;&gt;&gt; </span><span style="color: #6F42C1">import</span><span style="color: #24292E"> </span><span style="color: #032F62">torch</span></span>
<span class="line"><span style="color: #24292E">&gt;&gt;&gt; </span><span style="color: #6F42C1">torch.cuda.is_available</span><span style="color: #24292E">()</span></span>
<span class="line"><span style="color: #24292E">False</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br></div></div><p>このように， Docker を使うことで簡単に特定の OS・プログラムの入った計算環境を再現することが可能になる．</p>
<h3 id="自分だけのイメージを作る" tabindex="-1">自分だけのイメージを作る <a class="header-anchor" href="#自分だけのイメージを作る" aria-label="Permalink to &quot;自分だけのイメージを作る&quot;">&ZeroWidthSpace;</a></h3>
<p>自分の使うソフトウェア・ライブラリがインストールされた，自分だけのイメージを作ることも可能である．</p>
<p>たとえば， <a href="https://hub.docker.com/repository/docker/tomomano/labc" target="_blank" rel="noreferrer">本書のハンズオン実行用に提供している docker イメージ</a> には， Python, Node.js, AWS CLI, AWS CDK などのソフトウェアがインストール済みであり，ダウンロードしてくるだけですぐにハンズオンのプログラムが実行できるようになっている．</p>
<p>カスタムの docker イメージを作るには， <code>Dockerfile</code> という名前のついたファイルを用意し，その中にどんなプログラムをインストールするかなどを記述していく．</p>
<p>具体例として，本書で提供している Docker イメージのレシピを見てみよう (<a href="https://github.com/andatoshiki/toshiki-notebookblob/main/docker/Dockerfile" target="_blank" rel="noreferrer">docker/Dockerfile</a>)．</p>
<div class="language-dockerfile vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">dockerfile</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">FROM</span><span style="color: #ADBAC7"> node:12</span></span>
<span class="line"><span style="color: #F47067">LABEL</span><span style="color: #ADBAC7"> maintainer=</span><span style="color: #96D0FF">&quot;Tomoyuki Mano&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F47067">RUN</span><span style="color: #ADBAC7"> apt-get update \</span></span>
<span class="line"><span style="color: #ADBAC7">    &amp;&amp; apt-get install nano</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #F47067">RUN</span><span style="color: #ADBAC7"> cd /opt \</span></span>
<span class="line"><span style="color: #ADBAC7">    &amp;&amp; curl -q </span><span style="color: #96D0FF">&quot;https://www.python.org/ftp/python/3.7.6/Python-3.7.6.tgz&quot;</span><span style="color: #ADBAC7"> -o Python-3.7.6.tgz \</span></span>
<span class="line"><span style="color: #ADBAC7">    &amp;&amp; tar -xzf Python-3.7.6.tgz \</span></span>
<span class="line"><span style="color: #ADBAC7">    &amp;&amp; cd Python-3.7.6 \</span></span>
<span class="line"><span style="color: #ADBAC7">    &amp;&amp; ./configure --enable-optimizations \</span></span>
<span class="line"><span style="color: #ADBAC7">    &amp;&amp; make install</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F47067">RUN</span><span style="color: #ADBAC7"> cd /opt \</span></span>
<span class="line"><span style="color: #ADBAC7">    &amp;&amp; curl </span><span style="color: #96D0FF">&quot;https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip&quot;</span><span style="color: #ADBAC7"> -o </span><span style="color: #96D0FF">&quot;awscliv2.zip&quot;</span><span style="color: #ADBAC7"> \</span></span>
<span class="line"><span style="color: #ADBAC7">    &amp;&amp; unzip awscliv2.zip \</span></span>
<span class="line"><span style="color: #ADBAC7">    &amp;&amp; ./aws/install</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #F47067">RUN</span><span style="color: #ADBAC7"> npm install -g aws-cdk@1.100</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># clean up unnecessary files</span></span>
<span class="line"><span style="color: #F47067">RUN</span><span style="color: #ADBAC7"> rm -rf /opt/*</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># copy hands-on source code in /root/</span></span>
<span class="line"><span style="color: #F47067">COPY</span><span style="color: #ADBAC7"> handson/ /root/handson</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">FROM</span><span style="color: #24292E"> node:12</span></span>
<span class="line"><span style="color: #D73A49">LABEL</span><span style="color: #24292E"> maintainer=</span><span style="color: #032F62">&quot;Tomoyuki Mano&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D73A49">RUN</span><span style="color: #24292E"> apt-get update \</span></span>
<span class="line"><span style="color: #24292E">    &amp;&amp; apt-get install nano</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #D73A49">RUN</span><span style="color: #24292E"> cd /opt \</span></span>
<span class="line"><span style="color: #24292E">    &amp;&amp; curl -q </span><span style="color: #032F62">&quot;https://www.python.org/ftp/python/3.7.6/Python-3.7.6.tgz&quot;</span><span style="color: #24292E"> -o Python-3.7.6.tgz \</span></span>
<span class="line"><span style="color: #24292E">    &amp;&amp; tar -xzf Python-3.7.6.tgz \</span></span>
<span class="line"><span style="color: #24292E">    &amp;&amp; cd Python-3.7.6 \</span></span>
<span class="line"><span style="color: #24292E">    &amp;&amp; ./configure --enable-optimizations \</span></span>
<span class="line"><span style="color: #24292E">    &amp;&amp; make install</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D73A49">RUN</span><span style="color: #24292E"> cd /opt \</span></span>
<span class="line"><span style="color: #24292E">    &amp;&amp; curl </span><span style="color: #032F62">&quot;https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip&quot;</span><span style="color: #24292E"> -o </span><span style="color: #032F62">&quot;awscliv2.zip&quot;</span><span style="color: #24292E"> \</span></span>
<span class="line"><span style="color: #24292E">    &amp;&amp; unzip awscliv2.zip \</span></span>
<span class="line"><span style="color: #24292E">    &amp;&amp; ./aws/install</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #D73A49">RUN</span><span style="color: #24292E"> npm install -g aws-cdk@1.100</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># clean up unnecessary files</span></span>
<span class="line"><span style="color: #D73A49">RUN</span><span style="color: #24292E"> rm -rf /opt/*</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># copy hands-on source code in /root/</span></span>
<span class="line"><span style="color: #D73A49">COPY</span><span style="color: #24292E"> handson/ /root/handson</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br></div></div><p><code>Dockerfile</code> の中身の説明は詳しくは行わないが，たとえば上のコードで &lt;1&gt; で示したところは， Python 3.7 のインストールを実行している． また， &lt;2&gt; で示したところは， AWS CDK のインストールを行っていることがわかるだろう． このように，リアルな OS で行うのと同じ流れでインストールのコマンドを逐一記述していくことで，自分だけの Docker イメージを作成することができる． 一度イメージを作成すれば，それを配布することで，他者も同一の計算環境を簡単に再構成することができる．</p>
<p>&quot;ぼくの環境ではそのプログラム走ったのにな…&quot; というのは，プログラミング初心者ではよく耳にする会話だが， Docker を使いこなせばそのような心配とは無縁である． そのような意味で，クラウド以外の場面でも， Docker の有用性・汎用性は極めて高い．</p>
<p>コンテナを用いた仮想計算環境ツールとして Docker を紹介したが， ほかに選択肢はないのか？ よくぞ聞いてくれた！ Docker の登場以降，複数のコンテナベースの仮想環境ツールが開発されてきた． いずれのツールも，概念や API については Docker と共通するものが多いが，Docker にはない独自の特徴を提供している． ここではその中でも有名ないくつかを紹介しよう．</p>
<p><a href="https://github.com/hpcng/singularity" target="_blank" rel="noreferrer">Singularity</a> は科学計算や HPC (High Performance Computing) の分野で人気の高いコンテナプラットフォームである． Singularity では大学・研究機関の HPC クラスターでの運用に適したような設計が施されている． たとえば， Docker は基本的には root 権限で実行されるのに対し， Singularity はユーザー権限 (コマンドを実行したユーザー自身) でプログラムが実行される． root 権限での実行は Web サーバーのように個人・企業がある特定のサービスのために運用するサーバーでは問題ないが，多数のユーザーが多様な目的で計算を実行する HPC クラスターでは問題となる． また，Singularity は独自のイメージの作成方法・エコシステムをもっているが， Docker イメージを Singularity のイメージに変換し実行する機能も有している．</p>
<p><a href="https://github.com/containers/podman" target="_blank" rel="noreferrer">podman</a> は Red Hat 社によって開発されたもう一つのコンテナプラットフォームである． podman は基本的に Docker と同一のコマンドを採用しているが，実装は Red Hat によってスクラッチから行われた． podman では， Singularity と同様にユーザー権限でのプログラムの実行を可能であり，クラウドおよび HPC の両方の環境に対応するコンテナプラットフォームを目指して作られた． また，その名前にあるとおり pod とよばれる独自の概念が導入されている．</p>
<p>著者の個人的な意見としては，現時点では Docker をマスターしておけば当面は困ることはないと考えるが，興味のある読者はぜひこれらのツールも試してみてはいかがだろうか？</p>
<h2 id="elastic-container-service-ecs" tabindex="-1">Elastic Container Service (ECS) <a class="header-anchor" href="#elastic-container-service-ecs" aria-label="Permalink to &quot;Elastic Container Service (ECS)&quot;">&ZeroWidthSpace;</a></h2>
<p><img src="./assets/aws_logos/ECS.png" alt="ECS のアイコン"></p>
<p>ここまでに説明してきたように， Docker を使うことで仮想計算環境を簡単に複製・起動することが可能になる． 本章の最後の話題として， AWS 上で Docker を使った計算システムを構築する方法を解説しよう．</p>
<p><strong>Elastic Container Service (ECS)</strong> とは， Docker を使った計算機クラスターを AWS 上に作成するためのツールである (<a href="#fig:logo_ecs">figure_title</a>)． ECS を使用することで， Docker にパッケージされたアプリケーションを計算機クラスターに投入したり，計算機クラスターのインスタンスを追加・削除する操作 (=スケーリング) を行うことができる．</p>
<p>ECS の概要を示したのが <a href="#ecs_overview">figure_title</a> である． ECS は，<strong>タスク (Task)</strong> と呼ばれる単位で管理された計算ジョブを受け付ける． システムにタスクが投入されると，ECS は最初にタスクで指定された Docker イメージを外部レジストリからダウンロードしてくる． 外部レジストリとしては， Docker Hub や AWS 独自の Docker レジストリである <strong>ECR (Elastic Container Registry)</strong> を指定することができる．</p>
<p>ECS の次の重要な役割はタスクの配置である． あらかじめ定義されたクラスター内で，計算負荷が小さい仮想インスタンスを選び出し，そこに Docker イメージを配置することで指定された計算タスクが開始される． &quot;計算負荷が小さい仮想インスタンスを選び出す&quot; と言ったが，具体的にどのような戦略・ポリシーでこの選択を行うかは，ユーザーの指定したパラメータに従う．</p>
<p>また，クラスターのスケーリングも ECS における重要な概念である． スケーリングとは，クラスター内のインスタンスの計算負荷をモニタリングし，計算負荷に応じてインスタンスの起動・停止を行う操作を指す． クラスター全体の計算負荷が指定された閾値 (たとえば 80%の稼働率) を超えていた場合，新たな仮想インスタンスをクラスター内に立ち上げる操作を scale-out (スケールアウト) とよび， 負荷が減った場合に不要なインスタンスを停止する操作を scale-in (スケールイン) とよぶ． クラスターのスケーリングは， ECS がほかの AWS のサービスと連携することで実現される． 具体的には， EC2 の <strong>Auto scaling group (ASG)</strong> や <strong>Fargate</strong> の２つの選択肢が多くの場合選択される． <strong>ASG</strong> については (#sec_aws_batch), Fargate については (#sec_fargate_qabot) でより詳細に解説する．</p>
<p>これら一連のタスクの管理を， ECS は自動でやってくれる． クラスターのスケーリングやタスクの配置に関してのパラメータを一度指定してしまえば，ユーザーは (ほとんどなにも考えずに) 大量のタスクを投入することができる． クラスターのスケーリングによってタスクの量にちょうど十分なだけのインスタンスが起動し，タスクが完了した後は不要なインスタンスはすべて停止される．</p>
<p>さて，ここまで説明的な話が続いてしまったが，次章からは早速 Docker と AWS を使って大規模な並列計算システムを構築していこう！</p>
<p><img src="./assets/ecs.png" alt="ECS の概要"></p>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hands-on #6: Bashoutter ]]></title>
            <link>https://note.toshiki.devdevelopment/aws/handson-bashoutter</link>
            <guid>https://note.toshiki.devdevelopment/aws/handson-bashoutter</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="hands-on-6-bashoutter" tabindex="-1">Hands-on #6: Bashoutter <a class="header-anchor" href="#hands-on-6-bashoutter" aria-label="Permalink to &quot;Hands-on \#6: Bashoutter&quot;">&ZeroWidthSpace;</a></h1>
<p>さて，最後のハンズオンとなる第六回では，これまで学んできたサーバーレスクラウドの技術を使って，簡単なウェブサービスを作ってみよう． 具体的には，人々が自分の作った俳句を投稿する SNS サービス (<strong>Bashoutter</strong> と名付ける) を作成してみよう． Lambda, DynamoDB, S3 などの技術をすべて盛り込み，シンプルながらもサーバーレスの利点を生かしたスケーラブルな SNS アプリが誕生する． 最終的には， <a href="#handson_05_bashoutter">figure_title</a> のような，ミニマルではあるがとても現代風な SNS サイトが完成する！</p>
<p><img src="./assets/handson-bashoutter/bashoutter.png" alt="ハンズオン#6で作製する SNS アプリケーション &quot;Bashoutter&quot;"></p>
<h2 id="準備" tabindex="-1">準備 <a class="header-anchor" href="#準備" aria-label="Permalink to &quot;準備&quot;">&ZeroWidthSpace;</a></h2>
<p>ハンズオンのソースコードは GitHub の <a href="https://github.com/andatoshiki/toshiki-notebooktree/main/handson/bashoutter" target="_blank" rel="noreferrer">handson/bashoutter</a> に置いてある．</p>
<p>本ハンズオンの実行には，第一回ハンズオンで説明した準備 ( (#handson_01_prep)) が整っていることを前提とする． それ以外に必要な準備はない．</p>
<p>このハンズオンは，基本的に <a href="https://aws.amazon.com/free/?all-free-tier.sort-by=item.additionalFields.SortRank&amp;all-free-tier.sort-order=asc" target="_blank" rel="noreferrer">AWS の無料枠</a> の範囲内で実行できる．</p>
<h2 id="アプリケーションの説明" tabindex="-1">アプリケーションの説明 <a class="header-anchor" href="#アプリケーションの説明" aria-label="Permalink to &quot;アプリケーションの説明&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="api" tabindex="-1">API <a class="header-anchor" href="#api" aria-label="Permalink to &quot;API&quot;">&ZeroWidthSpace;</a></h3>
<p>今回のアプリケーションでは，人々からの俳句の投稿を受け付けたり，投稿された俳句の一覧を取得する，といった機能を実装したい． この機能を実現するための最小限の設計として， <a href="#tab_handson_05_api">table_title</a> に示すような四つの REST API を今回は実装する． 俳句を投稿する，閲覧する，削除するという基本的なデータ操作を行うための API が完備されている． また， <code>PATCH /haiku/{item_id}</code> は， <code>{item_id}</code> で指定された俳句に”いいね”をするために使用する．</p>
<table><caption>Bashoutter API</caption><colgroup><col style="width: 50%" /><col style="width: 50%" /></colgroup><tbody><tr class="odd"><td><p><code>GET /haiku</code></p></td><td><p>俳句の一覧を取得する</p></td></tr><tr class="even"><td><p><code>POST /haiku</code></p></td><td><p>新しい俳句を投稿する</p></td></tr><tr class="odd"><td><p><code>PATCH /haiku/{item_id}</code></p></td><td><p><code>{item_id}</code> で指定された俳句にお気に入り票を一つ入れる</p></td></tr><tr class="even"><td><p><code>DELETE /haiku/{item_id}</code></p></td><td><p><code>{item_id}</code> で指定された俳句を削除する</p></td></tr></tbody></table>
<p>それぞれの API のパラメータおよび返り値の詳細は，ハンズオンのソースコードの中の <a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/bashoutter/specs/swagger.yml" target="_blank" rel="noreferrer">swagger.yml</a> に定義してある．</p>
<p><strong>Open API Specification</strong> (OAS; 少し前は Swagger Specification とよばれていた) は， REST API のための記述フォーマットである． OAS に従って API の仕様が記述されていると，簡単にドキュメンテーションを生成したり，クライアントアプリケーションを自動生成することができる． <a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/bashoutter/specs/swagger.yml" target="_blank" rel="noreferrer">今回用意した API 仕様</a> も， OAS に従って書いてある． 詳しくは <a href="https://swagger.io/docs/specification/about/" target="_blank" rel="noreferrer">Swagger の公式ドキュメンテーション</a> などを参照．</p>
<h3 id="アプリケーションアーキテクチャ" tabindex="-1">アプリケーションアーキテクチャ <a class="header-anchor" href="#アプリケーションアーキテクチャ" aria-label="Permalink to &quot;アプリケーションアーキテクチャ&quot;">&ZeroWidthSpace;</a></h3>
<p>このハンズオンで作成するアプリケーションの概要を <a href="#handson_05_architecture">figure_title</a> に示す．</p>
<p><img src="./assets/handson-bashoutter/handson-05-architecture.png" alt="ハンズオン#5で作製するアプリケーションのアーキテクチャ"></p>
<p>簡単にまとめると，次のような設計である．</p>
<ul>
<li>
<p>クライアントからの API リクエストは， <strong>API Gateway</strong> (後述)にまず送信され， API の URI で指定された Lambda 関数へ転送される．</p>
</li>
<li>
<p>それぞれの API のパス (リソース) ごとに独立した Lambda を用意する．</p>
</li>
<li>
<p>俳句の情報 (作者，本文，投稿日時など) を記録するためのデータベース (DynamoDB) を用意する．</p>
</li>
<li>
<p>各 Lambda 関数には， DynamoDB へのアクセス権を付与する．</p>
</li>
<li>
<p>最後に，ウェブブラウザからコンテンツを表示できるよう， ウェブページの静的コンテンツを配信するための S3 バケットを用意する．クライアントはこの S3 バケットにアクセスすることで HTML/CSS/JS などのコンテンツを取得する．</p>
</li>
</ul>
<p>それでは，プログラムのソースコードを見てみよう (<a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/bashoutter/app.py" target="_blank" rel="noreferrer">handson/bashoutter/app.py</a>)．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">class</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50">Bashoutter</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">core</span><span style="color: #ADBAC7">.</span><span style="color: #6CB6FF">Stack</span><span style="color: #ADBAC7">):</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">def</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">__init__</span><span style="color: #ADBAC7">(self, scope: core.App, name: </span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">, </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">kwargs) -&gt; </span><span style="color: #6CB6FF">None</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #6CB6FF">super</span><span style="color: #ADBAC7">().</span><span style="color: #6CB6FF">__init__</span><span style="color: #ADBAC7">(scope, name, </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">kwargs)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390"># dynamoDB table to store haiku</span></span>
<span class="line"><span style="color: #ADBAC7">        table </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ddb.Table(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;Bashoutter-Table&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">partition_key</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ddb.Attribute(</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">name</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;item_id&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">type</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ddb.AttributeType.</span><span style="color: #6CB6FF">STRING</span></span>
<span class="line"><span style="color: #ADBAC7">            ),</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">billing_mode</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ddb.BillingMode.</span><span style="color: #6CB6FF">PAY_PER_REQUEST</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">removal_policy</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">core.RemovalPolicy.</span><span style="color: #6CB6FF">DESTROY</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        bucket </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> s3.Bucket(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;Bashoutter-Bucket&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">website_index_document</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;index.html&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">public_read_access</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">True</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">removal_policy</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">core.RemovalPolicy.</span><span style="color: #6CB6FF">DESTROY</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        common_params </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> {</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #96D0FF">&quot;runtime&quot;</span><span style="color: #ADBAC7">: _lambda.Runtime.</span><span style="color: #6CB6FF">PYTHON_3_7</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #96D0FF">&quot;environment&quot;</span><span style="color: #ADBAC7">: {</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #96D0FF">&quot;TABLE_NAME&quot;</span><span style="color: #ADBAC7">: table.table_name</span></span>
<span class="line"><span style="color: #ADBAC7">            }</span></span>
<span class="line"><span style="color: #ADBAC7">        }</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390"># define Lambda functions</span></span>
<span class="line"><span style="color: #ADBAC7">        get_haiku_lambda </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> _lambda.Function(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;GetHaiku&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">code</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">_lambda.Code.from_asset(</span><span style="color: #96D0FF">&quot;api&quot;</span><span style="color: #ADBAC7">),</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">handler</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;api.get_haiku&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">memory_size</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">512</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">common_params,</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"><span style="color: #ADBAC7">        post_haiku_lambda </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> _lambda.Function(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;PostHaiku&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">code</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">_lambda.Code.from_asset(</span><span style="color: #96D0FF">&quot;api&quot;</span><span style="color: #ADBAC7">),</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">handler</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;api.post_haiku&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">common_params,</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"><span style="color: #ADBAC7">        patch_haiku_lambda </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> _lambda.Function(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;PatchHaiku&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">code</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">_lambda.Code.from_asset(</span><span style="color: #96D0FF">&quot;api&quot;</span><span style="color: #ADBAC7">),</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">handler</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;api.patch_haiku&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">common_params,</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"><span style="color: #ADBAC7">        delete_haiku_lambda </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> _lambda.Function(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;DeleteHaiku&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">code</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">_lambda.Code.from_asset(</span><span style="color: #96D0FF">&quot;api&quot;</span><span style="color: #ADBAC7">),</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">handler</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;api.delete_haiku&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">common_params,</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390"># grant permissions</span></span>
<span class="line"><span style="color: #ADBAC7">        table.grant_read_data(get_haiku_lambda)</span></span>
<span class="line"><span style="color: #ADBAC7">        table.grant_read_write_data(post_haiku_lambda)</span></span>
<span class="line"><span style="color: #ADBAC7">        table.grant_read_write_data(patch_haiku_lambda)</span></span>
<span class="line"><span style="color: #ADBAC7">        table.grant_read_write_data(delete_haiku_lambda)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390"># define API Gateway</span></span>
<span class="line"><span style="color: #ADBAC7">        api </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> apigw.RestApi(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;BashoutterApi&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">default_cors_preflight_options</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">apigw.CorsOptions(</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">allow_origins</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">apigw.Cors.</span><span style="color: #6CB6FF">ALL_ORIGINS</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">allow_methods</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">apigw.Cors.</span><span style="color: #6CB6FF">ALL_METHODS</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            )</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        haiku </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> api.root.add_resource(</span><span style="color: #96D0FF">&quot;haiku&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">        haiku.add_method(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #96D0FF">&quot;GET&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            apigw.LambdaIntegration(get_haiku_lambda)</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"><span style="color: #ADBAC7">        haiku.add_method(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #96D0FF">&quot;POST&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            apigw.LambdaIntegration(post_haiku_lambda)</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        haiku_item_id </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> haiku.add_resource(</span><span style="color: #96D0FF">&quot;</span><span style="color: #F47067">{item_id}</span><span style="color: #96D0FF">&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">        haiku_item_id.add_method(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #96D0FF">&quot;PATCH&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            apigw.LambdaIntegration(patch_haiku_lambda)</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"><span style="color: #ADBAC7">        haiku_item_id.add_method(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #96D0FF">&quot;DELETE&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            apigw.LambdaIntegration(delete_haiku_lambda)</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">class</span><span style="color: #24292E"> </span><span style="color: #6F42C1">Bashoutter</span><span style="color: #24292E">(</span><span style="color: #6F42C1">core</span><span style="color: #24292E">.</span><span style="color: #6F42C1">Stack</span><span style="color: #24292E">):</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">def</span><span style="color: #24292E"> </span><span style="color: #005CC5">__init__</span><span style="color: #24292E">(self, scope: core.App, name: </span><span style="color: #005CC5">str</span><span style="color: #24292E">, </span><span style="color: #D73A49">**</span><span style="color: #24292E">kwargs) -&gt; </span><span style="color: #005CC5">None</span><span style="color: #24292E">:</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #005CC5">super</span><span style="color: #24292E">().</span><span style="color: #005CC5">__init__</span><span style="color: #24292E">(scope, name, </span><span style="color: #D73A49">**</span><span style="color: #24292E">kwargs)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D"># dynamoDB table to store haiku</span></span>
<span class="line"><span style="color: #24292E">        table </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ddb.Table(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;Bashoutter-Table&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">partition_key</span><span style="color: #D73A49">=</span><span style="color: #24292E">ddb.Attribute(</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">name</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;item_id&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">type</span><span style="color: #D73A49">=</span><span style="color: #24292E">ddb.AttributeType.</span><span style="color: #005CC5">STRING</span></span>
<span class="line"><span style="color: #24292E">            ),</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">billing_mode</span><span style="color: #D73A49">=</span><span style="color: #24292E">ddb.BillingMode.</span><span style="color: #005CC5">PAY_PER_REQUEST</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">removal_policy</span><span style="color: #D73A49">=</span><span style="color: #24292E">core.RemovalPolicy.</span><span style="color: #005CC5">DESTROY</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        bucket </span><span style="color: #D73A49">=</span><span style="color: #24292E"> s3.Bucket(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;Bashoutter-Bucket&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">website_index_document</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;index.html&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">public_read_access</span><span style="color: #D73A49">=</span><span style="color: #005CC5">True</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">removal_policy</span><span style="color: #D73A49">=</span><span style="color: #24292E">core.RemovalPolicy.</span><span style="color: #005CC5">DESTROY</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        common_params </span><span style="color: #D73A49">=</span><span style="color: #24292E"> {</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #032F62">&quot;runtime&quot;</span><span style="color: #24292E">: _lambda.Runtime.</span><span style="color: #005CC5">PYTHON_3_7</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #032F62">&quot;environment&quot;</span><span style="color: #24292E">: {</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #032F62">&quot;TABLE_NAME&quot;</span><span style="color: #24292E">: table.table_name</span></span>
<span class="line"><span style="color: #24292E">            }</span></span>
<span class="line"><span style="color: #24292E">        }</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D"># define Lambda functions</span></span>
<span class="line"><span style="color: #24292E">        get_haiku_lambda </span><span style="color: #D73A49">=</span><span style="color: #24292E"> _lambda.Function(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;GetHaiku&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">code</span><span style="color: #D73A49">=</span><span style="color: #24292E">_lambda.Code.from_asset(</span><span style="color: #032F62">&quot;api&quot;</span><span style="color: #24292E">),</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">handler</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;api.get_haiku&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">memory_size</span><span style="color: #D73A49">=</span><span style="color: #005CC5">512</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #D73A49">**</span><span style="color: #24292E">common_params,</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"><span style="color: #24292E">        post_haiku_lambda </span><span style="color: #D73A49">=</span><span style="color: #24292E"> _lambda.Function(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;PostHaiku&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">code</span><span style="color: #D73A49">=</span><span style="color: #24292E">_lambda.Code.from_asset(</span><span style="color: #032F62">&quot;api&quot;</span><span style="color: #24292E">),</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">handler</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;api.post_haiku&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #D73A49">**</span><span style="color: #24292E">common_params,</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"><span style="color: #24292E">        patch_haiku_lambda </span><span style="color: #D73A49">=</span><span style="color: #24292E"> _lambda.Function(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;PatchHaiku&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">code</span><span style="color: #D73A49">=</span><span style="color: #24292E">_lambda.Code.from_asset(</span><span style="color: #032F62">&quot;api&quot;</span><span style="color: #24292E">),</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">handler</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;api.patch_haiku&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #D73A49">**</span><span style="color: #24292E">common_params,</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"><span style="color: #24292E">        delete_haiku_lambda </span><span style="color: #D73A49">=</span><span style="color: #24292E"> _lambda.Function(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;DeleteHaiku&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">code</span><span style="color: #D73A49">=</span><span style="color: #24292E">_lambda.Code.from_asset(</span><span style="color: #032F62">&quot;api&quot;</span><span style="color: #24292E">),</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">handler</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;api.delete_haiku&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #D73A49">**</span><span style="color: #24292E">common_params,</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D"># grant permissions</span></span>
<span class="line"><span style="color: #24292E">        table.grant_read_data(get_haiku_lambda)</span></span>
<span class="line"><span style="color: #24292E">        table.grant_read_write_data(post_haiku_lambda)</span></span>
<span class="line"><span style="color: #24292E">        table.grant_read_write_data(patch_haiku_lambda)</span></span>
<span class="line"><span style="color: #24292E">        table.grant_read_write_data(delete_haiku_lambda)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D"># define API Gateway</span></span>
<span class="line"><span style="color: #24292E">        api </span><span style="color: #D73A49">=</span><span style="color: #24292E"> apigw.RestApi(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;BashoutterApi&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">default_cors_preflight_options</span><span style="color: #D73A49">=</span><span style="color: #24292E">apigw.CorsOptions(</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">allow_origins</span><span style="color: #D73A49">=</span><span style="color: #24292E">apigw.Cors.</span><span style="color: #005CC5">ALL_ORIGINS</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">allow_methods</span><span style="color: #D73A49">=</span><span style="color: #24292E">apigw.Cors.</span><span style="color: #005CC5">ALL_METHODS</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            )</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        haiku </span><span style="color: #D73A49">=</span><span style="color: #24292E"> api.root.add_resource(</span><span style="color: #032F62">&quot;haiku&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">        haiku.add_method(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #032F62">&quot;GET&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            apigw.LambdaIntegration(get_haiku_lambda)</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"><span style="color: #24292E">        haiku.add_method(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #032F62">&quot;POST&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            apigw.LambdaIntegration(post_haiku_lambda)</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        haiku_item_id </span><span style="color: #D73A49">=</span><span style="color: #24292E"> haiku.add_resource(</span><span style="color: #032F62">&quot;</span><span style="color: #005CC5">{item_id}</span><span style="color: #032F62">&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">        haiku_item_id.add_method(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #032F62">&quot;PATCH&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            apigw.LambdaIntegration(patch_haiku_lambda)</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"><span style="color: #24292E">        haiku_item_id.add_method(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #032F62">&quot;DELETE&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            apigw.LambdaIntegration(delete_haiku_lambda)</span></span>
<span class="line"><span style="color: #24292E">        )</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br><span class="line-number">36</span><br><span class="line-number">37</span><br><span class="line-number">38</span><br><span class="line-number">39</span><br><span class="line-number">40</span><br><span class="line-number">41</span><br><span class="line-number">42</span><br><span class="line-number">43</span><br><span class="line-number">44</span><br><span class="line-number">45</span><br><span class="line-number">46</span><br><span class="line-number">47</span><br><span class="line-number">48</span><br><span class="line-number">49</span><br><span class="line-number">50</span><br><span class="line-number">51</span><br><span class="line-number">52</span><br><span class="line-number">53</span><br><span class="line-number">54</span><br><span class="line-number">55</span><br><span class="line-number">56</span><br><span class="line-number">57</span><br><span class="line-number">58</span><br><span class="line-number">59</span><br><span class="line-number">60</span><br><span class="line-number">61</span><br><span class="line-number">62</span><br><span class="line-number">63</span><br><span class="line-number">64</span><br><span class="line-number">65</span><br><span class="line-number">66</span><br><span class="line-number">67</span><br><span class="line-number">68</span><br><span class="line-number">69</span><br><span class="line-number">70</span><br><span class="line-number">71</span><br><span class="line-number">72</span><br><span class="line-number">73</span><br><span class="line-number">74</span><br><span class="line-number">75</span><br><span class="line-number">76</span><br><span class="line-number">77</span><br><span class="line-number">78</span><br><span class="line-number">79</span><br><span class="line-number">80</span><br><span class="line-number">81</span><br><span class="line-number">82</span><br><span class="line-number">83</span><br><span class="line-number">84</span><br><span class="line-number">85</span><br><span class="line-number">86</span><br><span class="line-number">87</span><br><span class="line-number">88</span><br><span class="line-number">89</span><br><span class="line-number">90</span><br><span class="line-number">91</span><br><span class="line-number">92</span><br><span class="line-number">93</span><br><span class="line-number">94</span><br><span class="line-number">95</span><br><span class="line-number">96</span><br></div></div><ul>
<li>
<p>ここで，俳句の情報を記録しておくための DynamoDB テーブルを定義している．</p>
</li>
<li>
<p>静的コンテンツを配信するための S3 バケットを用意している．</p>
</li>
<li>
<p>それぞれの API で実行される Lambda 関数を定義している． 関数は Python3.7 で書かれており，コードは <a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/bashoutter/api/api.py" target="_blank" rel="noreferrer">handson/bashoutter/api/api.py</a> にある．</p>
</li>
<li>
<p>&lt;3&gt; で定義された Lambda 関数に対し，データベースへの読み書きのアクセス権限を付与している．</p>
</li>
<li>
<p>ここで，API Gateway により，各 API パスとそこで実行されるべき Lambda 関数を紐付けている．</p>
</li>
</ul>
<p>それぞれの項目について，もう少し詳しく説明しよう．</p>
<h3 id="public-access-mode-の-s3-バケット" tabindex="-1">Public access mode の S3 バケット <a class="header-anchor" href="#public-access-mode-の-s3-バケット" aria-label="Permalink to &quot;Public access mode の S3 バケット&quot;">&ZeroWidthSpace;</a></h3>
<p>S3 のバケットを作成しているコードを見てみよう．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">bucket </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> s3.Bucket(</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;Bashoutter-Bucket&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">website_index_document</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;index.html&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">public_read_access</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">True</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">removal_policy</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">core.RemovalPolicy.</span><span style="color: #6CB6FF">DESTROY</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">bucket </span><span style="color: #D73A49">=</span><span style="color: #24292E"> s3.Bucket(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;Bashoutter-Bucket&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">website_index_document</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;index.html&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">public_read_access</span><span style="color: #D73A49">=</span><span style="color: #005CC5">True</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">removal_policy</span><span style="color: #D73A49">=</span><span style="color: #24292E">core.RemovalPolicy.</span><span style="color: #005CC5">DESTROY</span></span>
<span class="line"><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br></div></div><p>ここで注目してほしいのは <code>public_read_access=True</code> の部分だ． 前章で， S3 について説明を行ったときには触れなかったが， S3 には <strong>Public access mode</strong> という機能がある． Public access mode をオンにしておくと，バケットの中のファイルは認証なしで (i.e. インターネット上の誰でも) 閲覧できるようになる． この設定は，一般公開されているウェブサイトの静的なコンテンツを置いておくのに最適であり，多くのサーバーレスによるウェブサービスでこのような設計が行われる． public access mode を設定しておくと， <code>http://XXXX.s3-website-ap-northeast-1.amazonaws.com/</code> のような固有の URL がバケットに対して付与される． そして，クライアントがこの URL にアクセスをすると，バケットの中にある <code>index.html</code> がクライアントに返され，ページがロードされる (どのファイルが返されるかは， <code>website_index_document=&quot;index.html&quot;</code> の部分で設定している．)</p>
<p>なお，この時点ではバケットは空である． HTML/CSS/JS など静的コンテンツの配置は，デプロイを行った後ほどのステップで行う．</p>
<p>より本格的なウェブページを運用する際には， public access mode の S3 バケットに， <a href="https://aws.amazon.com/cloudfront/" target="_blank" rel="noreferrer">CloudFront</a> という機能を追加することが一般的である． CloudFront により，　<strong>Content Delivery Nework (CDN)</strong> や暗号化された HTTPS 通信を設定することができる． CloudFront についての詳細は <a href="https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Introduction.html" target="_blank" rel="noreferrer">公式ドキュメンテーション &quot;What is Amazon CloudFront?&quot;</a> などを参照いただきたい．</p>
<p>今回のハンズオンでは説明の簡略化のため CloudFront の設定を行わなかったが，興味のある読者は次のリンクのプログラムが参考になるだろう．</p>
<ul>
<li><a href="https://github.com/aws-samples/aws-cdk-examples/tree/master/typescript/static-site" target="_blank" rel="noreferrer">https://github.com/aws-samples/aws-cdk-examples/tree/master/typescript/static-site</a></li>
</ul>
<p>今回の S3 バケットには， AWS によって付与されたランダムな URL がついている． これを． <code>example.com</code> のような自分のドメインでホストしたければ， AWS によって付与された URL を自分のドメインの DNS レコードに追加すればよい．</p>
<h3 id="api-のハンドラ関数" tabindex="-1">API のハンドラ関数 <a class="header-anchor" href="#api-のハンドラ関数" aria-label="Permalink to &quot;API のハンドラ関数&quot;">&ZeroWidthSpace;</a></h3>
<p>API リクエストが来たときに，リクエストされた処理を行う関数のことをハンドラ (handler) 関数とよぶ． <code>GET /haiku</code> の API に対してのハンドラ関数を Lambda で定義している部分を見てみよう．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">get_haiku_lambda </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> _lambda.Function(</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;GetHaiku&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">code</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">_lambda.Code.from_asset(</span><span style="color: #96D0FF">&quot;api&quot;</span><span style="color: #ADBAC7">),</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">handler</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;api.get_haiku&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">memory_size</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">512</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">common_params</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">get_haiku_lambda </span><span style="color: #D73A49">=</span><span style="color: #24292E"> _lambda.Function(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;GetHaiku&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">code</span><span style="color: #D73A49">=</span><span style="color: #24292E">_lambda.Code.from_asset(</span><span style="color: #032F62">&quot;api&quot;</span><span style="color: #24292E">),</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">handler</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;api.get_haiku&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">memory_size</span><span style="color: #D73A49">=</span><span style="color: #005CC5">512</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">**</span><span style="color: #24292E">common_params</span></span>
<span class="line"><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br></div></div><p>簡単なところから見ていくと， <code>memory_size=512</code> の箇所でメモリーの使用量を 512MB に指定している． また， <code>code=_lambda.Code.from_asset(&quot;api&quot;)</code> によって外部のディレクトリ (<code>api/</code>) を参照せよと指定しており， <code>handler=&quot;api.get_haiku&quot;</code> のところで <code>api.py</code> というファイルの <code>get_haiku()</code> という関数をハンドラ関数として実行せよ，と定義している．</p>
<p>次に，ハンドラ関数として使用されている <code>get_haiku()</code> のコードを見てみよう (<a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/bashoutter/api/api.py" target="_blank" rel="noreferrer">handson/bashoutter/api/api.py</a>)．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">ddb </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> boto3.resource(</span><span style="color: #96D0FF">&quot;dynamodb&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">table </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ddb.Table(os.environ[</span><span style="color: #96D0FF">&quot;TABLE_NAME&quot;</span><span style="color: #ADBAC7">])</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F47067">def</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">get_haiku</span><span style="color: #ADBAC7">(event, context):</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #96D0FF">&quot;&quot;&quot;</span></span>
<span class="line"><span style="color: #96D0FF">    handler for GET /haiku</span></span>
<span class="line"><span style="color: #96D0FF">    &quot;&quot;&quot;</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">try</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">        response </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> table.scan()</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        status_code </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">200</span></span>
<span class="line"><span style="color: #ADBAC7">        resp </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> response.get(</span><span style="color: #96D0FF">&quot;Items&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">except</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">Exception</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">as</span><span style="color: #ADBAC7"> e:</span></span>
<span class="line"><span style="color: #ADBAC7">        status_code </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">500</span></span>
<span class="line"><span style="color: #ADBAC7">        resp </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> {</span><span style="color: #96D0FF">&quot;description&quot;</span><span style="color: #ADBAC7">: </span><span style="color: #F47067">f</span><span style="color: #96D0FF">&quot;Internal server error. </span><span style="color: #F47067">{</span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">(e)</span><span style="color: #F47067">}</span><span style="color: #96D0FF">&quot;</span><span style="color: #ADBAC7">}</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">return</span><span style="color: #ADBAC7"> {</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #96D0FF">&quot;statusCode&quot;</span><span style="color: #ADBAC7">: status_code,</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #96D0FF">&quot;headers&quot;</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">HEADERS</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #96D0FF">&quot;body&quot;</span><span style="color: #ADBAC7">: json.dumps(resp, </span><span style="color: #F69D50">cls</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">DecimalEncoder)</span></span>
<span class="line"><span style="color: #ADBAC7">    }</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">ddb </span><span style="color: #D73A49">=</span><span style="color: #24292E"> boto3.resource(</span><span style="color: #032F62">&quot;dynamodb&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">table </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ddb.Table(os.environ[</span><span style="color: #032F62">&quot;TABLE_NAME&quot;</span><span style="color: #24292E">])</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D73A49">def</span><span style="color: #24292E"> </span><span style="color: #6F42C1">get_haiku</span><span style="color: #24292E">(event, context):</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #032F62">&quot;&quot;&quot;</span></span>
<span class="line"><span style="color: #032F62">    handler for GET /haiku</span></span>
<span class="line"><span style="color: #032F62">    &quot;&quot;&quot;</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">try</span><span style="color: #24292E">:</span></span>
<span class="line"><span style="color: #24292E">        response </span><span style="color: #D73A49">=</span><span style="color: #24292E"> table.scan()</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        status_code </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #005CC5">200</span></span>
<span class="line"><span style="color: #24292E">        resp </span><span style="color: #D73A49">=</span><span style="color: #24292E"> response.get(</span><span style="color: #032F62">&quot;Items&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">except</span><span style="color: #24292E"> </span><span style="color: #005CC5">Exception</span><span style="color: #24292E"> </span><span style="color: #D73A49">as</span><span style="color: #24292E"> e:</span></span>
<span class="line"><span style="color: #24292E">        status_code </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #005CC5">500</span></span>
<span class="line"><span style="color: #24292E">        resp </span><span style="color: #D73A49">=</span><span style="color: #24292E"> {</span><span style="color: #032F62">&quot;description&quot;</span><span style="color: #24292E">: </span><span style="color: #D73A49">f</span><span style="color: #032F62">&quot;Internal server error. </span><span style="color: #005CC5">{str</span><span style="color: #24292E">(e)</span><span style="color: #005CC5">}</span><span style="color: #032F62">&quot;</span><span style="color: #24292E">}</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">return</span><span style="color: #24292E"> {</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #032F62">&quot;statusCode&quot;</span><span style="color: #24292E">: status_code,</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #032F62">&quot;headers&quot;</span><span style="color: #24292E">: </span><span style="color: #005CC5">HEADERS</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #032F62">&quot;body&quot;</span><span style="color: #24292E">: json.dumps(resp, </span><span style="color: #E36209">cls</span><span style="color: #D73A49">=</span><span style="color: #24292E">DecimalEncoder)</span></span>
<span class="line"><span style="color: #24292E">    }</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br></div></div><p><code>response = table.scan()</code> で，俳句の格納された DynamoDB テーブルから，すべての要素を取り出している． もしなにもエラーが起きなければステータスコード 200 が返され，もしなにかエラーが起こればステータスコード 500 が返されるようになっている．</p>
<p>上記のような操作を，ほかの API についても繰り返すことで，すべての API のハンドラ関数が定義されている．</p>
<p><code>GET /haiku</code> のハンドラ関数で， <code>response = table.scan()</code> という部分があるが，実はこれは最善の書き方ではない． DynamoDB の <code>scan()</code> メソッドは，最大で 1MB までのデータしか返さない． データベースのサイズが大きく， 1MB 以上のデータがある場合には，再帰的に <code>scan()</code> メソッドをよぶ必要がある． 詳しくは <a href="https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/dynamodb.html#DynamoDB.Table.scan" target="_blank" rel="noreferrer">boto3 ドキュメンテーション</a> を参照．</p>
<h3 id="aws-における権限の管理-iam" tabindex="-1">AWS における権限の管理 (IAM) <a class="header-anchor" href="#aws-における権限の管理-iam" aria-label="Permalink to &quot;AWS における権限の管理 (IAM)&quot;">&ZeroWidthSpace;</a></h3>
<p>以下の部分のコードに注目してほしい．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">table.grant_read_data(get_haiku_lambda)</span></span>
<span class="line"><span style="color: #ADBAC7">table.grant_read_write_data(post_haiku_lambda)</span></span>
<span class="line"><span style="color: #ADBAC7">table.grant_read_write_data(patch_haiku_lambda)</span></span>
<span class="line"><span style="color: #ADBAC7">table.grant_read_write_data(delete_haiku_lambda)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">table.grant_read_data(get_haiku_lambda)</span></span>
<span class="line"><span style="color: #24292E">table.grant_read_write_data(post_haiku_lambda)</span></span>
<span class="line"><span style="color: #24292E">table.grant_read_write_data(patch_haiku_lambda)</span></span>
<span class="line"><span style="color: #24292E">table.grant_read_write_data(delete_haiku_lambda)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br></div></div><p>これまでは説明の簡略化のためにあえて触れてこなかったが， AWS には <a href="https://aws.amazon.com/iam/" target="_blank" rel="noreferrer">IAM (Identity and Access Management)</a> という重要な概念がある． IAM は基本的に，あるリソースがほかのリソースに対してどのような権限をもっているか，を規定するものである． Lambda は，デフォルトの状態ではほかのリソースにアクセスする権限をなにも有していない． したがって， Lambda 関数が DynamoDB のデータを読み書きするためには，それを許可するような IAM が Lambda 関数に付与されていなければならない．今回の S3 バケットには， AWS によって付与されたランダムな URL がついている． これを． <code>example.com</code> のような自分のドメインでホストしたければ， AWS によって付与された URL を自分のドメインの DNS レコードに追加すればよい．</p>
<p>CDK による <code>dynamodb.Table</code> オブジェクトには <code>grant_read_write_data()</code> という便利なメソッドが備わっており，アクセスを許可したい Lambda 関数を引数としてこのメソッドを呼ぶことで，データベースへの読み書きを許可する IAM を付与することができる． 同様に，CDK の <code>s3.Bucket</code> オブジェクトにも <code>grant_read_write()</code> というメソッドが備わっており，これによってバケットへの読み書きを許可することができる． このメソッドは，実は (#sec_aws_batch) で AWS Batch によるクラスターを構成した際に使用した． 興味のある読者は振り返ってコードを確認してみよう．</p>
<p>各リソースに付与する IAM は，<strong>必要最低限の権限を与えるにとどめる</strong>というのが基本方針である． これにより，セキュリティを向上させるだけでなく，意図していないプログラムからのデータベースへの読み書きを防止するという点で，バグを未然に防ぐことができる．</p>
<p>そのような理由により，このコードでは <code>GET</code> のハンドラー関数に対しては <code>grant_read_data()</code> によって， read 権限のみを付与している．</p>
<h3 id="api-gateway" tabindex="-1">API Gateway <a class="header-anchor" href="#api-gateway" aria-label="Permalink to &quot;API Gateway&quot;">&ZeroWidthSpace;</a></h3>
<p><a href="https://aws.amazon.com/api-gateway/" target="_blank" rel="noreferrer">API Gateway</a> とは， API の&quot;入り口&quot;として，API のリクエストパスに従って Lambda や EC2 などに接続を行うという機能を担う (<a href="#fig:bashoutter_api_gateway">figure_title</a>)． Lambda や EC2 によって行われた処理の結果は，再び API Gateway を経由してクライアントに返される． このように，クライアントとバックエンドサーバーの間に立ち， API のリソースパスに応じて接続先を振り分けるようなサーバーを<strong>ルーター</strong>，あるいは<strong>リバースプロキシ</strong>とよんだりする． 従来的には，ルーターにはそれ専用の仮想サーバーが置かれることが一般的であった． しかし， API Gateway はサーバーレスなルーターとして，固定されたサーバーを配置することなく， API のリクエストが来たときのみ起動し，API のルーティングを実行する． サーバーレスであることの当然の帰結として，アクセスの件数が増大したときにはそれにルーティングの処理能力を自動で増やす機能も備わっている．</p>
<p><img src="./assets/handson-bashoutter/api_gateway.png" alt="API Gateway"></p>
<p>API Gateway を配置することで，大量 (1 秒間に数千から数万件) の API リクエストに対応することのできるシステムを容易に構築することができる． API Gateway の料金は <a href="#tab_handson_05_apigateway_price">table_title</a> のように設定されている． また，無料利用枠により，月ごとに 100 万件までのリクエストは 0 円で利用できる．</p>
<table><caption>API Gateway の利用料金設定 (<a href="https://aws.amazon.com/api-gateway/pricing/">参照</a>)</caption><colgroup><col style="width: 50%" /><col style="width: 50%" /></colgroup><thead><tr class="header"><th>Number of Requests (per month)</th><th>Price (per million)</th></tr></thead><tbody><tr class="odd"><td><p>First 333 million</p></td><td><p>$4.25</p></td></tr><tr class="even"><td><p>Next 667 million</p></td><td><p>$3.53</p></td></tr><tr class="odd"><td><p>Next 19 billion</p></td><td><p>$3.00</p></td></tr><tr class="even"><td><p>Over 20 billion</p></td><td><p>$1.91</p></td></tr></tbody></table>
<p>ソースコードの該当箇所を見てみよう．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">api </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> apigw.RestApi(</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;BashoutterApi&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">default_cors_preflight_options</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">apigw.CorsOptions(</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #F69D50">allow_origins</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">apigw.Cors.</span><span style="color: #6CB6FF">ALL_ORIGINS</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #F69D50">allow_methods</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">apigw.Cors.</span><span style="color: #6CB6FF">ALL_METHODS</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    )</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">haiku </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> api.root.add_resource(</span><span style="color: #96D0FF">&quot;haiku&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">haiku.add_method(</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #96D0FF">&quot;GET&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    apigw.LambdaIntegration(get_haiku_lambda)</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">haiku.add_method(</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #96D0FF">&quot;POST&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    apigw.LambdaIntegration(post_haiku_lambda)</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">haiku_item_id </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> haiku.add_resource(</span><span style="color: #96D0FF">&quot;</span><span style="color: #F47067">{item_id}</span><span style="color: #96D0FF">&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">haiku_item_id.add_method(</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #96D0FF">&quot;PATCH&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    apigw.LambdaIntegration(patch_haiku_lambda)</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">haiku_item_id.add_method(</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #96D0FF">&quot;DELETE&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    apigw.LambdaIntegration(delete_haiku_lambda)</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">api </span><span style="color: #D73A49">=</span><span style="color: #24292E"> apigw.RestApi(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;BashoutterApi&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">default_cors_preflight_options</span><span style="color: #D73A49">=</span><span style="color: #24292E">apigw.CorsOptions(</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #E36209">allow_origins</span><span style="color: #D73A49">=</span><span style="color: #24292E">apigw.Cors.</span><span style="color: #005CC5">ALL_ORIGINS</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #E36209">allow_methods</span><span style="color: #D73A49">=</span><span style="color: #24292E">apigw.Cors.</span><span style="color: #005CC5">ALL_METHODS</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    )</span></span>
<span class="line"><span style="color: #24292E">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">haiku </span><span style="color: #D73A49">=</span><span style="color: #24292E"> api.root.add_resource(</span><span style="color: #032F62">&quot;haiku&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">haiku.add_method(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #032F62">&quot;GET&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    apigw.LambdaIntegration(get_haiku_lambda)</span></span>
<span class="line"><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">haiku.add_method(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #032F62">&quot;POST&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    apigw.LambdaIntegration(post_haiku_lambda)</span></span>
<span class="line"><span style="color: #24292E">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">haiku_item_id </span><span style="color: #D73A49">=</span><span style="color: #24292E"> haiku.add_resource(</span><span style="color: #032F62">&quot;</span><span style="color: #005CC5">{item_id}</span><span style="color: #032F62">&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">haiku_item_id.add_method(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #032F62">&quot;PATCH&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    apigw.LambdaIntegration(patch_haiku_lambda)</span></span>
<span class="line"><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">haiku_item_id.add_method(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #032F62">&quot;DELETE&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    apigw.LambdaIntegration(delete_haiku_lambda)</span></span>
<span class="line"><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br></div></div><ul>
<li>
<p>最初に， <code>api = apigw.RestApi()</code> により，空の API Gateway を作成している．</p>
</li>
<li>
<p>次に， <code>api.root.add_resource()</code> のメソッドを呼ぶことで， <code>/haiku</code> という API パスを追加している．</p>
</li>
<li>
<p>続いて， <code>add_method()</code> を呼ぶことで， <code>GET</code>, <code>POST</code> のメソッドを <code>/haiku</code> のパスに定義している．</p>
</li>
<li>
<p>さらに， <code>haiku.add_resource(&quot;{item_id}&quot;)</code> により， <code>/haiku/{item_id}</code> という API パスを追加している．</p>
</li>
<li>
<p>最後に， <code>add_method()</code> を呼ぶことにより， <code>PATCH</code>, <code>DELETE</code> のメソッドを <code>/haiku/{item_id}</code> のパスに定義している．</p>
</li>
</ul>
<p>このように， API Gateway の使い方は非常にシンプルで，逐次的に API パスとそこで実行されるメソッド・Lambda を記述していくだけでよい．</p>
<p>このプログラムで 新規 API を作成すると， ランダムな URL がその API のエンドポイントとして割り当てられる． これを． <code>api.example.com</code> のような自分のドメインでホストしたければ， AWS によって付与された URL を自分のドメインの DNS レコードに追加すればよい．</p>
<p>API Gateway で新規 API を作成したとき， <code>default_cors_preflight_options=</code> というパラメータで <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS" target="_blank" rel="noreferrer">Cross Origin Resource Sharing (CORS)</a> の設定を行っている． これは，ブラウザで走る Web アプリケーションと API を接続するときに必要な設定である．</p>
<h2 id="アプリケーションのデプロイ" tabindex="-1">アプリケーションのデプロイ <a class="header-anchor" href="#アプリケーションのデプロイ" aria-label="Permalink to &quot;アプリケーションのデプロイ&quot;">&ZeroWidthSpace;</a></h2>
<p>アプリケーションの中身が理解できたところで，早速デプロイを行ってみよう． デプロイの手順は，これまでのハンズオンとほとんど共通である． ここでは，コマンドのみ列挙する (<code>#</code> で始まる行はコメントである)． シークレットキーの設定も忘れずに ( (#aws_cli_install))．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390"># プロジェクトのディレクトリに移動</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cd</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">intro-aws/handson/bashoutter</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># venv を作成し，依存ライブラリのインストールを行う</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python3</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-m</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">venv</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.env</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">source</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.env/bin/activate</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">pip</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">install</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-r</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">requirements.txt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># デプロイを実行</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cdk</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">deploy</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D"># プロジェクトのディレクトリに移動</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cd</span><span style="color: #24292E"> </span><span style="color: #032F62">intro-aws/handson/bashoutter</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># venv を作成し，依存ライブラリのインストールを行う</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python3</span><span style="color: #24292E"> </span><span style="color: #005CC5">-m</span><span style="color: #24292E"> </span><span style="color: #032F62">venv</span><span style="color: #24292E"> </span><span style="color: #032F62">.env</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">source</span><span style="color: #24292E"> </span><span style="color: #032F62">.env/bin/activate</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">pip</span><span style="color: #24292E"> </span><span style="color: #032F62">install</span><span style="color: #24292E"> </span><span style="color: #005CC5">-r</span><span style="color: #24292E"> </span><span style="color: #032F62">requirements.txt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># デプロイを実行</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cdk</span><span style="color: #24292E"> </span><span style="color: #032F62">deploy</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br></div></div><p>デプロイのコマンドが無事に実行されれば， <a href="#handson_05_cdk_output">figure_title</a> のような出力が得られるはずである． ここで表示されている <code>Bashoutter.BashoutterApiEndpoint = XXXX</code>, <code>Bashoutter.BucketUrl = YYYY</code> の二つ文字列はあとで使うのでメモしておこう．</p>
<p><img src="./assets/handson-bashoutter/cdk_output.png" alt="CDKデプロイ実行後の出力"></p>
<p>AWS コンソールにログインして，デプロイされたスタックを確認してみよう． まずは，コンソールから API Gateway のページに行く． すると， <a href="#handson_05_apigw_console_list">figure_title</a> のような画面が表示され，デプロイ済みの API エンドポイントの一覧が確認できる．</p>
<p><img src="./assets/handson-bashoutter/apigw_console_list.png" alt="API Gateway コンソール画面 (1)"></p>
<p>今回デプロイした &quot;BashoutterApi&quot; という名前の API をクリックすることで <a href="#handson_05_apigw_console_detail">figure_title</a> のような画面に遷移し，詳細情報を閲覧できる． <code>GET /haiku</code>, <code>POST /haiku</code> などが定義されていることが確認できる．</p>
<p>それぞれのメソッドをクリックすると，そのメソッドの詳細情報を確認できる． API Gateway は，前述したルーティングの機能だけでなく，認証機能などを追加することも可能である． このハンズオンではとくにこれらの機能は使用しないが， &quot;Method Request&quot; と書いてある項目などがそれに相当する． 次に， <a href="#handson_05_apigw_console_detail">figure_title</a> で画面右端の赤色で囲った部分に，この API で呼ばれる Lambda 関数が指定されていることに注目しよう． 関数名をクリックと，該当する Lambda のコンソールに遷移し，関数の中身を閲覧することが可能である．</p>
<p><img src="./assets/handson-bashoutter/apigw_console_detail.png" alt="API Gateway コンソール画面 (2)"></p>
<p>次に， S3 のコンソール画面に移ってみよう． <code>bashouter-</code> で始まるランダムな名前のバケットが見つかるはずである (<a href="#handson_05_s3_console">figure_title</a>)．</p>
<p><img src="./assets/handson-bashoutter/s3_console.png" alt="S3 コンソール画面"></p>
<p>バケットの名前をクリックすることで，バケットの中身を確認してみよう． <code>index.html</code> のほか， <code>css/</code>, <code>js/</code> などのディレクトリがあるのが確認できるだろう (<a href="#handson_05_s3_contents">figure_title</a>)． これらが，ウェブページの&quot;枠&quot;を定義している静的コンテンツである．</p>
<p><img src="./assets/handson-bashoutter/s3_contents.png" alt="S3 バケットの中身"></p>
<h2 id="api-リクエストを送信する" tabindex="-1">API リクエストを送信する <a class="header-anchor" href="#api-リクエストを送信する" aria-label="Permalink to &quot;API リクエストを送信する&quot;">&ZeroWidthSpace;</a></h2>
<p>それでは，デプロイしたアプリケーションに対し，実際に API リクエストを送信してみよう． まずはコマンドラインから API を送信する演習を行おう． S3 に配置した GUI は一旦おいておく．</p>
<p>ここではコマンドラインから HTTP API リクエストを送信するためのシンプルな HTTP クライアントである <a href="https://httpie.org/" target="_blank" rel="noreferrer">HTTPie</a> を使ってみよう． HTTPie は，スタックをデプロイするときに Python 仮想環境 (venv) を作成したとき，一緒にインストールされている． 念のためインストールがうまくいっているか確認するには，仮想環境を立ち上げたあとコマンドラインに <code>http</code> と打ってみる． ヘルプのメッセージが出力されたら準備 OK である．</p>
<p>まず，先ほどデプロイを実行したときに得られた API のエンドポイントの URL (<code>Bashoutter.BashoutterApiEndpoint = XXXX</code> で得られた <code>XXXX</code> の文字列) をコマンドラインの変数に設定しておく．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">export</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ENDPOINT_URL=XXXX</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">export</span><span style="color: #24292E"> </span><span style="color: #032F62">ENDPOINT_URL=XXXX</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>次に，俳句の一覧を取得するため， <code>GET /haiku</code> の API を送信してみよう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">http</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">GET</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;${</span><span style="color: #ADBAC7">ENDPOINT_URL</span><span style="color: #96D0FF">}/haiku&quot;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">http</span><span style="color: #24292E"> </span><span style="color: #032F62">GET</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;${</span><span style="color: #24292E">ENDPOINT_URL</span><span style="color: #032F62">}/haiku&quot;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>現時点では，まだだれも俳句を投稿していないので，空の配列 (<code>[]</code>) が返ってくる．</p>
<p>それでは次に， <code>POST /haiku</code> を使って俳句を投稿してみよう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">http</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">POST</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;${</span><span style="color: #ADBAC7">ENDPOINT_URL</span><span style="color: #96D0FF">}/haiku&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">\</span></span>
<span class="line"><span style="color: #ADBAC7">username=</span><span style="color: #96D0FF">&quot;松尾芭蕉&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">\</span></span>
<span class="line"><span style="color: #ADBAC7">first=</span><span style="color: #96D0FF">&quot;閑さや&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">\</span></span>
<span class="line"><span style="color: #ADBAC7">second=</span><span style="color: #96D0FF">&quot;岩にしみ入る&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">\</span></span>
<span class="line"><span style="color: #ADBAC7">third=</span><span style="color: #96D0FF">&quot;蝉の声&quot;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">http</span><span style="color: #24292E"> </span><span style="color: #032F62">POST</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;${</span><span style="color: #24292E">ENDPOINT_URL</span><span style="color: #032F62">}/haiku&quot;</span><span style="color: #24292E"> </span><span style="color: #005CC5">\</span></span>
<span class="line"><span style="color: #24292E">username=</span><span style="color: #032F62">&quot;松尾芭蕉&quot;</span><span style="color: #24292E"> </span><span style="color: #005CC5">\</span></span>
<span class="line"><span style="color: #24292E">first=</span><span style="color: #032F62">&quot;閑さや&quot;</span><span style="color: #24292E"> </span><span style="color: #005CC5">\</span></span>
<span class="line"><span style="color: #24292E">second=</span><span style="color: #032F62">&quot;岩にしみ入る&quot;</span><span style="color: #24292E"> </span><span style="color: #005CC5">\</span></span>
<span class="line"><span style="color: #24292E">third=</span><span style="color: #032F62">&quot;蝉の声&quot;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br></div></div><p>次のような出力が得られるだろう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">HTTP/1.1</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">201</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">Created</span></span>
<span class="line"><span style="color: #F69D50">Connection:</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">keep-alive</span></span>
<span class="line"><span style="color: #F69D50">Content-Length:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">49</span></span>
<span class="line"><span style="color: #F69D50">Content-Type:</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">application/json</span></span>
<span class="line"><span style="color: #6CB6FF">....</span></span>
<span class="line"><span style="color: #ADBAC7">{</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">&quot;description&quot;</span><span style="color: #6CB6FF">:</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;Successfully added a new haiku&quot;</span></span>
<span class="line"><span style="color: #ADBAC7">}</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">HTTP/1.1</span><span style="color: #24292E"> </span><span style="color: #005CC5">201</span><span style="color: #24292E"> </span><span style="color: #032F62">Created</span></span>
<span class="line"><span style="color: #6F42C1">Connection:</span><span style="color: #24292E"> </span><span style="color: #032F62">keep-alive</span></span>
<span class="line"><span style="color: #6F42C1">Content-Length:</span><span style="color: #24292E"> </span><span style="color: #005CC5">49</span></span>
<span class="line"><span style="color: #6F42C1">Content-Type:</span><span style="color: #24292E"> </span><span style="color: #032F62">application/json</span></span>
<span class="line"><span style="color: #005CC5">....</span></span>
<span class="line"><span style="color: #24292E">{</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #6F42C1">&quot;description&quot;</span><span style="color: #005CC5">:</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;Successfully added a new haiku&quot;</span></span>
<span class="line"><span style="color: #24292E">}</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br></div></div><p>新しい俳句を投稿することに成功したようである． 本当に俳句が追加されたか，再び GET リクエストを呼ぶことで確認してみよう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">http</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">GET</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;${</span><span style="color: #ADBAC7">ENDPOINT_URL</span><span style="color: #96D0FF">}/haiku&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F69D50">HTTP/1.1</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">200</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">OK</span></span>
<span class="line"><span style="color: #F69D50">Connection:</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">keep-alive</span></span>
<span class="line"><span style="color: #F69D50">Content-Length:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">258</span></span>
<span class="line"><span style="color: #F69D50">Content-Type:</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">application/json</span></span>
<span class="line"><span style="color: #6CB6FF">...</span></span>
<span class="line"><span style="color: #ADBAC7">[</span></span>
<span class="line"><span style="color: #ADBAC7">    {</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #96D0FF">&quot;created_at&quot;</span><span style="color: #ADBAC7">: </span><span style="color: #96D0FF">&quot;2020-07-06T02:46:04+00:00&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #96D0FF">&quot;first&quot;</span><span style="color: #ADBAC7">: </span><span style="color: #96D0FF">&quot;閑さや&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #96D0FF">&quot;item_id&quot;</span><span style="color: #ADBAC7">: </span><span style="color: #96D0FF">&quot;7e91c5e4d7ad47909e0ac14c8bbab05b&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #96D0FF">&quot;likes&quot;</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">0.0</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #96D0FF">&quot;second&quot;</span><span style="color: #ADBAC7">: </span><span style="color: #96D0FF">&quot;岩にしみ入る&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #96D0FF">&quot;third&quot;</span><span style="color: #ADBAC7">: </span><span style="color: #96D0FF">&quot;蝉の声&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #96D0FF">&quot;username&quot;</span><span style="color: #ADBAC7">: </span><span style="color: #96D0FF">&quot;松尾芭蕉&quot;</span></span>
<span class="line"><span style="color: #ADBAC7">    }</span></span>
<span class="line"><span style="color: #ADBAC7">]</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">http</span><span style="color: #24292E"> </span><span style="color: #032F62">GET</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;${</span><span style="color: #24292E">ENDPOINT_URL</span><span style="color: #032F62">}/haiku&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6F42C1">HTTP/1.1</span><span style="color: #24292E"> </span><span style="color: #005CC5">200</span><span style="color: #24292E"> </span><span style="color: #032F62">OK</span></span>
<span class="line"><span style="color: #6F42C1">Connection:</span><span style="color: #24292E"> </span><span style="color: #032F62">keep-alive</span></span>
<span class="line"><span style="color: #6F42C1">Content-Length:</span><span style="color: #24292E"> </span><span style="color: #005CC5">258</span></span>
<span class="line"><span style="color: #6F42C1">Content-Type:</span><span style="color: #24292E"> </span><span style="color: #032F62">application/json</span></span>
<span class="line"><span style="color: #005CC5">...</span></span>
<span class="line"><span style="color: #24292E">[</span></span>
<span class="line"><span style="color: #24292E">    {</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #032F62">&quot;created_at&quot;</span><span style="color: #24292E">: </span><span style="color: #032F62">&quot;2020-07-06T02:46:04+00:00&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #032F62">&quot;first&quot;</span><span style="color: #24292E">: </span><span style="color: #032F62">&quot;閑さや&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #032F62">&quot;item_id&quot;</span><span style="color: #24292E">: </span><span style="color: #032F62">&quot;7e91c5e4d7ad47909e0ac14c8bbab05b&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #032F62">&quot;likes&quot;</span><span style="color: #24292E">: </span><span style="color: #005CC5">0.0</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #032F62">&quot;second&quot;</span><span style="color: #24292E">: </span><span style="color: #032F62">&quot;岩にしみ入る&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #032F62">&quot;third&quot;</span><span style="color: #24292E">: </span><span style="color: #032F62">&quot;蝉の声&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #032F62">&quot;username&quot;</span><span style="color: #24292E">: </span><span style="color: #032F62">&quot;松尾芭蕉&quot;</span></span>
<span class="line"><span style="color: #24292E">    }</span></span>
<span class="line"><span style="color: #24292E">]</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br></div></div><p>素晴らしい！</p>
<p>次に， <code>PATCH /haiku/{item_id}</code> を呼ぶことでこの俳句にいいねを追加してみよう． 一つ前のコマンドで取得した俳句の <code>item_id</code> を，次のコマンドの <code>XXXX</code> に代入した上で実行しよう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">http</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">PATCH</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;${</span><span style="color: #ADBAC7">ENDPOINT_URL</span><span style="color: #96D0FF">}/haiku/XXXX&quot;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">http</span><span style="color: #24292E"> </span><span style="color: #032F62">PATCH</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;${</span><span style="color: #24292E">ENDPOINT_URL</span><span style="color: #032F62">}/haiku/XXXX&quot;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p><code>{&quot;description&quot;: &quot;OK&quot;}</code> という出力が得られるはずである． 再び GET リクエストを送ることで，いいね (<code>likes</code>) が 1 増えたことを確認しよう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">http</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">GET</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;${</span><span style="color: #ADBAC7">ENDPOINT_URL</span><span style="color: #96D0FF">}/haiku&quot;</span></span>
<span class="line"><span style="color: #6CB6FF">...</span></span>
<span class="line"><span style="color: #ADBAC7">[</span></span>
<span class="line"><span style="color: #ADBAC7">    {</span></span>
<span class="line"><span style="color: #ADBAC7">        ...</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #96D0FF">&quot;likes&quot;</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">1.0</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        ...</span></span>
<span class="line"><span style="color: #ADBAC7">    }</span></span>
<span class="line"><span style="color: #ADBAC7">]</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">http</span><span style="color: #24292E"> </span><span style="color: #032F62">GET</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;${</span><span style="color: #24292E">ENDPOINT_URL</span><span style="color: #032F62">}/haiku&quot;</span></span>
<span class="line"><span style="color: #005CC5">...</span></span>
<span class="line"><span style="color: #24292E">[</span></span>
<span class="line"><span style="color: #24292E">    {</span></span>
<span class="line"><span style="color: #24292E">        ...</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #032F62">&quot;likes&quot;</span><span style="color: #24292E">: </span><span style="color: #005CC5">1.0</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        ...</span></span>
<span class="line"><span style="color: #24292E">    }</span></span>
<span class="line"><span style="color: #24292E">]</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br></div></div><p>最後に， DELETE リクエストを送ることで俳句をデータベースから削除しよう． <code>XXXX</code> は <code>item_id</code> の値で置き換えたうえで次のコマンドを実行する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">http</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">DELETE</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;${</span><span style="color: #ADBAC7">ENDPOINT_URL</span><span style="color: #96D0FF">}/haiku/XXXX&quot;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">http</span><span style="color: #24292E"> </span><span style="color: #032F62">DELETE</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;${</span><span style="color: #24292E">ENDPOINT_URL</span><span style="color: #032F62">}/haiku/XXXX&quot;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>再び GET リクエストを送ることで，返り値が空 (<code>[]</code>) になっていることを確認しよう．</p>
<p>これで，俳句の投稿・取得・削除そしていいねの追加，といった基本的な API がきちんと動作していることが確認できた．</p>
<h2 id="大量の-api-リクエストをシミュレートする" tabindex="-1">大量の API リクエストをシミュレートする <a class="header-anchor" href="#大量の-api-リクエストをシミュレートする" aria-label="Permalink to &quot;大量の API リクエストをシミュレートする&quot;">&ZeroWidthSpace;</a></h2>
<p>さて，前節ではマニュアルで一つずつ俳句を投稿した． 多数のユーザーがいるような SNS では，1 秒間に数千件以上の投稿がされている． 今回はサーバーレスアーキテクチャを採用したことで，そのような瞬間的な大量アクセスにも容易に対応できるようなシステムが自動的に構築されている． このポイントを実証するため，ここでは大量の API が送信された状況をシミュレートしてみよう．</p>
<p><a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/bashoutter/client.py" target="_blank" rel="noreferrer">handson/bashoutter/client.py</a> に，大量の API リクエストをシミュレートするためのプログラムが書かれている． このプログラムを使用すると， <code>POST /haiku</code> の API リクエストを指定された回数だけ実行することができる．</p>
<p>テストとして， API を 300 回実行してみよう． 次のコマンドを実行する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">client.py</span><span style="color: #ADBAC7"> $ENDPOINT_URL </span><span style="color: #96D0FF">post_many</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">300</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python</span><span style="color: #24292E"> </span><span style="color: #032F62">client.py</span><span style="color: #24292E"> $ENDPOINT_URL </span><span style="color: #032F62">post_many</span><span style="color: #24292E"> </span><span style="color: #005CC5">300</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>数秒のうちに実行が完了するだろう． これがもし，単一のサーバーからなる API だったとしたら，このような大量のリクエストの処理にはもっと時間がかかっただろう． 最悪の場合には，サーバーダウンにもつながっていたかもしれない． したがって，今回作成したサーバーレスアプリケーションは，とてもシンプルながらも 1 秒間に数百件の処理を行えるような，スケーラブルなクラウドシステムであることがわかる． サーバーレスでクラウドを設計することの利点を垣間見ることができただろうか？</p>
<p>先述のコマンドにより大量の俳句を投稿するとデータベースに無駄なデータがどんどん溜まってしまう． データベースを完全に空にするには，次のコマンドを使用する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">client.py</span><span style="color: #ADBAC7"> $ENDPOINT_URL </span><span style="color: #96D0FF">clear_database</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python</span><span style="color: #24292E"> </span><span style="color: #032F62">client.py</span><span style="color: #24292E"> $ENDPOINT_URL </span><span style="color: #032F62">clear_database</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><h2 id="bashoutter-gui-を動かしてみる" tabindex="-1">Bashoutter GUI を動かしてみる <a class="header-anchor" href="#bashoutter-gui-を動かしてみる" aria-label="Permalink to &quot;Bashoutter GUI を動かしてみる&quot;">&ZeroWidthSpace;</a></h2>
<p>前節ではコマンドラインから API を送信する演習を行った． ウェブアプリケーションでは，これと同じことがウェブブラウザの背後で行われ，ページのコンテンツが表示されている ( (#fig:web_server) 参照)． 最後に， API が GUI と統合されるとどうなるのか，見てみよう．</p>
<p>CDK のコードで， Public access mode の S3 バケットを作成したことを思い出してほしい． 最初のステップとして，ここにウェブサイトのコンテンツをアップロードしよう． ハンズオンのソースコードの中に <code>gui/dist</code> というフォルダが見つかるはずである． ここにはビルド済みのウェブサイトの静的コンテンツ (HTML/CSS/JavaScript) が入っている． AWS CLI のコマンドを使うことでこれらのファイルを S3 にアップロードしよう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">s3</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cp</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--recursive</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">./gui/dist</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">s3://</span><span style="color: #F47067">&lt;</span><span style="color: #96D0FF">BUCKET_NAM</span><span style="color: #ADBAC7">E</span><span style="color: #F47067">&gt;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">aws</span><span style="color: #24292E"> </span><span style="color: #032F62">s3</span><span style="color: #24292E"> </span><span style="color: #032F62">cp</span><span style="color: #24292E"> </span><span style="color: #005CC5">--recursive</span><span style="color: #24292E"> </span><span style="color: #032F62">./gui/dist</span><span style="color: #24292E"> </span><span style="color: #032F62">s3://</span><span style="color: #D73A49">&lt;</span><span style="color: #032F62">BUCKET_NAM</span><span style="color: #24292E">E</span><span style="color: #D73A49">&gt;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>コマンドを実行する際は， Bashoutter ハンズオンのディレクトリから行うこと (<code>./gui/dist</code> に注目)，そして <code>&lt;BUCKET_NAME&gt;</code> にはデプロイした自身のバケットの名前が入る点に注意． 念のため，AWS コンソールにログインし，バケットにファイルがアップロードされている点を確認しておこう．</p>
<p>なお，今回は GUI の説明はとくに行わないが， Bashoutter のウェブサイトは <a href="https://vuejs.org/" target="_blank" rel="noreferrer">Vue.js</a> と <a href="https://vuetifyjs.com/" target="_blank" rel="noreferrer">Vuetify</a> という UI フレームワークを使って作成した． Vue を使うことで， Single page application (SPA) の技術でウェブサイトの画面がレンダリングされる． ソースコードは <a href="https://github.com/andatoshiki/toshiki-notebooktree/main/handson/bashoutter/gui" target="_blank" rel="noreferrer">handson/bashoutter/gui</a> のディレクトリの中にあるので，興味のある読者は確認してみるとよい．</p>
<p>アップトードが完了したところで，続いてデプロイを実行したときにコマンドラインの出力を見直してみよう． <code>Bashoutter.BucketUrl=</code> で与えられた URL が見つかるはずである (<a href="#handson_05_cdk_output">figure_title</a>)． これは，先述したとおり， Public access mode の S3 バケットの URL である．</p>
<p>ウェブブラウザを開き，アドレスバーに S3 の URL を入力しへアクセスしてみよう． すると， <a href="#handson_05_bashoutter_2">figure_title</a> のようなページが表示されるはずである．</p>
<p><img src="./assets/handson-bashoutter/bashoutter_2.png" alt="&quot;Bashoutter&quot; の GUI 画面"></p>
<p>ページが表示されたら，一番上の &quot;API Endpoint URL&quot; と書いてあるテキストボックスに，今回デプロイした <strong>API Gateway の URL を入力</strong>する (今回のアプリケーションでは，API Gateway の URL はランダムに割り当てられるのでこのような GUI の仕様になっている)． そうしたら，画面の &quot;REFRESH&quot; と書いてあるボタンを押してみよう． データベースに俳句が登録済みであれば，俳句の一覧が表示されるはずである． 各俳句の左下にあるハートのアイコンをクリックすることで， &quot;like&quot; の票を入れることができる．</p>
<p>新しい俳句を投稿するには，五七五と投稿者の名前を入力して， &quot;POST&quot; を押す． &quot;POST&quot; を押した後は，再び &quot;REFRESH&quot; ボタンを押すことで最新の俳句のリストをデータベースから取得する．</p>
<h2 id="アプリケーションの削除" tabindex="-1">アプリケーションの削除 <a class="header-anchor" href="#アプリケーションの削除" aria-label="Permalink to &quot;アプリケーションの削除&quot;">&ZeroWidthSpace;</a></h2>
<p>これで， Bashoutter プロジェクトが完成した！ この SNS は，インターネットを通じて世界のどこからでもアクセスできる状態にある． また， <a href="#simulating_many_apis">大量の API リクエストをシミュレートする</a> で見たように，大量のユーザーの同時アクセスによる負荷がかかっても，柔軟にスケールが行われ遅延なく処理を行うことができる． 極めて簡素ながらも，立派なウェブサービスとしてのスペックは満たしているのである！</p>
<p>Bashoutter アプリを存分に楽しむことができたら，最後に忘れずにスタックを削除しよう．</p>
<p>コマンドラインからスタックの削除を実行するには，次のコマンドを使う．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cdk</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">destroy</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cdk</span><span style="color: #24292E"> </span><span style="color: #032F62">destroy</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>CDK のバージョンによっては S3 のバケットが空でないと， <code>cdk destroy</code> がエラーを出力する場合がある． この場合はスタックを削除する前に， S3 バケットの中身をすべて削除しなければならない．</p>
<p>コンソールから実行するには， S3 コンソールに行き，バケットの中身を開いたうえで，すべてのファイルを選択し， &quot;Actions&quot; → &quot;Delete&quot; を実行すればよいい．</p>
<p>コマンドラインから実行するには， 次のコマンドを使う． &lt;BUCKET NAME&gt; のところは，自分の バケットの名前 (&quot;BashoutterBucketXXXX&quot; というパターンの名前がついているはずである) に置き換えることを忘れずに．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">s3</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">rm</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">&lt;</span><span style="color: #96D0FF">BUCKET</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">NAM</span><span style="color: #ADBAC7">E</span><span style="color: #F47067">&gt;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--recursive</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">aws</span><span style="color: #24292E"> </span><span style="color: #032F62">s3</span><span style="color: #24292E"> </span><span style="color: #032F62">rm</span><span style="color: #24292E"> </span><span style="color: #D73A49">&lt;</span><span style="color: #032F62">BUCKET</span><span style="color: #24292E"> </span><span style="color: #032F62">NAM</span><span style="color: #24292E">E</span><span style="color: #D73A49">&gt;</span><span style="color: #24292E"> </span><span style="color: #005CC5">--recursive</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><h2 id="小括" tabindex="-1">小括 <a class="header-anchor" href="#小括" aria-label="Permalink to &quot;小括&quot;">&ZeroWidthSpace;</a></h2>
<p>ここまでが，本書第三部の内容であった．</p>
<p>第三部では，クラウドの応用として，一般の人に使ってもらうようなウェブアプリケーション・データベースをどのようにして作るのか，という点に焦点を当てて，説明を行った． その中で，従来的なクラウドシステムの設計と，ここ数年の最新の設計方法であるサーバーレスアーキテクチャについて解説した． (#sec_intro_serverless) では， AWS でのサーバーレスの実践として， Lambda, S3, DynamoDB のハンズオンを行った． 最後に， <a href="#sec_bashoutter">Hands-on #6: Bashoutter</a> では，これらの技術を統合することで，完全サーバーレスなウェブアプリケーション &quot;Bashoutter&quot; を作成した．</p>
<p>これらの演習を通じて，世の中のウェブサービスがどのようにしてでき上がっているのか，少し理解が深まっただろうか？ また，そのようなウェブアプリケーションを自分が作りたいと思ったとき，今回のハンズオンがその出発点となることができたならば幸いである．</p>
]]></description>
            <content:encoded><![CDATA[<h1 id="hands-on-6-bashoutter" tabindex="-1">Hands-on #6: Bashoutter <a class="header-anchor" href="#hands-on-6-bashoutter" aria-label="Permalink to &quot;Hands-on \#6: Bashoutter&quot;">&ZeroWidthSpace;</a></h1>
<p>さて，最後のハンズオンとなる第六回では，これまで学んできたサーバーレスクラウドの技術を使って，簡単なウェブサービスを作ってみよう． 具体的には，人々が自分の作った俳句を投稿する SNS サービス (<strong>Bashoutter</strong> と名付ける) を作成してみよう． Lambda, DynamoDB, S3 などの技術をすべて盛り込み，シンプルながらもサーバーレスの利点を生かしたスケーラブルな SNS アプリが誕生する． 最終的には， <a href="#handson_05_bashoutter">figure_title</a> のような，ミニマルではあるがとても現代風な SNS サイトが完成する！</p>
<p><img src="./assets/handson-bashoutter/bashoutter.png" alt="ハンズオン#6で作製する SNS アプリケーション &quot;Bashoutter&quot;"></p>
<h2 id="準備" tabindex="-1">準備 <a class="header-anchor" href="#準備" aria-label="Permalink to &quot;準備&quot;">&ZeroWidthSpace;</a></h2>
<p>ハンズオンのソースコードは GitHub の <a href="https://github.com/andatoshiki/toshiki-notebooktree/main/handson/bashoutter" target="_blank" rel="noreferrer">handson/bashoutter</a> に置いてある．</p>
<p>本ハンズオンの実行には，第一回ハンズオンで説明した準備 ( (#handson_01_prep)) が整っていることを前提とする． それ以外に必要な準備はない．</p>
<p>このハンズオンは，基本的に <a href="https://aws.amazon.com/free/?all-free-tier.sort-by=item.additionalFields.SortRank&amp;all-free-tier.sort-order=asc" target="_blank" rel="noreferrer">AWS の無料枠</a> の範囲内で実行できる．</p>
<h2 id="アプリケーションの説明" tabindex="-1">アプリケーションの説明 <a class="header-anchor" href="#アプリケーションの説明" aria-label="Permalink to &quot;アプリケーションの説明&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="api" tabindex="-1">API <a class="header-anchor" href="#api" aria-label="Permalink to &quot;API&quot;">&ZeroWidthSpace;</a></h3>
<p>今回のアプリケーションでは，人々からの俳句の投稿を受け付けたり，投稿された俳句の一覧を取得する，といった機能を実装したい． この機能を実現するための最小限の設計として， <a href="#tab_handson_05_api">table_title</a> に示すような四つの REST API を今回は実装する． 俳句を投稿する，閲覧する，削除するという基本的なデータ操作を行うための API が完備されている． また， <code>PATCH /haiku/{item_id}</code> は， <code>{item_id}</code> で指定された俳句に”いいね”をするために使用する．</p>
<table><caption>Bashoutter API</caption><colgroup><col style="width: 50%" /><col style="width: 50%" /></colgroup><tbody><tr class="odd"><td><p><code>GET /haiku</code></p></td><td><p>俳句の一覧を取得する</p></td></tr><tr class="even"><td><p><code>POST /haiku</code></p></td><td><p>新しい俳句を投稿する</p></td></tr><tr class="odd"><td><p><code>PATCH /haiku/{item_id}</code></p></td><td><p><code>{item_id}</code> で指定された俳句にお気に入り票を一つ入れる</p></td></tr><tr class="even"><td><p><code>DELETE /haiku/{item_id}</code></p></td><td><p><code>{item_id}</code> で指定された俳句を削除する</p></td></tr></tbody></table>
<p>それぞれの API のパラメータおよび返り値の詳細は，ハンズオンのソースコードの中の <a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/bashoutter/specs/swagger.yml" target="_blank" rel="noreferrer">swagger.yml</a> に定義してある．</p>
<p><strong>Open API Specification</strong> (OAS; 少し前は Swagger Specification とよばれていた) は， REST API のための記述フォーマットである． OAS に従って API の仕様が記述されていると，簡単にドキュメンテーションを生成したり，クライアントアプリケーションを自動生成することができる． <a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/bashoutter/specs/swagger.yml" target="_blank" rel="noreferrer">今回用意した API 仕様</a> も， OAS に従って書いてある． 詳しくは <a href="https://swagger.io/docs/specification/about/" target="_blank" rel="noreferrer">Swagger の公式ドキュメンテーション</a> などを参照．</p>
<h3 id="アプリケーションアーキテクチャ" tabindex="-1">アプリケーションアーキテクチャ <a class="header-anchor" href="#アプリケーションアーキテクチャ" aria-label="Permalink to &quot;アプリケーションアーキテクチャ&quot;">&ZeroWidthSpace;</a></h3>
<p>このハンズオンで作成するアプリケーションの概要を <a href="#handson_05_architecture">figure_title</a> に示す．</p>
<p><img src="./assets/handson-bashoutter/handson-05-architecture.png" alt="ハンズオン#5で作製するアプリケーションのアーキテクチャ"></p>
<p>簡単にまとめると，次のような設計である．</p>
<ul>
<li>
<p>クライアントからの API リクエストは， <strong>API Gateway</strong> (後述)にまず送信され， API の URI で指定された Lambda 関数へ転送される．</p>
</li>
<li>
<p>それぞれの API のパス (リソース) ごとに独立した Lambda を用意する．</p>
</li>
<li>
<p>俳句の情報 (作者，本文，投稿日時など) を記録するためのデータベース (DynamoDB) を用意する．</p>
</li>
<li>
<p>各 Lambda 関数には， DynamoDB へのアクセス権を付与する．</p>
</li>
<li>
<p>最後に，ウェブブラウザからコンテンツを表示できるよう， ウェブページの静的コンテンツを配信するための S3 バケットを用意する．クライアントはこの S3 バケットにアクセスすることで HTML/CSS/JS などのコンテンツを取得する．</p>
</li>
</ul>
<p>それでは，プログラムのソースコードを見てみよう (<a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/bashoutter/app.py" target="_blank" rel="noreferrer">handson/bashoutter/app.py</a>)．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">class</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50">Bashoutter</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">core</span><span style="color: #ADBAC7">.</span><span style="color: #6CB6FF">Stack</span><span style="color: #ADBAC7">):</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">def</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">__init__</span><span style="color: #ADBAC7">(self, scope: core.App, name: </span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">, </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">kwargs) -&gt; </span><span style="color: #6CB6FF">None</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #6CB6FF">super</span><span style="color: #ADBAC7">().</span><span style="color: #6CB6FF">__init__</span><span style="color: #ADBAC7">(scope, name, </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">kwargs)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390"># dynamoDB table to store haiku</span></span>
<span class="line"><span style="color: #ADBAC7">        table </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ddb.Table(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;Bashoutter-Table&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">partition_key</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ddb.Attribute(</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">name</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;item_id&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">type</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ddb.AttributeType.</span><span style="color: #6CB6FF">STRING</span></span>
<span class="line"><span style="color: #ADBAC7">            ),</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">billing_mode</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ddb.BillingMode.</span><span style="color: #6CB6FF">PAY_PER_REQUEST</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">removal_policy</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">core.RemovalPolicy.</span><span style="color: #6CB6FF">DESTROY</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        bucket </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> s3.Bucket(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;Bashoutter-Bucket&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">website_index_document</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;index.html&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">public_read_access</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">True</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">removal_policy</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">core.RemovalPolicy.</span><span style="color: #6CB6FF">DESTROY</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        common_params </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> {</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #96D0FF">&quot;runtime&quot;</span><span style="color: #ADBAC7">: _lambda.Runtime.</span><span style="color: #6CB6FF">PYTHON_3_7</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #96D0FF">&quot;environment&quot;</span><span style="color: #ADBAC7">: {</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #96D0FF">&quot;TABLE_NAME&quot;</span><span style="color: #ADBAC7">: table.table_name</span></span>
<span class="line"><span style="color: #ADBAC7">            }</span></span>
<span class="line"><span style="color: #ADBAC7">        }</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390"># define Lambda functions</span></span>
<span class="line"><span style="color: #ADBAC7">        get_haiku_lambda </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> _lambda.Function(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;GetHaiku&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">code</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">_lambda.Code.from_asset(</span><span style="color: #96D0FF">&quot;api&quot;</span><span style="color: #ADBAC7">),</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">handler</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;api.get_haiku&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">memory_size</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">512</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">common_params,</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"><span style="color: #ADBAC7">        post_haiku_lambda </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> _lambda.Function(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;PostHaiku&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">code</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">_lambda.Code.from_asset(</span><span style="color: #96D0FF">&quot;api&quot;</span><span style="color: #ADBAC7">),</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">handler</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;api.post_haiku&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">common_params,</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"><span style="color: #ADBAC7">        patch_haiku_lambda </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> _lambda.Function(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;PatchHaiku&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">code</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">_lambda.Code.from_asset(</span><span style="color: #96D0FF">&quot;api&quot;</span><span style="color: #ADBAC7">),</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">handler</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;api.patch_haiku&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">common_params,</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"><span style="color: #ADBAC7">        delete_haiku_lambda </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> _lambda.Function(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;DeleteHaiku&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">code</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">_lambda.Code.from_asset(</span><span style="color: #96D0FF">&quot;api&quot;</span><span style="color: #ADBAC7">),</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">handler</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;api.delete_haiku&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">common_params,</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390"># grant permissions</span></span>
<span class="line"><span style="color: #ADBAC7">        table.grant_read_data(get_haiku_lambda)</span></span>
<span class="line"><span style="color: #ADBAC7">        table.grant_read_write_data(post_haiku_lambda)</span></span>
<span class="line"><span style="color: #ADBAC7">        table.grant_read_write_data(patch_haiku_lambda)</span></span>
<span class="line"><span style="color: #ADBAC7">        table.grant_read_write_data(delete_haiku_lambda)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390"># define API Gateway</span></span>
<span class="line"><span style="color: #ADBAC7">        api </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> apigw.RestApi(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;BashoutterApi&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">default_cors_preflight_options</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">apigw.CorsOptions(</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">allow_origins</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">apigw.Cors.</span><span style="color: #6CB6FF">ALL_ORIGINS</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">allow_methods</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">apigw.Cors.</span><span style="color: #6CB6FF">ALL_METHODS</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            )</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        haiku </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> api.root.add_resource(</span><span style="color: #96D0FF">&quot;haiku&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">        haiku.add_method(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #96D0FF">&quot;GET&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            apigw.LambdaIntegration(get_haiku_lambda)</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"><span style="color: #ADBAC7">        haiku.add_method(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #96D0FF">&quot;POST&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            apigw.LambdaIntegration(post_haiku_lambda)</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        haiku_item_id </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> haiku.add_resource(</span><span style="color: #96D0FF">&quot;</span><span style="color: #F47067">{item_id}</span><span style="color: #96D0FF">&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">        haiku_item_id.add_method(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #96D0FF">&quot;PATCH&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            apigw.LambdaIntegration(patch_haiku_lambda)</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"><span style="color: #ADBAC7">        haiku_item_id.add_method(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #96D0FF">&quot;DELETE&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            apigw.LambdaIntegration(delete_haiku_lambda)</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">class</span><span style="color: #24292E"> </span><span style="color: #6F42C1">Bashoutter</span><span style="color: #24292E">(</span><span style="color: #6F42C1">core</span><span style="color: #24292E">.</span><span style="color: #6F42C1">Stack</span><span style="color: #24292E">):</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">def</span><span style="color: #24292E"> </span><span style="color: #005CC5">__init__</span><span style="color: #24292E">(self, scope: core.App, name: </span><span style="color: #005CC5">str</span><span style="color: #24292E">, </span><span style="color: #D73A49">**</span><span style="color: #24292E">kwargs) -&gt; </span><span style="color: #005CC5">None</span><span style="color: #24292E">:</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #005CC5">super</span><span style="color: #24292E">().</span><span style="color: #005CC5">__init__</span><span style="color: #24292E">(scope, name, </span><span style="color: #D73A49">**</span><span style="color: #24292E">kwargs)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D"># dynamoDB table to store haiku</span></span>
<span class="line"><span style="color: #24292E">        table </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ddb.Table(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;Bashoutter-Table&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">partition_key</span><span style="color: #D73A49">=</span><span style="color: #24292E">ddb.Attribute(</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">name</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;item_id&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">type</span><span style="color: #D73A49">=</span><span style="color: #24292E">ddb.AttributeType.</span><span style="color: #005CC5">STRING</span></span>
<span class="line"><span style="color: #24292E">            ),</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">billing_mode</span><span style="color: #D73A49">=</span><span style="color: #24292E">ddb.BillingMode.</span><span style="color: #005CC5">PAY_PER_REQUEST</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">removal_policy</span><span style="color: #D73A49">=</span><span style="color: #24292E">core.RemovalPolicy.</span><span style="color: #005CC5">DESTROY</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        bucket </span><span style="color: #D73A49">=</span><span style="color: #24292E"> s3.Bucket(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;Bashoutter-Bucket&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">website_index_document</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;index.html&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">public_read_access</span><span style="color: #D73A49">=</span><span style="color: #005CC5">True</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">removal_policy</span><span style="color: #D73A49">=</span><span style="color: #24292E">core.RemovalPolicy.</span><span style="color: #005CC5">DESTROY</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        common_params </span><span style="color: #D73A49">=</span><span style="color: #24292E"> {</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #032F62">&quot;runtime&quot;</span><span style="color: #24292E">: _lambda.Runtime.</span><span style="color: #005CC5">PYTHON_3_7</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #032F62">&quot;environment&quot;</span><span style="color: #24292E">: {</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #032F62">&quot;TABLE_NAME&quot;</span><span style="color: #24292E">: table.table_name</span></span>
<span class="line"><span style="color: #24292E">            }</span></span>
<span class="line"><span style="color: #24292E">        }</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D"># define Lambda functions</span></span>
<span class="line"><span style="color: #24292E">        get_haiku_lambda </span><span style="color: #D73A49">=</span><span style="color: #24292E"> _lambda.Function(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;GetHaiku&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">code</span><span style="color: #D73A49">=</span><span style="color: #24292E">_lambda.Code.from_asset(</span><span style="color: #032F62">&quot;api&quot;</span><span style="color: #24292E">),</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">handler</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;api.get_haiku&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">memory_size</span><span style="color: #D73A49">=</span><span style="color: #005CC5">512</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #D73A49">**</span><span style="color: #24292E">common_params,</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"><span style="color: #24292E">        post_haiku_lambda </span><span style="color: #D73A49">=</span><span style="color: #24292E"> _lambda.Function(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;PostHaiku&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">code</span><span style="color: #D73A49">=</span><span style="color: #24292E">_lambda.Code.from_asset(</span><span style="color: #032F62">&quot;api&quot;</span><span style="color: #24292E">),</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">handler</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;api.post_haiku&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #D73A49">**</span><span style="color: #24292E">common_params,</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"><span style="color: #24292E">        patch_haiku_lambda </span><span style="color: #D73A49">=</span><span style="color: #24292E"> _lambda.Function(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;PatchHaiku&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">code</span><span style="color: #D73A49">=</span><span style="color: #24292E">_lambda.Code.from_asset(</span><span style="color: #032F62">&quot;api&quot;</span><span style="color: #24292E">),</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">handler</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;api.patch_haiku&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #D73A49">**</span><span style="color: #24292E">common_params,</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"><span style="color: #24292E">        delete_haiku_lambda </span><span style="color: #D73A49">=</span><span style="color: #24292E"> _lambda.Function(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;DeleteHaiku&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">code</span><span style="color: #D73A49">=</span><span style="color: #24292E">_lambda.Code.from_asset(</span><span style="color: #032F62">&quot;api&quot;</span><span style="color: #24292E">),</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">handler</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;api.delete_haiku&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #D73A49">**</span><span style="color: #24292E">common_params,</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D"># grant permissions</span></span>
<span class="line"><span style="color: #24292E">        table.grant_read_data(get_haiku_lambda)</span></span>
<span class="line"><span style="color: #24292E">        table.grant_read_write_data(post_haiku_lambda)</span></span>
<span class="line"><span style="color: #24292E">        table.grant_read_write_data(patch_haiku_lambda)</span></span>
<span class="line"><span style="color: #24292E">        table.grant_read_write_data(delete_haiku_lambda)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D"># define API Gateway</span></span>
<span class="line"><span style="color: #24292E">        api </span><span style="color: #D73A49">=</span><span style="color: #24292E"> apigw.RestApi(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;BashoutterApi&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">default_cors_preflight_options</span><span style="color: #D73A49">=</span><span style="color: #24292E">apigw.CorsOptions(</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">allow_origins</span><span style="color: #D73A49">=</span><span style="color: #24292E">apigw.Cors.</span><span style="color: #005CC5">ALL_ORIGINS</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">allow_methods</span><span style="color: #D73A49">=</span><span style="color: #24292E">apigw.Cors.</span><span style="color: #005CC5">ALL_METHODS</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            )</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        haiku </span><span style="color: #D73A49">=</span><span style="color: #24292E"> api.root.add_resource(</span><span style="color: #032F62">&quot;haiku&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">        haiku.add_method(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #032F62">&quot;GET&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            apigw.LambdaIntegration(get_haiku_lambda)</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"><span style="color: #24292E">        haiku.add_method(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #032F62">&quot;POST&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            apigw.LambdaIntegration(post_haiku_lambda)</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        haiku_item_id </span><span style="color: #D73A49">=</span><span style="color: #24292E"> haiku.add_resource(</span><span style="color: #032F62">&quot;</span><span style="color: #005CC5">{item_id}</span><span style="color: #032F62">&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">        haiku_item_id.add_method(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #032F62">&quot;PATCH&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            apigw.LambdaIntegration(patch_haiku_lambda)</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"><span style="color: #24292E">        haiku_item_id.add_method(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #032F62">&quot;DELETE&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            apigw.LambdaIntegration(delete_haiku_lambda)</span></span>
<span class="line"><span style="color: #24292E">        )</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br><span class="line-number">36</span><br><span class="line-number">37</span><br><span class="line-number">38</span><br><span class="line-number">39</span><br><span class="line-number">40</span><br><span class="line-number">41</span><br><span class="line-number">42</span><br><span class="line-number">43</span><br><span class="line-number">44</span><br><span class="line-number">45</span><br><span class="line-number">46</span><br><span class="line-number">47</span><br><span class="line-number">48</span><br><span class="line-number">49</span><br><span class="line-number">50</span><br><span class="line-number">51</span><br><span class="line-number">52</span><br><span class="line-number">53</span><br><span class="line-number">54</span><br><span class="line-number">55</span><br><span class="line-number">56</span><br><span class="line-number">57</span><br><span class="line-number">58</span><br><span class="line-number">59</span><br><span class="line-number">60</span><br><span class="line-number">61</span><br><span class="line-number">62</span><br><span class="line-number">63</span><br><span class="line-number">64</span><br><span class="line-number">65</span><br><span class="line-number">66</span><br><span class="line-number">67</span><br><span class="line-number">68</span><br><span class="line-number">69</span><br><span class="line-number">70</span><br><span class="line-number">71</span><br><span class="line-number">72</span><br><span class="line-number">73</span><br><span class="line-number">74</span><br><span class="line-number">75</span><br><span class="line-number">76</span><br><span class="line-number">77</span><br><span class="line-number">78</span><br><span class="line-number">79</span><br><span class="line-number">80</span><br><span class="line-number">81</span><br><span class="line-number">82</span><br><span class="line-number">83</span><br><span class="line-number">84</span><br><span class="line-number">85</span><br><span class="line-number">86</span><br><span class="line-number">87</span><br><span class="line-number">88</span><br><span class="line-number">89</span><br><span class="line-number">90</span><br><span class="line-number">91</span><br><span class="line-number">92</span><br><span class="line-number">93</span><br><span class="line-number">94</span><br><span class="line-number">95</span><br><span class="line-number">96</span><br></div></div><ul>
<li>
<p>ここで，俳句の情報を記録しておくための DynamoDB テーブルを定義している．</p>
</li>
<li>
<p>静的コンテンツを配信するための S3 バケットを用意している．</p>
</li>
<li>
<p>それぞれの API で実行される Lambda 関数を定義している． 関数は Python3.7 で書かれており，コードは <a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/bashoutter/api/api.py" target="_blank" rel="noreferrer">handson/bashoutter/api/api.py</a> にある．</p>
</li>
<li>
<p>&lt;3&gt; で定義された Lambda 関数に対し，データベースへの読み書きのアクセス権限を付与している．</p>
</li>
<li>
<p>ここで，API Gateway により，各 API パスとそこで実行されるべき Lambda 関数を紐付けている．</p>
</li>
</ul>
<p>それぞれの項目について，もう少し詳しく説明しよう．</p>
<h3 id="public-access-mode-の-s3-バケット" tabindex="-1">Public access mode の S3 バケット <a class="header-anchor" href="#public-access-mode-の-s3-バケット" aria-label="Permalink to &quot;Public access mode の S3 バケット&quot;">&ZeroWidthSpace;</a></h3>
<p>S3 のバケットを作成しているコードを見てみよう．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">bucket </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> s3.Bucket(</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;Bashoutter-Bucket&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">website_index_document</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;index.html&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">public_read_access</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">True</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">removal_policy</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">core.RemovalPolicy.</span><span style="color: #6CB6FF">DESTROY</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">bucket </span><span style="color: #D73A49">=</span><span style="color: #24292E"> s3.Bucket(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;Bashoutter-Bucket&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">website_index_document</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;index.html&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">public_read_access</span><span style="color: #D73A49">=</span><span style="color: #005CC5">True</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">removal_policy</span><span style="color: #D73A49">=</span><span style="color: #24292E">core.RemovalPolicy.</span><span style="color: #005CC5">DESTROY</span></span>
<span class="line"><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br></div></div><p>ここで注目してほしいのは <code>public_read_access=True</code> の部分だ． 前章で， S3 について説明を行ったときには触れなかったが， S3 には <strong>Public access mode</strong> という機能がある． Public access mode をオンにしておくと，バケットの中のファイルは認証なしで (i.e. インターネット上の誰でも) 閲覧できるようになる． この設定は，一般公開されているウェブサイトの静的なコンテンツを置いておくのに最適であり，多くのサーバーレスによるウェブサービスでこのような設計が行われる． public access mode を設定しておくと， <code>http://XXXX.s3-website-ap-northeast-1.amazonaws.com/</code> のような固有の URL がバケットに対して付与される． そして，クライアントがこの URL にアクセスをすると，バケットの中にある <code>index.html</code> がクライアントに返され，ページがロードされる (どのファイルが返されるかは， <code>website_index_document=&quot;index.html&quot;</code> の部分で設定している．)</p>
<p>なお，この時点ではバケットは空である． HTML/CSS/JS など静的コンテンツの配置は，デプロイを行った後ほどのステップで行う．</p>
<p>より本格的なウェブページを運用する際には， public access mode の S3 バケットに， <a href="https://aws.amazon.com/cloudfront/" target="_blank" rel="noreferrer">CloudFront</a> という機能を追加することが一般的である． CloudFront により，　<strong>Content Delivery Nework (CDN)</strong> や暗号化された HTTPS 通信を設定することができる． CloudFront についての詳細は <a href="https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Introduction.html" target="_blank" rel="noreferrer">公式ドキュメンテーション &quot;What is Amazon CloudFront?&quot;</a> などを参照いただきたい．</p>
<p>今回のハンズオンでは説明の簡略化のため CloudFront の設定を行わなかったが，興味のある読者は次のリンクのプログラムが参考になるだろう．</p>
<ul>
<li><a href="https://github.com/aws-samples/aws-cdk-examples/tree/master/typescript/static-site" target="_blank" rel="noreferrer">https://github.com/aws-samples/aws-cdk-examples/tree/master/typescript/static-site</a></li>
</ul>
<p>今回の S3 バケットには， AWS によって付与されたランダムな URL がついている． これを． <code>example.com</code> のような自分のドメインでホストしたければ， AWS によって付与された URL を自分のドメインの DNS レコードに追加すればよい．</p>
<h3 id="api-のハンドラ関数" tabindex="-1">API のハンドラ関数 <a class="header-anchor" href="#api-のハンドラ関数" aria-label="Permalink to &quot;API のハンドラ関数&quot;">&ZeroWidthSpace;</a></h3>
<p>API リクエストが来たときに，リクエストされた処理を行う関数のことをハンドラ (handler) 関数とよぶ． <code>GET /haiku</code> の API に対してのハンドラ関数を Lambda で定義している部分を見てみよう．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">get_haiku_lambda </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> _lambda.Function(</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;GetHaiku&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">code</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">_lambda.Code.from_asset(</span><span style="color: #96D0FF">&quot;api&quot;</span><span style="color: #ADBAC7">),</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">handler</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;api.get_haiku&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">memory_size</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">512</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">common_params</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">get_haiku_lambda </span><span style="color: #D73A49">=</span><span style="color: #24292E"> _lambda.Function(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;GetHaiku&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">code</span><span style="color: #D73A49">=</span><span style="color: #24292E">_lambda.Code.from_asset(</span><span style="color: #032F62">&quot;api&quot;</span><span style="color: #24292E">),</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">handler</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;api.get_haiku&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">memory_size</span><span style="color: #D73A49">=</span><span style="color: #005CC5">512</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">**</span><span style="color: #24292E">common_params</span></span>
<span class="line"><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br></div></div><p>簡単なところから見ていくと， <code>memory_size=512</code> の箇所でメモリーの使用量を 512MB に指定している． また， <code>code=_lambda.Code.from_asset(&quot;api&quot;)</code> によって外部のディレクトリ (<code>api/</code>) を参照せよと指定しており， <code>handler=&quot;api.get_haiku&quot;</code> のところで <code>api.py</code> というファイルの <code>get_haiku()</code> という関数をハンドラ関数として実行せよ，と定義している．</p>
<p>次に，ハンドラ関数として使用されている <code>get_haiku()</code> のコードを見てみよう (<a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/bashoutter/api/api.py" target="_blank" rel="noreferrer">handson/bashoutter/api/api.py</a>)．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">ddb </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> boto3.resource(</span><span style="color: #96D0FF">&quot;dynamodb&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">table </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ddb.Table(os.environ[</span><span style="color: #96D0FF">&quot;TABLE_NAME&quot;</span><span style="color: #ADBAC7">])</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F47067">def</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">get_haiku</span><span style="color: #ADBAC7">(event, context):</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #96D0FF">&quot;&quot;&quot;</span></span>
<span class="line"><span style="color: #96D0FF">    handler for GET /haiku</span></span>
<span class="line"><span style="color: #96D0FF">    &quot;&quot;&quot;</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">try</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">        response </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> table.scan()</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        status_code </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">200</span></span>
<span class="line"><span style="color: #ADBAC7">        resp </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> response.get(</span><span style="color: #96D0FF">&quot;Items&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">except</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">Exception</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">as</span><span style="color: #ADBAC7"> e:</span></span>
<span class="line"><span style="color: #ADBAC7">        status_code </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">500</span></span>
<span class="line"><span style="color: #ADBAC7">        resp </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> {</span><span style="color: #96D0FF">&quot;description&quot;</span><span style="color: #ADBAC7">: </span><span style="color: #F47067">f</span><span style="color: #96D0FF">&quot;Internal server error. </span><span style="color: #F47067">{</span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">(e)</span><span style="color: #F47067">}</span><span style="color: #96D0FF">&quot;</span><span style="color: #ADBAC7">}</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">return</span><span style="color: #ADBAC7"> {</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #96D0FF">&quot;statusCode&quot;</span><span style="color: #ADBAC7">: status_code,</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #96D0FF">&quot;headers&quot;</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">HEADERS</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #96D0FF">&quot;body&quot;</span><span style="color: #ADBAC7">: json.dumps(resp, </span><span style="color: #F69D50">cls</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">DecimalEncoder)</span></span>
<span class="line"><span style="color: #ADBAC7">    }</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">ddb </span><span style="color: #D73A49">=</span><span style="color: #24292E"> boto3.resource(</span><span style="color: #032F62">&quot;dynamodb&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">table </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ddb.Table(os.environ[</span><span style="color: #032F62">&quot;TABLE_NAME&quot;</span><span style="color: #24292E">])</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D73A49">def</span><span style="color: #24292E"> </span><span style="color: #6F42C1">get_haiku</span><span style="color: #24292E">(event, context):</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #032F62">&quot;&quot;&quot;</span></span>
<span class="line"><span style="color: #032F62">    handler for GET /haiku</span></span>
<span class="line"><span style="color: #032F62">    &quot;&quot;&quot;</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">try</span><span style="color: #24292E">:</span></span>
<span class="line"><span style="color: #24292E">        response </span><span style="color: #D73A49">=</span><span style="color: #24292E"> table.scan()</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        status_code </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #005CC5">200</span></span>
<span class="line"><span style="color: #24292E">        resp </span><span style="color: #D73A49">=</span><span style="color: #24292E"> response.get(</span><span style="color: #032F62">&quot;Items&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">except</span><span style="color: #24292E"> </span><span style="color: #005CC5">Exception</span><span style="color: #24292E"> </span><span style="color: #D73A49">as</span><span style="color: #24292E"> e:</span></span>
<span class="line"><span style="color: #24292E">        status_code </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #005CC5">500</span></span>
<span class="line"><span style="color: #24292E">        resp </span><span style="color: #D73A49">=</span><span style="color: #24292E"> {</span><span style="color: #032F62">&quot;description&quot;</span><span style="color: #24292E">: </span><span style="color: #D73A49">f</span><span style="color: #032F62">&quot;Internal server error. </span><span style="color: #005CC5">{str</span><span style="color: #24292E">(e)</span><span style="color: #005CC5">}</span><span style="color: #032F62">&quot;</span><span style="color: #24292E">}</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">return</span><span style="color: #24292E"> {</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #032F62">&quot;statusCode&quot;</span><span style="color: #24292E">: status_code,</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #032F62">&quot;headers&quot;</span><span style="color: #24292E">: </span><span style="color: #005CC5">HEADERS</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #032F62">&quot;body&quot;</span><span style="color: #24292E">: json.dumps(resp, </span><span style="color: #E36209">cls</span><span style="color: #D73A49">=</span><span style="color: #24292E">DecimalEncoder)</span></span>
<span class="line"><span style="color: #24292E">    }</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br></div></div><p><code>response = table.scan()</code> で，俳句の格納された DynamoDB テーブルから，すべての要素を取り出している． もしなにもエラーが起きなければステータスコード 200 が返され，もしなにかエラーが起こればステータスコード 500 が返されるようになっている．</p>
<p>上記のような操作を，ほかの API についても繰り返すことで，すべての API のハンドラ関数が定義されている．</p>
<p><code>GET /haiku</code> のハンドラ関数で， <code>response = table.scan()</code> という部分があるが，実はこれは最善の書き方ではない． DynamoDB の <code>scan()</code> メソッドは，最大で 1MB までのデータしか返さない． データベースのサイズが大きく， 1MB 以上のデータがある場合には，再帰的に <code>scan()</code> メソッドをよぶ必要がある． 詳しくは <a href="https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/dynamodb.html#DynamoDB.Table.scan" target="_blank" rel="noreferrer">boto3 ドキュメンテーション</a> を参照．</p>
<h3 id="aws-における権限の管理-iam" tabindex="-1">AWS における権限の管理 (IAM) <a class="header-anchor" href="#aws-における権限の管理-iam" aria-label="Permalink to &quot;AWS における権限の管理 (IAM)&quot;">&ZeroWidthSpace;</a></h3>
<p>以下の部分のコードに注目してほしい．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">table.grant_read_data(get_haiku_lambda)</span></span>
<span class="line"><span style="color: #ADBAC7">table.grant_read_write_data(post_haiku_lambda)</span></span>
<span class="line"><span style="color: #ADBAC7">table.grant_read_write_data(patch_haiku_lambda)</span></span>
<span class="line"><span style="color: #ADBAC7">table.grant_read_write_data(delete_haiku_lambda)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">table.grant_read_data(get_haiku_lambda)</span></span>
<span class="line"><span style="color: #24292E">table.grant_read_write_data(post_haiku_lambda)</span></span>
<span class="line"><span style="color: #24292E">table.grant_read_write_data(patch_haiku_lambda)</span></span>
<span class="line"><span style="color: #24292E">table.grant_read_write_data(delete_haiku_lambda)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br></div></div><p>これまでは説明の簡略化のためにあえて触れてこなかったが， AWS には <a href="https://aws.amazon.com/iam/" target="_blank" rel="noreferrer">IAM (Identity and Access Management)</a> という重要な概念がある． IAM は基本的に，あるリソースがほかのリソースに対してどのような権限をもっているか，を規定するものである． Lambda は，デフォルトの状態ではほかのリソースにアクセスする権限をなにも有していない． したがって， Lambda 関数が DynamoDB のデータを読み書きするためには，それを許可するような IAM が Lambda 関数に付与されていなければならない．今回の S3 バケットには， AWS によって付与されたランダムな URL がついている． これを． <code>example.com</code> のような自分のドメインでホストしたければ， AWS によって付与された URL を自分のドメインの DNS レコードに追加すればよい．</p>
<p>CDK による <code>dynamodb.Table</code> オブジェクトには <code>grant_read_write_data()</code> という便利なメソッドが備わっており，アクセスを許可したい Lambda 関数を引数としてこのメソッドを呼ぶことで，データベースへの読み書きを許可する IAM を付与することができる． 同様に，CDK の <code>s3.Bucket</code> オブジェクトにも <code>grant_read_write()</code> というメソッドが備わっており，これによってバケットへの読み書きを許可することができる． このメソッドは，実は (#sec_aws_batch) で AWS Batch によるクラスターを構成した際に使用した． 興味のある読者は振り返ってコードを確認してみよう．</p>
<p>各リソースに付与する IAM は，<strong>必要最低限の権限を与えるにとどめる</strong>というのが基本方針である． これにより，セキュリティを向上させるだけでなく，意図していないプログラムからのデータベースへの読み書きを防止するという点で，バグを未然に防ぐことができる．</p>
<p>そのような理由により，このコードでは <code>GET</code> のハンドラー関数に対しては <code>grant_read_data()</code> によって， read 権限のみを付与している．</p>
<h3 id="api-gateway" tabindex="-1">API Gateway <a class="header-anchor" href="#api-gateway" aria-label="Permalink to &quot;API Gateway&quot;">&ZeroWidthSpace;</a></h3>
<p><a href="https://aws.amazon.com/api-gateway/" target="_blank" rel="noreferrer">API Gateway</a> とは， API の&quot;入り口&quot;として，API のリクエストパスに従って Lambda や EC2 などに接続を行うという機能を担う (<a href="#fig:bashoutter_api_gateway">figure_title</a>)． Lambda や EC2 によって行われた処理の結果は，再び API Gateway を経由してクライアントに返される． このように，クライアントとバックエンドサーバーの間に立ち， API のリソースパスに応じて接続先を振り分けるようなサーバーを<strong>ルーター</strong>，あるいは<strong>リバースプロキシ</strong>とよんだりする． 従来的には，ルーターにはそれ専用の仮想サーバーが置かれることが一般的であった． しかし， API Gateway はサーバーレスなルーターとして，固定されたサーバーを配置することなく， API のリクエストが来たときのみ起動し，API のルーティングを実行する． サーバーレスであることの当然の帰結として，アクセスの件数が増大したときにはそれにルーティングの処理能力を自動で増やす機能も備わっている．</p>
<p><img src="./assets/handson-bashoutter/api_gateway.png" alt="API Gateway"></p>
<p>API Gateway を配置することで，大量 (1 秒間に数千から数万件) の API リクエストに対応することのできるシステムを容易に構築することができる． API Gateway の料金は <a href="#tab_handson_05_apigateway_price">table_title</a> のように設定されている． また，無料利用枠により，月ごとに 100 万件までのリクエストは 0 円で利用できる．</p>
<table><caption>API Gateway の利用料金設定 (<a href="https://aws.amazon.com/api-gateway/pricing/">参照</a>)</caption><colgroup><col style="width: 50%" /><col style="width: 50%" /></colgroup><thead><tr class="header"><th>Number of Requests (per month)</th><th>Price (per million)</th></tr></thead><tbody><tr class="odd"><td><p>First 333 million</p></td><td><p>$4.25</p></td></tr><tr class="even"><td><p>Next 667 million</p></td><td><p>$3.53</p></td></tr><tr class="odd"><td><p>Next 19 billion</p></td><td><p>$3.00</p></td></tr><tr class="even"><td><p>Over 20 billion</p></td><td><p>$1.91</p></td></tr></tbody></table>
<p>ソースコードの該当箇所を見てみよう．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">api </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> apigw.RestApi(</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;BashoutterApi&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">default_cors_preflight_options</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">apigw.CorsOptions(</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #F69D50">allow_origins</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">apigw.Cors.</span><span style="color: #6CB6FF">ALL_ORIGINS</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #F69D50">allow_methods</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">apigw.Cors.</span><span style="color: #6CB6FF">ALL_METHODS</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    )</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">haiku </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> api.root.add_resource(</span><span style="color: #96D0FF">&quot;haiku&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">haiku.add_method(</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #96D0FF">&quot;GET&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    apigw.LambdaIntegration(get_haiku_lambda)</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">haiku.add_method(</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #96D0FF">&quot;POST&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    apigw.LambdaIntegration(post_haiku_lambda)</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">haiku_item_id </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> haiku.add_resource(</span><span style="color: #96D0FF">&quot;</span><span style="color: #F47067">{item_id}</span><span style="color: #96D0FF">&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">haiku_item_id.add_method(</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #96D0FF">&quot;PATCH&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    apigw.LambdaIntegration(patch_haiku_lambda)</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">haiku_item_id.add_method(</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #96D0FF">&quot;DELETE&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    apigw.LambdaIntegration(delete_haiku_lambda)</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">api </span><span style="color: #D73A49">=</span><span style="color: #24292E"> apigw.RestApi(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;BashoutterApi&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">default_cors_preflight_options</span><span style="color: #D73A49">=</span><span style="color: #24292E">apigw.CorsOptions(</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #E36209">allow_origins</span><span style="color: #D73A49">=</span><span style="color: #24292E">apigw.Cors.</span><span style="color: #005CC5">ALL_ORIGINS</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #E36209">allow_methods</span><span style="color: #D73A49">=</span><span style="color: #24292E">apigw.Cors.</span><span style="color: #005CC5">ALL_METHODS</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    )</span></span>
<span class="line"><span style="color: #24292E">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">haiku </span><span style="color: #D73A49">=</span><span style="color: #24292E"> api.root.add_resource(</span><span style="color: #032F62">&quot;haiku&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">haiku.add_method(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #032F62">&quot;GET&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    apigw.LambdaIntegration(get_haiku_lambda)</span></span>
<span class="line"><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">haiku.add_method(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #032F62">&quot;POST&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    apigw.LambdaIntegration(post_haiku_lambda)</span></span>
<span class="line"><span style="color: #24292E">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">haiku_item_id </span><span style="color: #D73A49">=</span><span style="color: #24292E"> haiku.add_resource(</span><span style="color: #032F62">&quot;</span><span style="color: #005CC5">{item_id}</span><span style="color: #032F62">&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">haiku_item_id.add_method(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #032F62">&quot;PATCH&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    apigw.LambdaIntegration(patch_haiku_lambda)</span></span>
<span class="line"><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">haiku_item_id.add_method(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #032F62">&quot;DELETE&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    apigw.LambdaIntegration(delete_haiku_lambda)</span></span>
<span class="line"><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br></div></div><ul>
<li>
<p>最初に， <code>api = apigw.RestApi()</code> により，空の API Gateway を作成している．</p>
</li>
<li>
<p>次に， <code>api.root.add_resource()</code> のメソッドを呼ぶことで， <code>/haiku</code> という API パスを追加している．</p>
</li>
<li>
<p>続いて， <code>add_method()</code> を呼ぶことで， <code>GET</code>, <code>POST</code> のメソッドを <code>/haiku</code> のパスに定義している．</p>
</li>
<li>
<p>さらに， <code>haiku.add_resource(&quot;{item_id}&quot;)</code> により， <code>/haiku/{item_id}</code> という API パスを追加している．</p>
</li>
<li>
<p>最後に， <code>add_method()</code> を呼ぶことにより， <code>PATCH</code>, <code>DELETE</code> のメソッドを <code>/haiku/{item_id}</code> のパスに定義している．</p>
</li>
</ul>
<p>このように， API Gateway の使い方は非常にシンプルで，逐次的に API パスとそこで実行されるメソッド・Lambda を記述していくだけでよい．</p>
<p>このプログラムで 新規 API を作成すると， ランダムな URL がその API のエンドポイントとして割り当てられる． これを． <code>api.example.com</code> のような自分のドメインでホストしたければ， AWS によって付与された URL を自分のドメインの DNS レコードに追加すればよい．</p>
<p>API Gateway で新規 API を作成したとき， <code>default_cors_preflight_options=</code> というパラメータで <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS" target="_blank" rel="noreferrer">Cross Origin Resource Sharing (CORS)</a> の設定を行っている． これは，ブラウザで走る Web アプリケーションと API を接続するときに必要な設定である．</p>
<h2 id="アプリケーションのデプロイ" tabindex="-1">アプリケーションのデプロイ <a class="header-anchor" href="#アプリケーションのデプロイ" aria-label="Permalink to &quot;アプリケーションのデプロイ&quot;">&ZeroWidthSpace;</a></h2>
<p>アプリケーションの中身が理解できたところで，早速デプロイを行ってみよう． デプロイの手順は，これまでのハンズオンとほとんど共通である． ここでは，コマンドのみ列挙する (<code>#</code> で始まる行はコメントである)． シークレットキーの設定も忘れずに ( (#aws_cli_install))．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390"># プロジェクトのディレクトリに移動</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cd</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">intro-aws/handson/bashoutter</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># venv を作成し，依存ライブラリのインストールを行う</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python3</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-m</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">venv</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.env</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">source</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.env/bin/activate</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">pip</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">install</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-r</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">requirements.txt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># デプロイを実行</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cdk</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">deploy</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D"># プロジェクトのディレクトリに移動</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cd</span><span style="color: #24292E"> </span><span style="color: #032F62">intro-aws/handson/bashoutter</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># venv を作成し，依存ライブラリのインストールを行う</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python3</span><span style="color: #24292E"> </span><span style="color: #005CC5">-m</span><span style="color: #24292E"> </span><span style="color: #032F62">venv</span><span style="color: #24292E"> </span><span style="color: #032F62">.env</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">source</span><span style="color: #24292E"> </span><span style="color: #032F62">.env/bin/activate</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">pip</span><span style="color: #24292E"> </span><span style="color: #032F62">install</span><span style="color: #24292E"> </span><span style="color: #005CC5">-r</span><span style="color: #24292E"> </span><span style="color: #032F62">requirements.txt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># デプロイを実行</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cdk</span><span style="color: #24292E"> </span><span style="color: #032F62">deploy</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br></div></div><p>デプロイのコマンドが無事に実行されれば， <a href="#handson_05_cdk_output">figure_title</a> のような出力が得られるはずである． ここで表示されている <code>Bashoutter.BashoutterApiEndpoint = XXXX</code>, <code>Bashoutter.BucketUrl = YYYY</code> の二つ文字列はあとで使うのでメモしておこう．</p>
<p><img src="./assets/handson-bashoutter/cdk_output.png" alt="CDKデプロイ実行後の出力"></p>
<p>AWS コンソールにログインして，デプロイされたスタックを確認してみよう． まずは，コンソールから API Gateway のページに行く． すると， <a href="#handson_05_apigw_console_list">figure_title</a> のような画面が表示され，デプロイ済みの API エンドポイントの一覧が確認できる．</p>
<p><img src="./assets/handson-bashoutter/apigw_console_list.png" alt="API Gateway コンソール画面 (1)"></p>
<p>今回デプロイした &quot;BashoutterApi&quot; という名前の API をクリックすることで <a href="#handson_05_apigw_console_detail">figure_title</a> のような画面に遷移し，詳細情報を閲覧できる． <code>GET /haiku</code>, <code>POST /haiku</code> などが定義されていることが確認できる．</p>
<p>それぞれのメソッドをクリックすると，そのメソッドの詳細情報を確認できる． API Gateway は，前述したルーティングの機能だけでなく，認証機能などを追加することも可能である． このハンズオンではとくにこれらの機能は使用しないが， &quot;Method Request&quot; と書いてある項目などがそれに相当する． 次に， <a href="#handson_05_apigw_console_detail">figure_title</a> で画面右端の赤色で囲った部分に，この API で呼ばれる Lambda 関数が指定されていることに注目しよう． 関数名をクリックと，該当する Lambda のコンソールに遷移し，関数の中身を閲覧することが可能である．</p>
<p><img src="./assets/handson-bashoutter/apigw_console_detail.png" alt="API Gateway コンソール画面 (2)"></p>
<p>次に， S3 のコンソール画面に移ってみよう． <code>bashouter-</code> で始まるランダムな名前のバケットが見つかるはずである (<a href="#handson_05_s3_console">figure_title</a>)．</p>
<p><img src="./assets/handson-bashoutter/s3_console.png" alt="S3 コンソール画面"></p>
<p>バケットの名前をクリックすることで，バケットの中身を確認してみよう． <code>index.html</code> のほか， <code>css/</code>, <code>js/</code> などのディレクトリがあるのが確認できるだろう (<a href="#handson_05_s3_contents">figure_title</a>)． これらが，ウェブページの&quot;枠&quot;を定義している静的コンテンツである．</p>
<p><img src="./assets/handson-bashoutter/s3_contents.png" alt="S3 バケットの中身"></p>
<h2 id="api-リクエストを送信する" tabindex="-1">API リクエストを送信する <a class="header-anchor" href="#api-リクエストを送信する" aria-label="Permalink to &quot;API リクエストを送信する&quot;">&ZeroWidthSpace;</a></h2>
<p>それでは，デプロイしたアプリケーションに対し，実際に API リクエストを送信してみよう． まずはコマンドラインから API を送信する演習を行おう． S3 に配置した GUI は一旦おいておく．</p>
<p>ここではコマンドラインから HTTP API リクエストを送信するためのシンプルな HTTP クライアントである <a href="https://httpie.org/" target="_blank" rel="noreferrer">HTTPie</a> を使ってみよう． HTTPie は，スタックをデプロイするときに Python 仮想環境 (venv) を作成したとき，一緒にインストールされている． 念のためインストールがうまくいっているか確認するには，仮想環境を立ち上げたあとコマンドラインに <code>http</code> と打ってみる． ヘルプのメッセージが出力されたら準備 OK である．</p>
<p>まず，先ほどデプロイを実行したときに得られた API のエンドポイントの URL (<code>Bashoutter.BashoutterApiEndpoint = XXXX</code> で得られた <code>XXXX</code> の文字列) をコマンドラインの変数に設定しておく．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">export</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ENDPOINT_URL=XXXX</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">export</span><span style="color: #24292E"> </span><span style="color: #032F62">ENDPOINT_URL=XXXX</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>次に，俳句の一覧を取得するため， <code>GET /haiku</code> の API を送信してみよう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">http</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">GET</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;${</span><span style="color: #ADBAC7">ENDPOINT_URL</span><span style="color: #96D0FF">}/haiku&quot;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">http</span><span style="color: #24292E"> </span><span style="color: #032F62">GET</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;${</span><span style="color: #24292E">ENDPOINT_URL</span><span style="color: #032F62">}/haiku&quot;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>現時点では，まだだれも俳句を投稿していないので，空の配列 (<code>[]</code>) が返ってくる．</p>
<p>それでは次に， <code>POST /haiku</code> を使って俳句を投稿してみよう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">http</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">POST</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;${</span><span style="color: #ADBAC7">ENDPOINT_URL</span><span style="color: #96D0FF">}/haiku&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">\</span></span>
<span class="line"><span style="color: #ADBAC7">username=</span><span style="color: #96D0FF">&quot;松尾芭蕉&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">\</span></span>
<span class="line"><span style="color: #ADBAC7">first=</span><span style="color: #96D0FF">&quot;閑さや&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">\</span></span>
<span class="line"><span style="color: #ADBAC7">second=</span><span style="color: #96D0FF">&quot;岩にしみ入る&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">\</span></span>
<span class="line"><span style="color: #ADBAC7">third=</span><span style="color: #96D0FF">&quot;蝉の声&quot;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">http</span><span style="color: #24292E"> </span><span style="color: #032F62">POST</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;${</span><span style="color: #24292E">ENDPOINT_URL</span><span style="color: #032F62">}/haiku&quot;</span><span style="color: #24292E"> </span><span style="color: #005CC5">\</span></span>
<span class="line"><span style="color: #24292E">username=</span><span style="color: #032F62">&quot;松尾芭蕉&quot;</span><span style="color: #24292E"> </span><span style="color: #005CC5">\</span></span>
<span class="line"><span style="color: #24292E">first=</span><span style="color: #032F62">&quot;閑さや&quot;</span><span style="color: #24292E"> </span><span style="color: #005CC5">\</span></span>
<span class="line"><span style="color: #24292E">second=</span><span style="color: #032F62">&quot;岩にしみ入る&quot;</span><span style="color: #24292E"> </span><span style="color: #005CC5">\</span></span>
<span class="line"><span style="color: #24292E">third=</span><span style="color: #032F62">&quot;蝉の声&quot;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br></div></div><p>次のような出力が得られるだろう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">HTTP/1.1</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">201</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">Created</span></span>
<span class="line"><span style="color: #F69D50">Connection:</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">keep-alive</span></span>
<span class="line"><span style="color: #F69D50">Content-Length:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">49</span></span>
<span class="line"><span style="color: #F69D50">Content-Type:</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">application/json</span></span>
<span class="line"><span style="color: #6CB6FF">....</span></span>
<span class="line"><span style="color: #ADBAC7">{</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">&quot;description&quot;</span><span style="color: #6CB6FF">:</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;Successfully added a new haiku&quot;</span></span>
<span class="line"><span style="color: #ADBAC7">}</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">HTTP/1.1</span><span style="color: #24292E"> </span><span style="color: #005CC5">201</span><span style="color: #24292E"> </span><span style="color: #032F62">Created</span></span>
<span class="line"><span style="color: #6F42C1">Connection:</span><span style="color: #24292E"> </span><span style="color: #032F62">keep-alive</span></span>
<span class="line"><span style="color: #6F42C1">Content-Length:</span><span style="color: #24292E"> </span><span style="color: #005CC5">49</span></span>
<span class="line"><span style="color: #6F42C1">Content-Type:</span><span style="color: #24292E"> </span><span style="color: #032F62">application/json</span></span>
<span class="line"><span style="color: #005CC5">....</span></span>
<span class="line"><span style="color: #24292E">{</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #6F42C1">&quot;description&quot;</span><span style="color: #005CC5">:</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;Successfully added a new haiku&quot;</span></span>
<span class="line"><span style="color: #24292E">}</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br></div></div><p>新しい俳句を投稿することに成功したようである． 本当に俳句が追加されたか，再び GET リクエストを呼ぶことで確認してみよう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">http</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">GET</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;${</span><span style="color: #ADBAC7">ENDPOINT_URL</span><span style="color: #96D0FF">}/haiku&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F69D50">HTTP/1.1</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">200</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">OK</span></span>
<span class="line"><span style="color: #F69D50">Connection:</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">keep-alive</span></span>
<span class="line"><span style="color: #F69D50">Content-Length:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">258</span></span>
<span class="line"><span style="color: #F69D50">Content-Type:</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">application/json</span></span>
<span class="line"><span style="color: #6CB6FF">...</span></span>
<span class="line"><span style="color: #ADBAC7">[</span></span>
<span class="line"><span style="color: #ADBAC7">    {</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #96D0FF">&quot;created_at&quot;</span><span style="color: #ADBAC7">: </span><span style="color: #96D0FF">&quot;2020-07-06T02:46:04+00:00&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #96D0FF">&quot;first&quot;</span><span style="color: #ADBAC7">: </span><span style="color: #96D0FF">&quot;閑さや&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #96D0FF">&quot;item_id&quot;</span><span style="color: #ADBAC7">: </span><span style="color: #96D0FF">&quot;7e91c5e4d7ad47909e0ac14c8bbab05b&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #96D0FF">&quot;likes&quot;</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">0.0</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #96D0FF">&quot;second&quot;</span><span style="color: #ADBAC7">: </span><span style="color: #96D0FF">&quot;岩にしみ入る&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #96D0FF">&quot;third&quot;</span><span style="color: #ADBAC7">: </span><span style="color: #96D0FF">&quot;蝉の声&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #96D0FF">&quot;username&quot;</span><span style="color: #ADBAC7">: </span><span style="color: #96D0FF">&quot;松尾芭蕉&quot;</span></span>
<span class="line"><span style="color: #ADBAC7">    }</span></span>
<span class="line"><span style="color: #ADBAC7">]</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">http</span><span style="color: #24292E"> </span><span style="color: #032F62">GET</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;${</span><span style="color: #24292E">ENDPOINT_URL</span><span style="color: #032F62">}/haiku&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6F42C1">HTTP/1.1</span><span style="color: #24292E"> </span><span style="color: #005CC5">200</span><span style="color: #24292E"> </span><span style="color: #032F62">OK</span></span>
<span class="line"><span style="color: #6F42C1">Connection:</span><span style="color: #24292E"> </span><span style="color: #032F62">keep-alive</span></span>
<span class="line"><span style="color: #6F42C1">Content-Length:</span><span style="color: #24292E"> </span><span style="color: #005CC5">258</span></span>
<span class="line"><span style="color: #6F42C1">Content-Type:</span><span style="color: #24292E"> </span><span style="color: #032F62">application/json</span></span>
<span class="line"><span style="color: #005CC5">...</span></span>
<span class="line"><span style="color: #24292E">[</span></span>
<span class="line"><span style="color: #24292E">    {</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #032F62">&quot;created_at&quot;</span><span style="color: #24292E">: </span><span style="color: #032F62">&quot;2020-07-06T02:46:04+00:00&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #032F62">&quot;first&quot;</span><span style="color: #24292E">: </span><span style="color: #032F62">&quot;閑さや&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #032F62">&quot;item_id&quot;</span><span style="color: #24292E">: </span><span style="color: #032F62">&quot;7e91c5e4d7ad47909e0ac14c8bbab05b&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #032F62">&quot;likes&quot;</span><span style="color: #24292E">: </span><span style="color: #005CC5">0.0</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #032F62">&quot;second&quot;</span><span style="color: #24292E">: </span><span style="color: #032F62">&quot;岩にしみ入る&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #032F62">&quot;third&quot;</span><span style="color: #24292E">: </span><span style="color: #032F62">&quot;蝉の声&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #032F62">&quot;username&quot;</span><span style="color: #24292E">: </span><span style="color: #032F62">&quot;松尾芭蕉&quot;</span></span>
<span class="line"><span style="color: #24292E">    }</span></span>
<span class="line"><span style="color: #24292E">]</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br></div></div><p>素晴らしい！</p>
<p>次に， <code>PATCH /haiku/{item_id}</code> を呼ぶことでこの俳句にいいねを追加してみよう． 一つ前のコマンドで取得した俳句の <code>item_id</code> を，次のコマンドの <code>XXXX</code> に代入した上で実行しよう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">http</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">PATCH</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;${</span><span style="color: #ADBAC7">ENDPOINT_URL</span><span style="color: #96D0FF">}/haiku/XXXX&quot;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">http</span><span style="color: #24292E"> </span><span style="color: #032F62">PATCH</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;${</span><span style="color: #24292E">ENDPOINT_URL</span><span style="color: #032F62">}/haiku/XXXX&quot;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p><code>{&quot;description&quot;: &quot;OK&quot;}</code> という出力が得られるはずである． 再び GET リクエストを送ることで，いいね (<code>likes</code>) が 1 増えたことを確認しよう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">http</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">GET</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;${</span><span style="color: #ADBAC7">ENDPOINT_URL</span><span style="color: #96D0FF">}/haiku&quot;</span></span>
<span class="line"><span style="color: #6CB6FF">...</span></span>
<span class="line"><span style="color: #ADBAC7">[</span></span>
<span class="line"><span style="color: #ADBAC7">    {</span></span>
<span class="line"><span style="color: #ADBAC7">        ...</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #96D0FF">&quot;likes&quot;</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">1.0</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        ...</span></span>
<span class="line"><span style="color: #ADBAC7">    }</span></span>
<span class="line"><span style="color: #ADBAC7">]</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">http</span><span style="color: #24292E"> </span><span style="color: #032F62">GET</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;${</span><span style="color: #24292E">ENDPOINT_URL</span><span style="color: #032F62">}/haiku&quot;</span></span>
<span class="line"><span style="color: #005CC5">...</span></span>
<span class="line"><span style="color: #24292E">[</span></span>
<span class="line"><span style="color: #24292E">    {</span></span>
<span class="line"><span style="color: #24292E">        ...</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #032F62">&quot;likes&quot;</span><span style="color: #24292E">: </span><span style="color: #005CC5">1.0</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        ...</span></span>
<span class="line"><span style="color: #24292E">    }</span></span>
<span class="line"><span style="color: #24292E">]</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br></div></div><p>最後に， DELETE リクエストを送ることで俳句をデータベースから削除しよう． <code>XXXX</code> は <code>item_id</code> の値で置き換えたうえで次のコマンドを実行する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">http</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">DELETE</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;${</span><span style="color: #ADBAC7">ENDPOINT_URL</span><span style="color: #96D0FF">}/haiku/XXXX&quot;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">http</span><span style="color: #24292E"> </span><span style="color: #032F62">DELETE</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;${</span><span style="color: #24292E">ENDPOINT_URL</span><span style="color: #032F62">}/haiku/XXXX&quot;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>再び GET リクエストを送ることで，返り値が空 (<code>[]</code>) になっていることを確認しよう．</p>
<p>これで，俳句の投稿・取得・削除そしていいねの追加，といった基本的な API がきちんと動作していることが確認できた．</p>
<h2 id="大量の-api-リクエストをシミュレートする" tabindex="-1">大量の API リクエストをシミュレートする <a class="header-anchor" href="#大量の-api-リクエストをシミュレートする" aria-label="Permalink to &quot;大量の API リクエストをシミュレートする&quot;">&ZeroWidthSpace;</a></h2>
<p>さて，前節ではマニュアルで一つずつ俳句を投稿した． 多数のユーザーがいるような SNS では，1 秒間に数千件以上の投稿がされている． 今回はサーバーレスアーキテクチャを採用したことで，そのような瞬間的な大量アクセスにも容易に対応できるようなシステムが自動的に構築されている． このポイントを実証するため，ここでは大量の API が送信された状況をシミュレートしてみよう．</p>
<p><a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/bashoutter/client.py" target="_blank" rel="noreferrer">handson/bashoutter/client.py</a> に，大量の API リクエストをシミュレートするためのプログラムが書かれている． このプログラムを使用すると， <code>POST /haiku</code> の API リクエストを指定された回数だけ実行することができる．</p>
<p>テストとして， API を 300 回実行してみよう． 次のコマンドを実行する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">client.py</span><span style="color: #ADBAC7"> $ENDPOINT_URL </span><span style="color: #96D0FF">post_many</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">300</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python</span><span style="color: #24292E"> </span><span style="color: #032F62">client.py</span><span style="color: #24292E"> $ENDPOINT_URL </span><span style="color: #032F62">post_many</span><span style="color: #24292E"> </span><span style="color: #005CC5">300</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>数秒のうちに実行が完了するだろう． これがもし，単一のサーバーからなる API だったとしたら，このような大量のリクエストの処理にはもっと時間がかかっただろう． 最悪の場合には，サーバーダウンにもつながっていたかもしれない． したがって，今回作成したサーバーレスアプリケーションは，とてもシンプルながらも 1 秒間に数百件の処理を行えるような，スケーラブルなクラウドシステムであることがわかる． サーバーレスでクラウドを設計することの利点を垣間見ることができただろうか？</p>
<p>先述のコマンドにより大量の俳句を投稿するとデータベースに無駄なデータがどんどん溜まってしまう． データベースを完全に空にするには，次のコマンドを使用する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">client.py</span><span style="color: #ADBAC7"> $ENDPOINT_URL </span><span style="color: #96D0FF">clear_database</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python</span><span style="color: #24292E"> </span><span style="color: #032F62">client.py</span><span style="color: #24292E"> $ENDPOINT_URL </span><span style="color: #032F62">clear_database</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><h2 id="bashoutter-gui-を動かしてみる" tabindex="-1">Bashoutter GUI を動かしてみる <a class="header-anchor" href="#bashoutter-gui-を動かしてみる" aria-label="Permalink to &quot;Bashoutter GUI を動かしてみる&quot;">&ZeroWidthSpace;</a></h2>
<p>前節ではコマンドラインから API を送信する演習を行った． ウェブアプリケーションでは，これと同じことがウェブブラウザの背後で行われ，ページのコンテンツが表示されている ( (#fig:web_server) 参照)． 最後に， API が GUI と統合されるとどうなるのか，見てみよう．</p>
<p>CDK のコードで， Public access mode の S3 バケットを作成したことを思い出してほしい． 最初のステップとして，ここにウェブサイトのコンテンツをアップロードしよう． ハンズオンのソースコードの中に <code>gui/dist</code> というフォルダが見つかるはずである． ここにはビルド済みのウェブサイトの静的コンテンツ (HTML/CSS/JavaScript) が入っている． AWS CLI のコマンドを使うことでこれらのファイルを S3 にアップロードしよう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">s3</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cp</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--recursive</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">./gui/dist</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">s3://</span><span style="color: #F47067">&lt;</span><span style="color: #96D0FF">BUCKET_NAM</span><span style="color: #ADBAC7">E</span><span style="color: #F47067">&gt;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">aws</span><span style="color: #24292E"> </span><span style="color: #032F62">s3</span><span style="color: #24292E"> </span><span style="color: #032F62">cp</span><span style="color: #24292E"> </span><span style="color: #005CC5">--recursive</span><span style="color: #24292E"> </span><span style="color: #032F62">./gui/dist</span><span style="color: #24292E"> </span><span style="color: #032F62">s3://</span><span style="color: #D73A49">&lt;</span><span style="color: #032F62">BUCKET_NAM</span><span style="color: #24292E">E</span><span style="color: #D73A49">&gt;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>コマンドを実行する際は， Bashoutter ハンズオンのディレクトリから行うこと (<code>./gui/dist</code> に注目)，そして <code>&lt;BUCKET_NAME&gt;</code> にはデプロイした自身のバケットの名前が入る点に注意． 念のため，AWS コンソールにログインし，バケットにファイルがアップロードされている点を確認しておこう．</p>
<p>なお，今回は GUI の説明はとくに行わないが， Bashoutter のウェブサイトは <a href="https://vuejs.org/" target="_blank" rel="noreferrer">Vue.js</a> と <a href="https://vuetifyjs.com/" target="_blank" rel="noreferrer">Vuetify</a> という UI フレームワークを使って作成した． Vue を使うことで， Single page application (SPA) の技術でウェブサイトの画面がレンダリングされる． ソースコードは <a href="https://github.com/andatoshiki/toshiki-notebooktree/main/handson/bashoutter/gui" target="_blank" rel="noreferrer">handson/bashoutter/gui</a> のディレクトリの中にあるので，興味のある読者は確認してみるとよい．</p>
<p>アップトードが完了したところで，続いてデプロイを実行したときにコマンドラインの出力を見直してみよう． <code>Bashoutter.BucketUrl=</code> で与えられた URL が見つかるはずである (<a href="#handson_05_cdk_output">figure_title</a>)． これは，先述したとおり， Public access mode の S3 バケットの URL である．</p>
<p>ウェブブラウザを開き，アドレスバーに S3 の URL を入力しへアクセスしてみよう． すると， <a href="#handson_05_bashoutter_2">figure_title</a> のようなページが表示されるはずである．</p>
<p><img src="./assets/handson-bashoutter/bashoutter_2.png" alt="&quot;Bashoutter&quot; の GUI 画面"></p>
<p>ページが表示されたら，一番上の &quot;API Endpoint URL&quot; と書いてあるテキストボックスに，今回デプロイした <strong>API Gateway の URL を入力</strong>する (今回のアプリケーションでは，API Gateway の URL はランダムに割り当てられるのでこのような GUI の仕様になっている)． そうしたら，画面の &quot;REFRESH&quot; と書いてあるボタンを押してみよう． データベースに俳句が登録済みであれば，俳句の一覧が表示されるはずである． 各俳句の左下にあるハートのアイコンをクリックすることで， &quot;like&quot; の票を入れることができる．</p>
<p>新しい俳句を投稿するには，五七五と投稿者の名前を入力して， &quot;POST&quot; を押す． &quot;POST&quot; を押した後は，再び &quot;REFRESH&quot; ボタンを押すことで最新の俳句のリストをデータベースから取得する．</p>
<h2 id="アプリケーションの削除" tabindex="-1">アプリケーションの削除 <a class="header-anchor" href="#アプリケーションの削除" aria-label="Permalink to &quot;アプリケーションの削除&quot;">&ZeroWidthSpace;</a></h2>
<p>これで， Bashoutter プロジェクトが完成した！ この SNS は，インターネットを通じて世界のどこからでもアクセスできる状態にある． また， <a href="#simulating_many_apis">大量の API リクエストをシミュレートする</a> で見たように，大量のユーザーの同時アクセスによる負荷がかかっても，柔軟にスケールが行われ遅延なく処理を行うことができる． 極めて簡素ながらも，立派なウェブサービスとしてのスペックは満たしているのである！</p>
<p>Bashoutter アプリを存分に楽しむことができたら，最後に忘れずにスタックを削除しよう．</p>
<p>コマンドラインからスタックの削除を実行するには，次のコマンドを使う．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cdk</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">destroy</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cdk</span><span style="color: #24292E"> </span><span style="color: #032F62">destroy</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>CDK のバージョンによっては S3 のバケットが空でないと， <code>cdk destroy</code> がエラーを出力する場合がある． この場合はスタックを削除する前に， S3 バケットの中身をすべて削除しなければならない．</p>
<p>コンソールから実行するには， S3 コンソールに行き，バケットの中身を開いたうえで，すべてのファイルを選択し， &quot;Actions&quot; → &quot;Delete&quot; を実行すればよいい．</p>
<p>コマンドラインから実行するには， 次のコマンドを使う． &lt;BUCKET NAME&gt; のところは，自分の バケットの名前 (&quot;BashoutterBucketXXXX&quot; というパターンの名前がついているはずである) に置き換えることを忘れずに．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">s3</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">rm</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">&lt;</span><span style="color: #96D0FF">BUCKET</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">NAM</span><span style="color: #ADBAC7">E</span><span style="color: #F47067">&gt;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--recursive</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">aws</span><span style="color: #24292E"> </span><span style="color: #032F62">s3</span><span style="color: #24292E"> </span><span style="color: #032F62">rm</span><span style="color: #24292E"> </span><span style="color: #D73A49">&lt;</span><span style="color: #032F62">BUCKET</span><span style="color: #24292E"> </span><span style="color: #032F62">NAM</span><span style="color: #24292E">E</span><span style="color: #D73A49">&gt;</span><span style="color: #24292E"> </span><span style="color: #005CC5">--recursive</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><h2 id="小括" tabindex="-1">小括 <a class="header-anchor" href="#小括" aria-label="Permalink to &quot;小括&quot;">&ZeroWidthSpace;</a></h2>
<p>ここまでが，本書第三部の内容であった．</p>
<p>第三部では，クラウドの応用として，一般の人に使ってもらうようなウェブアプリケーション・データベースをどのようにして作るのか，という点に焦点を当てて，説明を行った． その中で，従来的なクラウドシステムの設計と，ここ数年の最新の設計方法であるサーバーレスアーキテクチャについて解説した． (#sec_intro_serverless) では， AWS でのサーバーレスの実践として， Lambda, S3, DynamoDB のハンズオンを行った． 最後に， <a href="#sec_bashoutter">Hands-on #6: Bashoutter</a> では，これらの技術を統合することで，完全サーバーレスなウェブアプリケーション &quot;Bashoutter&quot; を作成した．</p>
<p>これらの演習を通じて，世の中のウェブサービスがどのようにしてでき上がっているのか，少し理解が深まっただろうか？ また，そのようなウェブアプリケーションを自分が作りたいと思ったとき，今回のハンズオンがその出発点となることができたならば幸いである．</p>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hands-on #1: 初めての EC2 インスタンスを起動する ]]></title>
            <link>https://note.toshiki.devdevelopment/aws/handson-ec2</link>
            <guid>https://note.toshiki.devdevelopment/aws/handson-ec2</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="hands-on-1-初めての-ec2-インスタンスを起動する" tabindex="-1">Hands-on #1: 初めての EC2 インスタンスを起動する <a class="header-anchor" href="#hands-on-1-初めての-ec2-インスタンスを起動する" aria-label="Permalink to &quot;Hands-on \#1: 初めての EC2 インスタンスを起動する&quot;">&ZeroWidthSpace;</a></h1>
<p>ハンズオンの第一回では， CDK を使って EC2 のインスタンス(仮想サーバー)を作成し，SSH でサーバーにログインする，という演習を行う． このハンズオンを終えれば，あなたは自分だけのサーバーを AWS 上に立ち上げ，自由に計算を走らせることができるようになるのである！</p>
<h2 id="準備" tabindex="-1">準備 <a class="header-anchor" href="#準備" aria-label="Permalink to &quot;準備&quot;">&ZeroWidthSpace;</a></h2>
<p>ハンズオンのソースコードは GitHub の <a href="https://github.com/andatoshiki/toshiki-notebooktree/main/handson/ec2-get-started" target="_blank" rel="noreferrer">handson/ec2-get-started</a> に置いてある．</p>
<p>このハンズオンは，基本的に <a href="https://aws.amazon.com/free/?all-free-tier.sort-by=item.additionalFields.SortRank&amp;all-free-tier.sort-order=asc" target="_blank" rel="noreferrer">AWS の無料枠</a> の範囲内で実行することができる．</p>
<p>まずは，ハンズオンを実行するための環境を整える． これらの環境整備は，後のハンズオンでも前提となるものなので確実にミスなく行っていただきたい．</p>
<ul>
<li>
<p><strong>AWS Account</strong>: ハンズオンを実行するには個人の AWS アカウントが必要である． AWS アカウントの取得については (#sec:create_aws_account) を参照のこと．</p>
</li>
<li>
<p><strong>Python と Node.js</strong>: 本ハンズオンを実行するには，Python (3.6 以上)，Node.js (12.0 以上) がインストールされていなければならない．</p>
</li>
<li>
<p><strong>AWS CLI</strong>: AWS CLI のインストールについては， (#aws_cli_install) を参照． ここに記載されている認証鍵の設定も済ませておくこと．</p>
</li>
<li>
<p><strong>AWS CDK</strong>: AWS CDK のインストールについては， (#aws_cdk_install) を参照．</p>
</li>
<li>
<p><strong>ソースコードのダウンロード</strong>: 本ハンズオンで使用するプログラムのソースコードを，以下のコマンドを使って GitHub からダウンロードする．</p>
</li>
</ul>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">git</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">clone</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">https://github.com/tomomano/learn-aws-by-coding.git</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">git</span><span style="color: #24292E"> </span><span style="color: #032F62">clone</span><span style="color: #24292E"> </span><span style="color: #032F62">https://github.com/tomomano/learn-aws-by-coding.git</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>あるいは， <a href="https://github.com/tomomano/learn-aws-by-coding" target="_blank" rel="noreferrer">https://github.com/tomomano/learn-aws-by-coding</a> のページに行って，右上のダウンロードボタンからダウンロードすることもできる．</p>
<p><strong>Docker を使用する場合</strong></p>
<p>Python, Node.js, AWS CDK など，ハンズオンのプログラムを実行するために必要なプログラム/ライブラリがインストール済みの Docker image を用意した． また，ハンズオンのソースコードもパッケージ済みである． Docker の使い方を知っている読者は，これを使えば，諸々のインストールをする必要なく，すぐにハンズオンのプログラムを実行できる．</p>
<p>使用方法については (#sec_handson_docker) を参照のこと．</p>
<h2 id="ssh" tabindex="-1">SSH <a class="header-anchor" href="#ssh" aria-label="Permalink to &quot;SSH&quot;">&ZeroWidthSpace;</a></h2>
<p><strong>SSH (secure shell)</strong> は Unix 系のリモートサーバーに安全にアクセスするためのツールである． 本ハンズオンでは， SSH を使って仮想サーバーにアクセスする． SSH に慣れていない読者のため，簡単な説明をここで行おう．</p>
<p>SSH による通信はすべて暗号化されているので，機密情報をインターネットを介して安全に送受信することができる． 本ハンズオンで，リモートのサーバーにアクセスするための SSH クライアントがローカルマシンにインストールされている必要がある． SSH クライアントは Linux/Mac には標準搭載されている． Windows の場合は WSL をインストールすることで SSH クライアントを利用することを推奨する ( (#environments) を参照)．</p>
<p>SSH コマンドの基本的な使い方を次に示す． <code>&lt;host name&gt;</code> はアクセスする先のサーバーの IP アドレスや DNS によるホストネームが入る． <code>&lt;user name&gt;</code> は接続する先のユーザー名である．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ssh</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">&lt;</span><span style="color: #96D0FF">user</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">nam</span><span style="color: #ADBAC7">e</span><span style="color: #F47067">&gt;</span><span style="color: #96D0FF">@</span><span style="color: #F47067">&lt;</span><span style="color: #96D0FF">host</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">nam</span><span style="color: #ADBAC7">e</span><span style="color: #F47067">&gt;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">ssh</span><span style="color: #24292E"> </span><span style="color: #D73A49">&lt;</span><span style="color: #032F62">user</span><span style="color: #24292E"> </span><span style="color: #032F62">nam</span><span style="color: #24292E">e</span><span style="color: #D73A49">&gt;</span><span style="color: #032F62">@</span><span style="color: #D73A49">&lt;</span><span style="color: #032F62">host</span><span style="color: #24292E"> </span><span style="color: #032F62">nam</span><span style="color: #24292E">e</span><span style="color: #D73A49">&gt;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>SSH は平文のパスワードによる認証を行うこともできるが，より強固なセキュリティを施すため，<strong>公開鍵暗号方式(Public Key Cryptography)による認証</strong>を行うことが強く推奨されており， EC2 はこの方法でしかアクセスを許していない． 公開鍵暗号方式の仕組みについては各自勉強してほしい． 本ハンズオンにおいて大事なことは，<strong>EC2 インスタンスが公開鍵(Public key)を保持し，クライアントとなるコンピュータ(読者自身のコンピュータ)が秘密鍵(Private key)を保持する</strong>，という点である． EC2 のインスタンスには秘密鍵を持ったコンピュータのみがアクセスすることができる．逆に言うと，秘密鍵が漏洩すると第三者もサーバーにアクセスできることになるので，<strong>秘密鍵は絶対に漏洩することのないよう注意して管理する</strong>．</p>
<p>SSH コマンドでは，ログインのために使用する秘密鍵ファイルを <code>-i</code> もしくは <code>--identity_file</code> のオプションで指定することができる． たとえば，次のように使う．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ssh</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-i</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">Ec2SecretKey.pem</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">&lt;</span><span style="color: #96D0FF">user</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">nam</span><span style="color: #ADBAC7">e</span><span style="color: #F47067">&gt;</span><span style="color: #96D0FF">@</span><span style="color: #F47067">&lt;</span><span style="color: #96D0FF">host</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">nam</span><span style="color: #ADBAC7">e</span><span style="color: #F47067">&gt;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">ssh</span><span style="color: #24292E"> </span><span style="color: #005CC5">-i</span><span style="color: #24292E"> </span><span style="color: #032F62">Ec2SecretKey.pem</span><span style="color: #24292E"> </span><span style="color: #D73A49">&lt;</span><span style="color: #032F62">user</span><span style="color: #24292E"> </span><span style="color: #032F62">nam</span><span style="color: #24292E">e</span><span style="color: #D73A49">&gt;</span><span style="color: #032F62">@</span><span style="color: #D73A49">&lt;</span><span style="color: #032F62">host</span><span style="color: #24292E"> </span><span style="color: #032F62">nam</span><span style="color: #24292E">e</span><span style="color: #D73A49">&gt;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><h2 id="アプリケーションの説明" tabindex="-1">アプリケーションの説明 <a class="header-anchor" href="#アプリケーションの説明" aria-label="Permalink to &quot;アプリケーションの説明&quot;">&ZeroWidthSpace;</a></h2>
<p>このハンズオンで作成するアプリケーションの概要を <a href="#handson_01_architecture">figure_title</a> に示す．</p>
<p><img src="./assets/handson-01/app_architecture.png" alt="ハンズオン#1で作製するアプリケーションのアーキテクチャ"></p>
<p>このアプリケーションではまず，<strong>VPC (Virtual Private Cloud)</strong> を使ってプライベートな仮想ネットワーク環境を立ち上げている． その VPC の public subnet の内側に，<strong>EC2 (Elatic Compute Cloud)</strong> の仮想サーバーを配置する． さらに，セキュリティのため， <strong>Security Group</strong> による EC2 インスタンスへのアクセス制限を設定している． このようにして作成された仮想サーバーに，SSH を使ってアクセスし，簡単な計算を行う．</p>
<p><a href="#handson_01_architecture">figure_title</a> のようなアプリケーションを，CDK を使って構築する．</p>
<p>早速ではあるが，今回のハンズオンで使用するプログラムを見てみよう (<a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/ec2-get-started/app.py" target="_blank" rel="noreferrer">handson/ec2-get-started/app.py</a>)．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">class</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50">MyFirstEc2</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">core</span><span style="color: #ADBAC7">.</span><span style="color: #6CB6FF">Stack</span><span style="color: #ADBAC7">):</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">def</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">__init__</span><span style="color: #ADBAC7">(self, scope: core.App, name: </span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">, key_name: </span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">, </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">kwargs) -&gt; </span><span style="color: #6CB6FF">None</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #6CB6FF">super</span><span style="color: #ADBAC7">().</span><span style="color: #6CB6FF">__init__</span><span style="color: #ADBAC7">(scope, name, </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">kwargs)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        vpc </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ec2.Vpc(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;MyFirstEc2-Vpc&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">max_azs</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">cidr</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;10.10.0.0/23&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">subnet_configuration</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">[</span></span>
<span class="line"><span style="color: #ADBAC7">                ec2.SubnetConfiguration(</span></span>
<span class="line"><span style="color: #ADBAC7">                    </span><span style="color: #F69D50">name</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;public&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                    </span><span style="color: #F69D50">subnet_type</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.SubnetType.</span><span style="color: #6CB6FF">PUBLIC</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                )</span></span>
<span class="line"><span style="color: #ADBAC7">            ],</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">nat_gateways</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        sg </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ec2.SecurityGroup(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;MyFirstEc2Vpc-Sg&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">vpc</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">vpc,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">allow_all_outbound</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">True</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"><span style="color: #ADBAC7">        sg.add_ingress_rule(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">peer</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.Peer.any_ipv4(),</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">connection</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.Port.tcp(</span><span style="color: #6CB6FF">22</span><span style="color: #ADBAC7">),</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        host </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ec2.Instance(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;MyFirstEc2Instance&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">instance_type</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.InstanceType(</span><span style="color: #96D0FF">&quot;t2.micro&quot;</span><span style="color: #ADBAC7">),</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">machine_image</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.MachineImage.latest_amazon_linux(),</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">vpc</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">vpc,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">vpc_subnets</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.SubnetSelection(</span><span style="color: #F69D50">subnet_type</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.SubnetType.</span><span style="color: #6CB6FF">PUBLIC</span><span style="color: #ADBAC7">),</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">security_group</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">sg,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">key_name</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">key_name</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">class</span><span style="color: #24292E"> </span><span style="color: #6F42C1">MyFirstEc2</span><span style="color: #24292E">(</span><span style="color: #6F42C1">core</span><span style="color: #24292E">.</span><span style="color: #6F42C1">Stack</span><span style="color: #24292E">):</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">def</span><span style="color: #24292E"> </span><span style="color: #005CC5">__init__</span><span style="color: #24292E">(self, scope: core.App, name: </span><span style="color: #005CC5">str</span><span style="color: #24292E">, key_name: </span><span style="color: #005CC5">str</span><span style="color: #24292E">, </span><span style="color: #D73A49">**</span><span style="color: #24292E">kwargs) -&gt; </span><span style="color: #005CC5">None</span><span style="color: #24292E">:</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #005CC5">super</span><span style="color: #24292E">().</span><span style="color: #005CC5">__init__</span><span style="color: #24292E">(scope, name, </span><span style="color: #D73A49">**</span><span style="color: #24292E">kwargs)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        vpc </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ec2.Vpc(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;MyFirstEc2-Vpc&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">max_azs</span><span style="color: #D73A49">=</span><span style="color: #005CC5">1</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">cidr</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;10.10.0.0/23&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">subnet_configuration</span><span style="color: #D73A49">=</span><span style="color: #24292E">[</span></span>
<span class="line"><span style="color: #24292E">                ec2.SubnetConfiguration(</span></span>
<span class="line"><span style="color: #24292E">                    </span><span style="color: #E36209">name</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;public&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                    </span><span style="color: #E36209">subnet_type</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.SubnetType.</span><span style="color: #005CC5">PUBLIC</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                )</span></span>
<span class="line"><span style="color: #24292E">            ],</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">nat_gateways</span><span style="color: #D73A49">=</span><span style="color: #005CC5">0</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        sg </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ec2.SecurityGroup(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;MyFirstEc2Vpc-Sg&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">vpc</span><span style="color: #D73A49">=</span><span style="color: #24292E">vpc,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">allow_all_outbound</span><span style="color: #D73A49">=</span><span style="color: #005CC5">True</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"><span style="color: #24292E">        sg.add_ingress_rule(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">peer</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.Peer.any_ipv4(),</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">connection</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.Port.tcp(</span><span style="color: #005CC5">22</span><span style="color: #24292E">),</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        host </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ec2.Instance(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;MyFirstEc2Instance&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">instance_type</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.InstanceType(</span><span style="color: #032F62">&quot;t2.micro&quot;</span><span style="color: #24292E">),</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">machine_image</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.MachineImage.latest_amazon_linux(),</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">vpc</span><span style="color: #D73A49">=</span><span style="color: #24292E">vpc,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">vpc_subnets</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.SubnetSelection(</span><span style="color: #E36209">subnet_type</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.SubnetType.</span><span style="color: #005CC5">PUBLIC</span><span style="color: #24292E">),</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">security_group</span><span style="color: #D73A49">=</span><span style="color: #24292E">sg,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">key_name</span><span style="color: #D73A49">=</span><span style="color: #24292E">key_name</span></span>
<span class="line"><span style="color: #24292E">        )</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br><span class="line-number">36</span><br><span class="line-number">37</span><br><span class="line-number">38</span><br><span class="line-number">39</span><br><span class="line-number">40</span><br></div></div><ul>
<li>
<p>まず最初に，VPC を定義する．</p>
</li>
<li>
<p>次に， security group (SG) を定義している． ここでは，任意の IPv4 のアドレスからの，ポート 22 (SSH の接続に使用される)への接続を許可している． それ以外の接続は拒絶される．</p>
</li>
<li>
<p>最後に，上記で作った VPC と SG が付与された EC2 インスタンスを作成している． インスタンスタイプは <code>t2.micro</code> を選択し， <a href="https://aws.amazon.com/amazon-linux-ami/" target="_blank" rel="noreferrer">Amazon Linux</a> を OS として設定している．</p>
</li>
</ul>
<p>それぞれについて，もう少し詳しく説明しよう．</p>
<h3 id="vpc-virtual-private-cloud" tabindex="-1">VPC (Virtual Private Cloud) <a class="header-anchor" href="#vpc-virtual-private-cloud" aria-label="Permalink to &quot;VPC (Virtual Private Cloud)&quot;">&ZeroWidthSpace;</a></h3>
<p><strong>VPC のアイコン.</strong></p>
<p><img src="./assets/aws_logos/VPC.png" alt="VPC"></p>
<p>VPC は AWS 上にプライベートな仮想ネットワーク環境を構築するツールである．高度な計算システムを構築するには，複数のサーバーを連動させて計算を行う必要があるが，そのような場合に互いのアドレスなどを管理する必要があり，そういった目的で VPC は有用である．</p>
<p>本ハンズオンでは，サーバーは一つしか起動しないので，VPC の恩恵はよく分からないかもしれない．しかし，EC2 インスタンスは必ず VPC の中に配置されなければならない，という制約があるので，このハンズオンでもミニマルな VPC を構成している．</p>
<p>興味のある読者のために，VPC のコードについてもう少し詳しく説明しよう．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">vpc </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ec2.Vpc(</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;MyFirstEc2-Vpc&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">max_azs</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">cidr</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;10.10.0.0/23&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">subnet_configuration</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">[</span></span>
<span class="line"><span style="color: #ADBAC7">        ec2.SubnetConfiguration(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">name</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;public&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">subnet_type</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.SubnetType.</span><span style="color: #6CB6FF">PUBLIC</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"><span style="color: #ADBAC7">    ],</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">nat_gateways</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">vpc </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ec2.Vpc(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;MyFirstEc2-Vpc&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">max_azs</span><span style="color: #D73A49">=</span><span style="color: #005CC5">1</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">cidr</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;10.10.0.0/23&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">subnet_configuration</span><span style="color: #D73A49">=</span><span style="color: #24292E">[</span></span>
<span class="line"><span style="color: #24292E">        ec2.SubnetConfiguration(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">name</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;public&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">subnet_type</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.SubnetType.</span><span style="color: #005CC5">PUBLIC</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"><span style="color: #24292E">    ],</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">nat_gateways</span><span style="color: #D73A49">=</span><span style="color: #005CC5">0</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br></div></div><ul>
<li>
<p><code>max_azs=1</code> : このパラメータは，前章で説明した avaialibility zone (AZ) を設定している． このハンズオンでは，特にデータセンターの障害などを気にする必要はないので <code>1</code> にしている．</p>
</li>
<li>
<p><code>cidr=&quot;10.10.0.0/23&quot;</code> : このパラメータは，VPC 内の IPv4 のレンジを指定している． CIDR 記法については， <a href="https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing" target="_blank" rel="noreferrer">Wikipedia</a>などを参照． <code>10.10.0.0/23</code> は <code>10.10.0.0</code> から <code>10.10.1.255</code> までの 512 個の連続したアドレス範囲を指している． つまり，この VPC では最大で 512 個のユニークな IPv4 アドレスが使えることになる． 今回はサーバーは一つなので 512 個は明らかに多すぎるが，VPC はアドレスの数はどれだけ作成しても無料なので，多めに作成した．</p>
</li>
<li>
<p><code>subnet_configuration=...</code> : このパラメータは，VPC にどのようなサブネットを作るか，を決めている． サブネットの種類には <strong>private subnet</strong> と <strong>public subnet</strong> の二種類がある． private subnet は基本的にインターネットとは遮断されたサブネット環境である． インターネットと繋がっていないので，セキュリティは極めて高く， VPC 内のサーバーとのみ通信を行えばよい EC2 インスタンスはここに配置する． Public subnet とはインターネットに繋がったサブネットである． 本ハンズオンで作成するサーバーは，外から SSH でログインを行いたいので， Public subnet 内に配置する． より詳細な記述は <a href="https://docs.aws.amazon.com/vpc/latest/userguide/VPC_Subnets.html#vpc-subnet-basics" target="_blank" rel="noreferrer">公式ドキュメンテーション</a> を参照．</p>
</li>
<li>
<p><code>natgateways=0</code> : これは少し高度な内容なので省略する (興味のある読者は <a href="https://docs.aws.amazon.com/vpc/latest/userguide/vpc-nat-gateway.html" target="_blank" rel="noreferrer">公式ドキュメンテーション</a>を参照)． が，<strong>これを 0 にしておかないと，NAT Gateway の利用料金が発生してしまうので，注意！</strong></p>
</li>
</ul>
<h3 id="security-group" tabindex="-1">Security Group <a class="header-anchor" href="#security-group" aria-label="Permalink to &quot;Security Group&quot;">&ZeroWidthSpace;</a></h3>
<p>Security group (SG) は， EC2 インスタンスに付与することのできる仮想ファイアーウォールである． たとえば，特定の IP アドレスから来た接続を許可・拒絶したり　(インバウンド・トラフィックの制限) ，逆に特定の IP アドレスへのアクセスを禁止したり (アウトバウンド・トラフィックの制限) することができる．</p>
<p>コードの該当部分を見てみよう．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">sg </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ec2.SecurityGroup(</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;MyFirstEc2Vpc-Sg&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">vpc</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">vpc,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">allow_all_outbound</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">True</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">sg.add_ingress_rule(</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">peer</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.Peer.any_ipv4(),</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">connection</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.Port.tcp(</span><span style="color: #6CB6FF">22</span><span style="color: #ADBAC7">),</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">sg </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ec2.SecurityGroup(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;MyFirstEc2Vpc-Sg&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">vpc</span><span style="color: #D73A49">=</span><span style="color: #24292E">vpc,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">allow_all_outbound</span><span style="color: #D73A49">=</span><span style="color: #005CC5">True</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">sg.add_ingress_rule(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">peer</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.Peer.any_ipv4(),</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">connection</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.Port.tcp(</span><span style="color: #005CC5">22</span><span style="color: #24292E">),</span></span>
<span class="line"><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br></div></div><p>本ハンズオンでは， SSH による外部からの接続を許容するため， <code>sg.add_ingress_rule(peer=ec2.Peer.any_ipv4(), connection=ec2.Port.tcp(22))</code> により，すべての IPv4 アドレスからのポート 22 番へのアクセスを許容している． また， SSH で EC2 インスタンスにログインしたのち，インターネットからプログラムなどをダウンロードできるよう， <code>allow_all_outbound=True</code> のパラメータを設定している．</p>
<p>SSH はデフォルトでは 22 番ポートを使用するのが慣例である．</p>
<p>セキュリティ上の観点からは，SSH の接続は自宅や大学・職場など特定の地点からの接続のみを許す方が望ましい．</p>
<h3 id="ec2-elastic-compute-cloud" tabindex="-1">EC2 (Elastic Compute Cloud) <a class="header-anchor" href="#ec2-elastic-compute-cloud" aria-label="Permalink to &quot;EC2 (Elastic Compute Cloud)&quot;">&ZeroWidthSpace;</a></h3>
<p><strong>EC2 のアイコン.</strong></p>
<p><img src="./assets/aws_logos/EC2.png" alt="EC2"></p>
<p>EC2 は AWS 上に仮想サーバーを立ち上げるサービスである． 個々の起動状態にある仮想サーバーのことをインスタンス (instance) とよぶ (しかし，口語的なコミュニケーションにおいては，サーバーとインスタンスという言葉は相互互換的に用いられることが多い)．</p>
<p>EC2 では用途に応じて様々なインスタンスタイプが提供されている． <a href="#ec2_instance_types">table_title</a> に，代表的なインスタンスタイプの例を挙げる (執筆時点での情報)． EC2 のインスタンスタイプのすべてのリストは <a href="https://aws.amazon.com/ec2/instance-types/" target="_blank" rel="noreferrer">公式ドキュメンテーション &quot;Amazon EC2 Instance Types&quot;</a> で見ることができる．</p>
<h3 id="ec2-instance-types" tabindex="-1">EC2 instance types <a class="header-anchor" href="#ec2-instance-types" aria-label="Permalink to &quot;EC2 instance types&quot;">&ZeroWidthSpace;</a></h3>
<table>
<thead>
<tr>
<th>Instance</th>
<th>vCPU</th>
<th>Memory (GiB)</th>
<th>Network bandwidth (Gbps)</th>
<th>Price per hour ($)</th>
</tr>
</thead>
<tbody>
<tr>
<td>t2.micro</td>
<td>1</td>
<td>1</td>
<td>-</td>
<td>0.0116</td>
</tr>
<tr>
<td>t2.small</td>
<td>1</td>
<td>2</td>
<td>-</td>
<td>0.023</td>
</tr>
<tr>
<td>t2.medium</td>
<td>2</td>
<td>4</td>
<td>-</td>
<td>0.0464</td>
</tr>
<tr>
<td>c5.24xlarge</td>
<td>96</td>
<td>192</td>
<td>25</td>
<td>4.08</td>
</tr>
<tr>
<td>c5n.18xlarge</td>
<td>72</td>
<td>192</td>
<td>100</td>
<td>3.888</td>
</tr>
<tr>
<td>x1e.16xlarge</td>
<td>64</td>
<td>1952</td>
<td>10</td>
<td>13.344</td>
</tr>
</tbody>
</table>
<p><a href="#ec2_instance_types">table_title</a> からわかるように， CPU は 1 コアから 96 コアまで，メモリーは 1GB から 2TB 以上まで，ネットワーク帯域は最大で 100Gbps まで，幅広く選択することができる． また，時間あたりの料金は，CPU・メモリーの占有数にほぼ比例する形で増加する． EC2 はサーバーの起動時間を秒単位で記録しており，<strong>利用料金は使用時間に比例する形で決定される</strong>． 例えば， <code>t2.medium</code> のインスタンスを 10 時間起動した場合，0.0464 * 10 = 0.464 ドルの料金が発生する．</p>
<p>AWS には <a href="https://aws.amazon.com/free/?all-free-tier.sort-by=item.additionalFields.SortRank&amp;all-free-tier.sort-order=asc" target="_blank" rel="noreferrer">無料利用枠</a> というものがあり， <code>t2.micro</code> であれば月に 750 時間までは無料で利用することができる．</p>
<p><a href="#ec2_instance_types">table_title</a> の価格は <code>us-east-1</code> のものである． リージョンによって多少価格設定が異なる．</p>
<p>上記で t2.micro の $0.0116 / hour という金額は， On-demand インスタンスというタイプを選択した場合の価格である． EC2 ではほかに， <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-spot-instances.html" target="_blank" rel="noreferrer">Spot instance</a> とよばれるインスタンスも存在しする． Spot instance は，AWS のデータセンターの負荷が増えた場合，ユーザーのプログラムが実行中であっても AWS の判断により強制シャットダウンされる，という不便さを抱えているのだが，その分大幅に安い料金設定になっている． AWS で一時的に生じた余剰な空き CPU をユーザーに割安で貸し出す，という発想である． 科学計算やウェブサーバーなどの用途でコストを削減する目的で， Spot Instance を活用する事例も多数報告されている．</p>
<p>EC2 インスタンスを定義しているコードの該当部分を見てみよう．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">host </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ec2.Instance(</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;MyFirstEc2Instance&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">instance_type</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.InstanceType(</span><span style="color: #96D0FF">&quot;t2.micro&quot;</span><span style="color: #ADBAC7">),</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">machine_image</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.MachineImage.latest_amazon_linux(),</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">vpc</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">vpc,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">vpc_subnets</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.SubnetSelection(</span><span style="color: #F69D50">subnet_type</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.SubnetType.</span><span style="color: #6CB6FF">PUBLIC</span><span style="color: #ADBAC7">),</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">security_group</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">sg,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">key_name</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">key_name</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">host </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ec2.Instance(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;MyFirstEc2Instance&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">instance_type</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.InstanceType(</span><span style="color: #032F62">&quot;t2.micro&quot;</span><span style="color: #24292E">),</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">machine_image</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.MachineImage.latest_amazon_linux(),</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">vpc</span><span style="color: #D73A49">=</span><span style="color: #24292E">vpc,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">vpc_subnets</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.SubnetSelection(</span><span style="color: #E36209">subnet_type</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.SubnetType.</span><span style="color: #005CC5">PUBLIC</span><span style="color: #24292E">),</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">security_group</span><span style="color: #D73A49">=</span><span style="color: #24292E">sg,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">key_name</span><span style="color: #D73A49">=</span><span style="color: #24292E">key_name</span></span>
<span class="line"><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br></div></div><p>ここでは， <code>t2.micro</code> というインスタンスタイプを選択している． さらに， <code>machine_image</code> として， <a href="https://aws.amazon.com/amazon-linux-ami/" target="_blank" rel="noreferrer">Amazon Linux</a> を選択している (Machine image は OS と似た概念である． Machine image については， (#sec_jupyter_and_deep_learning) でより詳しく触れる)． さらに，上で定義した VPC, SG をこのインスタンスに付与している．</p>
<p>以上が，今回使用するプログラムの簡単な解説であった． ミニマルな形のプログラムではあるが，仮想サーバーを作成するのに必要なステップがおわかりいただけただろうか？</p>
<h2 id="プログラムを実行する" tabindex="-1">プログラムを実行する <a class="header-anchor" href="#プログラムを実行する" aria-label="Permalink to &quot;プログラムを実行する&quot;">&ZeroWidthSpace;</a></h2>
<p>さて，ハンズオンのコードの理解ができたところで，プログラムを実際に実行してみよう．繰り返しになるが， <a href="#handson_01_prep">準備</a> での準備ができていることが前提である．</p>
<h3 id="python-の依存ライブラリのインストール" tabindex="-1">Python の依存ライブラリのインストール <a class="header-anchor" href="#python-の依存ライブラリのインストール" aria-label="Permalink to &quot;Python の依存ライブラリのインストール&quot;">&ZeroWidthSpace;</a></h3>
<p>まずは，Python の依存ライブラリをインストールする．以下では，Python のライブラリを管理するツールとして， <a href="https://docs.python.org/3/library/venv.html" target="_blank" rel="noreferrer">venv</a> を使用する．</p>
<p>まずは， <code>handson/ec2-get-started</code> のディレクトリに移動しよう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cd</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">handson/ec2-get-started</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cd</span><span style="color: #24292E"> </span><span style="color: #032F62">handson/ec2-get-started</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>ディレクトリを移動したら， <code>venv</code> で新しい仮想環境を作成し，インストールを実行する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python3</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-m</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">venv</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.env</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">source</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.env/bin/activate</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">pip</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">install</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-r</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">requirements.txt</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python3</span><span style="color: #24292E"> </span><span style="color: #005CC5">-m</span><span style="color: #24292E"> </span><span style="color: #032F62">venv</span><span style="color: #24292E"> </span><span style="color: #032F62">.env</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">source</span><span style="color: #24292E"> </span><span style="color: #032F62">.env/bin/activate</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">pip</span><span style="color: #24292E"> </span><span style="color: #032F62">install</span><span style="color: #24292E"> </span><span style="color: #005CC5">-r</span><span style="color: #24292E"> </span><span style="color: #032F62">requirements.txt</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><p>これで Python の環境構築は完了だ．</p>
<p><code>venv</code> の簡単な説明は (#venv_quick_guide) に記述してある．</p>
<p>環境によっては <code>pip</code> ではなく <code>pip3</code> あるいは <code>python3 -m pip</code> に置き換える必要がある．</p>
<h3 id="aws-のシークレットキーをセットする" tabindex="-1">AWS のシークレットキーをセットする <a class="header-anchor" href="#aws-のシークレットキーをセットする" aria-label="Permalink to &quot;AWS のシークレットキーをセットする&quot;">&ZeroWidthSpace;</a></h3>
<p>AWS CLI および AWS CDK を使うには， AWS のシークレットキーが設定されている必要がある． シークレットキーの発行については (#aws_secrets) を参照のこと． シークレットキーを発行したら， (#aws_cli_install) を参照し，コマンドラインの設定を行う．</p>
<p>手順をここに短く要約すると，一つ目の方法は <code>AWS_ACCESS_KEY_ID</code> などの環境変数を設定するやり方である． もう一つの方法は， <code>~/.aws/credentials</code> に認証情報を保存しておく方式である． シークレットキーの設定は AWS CLI/CDK を使用するうえで共通のステップになるので，しっかりと理解しておくように．</p>
<h3 id="ssh-鍵を生成" tabindex="-1">SSH 鍵を生成 <a class="header-anchor" href="#ssh-鍵を生成" aria-label="Permalink to &quot;SSH 鍵を生成&quot;">&ZeroWidthSpace;</a></h3>
<p>EC2 インスタンスには SSH を使ってログインする． EC2 インスタンスを作成するのに先行して，今回のハンズオンで専用に使う SSH の公開鍵・秘密鍵のペアを準備する必要がある．</p>
<p>次の AWS CLI コマンドにより， <code>HirakeGoma</code> という名前のついた鍵を生成する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">export</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">KEY_NAME=&quot;HirakeGoma&quot;</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ec2</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">create-key-pair</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--key-name</span><span style="color: #ADBAC7"> ${KEY_NAME} </span><span style="color: #6CB6FF">--query</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;KeyMaterial&#39;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--output</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">text</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">&gt;</span><span style="color: #ADBAC7"> ${KEY_NAME}</span><span style="color: #96D0FF">.pem</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">export</span><span style="color: #24292E"> </span><span style="color: #032F62">KEY_NAME=&quot;HirakeGoma&quot;</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">aws</span><span style="color: #24292E"> </span><span style="color: #032F62">ec2</span><span style="color: #24292E"> </span><span style="color: #032F62">create-key-pair</span><span style="color: #24292E"> </span><span style="color: #005CC5">--key-name</span><span style="color: #24292E"> ${KEY_NAME} </span><span style="color: #005CC5">--query</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;KeyMaterial&#39;</span><span style="color: #24292E"> </span><span style="color: #005CC5">--output</span><span style="color: #24292E"> </span><span style="color: #032F62">text</span><span style="color: #24292E"> </span><span style="color: #D73A49">&gt;</span><span style="color: #24292E"> ${KEY_NAME}</span><span style="color: #032F62">.pem</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>このコマンドを実行すると，現在のディレクトリに <code>HirakeGoma.pem</code> というファイルが作成される．これが，サーバーにアクセスするための秘密鍵である． SSH でこの鍵を使うため， <code>~/.ssh/</code> のディレクトリに鍵を移動する． さらに，秘密鍵が書き換えられたり第三者に閲覧されないよう，ファイルのアクセス権限を <code>400</code> に設定する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">mv</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">HirakeGoma.pem</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">~/.ssh/</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">chmod</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">400</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">~/.ssh/HirakeGoma.pem</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">mv</span><span style="color: #24292E"> </span><span style="color: #032F62">HirakeGoma.pem</span><span style="color: #24292E"> </span><span style="color: #032F62">~/.ssh/</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">chmod</span><span style="color: #24292E"> </span><span style="color: #005CC5">400</span><span style="color: #24292E"> </span><span style="color: #032F62">~/.ssh/HirakeGoma.pem</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><h3 id="デプロイを実行" tabindex="-1">デプロイを実行 <a class="header-anchor" href="#デプロイを実行" aria-label="Permalink to &quot;デプロイを実行&quot;">&ZeroWidthSpace;</a></h3>
<p>これまでのステップで， EC2 インスタンスをデプロイするための準備が整った！ 早速，次のコマンドによりアプリケーションを AWS にデプロイしよう． <code>-c key_name=&quot;HirakeGoma&quot;</code> というオプションで，先ほど生成した <code>HirakeGoma</code> という名前の鍵を使うよう指定している．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cdk</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">deploy</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-c</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">key_name=&quot;HirakeGoma&quot;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cdk</span><span style="color: #24292E"> </span><span style="color: #032F62">deploy</span><span style="color: #24292E"> </span><span style="color: #005CC5">-c</span><span style="color: #24292E"> </span><span style="color: #032F62">key_name=&quot;HirakeGoma&quot;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>このコマンドを実行すると， VPC， EC2 などが AWS 上に展開される． そして，コマンドの出力の最後に <a href="#handson_01_cdk_output">figure_title</a> のような出力が得られるはずである． <strong>出力の中で <code>InstancePublicIp</code> に続く数字が，起動したインスタンスのパブリック IP アドレスである．</strong> IP アドレスはデプロイごとにランダムなアドレスが割り当てられる．</p>
<p><img src="./assets/handson-01/cdk_output.png" alt="CDKデプロイ実行後の出力"></p>
<h3 id="ssh-でログイン" tabindex="-1">SSH でログイン <a class="header-anchor" href="#ssh-でログイン" aria-label="Permalink to &quot;SSH でログイン&quot;">&ZeroWidthSpace;</a></h3>
<p>早速，SSH 　で接続してみよう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ssh</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-i</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">~/.ssh/HirakeGoma.pem</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ec2-user@</span><span style="color: #F47067">&lt;</span><span style="color: #96D0FF">IP</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">addres</span><span style="color: #ADBAC7">s</span><span style="color: #F47067">&gt;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">ssh</span><span style="color: #24292E"> </span><span style="color: #005CC5">-i</span><span style="color: #24292E"> </span><span style="color: #032F62">~/.ssh/HirakeGoma.pem</span><span style="color: #24292E"> </span><span style="color: #032F62">ec2-user@</span><span style="color: #D73A49">&lt;</span><span style="color: #032F62">IP</span><span style="color: #24292E"> </span><span style="color: #032F62">addres</span><span style="color: #24292E">s</span><span style="color: #D73A49">&gt;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p><code>-i</code> オプションで，先ほど生成した秘密鍵を指定している． EC2 インスタンスにはデフォルトで <code>ec2-user</code> という名前のユーザーが作られているので，それを使用する． 最後に， <code>&lt;IP address&gt;</code> の部分は自身が作成した EC2 インスタンスの IP アドレスで置き換える (<code>12.345.678.9</code> など）．</p>
<p>ログインに成功すると， <a href="#fig_handson_01_ssh_login">figure_title</a> のような画面が表示される． リモートのサーバーにログインしているので，プロンプトが <code>[ec2-user@ip-10-10-1-217 ~]$</code> のようになっていることを確認しよう．</p>
<p><img src="./assets/handson-01/ssh_login.png" alt="SSH で EC2 インスタンスにログイン"></p>
<p><strong>おめでとう！これで，めでたく AWS 上に EC2 仮想サーバーを起動し，リモートからアクセスできるようになった！</strong></p>
<h3 id="起動した-ec2-インスタンスで遊んでみる" tabindex="-1">起動した EC2 インスタンスで遊んでみる <a class="header-anchor" href="#起動した-ec2-インスタンスで遊んでみる" aria-label="Permalink to &quot;起動した EC2 インスタンスで遊んでみる&quot;">&ZeroWidthSpace;</a></h3>
<p>せっかく新しいインスタンスを起動したので，少し遊んでみよう．</p>
<p>ログインした EC2 インスタンスで，次のコマンドを実行してみよう． CPU の情報を取得することができる．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cat</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">/proc/cpuinfo</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F69D50">processor</span><span style="color: #ADBAC7">       </span><span style="color: #96D0FF">:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0</span></span>
<span class="line"><span style="color: #F69D50">vendor_id</span><span style="color: #ADBAC7">       </span><span style="color: #96D0FF">:</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">GenuineIntel</span></span>
<span class="line"><span style="color: #F69D50">cpu</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">family</span><span style="color: #ADBAC7">      </span><span style="color: #96D0FF">:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">6</span></span>
<span class="line"><span style="color: #F69D50">model</span><span style="color: #ADBAC7">           </span><span style="color: #96D0FF">:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">63</span></span>
<span class="line"><span style="color: #F69D50">model</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">name</span><span style="color: #ADBAC7">      </span><span style="color: #96D0FF">:</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">Intel</span><span style="color: #ADBAC7">(</span><span style="color: #F69D50">R</span><span style="color: #ADBAC7">) </span><span style="color: #96D0FF">Xeon</span><span style="color: #ADBAC7">(</span><span style="color: #F69D50">R</span><span style="color: #ADBAC7">) </span><span style="color: #96D0FF">CPU</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">E5-2676</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">v3</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">@</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">2.40</span><span style="color: #96D0FF">GHz</span></span>
<span class="line"><span style="color: #F69D50">stepping</span><span style="color: #ADBAC7">        </span><span style="color: #96D0FF">:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">2</span></span>
<span class="line"><span style="color: #F69D50">microcode</span><span style="color: #ADBAC7">       </span><span style="color: #96D0FF">:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0x43</span></span>
<span class="line"><span style="color: #F69D50">cpu</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">MHz</span><span style="color: #ADBAC7">         </span><span style="color: #96D0FF">:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">2400.096</span></span>
<span class="line"><span style="color: #F69D50">cache</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">size</span><span style="color: #ADBAC7">      </span><span style="color: #96D0FF">:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">30720</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">KB</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cat</span><span style="color: #24292E"> </span><span style="color: #032F62">/proc/cpuinfo</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6F42C1">processor</span><span style="color: #24292E">       </span><span style="color: #032F62">:</span><span style="color: #24292E"> </span><span style="color: #005CC5">0</span></span>
<span class="line"><span style="color: #6F42C1">vendor_id</span><span style="color: #24292E">       </span><span style="color: #032F62">:</span><span style="color: #24292E"> </span><span style="color: #032F62">GenuineIntel</span></span>
<span class="line"><span style="color: #6F42C1">cpu</span><span style="color: #24292E"> </span><span style="color: #032F62">family</span><span style="color: #24292E">      </span><span style="color: #032F62">:</span><span style="color: #24292E"> </span><span style="color: #005CC5">6</span></span>
<span class="line"><span style="color: #6F42C1">model</span><span style="color: #24292E">           </span><span style="color: #032F62">:</span><span style="color: #24292E"> </span><span style="color: #005CC5">63</span></span>
<span class="line"><span style="color: #6F42C1">model</span><span style="color: #24292E"> </span><span style="color: #032F62">name</span><span style="color: #24292E">      </span><span style="color: #032F62">:</span><span style="color: #24292E"> </span><span style="color: #032F62">Intel</span><span style="color: #24292E">(</span><span style="color: #6F42C1">R</span><span style="color: #24292E">) </span><span style="color: #032F62">Xeon</span><span style="color: #24292E">(</span><span style="color: #6F42C1">R</span><span style="color: #24292E">) </span><span style="color: #032F62">CPU</span><span style="color: #24292E"> </span><span style="color: #032F62">E5-2676</span><span style="color: #24292E"> </span><span style="color: #032F62">v3</span><span style="color: #24292E"> </span><span style="color: #032F62">@</span><span style="color: #24292E"> </span><span style="color: #005CC5">2.40</span><span style="color: #032F62">GHz</span></span>
<span class="line"><span style="color: #6F42C1">stepping</span><span style="color: #24292E">        </span><span style="color: #032F62">:</span><span style="color: #24292E"> </span><span style="color: #005CC5">2</span></span>
<span class="line"><span style="color: #6F42C1">microcode</span><span style="color: #24292E">       </span><span style="color: #032F62">:</span><span style="color: #24292E"> </span><span style="color: #005CC5">0x43</span></span>
<span class="line"><span style="color: #6F42C1">cpu</span><span style="color: #24292E"> </span><span style="color: #032F62">MHz</span><span style="color: #24292E">         </span><span style="color: #032F62">:</span><span style="color: #24292E"> </span><span style="color: #005CC5">2400.096</span></span>
<span class="line"><span style="color: #6F42C1">cache</span><span style="color: #24292E"> </span><span style="color: #032F62">size</span><span style="color: #24292E">      </span><span style="color: #032F62">:</span><span style="color: #24292E"> </span><span style="color: #005CC5">30720</span><span style="color: #24292E"> </span><span style="color: #032F62">KB</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br></div></div><p>次に，実行中のプロセスやメモリの消費を見てみよう．</p>
<div class="language-bash vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7">  </span><span style="color: #96D0FF">top</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-n</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">1</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F69D50">top</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">-</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">09</span><span style="color: #96D0FF">:29:19</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">up</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">43</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">min,</span><span style="color: #ADBAC7">  </span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">user,</span><span style="color: #ADBAC7">  </span><span style="color: #96D0FF">load</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">average:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0.00</span><span style="color: #96D0FF">,</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0.00</span><span style="color: #96D0FF">,</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0.00</span></span>
<span class="line"><span style="color: #F69D50">Tasks:</span><span style="color: #ADBAC7">  </span><span style="color: #6CB6FF">76</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">total,</span><span style="color: #ADBAC7">   </span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">running,</span><span style="color: #ADBAC7">  </span><span style="color: #6CB6FF">51</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">sleeping,</span><span style="color: #ADBAC7">   </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">stopped,</span><span style="color: #ADBAC7">   </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">zombie</span></span>
<span class="line"><span style="color: #F69D50">Cpu(s</span><span style="color: #ADBAC7">):  0.3%us,  0.3%sy,  0.1%ni, 98.9%id,  0.2%wa,  0.0%hi,  0.0%si,  0.2%st</span></span>
<span class="line"><span style="color: #F69D50">Mem:</span><span style="color: #ADBAC7">   </span><span style="color: #6CB6FF">1009140</span><span style="color: #96D0FF">k</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">total,</span><span style="color: #ADBAC7">   </span><span style="color: #6CB6FF">270760</span><span style="color: #96D0FF">k</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">used,</span><span style="color: #ADBAC7">   </span><span style="color: #6CB6FF">738380</span><span style="color: #96D0FF">k</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">free,</span><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">14340</span><span style="color: #96D0FF">k</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">buffers</span></span>
<span class="line"><span style="color: #F69D50">Swap:</span><span style="color: #ADBAC7">        </span><span style="color: #6CB6FF">0</span><span style="color: #96D0FF">k</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">total,</span><span style="color: #ADBAC7">        </span><span style="color: #6CB6FF">0</span><span style="color: #96D0FF">k</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">used,</span><span style="color: #ADBAC7">        </span><span style="color: #6CB6FF">0</span><span style="color: #96D0FF">k</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">free,</span><span style="color: #ADBAC7">   </span><span style="color: #6CB6FF">185856</span><span style="color: #96D0FF">k</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cached</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #F69D50">PID</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">USER</span><span style="color: #ADBAC7">      </span><span style="color: #96D0FF">PR</span><span style="color: #ADBAC7">  </span><span style="color: #96D0FF">NI</span><span style="color: #ADBAC7">  </span><span style="color: #96D0FF">VIRT</span><span style="color: #ADBAC7">  </span><span style="color: #96D0FF">RES</span><span style="color: #ADBAC7">  </span><span style="color: #96D0FF">SHR</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">S</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">%CPU</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">%MEM</span><span style="color: #ADBAC7">    </span><span style="color: #96D0FF">TIME+</span><span style="color: #ADBAC7">  </span><span style="color: #96D0FF">COMMAND</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">1</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">root</span><span style="color: #ADBAC7">      </span><span style="color: #6CB6FF">20</span><span style="color: #ADBAC7">   </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">19696</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">2596</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">2268</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">S</span><span style="color: #ADBAC7">  </span><span style="color: #6CB6FF">0.0</span><span style="color: #ADBAC7">  </span><span style="color: #6CB6FF">0.3</span><span style="color: #ADBAC7">   </span><span style="color: #6CB6FF">0</span><span style="color: #96D0FF">:01.21</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">init</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">2</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">root</span><span style="color: #ADBAC7">      </span><span style="color: #6CB6FF">20</span><span style="color: #ADBAC7">   </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">     </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">S</span><span style="color: #ADBAC7">  </span><span style="color: #6CB6FF">0.0</span><span style="color: #ADBAC7">  </span><span style="color: #6CB6FF">0.0</span><span style="color: #ADBAC7">   </span><span style="color: #6CB6FF">0</span><span style="color: #96D0FF">:00.00</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">kthreadd</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">3</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">root</span><span style="color: #ADBAC7">      </span><span style="color: #6CB6FF">20</span><span style="color: #ADBAC7">   </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">     </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">I</span><span style="color: #ADBAC7">  </span><span style="color: #6CB6FF">0.0</span><span style="color: #ADBAC7">  </span><span style="color: #6CB6FF">0.0</span><span style="color: #ADBAC7">   </span><span style="color: #6CB6FF">0</span><span style="color: #96D0FF">:00.00</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">kworker/0:0</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E">  </span><span style="color: #032F62">top</span><span style="color: #24292E"> </span><span style="color: #005CC5">-n</span><span style="color: #24292E"> </span><span style="color: #005CC5">1</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6F42C1">top</span><span style="color: #24292E"> </span><span style="color: #032F62">-</span><span style="color: #24292E"> </span><span style="color: #005CC5">09</span><span style="color: #032F62">:29:19</span><span style="color: #24292E"> </span><span style="color: #032F62">up</span><span style="color: #24292E"> </span><span style="color: #005CC5">43</span><span style="color: #24292E"> </span><span style="color: #032F62">min,</span><span style="color: #24292E">  </span><span style="color: #005CC5">1</span><span style="color: #24292E"> </span><span style="color: #032F62">user,</span><span style="color: #24292E">  </span><span style="color: #032F62">load</span><span style="color: #24292E"> </span><span style="color: #032F62">average:</span><span style="color: #24292E"> </span><span style="color: #005CC5">0.00</span><span style="color: #032F62">,</span><span style="color: #24292E"> </span><span style="color: #005CC5">0.00</span><span style="color: #032F62">,</span><span style="color: #24292E"> </span><span style="color: #005CC5">0.00</span></span>
<span class="line"><span style="color: #6F42C1">Tasks:</span><span style="color: #24292E">  </span><span style="color: #005CC5">76</span><span style="color: #24292E"> </span><span style="color: #032F62">total,</span><span style="color: #24292E">   </span><span style="color: #005CC5">1</span><span style="color: #24292E"> </span><span style="color: #032F62">running,</span><span style="color: #24292E">  </span><span style="color: #005CC5">51</span><span style="color: #24292E"> </span><span style="color: #032F62">sleeping,</span><span style="color: #24292E">   </span><span style="color: #005CC5">0</span><span style="color: #24292E"> </span><span style="color: #032F62">stopped,</span><span style="color: #24292E">   </span><span style="color: #005CC5">0</span><span style="color: #24292E"> </span><span style="color: #032F62">zombie</span></span>
<span class="line"><span style="color: #6F42C1">Cpu(s</span><span style="color: #24292E">):  0.3%us,  0.3%sy,  0.1%ni, 98.9%id,  0.2%wa,  0.0%hi,  0.0%si,  0.2%st</span></span>
<span class="line"><span style="color: #6F42C1">Mem:</span><span style="color: #24292E">   </span><span style="color: #005CC5">1009140</span><span style="color: #032F62">k</span><span style="color: #24292E"> </span><span style="color: #032F62">total,</span><span style="color: #24292E">   </span><span style="color: #005CC5">270760</span><span style="color: #032F62">k</span><span style="color: #24292E"> </span><span style="color: #032F62">used,</span><span style="color: #24292E">   </span><span style="color: #005CC5">738380</span><span style="color: #032F62">k</span><span style="color: #24292E"> </span><span style="color: #032F62">free,</span><span style="color: #24292E">    </span><span style="color: #005CC5">14340</span><span style="color: #032F62">k</span><span style="color: #24292E"> </span><span style="color: #032F62">buffers</span></span>
<span class="line"><span style="color: #6F42C1">Swap:</span><span style="color: #24292E">        </span><span style="color: #005CC5">0</span><span style="color: #032F62">k</span><span style="color: #24292E"> </span><span style="color: #032F62">total,</span><span style="color: #24292E">        </span><span style="color: #005CC5">0</span><span style="color: #032F62">k</span><span style="color: #24292E"> </span><span style="color: #032F62">used,</span><span style="color: #24292E">        </span><span style="color: #005CC5">0</span><span style="color: #032F62">k</span><span style="color: #24292E"> </span><span style="color: #032F62">free,</span><span style="color: #24292E">   </span><span style="color: #005CC5">185856</span><span style="color: #032F62">k</span><span style="color: #24292E"> </span><span style="color: #032F62">cached</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">  </span><span style="color: #6F42C1">PID</span><span style="color: #24292E"> </span><span style="color: #032F62">USER</span><span style="color: #24292E">      </span><span style="color: #032F62">PR</span><span style="color: #24292E">  </span><span style="color: #032F62">NI</span><span style="color: #24292E">  </span><span style="color: #032F62">VIRT</span><span style="color: #24292E">  </span><span style="color: #032F62">RES</span><span style="color: #24292E">  </span><span style="color: #032F62">SHR</span><span style="color: #24292E"> </span><span style="color: #032F62">S</span><span style="color: #24292E"> </span><span style="color: #032F62">%CPU</span><span style="color: #24292E"> </span><span style="color: #032F62">%MEM</span><span style="color: #24292E">    </span><span style="color: #032F62">TIME+</span><span style="color: #24292E">  </span><span style="color: #032F62">COMMAND</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #6F42C1">1</span><span style="color: #24292E"> </span><span style="color: #032F62">root</span><span style="color: #24292E">      </span><span style="color: #005CC5">20</span><span style="color: #24292E">   </span><span style="color: #005CC5">0</span><span style="color: #24292E"> </span><span style="color: #005CC5">19696</span><span style="color: #24292E"> </span><span style="color: #005CC5">2596</span><span style="color: #24292E"> </span><span style="color: #005CC5">2268</span><span style="color: #24292E"> </span><span style="color: #032F62">S</span><span style="color: #24292E">  </span><span style="color: #005CC5">0.0</span><span style="color: #24292E">  </span><span style="color: #005CC5">0.3</span><span style="color: #24292E">   </span><span style="color: #005CC5">0</span><span style="color: #032F62">:01.21</span><span style="color: #24292E"> </span><span style="color: #032F62">init</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #6F42C1">2</span><span style="color: #24292E"> </span><span style="color: #032F62">root</span><span style="color: #24292E">      </span><span style="color: #005CC5">20</span><span style="color: #24292E">   </span><span style="color: #005CC5">0</span><span style="color: #24292E">     </span><span style="color: #005CC5">0</span><span style="color: #24292E">    </span><span style="color: #005CC5">0</span><span style="color: #24292E">    </span><span style="color: #005CC5">0</span><span style="color: #24292E"> </span><span style="color: #032F62">S</span><span style="color: #24292E">  </span><span style="color: #005CC5">0.0</span><span style="color: #24292E">  </span><span style="color: #005CC5">0.0</span><span style="color: #24292E">   </span><span style="color: #005CC5">0</span><span style="color: #032F62">:00.00</span><span style="color: #24292E"> </span><span style="color: #032F62">kthreadd</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #6F42C1">3</span><span style="color: #24292E"> </span><span style="color: #032F62">root</span><span style="color: #24292E">      </span><span style="color: #005CC5">20</span><span style="color: #24292E">   </span><span style="color: #005CC5">0</span><span style="color: #24292E">     </span><span style="color: #005CC5">0</span><span style="color: #24292E">    </span><span style="color: #005CC5">0</span><span style="color: #24292E">    </span><span style="color: #005CC5">0</span><span style="color: #24292E"> </span><span style="color: #032F62">I</span><span style="color: #24292E">  </span><span style="color: #005CC5">0.0</span><span style="color: #24292E">  </span><span style="color: #005CC5">0.0</span><span style="color: #24292E">   </span><span style="color: #005CC5">0</span><span style="color: #032F62">:00.00</span><span style="color: #24292E"> </span><span style="color: #032F62">kworker/0:0</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br></div></div><p><code>t2.micro</code> インスタンスなので， 1009140k = 1GB のメモリーがあることがわかる．</p>
<p>今回起動したインスタンスには Python 2 はインストール済みだが， Python 3 は入っていない． Python 3.6 のインストールを行ってみよう． インストールは簡単である．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">sudo</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">yum</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">update</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-y</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">sudo</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">yum</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">install</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-y</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python36</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">sudo</span><span style="color: #24292E"> </span><span style="color: #032F62">yum</span><span style="color: #24292E"> </span><span style="color: #032F62">update</span><span style="color: #24292E"> </span><span style="color: #005CC5">-y</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">sudo</span><span style="color: #24292E"> </span><span style="color: #032F62">yum</span><span style="color: #24292E"> </span><span style="color: #032F62">install</span><span style="color: #24292E"> </span><span style="color: #005CC5">-y</span><span style="color: #24292E"> </span><span style="color: #032F62">python36</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>インストールした Python を起動してみよう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python3</span></span>
<span class="line"><span style="color: #F69D50">Python</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">3.6</span><span style="color: #96D0FF">.10</span><span style="color: #ADBAC7"> (default, </span><span style="color: #96D0FF">Feb</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">10</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">2020</span><span style="color: #96D0FF">,</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">19</span><span style="color: #96D0FF">:55:14</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">[GCC </span><span style="color: #6CB6FF">4.8</span><span style="color: #ADBAC7">.5 </span><span style="color: #6CB6FF">20150623</span><span style="color: #ADBAC7"> (Red Hat </span><span style="color: #6CB6FF">4.8</span><span style="color: #ADBAC7">.5-28)] on linux</span></span>
<span class="line"><span style="color: #F69D50">Type</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;help&quot;,</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;copyright&quot;,</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;credits&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">or</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;license&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">for</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">more</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">information.</span></span>
<span class="line"><span style="color: #ADBAC7">&gt;&gt;&gt;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python3</span></span>
<span class="line"><span style="color: #6F42C1">Python</span><span style="color: #24292E"> </span><span style="color: #005CC5">3.6</span><span style="color: #032F62">.10</span><span style="color: #24292E"> (default, </span><span style="color: #032F62">Feb</span><span style="color: #24292E"> </span><span style="color: #005CC5">10</span><span style="color: #24292E"> </span><span style="color: #005CC5">2020</span><span style="color: #032F62">,</span><span style="color: #24292E"> </span><span style="color: #005CC5">19</span><span style="color: #032F62">:55:14</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">[GCC </span><span style="color: #005CC5">4.8</span><span style="color: #24292E">.5 </span><span style="color: #005CC5">20150623</span><span style="color: #24292E"> (Red Hat </span><span style="color: #005CC5">4.8</span><span style="color: #24292E">.5-28)] on linux</span></span>
<span class="line"><span style="color: #6F42C1">Type</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;help&quot;,</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;copyright&quot;,</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;credits&quot;</span><span style="color: #24292E"> </span><span style="color: #032F62">or</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;license&quot;</span><span style="color: #24292E"> </span><span style="color: #032F62">for</span><span style="color: #24292E"> </span><span style="color: #032F62">more</span><span style="color: #24292E"> </span><span style="color: #032F62">information.</span></span>
<span class="line"><span style="color: #24292E">&gt;&gt;&gt;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br></div></div><p>Python のインタープリタが起動した！ <code>Ctrl + D</code> あるいは <code>exit()</code> と入力することで，インタープリタを閉じることができる．</p>
<p>さて，サーバーでのお遊びはこんなところにしておこう (興味があれば各自いろいろと試してみると良い) ． 次のコマンドでログアウトする．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">exit</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">exit</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><h3 id="aws-コンソールから確認" tabindex="-1">AWS コンソールから確認 <a class="header-anchor" href="#aws-コンソールから確認" aria-label="Permalink to &quot;AWS コンソールから確認&quot;">&ZeroWidthSpace;</a></h3>
<p>これまでは，すべてコマンドラインから EC2 に関連する操作を行ってきた． EC2 インスタンスの状態を確認したり，サーバーをシャットダウンするなどの操作は，AWS コンソールから実行することもできる． 軽くこれを紹介しよう．</p>
<p>まず，ウェブブラウザを開いて AWS コンソールにログインする． ログインしたら， <code>Services</code> から <code>EC2</code> を検索(選択)する． 次に，左のサイドバーの <code>Instances</code> とページをたどる. すると， <a href="#aws_ec2_console">figure_title</a> のような画面が得られるはずである． この画面で，自分のアカウントの管理下にあるインスタンスを確認できる． 同様に，VPC・SG についてもコンソールから確認できる．</p>
<p><img src="./assets/handson-01/ec2_console.png" alt="EC2 コンソール画面"></p>
<p><strong>コンソール右上で，正しいリージョン (今回の場合は ap-northeast-1, Tokyo) が選択されているか，注意する！</strong></p>
<p>前章で CloudFormation について触れたが，今回デプロイしたアプリケーションも，CloudFormation のスタックとして管理されている． <strong>スタック (stack)</strong> とは， AWS リソースの集合のことを指す． 今回の場合は， VPC/EC2/SG などがスタックの中に含まれている． コンソールで <code>CloudFormation</code> のページに行ってみよう (<a href="#aws_cloudformation_console">figure_title</a>)．</p>
<p><img src="./assets/handson-01/cloudformation_console.png" alt="CloudFormation コンソール画面"></p>
<p>&quot;MyFirstEc2&quot; という名前のスタックがあることが確認できる． クリックをして中身を見てみると，EC2, VPC などのリソースがこのスタックに紐付いていることがわかる．</p>
<h3 id="スタックを削除" tabindex="-1">スタックを削除 <a class="header-anchor" href="#スタックを削除" aria-label="Permalink to &quot;スタックを削除&quot;">&ZeroWidthSpace;</a></h3>
<p>これにて，第一回のハンズオンで説明すべき事柄はすべて完了した． 最後に，使わなくなったスタックを削除しよう． スタックの削除には，二つの方法がある．</p>
<p>一つ目の方法は，前節の Cloudformation のコンソール画面で， &quot;Delete&quot; ボタンを押すことである (<a href="#cloudformation_delete">figure_title</a>)． すると，スタックの状態が <code>&quot;DELETE_IN_PROGRESS&quot;</code> に変わり，削除が完了すると CloudFormation のスタックの一覧から消える．</p>
<p><img src="./assets/handson-01/cloudformation_delete.png" alt="CloudFormationコンソール画面から，スタックを削除"></p>
<p>二つ目の方法は，コマンドラインから行う方法である． 先ほど，デプロイを行ったコマンドラインに戻ろう． そうしたら，次のコマンドを実行する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cdk</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">destroy</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cdk</span><span style="color: #24292E"> </span><span style="color: #032F62">destroy</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>このコマンドを実行すると，スタックの削除が始まる． 削除した後は，VPC, EC2 など，すべて跡形もなく消え去っていることを自身で確かめよう． CloudFormation を用いることで関連するすべての AWS リソースを一度に管理・削除することができるので，大変便利である．</p>
<p><strong>スタックの削除は各自で必ず行うこと！</strong> 行わなかった場合， EC2 インスタンスの料金が発生し続けることになる！</p>
<p>また，本ハンズオンのために作成した SSH 鍵ペアも不要なので，削除しておく． まず， EC2 側に登録してある公開鍵を削除する． これも，コンソールおよびコマンドラインの二つの方法で実行できる．</p>
<p>コンソールから実行するには， <code>EC2</code> の画面に行き，左のサイドバーの <code>Key Pairs</code> を選択する． 鍵の一覧が表示されるので， <code>HirakeGoma</code> とある鍵にチェックを入れ，画面右上の <code>Actions</code> から， <code>Delete</code> を実行する (<a href="#delete_ec2_key_pair">figure_title</a>)．</p>
<p><img src="./assets/handson-01/ec2_keypair_console.png" alt="EC2でSSH鍵ペアを削除"></p>
<p>コマンドラインから実行するには，次のコマンドを使う．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ec2</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">delete-key-pair</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--key-name</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;HirakeGoma&quot;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">aws</span><span style="color: #24292E"> </span><span style="color: #032F62">ec2</span><span style="color: #24292E"> </span><span style="color: #032F62">delete-key-pair</span><span style="color: #24292E"> </span><span style="color: #005CC5">--key-name</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;HirakeGoma&quot;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>最後に，ローカルのコンピュータから鍵を削除する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">rm</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-f</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">~/.ssh/HirakeGoma.pem</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">rm</span><span style="color: #24292E"> </span><span style="color: #005CC5">-f</span><span style="color: #24292E"> </span><span style="color: #032F62">~/.ssh/HirakeGoma.pem</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>これで，クラウドの片付けもすべて終了だ．</p>
<p>なお，頻繁に EC2 インスタンスを起動したりする場合は，いちいち SSH 鍵を削除する必要はない．</p>
<h2 id="小括" tabindex="-1">小括 <a class="header-anchor" href="#小括" aria-label="Permalink to &quot;小括&quot;">&ZeroWidthSpace;</a></h2>
<p>ここまでが，本書の第一部の内容である． 盛りだくさんの内容であったが，ついてこれたであろうか？</p>
<p>(#chap_cloud_basics) では，クラウドの定義と用語の説明を行ったあと，なぜクラウドを使うのか，という点を議論した． 続いて (#sec_aws_general_introduction) では，クラウドを学ぶ具体的なプラットフォームとして AWS を取り上げ， AWS を使用するにあたり最低限必要な知識と用語の説明を行った． さらに， <a href="#sec_first_ec2">Hands-on #1: 初めての EC2 インスタンスを起動する</a> のハンズオンでは AWS CLI と AWS CDK を使って，自身のプライベートなサーバーを AWS 上に立ち上げる演習を行った．</p>
<p>これらを通じて，いかに簡単に (たった数行のコマンドで！) 仮想サーバーを立ち上げたり，削除したりすることができるか，体験できただろう． 筆者は， (#chap_cloud_basics) でクラウドの最も重要な側面はダイナミックに計算リソースを拡大・縮小できることである，と述べた． この言葉の意味が，ハンズオンを通じてより明らかになっただろうか？ ここで学んだ技術を少し応用するだけで，自分のウェブページをホストする仮想サーバーを作成したり，大量のコアを搭載した EC2 インスタンスを用意して科学計算を実行するなど，いろいろなアプリケーションが実現できる．</p>
<p>次章からは，今回学んだクラウドの技術を基に，より現実に即した問題を解くことを体験してもらう． お楽しみに！</p>
]]></description>
            <content:encoded><![CDATA[<h1 id="hands-on-1-初めての-ec2-インスタンスを起動する" tabindex="-1">Hands-on #1: 初めての EC2 インスタンスを起動する <a class="header-anchor" href="#hands-on-1-初めての-ec2-インスタンスを起動する" aria-label="Permalink to &quot;Hands-on \#1: 初めての EC2 インスタンスを起動する&quot;">&ZeroWidthSpace;</a></h1>
<p>ハンズオンの第一回では， CDK を使って EC2 のインスタンス(仮想サーバー)を作成し，SSH でサーバーにログインする，という演習を行う． このハンズオンを終えれば，あなたは自分だけのサーバーを AWS 上に立ち上げ，自由に計算を走らせることができるようになるのである！</p>
<h2 id="準備" tabindex="-1">準備 <a class="header-anchor" href="#準備" aria-label="Permalink to &quot;準備&quot;">&ZeroWidthSpace;</a></h2>
<p>ハンズオンのソースコードは GitHub の <a href="https://github.com/andatoshiki/toshiki-notebooktree/main/handson/ec2-get-started" target="_blank" rel="noreferrer">handson/ec2-get-started</a> に置いてある．</p>
<p>このハンズオンは，基本的に <a href="https://aws.amazon.com/free/?all-free-tier.sort-by=item.additionalFields.SortRank&amp;all-free-tier.sort-order=asc" target="_blank" rel="noreferrer">AWS の無料枠</a> の範囲内で実行することができる．</p>
<p>まずは，ハンズオンを実行するための環境を整える． これらの環境整備は，後のハンズオンでも前提となるものなので確実にミスなく行っていただきたい．</p>
<ul>
<li>
<p><strong>AWS Account</strong>: ハンズオンを実行するには個人の AWS アカウントが必要である． AWS アカウントの取得については (#sec:create_aws_account) を参照のこと．</p>
</li>
<li>
<p><strong>Python と Node.js</strong>: 本ハンズオンを実行するには，Python (3.6 以上)，Node.js (12.0 以上) がインストールされていなければならない．</p>
</li>
<li>
<p><strong>AWS CLI</strong>: AWS CLI のインストールについては， (#aws_cli_install) を参照． ここに記載されている認証鍵の設定も済ませておくこと．</p>
</li>
<li>
<p><strong>AWS CDK</strong>: AWS CDK のインストールについては， (#aws_cdk_install) を参照．</p>
</li>
<li>
<p><strong>ソースコードのダウンロード</strong>: 本ハンズオンで使用するプログラムのソースコードを，以下のコマンドを使って GitHub からダウンロードする．</p>
</li>
</ul>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">git</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">clone</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">https://github.com/tomomano/learn-aws-by-coding.git</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">git</span><span style="color: #24292E"> </span><span style="color: #032F62">clone</span><span style="color: #24292E"> </span><span style="color: #032F62">https://github.com/tomomano/learn-aws-by-coding.git</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>あるいは， <a href="https://github.com/tomomano/learn-aws-by-coding" target="_blank" rel="noreferrer">https://github.com/tomomano/learn-aws-by-coding</a> のページに行って，右上のダウンロードボタンからダウンロードすることもできる．</p>
<p><strong>Docker を使用する場合</strong></p>
<p>Python, Node.js, AWS CDK など，ハンズオンのプログラムを実行するために必要なプログラム/ライブラリがインストール済みの Docker image を用意した． また，ハンズオンのソースコードもパッケージ済みである． Docker の使い方を知っている読者は，これを使えば，諸々のインストールをする必要なく，すぐにハンズオンのプログラムを実行できる．</p>
<p>使用方法については (#sec_handson_docker) を参照のこと．</p>
<h2 id="ssh" tabindex="-1">SSH <a class="header-anchor" href="#ssh" aria-label="Permalink to &quot;SSH&quot;">&ZeroWidthSpace;</a></h2>
<p><strong>SSH (secure shell)</strong> は Unix 系のリモートサーバーに安全にアクセスするためのツールである． 本ハンズオンでは， SSH を使って仮想サーバーにアクセスする． SSH に慣れていない読者のため，簡単な説明をここで行おう．</p>
<p>SSH による通信はすべて暗号化されているので，機密情報をインターネットを介して安全に送受信することができる． 本ハンズオンで，リモートのサーバーにアクセスするための SSH クライアントがローカルマシンにインストールされている必要がある． SSH クライアントは Linux/Mac には標準搭載されている． Windows の場合は WSL をインストールすることで SSH クライアントを利用することを推奨する ( (#environments) を参照)．</p>
<p>SSH コマンドの基本的な使い方を次に示す． <code>&lt;host name&gt;</code> はアクセスする先のサーバーの IP アドレスや DNS によるホストネームが入る． <code>&lt;user name&gt;</code> は接続する先のユーザー名である．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ssh</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">&lt;</span><span style="color: #96D0FF">user</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">nam</span><span style="color: #ADBAC7">e</span><span style="color: #F47067">&gt;</span><span style="color: #96D0FF">@</span><span style="color: #F47067">&lt;</span><span style="color: #96D0FF">host</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">nam</span><span style="color: #ADBAC7">e</span><span style="color: #F47067">&gt;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">ssh</span><span style="color: #24292E"> </span><span style="color: #D73A49">&lt;</span><span style="color: #032F62">user</span><span style="color: #24292E"> </span><span style="color: #032F62">nam</span><span style="color: #24292E">e</span><span style="color: #D73A49">&gt;</span><span style="color: #032F62">@</span><span style="color: #D73A49">&lt;</span><span style="color: #032F62">host</span><span style="color: #24292E"> </span><span style="color: #032F62">nam</span><span style="color: #24292E">e</span><span style="color: #D73A49">&gt;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>SSH は平文のパスワードによる認証を行うこともできるが，より強固なセキュリティを施すため，<strong>公開鍵暗号方式(Public Key Cryptography)による認証</strong>を行うことが強く推奨されており， EC2 はこの方法でしかアクセスを許していない． 公開鍵暗号方式の仕組みについては各自勉強してほしい． 本ハンズオンにおいて大事なことは，<strong>EC2 インスタンスが公開鍵(Public key)を保持し，クライアントとなるコンピュータ(読者自身のコンピュータ)が秘密鍵(Private key)を保持する</strong>，という点である． EC2 のインスタンスには秘密鍵を持ったコンピュータのみがアクセスすることができる．逆に言うと，秘密鍵が漏洩すると第三者もサーバーにアクセスできることになるので，<strong>秘密鍵は絶対に漏洩することのないよう注意して管理する</strong>．</p>
<p>SSH コマンドでは，ログインのために使用する秘密鍵ファイルを <code>-i</code> もしくは <code>--identity_file</code> のオプションで指定することができる． たとえば，次のように使う．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ssh</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-i</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">Ec2SecretKey.pem</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">&lt;</span><span style="color: #96D0FF">user</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">nam</span><span style="color: #ADBAC7">e</span><span style="color: #F47067">&gt;</span><span style="color: #96D0FF">@</span><span style="color: #F47067">&lt;</span><span style="color: #96D0FF">host</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">nam</span><span style="color: #ADBAC7">e</span><span style="color: #F47067">&gt;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">ssh</span><span style="color: #24292E"> </span><span style="color: #005CC5">-i</span><span style="color: #24292E"> </span><span style="color: #032F62">Ec2SecretKey.pem</span><span style="color: #24292E"> </span><span style="color: #D73A49">&lt;</span><span style="color: #032F62">user</span><span style="color: #24292E"> </span><span style="color: #032F62">nam</span><span style="color: #24292E">e</span><span style="color: #D73A49">&gt;</span><span style="color: #032F62">@</span><span style="color: #D73A49">&lt;</span><span style="color: #032F62">host</span><span style="color: #24292E"> </span><span style="color: #032F62">nam</span><span style="color: #24292E">e</span><span style="color: #D73A49">&gt;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><h2 id="アプリケーションの説明" tabindex="-1">アプリケーションの説明 <a class="header-anchor" href="#アプリケーションの説明" aria-label="Permalink to &quot;アプリケーションの説明&quot;">&ZeroWidthSpace;</a></h2>
<p>このハンズオンで作成するアプリケーションの概要を <a href="#handson_01_architecture">figure_title</a> に示す．</p>
<p><img src="./assets/handson-01/app_architecture.png" alt="ハンズオン#1で作製するアプリケーションのアーキテクチャ"></p>
<p>このアプリケーションではまず，<strong>VPC (Virtual Private Cloud)</strong> を使ってプライベートな仮想ネットワーク環境を立ち上げている． その VPC の public subnet の内側に，<strong>EC2 (Elatic Compute Cloud)</strong> の仮想サーバーを配置する． さらに，セキュリティのため， <strong>Security Group</strong> による EC2 インスタンスへのアクセス制限を設定している． このようにして作成された仮想サーバーに，SSH を使ってアクセスし，簡単な計算を行う．</p>
<p><a href="#handson_01_architecture">figure_title</a> のようなアプリケーションを，CDK を使って構築する．</p>
<p>早速ではあるが，今回のハンズオンで使用するプログラムを見てみよう (<a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/ec2-get-started/app.py" target="_blank" rel="noreferrer">handson/ec2-get-started/app.py</a>)．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">class</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50">MyFirstEc2</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">core</span><span style="color: #ADBAC7">.</span><span style="color: #6CB6FF">Stack</span><span style="color: #ADBAC7">):</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">def</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">__init__</span><span style="color: #ADBAC7">(self, scope: core.App, name: </span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">, key_name: </span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">, </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">kwargs) -&gt; </span><span style="color: #6CB6FF">None</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #6CB6FF">super</span><span style="color: #ADBAC7">().</span><span style="color: #6CB6FF">__init__</span><span style="color: #ADBAC7">(scope, name, </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">kwargs)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        vpc </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ec2.Vpc(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;MyFirstEc2-Vpc&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">max_azs</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">cidr</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;10.10.0.0/23&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">subnet_configuration</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">[</span></span>
<span class="line"><span style="color: #ADBAC7">                ec2.SubnetConfiguration(</span></span>
<span class="line"><span style="color: #ADBAC7">                    </span><span style="color: #F69D50">name</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;public&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                    </span><span style="color: #F69D50">subnet_type</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.SubnetType.</span><span style="color: #6CB6FF">PUBLIC</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                )</span></span>
<span class="line"><span style="color: #ADBAC7">            ],</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">nat_gateways</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        sg </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ec2.SecurityGroup(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;MyFirstEc2Vpc-Sg&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">vpc</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">vpc,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">allow_all_outbound</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">True</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"><span style="color: #ADBAC7">        sg.add_ingress_rule(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">peer</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.Peer.any_ipv4(),</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">connection</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.Port.tcp(</span><span style="color: #6CB6FF">22</span><span style="color: #ADBAC7">),</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        host </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ec2.Instance(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;MyFirstEc2Instance&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">instance_type</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.InstanceType(</span><span style="color: #96D0FF">&quot;t2.micro&quot;</span><span style="color: #ADBAC7">),</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">machine_image</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.MachineImage.latest_amazon_linux(),</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">vpc</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">vpc,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">vpc_subnets</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.SubnetSelection(</span><span style="color: #F69D50">subnet_type</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.SubnetType.</span><span style="color: #6CB6FF">PUBLIC</span><span style="color: #ADBAC7">),</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">security_group</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">sg,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">key_name</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">key_name</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">class</span><span style="color: #24292E"> </span><span style="color: #6F42C1">MyFirstEc2</span><span style="color: #24292E">(</span><span style="color: #6F42C1">core</span><span style="color: #24292E">.</span><span style="color: #6F42C1">Stack</span><span style="color: #24292E">):</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">def</span><span style="color: #24292E"> </span><span style="color: #005CC5">__init__</span><span style="color: #24292E">(self, scope: core.App, name: </span><span style="color: #005CC5">str</span><span style="color: #24292E">, key_name: </span><span style="color: #005CC5">str</span><span style="color: #24292E">, </span><span style="color: #D73A49">**</span><span style="color: #24292E">kwargs) -&gt; </span><span style="color: #005CC5">None</span><span style="color: #24292E">:</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #005CC5">super</span><span style="color: #24292E">().</span><span style="color: #005CC5">__init__</span><span style="color: #24292E">(scope, name, </span><span style="color: #D73A49">**</span><span style="color: #24292E">kwargs)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        vpc </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ec2.Vpc(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;MyFirstEc2-Vpc&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">max_azs</span><span style="color: #D73A49">=</span><span style="color: #005CC5">1</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">cidr</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;10.10.0.0/23&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">subnet_configuration</span><span style="color: #D73A49">=</span><span style="color: #24292E">[</span></span>
<span class="line"><span style="color: #24292E">                ec2.SubnetConfiguration(</span></span>
<span class="line"><span style="color: #24292E">                    </span><span style="color: #E36209">name</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;public&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                    </span><span style="color: #E36209">subnet_type</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.SubnetType.</span><span style="color: #005CC5">PUBLIC</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                )</span></span>
<span class="line"><span style="color: #24292E">            ],</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">nat_gateways</span><span style="color: #D73A49">=</span><span style="color: #005CC5">0</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        sg </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ec2.SecurityGroup(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;MyFirstEc2Vpc-Sg&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">vpc</span><span style="color: #D73A49">=</span><span style="color: #24292E">vpc,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">allow_all_outbound</span><span style="color: #D73A49">=</span><span style="color: #005CC5">True</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"><span style="color: #24292E">        sg.add_ingress_rule(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">peer</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.Peer.any_ipv4(),</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">connection</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.Port.tcp(</span><span style="color: #005CC5">22</span><span style="color: #24292E">),</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        host </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ec2.Instance(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;MyFirstEc2Instance&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">instance_type</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.InstanceType(</span><span style="color: #032F62">&quot;t2.micro&quot;</span><span style="color: #24292E">),</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">machine_image</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.MachineImage.latest_amazon_linux(),</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">vpc</span><span style="color: #D73A49">=</span><span style="color: #24292E">vpc,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">vpc_subnets</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.SubnetSelection(</span><span style="color: #E36209">subnet_type</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.SubnetType.</span><span style="color: #005CC5">PUBLIC</span><span style="color: #24292E">),</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">security_group</span><span style="color: #D73A49">=</span><span style="color: #24292E">sg,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">key_name</span><span style="color: #D73A49">=</span><span style="color: #24292E">key_name</span></span>
<span class="line"><span style="color: #24292E">        )</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br><span class="line-number">36</span><br><span class="line-number">37</span><br><span class="line-number">38</span><br><span class="line-number">39</span><br><span class="line-number">40</span><br></div></div><ul>
<li>
<p>まず最初に，VPC を定義する．</p>
</li>
<li>
<p>次に， security group (SG) を定義している． ここでは，任意の IPv4 のアドレスからの，ポート 22 (SSH の接続に使用される)への接続を許可している． それ以外の接続は拒絶される．</p>
</li>
<li>
<p>最後に，上記で作った VPC と SG が付与された EC2 インスタンスを作成している． インスタンスタイプは <code>t2.micro</code> を選択し， <a href="https://aws.amazon.com/amazon-linux-ami/" target="_blank" rel="noreferrer">Amazon Linux</a> を OS として設定している．</p>
</li>
</ul>
<p>それぞれについて，もう少し詳しく説明しよう．</p>
<h3 id="vpc-virtual-private-cloud" tabindex="-1">VPC (Virtual Private Cloud) <a class="header-anchor" href="#vpc-virtual-private-cloud" aria-label="Permalink to &quot;VPC (Virtual Private Cloud)&quot;">&ZeroWidthSpace;</a></h3>
<p><strong>VPC のアイコン.</strong></p>
<p><img src="./assets/aws_logos/VPC.png" alt="VPC"></p>
<p>VPC は AWS 上にプライベートな仮想ネットワーク環境を構築するツールである．高度な計算システムを構築するには，複数のサーバーを連動させて計算を行う必要があるが，そのような場合に互いのアドレスなどを管理する必要があり，そういった目的で VPC は有用である．</p>
<p>本ハンズオンでは，サーバーは一つしか起動しないので，VPC の恩恵はよく分からないかもしれない．しかし，EC2 インスタンスは必ず VPC の中に配置されなければならない，という制約があるので，このハンズオンでもミニマルな VPC を構成している．</p>
<p>興味のある読者のために，VPC のコードについてもう少し詳しく説明しよう．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">vpc </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ec2.Vpc(</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;MyFirstEc2-Vpc&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">max_azs</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">cidr</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;10.10.0.0/23&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">subnet_configuration</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">[</span></span>
<span class="line"><span style="color: #ADBAC7">        ec2.SubnetConfiguration(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">name</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;public&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">subnet_type</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.SubnetType.</span><span style="color: #6CB6FF">PUBLIC</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"><span style="color: #ADBAC7">    ],</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">nat_gateways</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">vpc </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ec2.Vpc(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;MyFirstEc2-Vpc&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">max_azs</span><span style="color: #D73A49">=</span><span style="color: #005CC5">1</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">cidr</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;10.10.0.0/23&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">subnet_configuration</span><span style="color: #D73A49">=</span><span style="color: #24292E">[</span></span>
<span class="line"><span style="color: #24292E">        ec2.SubnetConfiguration(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">name</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;public&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">subnet_type</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.SubnetType.</span><span style="color: #005CC5">PUBLIC</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"><span style="color: #24292E">    ],</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">nat_gateways</span><span style="color: #D73A49">=</span><span style="color: #005CC5">0</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br></div></div><ul>
<li>
<p><code>max_azs=1</code> : このパラメータは，前章で説明した avaialibility zone (AZ) を設定している． このハンズオンでは，特にデータセンターの障害などを気にする必要はないので <code>1</code> にしている．</p>
</li>
<li>
<p><code>cidr=&quot;10.10.0.0/23&quot;</code> : このパラメータは，VPC 内の IPv4 のレンジを指定している． CIDR 記法については， <a href="https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing" target="_blank" rel="noreferrer">Wikipedia</a>などを参照． <code>10.10.0.0/23</code> は <code>10.10.0.0</code> から <code>10.10.1.255</code> までの 512 個の連続したアドレス範囲を指している． つまり，この VPC では最大で 512 個のユニークな IPv4 アドレスが使えることになる． 今回はサーバーは一つなので 512 個は明らかに多すぎるが，VPC はアドレスの数はどれだけ作成しても無料なので，多めに作成した．</p>
</li>
<li>
<p><code>subnet_configuration=...</code> : このパラメータは，VPC にどのようなサブネットを作るか，を決めている． サブネットの種類には <strong>private subnet</strong> と <strong>public subnet</strong> の二種類がある． private subnet は基本的にインターネットとは遮断されたサブネット環境である． インターネットと繋がっていないので，セキュリティは極めて高く， VPC 内のサーバーとのみ通信を行えばよい EC2 インスタンスはここに配置する． Public subnet とはインターネットに繋がったサブネットである． 本ハンズオンで作成するサーバーは，外から SSH でログインを行いたいので， Public subnet 内に配置する． より詳細な記述は <a href="https://docs.aws.amazon.com/vpc/latest/userguide/VPC_Subnets.html#vpc-subnet-basics" target="_blank" rel="noreferrer">公式ドキュメンテーション</a> を参照．</p>
</li>
<li>
<p><code>natgateways=0</code> : これは少し高度な内容なので省略する (興味のある読者は <a href="https://docs.aws.amazon.com/vpc/latest/userguide/vpc-nat-gateway.html" target="_blank" rel="noreferrer">公式ドキュメンテーション</a>を参照)． が，<strong>これを 0 にしておかないと，NAT Gateway の利用料金が発生してしまうので，注意！</strong></p>
</li>
</ul>
<h3 id="security-group" tabindex="-1">Security Group <a class="header-anchor" href="#security-group" aria-label="Permalink to &quot;Security Group&quot;">&ZeroWidthSpace;</a></h3>
<p>Security group (SG) は， EC2 インスタンスに付与することのできる仮想ファイアーウォールである． たとえば，特定の IP アドレスから来た接続を許可・拒絶したり　(インバウンド・トラフィックの制限) ，逆に特定の IP アドレスへのアクセスを禁止したり (アウトバウンド・トラフィックの制限) することができる．</p>
<p>コードの該当部分を見てみよう．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">sg </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ec2.SecurityGroup(</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;MyFirstEc2Vpc-Sg&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">vpc</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">vpc,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">allow_all_outbound</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">True</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">sg.add_ingress_rule(</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">peer</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.Peer.any_ipv4(),</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">connection</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.Port.tcp(</span><span style="color: #6CB6FF">22</span><span style="color: #ADBAC7">),</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">sg </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ec2.SecurityGroup(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;MyFirstEc2Vpc-Sg&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">vpc</span><span style="color: #D73A49">=</span><span style="color: #24292E">vpc,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">allow_all_outbound</span><span style="color: #D73A49">=</span><span style="color: #005CC5">True</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">sg.add_ingress_rule(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">peer</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.Peer.any_ipv4(),</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">connection</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.Port.tcp(</span><span style="color: #005CC5">22</span><span style="color: #24292E">),</span></span>
<span class="line"><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br></div></div><p>本ハンズオンでは， SSH による外部からの接続を許容するため， <code>sg.add_ingress_rule(peer=ec2.Peer.any_ipv4(), connection=ec2.Port.tcp(22))</code> により，すべての IPv4 アドレスからのポート 22 番へのアクセスを許容している． また， SSH で EC2 インスタンスにログインしたのち，インターネットからプログラムなどをダウンロードできるよう， <code>allow_all_outbound=True</code> のパラメータを設定している．</p>
<p>SSH はデフォルトでは 22 番ポートを使用するのが慣例である．</p>
<p>セキュリティ上の観点からは，SSH の接続は自宅や大学・職場など特定の地点からの接続のみを許す方が望ましい．</p>
<h3 id="ec2-elastic-compute-cloud" tabindex="-1">EC2 (Elastic Compute Cloud) <a class="header-anchor" href="#ec2-elastic-compute-cloud" aria-label="Permalink to &quot;EC2 (Elastic Compute Cloud)&quot;">&ZeroWidthSpace;</a></h3>
<p><strong>EC2 のアイコン.</strong></p>
<p><img src="./assets/aws_logos/EC2.png" alt="EC2"></p>
<p>EC2 は AWS 上に仮想サーバーを立ち上げるサービスである． 個々の起動状態にある仮想サーバーのことをインスタンス (instance) とよぶ (しかし，口語的なコミュニケーションにおいては，サーバーとインスタンスという言葉は相互互換的に用いられることが多い)．</p>
<p>EC2 では用途に応じて様々なインスタンスタイプが提供されている． <a href="#ec2_instance_types">table_title</a> に，代表的なインスタンスタイプの例を挙げる (執筆時点での情報)． EC2 のインスタンスタイプのすべてのリストは <a href="https://aws.amazon.com/ec2/instance-types/" target="_blank" rel="noreferrer">公式ドキュメンテーション &quot;Amazon EC2 Instance Types&quot;</a> で見ることができる．</p>
<h3 id="ec2-instance-types" tabindex="-1">EC2 instance types <a class="header-anchor" href="#ec2-instance-types" aria-label="Permalink to &quot;EC2 instance types&quot;">&ZeroWidthSpace;</a></h3>
<table>
<thead>
<tr>
<th>Instance</th>
<th>vCPU</th>
<th>Memory (GiB)</th>
<th>Network bandwidth (Gbps)</th>
<th>Price per hour ($)</th>
</tr>
</thead>
<tbody>
<tr>
<td>t2.micro</td>
<td>1</td>
<td>1</td>
<td>-</td>
<td>0.0116</td>
</tr>
<tr>
<td>t2.small</td>
<td>1</td>
<td>2</td>
<td>-</td>
<td>0.023</td>
</tr>
<tr>
<td>t2.medium</td>
<td>2</td>
<td>4</td>
<td>-</td>
<td>0.0464</td>
</tr>
<tr>
<td>c5.24xlarge</td>
<td>96</td>
<td>192</td>
<td>25</td>
<td>4.08</td>
</tr>
<tr>
<td>c5n.18xlarge</td>
<td>72</td>
<td>192</td>
<td>100</td>
<td>3.888</td>
</tr>
<tr>
<td>x1e.16xlarge</td>
<td>64</td>
<td>1952</td>
<td>10</td>
<td>13.344</td>
</tr>
</tbody>
</table>
<p><a href="#ec2_instance_types">table_title</a> からわかるように， CPU は 1 コアから 96 コアまで，メモリーは 1GB から 2TB 以上まで，ネットワーク帯域は最大で 100Gbps まで，幅広く選択することができる． また，時間あたりの料金は，CPU・メモリーの占有数にほぼ比例する形で増加する． EC2 はサーバーの起動時間を秒単位で記録しており，<strong>利用料金は使用時間に比例する形で決定される</strong>． 例えば， <code>t2.medium</code> のインスタンスを 10 時間起動した場合，0.0464 * 10 = 0.464 ドルの料金が発生する．</p>
<p>AWS には <a href="https://aws.amazon.com/free/?all-free-tier.sort-by=item.additionalFields.SortRank&amp;all-free-tier.sort-order=asc" target="_blank" rel="noreferrer">無料利用枠</a> というものがあり， <code>t2.micro</code> であれば月に 750 時間までは無料で利用することができる．</p>
<p><a href="#ec2_instance_types">table_title</a> の価格は <code>us-east-1</code> のものである． リージョンによって多少価格設定が異なる．</p>
<p>上記で t2.micro の $0.0116 / hour という金額は， On-demand インスタンスというタイプを選択した場合の価格である． EC2 ではほかに， <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-spot-instances.html" target="_blank" rel="noreferrer">Spot instance</a> とよばれるインスタンスも存在しする． Spot instance は，AWS のデータセンターの負荷が増えた場合，ユーザーのプログラムが実行中であっても AWS の判断により強制シャットダウンされる，という不便さを抱えているのだが，その分大幅に安い料金設定になっている． AWS で一時的に生じた余剰な空き CPU をユーザーに割安で貸し出す，という発想である． 科学計算やウェブサーバーなどの用途でコストを削減する目的で， Spot Instance を活用する事例も多数報告されている．</p>
<p>EC2 インスタンスを定義しているコードの該当部分を見てみよう．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">host </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ec2.Instance(</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;MyFirstEc2Instance&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">instance_type</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.InstanceType(</span><span style="color: #96D0FF">&quot;t2.micro&quot;</span><span style="color: #ADBAC7">),</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">machine_image</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.MachineImage.latest_amazon_linux(),</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">vpc</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">vpc,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">vpc_subnets</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.SubnetSelection(</span><span style="color: #F69D50">subnet_type</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.SubnetType.</span><span style="color: #6CB6FF">PUBLIC</span><span style="color: #ADBAC7">),</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">security_group</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">sg,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">key_name</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">key_name</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">host </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ec2.Instance(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;MyFirstEc2Instance&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">instance_type</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.InstanceType(</span><span style="color: #032F62">&quot;t2.micro&quot;</span><span style="color: #24292E">),</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">machine_image</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.MachineImage.latest_amazon_linux(),</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">vpc</span><span style="color: #D73A49">=</span><span style="color: #24292E">vpc,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">vpc_subnets</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.SubnetSelection(</span><span style="color: #E36209">subnet_type</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.SubnetType.</span><span style="color: #005CC5">PUBLIC</span><span style="color: #24292E">),</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">security_group</span><span style="color: #D73A49">=</span><span style="color: #24292E">sg,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">key_name</span><span style="color: #D73A49">=</span><span style="color: #24292E">key_name</span></span>
<span class="line"><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br></div></div><p>ここでは， <code>t2.micro</code> というインスタンスタイプを選択している． さらに， <code>machine_image</code> として， <a href="https://aws.amazon.com/amazon-linux-ami/" target="_blank" rel="noreferrer">Amazon Linux</a> を選択している (Machine image は OS と似た概念である． Machine image については， (#sec_jupyter_and_deep_learning) でより詳しく触れる)． さらに，上で定義した VPC, SG をこのインスタンスに付与している．</p>
<p>以上が，今回使用するプログラムの簡単な解説であった． ミニマルな形のプログラムではあるが，仮想サーバーを作成するのに必要なステップがおわかりいただけただろうか？</p>
<h2 id="プログラムを実行する" tabindex="-1">プログラムを実行する <a class="header-anchor" href="#プログラムを実行する" aria-label="Permalink to &quot;プログラムを実行する&quot;">&ZeroWidthSpace;</a></h2>
<p>さて，ハンズオンのコードの理解ができたところで，プログラムを実際に実行してみよう．繰り返しになるが， <a href="#handson_01_prep">準備</a> での準備ができていることが前提である．</p>
<h3 id="python-の依存ライブラリのインストール" tabindex="-1">Python の依存ライブラリのインストール <a class="header-anchor" href="#python-の依存ライブラリのインストール" aria-label="Permalink to &quot;Python の依存ライブラリのインストール&quot;">&ZeroWidthSpace;</a></h3>
<p>まずは，Python の依存ライブラリをインストールする．以下では，Python のライブラリを管理するツールとして， <a href="https://docs.python.org/3/library/venv.html" target="_blank" rel="noreferrer">venv</a> を使用する．</p>
<p>まずは， <code>handson/ec2-get-started</code> のディレクトリに移動しよう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cd</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">handson/ec2-get-started</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cd</span><span style="color: #24292E"> </span><span style="color: #032F62">handson/ec2-get-started</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>ディレクトリを移動したら， <code>venv</code> で新しい仮想環境を作成し，インストールを実行する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python3</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-m</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">venv</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.env</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">source</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.env/bin/activate</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">pip</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">install</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-r</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">requirements.txt</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python3</span><span style="color: #24292E"> </span><span style="color: #005CC5">-m</span><span style="color: #24292E"> </span><span style="color: #032F62">venv</span><span style="color: #24292E"> </span><span style="color: #032F62">.env</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">source</span><span style="color: #24292E"> </span><span style="color: #032F62">.env/bin/activate</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">pip</span><span style="color: #24292E"> </span><span style="color: #032F62">install</span><span style="color: #24292E"> </span><span style="color: #005CC5">-r</span><span style="color: #24292E"> </span><span style="color: #032F62">requirements.txt</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><p>これで Python の環境構築は完了だ．</p>
<p><code>venv</code> の簡単な説明は (#venv_quick_guide) に記述してある．</p>
<p>環境によっては <code>pip</code> ではなく <code>pip3</code> あるいは <code>python3 -m pip</code> に置き換える必要がある．</p>
<h3 id="aws-のシークレットキーをセットする" tabindex="-1">AWS のシークレットキーをセットする <a class="header-anchor" href="#aws-のシークレットキーをセットする" aria-label="Permalink to &quot;AWS のシークレットキーをセットする&quot;">&ZeroWidthSpace;</a></h3>
<p>AWS CLI および AWS CDK を使うには， AWS のシークレットキーが設定されている必要がある． シークレットキーの発行については (#aws_secrets) を参照のこと． シークレットキーを発行したら， (#aws_cli_install) を参照し，コマンドラインの設定を行う．</p>
<p>手順をここに短く要約すると，一つ目の方法は <code>AWS_ACCESS_KEY_ID</code> などの環境変数を設定するやり方である． もう一つの方法は， <code>~/.aws/credentials</code> に認証情報を保存しておく方式である． シークレットキーの設定は AWS CLI/CDK を使用するうえで共通のステップになるので，しっかりと理解しておくように．</p>
<h3 id="ssh-鍵を生成" tabindex="-1">SSH 鍵を生成 <a class="header-anchor" href="#ssh-鍵を生成" aria-label="Permalink to &quot;SSH 鍵を生成&quot;">&ZeroWidthSpace;</a></h3>
<p>EC2 インスタンスには SSH を使ってログインする． EC2 インスタンスを作成するのに先行して，今回のハンズオンで専用に使う SSH の公開鍵・秘密鍵のペアを準備する必要がある．</p>
<p>次の AWS CLI コマンドにより， <code>HirakeGoma</code> という名前のついた鍵を生成する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">export</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">KEY_NAME=&quot;HirakeGoma&quot;</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ec2</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">create-key-pair</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--key-name</span><span style="color: #ADBAC7"> ${KEY_NAME} </span><span style="color: #6CB6FF">--query</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;KeyMaterial&#39;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--output</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">text</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">&gt;</span><span style="color: #ADBAC7"> ${KEY_NAME}</span><span style="color: #96D0FF">.pem</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">export</span><span style="color: #24292E"> </span><span style="color: #032F62">KEY_NAME=&quot;HirakeGoma&quot;</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">aws</span><span style="color: #24292E"> </span><span style="color: #032F62">ec2</span><span style="color: #24292E"> </span><span style="color: #032F62">create-key-pair</span><span style="color: #24292E"> </span><span style="color: #005CC5">--key-name</span><span style="color: #24292E"> ${KEY_NAME} </span><span style="color: #005CC5">--query</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;KeyMaterial&#39;</span><span style="color: #24292E"> </span><span style="color: #005CC5">--output</span><span style="color: #24292E"> </span><span style="color: #032F62">text</span><span style="color: #24292E"> </span><span style="color: #D73A49">&gt;</span><span style="color: #24292E"> ${KEY_NAME}</span><span style="color: #032F62">.pem</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>このコマンドを実行すると，現在のディレクトリに <code>HirakeGoma.pem</code> というファイルが作成される．これが，サーバーにアクセスするための秘密鍵である． SSH でこの鍵を使うため， <code>~/.ssh/</code> のディレクトリに鍵を移動する． さらに，秘密鍵が書き換えられたり第三者に閲覧されないよう，ファイルのアクセス権限を <code>400</code> に設定する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">mv</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">HirakeGoma.pem</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">~/.ssh/</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">chmod</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">400</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">~/.ssh/HirakeGoma.pem</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">mv</span><span style="color: #24292E"> </span><span style="color: #032F62">HirakeGoma.pem</span><span style="color: #24292E"> </span><span style="color: #032F62">~/.ssh/</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">chmod</span><span style="color: #24292E"> </span><span style="color: #005CC5">400</span><span style="color: #24292E"> </span><span style="color: #032F62">~/.ssh/HirakeGoma.pem</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><h3 id="デプロイを実行" tabindex="-1">デプロイを実行 <a class="header-anchor" href="#デプロイを実行" aria-label="Permalink to &quot;デプロイを実行&quot;">&ZeroWidthSpace;</a></h3>
<p>これまでのステップで， EC2 インスタンスをデプロイするための準備が整った！ 早速，次のコマンドによりアプリケーションを AWS にデプロイしよう． <code>-c key_name=&quot;HirakeGoma&quot;</code> というオプションで，先ほど生成した <code>HirakeGoma</code> という名前の鍵を使うよう指定している．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cdk</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">deploy</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-c</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">key_name=&quot;HirakeGoma&quot;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cdk</span><span style="color: #24292E"> </span><span style="color: #032F62">deploy</span><span style="color: #24292E"> </span><span style="color: #005CC5">-c</span><span style="color: #24292E"> </span><span style="color: #032F62">key_name=&quot;HirakeGoma&quot;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>このコマンドを実行すると， VPC， EC2 などが AWS 上に展開される． そして，コマンドの出力の最後に <a href="#handson_01_cdk_output">figure_title</a> のような出力が得られるはずである． <strong>出力の中で <code>InstancePublicIp</code> に続く数字が，起動したインスタンスのパブリック IP アドレスである．</strong> IP アドレスはデプロイごとにランダムなアドレスが割り当てられる．</p>
<p><img src="./assets/handson-01/cdk_output.png" alt="CDKデプロイ実行後の出力"></p>
<h3 id="ssh-でログイン" tabindex="-1">SSH でログイン <a class="header-anchor" href="#ssh-でログイン" aria-label="Permalink to &quot;SSH でログイン&quot;">&ZeroWidthSpace;</a></h3>
<p>早速，SSH 　で接続してみよう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ssh</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-i</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">~/.ssh/HirakeGoma.pem</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ec2-user@</span><span style="color: #F47067">&lt;</span><span style="color: #96D0FF">IP</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">addres</span><span style="color: #ADBAC7">s</span><span style="color: #F47067">&gt;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">ssh</span><span style="color: #24292E"> </span><span style="color: #005CC5">-i</span><span style="color: #24292E"> </span><span style="color: #032F62">~/.ssh/HirakeGoma.pem</span><span style="color: #24292E"> </span><span style="color: #032F62">ec2-user@</span><span style="color: #D73A49">&lt;</span><span style="color: #032F62">IP</span><span style="color: #24292E"> </span><span style="color: #032F62">addres</span><span style="color: #24292E">s</span><span style="color: #D73A49">&gt;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p><code>-i</code> オプションで，先ほど生成した秘密鍵を指定している． EC2 インスタンスにはデフォルトで <code>ec2-user</code> という名前のユーザーが作られているので，それを使用する． 最後に， <code>&lt;IP address&gt;</code> の部分は自身が作成した EC2 インスタンスの IP アドレスで置き換える (<code>12.345.678.9</code> など）．</p>
<p>ログインに成功すると， <a href="#fig_handson_01_ssh_login">figure_title</a> のような画面が表示される． リモートのサーバーにログインしているので，プロンプトが <code>[ec2-user@ip-10-10-1-217 ~]$</code> のようになっていることを確認しよう．</p>
<p><img src="./assets/handson-01/ssh_login.png" alt="SSH で EC2 インスタンスにログイン"></p>
<p><strong>おめでとう！これで，めでたく AWS 上に EC2 仮想サーバーを起動し，リモートからアクセスできるようになった！</strong></p>
<h3 id="起動した-ec2-インスタンスで遊んでみる" tabindex="-1">起動した EC2 インスタンスで遊んでみる <a class="header-anchor" href="#起動した-ec2-インスタンスで遊んでみる" aria-label="Permalink to &quot;起動した EC2 インスタンスで遊んでみる&quot;">&ZeroWidthSpace;</a></h3>
<p>せっかく新しいインスタンスを起動したので，少し遊んでみよう．</p>
<p>ログインした EC2 インスタンスで，次のコマンドを実行してみよう． CPU の情報を取得することができる．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cat</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">/proc/cpuinfo</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F69D50">processor</span><span style="color: #ADBAC7">       </span><span style="color: #96D0FF">:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0</span></span>
<span class="line"><span style="color: #F69D50">vendor_id</span><span style="color: #ADBAC7">       </span><span style="color: #96D0FF">:</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">GenuineIntel</span></span>
<span class="line"><span style="color: #F69D50">cpu</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">family</span><span style="color: #ADBAC7">      </span><span style="color: #96D0FF">:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">6</span></span>
<span class="line"><span style="color: #F69D50">model</span><span style="color: #ADBAC7">           </span><span style="color: #96D0FF">:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">63</span></span>
<span class="line"><span style="color: #F69D50">model</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">name</span><span style="color: #ADBAC7">      </span><span style="color: #96D0FF">:</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">Intel</span><span style="color: #ADBAC7">(</span><span style="color: #F69D50">R</span><span style="color: #ADBAC7">) </span><span style="color: #96D0FF">Xeon</span><span style="color: #ADBAC7">(</span><span style="color: #F69D50">R</span><span style="color: #ADBAC7">) </span><span style="color: #96D0FF">CPU</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">E5-2676</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">v3</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">@</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">2.40</span><span style="color: #96D0FF">GHz</span></span>
<span class="line"><span style="color: #F69D50">stepping</span><span style="color: #ADBAC7">        </span><span style="color: #96D0FF">:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">2</span></span>
<span class="line"><span style="color: #F69D50">microcode</span><span style="color: #ADBAC7">       </span><span style="color: #96D0FF">:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0x43</span></span>
<span class="line"><span style="color: #F69D50">cpu</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">MHz</span><span style="color: #ADBAC7">         </span><span style="color: #96D0FF">:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">2400.096</span></span>
<span class="line"><span style="color: #F69D50">cache</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">size</span><span style="color: #ADBAC7">      </span><span style="color: #96D0FF">:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">30720</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">KB</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cat</span><span style="color: #24292E"> </span><span style="color: #032F62">/proc/cpuinfo</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6F42C1">processor</span><span style="color: #24292E">       </span><span style="color: #032F62">:</span><span style="color: #24292E"> </span><span style="color: #005CC5">0</span></span>
<span class="line"><span style="color: #6F42C1">vendor_id</span><span style="color: #24292E">       </span><span style="color: #032F62">:</span><span style="color: #24292E"> </span><span style="color: #032F62">GenuineIntel</span></span>
<span class="line"><span style="color: #6F42C1">cpu</span><span style="color: #24292E"> </span><span style="color: #032F62">family</span><span style="color: #24292E">      </span><span style="color: #032F62">:</span><span style="color: #24292E"> </span><span style="color: #005CC5">6</span></span>
<span class="line"><span style="color: #6F42C1">model</span><span style="color: #24292E">           </span><span style="color: #032F62">:</span><span style="color: #24292E"> </span><span style="color: #005CC5">63</span></span>
<span class="line"><span style="color: #6F42C1">model</span><span style="color: #24292E"> </span><span style="color: #032F62">name</span><span style="color: #24292E">      </span><span style="color: #032F62">:</span><span style="color: #24292E"> </span><span style="color: #032F62">Intel</span><span style="color: #24292E">(</span><span style="color: #6F42C1">R</span><span style="color: #24292E">) </span><span style="color: #032F62">Xeon</span><span style="color: #24292E">(</span><span style="color: #6F42C1">R</span><span style="color: #24292E">) </span><span style="color: #032F62">CPU</span><span style="color: #24292E"> </span><span style="color: #032F62">E5-2676</span><span style="color: #24292E"> </span><span style="color: #032F62">v3</span><span style="color: #24292E"> </span><span style="color: #032F62">@</span><span style="color: #24292E"> </span><span style="color: #005CC5">2.40</span><span style="color: #032F62">GHz</span></span>
<span class="line"><span style="color: #6F42C1">stepping</span><span style="color: #24292E">        </span><span style="color: #032F62">:</span><span style="color: #24292E"> </span><span style="color: #005CC5">2</span></span>
<span class="line"><span style="color: #6F42C1">microcode</span><span style="color: #24292E">       </span><span style="color: #032F62">:</span><span style="color: #24292E"> </span><span style="color: #005CC5">0x43</span></span>
<span class="line"><span style="color: #6F42C1">cpu</span><span style="color: #24292E"> </span><span style="color: #032F62">MHz</span><span style="color: #24292E">         </span><span style="color: #032F62">:</span><span style="color: #24292E"> </span><span style="color: #005CC5">2400.096</span></span>
<span class="line"><span style="color: #6F42C1">cache</span><span style="color: #24292E"> </span><span style="color: #032F62">size</span><span style="color: #24292E">      </span><span style="color: #032F62">:</span><span style="color: #24292E"> </span><span style="color: #005CC5">30720</span><span style="color: #24292E"> </span><span style="color: #032F62">KB</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br></div></div><p>次に，実行中のプロセスやメモリの消費を見てみよう．</p>
<div class="language-bash vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7">  </span><span style="color: #96D0FF">top</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-n</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">1</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F69D50">top</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">-</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">09</span><span style="color: #96D0FF">:29:19</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">up</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">43</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">min,</span><span style="color: #ADBAC7">  </span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">user,</span><span style="color: #ADBAC7">  </span><span style="color: #96D0FF">load</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">average:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0.00</span><span style="color: #96D0FF">,</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0.00</span><span style="color: #96D0FF">,</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0.00</span></span>
<span class="line"><span style="color: #F69D50">Tasks:</span><span style="color: #ADBAC7">  </span><span style="color: #6CB6FF">76</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">total,</span><span style="color: #ADBAC7">   </span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">running,</span><span style="color: #ADBAC7">  </span><span style="color: #6CB6FF">51</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">sleeping,</span><span style="color: #ADBAC7">   </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">stopped,</span><span style="color: #ADBAC7">   </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">zombie</span></span>
<span class="line"><span style="color: #F69D50">Cpu(s</span><span style="color: #ADBAC7">):  0.3%us,  0.3%sy,  0.1%ni, 98.9%id,  0.2%wa,  0.0%hi,  0.0%si,  0.2%st</span></span>
<span class="line"><span style="color: #F69D50">Mem:</span><span style="color: #ADBAC7">   </span><span style="color: #6CB6FF">1009140</span><span style="color: #96D0FF">k</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">total,</span><span style="color: #ADBAC7">   </span><span style="color: #6CB6FF">270760</span><span style="color: #96D0FF">k</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">used,</span><span style="color: #ADBAC7">   </span><span style="color: #6CB6FF">738380</span><span style="color: #96D0FF">k</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">free,</span><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">14340</span><span style="color: #96D0FF">k</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">buffers</span></span>
<span class="line"><span style="color: #F69D50">Swap:</span><span style="color: #ADBAC7">        </span><span style="color: #6CB6FF">0</span><span style="color: #96D0FF">k</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">total,</span><span style="color: #ADBAC7">        </span><span style="color: #6CB6FF">0</span><span style="color: #96D0FF">k</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">used,</span><span style="color: #ADBAC7">        </span><span style="color: #6CB6FF">0</span><span style="color: #96D0FF">k</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">free,</span><span style="color: #ADBAC7">   </span><span style="color: #6CB6FF">185856</span><span style="color: #96D0FF">k</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cached</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #F69D50">PID</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">USER</span><span style="color: #ADBAC7">      </span><span style="color: #96D0FF">PR</span><span style="color: #ADBAC7">  </span><span style="color: #96D0FF">NI</span><span style="color: #ADBAC7">  </span><span style="color: #96D0FF">VIRT</span><span style="color: #ADBAC7">  </span><span style="color: #96D0FF">RES</span><span style="color: #ADBAC7">  </span><span style="color: #96D0FF">SHR</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">S</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">%CPU</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">%MEM</span><span style="color: #ADBAC7">    </span><span style="color: #96D0FF">TIME+</span><span style="color: #ADBAC7">  </span><span style="color: #96D0FF">COMMAND</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">1</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">root</span><span style="color: #ADBAC7">      </span><span style="color: #6CB6FF">20</span><span style="color: #ADBAC7">   </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">19696</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">2596</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">2268</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">S</span><span style="color: #ADBAC7">  </span><span style="color: #6CB6FF">0.0</span><span style="color: #ADBAC7">  </span><span style="color: #6CB6FF">0.3</span><span style="color: #ADBAC7">   </span><span style="color: #6CB6FF">0</span><span style="color: #96D0FF">:01.21</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">init</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">2</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">root</span><span style="color: #ADBAC7">      </span><span style="color: #6CB6FF">20</span><span style="color: #ADBAC7">   </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">     </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">S</span><span style="color: #ADBAC7">  </span><span style="color: #6CB6FF">0.0</span><span style="color: #ADBAC7">  </span><span style="color: #6CB6FF">0.0</span><span style="color: #ADBAC7">   </span><span style="color: #6CB6FF">0</span><span style="color: #96D0FF">:00.00</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">kthreadd</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">3</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">root</span><span style="color: #ADBAC7">      </span><span style="color: #6CB6FF">20</span><span style="color: #ADBAC7">   </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">     </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">I</span><span style="color: #ADBAC7">  </span><span style="color: #6CB6FF">0.0</span><span style="color: #ADBAC7">  </span><span style="color: #6CB6FF">0.0</span><span style="color: #ADBAC7">   </span><span style="color: #6CB6FF">0</span><span style="color: #96D0FF">:00.00</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">kworker/0:0</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E">  </span><span style="color: #032F62">top</span><span style="color: #24292E"> </span><span style="color: #005CC5">-n</span><span style="color: #24292E"> </span><span style="color: #005CC5">1</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6F42C1">top</span><span style="color: #24292E"> </span><span style="color: #032F62">-</span><span style="color: #24292E"> </span><span style="color: #005CC5">09</span><span style="color: #032F62">:29:19</span><span style="color: #24292E"> </span><span style="color: #032F62">up</span><span style="color: #24292E"> </span><span style="color: #005CC5">43</span><span style="color: #24292E"> </span><span style="color: #032F62">min,</span><span style="color: #24292E">  </span><span style="color: #005CC5">1</span><span style="color: #24292E"> </span><span style="color: #032F62">user,</span><span style="color: #24292E">  </span><span style="color: #032F62">load</span><span style="color: #24292E"> </span><span style="color: #032F62">average:</span><span style="color: #24292E"> </span><span style="color: #005CC5">0.00</span><span style="color: #032F62">,</span><span style="color: #24292E"> </span><span style="color: #005CC5">0.00</span><span style="color: #032F62">,</span><span style="color: #24292E"> </span><span style="color: #005CC5">0.00</span></span>
<span class="line"><span style="color: #6F42C1">Tasks:</span><span style="color: #24292E">  </span><span style="color: #005CC5">76</span><span style="color: #24292E"> </span><span style="color: #032F62">total,</span><span style="color: #24292E">   </span><span style="color: #005CC5">1</span><span style="color: #24292E"> </span><span style="color: #032F62">running,</span><span style="color: #24292E">  </span><span style="color: #005CC5">51</span><span style="color: #24292E"> </span><span style="color: #032F62">sleeping,</span><span style="color: #24292E">   </span><span style="color: #005CC5">0</span><span style="color: #24292E"> </span><span style="color: #032F62">stopped,</span><span style="color: #24292E">   </span><span style="color: #005CC5">0</span><span style="color: #24292E"> </span><span style="color: #032F62">zombie</span></span>
<span class="line"><span style="color: #6F42C1">Cpu(s</span><span style="color: #24292E">):  0.3%us,  0.3%sy,  0.1%ni, 98.9%id,  0.2%wa,  0.0%hi,  0.0%si,  0.2%st</span></span>
<span class="line"><span style="color: #6F42C1">Mem:</span><span style="color: #24292E">   </span><span style="color: #005CC5">1009140</span><span style="color: #032F62">k</span><span style="color: #24292E"> </span><span style="color: #032F62">total,</span><span style="color: #24292E">   </span><span style="color: #005CC5">270760</span><span style="color: #032F62">k</span><span style="color: #24292E"> </span><span style="color: #032F62">used,</span><span style="color: #24292E">   </span><span style="color: #005CC5">738380</span><span style="color: #032F62">k</span><span style="color: #24292E"> </span><span style="color: #032F62">free,</span><span style="color: #24292E">    </span><span style="color: #005CC5">14340</span><span style="color: #032F62">k</span><span style="color: #24292E"> </span><span style="color: #032F62">buffers</span></span>
<span class="line"><span style="color: #6F42C1">Swap:</span><span style="color: #24292E">        </span><span style="color: #005CC5">0</span><span style="color: #032F62">k</span><span style="color: #24292E"> </span><span style="color: #032F62">total,</span><span style="color: #24292E">        </span><span style="color: #005CC5">0</span><span style="color: #032F62">k</span><span style="color: #24292E"> </span><span style="color: #032F62">used,</span><span style="color: #24292E">        </span><span style="color: #005CC5">0</span><span style="color: #032F62">k</span><span style="color: #24292E"> </span><span style="color: #032F62">free,</span><span style="color: #24292E">   </span><span style="color: #005CC5">185856</span><span style="color: #032F62">k</span><span style="color: #24292E"> </span><span style="color: #032F62">cached</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">  </span><span style="color: #6F42C1">PID</span><span style="color: #24292E"> </span><span style="color: #032F62">USER</span><span style="color: #24292E">      </span><span style="color: #032F62">PR</span><span style="color: #24292E">  </span><span style="color: #032F62">NI</span><span style="color: #24292E">  </span><span style="color: #032F62">VIRT</span><span style="color: #24292E">  </span><span style="color: #032F62">RES</span><span style="color: #24292E">  </span><span style="color: #032F62">SHR</span><span style="color: #24292E"> </span><span style="color: #032F62">S</span><span style="color: #24292E"> </span><span style="color: #032F62">%CPU</span><span style="color: #24292E"> </span><span style="color: #032F62">%MEM</span><span style="color: #24292E">    </span><span style="color: #032F62">TIME+</span><span style="color: #24292E">  </span><span style="color: #032F62">COMMAND</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #6F42C1">1</span><span style="color: #24292E"> </span><span style="color: #032F62">root</span><span style="color: #24292E">      </span><span style="color: #005CC5">20</span><span style="color: #24292E">   </span><span style="color: #005CC5">0</span><span style="color: #24292E"> </span><span style="color: #005CC5">19696</span><span style="color: #24292E"> </span><span style="color: #005CC5">2596</span><span style="color: #24292E"> </span><span style="color: #005CC5">2268</span><span style="color: #24292E"> </span><span style="color: #032F62">S</span><span style="color: #24292E">  </span><span style="color: #005CC5">0.0</span><span style="color: #24292E">  </span><span style="color: #005CC5">0.3</span><span style="color: #24292E">   </span><span style="color: #005CC5">0</span><span style="color: #032F62">:01.21</span><span style="color: #24292E"> </span><span style="color: #032F62">init</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #6F42C1">2</span><span style="color: #24292E"> </span><span style="color: #032F62">root</span><span style="color: #24292E">      </span><span style="color: #005CC5">20</span><span style="color: #24292E">   </span><span style="color: #005CC5">0</span><span style="color: #24292E">     </span><span style="color: #005CC5">0</span><span style="color: #24292E">    </span><span style="color: #005CC5">0</span><span style="color: #24292E">    </span><span style="color: #005CC5">0</span><span style="color: #24292E"> </span><span style="color: #032F62">S</span><span style="color: #24292E">  </span><span style="color: #005CC5">0.0</span><span style="color: #24292E">  </span><span style="color: #005CC5">0.0</span><span style="color: #24292E">   </span><span style="color: #005CC5">0</span><span style="color: #032F62">:00.00</span><span style="color: #24292E"> </span><span style="color: #032F62">kthreadd</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #6F42C1">3</span><span style="color: #24292E"> </span><span style="color: #032F62">root</span><span style="color: #24292E">      </span><span style="color: #005CC5">20</span><span style="color: #24292E">   </span><span style="color: #005CC5">0</span><span style="color: #24292E">     </span><span style="color: #005CC5">0</span><span style="color: #24292E">    </span><span style="color: #005CC5">0</span><span style="color: #24292E">    </span><span style="color: #005CC5">0</span><span style="color: #24292E"> </span><span style="color: #032F62">I</span><span style="color: #24292E">  </span><span style="color: #005CC5">0.0</span><span style="color: #24292E">  </span><span style="color: #005CC5">0.0</span><span style="color: #24292E">   </span><span style="color: #005CC5">0</span><span style="color: #032F62">:00.00</span><span style="color: #24292E"> </span><span style="color: #032F62">kworker/0:0</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br></div></div><p><code>t2.micro</code> インスタンスなので， 1009140k = 1GB のメモリーがあることがわかる．</p>
<p>今回起動したインスタンスには Python 2 はインストール済みだが， Python 3 は入っていない． Python 3.6 のインストールを行ってみよう． インストールは簡単である．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">sudo</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">yum</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">update</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-y</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">sudo</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">yum</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">install</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-y</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python36</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">sudo</span><span style="color: #24292E"> </span><span style="color: #032F62">yum</span><span style="color: #24292E"> </span><span style="color: #032F62">update</span><span style="color: #24292E"> </span><span style="color: #005CC5">-y</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">sudo</span><span style="color: #24292E"> </span><span style="color: #032F62">yum</span><span style="color: #24292E"> </span><span style="color: #032F62">install</span><span style="color: #24292E"> </span><span style="color: #005CC5">-y</span><span style="color: #24292E"> </span><span style="color: #032F62">python36</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>インストールした Python を起動してみよう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python3</span></span>
<span class="line"><span style="color: #F69D50">Python</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">3.6</span><span style="color: #96D0FF">.10</span><span style="color: #ADBAC7"> (default, </span><span style="color: #96D0FF">Feb</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">10</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">2020</span><span style="color: #96D0FF">,</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">19</span><span style="color: #96D0FF">:55:14</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">[GCC </span><span style="color: #6CB6FF">4.8</span><span style="color: #ADBAC7">.5 </span><span style="color: #6CB6FF">20150623</span><span style="color: #ADBAC7"> (Red Hat </span><span style="color: #6CB6FF">4.8</span><span style="color: #ADBAC7">.5-28)] on linux</span></span>
<span class="line"><span style="color: #F69D50">Type</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;help&quot;,</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;copyright&quot;,</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;credits&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">or</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;license&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">for</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">more</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">information.</span></span>
<span class="line"><span style="color: #ADBAC7">&gt;&gt;&gt;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python3</span></span>
<span class="line"><span style="color: #6F42C1">Python</span><span style="color: #24292E"> </span><span style="color: #005CC5">3.6</span><span style="color: #032F62">.10</span><span style="color: #24292E"> (default, </span><span style="color: #032F62">Feb</span><span style="color: #24292E"> </span><span style="color: #005CC5">10</span><span style="color: #24292E"> </span><span style="color: #005CC5">2020</span><span style="color: #032F62">,</span><span style="color: #24292E"> </span><span style="color: #005CC5">19</span><span style="color: #032F62">:55:14</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">[GCC </span><span style="color: #005CC5">4.8</span><span style="color: #24292E">.5 </span><span style="color: #005CC5">20150623</span><span style="color: #24292E"> (Red Hat </span><span style="color: #005CC5">4.8</span><span style="color: #24292E">.5-28)] on linux</span></span>
<span class="line"><span style="color: #6F42C1">Type</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;help&quot;,</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;copyright&quot;,</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;credits&quot;</span><span style="color: #24292E"> </span><span style="color: #032F62">or</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;license&quot;</span><span style="color: #24292E"> </span><span style="color: #032F62">for</span><span style="color: #24292E"> </span><span style="color: #032F62">more</span><span style="color: #24292E"> </span><span style="color: #032F62">information.</span></span>
<span class="line"><span style="color: #24292E">&gt;&gt;&gt;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br></div></div><p>Python のインタープリタが起動した！ <code>Ctrl + D</code> あるいは <code>exit()</code> と入力することで，インタープリタを閉じることができる．</p>
<p>さて，サーバーでのお遊びはこんなところにしておこう (興味があれば各自いろいろと試してみると良い) ． 次のコマンドでログアウトする．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">exit</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">exit</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><h3 id="aws-コンソールから確認" tabindex="-1">AWS コンソールから確認 <a class="header-anchor" href="#aws-コンソールから確認" aria-label="Permalink to &quot;AWS コンソールから確認&quot;">&ZeroWidthSpace;</a></h3>
<p>これまでは，すべてコマンドラインから EC2 に関連する操作を行ってきた． EC2 インスタンスの状態を確認したり，サーバーをシャットダウンするなどの操作は，AWS コンソールから実行することもできる． 軽くこれを紹介しよう．</p>
<p>まず，ウェブブラウザを開いて AWS コンソールにログインする． ログインしたら， <code>Services</code> から <code>EC2</code> を検索(選択)する． 次に，左のサイドバーの <code>Instances</code> とページをたどる. すると， <a href="#aws_ec2_console">figure_title</a> のような画面が得られるはずである． この画面で，自分のアカウントの管理下にあるインスタンスを確認できる． 同様に，VPC・SG についてもコンソールから確認できる．</p>
<p><img src="./assets/handson-01/ec2_console.png" alt="EC2 コンソール画面"></p>
<p><strong>コンソール右上で，正しいリージョン (今回の場合は ap-northeast-1, Tokyo) が選択されているか，注意する！</strong></p>
<p>前章で CloudFormation について触れたが，今回デプロイしたアプリケーションも，CloudFormation のスタックとして管理されている． <strong>スタック (stack)</strong> とは， AWS リソースの集合のことを指す． 今回の場合は， VPC/EC2/SG などがスタックの中に含まれている． コンソールで <code>CloudFormation</code> のページに行ってみよう (<a href="#aws_cloudformation_console">figure_title</a>)．</p>
<p><img src="./assets/handson-01/cloudformation_console.png" alt="CloudFormation コンソール画面"></p>
<p>&quot;MyFirstEc2&quot; という名前のスタックがあることが確認できる． クリックをして中身を見てみると，EC2, VPC などのリソースがこのスタックに紐付いていることがわかる．</p>
<h3 id="スタックを削除" tabindex="-1">スタックを削除 <a class="header-anchor" href="#スタックを削除" aria-label="Permalink to &quot;スタックを削除&quot;">&ZeroWidthSpace;</a></h3>
<p>これにて，第一回のハンズオンで説明すべき事柄はすべて完了した． 最後に，使わなくなったスタックを削除しよう． スタックの削除には，二つの方法がある．</p>
<p>一つ目の方法は，前節の Cloudformation のコンソール画面で， &quot;Delete&quot; ボタンを押すことである (<a href="#cloudformation_delete">figure_title</a>)． すると，スタックの状態が <code>&quot;DELETE_IN_PROGRESS&quot;</code> に変わり，削除が完了すると CloudFormation のスタックの一覧から消える．</p>
<p><img src="./assets/handson-01/cloudformation_delete.png" alt="CloudFormationコンソール画面から，スタックを削除"></p>
<p>二つ目の方法は，コマンドラインから行う方法である． 先ほど，デプロイを行ったコマンドラインに戻ろう． そうしたら，次のコマンドを実行する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cdk</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">destroy</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cdk</span><span style="color: #24292E"> </span><span style="color: #032F62">destroy</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>このコマンドを実行すると，スタックの削除が始まる． 削除した後は，VPC, EC2 など，すべて跡形もなく消え去っていることを自身で確かめよう． CloudFormation を用いることで関連するすべての AWS リソースを一度に管理・削除することができるので，大変便利である．</p>
<p><strong>スタックの削除は各自で必ず行うこと！</strong> 行わなかった場合， EC2 インスタンスの料金が発生し続けることになる！</p>
<p>また，本ハンズオンのために作成した SSH 鍵ペアも不要なので，削除しておく． まず， EC2 側に登録してある公開鍵を削除する． これも，コンソールおよびコマンドラインの二つの方法で実行できる．</p>
<p>コンソールから実行するには， <code>EC2</code> の画面に行き，左のサイドバーの <code>Key Pairs</code> を選択する． 鍵の一覧が表示されるので， <code>HirakeGoma</code> とある鍵にチェックを入れ，画面右上の <code>Actions</code> から， <code>Delete</code> を実行する (<a href="#delete_ec2_key_pair">figure_title</a>)．</p>
<p><img src="./assets/handson-01/ec2_keypair_console.png" alt="EC2でSSH鍵ペアを削除"></p>
<p>コマンドラインから実行するには，次のコマンドを使う．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ec2</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">delete-key-pair</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--key-name</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;HirakeGoma&quot;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">aws</span><span style="color: #24292E"> </span><span style="color: #032F62">ec2</span><span style="color: #24292E"> </span><span style="color: #032F62">delete-key-pair</span><span style="color: #24292E"> </span><span style="color: #005CC5">--key-name</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;HirakeGoma&quot;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>最後に，ローカルのコンピュータから鍵を削除する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">rm</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-f</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">~/.ssh/HirakeGoma.pem</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">rm</span><span style="color: #24292E"> </span><span style="color: #005CC5">-f</span><span style="color: #24292E"> </span><span style="color: #032F62">~/.ssh/HirakeGoma.pem</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>これで，クラウドの片付けもすべて終了だ．</p>
<p>なお，頻繁に EC2 インスタンスを起動したりする場合は，いちいち SSH 鍵を削除する必要はない．</p>
<h2 id="小括" tabindex="-1">小括 <a class="header-anchor" href="#小括" aria-label="Permalink to &quot;小括&quot;">&ZeroWidthSpace;</a></h2>
<p>ここまでが，本書の第一部の内容である． 盛りだくさんの内容であったが，ついてこれたであろうか？</p>
<p>(#chap_cloud_basics) では，クラウドの定義と用語の説明を行ったあと，なぜクラウドを使うのか，という点を議論した． 続いて (#sec_aws_general_introduction) では，クラウドを学ぶ具体的なプラットフォームとして AWS を取り上げ， AWS を使用するにあたり最低限必要な知識と用語の説明を行った． さらに， <a href="#sec_first_ec2">Hands-on #1: 初めての EC2 インスタンスを起動する</a> のハンズオンでは AWS CLI と AWS CDK を使って，自身のプライベートなサーバーを AWS 上に立ち上げる演習を行った．</p>
<p>これらを通じて，いかに簡単に (たった数行のコマンドで！) 仮想サーバーを立ち上げたり，削除したりすることができるか，体験できただろう． 筆者は， (#chap_cloud_basics) でクラウドの最も重要な側面はダイナミックに計算リソースを拡大・縮小できることである，と述べた． この言葉の意味が，ハンズオンを通じてより明らかになっただろうか？ ここで学んだ技術を少し応用するだけで，自分のウェブページをホストする仮想サーバーを作成したり，大量のコアを搭載した EC2 インスタンスを用意して科学計算を実行するなど，いろいろなアプリケーションが実現できる．</p>
<p>次章からは，今回学んだクラウドの技術を基に，より現実に即した問題を解くことを体験してもらう． お楽しみに！</p>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hands-on #2: AWS でディープラーニングを実践 ]]></title>
            <link>https://note.toshiki.devdevelopment/aws/handson-jupyter</link>
            <guid>https://note.toshiki.devdevelopment/aws/handson-jupyter</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="hands-on-2-aws-でディープラーニングを実践" tabindex="-1">Hands-on #2: AWS でディープラーニングを実践 <a class="header-anchor" href="#hands-on-2-aws-でディープラーニングを実践" aria-label="Permalink to &quot;Hands-on \#2: AWS でディープラーニングを実践&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="準備" tabindex="-1">準備 <a class="header-anchor" href="#準備" aria-label="Permalink to &quot;準備&quot;">&ZeroWidthSpace;</a></h2>
<p>ハンズオン第二回では， GPU を搭載した EC2 インスタンスを起動し，深層学習モデルの学習と推論を実行する演習を行う．</p>
<p>ハンズオンのソースコードは GitHub の <a href="https://github.com/andatoshiki/toshiki-notebooktree/main/handson/mnist" target="_blank" rel="noreferrer">handson/mnist</a> に置いてある．</p>
<p>本ハンズオンの実行には，第一回ハンズオンで説明した準備 ( (#handson_01_prep)) が整っていることを前提とする． それ以外に必要な準備はない．</p>
<p>初期状態の AWS アカウントでは， GPU 搭載の G タイプのインスタンスの起動上限が 0 になっていることがある． これを確認するには， AWS コンソールから EC2 の画面を開き，左のメニューから <code>Limits</code> を選択する． その中の <code>Running On-Demand All G instances</code> という数字が G インスタンスの起動上限を表している．</p>
<p>もし，これが 0 になっていた場合は， AWS の自動申請フォームから上限緩和のリクエストを送る必要がある． 詳しくは <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-resource-limits.html" target="_blank" rel="noreferrer">公式ドキュメンテーション &quot;Amazon EC2 service quotas&quot;</a> を参照のこと．</p>
<p>このハンズオンは， <code>g4dn.xlarge</code> タイプの EC2 インスタンスを使うので，東京 (<code>ap-northeast-1</code>) リージョンでは 0.71 $/hour のコストが発生する．</p>
<p>AWS Educate Starter Account を使用している読者へ: 執筆時点においては， Starter Account には GPU 搭載型インスタンスを起動できないという制限が設けられている． したがって， Starter Account のユーザーはこのハンズオンを実行することはできない． 興味のある読者は，制限のない一般アカウントを自分自身で取得する必要があることに注意．</p>
<h2 id="アプリケーションの説明" tabindex="-1">アプリケーションの説明 <a class="header-anchor" href="#アプリケーションの説明" aria-label="Permalink to &quot;アプリケーションの説明&quot;">&ZeroWidthSpace;</a></h2>
<p>このハンズオンで作成するアプリケーションの概要を <a href="#handson_02_architecture">figure_title</a> に示す．</p>
<p><img src="./assets/handson-jupyter/handson-02-architecture.png" alt="ハンズオン#2で作製するアプリケーションのアーキテクチャ"></p>
<p>図の多くの部分が，第一回ハンズオンで作成したアプリケーションと共通していることに気がつくだろう． 少しの変更で，簡単にディープラーニングを走らせる環境を構築することができるのである！主な変更点は次の３点である．</p>
<ul>
<li>
<p>GPU を搭載した <code>g4dn.xlarge</code> インスタンスタイプを使用</p>
</li>
<li>
<p>ディープラーニングに使うプログラムがあらかじめインストールされた DLAMI (後述) を使用</p>
</li>
<li>
<p>SSH にポートフォワーディングのオプションつけてサーバーに接続し，サーバーで起動している Jupyter Notebook (後述) を使ってプログラムを書いたり実行したりする</p>
</li>
</ul>
<p>ハンズオンで使用するプログラムのコードをみてみよう <a href="https://github.com/andatoshiki/toshiki-notebooktree/main/handson/mnist/app.py" target="_blank" rel="noreferrer">handson/mnist/app.py</a>)． コードは第一回目とほとんど共通である．変更点のみ解説を行う．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">class</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50">Ec2ForDl</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">core</span><span style="color: #ADBAC7">.</span><span style="color: #6CB6FF">Stack</span><span style="color: #ADBAC7">):</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">def</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">__init__</span><span style="color: #ADBAC7">(self, scope: core.App, name: </span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">, key_name: </span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">, </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">kwargs) -&gt; </span><span style="color: #6CB6FF">None</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #6CB6FF">super</span><span style="color: #ADBAC7">().</span><span style="color: #6CB6FF">__init__</span><span style="color: #ADBAC7">(scope, name, </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">kwargs)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        vpc </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ec2.Vpc(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;Ec2ForDl-Vpc&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">max_azs</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">cidr</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;10.10.0.0/23&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">subnet_configuration</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">[</span></span>
<span class="line"><span style="color: #ADBAC7">                ec2.SubnetConfiguration(</span></span>
<span class="line"><span style="color: #ADBAC7">                    </span><span style="color: #F69D50">name</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;public&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                    </span><span style="color: #F69D50">subnet_type</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.SubnetType.</span><span style="color: #6CB6FF">PUBLIC</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                )</span></span>
<span class="line"><span style="color: #ADBAC7">            ],</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">nat_gateways</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        sg </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ec2.SecurityGroup(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;Ec2ForDl-Sg&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">vpc</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">vpc,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">allow_all_outbound</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">True</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"><span style="color: #ADBAC7">        sg.add_ingress_rule(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">peer</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.Peer.any_ipv4(),</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">connection</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.Port.tcp(</span><span style="color: #6CB6FF">22</span><span style="color: #ADBAC7">),</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        host </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ec2.Instance(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;Ec2ForDl-Instance&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">instance_type</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.InstanceType(</span><span style="color: #96D0FF">&quot;g4dn.xlarge&quot;</span><span style="color: #ADBAC7">), </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">machine_image</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.MachineImage.generic_linux({</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #96D0FF">&quot;us-east-1&quot;</span><span style="color: #ADBAC7">: </span><span style="color: #96D0FF">&quot;ami-060f07284bb6f9faf&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #96D0FF">&quot;ap-northeast-1&quot;</span><span style="color: #ADBAC7">: </span><span style="color: #96D0FF">&quot;ami-09c0c16fc46a29ed9&quot;</span></span>
<span class="line"><span style="color: #ADBAC7">            }), </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">vpc</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">vpc,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">vpc_subnets</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.SubnetSelection(</span><span style="color: #F69D50">subnet_type</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.SubnetType.</span><span style="color: #6CB6FF">PUBLIC</span><span style="color: #ADBAC7">),</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">security_group</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">sg,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">key_name</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">key_name</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">class</span><span style="color: #24292E"> </span><span style="color: #6F42C1">Ec2ForDl</span><span style="color: #24292E">(</span><span style="color: #6F42C1">core</span><span style="color: #24292E">.</span><span style="color: #6F42C1">Stack</span><span style="color: #24292E">):</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">def</span><span style="color: #24292E"> </span><span style="color: #005CC5">__init__</span><span style="color: #24292E">(self, scope: core.App, name: </span><span style="color: #005CC5">str</span><span style="color: #24292E">, key_name: </span><span style="color: #005CC5">str</span><span style="color: #24292E">, </span><span style="color: #D73A49">**</span><span style="color: #24292E">kwargs) -&gt; </span><span style="color: #005CC5">None</span><span style="color: #24292E">:</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #005CC5">super</span><span style="color: #24292E">().</span><span style="color: #005CC5">__init__</span><span style="color: #24292E">(scope, name, </span><span style="color: #D73A49">**</span><span style="color: #24292E">kwargs)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        vpc </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ec2.Vpc(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;Ec2ForDl-Vpc&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">max_azs</span><span style="color: #D73A49">=</span><span style="color: #005CC5">1</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">cidr</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;10.10.0.0/23&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">subnet_configuration</span><span style="color: #D73A49">=</span><span style="color: #24292E">[</span></span>
<span class="line"><span style="color: #24292E">                ec2.SubnetConfiguration(</span></span>
<span class="line"><span style="color: #24292E">                    </span><span style="color: #E36209">name</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;public&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                    </span><span style="color: #E36209">subnet_type</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.SubnetType.</span><span style="color: #005CC5">PUBLIC</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                )</span></span>
<span class="line"><span style="color: #24292E">            ],</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">nat_gateways</span><span style="color: #D73A49">=</span><span style="color: #005CC5">0</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        sg </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ec2.SecurityGroup(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;Ec2ForDl-Sg&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">vpc</span><span style="color: #D73A49">=</span><span style="color: #24292E">vpc,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">allow_all_outbound</span><span style="color: #D73A49">=</span><span style="color: #005CC5">True</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"><span style="color: #24292E">        sg.add_ingress_rule(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">peer</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.Peer.any_ipv4(),</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">connection</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.Port.tcp(</span><span style="color: #005CC5">22</span><span style="color: #24292E">),</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        host </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ec2.Instance(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;Ec2ForDl-Instance&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">instance_type</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.InstanceType(</span><span style="color: #032F62">&quot;g4dn.xlarge&quot;</span><span style="color: #24292E">), </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">machine_image</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.MachineImage.generic_linux({</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #032F62">&quot;us-east-1&quot;</span><span style="color: #24292E">: </span><span style="color: #032F62">&quot;ami-060f07284bb6f9faf&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #032F62">&quot;ap-northeast-1&quot;</span><span style="color: #24292E">: </span><span style="color: #032F62">&quot;ami-09c0c16fc46a29ed9&quot;</span></span>
<span class="line"><span style="color: #24292E">            }), </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">vpc</span><span style="color: #D73A49">=</span><span style="color: #24292E">vpc,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">vpc_subnets</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.SubnetSelection(</span><span style="color: #E36209">subnet_type</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.SubnetType.</span><span style="color: #005CC5">PUBLIC</span><span style="color: #24292E">),</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">security_group</span><span style="color: #D73A49">=</span><span style="color: #24292E">sg,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">key_name</span><span style="color: #D73A49">=</span><span style="color: #24292E">key_name</span></span>
<span class="line"><span style="color: #24292E">        )</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br><span class="line-number">36</span><br><span class="line-number">37</span><br><span class="line-number">38</span><br><span class="line-number">39</span><br><span class="line-number">40</span><br></div></div><ul>
<li>
<p>ここで， <code>g4dn.xlarge</code> インスタンスタイプを選択している (第一回では， CPU のみの <code>t2.micro</code> だった)． <code>g4dn.xlarge</code> のインスタンスタイプは， (#sec_scientific_computing) ですでに触れた通り， <code>NVIDIA T4</code> と呼ばれる廉価版モデルの GPU を搭載したインスタンスである． CPU は 4 core, メインメモリーは 16GB が割り当てあられている．</p>
</li>
<li>
<p>ここでは，Deep Learning 用の諸々のソフトウェアがプリンストールされた AMI (<a href="https://docs.aws.amazon.com/dlami/latest/devguide/what-is-dlami.html" target="_blank" rel="noreferrer">Deep Learning Amazon Machine Image; DLAMI</a>) を選択している (第一回では，Amazon Linux という AMI を使用していた)． 使用する AMI の ID は リージョンごとに指定する必要があり，ここでは <code>us-east-1</code> と <code>ap-northeast-1</code> でそれぞれ定義している．</p>
</li>
</ul>
<p>DLAMI という新しい概念が出てきたので，説明しよう．</p>
<p>AMI が <code>us-east-1</code> と <code>ap-northeast-1</code> でしか定義されていないので，提供されているコードはこの二つのリージョンのみでデプロイ可能である． もしほかのリージョンを利用したい場合は， AMI の ID を自身で検索し，コードに書き込む必要がある．</p>
<h3 id="dlami-deep-learning-amazon-machine-image" tabindex="-1">DLAMI (Deep Learning Amazon Machine Image) <a class="header-anchor" href="#dlami-deep-learning-amazon-machine-image" aria-label="Permalink to &quot;DLAMI (Deep Learning Amazon Machine Image)&quot;">&ZeroWidthSpace;</a></h3>
<p><strong>AMI (Amazon Machine Image)</strong> とは，大まかには OS (Operating System) に相当する概念である． 当然のことながら， OS がなければコンピュータはなにもできないので，EC2 インスタンスを起動するときには必ずなにかの OS を&quot;インストール&quot;する必要がある． EC2 が起動したときにロードされる OS に相当するものが， AMI である． AMI には，たとえば <a href="https://ubuntu.com/" target="_blank" rel="noreferrer">Ubuntu</a> などの Linux 系 OS に加えて，Windows Server を選択することもできる． また， EC2 での使用に最適化された <a href="https://aws.amazon.com/amazon-linux-ami/" target="_blank" rel="noreferrer">Amazon Linux</a> という AMI も提供されている．</p>
<p>しかしながら， AMI を単なる OS と理解するのは過剰な単純化である． AMI には，ベースとなる (空っぽの) OS を選択することもできるが，それに加えて，各種のプログラムがインストール済みの AMI も定義することができる． 必要なプログラムがインストールされている AMI を見つけることができれば，自身でインストールを行ったり環境設定したりする手間が大幅に省ける． 具体例を挙げると，ハンズオン第一回では EC2 インスタンスに Python 3.6 をインストールする例を示したが，そのような操作をインスタンスが起動するたびに行うのは手間である！</p>
<p>AMI は， AWS 公式のものに加えて，サードパーティから提供されているものもある． また，自分自身の AMI を作って登録することも可能である (<a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/creating-an-ami-instance-store.html" target="_blank" rel="noreferrer">参考</a>)． AMI は EC2 のコンソールから検索することが可能である． あるいは，AWS CLI を使って，次のコマンドでリストを取得することができる (<a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/finding-an-ami.html" target="_blank" rel="noreferrer">参考</a>)．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ec2</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">describe-images</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--owners</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">amazon</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">aws</span><span style="color: #24292E"> </span><span style="color: #032F62">ec2</span><span style="color: #24292E"> </span><span style="color: #032F62">describe-images</span><span style="color: #24292E"> </span><span style="color: #005CC5">--owners</span><span style="color: #24292E"> </span><span style="color: #032F62">amazon</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>ディープラーニングで頻繁に使われるプログラムがあらかじめインストールしてある AMI が， <a href="https://docs.aws.amazon.com/dlami/latest/devguide/what-is-dlami.html" target="_blank" rel="noreferrer">DLAMI (Deep Learning AMI)</a> である． DLAMI には <code>TensorFlow</code>, <code>PyTorch</code> などの人気の高いディープラーニングのフレームワーク・ライブラリがすでにインストールされているため， EC2 インスタンスを起動してすぐさまディープラーニングの計算を実行できる．</p>
<p>本ハンズオンでは， Amazon Linux 2 をベースにした DLAMI を使用する (AMI ID = ami-09c0c16fc46a29ed9．この AMI は ap-northeast-1 でしか使用できない点に注意)． AWS CLI を使って，この AMI の詳細情報を取得してみよう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ec2</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">describe-images</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--owners</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">amazon</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--image-ids</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;ami-09c0c16fc46a29ed9&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--region</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ap-northeast-1</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">aws</span><span style="color: #24292E"> </span><span style="color: #032F62">ec2</span><span style="color: #24292E"> </span><span style="color: #032F62">describe-images</span><span style="color: #24292E"> </span><span style="color: #005CC5">--owners</span><span style="color: #24292E"> </span><span style="color: #032F62">amazon</span><span style="color: #24292E"> </span><span style="color: #005CC5">--image-ids</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;ami-09c0c16fc46a29ed9&quot;</span><span style="color: #24292E"> </span><span style="color: #005CC5">--region</span><span style="color: #24292E"> </span><span style="color: #032F62">ap-northeast-1</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p><img src="./assets/handson-jupyter/ami-info.png" alt="AMI ID = ami-09c0c16fc46a29ed9 の詳細情報"></p>
<p><a href="#handson_02_ami-info">figure_title</a> のような出力が得られるはずである．得られた出力から，この DLAMI には PyTorch のバージョン 1.4.0 と 1.5.0 がインストールされていることがわかる． この DLAMI を使って，早速ディープラーニングの計算を実行してみよう．</p>
<p>DLAMI には具体的には何がインストールされているのだろうか？ 興味のある読者のために，簡単な解説をしよう (参考: <a href="https://docs.aws.amazon.com/dlami/latest/devguide/what-is-dlami.html" target="_blank" rel="noreferrer">公式ドキュメンテーション &quot;What Is the AWS Deep Learning AMI?&quot;</a>)．</p>
<p>最も low-level なレイヤーとしては， GPU ドライバー がインストールされている． GPU ドライバーなしには OS は GPU とコマンドのやり取りをすることができない． 次のレイヤーが <a href="https://developer.nvidia.com/about-cuda" target="_blank" rel="noreferrer">CUDA</a> と <a href="https://developer.nvidia.com/cudnn" target="_blank" rel="noreferrer">cuDNN</a> である． CUDA は， NVIDIA 社が開発した， GPU 上で汎用コンピューティングを行うための言語であり， C++ 言語を拡張したシンタックスを備える． cuDNN は CUDA で書かれたディープラーニングのライブラリであり，n 次元の畳み込みなどの演算が実装されている． ここまでが， &quot;Base&quot; とよばれるタイプの DLAMI の中身である．</p>
<p>これに加えて， &quot;Conda&quot; とよばれるタイプには， &quot;Base&quot; のプログラム基盤の上に， <code>TensorFlow</code> や <code>PyTorch</code> などのライブラリがインストールされている． さらに， <a href="https://docs.conda.io/projects/conda/en/latest/index.html" target="_blank" rel="noreferrer">Anaconda</a> による仮想環境を使うことによって， <code>TensorFlow</code> の環境・ <code>PyTorch</code> の環境・ <code>MxNet</code> の環境など，フレームワークを簡単に切り替えることができる (これについては，後のハンズオンで触れる)． また， Jupyter Notebook もインストール済みである．</p>
<h2 id="スタックのデプロイ" tabindex="-1">スタックのデプロイ <a class="header-anchor" href="#スタックのデプロイ" aria-label="Permalink to &quot;スタックのデプロイ&quot;">&ZeroWidthSpace;</a></h2>
<p>スタックの中身が理解できたところで，早速スタックをデプロイしてみよう．</p>
<p>デプロイの手順は，ハンズオン 1 とほとんど共通である． ここでは，コマンドのみ列挙する (<code>#</code> で始まる行はコメントである)． それぞれのコマンドの意味を忘れてしまった場合は，ハンズオン 1 に戻って復習していただきたい． シークレットキーの設定も忘れずに ( (#aws_cli_install))．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390"># プロジェクトのディレクトリに移動</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cd</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">handson/mnist</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># venv を作成し，依存ライブラリのインストールを行う</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python3</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-m</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">venv</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.env</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">source</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.env/bin/activate</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">pip</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">install</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-r</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">requirements.txt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># SSH鍵を生成</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">export</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">KEY_NAME=&quot;HirakeGoma&quot;</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ec2</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">create-key-pair</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--key-name</span><span style="color: #ADBAC7"> ${KEY_NAME} </span><span style="color: #6CB6FF">--query</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;KeyMaterial&#39;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--output</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">text</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">&gt;</span><span style="color: #ADBAC7"> ${KEY_NAME}</span><span style="color: #96D0FF">.pem</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">mv</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">HirakeGoma.pem</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">~/.ssh/</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">chmod</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">400</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">~/.ssh/HirakeGoma.pem</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># デプロイを実行</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cdk</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">deploy</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-c</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">key_name=&quot;HirakeGoma&quot;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D"># プロジェクトのディレクトリに移動</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cd</span><span style="color: #24292E"> </span><span style="color: #032F62">handson/mnist</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># venv を作成し，依存ライブラリのインストールを行う</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python3</span><span style="color: #24292E"> </span><span style="color: #005CC5">-m</span><span style="color: #24292E"> </span><span style="color: #032F62">venv</span><span style="color: #24292E"> </span><span style="color: #032F62">.env</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">source</span><span style="color: #24292E"> </span><span style="color: #032F62">.env/bin/activate</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">pip</span><span style="color: #24292E"> </span><span style="color: #032F62">install</span><span style="color: #24292E"> </span><span style="color: #005CC5">-r</span><span style="color: #24292E"> </span><span style="color: #032F62">requirements.txt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># SSH鍵を生成</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">export</span><span style="color: #24292E"> </span><span style="color: #032F62">KEY_NAME=&quot;HirakeGoma&quot;</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">aws</span><span style="color: #24292E"> </span><span style="color: #032F62">ec2</span><span style="color: #24292E"> </span><span style="color: #032F62">create-key-pair</span><span style="color: #24292E"> </span><span style="color: #005CC5">--key-name</span><span style="color: #24292E"> ${KEY_NAME} </span><span style="color: #005CC5">--query</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;KeyMaterial&#39;</span><span style="color: #24292E"> </span><span style="color: #005CC5">--output</span><span style="color: #24292E"> </span><span style="color: #032F62">text</span><span style="color: #24292E"> </span><span style="color: #D73A49">&gt;</span><span style="color: #24292E"> ${KEY_NAME}</span><span style="color: #032F62">.pem</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">mv</span><span style="color: #24292E"> </span><span style="color: #032F62">HirakeGoma.pem</span><span style="color: #24292E"> </span><span style="color: #032F62">~/.ssh/</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">chmod</span><span style="color: #24292E"> </span><span style="color: #005CC5">400</span><span style="color: #24292E"> </span><span style="color: #032F62">~/.ssh/HirakeGoma.pem</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># デプロイを実行</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cdk</span><span style="color: #24292E"> </span><span style="color: #032F62">deploy</span><span style="color: #24292E"> </span><span style="color: #005CC5">-c</span><span style="color: #24292E"> </span><span style="color: #032F62">key_name=&quot;HirakeGoma&quot;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br></div></div><p>ハンズオン 1 で作成した SSH 鍵の削除を行わなかった場合は， SSH 鍵を改めて作成する必要はない． 逆に言うと，同じ名前の SSH がすでに存在する場合は，鍵生成のコマンドはエラーを出力する．</p>
<p>デプロイのコマンドが無事に実行されれば， <a href="#handson_02_cdk_output">figure_title</a> のような出力が得られるはずである．AWS により割り振られた IP アドレス (<code>InstancePublicIp</code> に続く文字列) をメモしておこう．</p>
<p><img src="./assets/handson-jupyter/cdk_output.png" alt="CDKデプロイ実行後の出力"></p>
<h2 id="ログイン" tabindex="-1">ログイン <a class="header-anchor" href="#ログイン" aria-label="Permalink to &quot;ログイン&quot;">&ZeroWidthSpace;</a></h2>
<p>早速，デプロイしたインスタンスに SSH でログインしてみよう． ここでは，この後で使う Jupyter Notebook に接続するため，<strong>ポートフォワーディング (port forwarding)</strong> のオプション (<code>-L</code>) をつけてログインする．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ssh</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-i</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">~/.ssh/HirakeGoma.pem</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-L</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">localhost:8931:localhost:8888</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ec2-user@</span><span style="color: #F47067">&lt;</span><span style="color: #96D0FF">IP</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">addres</span><span style="color: #ADBAC7">s</span><span style="color: #F47067">&gt;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">ssh</span><span style="color: #24292E"> </span><span style="color: #005CC5">-i</span><span style="color: #24292E"> </span><span style="color: #032F62">~/.ssh/HirakeGoma.pem</span><span style="color: #24292E"> </span><span style="color: #005CC5">-L</span><span style="color: #24292E"> </span><span style="color: #032F62">localhost:8931:localhost:8888</span><span style="color: #24292E"> </span><span style="color: #032F62">ec2-user@</span><span style="color: #D73A49">&lt;</span><span style="color: #032F62">IP</span><span style="color: #24292E"> </span><span style="color: #032F62">addres</span><span style="color: #24292E">s</span><span style="color: #D73A49">&gt;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>ポートフォワーディングとは，クライアントマシンの特定のアドレスへの接続を， SSH の暗号化された通信を介して，リモートマシンの特定のアドレスへ転送する，という意味である． このコマンドの <code>-L localhost:8931:localhost:8888</code> は，自分のローカルマシンの <code>localhost:8931</code> へのアクセスを，リモートサーバーの <code>localhost:8888</code> のアドレスに転送せよ，という意味である (<code>:</code> につづく数字は TCP/IP ポートの番号を意味している)． リモートサーバーのポート 8888 には，後述する Jupyter Notebook が起動している． したがって，ローカルマシンの <code>localhost:8931</code> にアクセスすることで，リモートサーバーの Jupyter Notebook にアクセスすることができるのである (<a href="#fig:ssh_port_forwarding">figure_title</a>)． このような SSH による接続方式を<strong>トンネル接続</strong>とよぶ．</p>
<p><img src="./assets/ssh_port_forwarding.png" alt="SSH のポートフォワーディングによる Jupyter Notebook へのアクセス"></p>
<p>ポートフォワーディングのオプションで，ポートの番号 (<code>:8931</code>, <code>:8888</code> など) には 1 から 65535 までの任意の整数を指定できる． しかし，たとえば ポート 22 (SSH) やポート 80 (HTTP) など，いくつかすでに使われているポート番号もあることに注意する． また， Jupyter Notebook はデフォルトではポート 8888 番を使用する． したがって，リモート側のポート番号は，8888 を使うのがよい．</p>
<p>SSH ログインコマンドの <code>&lt;IP address&gt;</code> 部分は自身のインスタンスの IP アドレスを代入することを忘れずに．</p>
<p><strong>本書の提供している Docker を使ってデプロイを実行した人へ</strong></p>
<p>SSH によるログインは， <strong>Docker の外</strong> (すなわちクライアントマシン本体) から行わなければならない． なぜなら，Jupyter を開くウェブブラウザは Docker の外にあるからである．</p>
<p>その際，秘密鍵を Docker の外にもってこなければならない． 手っ取り早い方法は， <code>cat ~/.ssh/HirakeGoma</code> と打って，出力結果をコピーしてホストマシンのファイルに書き込む方法である． あるいは <code>-v</code> オプションをつけて，ファイルシステムをマウントしてもよい (詳しくは <a href="https://docs.docker.com/storage/volumes/" target="_blank" rel="noreferrer">Docker 公式ドキュメンテーション &quot;Use volumes&quot;</a> を参照)．</p>
<p>SSH によるログインができたら，早速， GPU の状態を確認してみよう． 次のコマンドを実行する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">nvidia-smi</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">nvidia-smi</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p><a href="#handson_02_nvidia-smi">figure_title</a> のような出力が得られるはずである． 出力を見ると， Tesla T4 型の GPU が 1 台搭載されていることが確認できる． その他，GPU Driver や CUDA のバージョン， GPU の負荷・メモリー使用率などの情報を確認することができる．</p>
<p><img src="./assets/handson-jupyter/nvidia-smi.png" alt="nvidia-smi の出力"></p>
<h2 id="jupyter-notebook-の起動" tabindex="-1">Jupyter Notebook の起動 <a class="header-anchor" href="#jupyter-notebook-の起動" aria-label="Permalink to &quot;Jupyter Notebook の起動&quot;">&ZeroWidthSpace;</a></h2>
<p><a href="https://jupyter.org/" target="_blank" rel="noreferrer">Jupyter Notebook</a> とは，インタラクティブに Python のプログラムを書いたり実行したりするためのツールである． Jupyter は GUI としてウェブブラウザを介してアクセスする形式をとっており，まるでノートを書くように，プロットやテーブルのデータも美しく表示することができる (<a href="#handson_02_welcome_jupyter">figure_title</a>)． Python に慣れている読者は，きっと一度は使ったことがあるだろう．</p>
<p><img src="./assets/handson-jupyter/welcome_to_jupyter.png" alt="Jupyter Notebook の画面"></p>
<p>このハンズオンでは， Jupyter Notebook を使ってディープラーニングのプログラムをインタラクティブに実行していく． DLAMI には既に Jupyter がインストールされているので，特段の設定なしに使い始めることができる．</p>
<p>早速， Jupyter を起動しよう． SSH でログインした先の EC2 インスタンスで，次のコマンドを実行すればよい．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cd</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">~</span><span style="color: #ADBAC7"> </span><span style="color: #768390"># go to home directory</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">jupyter</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">notebook</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cd</span><span style="color: #24292E"> </span><span style="color: #032F62">~</span><span style="color: #24292E"> </span><span style="color: #6A737D"># go to home directory</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">jupyter</span><span style="color: #24292E"> </span><span style="color: #032F62">notebook</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>このコマンドを実行すると， <a href="#handson_02_jupyter_launch">figure_title</a> のような出力が確認できるだろう． この出力から，Jupyter のサーバーが EC2 インスタンスの <code>localhost:8888</code> というアドレスに起動していることがわかる． また， <code>localhost:8888</code> に続く <code>?token=XXXX</code> は，アクセスに使うための一時的なトークンである．</p>
<p><img src="./assets/handson-jupyter/jupyter_launch.png" alt="Jupyter Notebook サーバーを起動"></p>
<p>Jupyter Notebook を初回に起動するときは，起動に数分程度の時間がかかることがある． ほかの動作も起動直後は遅く，いくつかプログラムを走らせていくうちに俊敏に反応するようになってくる． これは， AWS の GPU 搭載型仮想マシンの運用方法に起因する現象だと考えられる．</p>
<p>先ほど，ポートフォワーディングのオプションをつけて SSH 接続をしているので， Jupyter の起動している <code>localhost:8888</code> には，ローカルマシンの <code>localhost:8931</code> からアクセスすることができる． したがって，ローカルマシンから Jupyter にアクセスするには，ウェブブラウザ (Chrome, FireFox など)から次のアドレスにアクセスすれば良い．</p>
<div class="language- vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #adbac7">http://localhost:8931/?token=XXXX&amp;lt;/programlisting&amp;gt;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292e">http://localhost:8931/?token=XXXX&amp;lt;/programlisting&amp;gt;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p><code>?token=XXXX</code> の部分は，上で Jupyter を起動したときに発行されたトークンの値に置き換える．</p>
<p>上のアドレスにアクセスすると， Jupyter のホーム画面が起動するはずである (<a href="#handson_02_jupyter_home">figure_title</a>)． これで， Jupyter の準備が整った！</p>
<p><img src="./assets/handson-jupyter/jupyter_home.png" alt="Jupyter ホーム画面"></p>
<p>Jupyter Notebook の使い方 (超簡易版)</p>
<ul>
<li>
<p><code>Shift</code> + <code>Enter</code>: セルを実行</p>
</li>
<li>
<p><code>Esc</code>: <strong>Command mode</strong> に遷移</p>
</li>
<li>
<p>メニューバーの &quot;+&quot; ボタン または Command mode で <code>A</code> ⇒ セルを追加</p>
</li>
<li>
<p>メニューバーの &quot;ハサミ&quot; ボタン または Command mode で <code>X</code> ⇒ セルを削除</p>
</li>
</ul>
<p>ショートカットの一覧などは <a href="https://towardsdatascience.com/jypyter-notebook-shortcuts-bf0101a98330" target="_blank" rel="noreferrer">Ventsislav Yordanov 氏によるブログ</a> が参考になる．</p>
<h2 id="pytorch-はじめの一歩" tabindex="-1">PyTorch はじめの一歩 <a class="header-anchor" href="#pytorch-はじめの一歩" aria-label="Permalink to &quot;PyTorch はじめの一歩&quot;">&ZeroWidthSpace;</a></h2>
<p><a href="https://pytorch.org/" target="_blank" rel="noreferrer">PyTorch</a> は Facebook AI Research LAB (FAIR) が中心となって開発を進めている，オープンソースのディープラーニングのライブラリである． PyTorch は 有名な例で言えば Tesla 社の自動運転プロジェクトなどで使用されており，執筆時点において最も人気の高いディープラーニングライブラリの一つである． 本ハンズオンでは， PyTorch を使ってディープラーニングの実践を行う．</p>
<p>PyTorch の歴史のお話</p>
<p>Facebook は PyTorch のほかに Caffe2 とよばれるディープラーニングのフレームワークを開発していた (初代 Caffe は UC Berkley の博士課程学生だった Yangqing Jia によって創られた)． Caffe2 は 2018 年に PyTorch プロジェクトに合併された．</p>
<p>また，2019 年 12 月，日本の Preferred Networks 社が開発していた <a href="https://chainer.org/" target="_blank" rel="noreferrer">Chainer</a> も開発を終了し，PyTorch の開発チームと協業していくことが発表された (詳しくは <a href="https://chainer.org/announcement/2019/12/05/released-v7-ja.html" target="_blank" rel="noreferrer">プレスリリース</a> を参照)． PyTorch には，開発統合前から Chainer からインスパイアされた API がいくつもあり， Chainer の DNA は今も PyTorch に引き継がれているのである…!</p>
<p>本格的なディープラーニングの計算に移る前に， PyTorch ライブラリを使って， GPU で計算を行うとはどういうものか，その入り口に触れてみよう．</p>
<p>まずは，新しいノートブックを作成する． Jupyter のホーム画面の右上の &quot;New&quot; を押し，&quot;conda_pytorch_p36&quot; という環境を選択したうえで，新規ノートブックを作成する (<a href="#handson_02_jupyeter_new">figure_title</a>)． &quot;conda_pytorch_p36&quot; の仮想環境には， PyTorch がインストール済みである．</p>
<p><img src="./assets/handson-jupyter/jupyter_new.png" alt="新規ノートブックの作成． &quot;conda_pytorch_p36&quot; の環境を選択する．"></p>
<p>ここでは，次のようなプログラムを書いて，実行していく． (<a href="#handson_02_jupyeter_pytorch">figure_title</a>)．</p>
<p><img src="./assets/handson-jupyter/jupyter_pytorch.png" alt="PyTorch始めの一歩"></p>
<p>まずは， PyTorch をインポートする．さらに， GPU が使える環境にあるか，確認する．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> torch</span></span>
<span class="line"><span style="color: #6CB6FF">print</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;Is CUDA ready?&quot;</span><span style="color: #ADBAC7">, torch.cuda.is_available())</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> torch</span></span>
<span class="line"><span style="color: #005CC5">print</span><span style="color: #24292E">(</span><span style="color: #032F62">&quot;Is CUDA ready?&quot;</span><span style="color: #24292E">, torch.cuda.is_available())</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>出力:</p>
<p>Is CUDA ready? True&lt;/programlisting&gt;</p>
<p>次に，3x3 のランダムな行列を <strong>CPU</strong> 上に作ってみよう．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">x </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> torch.rand(</span><span style="color: #6CB6FF">3</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">3</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #6CB6FF">print</span><span style="color: #ADBAC7">(x)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">x </span><span style="color: #D73A49">=</span><span style="color: #24292E"> torch.rand(</span><span style="color: #005CC5">3</span><span style="color: #24292E">,</span><span style="color: #005CC5">3</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #005CC5">print</span><span style="color: #24292E">(x)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>出力:</p>
<p>tensor([[0.6896, 0.2428, 0.3269], [0.0533, 0.3594, 0.9499], [0.9764, 0.5881, 0.0203]])&lt;/programlisting&gt;</p>
<p>次に，行列を <strong>GPU</strong> 上に作成する．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">y </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> torch.ones_like(x, </span><span style="color: #F69D50">device</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;cuda&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">x </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> x.to(</span><span style="color: #96D0FF">&quot;cuda&quot;</span><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">y </span><span style="color: #D73A49">=</span><span style="color: #24292E"> torch.ones_like(x, </span><span style="color: #E36209">device</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;cuda&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">x </span><span style="color: #D73A49">=</span><span style="color: #24292E"> x.to(</span><span style="color: #032F62">&quot;cuda&quot;</span><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>そして，行列 <code>x</code> と <code>y</code> の加算を，<strong>GPU 上で実行する</strong>．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">z </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> x </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> y</span></span>
<span class="line"><span style="color: #6CB6FF">print</span><span style="color: #ADBAC7">(z)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">z </span><span style="color: #D73A49">=</span><span style="color: #24292E"> x </span><span style="color: #D73A49">+</span><span style="color: #24292E"> y</span></span>
<span class="line"><span style="color: #005CC5">print</span><span style="color: #24292E">(z)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>出力:</p>
<p>tensor([[1.6896, 1.2428, 1.3269], [1.0533, 1.3594, 1.9499], [1.9764, 1.5881, 1.0203]], device='cuda:0')&lt;/programlisting&gt;</p>
<p>最後に， GPU 上にある行列を， CPU に戻す．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">z </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> z.to(</span><span style="color: #96D0FF">&quot;cpu&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #6CB6FF">print</span><span style="color: #ADBAC7">(z)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">z </span><span style="color: #D73A49">=</span><span style="color: #24292E"> z.to(</span><span style="color: #032F62">&quot;cpu&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #005CC5">print</span><span style="color: #24292E">(z)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>出力:</p>
<p>tensor([[1.6896, 1.2428, 1.3269], [1.0533, 1.3594, 1.9499], [1.9764, 1.5881, 1.0203]])&lt;/programlisting&gt;</p>
<p>以上の例は， GPU を使った計算の初歩の初歩であるが，雰囲気はつかめただろうか？ CPU と GPU で明示的にデータを交換するのが肝である． この例はたった 3x3 の行列の足し算なので， GPU を使う意味はまったくないが，これが数千，数万のサイズの行列になったとき， GPU は格段の威力を発揮する．</p>
<p>完成した Jupyter Notebook は <a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/mnist/pytorch/pytorch_get_started.ipynb" target="_blank" rel="noreferrer">/handson/mnist/pytorch/pytorch_get_started.ipynb</a> にある． Jupyter の画面右上の &quot;Upload&quot; からこのファイルをアップロードして，コードを走らせることが可能である．</p>
<p>しなしながら，勉強のときにはコードはすべて自分の手で打つことが，記憶に残りやすくより効果的である，というのが筆者の意見である．</p>
<p>実際にベンチマークを取ることで GPU と CPU の速度を比較をしてみよう． 実行時間を計測するツールとして， Jupyter の提供する <a href="https://ipython.readthedocs.io/en/stable/interactive/magics.html" target="_blank" rel="noreferrer">%time</a> マジックコマンドを利用する．</p>
<p>まずは CPU を使用して，10000x10000 の行列の行列積を計算した場合の速度を測ってみよう． 先ほどのノートブックの続きに，次のコードを実行する．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">s </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">10000</span></span>
<span class="line"><span style="color: #ADBAC7">device </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;cpu&quot;</span></span>
<span class="line"><span style="color: #ADBAC7">x </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> torch.rand(s, s, </span><span style="color: #F69D50">device</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">device, </span><span style="color: #F69D50">dtype</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">torch.float32)</span></span>
<span class="line"><span style="color: #ADBAC7">y </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> torch.rand(s, s, </span><span style="color: #F69D50">device</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">device, </span><span style="color: #F69D50">dtype</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">torch.float32)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F47067">%</span><span style="color: #ADBAC7">time z </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> torch.matmul(x,y)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">s </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #005CC5">10000</span></span>
<span class="line"><span style="color: #24292E">device </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;cpu&quot;</span></span>
<span class="line"><span style="color: #24292E">x </span><span style="color: #D73A49">=</span><span style="color: #24292E"> torch.rand(s, s, </span><span style="color: #E36209">device</span><span style="color: #D73A49">=</span><span style="color: #24292E">device, </span><span style="color: #E36209">dtype</span><span style="color: #D73A49">=</span><span style="color: #24292E">torch.float32)</span></span>
<span class="line"><span style="color: #24292E">y </span><span style="color: #D73A49">=</span><span style="color: #24292E"> torch.rand(s, s, </span><span style="color: #E36209">device</span><span style="color: #D73A49">=</span><span style="color: #24292E">device, </span><span style="color: #E36209">dtype</span><span style="color: #D73A49">=</span><span style="color: #24292E">torch.float32)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D73A49">%</span><span style="color: #24292E">time z </span><span style="color: #D73A49">=</span><span style="color: #24292E"> torch.matmul(x,y)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br></div></div><p>出力は以下のようなものが得られるだろう． これは，行列積の計算に実時間で 5.8 秒かかったことを意味する (実行のたびに計測される時間はばらつくことに留意)．</p>
<p>CPU times: user 11.5 s, sys: 140 ms, total: 11.6 s Wall time: 5.8 s&lt;/programlisting&gt;</p>
<p>次に， GPU を使用して，同じ演算を行った場合の速度を計測しよう．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">s </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">10000</span></span>
<span class="line"><span style="color: #ADBAC7">device </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;cuda&quot;</span></span>
<span class="line"><span style="color: #ADBAC7">x </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> torch.rand(s, s, </span><span style="color: #F69D50">device</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">device, </span><span style="color: #F69D50">dtype</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">torch.float32)</span></span>
<span class="line"><span style="color: #ADBAC7">y </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> torch.rand(s, s, </span><span style="color: #F69D50">device</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">device, </span><span style="color: #F69D50">dtype</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">torch.float32)</span></span>
<span class="line"><span style="color: #ADBAC7">torch.cuda.synchronize()</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F47067">%</span><span style="color: #ADBAC7">time z </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> torch.matmul(x,y); torch.cuda.synchronize()</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">s </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #005CC5">10000</span></span>
<span class="line"><span style="color: #24292E">device </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;cuda&quot;</span></span>
<span class="line"><span style="color: #24292E">x </span><span style="color: #D73A49">=</span><span style="color: #24292E"> torch.rand(s, s, </span><span style="color: #E36209">device</span><span style="color: #D73A49">=</span><span style="color: #24292E">device, </span><span style="color: #E36209">dtype</span><span style="color: #D73A49">=</span><span style="color: #24292E">torch.float32)</span></span>
<span class="line"><span style="color: #24292E">y </span><span style="color: #D73A49">=</span><span style="color: #24292E"> torch.rand(s, s, </span><span style="color: #E36209">device</span><span style="color: #D73A49">=</span><span style="color: #24292E">device, </span><span style="color: #E36209">dtype</span><span style="color: #D73A49">=</span><span style="color: #24292E">torch.float32)</span></span>
<span class="line"><span style="color: #24292E">torch.cuda.synchronize()</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D73A49">%</span><span style="color: #24292E">time z </span><span style="color: #D73A49">=</span><span style="color: #24292E"> torch.matmul(x,y); torch.cuda.synchronize()</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br></div></div><p>出力は以下のようなものになるだろう． GPU では 553 ミリ秒 で計算を終えることができた！</p>
<p>CPU times: user 334 ms, sys: 220 ms, total: 554 ms Wall time: 553 ms&lt;/programlisting&gt;</p>
<p>PyTorch において， GPU での演算は asynchronous (非同期) で実行される． その理由で，上のベンチマークコードでは， <code>torch.cuda.synchronize()</code> というステートメントを埋め込んである．</p>
<p>このベンチマークでは， <code>dtype=torch.float32</code> と指定することで，32bit の浮動小数点型を用いている． ディープラーニングの学習および推論の計算には，32bit 型，場合によっては 16bit 型が使われるのが一般的である． これの主な理由として，教師データやミニバッチに起因するノイズが，浮動小数点の精度よりも大きいことがあげられる． 32bit/16bit を採用することで，メモリー消費を抑えたり，計算速度の向上が達成できる．</p>
<p>上記のベンチマークから，GPU を用いることで，<strong>約 10 倍のスピードアップ</strong>を実現することができた． スピードアップの性能は，演算の種類や行列のサイズに依存する． 行列積は，そのなかでも最も速度向上が見込まれる演算の一つである．</p>
<h2 id="実践ディープラーニング-mnist-手書き数字認識タスク" tabindex="-1">実践ディープラーニング! MNIST 手書き数字認識タスク <a class="header-anchor" href="#実践ディープラーニング-mnist-手書き数字認識タスク" aria-label="Permalink to &quot;実践ディープラーニング! MNIST 手書き数字認識タスク&quot;">&ZeroWidthSpace;</a></h2>
<p>ここまで，AWS 上でディープラーニングの計算をするための概念や前提知識をながながと説明してきたが，ついにここからディープラーニングの計算を実際に走らせてみる．</p>
<p>ここでは，機械学習のタスクで最も初歩的かつ有名な <strong>MNIST データセットを使った数字認識</strong>を扱う (<a href="#handson_02_mnist_examples">figure_title</a>)． これは，0 から 9 までの手書きの数字の画像が与えられ，その数字が何の数字なのかを当てる，というシンプルなタスクである．</p>
<p><img src="./assets/handson-jupyter/mnist_examples.png" alt="MNIST 手書き数字データセット"></p>
<p>今回は， MNIST 文字認識タスクを，<strong>畳み込みニューラルネットワーク (Convolutional Neural Network; CNN)</strong> を使って解く． ソースコードは <a href="https://github.com/tomomano/learn-aws-by-coding-source-code/tree/main/handson/mnist/pytorch" target="_blank" rel="noreferrer">/handson/minist/pytorch/</a> にある <code>mnist.ipynb</code> と <code>simple_mnist.py</code> である． なお，このプログラムは， <a href="https://github.com/pytorch/examples/tree/master/mnist" target="_blank" rel="noreferrer">PyTorch の公式 Example Project 集</a> を参考に，多少の改変を行ったものである．</p>
<p>まずは，カスタムのクラスや関数が定義された <code>simple_mnist.py</code> をアップロードしよう (<a href="#handson_02_jupyter_upload">figure_title</a>)． 画面右上の &quot;Upload&quot; ボタンをクリックし，ファイルを選択することでアップロードができる． この Python プログラムの中に，CNN のモデルや，学習の各イテレーションにおけるパラメータの更新などが記述されている． 今回はこの中身を説明することはしないが，興味のある読者は自身でソースコードを読んでみるとよい．</p>
<p><img src="./assets/handson-jupyter/jupyter_upload.png" alt=" をアップロード"></p>
<p><code>simple_mnist.py</code> をアップロードできたら，次に新しい notebook を作成しよう． &quot;conda_pytorch_p36&quot; の環境を選択することを忘れずに．</p>
<p>新しいノートブックが起動したら，まずは必要なライブラリをインポートしよう．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> torch</span></span>
<span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> torch.optim </span><span style="color: #F47067">as</span><span style="color: #ADBAC7"> optim</span></span>
<span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> torchvision</span></span>
<span class="line"><span style="color: #F47067">from</span><span style="color: #ADBAC7"> torchvision </span><span style="color: #F47067">import</span><span style="color: #ADBAC7"> datasets, transforms</span></span>
<span class="line"><span style="color: #F47067">from</span><span style="color: #ADBAC7"> matplotlib </span><span style="color: #F47067">import</span><span style="color: #ADBAC7"> pyplot </span><span style="color: #F47067">as</span><span style="color: #ADBAC7"> plt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># custom functions and classes</span></span>
<span class="line"><span style="color: #F47067">from</span><span style="color: #ADBAC7"> simple_mnist </span><span style="color: #F47067">import</span><span style="color: #ADBAC7"> Model, train, evaluate</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> torch</span></span>
<span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> torch.optim </span><span style="color: #D73A49">as</span><span style="color: #24292E"> optim</span></span>
<span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> torchvision</span></span>
<span class="line"><span style="color: #D73A49">from</span><span style="color: #24292E"> torchvision </span><span style="color: #D73A49">import</span><span style="color: #24292E"> datasets, transforms</span></span>
<span class="line"><span style="color: #D73A49">from</span><span style="color: #24292E"> matplotlib </span><span style="color: #D73A49">import</span><span style="color: #24292E"> pyplot </span><span style="color: #D73A49">as</span><span style="color: #24292E"> plt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># custom functions and classes</span></span>
<span class="line"><span style="color: #D73A49">from</span><span style="color: #24292E"> simple_mnist </span><span style="color: #D73A49">import</span><span style="color: #24292E"> Model, train, evaluate</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br></div></div><p><a href="https://pytorch.org/docs/stable/torchvision/index.html" target="_blank" rel="noreferrer">torchvision</a> パッケージには，MNIST データセットをロードするなどの便利な関数が含まれている． また，今回のハンズオンで使うカスタムのクラス・関数 (<code>Model</code>, <code>train</code>, <code>evaluate</code>) のインポートを行っている．</p>
<p>次に，MNIST テストデータをダウンロードしよう． 同時に，画像データの輝度の正規化も行っている．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">transf </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> transforms.Compose([transforms.ToTensor(),</span></span>
<span class="line"><span style="color: #ADBAC7">                             transforms.Normalize((</span><span style="color: #6CB6FF">0.1307</span><span style="color: #ADBAC7">,), (</span><span style="color: #6CB6FF">0.3081</span><span style="color: #ADBAC7">,))])</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">trainset </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> datasets.MNIST(</span><span style="color: #F69D50">root</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&#39;./data&#39;</span><span style="color: #ADBAC7">, </span><span style="color: #F69D50">train</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">True</span><span style="color: #ADBAC7">, </span><span style="color: #F69D50">download</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">True</span><span style="color: #ADBAC7">, </span><span style="color: #F69D50">transform</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">transf)</span></span>
<span class="line"><span style="color: #ADBAC7">trainloader </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> torch.utils.data.DataLoader(trainset, </span><span style="color: #F69D50">batch_size</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">64</span><span style="color: #ADBAC7">, </span><span style="color: #F69D50">shuffle</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">True</span><span style="color: #ADBAC7">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">testset </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> datasets.MNIST(</span><span style="color: #F69D50">root</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&#39;./data&#39;</span><span style="color: #ADBAC7">, </span><span style="color: #F69D50">train</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">False</span><span style="color: #ADBAC7">, </span><span style="color: #F69D50">download</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">True</span><span style="color: #ADBAC7">, </span><span style="color: #F69D50">transform</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">transf)</span></span>
<span class="line"><span style="color: #ADBAC7">testloader </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> torch.utils.data.DataLoader(testset, </span><span style="color: #F69D50">batch_size</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">1000</span><span style="color: #ADBAC7">, </span><span style="color: #F69D50">shuffle</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">True</span><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">transf </span><span style="color: #D73A49">=</span><span style="color: #24292E"> transforms.Compose([transforms.ToTensor(),</span></span>
<span class="line"><span style="color: #24292E">                             transforms.Normalize((</span><span style="color: #005CC5">0.1307</span><span style="color: #24292E">,), (</span><span style="color: #005CC5">0.3081</span><span style="color: #24292E">,))])</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">trainset </span><span style="color: #D73A49">=</span><span style="color: #24292E"> datasets.MNIST(</span><span style="color: #E36209">root</span><span style="color: #D73A49">=</span><span style="color: #032F62">&#39;./data&#39;</span><span style="color: #24292E">, </span><span style="color: #E36209">train</span><span style="color: #D73A49">=</span><span style="color: #005CC5">True</span><span style="color: #24292E">, </span><span style="color: #E36209">download</span><span style="color: #D73A49">=</span><span style="color: #005CC5">True</span><span style="color: #24292E">, </span><span style="color: #E36209">transform</span><span style="color: #D73A49">=</span><span style="color: #24292E">transf)</span></span>
<span class="line"><span style="color: #24292E">trainloader </span><span style="color: #D73A49">=</span><span style="color: #24292E"> torch.utils.data.DataLoader(trainset, </span><span style="color: #E36209">batch_size</span><span style="color: #D73A49">=</span><span style="color: #005CC5">64</span><span style="color: #24292E">, </span><span style="color: #E36209">shuffle</span><span style="color: #D73A49">=</span><span style="color: #005CC5">True</span><span style="color: #24292E">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">testset </span><span style="color: #D73A49">=</span><span style="color: #24292E"> datasets.MNIST(</span><span style="color: #E36209">root</span><span style="color: #D73A49">=</span><span style="color: #032F62">&#39;./data&#39;</span><span style="color: #24292E">, </span><span style="color: #E36209">train</span><span style="color: #D73A49">=</span><span style="color: #005CC5">False</span><span style="color: #24292E">, </span><span style="color: #E36209">download</span><span style="color: #D73A49">=</span><span style="color: #005CC5">True</span><span style="color: #24292E">, </span><span style="color: #E36209">transform</span><span style="color: #D73A49">=</span><span style="color: #24292E">transf)</span></span>
<span class="line"><span style="color: #24292E">testloader </span><span style="color: #D73A49">=</span><span style="color: #24292E"> torch.utils.data.DataLoader(testset, </span><span style="color: #E36209">batch_size</span><span style="color: #D73A49">=</span><span style="color: #005CC5">1000</span><span style="color: #24292E">, </span><span style="color: #E36209">shuffle</span><span style="color: #D73A49">=</span><span style="color: #005CC5">True</span><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br></div></div><p>今回扱う MNIST データは 28x28 ピクセルの正方形の画像(モノクロ)と，それぞれのラベル(0 - 9 の数字)の組で構成されている． いくつかのデータを抽出して，可視化してみよう． <a href="#handson_02_mnist_ground_truth">figure_title</a> のような出力が得られるはずである．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">examples </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">iter</span><span style="color: #ADBAC7">(testloader)</span></span>
<span class="line"><span style="color: #ADBAC7">example_data, example_targets </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> examples.next()</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6CB6FF">print</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;Example data size:&quot;</span><span style="color: #ADBAC7">, example_data.shape)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">fig </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> plt.figure(</span><span style="color: #F69D50">figsize</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">10</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">4</span><span style="color: #ADBAC7">))</span></span>
<span class="line"><span style="color: #F47067">for</span><span style="color: #ADBAC7"> i </span><span style="color: #F47067">in</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">range</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">10</span><span style="color: #ADBAC7">):</span></span>
<span class="line"><span style="color: #ADBAC7">    plt.subplot(</span><span style="color: #6CB6FF">2</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">5</span><span style="color: #ADBAC7">,i</span><span style="color: #F47067">+</span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">    plt.tight_layout()</span></span>
<span class="line"><span style="color: #ADBAC7">    plt.imshow(example_data[i][</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">], </span><span style="color: #F69D50">cmap</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&#39;gray&#39;</span><span style="color: #ADBAC7">, </span><span style="color: #F69D50">interpolation</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&#39;none&#39;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">    plt.title(</span><span style="color: #96D0FF">&quot;Ground Truth: </span><span style="color: #F47067">{}</span><span style="color: #96D0FF">&quot;</span><span style="color: #ADBAC7">.format(example_targets[i]))</span></span>
<span class="line"><span style="color: #ADBAC7">    plt.xticks([])</span></span>
<span class="line"><span style="color: #ADBAC7">    plt.yticks([])</span></span>
<span class="line"><span style="color: #ADBAC7">plt.show()</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">examples </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #005CC5">iter</span><span style="color: #24292E">(testloader)</span></span>
<span class="line"><span style="color: #24292E">example_data, example_targets </span><span style="color: #D73A49">=</span><span style="color: #24292E"> examples.next()</span></span>
<span class="line"></span>
<span class="line"><span style="color: #005CC5">print</span><span style="color: #24292E">(</span><span style="color: #032F62">&quot;Example data size:&quot;</span><span style="color: #24292E">, example_data.shape)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">fig </span><span style="color: #D73A49">=</span><span style="color: #24292E"> plt.figure(</span><span style="color: #E36209">figsize</span><span style="color: #D73A49">=</span><span style="color: #24292E">(</span><span style="color: #005CC5">10</span><span style="color: #24292E">,</span><span style="color: #005CC5">4</span><span style="color: #24292E">))</span></span>
<span class="line"><span style="color: #D73A49">for</span><span style="color: #24292E"> i </span><span style="color: #D73A49">in</span><span style="color: #24292E"> </span><span style="color: #005CC5">range</span><span style="color: #24292E">(</span><span style="color: #005CC5">10</span><span style="color: #24292E">):</span></span>
<span class="line"><span style="color: #24292E">    plt.subplot(</span><span style="color: #005CC5">2</span><span style="color: #24292E">,</span><span style="color: #005CC5">5</span><span style="color: #24292E">,i</span><span style="color: #D73A49">+</span><span style="color: #005CC5">1</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">    plt.tight_layout()</span></span>
<span class="line"><span style="color: #24292E">    plt.imshow(example_data[i][</span><span style="color: #005CC5">0</span><span style="color: #24292E">], </span><span style="color: #E36209">cmap</span><span style="color: #D73A49">=</span><span style="color: #032F62">&#39;gray&#39;</span><span style="color: #24292E">, </span><span style="color: #E36209">interpolation</span><span style="color: #D73A49">=</span><span style="color: #032F62">&#39;none&#39;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">    plt.title(</span><span style="color: #032F62">&quot;Ground Truth: </span><span style="color: #005CC5">{}</span><span style="color: #032F62">&quot;</span><span style="color: #24292E">.format(example_targets[i]))</span></span>
<span class="line"><span style="color: #24292E">    plt.xticks([])</span></span>
<span class="line"><span style="color: #24292E">    plt.yticks([])</span></span>
<span class="line"><span style="color: #24292E">plt.show()</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br></div></div><p><img src="./assets/handson-jupyter/mnist_ground_truth.png" alt="MNIST の手書き数字画像とその教師ラベル"></p>
<p>次に， CNN のモデルを定義する．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">model </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> Model()</span></span>
<span class="line"><span style="color: #ADBAC7">model.to(</span><span style="color: #96D0FF">&quot;cuda&quot;</span><span style="color: #ADBAC7">) </span><span style="color: #768390"># load to GPU</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">model </span><span style="color: #D73A49">=</span><span style="color: #24292E"> Model()</span></span>
<span class="line"><span style="color: #24292E">model.to(</span><span style="color: #032F62">&quot;cuda&quot;</span><span style="color: #24292E">) </span><span style="color: #6A737D"># load to GPU</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>今回使う <code>Model</code> は <code>simple_mnist.py</code> の中で定義されている． このモデルは，<a href="#handson_02_cnn_architecture">figure_title</a> に示したような，２層の畳み込み層と 2 層の全結合層からなるネットワークである． 出力層 (output layer) には Softmax 関数を使用し，損失関数 (Loss function) には 負の対数尤度関数 (Negative log likelyhood; NLL) を使用している．</p>
<p><img src="./assets/handson-jupyter/cnn_architecture.png" alt="本ハンズオンで使用するニューラルネットの構造．"></p>
<p>続いて， CNN のパラメータを更新する最適化アルゴリズムを定義する． ここでは， <strong>確率的勾配降下法 (Stochastic Gradient Descent; SGD)</strong> を使用している．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">optimizer </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> optim.SGD(model.parameters(), </span><span style="color: #F69D50">lr</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">0.01</span><span style="color: #ADBAC7">, </span><span style="color: #F69D50">momentum</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">0.5</span><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">optimizer </span><span style="color: #D73A49">=</span><span style="color: #24292E"> optim.SGD(model.parameters(), </span><span style="color: #E36209">lr</span><span style="color: #D73A49">=</span><span style="color: #005CC5">0.01</span><span style="color: #24292E">, </span><span style="color: #E36209">momentum</span><span style="color: #D73A49">=</span><span style="color: #005CC5">0.5</span><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>これで，準備が整った． CNN の学習ループを開始しよう!</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">train_losses </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> []</span></span>
<span class="line"><span style="color: #F47067">for</span><span style="color: #ADBAC7"> epoch </span><span style="color: #F47067">in</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">range</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">5</span><span style="color: #ADBAC7">):</span></span>
<span class="line"><span style="color: #ADBAC7">    losses </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> train(model, trainloader, optimizer, epoch)</span></span>
<span class="line"><span style="color: #ADBAC7">    train_losses </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> train_losses </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> losses</span></span>
<span class="line"><span style="color: #ADBAC7">    test_loss, test_accuracy </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> evaluate(model, testloader)</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">print</span><span style="color: #ADBAC7">(</span><span style="color: #F47067">f</span><span style="color: #96D0FF">&quot;</span><span style="color: #F47067">\n</span><span style="color: #96D0FF">Test set: Average loss: </span><span style="color: #F47067">{</span><span style="color: #ADBAC7">test_loss</span><span style="color: #F47067">:.4f}</span><span style="color: #96D0FF">, Accuracy: </span><span style="color: #F47067">{</span><span style="color: #ADBAC7">test_accuracy</span><span style="color: #F47067">:.1f}</span><span style="color: #96D0FF">%</span><span style="color: #F47067">\n</span><span style="color: #96D0FF">&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">plt.figure(</span><span style="color: #F69D50">figsize</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">7</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">5</span><span style="color: #ADBAC7">))</span></span>
<span class="line"><span style="color: #ADBAC7">plt.plot(train_losses)</span></span>
<span class="line"><span style="color: #ADBAC7">plt.xlabel(</span><span style="color: #96D0FF">&quot;Iterations&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">plt.ylabel(</span><span style="color: #96D0FF">&quot;Train loss&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">plt.show()</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">train_losses </span><span style="color: #D73A49">=</span><span style="color: #24292E"> []</span></span>
<span class="line"><span style="color: #D73A49">for</span><span style="color: #24292E"> epoch </span><span style="color: #D73A49">in</span><span style="color: #24292E"> </span><span style="color: #005CC5">range</span><span style="color: #24292E">(</span><span style="color: #005CC5">5</span><span style="color: #24292E">):</span></span>
<span class="line"><span style="color: #24292E">    losses </span><span style="color: #D73A49">=</span><span style="color: #24292E"> train(model, trainloader, optimizer, epoch)</span></span>
<span class="line"><span style="color: #24292E">    train_losses </span><span style="color: #D73A49">=</span><span style="color: #24292E"> train_losses </span><span style="color: #D73A49">+</span><span style="color: #24292E"> losses</span></span>
<span class="line"><span style="color: #24292E">    test_loss, test_accuracy </span><span style="color: #D73A49">=</span><span style="color: #24292E"> evaluate(model, testloader)</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">print</span><span style="color: #24292E">(</span><span style="color: #D73A49">f</span><span style="color: #032F62">&quot;</span><span style="color: #005CC5">\n</span><span style="color: #032F62">Test set: Average loss: </span><span style="color: #005CC5">{</span><span style="color: #24292E">test_loss</span><span style="color: #D73A49">:.4f</span><span style="color: #005CC5">}</span><span style="color: #032F62">, Accuracy: </span><span style="color: #005CC5">{</span><span style="color: #24292E">test_accuracy</span><span style="color: #D73A49">:.1f</span><span style="color: #005CC5">}</span><span style="color: #032F62">%</span><span style="color: #005CC5">\n</span><span style="color: #032F62">&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">plt.figure(</span><span style="color: #E36209">figsize</span><span style="color: #D73A49">=</span><span style="color: #24292E">(</span><span style="color: #005CC5">7</span><span style="color: #24292E">,</span><span style="color: #005CC5">5</span><span style="color: #24292E">))</span></span>
<span class="line"><span style="color: #24292E">plt.plot(train_losses)</span></span>
<span class="line"><span style="color: #24292E">plt.xlabel(</span><span style="color: #032F62">&quot;Iterations&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">plt.ylabel(</span><span style="color: #032F62">&quot;Train loss&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">plt.show()</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br></div></div><p>ここでは 5 エポック分の学習を行っている． GPU を使えば，これくらいの計算であれば 1 分程度で完了するだろう．</p>
<p>出力として， <a href="#handson_02_train_loss">figure_title</a> のようなプロットが得られるはずである． イテレーションを重ねるにつれて，損失関数 (Loss function) の値が減少している (=精度が向上している) ことがわかる．</p>
<p><img src="./assets/handson-jupyter/train_loss.png" alt="学習の進行に対する Train loss の変化"></p>
<p>出力にはテキスト形式で各エポック終了後のテストデータに対する精度も表示されている． 最終的には 98% 以上の極めて高い精度を実現できていることが確認できるだろう (<a href="#handson_02_mnist_final_score">figure_title</a>)．</p>
<p><img src="./assets/handson-jupyter/mnist_final_score.png" alt="学習したCNNのテストデータに対するスコア (5エポック後)"></p>
<p>学習した CNN の推論結果を可視化してみよう． 次のコードを実行することで， <a href="#handson_02_mnist_mnist_prediction">figure_title</a> のような出力が得られるだろう． この図で，下段右から二番目は，&quot;1&quot;に近い見た目をしているが，きちんと&quot;9&quot;と推論できている． なかなか賢い CNN を作り出すことができたようだ！</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">model.eval()</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F47067">with</span><span style="color: #ADBAC7"> torch.no_grad():</span></span>
<span class="line"><span style="color: #ADBAC7">    output </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> model(example_data.to(</span><span style="color: #96D0FF">&quot;cuda&quot;</span><span style="color: #ADBAC7">))</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">fig </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> plt.figure(</span><span style="color: #F69D50">figsize</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">10</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">4</span><span style="color: #ADBAC7">))</span></span>
<span class="line"><span style="color: #F47067">for</span><span style="color: #ADBAC7"> i </span><span style="color: #F47067">in</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">range</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">10</span><span style="color: #ADBAC7">):</span></span>
<span class="line"><span style="color: #ADBAC7">    plt.subplot(</span><span style="color: #6CB6FF">2</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">5</span><span style="color: #ADBAC7">,i</span><span style="color: #F47067">+</span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">    plt.tight_layout()</span></span>
<span class="line"><span style="color: #ADBAC7">    plt.imshow(example_data[i][</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">], </span><span style="color: #F69D50">cmap</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&#39;gray&#39;</span><span style="color: #ADBAC7">, </span><span style="color: #F69D50">interpolation</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&#39;none&#39;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">    plt.title(</span><span style="color: #96D0FF">&quot;Prediction: </span><span style="color: #F47067">{}</span><span style="color: #96D0FF">&quot;</span><span style="color: #ADBAC7">.format(output.data.max(</span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">, </span><span style="color: #F69D50">keepdim</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">True</span><span style="color: #ADBAC7">)[</span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">][i].item()))</span></span>
<span class="line"><span style="color: #ADBAC7">    plt.xticks([])</span></span>
<span class="line"><span style="color: #ADBAC7">    plt.yticks([])</span></span>
<span class="line"><span style="color: #ADBAC7">plt.show()</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">model.eval()</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D73A49">with</span><span style="color: #24292E"> torch.no_grad():</span></span>
<span class="line"><span style="color: #24292E">    output </span><span style="color: #D73A49">=</span><span style="color: #24292E"> model(example_data.to(</span><span style="color: #032F62">&quot;cuda&quot;</span><span style="color: #24292E">))</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">fig </span><span style="color: #D73A49">=</span><span style="color: #24292E"> plt.figure(</span><span style="color: #E36209">figsize</span><span style="color: #D73A49">=</span><span style="color: #24292E">(</span><span style="color: #005CC5">10</span><span style="color: #24292E">,</span><span style="color: #005CC5">4</span><span style="color: #24292E">))</span></span>
<span class="line"><span style="color: #D73A49">for</span><span style="color: #24292E"> i </span><span style="color: #D73A49">in</span><span style="color: #24292E"> </span><span style="color: #005CC5">range</span><span style="color: #24292E">(</span><span style="color: #005CC5">10</span><span style="color: #24292E">):</span></span>
<span class="line"><span style="color: #24292E">    plt.subplot(</span><span style="color: #005CC5">2</span><span style="color: #24292E">,</span><span style="color: #005CC5">5</span><span style="color: #24292E">,i</span><span style="color: #D73A49">+</span><span style="color: #005CC5">1</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">    plt.tight_layout()</span></span>
<span class="line"><span style="color: #24292E">    plt.imshow(example_data[i][</span><span style="color: #005CC5">0</span><span style="color: #24292E">], </span><span style="color: #E36209">cmap</span><span style="color: #D73A49">=</span><span style="color: #032F62">&#39;gray&#39;</span><span style="color: #24292E">, </span><span style="color: #E36209">interpolation</span><span style="color: #D73A49">=</span><span style="color: #032F62">&#39;none&#39;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">    plt.title(</span><span style="color: #032F62">&quot;Prediction: </span><span style="color: #005CC5">{}</span><span style="color: #032F62">&quot;</span><span style="color: #24292E">.format(output.data.max(</span><span style="color: #005CC5">1</span><span style="color: #24292E">, </span><span style="color: #E36209">keepdim</span><span style="color: #D73A49">=</span><span style="color: #005CC5">True</span><span style="color: #24292E">)[</span><span style="color: #005CC5">1</span><span style="color: #24292E">][i].item()))</span></span>
<span class="line"><span style="color: #24292E">    plt.xticks([])</span></span>
<span class="line"><span style="color: #24292E">    plt.yticks([])</span></span>
<span class="line"><span style="color: #24292E">plt.show()</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br></div></div><p><img src="./assets/handson-jupyter/mnist_prediction.png" alt="学習した CNN による，MNIST画像の推論結果"></p>
<p>最後に，学習したニューラルネットワークのパラメータを <code>mnist_cnn.pt</code> というファイル名で保存しておこう． これで，将来いつでも今回学習したモデルを再現し，別の実験に使用することができる．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">torch.save(model.state_dict(), </span><span style="color: #96D0FF">&quot;mnist_cnn.pt&quot;</span><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">torch.save(model.state_dict(), </span><span style="color: #032F62">&quot;mnist_cnn.pt&quot;</span><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>以上が， AWS クラウドの仮想サーバーを立ち上げ，最初のディープラーニングの計算を行う一連の流れである． MNIST 文字認識のタスクを行うニューラルネットを，クラウド上の GPU を使って高速に学習させ，現実的な問題を一つ解くことができたのである． 興味のある読者は，今回のハンズオンを雛形に，自分の所望の計算を走らせてみるとよいだろう．</p>
<h2 id="スタックの削除" tabindex="-1">スタックの削除 <a class="header-anchor" href="#スタックの削除" aria-label="Permalink to &quot;スタックの削除&quot;">&ZeroWidthSpace;</a></h2>
<p>これにて，ハンズオン第二回の内容はすべて説明した． クラウドの利用料金を最小化するため，使い終わった EC2 インスタンスはすぐさま削除しよう．</p>
<p>ハンズオン第一回と同様に， AWS の CloudFormation コンソールか， AWS CLI により削除を実行する (詳細は (#handson_01_delete_stack) 参照)．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cdk</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">destroy</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cdk</span><span style="color: #24292E"> </span><span style="color: #032F62">destroy</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p><strong>スタックの削除は各自で必ず行うこと！</strong> 行わなかった場合，EC2 インスタンスの料金が発生し続けることになる！ <code>g4dn.xlarge</code> は $0.71 / hour の料金設定なので，一日起動しつづけると約$17 の請求が発生することになる！</p>
<p><strong>AWS のバジェットアラート</strong></p>
<p>AWS の初心者が (あるいは経験者も) しばしば陥る失敗が，インスタンスの停止忘れなどで無駄なリソースがクラウドで放置されてしまい，巨大な額の請求が届く，というミスだ． 特に，開発を行っている間はこのような事態は起こりうるものだと思って，備えておかなければならない． このような事態を未然に防ぐため， AWS Budgets という機能が無料で提供されている． AWS Budgets を利用することで，月の利用金額がある閾値を超えた場合にユーザーにメールが送信される，などのアラートを設定することができる． 詳細な手順は <a href="https://aws.amazon.com/blogs/aws-cost-management/getting-started-with-aws-budgets/" target="_blank" rel="noreferrer">AWS の公式ブログ &quot;Getting Started with AWS Budgets&quot;</a> を参照のこと． 本書の読者も，ぜひこのタイミングでアラートを設定しておくことを推奨する．</p>
]]></description>
            <content:encoded><![CDATA[<h1 id="hands-on-2-aws-でディープラーニングを実践" tabindex="-1">Hands-on #2: AWS でディープラーニングを実践 <a class="header-anchor" href="#hands-on-2-aws-でディープラーニングを実践" aria-label="Permalink to &quot;Hands-on \#2: AWS でディープラーニングを実践&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="準備" tabindex="-1">準備 <a class="header-anchor" href="#準備" aria-label="Permalink to &quot;準備&quot;">&ZeroWidthSpace;</a></h2>
<p>ハンズオン第二回では， GPU を搭載した EC2 インスタンスを起動し，深層学習モデルの学習と推論を実行する演習を行う．</p>
<p>ハンズオンのソースコードは GitHub の <a href="https://github.com/andatoshiki/toshiki-notebooktree/main/handson/mnist" target="_blank" rel="noreferrer">handson/mnist</a> に置いてある．</p>
<p>本ハンズオンの実行には，第一回ハンズオンで説明した準備 ( (#handson_01_prep)) が整っていることを前提とする． それ以外に必要な準備はない．</p>
<p>初期状態の AWS アカウントでは， GPU 搭載の G タイプのインスタンスの起動上限が 0 になっていることがある． これを確認するには， AWS コンソールから EC2 の画面を開き，左のメニューから <code>Limits</code> を選択する． その中の <code>Running On-Demand All G instances</code> という数字が G インスタンスの起動上限を表している．</p>
<p>もし，これが 0 になっていた場合は， AWS の自動申請フォームから上限緩和のリクエストを送る必要がある． 詳しくは <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-resource-limits.html" target="_blank" rel="noreferrer">公式ドキュメンテーション &quot;Amazon EC2 service quotas&quot;</a> を参照のこと．</p>
<p>このハンズオンは， <code>g4dn.xlarge</code> タイプの EC2 インスタンスを使うので，東京 (<code>ap-northeast-1</code>) リージョンでは 0.71 $/hour のコストが発生する．</p>
<p>AWS Educate Starter Account を使用している読者へ: 執筆時点においては， Starter Account には GPU 搭載型インスタンスを起動できないという制限が設けられている． したがって， Starter Account のユーザーはこのハンズオンを実行することはできない． 興味のある読者は，制限のない一般アカウントを自分自身で取得する必要があることに注意．</p>
<h2 id="アプリケーションの説明" tabindex="-1">アプリケーションの説明 <a class="header-anchor" href="#アプリケーションの説明" aria-label="Permalink to &quot;アプリケーションの説明&quot;">&ZeroWidthSpace;</a></h2>
<p>このハンズオンで作成するアプリケーションの概要を <a href="#handson_02_architecture">figure_title</a> に示す．</p>
<p><img src="./assets/handson-jupyter/handson-02-architecture.png" alt="ハンズオン#2で作製するアプリケーションのアーキテクチャ"></p>
<p>図の多くの部分が，第一回ハンズオンで作成したアプリケーションと共通していることに気がつくだろう． 少しの変更で，簡単にディープラーニングを走らせる環境を構築することができるのである！主な変更点は次の３点である．</p>
<ul>
<li>
<p>GPU を搭載した <code>g4dn.xlarge</code> インスタンスタイプを使用</p>
</li>
<li>
<p>ディープラーニングに使うプログラムがあらかじめインストールされた DLAMI (後述) を使用</p>
</li>
<li>
<p>SSH にポートフォワーディングのオプションつけてサーバーに接続し，サーバーで起動している Jupyter Notebook (後述) を使ってプログラムを書いたり実行したりする</p>
</li>
</ul>
<p>ハンズオンで使用するプログラムのコードをみてみよう <a href="https://github.com/andatoshiki/toshiki-notebooktree/main/handson/mnist/app.py" target="_blank" rel="noreferrer">handson/mnist/app.py</a>)． コードは第一回目とほとんど共通である．変更点のみ解説を行う．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">class</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50">Ec2ForDl</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">core</span><span style="color: #ADBAC7">.</span><span style="color: #6CB6FF">Stack</span><span style="color: #ADBAC7">):</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">def</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">__init__</span><span style="color: #ADBAC7">(self, scope: core.App, name: </span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">, key_name: </span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">, </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">kwargs) -&gt; </span><span style="color: #6CB6FF">None</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #6CB6FF">super</span><span style="color: #ADBAC7">().</span><span style="color: #6CB6FF">__init__</span><span style="color: #ADBAC7">(scope, name, </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">kwargs)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        vpc </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ec2.Vpc(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;Ec2ForDl-Vpc&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">max_azs</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">cidr</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;10.10.0.0/23&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">subnet_configuration</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">[</span></span>
<span class="line"><span style="color: #ADBAC7">                ec2.SubnetConfiguration(</span></span>
<span class="line"><span style="color: #ADBAC7">                    </span><span style="color: #F69D50">name</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;public&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                    </span><span style="color: #F69D50">subnet_type</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.SubnetType.</span><span style="color: #6CB6FF">PUBLIC</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                )</span></span>
<span class="line"><span style="color: #ADBAC7">            ],</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">nat_gateways</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        sg </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ec2.SecurityGroup(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;Ec2ForDl-Sg&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">vpc</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">vpc,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">allow_all_outbound</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">True</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"><span style="color: #ADBAC7">        sg.add_ingress_rule(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">peer</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.Peer.any_ipv4(),</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">connection</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.Port.tcp(</span><span style="color: #6CB6FF">22</span><span style="color: #ADBAC7">),</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        host </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ec2.Instance(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;Ec2ForDl-Instance&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">instance_type</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.InstanceType(</span><span style="color: #96D0FF">&quot;g4dn.xlarge&quot;</span><span style="color: #ADBAC7">), </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">machine_image</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.MachineImage.generic_linux({</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #96D0FF">&quot;us-east-1&quot;</span><span style="color: #ADBAC7">: </span><span style="color: #96D0FF">&quot;ami-060f07284bb6f9faf&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #96D0FF">&quot;ap-northeast-1&quot;</span><span style="color: #ADBAC7">: </span><span style="color: #96D0FF">&quot;ami-09c0c16fc46a29ed9&quot;</span></span>
<span class="line"><span style="color: #ADBAC7">            }), </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">vpc</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">vpc,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">vpc_subnets</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.SubnetSelection(</span><span style="color: #F69D50">subnet_type</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.SubnetType.</span><span style="color: #6CB6FF">PUBLIC</span><span style="color: #ADBAC7">),</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">security_group</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">sg,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">key_name</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">key_name</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">class</span><span style="color: #24292E"> </span><span style="color: #6F42C1">Ec2ForDl</span><span style="color: #24292E">(</span><span style="color: #6F42C1">core</span><span style="color: #24292E">.</span><span style="color: #6F42C1">Stack</span><span style="color: #24292E">):</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">def</span><span style="color: #24292E"> </span><span style="color: #005CC5">__init__</span><span style="color: #24292E">(self, scope: core.App, name: </span><span style="color: #005CC5">str</span><span style="color: #24292E">, key_name: </span><span style="color: #005CC5">str</span><span style="color: #24292E">, </span><span style="color: #D73A49">**</span><span style="color: #24292E">kwargs) -&gt; </span><span style="color: #005CC5">None</span><span style="color: #24292E">:</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #005CC5">super</span><span style="color: #24292E">().</span><span style="color: #005CC5">__init__</span><span style="color: #24292E">(scope, name, </span><span style="color: #D73A49">**</span><span style="color: #24292E">kwargs)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        vpc </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ec2.Vpc(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;Ec2ForDl-Vpc&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">max_azs</span><span style="color: #D73A49">=</span><span style="color: #005CC5">1</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">cidr</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;10.10.0.0/23&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">subnet_configuration</span><span style="color: #D73A49">=</span><span style="color: #24292E">[</span></span>
<span class="line"><span style="color: #24292E">                ec2.SubnetConfiguration(</span></span>
<span class="line"><span style="color: #24292E">                    </span><span style="color: #E36209">name</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;public&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                    </span><span style="color: #E36209">subnet_type</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.SubnetType.</span><span style="color: #005CC5">PUBLIC</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                )</span></span>
<span class="line"><span style="color: #24292E">            ],</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">nat_gateways</span><span style="color: #D73A49">=</span><span style="color: #005CC5">0</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        sg </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ec2.SecurityGroup(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;Ec2ForDl-Sg&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">vpc</span><span style="color: #D73A49">=</span><span style="color: #24292E">vpc,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">allow_all_outbound</span><span style="color: #D73A49">=</span><span style="color: #005CC5">True</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"><span style="color: #24292E">        sg.add_ingress_rule(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">peer</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.Peer.any_ipv4(),</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">connection</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.Port.tcp(</span><span style="color: #005CC5">22</span><span style="color: #24292E">),</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        host </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ec2.Instance(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;Ec2ForDl-Instance&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">instance_type</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.InstanceType(</span><span style="color: #032F62">&quot;g4dn.xlarge&quot;</span><span style="color: #24292E">), </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">machine_image</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.MachineImage.generic_linux({</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #032F62">&quot;us-east-1&quot;</span><span style="color: #24292E">: </span><span style="color: #032F62">&quot;ami-060f07284bb6f9faf&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #032F62">&quot;ap-northeast-1&quot;</span><span style="color: #24292E">: </span><span style="color: #032F62">&quot;ami-09c0c16fc46a29ed9&quot;</span></span>
<span class="line"><span style="color: #24292E">            }), </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">vpc</span><span style="color: #D73A49">=</span><span style="color: #24292E">vpc,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">vpc_subnets</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.SubnetSelection(</span><span style="color: #E36209">subnet_type</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.SubnetType.</span><span style="color: #005CC5">PUBLIC</span><span style="color: #24292E">),</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">security_group</span><span style="color: #D73A49">=</span><span style="color: #24292E">sg,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">key_name</span><span style="color: #D73A49">=</span><span style="color: #24292E">key_name</span></span>
<span class="line"><span style="color: #24292E">        )</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br><span class="line-number">36</span><br><span class="line-number">37</span><br><span class="line-number">38</span><br><span class="line-number">39</span><br><span class="line-number">40</span><br></div></div><ul>
<li>
<p>ここで， <code>g4dn.xlarge</code> インスタンスタイプを選択している (第一回では， CPU のみの <code>t2.micro</code> だった)． <code>g4dn.xlarge</code> のインスタンスタイプは， (#sec_scientific_computing) ですでに触れた通り， <code>NVIDIA T4</code> と呼ばれる廉価版モデルの GPU を搭載したインスタンスである． CPU は 4 core, メインメモリーは 16GB が割り当てあられている．</p>
</li>
<li>
<p>ここでは，Deep Learning 用の諸々のソフトウェアがプリンストールされた AMI (<a href="https://docs.aws.amazon.com/dlami/latest/devguide/what-is-dlami.html" target="_blank" rel="noreferrer">Deep Learning Amazon Machine Image; DLAMI</a>) を選択している (第一回では，Amazon Linux という AMI を使用していた)． 使用する AMI の ID は リージョンごとに指定する必要があり，ここでは <code>us-east-1</code> と <code>ap-northeast-1</code> でそれぞれ定義している．</p>
</li>
</ul>
<p>DLAMI という新しい概念が出てきたので，説明しよう．</p>
<p>AMI が <code>us-east-1</code> と <code>ap-northeast-1</code> でしか定義されていないので，提供されているコードはこの二つのリージョンのみでデプロイ可能である． もしほかのリージョンを利用したい場合は， AMI の ID を自身で検索し，コードに書き込む必要がある．</p>
<h3 id="dlami-deep-learning-amazon-machine-image" tabindex="-1">DLAMI (Deep Learning Amazon Machine Image) <a class="header-anchor" href="#dlami-deep-learning-amazon-machine-image" aria-label="Permalink to &quot;DLAMI (Deep Learning Amazon Machine Image)&quot;">&ZeroWidthSpace;</a></h3>
<p><strong>AMI (Amazon Machine Image)</strong> とは，大まかには OS (Operating System) に相当する概念である． 当然のことながら， OS がなければコンピュータはなにもできないので，EC2 インスタンスを起動するときには必ずなにかの OS を&quot;インストール&quot;する必要がある． EC2 が起動したときにロードされる OS に相当するものが， AMI である． AMI には，たとえば <a href="https://ubuntu.com/" target="_blank" rel="noreferrer">Ubuntu</a> などの Linux 系 OS に加えて，Windows Server を選択することもできる． また， EC2 での使用に最適化された <a href="https://aws.amazon.com/amazon-linux-ami/" target="_blank" rel="noreferrer">Amazon Linux</a> という AMI も提供されている．</p>
<p>しかしながら， AMI を単なる OS と理解するのは過剰な単純化である． AMI には，ベースとなる (空っぽの) OS を選択することもできるが，それに加えて，各種のプログラムがインストール済みの AMI も定義することができる． 必要なプログラムがインストールされている AMI を見つけることができれば，自身でインストールを行ったり環境設定したりする手間が大幅に省ける． 具体例を挙げると，ハンズオン第一回では EC2 インスタンスに Python 3.6 をインストールする例を示したが，そのような操作をインスタンスが起動するたびに行うのは手間である！</p>
<p>AMI は， AWS 公式のものに加えて，サードパーティから提供されているものもある． また，自分自身の AMI を作って登録することも可能である (<a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/creating-an-ami-instance-store.html" target="_blank" rel="noreferrer">参考</a>)． AMI は EC2 のコンソールから検索することが可能である． あるいは，AWS CLI を使って，次のコマンドでリストを取得することができる (<a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/finding-an-ami.html" target="_blank" rel="noreferrer">参考</a>)．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ec2</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">describe-images</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--owners</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">amazon</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">aws</span><span style="color: #24292E"> </span><span style="color: #032F62">ec2</span><span style="color: #24292E"> </span><span style="color: #032F62">describe-images</span><span style="color: #24292E"> </span><span style="color: #005CC5">--owners</span><span style="color: #24292E"> </span><span style="color: #032F62">amazon</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>ディープラーニングで頻繁に使われるプログラムがあらかじめインストールしてある AMI が， <a href="https://docs.aws.amazon.com/dlami/latest/devguide/what-is-dlami.html" target="_blank" rel="noreferrer">DLAMI (Deep Learning AMI)</a> である． DLAMI には <code>TensorFlow</code>, <code>PyTorch</code> などの人気の高いディープラーニングのフレームワーク・ライブラリがすでにインストールされているため， EC2 インスタンスを起動してすぐさまディープラーニングの計算を実行できる．</p>
<p>本ハンズオンでは， Amazon Linux 2 をベースにした DLAMI を使用する (AMI ID = ami-09c0c16fc46a29ed9．この AMI は ap-northeast-1 でしか使用できない点に注意)． AWS CLI を使って，この AMI の詳細情報を取得してみよう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ec2</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">describe-images</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--owners</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">amazon</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--image-ids</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;ami-09c0c16fc46a29ed9&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--region</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ap-northeast-1</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">aws</span><span style="color: #24292E"> </span><span style="color: #032F62">ec2</span><span style="color: #24292E"> </span><span style="color: #032F62">describe-images</span><span style="color: #24292E"> </span><span style="color: #005CC5">--owners</span><span style="color: #24292E"> </span><span style="color: #032F62">amazon</span><span style="color: #24292E"> </span><span style="color: #005CC5">--image-ids</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;ami-09c0c16fc46a29ed9&quot;</span><span style="color: #24292E"> </span><span style="color: #005CC5">--region</span><span style="color: #24292E"> </span><span style="color: #032F62">ap-northeast-1</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p><img src="./assets/handson-jupyter/ami-info.png" alt="AMI ID = ami-09c0c16fc46a29ed9 の詳細情報"></p>
<p><a href="#handson_02_ami-info">figure_title</a> のような出力が得られるはずである．得られた出力から，この DLAMI には PyTorch のバージョン 1.4.0 と 1.5.0 がインストールされていることがわかる． この DLAMI を使って，早速ディープラーニングの計算を実行してみよう．</p>
<p>DLAMI には具体的には何がインストールされているのだろうか？ 興味のある読者のために，簡単な解説をしよう (参考: <a href="https://docs.aws.amazon.com/dlami/latest/devguide/what-is-dlami.html" target="_blank" rel="noreferrer">公式ドキュメンテーション &quot;What Is the AWS Deep Learning AMI?&quot;</a>)．</p>
<p>最も low-level なレイヤーとしては， GPU ドライバー がインストールされている． GPU ドライバーなしには OS は GPU とコマンドのやり取りをすることができない． 次のレイヤーが <a href="https://developer.nvidia.com/about-cuda" target="_blank" rel="noreferrer">CUDA</a> と <a href="https://developer.nvidia.com/cudnn" target="_blank" rel="noreferrer">cuDNN</a> である． CUDA は， NVIDIA 社が開発した， GPU 上で汎用コンピューティングを行うための言語であり， C++ 言語を拡張したシンタックスを備える． cuDNN は CUDA で書かれたディープラーニングのライブラリであり，n 次元の畳み込みなどの演算が実装されている． ここまでが， &quot;Base&quot; とよばれるタイプの DLAMI の中身である．</p>
<p>これに加えて， &quot;Conda&quot; とよばれるタイプには， &quot;Base&quot; のプログラム基盤の上に， <code>TensorFlow</code> や <code>PyTorch</code> などのライブラリがインストールされている． さらに， <a href="https://docs.conda.io/projects/conda/en/latest/index.html" target="_blank" rel="noreferrer">Anaconda</a> による仮想環境を使うことによって， <code>TensorFlow</code> の環境・ <code>PyTorch</code> の環境・ <code>MxNet</code> の環境など，フレームワークを簡単に切り替えることができる (これについては，後のハンズオンで触れる)． また， Jupyter Notebook もインストール済みである．</p>
<h2 id="スタックのデプロイ" tabindex="-1">スタックのデプロイ <a class="header-anchor" href="#スタックのデプロイ" aria-label="Permalink to &quot;スタックのデプロイ&quot;">&ZeroWidthSpace;</a></h2>
<p>スタックの中身が理解できたところで，早速スタックをデプロイしてみよう．</p>
<p>デプロイの手順は，ハンズオン 1 とほとんど共通である． ここでは，コマンドのみ列挙する (<code>#</code> で始まる行はコメントである)． それぞれのコマンドの意味を忘れてしまった場合は，ハンズオン 1 に戻って復習していただきたい． シークレットキーの設定も忘れずに ( (#aws_cli_install))．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390"># プロジェクトのディレクトリに移動</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cd</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">handson/mnist</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># venv を作成し，依存ライブラリのインストールを行う</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python3</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-m</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">venv</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.env</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">source</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.env/bin/activate</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">pip</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">install</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-r</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">requirements.txt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># SSH鍵を生成</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">export</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">KEY_NAME=&quot;HirakeGoma&quot;</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ec2</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">create-key-pair</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--key-name</span><span style="color: #ADBAC7"> ${KEY_NAME} </span><span style="color: #6CB6FF">--query</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;KeyMaterial&#39;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--output</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">text</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">&gt;</span><span style="color: #ADBAC7"> ${KEY_NAME}</span><span style="color: #96D0FF">.pem</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">mv</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">HirakeGoma.pem</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">~/.ssh/</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">chmod</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">400</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">~/.ssh/HirakeGoma.pem</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># デプロイを実行</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cdk</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">deploy</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-c</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">key_name=&quot;HirakeGoma&quot;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D"># プロジェクトのディレクトリに移動</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cd</span><span style="color: #24292E"> </span><span style="color: #032F62">handson/mnist</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># venv を作成し，依存ライブラリのインストールを行う</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python3</span><span style="color: #24292E"> </span><span style="color: #005CC5">-m</span><span style="color: #24292E"> </span><span style="color: #032F62">venv</span><span style="color: #24292E"> </span><span style="color: #032F62">.env</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">source</span><span style="color: #24292E"> </span><span style="color: #032F62">.env/bin/activate</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">pip</span><span style="color: #24292E"> </span><span style="color: #032F62">install</span><span style="color: #24292E"> </span><span style="color: #005CC5">-r</span><span style="color: #24292E"> </span><span style="color: #032F62">requirements.txt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># SSH鍵を生成</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">export</span><span style="color: #24292E"> </span><span style="color: #032F62">KEY_NAME=&quot;HirakeGoma&quot;</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">aws</span><span style="color: #24292E"> </span><span style="color: #032F62">ec2</span><span style="color: #24292E"> </span><span style="color: #032F62">create-key-pair</span><span style="color: #24292E"> </span><span style="color: #005CC5">--key-name</span><span style="color: #24292E"> ${KEY_NAME} </span><span style="color: #005CC5">--query</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;KeyMaterial&#39;</span><span style="color: #24292E"> </span><span style="color: #005CC5">--output</span><span style="color: #24292E"> </span><span style="color: #032F62">text</span><span style="color: #24292E"> </span><span style="color: #D73A49">&gt;</span><span style="color: #24292E"> ${KEY_NAME}</span><span style="color: #032F62">.pem</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">mv</span><span style="color: #24292E"> </span><span style="color: #032F62">HirakeGoma.pem</span><span style="color: #24292E"> </span><span style="color: #032F62">~/.ssh/</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">chmod</span><span style="color: #24292E"> </span><span style="color: #005CC5">400</span><span style="color: #24292E"> </span><span style="color: #032F62">~/.ssh/HirakeGoma.pem</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># デプロイを実行</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cdk</span><span style="color: #24292E"> </span><span style="color: #032F62">deploy</span><span style="color: #24292E"> </span><span style="color: #005CC5">-c</span><span style="color: #24292E"> </span><span style="color: #032F62">key_name=&quot;HirakeGoma&quot;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br></div></div><p>ハンズオン 1 で作成した SSH 鍵の削除を行わなかった場合は， SSH 鍵を改めて作成する必要はない． 逆に言うと，同じ名前の SSH がすでに存在する場合は，鍵生成のコマンドはエラーを出力する．</p>
<p>デプロイのコマンドが無事に実行されれば， <a href="#handson_02_cdk_output">figure_title</a> のような出力が得られるはずである．AWS により割り振られた IP アドレス (<code>InstancePublicIp</code> に続く文字列) をメモしておこう．</p>
<p><img src="./assets/handson-jupyter/cdk_output.png" alt="CDKデプロイ実行後の出力"></p>
<h2 id="ログイン" tabindex="-1">ログイン <a class="header-anchor" href="#ログイン" aria-label="Permalink to &quot;ログイン&quot;">&ZeroWidthSpace;</a></h2>
<p>早速，デプロイしたインスタンスに SSH でログインしてみよう． ここでは，この後で使う Jupyter Notebook に接続するため，<strong>ポートフォワーディング (port forwarding)</strong> のオプション (<code>-L</code>) をつけてログインする．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ssh</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-i</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">~/.ssh/HirakeGoma.pem</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-L</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">localhost:8931:localhost:8888</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ec2-user@</span><span style="color: #F47067">&lt;</span><span style="color: #96D0FF">IP</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">addres</span><span style="color: #ADBAC7">s</span><span style="color: #F47067">&gt;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">ssh</span><span style="color: #24292E"> </span><span style="color: #005CC5">-i</span><span style="color: #24292E"> </span><span style="color: #032F62">~/.ssh/HirakeGoma.pem</span><span style="color: #24292E"> </span><span style="color: #005CC5">-L</span><span style="color: #24292E"> </span><span style="color: #032F62">localhost:8931:localhost:8888</span><span style="color: #24292E"> </span><span style="color: #032F62">ec2-user@</span><span style="color: #D73A49">&lt;</span><span style="color: #032F62">IP</span><span style="color: #24292E"> </span><span style="color: #032F62">addres</span><span style="color: #24292E">s</span><span style="color: #D73A49">&gt;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>ポートフォワーディングとは，クライアントマシンの特定のアドレスへの接続を， SSH の暗号化された通信を介して，リモートマシンの特定のアドレスへ転送する，という意味である． このコマンドの <code>-L localhost:8931:localhost:8888</code> は，自分のローカルマシンの <code>localhost:8931</code> へのアクセスを，リモートサーバーの <code>localhost:8888</code> のアドレスに転送せよ，という意味である (<code>:</code> につづく数字は TCP/IP ポートの番号を意味している)． リモートサーバーのポート 8888 には，後述する Jupyter Notebook が起動している． したがって，ローカルマシンの <code>localhost:8931</code> にアクセスすることで，リモートサーバーの Jupyter Notebook にアクセスすることができるのである (<a href="#fig:ssh_port_forwarding">figure_title</a>)． このような SSH による接続方式を<strong>トンネル接続</strong>とよぶ．</p>
<p><img src="./assets/ssh_port_forwarding.png" alt="SSH のポートフォワーディングによる Jupyter Notebook へのアクセス"></p>
<p>ポートフォワーディングのオプションで，ポートの番号 (<code>:8931</code>, <code>:8888</code> など) には 1 から 65535 までの任意の整数を指定できる． しかし，たとえば ポート 22 (SSH) やポート 80 (HTTP) など，いくつかすでに使われているポート番号もあることに注意する． また， Jupyter Notebook はデフォルトではポート 8888 番を使用する． したがって，リモート側のポート番号は，8888 を使うのがよい．</p>
<p>SSH ログインコマンドの <code>&lt;IP address&gt;</code> 部分は自身のインスタンスの IP アドレスを代入することを忘れずに．</p>
<p><strong>本書の提供している Docker を使ってデプロイを実行した人へ</strong></p>
<p>SSH によるログインは， <strong>Docker の外</strong> (すなわちクライアントマシン本体) から行わなければならない． なぜなら，Jupyter を開くウェブブラウザは Docker の外にあるからである．</p>
<p>その際，秘密鍵を Docker の外にもってこなければならない． 手っ取り早い方法は， <code>cat ~/.ssh/HirakeGoma</code> と打って，出力結果をコピーしてホストマシンのファイルに書き込む方法である． あるいは <code>-v</code> オプションをつけて，ファイルシステムをマウントしてもよい (詳しくは <a href="https://docs.docker.com/storage/volumes/" target="_blank" rel="noreferrer">Docker 公式ドキュメンテーション &quot;Use volumes&quot;</a> を参照)．</p>
<p>SSH によるログインができたら，早速， GPU の状態を確認してみよう． 次のコマンドを実行する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">nvidia-smi</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">nvidia-smi</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p><a href="#handson_02_nvidia-smi">figure_title</a> のような出力が得られるはずである． 出力を見ると， Tesla T4 型の GPU が 1 台搭載されていることが確認できる． その他，GPU Driver や CUDA のバージョン， GPU の負荷・メモリー使用率などの情報を確認することができる．</p>
<p><img src="./assets/handson-jupyter/nvidia-smi.png" alt="nvidia-smi の出力"></p>
<h2 id="jupyter-notebook-の起動" tabindex="-1">Jupyter Notebook の起動 <a class="header-anchor" href="#jupyter-notebook-の起動" aria-label="Permalink to &quot;Jupyter Notebook の起動&quot;">&ZeroWidthSpace;</a></h2>
<p><a href="https://jupyter.org/" target="_blank" rel="noreferrer">Jupyter Notebook</a> とは，インタラクティブに Python のプログラムを書いたり実行したりするためのツールである． Jupyter は GUI としてウェブブラウザを介してアクセスする形式をとっており，まるでノートを書くように，プロットやテーブルのデータも美しく表示することができる (<a href="#handson_02_welcome_jupyter">figure_title</a>)． Python に慣れている読者は，きっと一度は使ったことがあるだろう．</p>
<p><img src="./assets/handson-jupyter/welcome_to_jupyter.png" alt="Jupyter Notebook の画面"></p>
<p>このハンズオンでは， Jupyter Notebook を使ってディープラーニングのプログラムをインタラクティブに実行していく． DLAMI には既に Jupyter がインストールされているので，特段の設定なしに使い始めることができる．</p>
<p>早速， Jupyter を起動しよう． SSH でログインした先の EC2 インスタンスで，次のコマンドを実行すればよい．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cd</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">~</span><span style="color: #ADBAC7"> </span><span style="color: #768390"># go to home directory</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">jupyter</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">notebook</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cd</span><span style="color: #24292E"> </span><span style="color: #032F62">~</span><span style="color: #24292E"> </span><span style="color: #6A737D"># go to home directory</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">jupyter</span><span style="color: #24292E"> </span><span style="color: #032F62">notebook</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>このコマンドを実行すると， <a href="#handson_02_jupyter_launch">figure_title</a> のような出力が確認できるだろう． この出力から，Jupyter のサーバーが EC2 インスタンスの <code>localhost:8888</code> というアドレスに起動していることがわかる． また， <code>localhost:8888</code> に続く <code>?token=XXXX</code> は，アクセスに使うための一時的なトークンである．</p>
<p><img src="./assets/handson-jupyter/jupyter_launch.png" alt="Jupyter Notebook サーバーを起動"></p>
<p>Jupyter Notebook を初回に起動するときは，起動に数分程度の時間がかかることがある． ほかの動作も起動直後は遅く，いくつかプログラムを走らせていくうちに俊敏に反応するようになってくる． これは， AWS の GPU 搭載型仮想マシンの運用方法に起因する現象だと考えられる．</p>
<p>先ほど，ポートフォワーディングのオプションをつけて SSH 接続をしているので， Jupyter の起動している <code>localhost:8888</code> には，ローカルマシンの <code>localhost:8931</code> からアクセスすることができる． したがって，ローカルマシンから Jupyter にアクセスするには，ウェブブラウザ (Chrome, FireFox など)から次のアドレスにアクセスすれば良い．</p>
<div class="language- vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #adbac7">http://localhost:8931/?token=XXXX&amp;lt;/programlisting&amp;gt;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292e">http://localhost:8931/?token=XXXX&amp;lt;/programlisting&amp;gt;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p><code>?token=XXXX</code> の部分は，上で Jupyter を起動したときに発行されたトークンの値に置き換える．</p>
<p>上のアドレスにアクセスすると， Jupyter のホーム画面が起動するはずである (<a href="#handson_02_jupyter_home">figure_title</a>)． これで， Jupyter の準備が整った！</p>
<p><img src="./assets/handson-jupyter/jupyter_home.png" alt="Jupyter ホーム画面"></p>
<p>Jupyter Notebook の使い方 (超簡易版)</p>
<ul>
<li>
<p><code>Shift</code> + <code>Enter</code>: セルを実行</p>
</li>
<li>
<p><code>Esc</code>: <strong>Command mode</strong> に遷移</p>
</li>
<li>
<p>メニューバーの &quot;+&quot; ボタン または Command mode で <code>A</code> ⇒ セルを追加</p>
</li>
<li>
<p>メニューバーの &quot;ハサミ&quot; ボタン または Command mode で <code>X</code> ⇒ セルを削除</p>
</li>
</ul>
<p>ショートカットの一覧などは <a href="https://towardsdatascience.com/jypyter-notebook-shortcuts-bf0101a98330" target="_blank" rel="noreferrer">Ventsislav Yordanov 氏によるブログ</a> が参考になる．</p>
<h2 id="pytorch-はじめの一歩" tabindex="-1">PyTorch はじめの一歩 <a class="header-anchor" href="#pytorch-はじめの一歩" aria-label="Permalink to &quot;PyTorch はじめの一歩&quot;">&ZeroWidthSpace;</a></h2>
<p><a href="https://pytorch.org/" target="_blank" rel="noreferrer">PyTorch</a> は Facebook AI Research LAB (FAIR) が中心となって開発を進めている，オープンソースのディープラーニングのライブラリである． PyTorch は 有名な例で言えば Tesla 社の自動運転プロジェクトなどで使用されており，執筆時点において最も人気の高いディープラーニングライブラリの一つである． 本ハンズオンでは， PyTorch を使ってディープラーニングの実践を行う．</p>
<p>PyTorch の歴史のお話</p>
<p>Facebook は PyTorch のほかに Caffe2 とよばれるディープラーニングのフレームワークを開発していた (初代 Caffe は UC Berkley の博士課程学生だった Yangqing Jia によって創られた)． Caffe2 は 2018 年に PyTorch プロジェクトに合併された．</p>
<p>また，2019 年 12 月，日本の Preferred Networks 社が開発していた <a href="https://chainer.org/" target="_blank" rel="noreferrer">Chainer</a> も開発を終了し，PyTorch の開発チームと協業していくことが発表された (詳しくは <a href="https://chainer.org/announcement/2019/12/05/released-v7-ja.html" target="_blank" rel="noreferrer">プレスリリース</a> を参照)． PyTorch には，開発統合前から Chainer からインスパイアされた API がいくつもあり， Chainer の DNA は今も PyTorch に引き継がれているのである…!</p>
<p>本格的なディープラーニングの計算に移る前に， PyTorch ライブラリを使って， GPU で計算を行うとはどういうものか，その入り口に触れてみよう．</p>
<p>まずは，新しいノートブックを作成する． Jupyter のホーム画面の右上の &quot;New&quot; を押し，&quot;conda_pytorch_p36&quot; という環境を選択したうえで，新規ノートブックを作成する (<a href="#handson_02_jupyeter_new">figure_title</a>)． &quot;conda_pytorch_p36&quot; の仮想環境には， PyTorch がインストール済みである．</p>
<p><img src="./assets/handson-jupyter/jupyter_new.png" alt="新規ノートブックの作成． &quot;conda_pytorch_p36&quot; の環境を選択する．"></p>
<p>ここでは，次のようなプログラムを書いて，実行していく． (<a href="#handson_02_jupyeter_pytorch">figure_title</a>)．</p>
<p><img src="./assets/handson-jupyter/jupyter_pytorch.png" alt="PyTorch始めの一歩"></p>
<p>まずは， PyTorch をインポートする．さらに， GPU が使える環境にあるか，確認する．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> torch</span></span>
<span class="line"><span style="color: #6CB6FF">print</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;Is CUDA ready?&quot;</span><span style="color: #ADBAC7">, torch.cuda.is_available())</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> torch</span></span>
<span class="line"><span style="color: #005CC5">print</span><span style="color: #24292E">(</span><span style="color: #032F62">&quot;Is CUDA ready?&quot;</span><span style="color: #24292E">, torch.cuda.is_available())</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>出力:</p>
<p>Is CUDA ready? True&lt;/programlisting&gt;</p>
<p>次に，3x3 のランダムな行列を <strong>CPU</strong> 上に作ってみよう．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">x </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> torch.rand(</span><span style="color: #6CB6FF">3</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">3</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #6CB6FF">print</span><span style="color: #ADBAC7">(x)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">x </span><span style="color: #D73A49">=</span><span style="color: #24292E"> torch.rand(</span><span style="color: #005CC5">3</span><span style="color: #24292E">,</span><span style="color: #005CC5">3</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #005CC5">print</span><span style="color: #24292E">(x)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>出力:</p>
<p>tensor([[0.6896, 0.2428, 0.3269], [0.0533, 0.3594, 0.9499], [0.9764, 0.5881, 0.0203]])&lt;/programlisting&gt;</p>
<p>次に，行列を <strong>GPU</strong> 上に作成する．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">y </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> torch.ones_like(x, </span><span style="color: #F69D50">device</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;cuda&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">x </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> x.to(</span><span style="color: #96D0FF">&quot;cuda&quot;</span><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">y </span><span style="color: #D73A49">=</span><span style="color: #24292E"> torch.ones_like(x, </span><span style="color: #E36209">device</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;cuda&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">x </span><span style="color: #D73A49">=</span><span style="color: #24292E"> x.to(</span><span style="color: #032F62">&quot;cuda&quot;</span><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>そして，行列 <code>x</code> と <code>y</code> の加算を，<strong>GPU 上で実行する</strong>．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">z </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> x </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> y</span></span>
<span class="line"><span style="color: #6CB6FF">print</span><span style="color: #ADBAC7">(z)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">z </span><span style="color: #D73A49">=</span><span style="color: #24292E"> x </span><span style="color: #D73A49">+</span><span style="color: #24292E"> y</span></span>
<span class="line"><span style="color: #005CC5">print</span><span style="color: #24292E">(z)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>出力:</p>
<p>tensor([[1.6896, 1.2428, 1.3269], [1.0533, 1.3594, 1.9499], [1.9764, 1.5881, 1.0203]], device='cuda:0')&lt;/programlisting&gt;</p>
<p>最後に， GPU 上にある行列を， CPU に戻す．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">z </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> z.to(</span><span style="color: #96D0FF">&quot;cpu&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #6CB6FF">print</span><span style="color: #ADBAC7">(z)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">z </span><span style="color: #D73A49">=</span><span style="color: #24292E"> z.to(</span><span style="color: #032F62">&quot;cpu&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #005CC5">print</span><span style="color: #24292E">(z)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>出力:</p>
<p>tensor([[1.6896, 1.2428, 1.3269], [1.0533, 1.3594, 1.9499], [1.9764, 1.5881, 1.0203]])&lt;/programlisting&gt;</p>
<p>以上の例は， GPU を使った計算の初歩の初歩であるが，雰囲気はつかめただろうか？ CPU と GPU で明示的にデータを交換するのが肝である． この例はたった 3x3 の行列の足し算なので， GPU を使う意味はまったくないが，これが数千，数万のサイズの行列になったとき， GPU は格段の威力を発揮する．</p>
<p>完成した Jupyter Notebook は <a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/mnist/pytorch/pytorch_get_started.ipynb" target="_blank" rel="noreferrer">/handson/mnist/pytorch/pytorch_get_started.ipynb</a> にある． Jupyter の画面右上の &quot;Upload&quot; からこのファイルをアップロードして，コードを走らせることが可能である．</p>
<p>しなしながら，勉強のときにはコードはすべて自分の手で打つことが，記憶に残りやすくより効果的である，というのが筆者の意見である．</p>
<p>実際にベンチマークを取ることで GPU と CPU の速度を比較をしてみよう． 実行時間を計測するツールとして， Jupyter の提供する <a href="https://ipython.readthedocs.io/en/stable/interactive/magics.html" target="_blank" rel="noreferrer">%time</a> マジックコマンドを利用する．</p>
<p>まずは CPU を使用して，10000x10000 の行列の行列積を計算した場合の速度を測ってみよう． 先ほどのノートブックの続きに，次のコードを実行する．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">s </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">10000</span></span>
<span class="line"><span style="color: #ADBAC7">device </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;cpu&quot;</span></span>
<span class="line"><span style="color: #ADBAC7">x </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> torch.rand(s, s, </span><span style="color: #F69D50">device</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">device, </span><span style="color: #F69D50">dtype</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">torch.float32)</span></span>
<span class="line"><span style="color: #ADBAC7">y </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> torch.rand(s, s, </span><span style="color: #F69D50">device</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">device, </span><span style="color: #F69D50">dtype</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">torch.float32)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F47067">%</span><span style="color: #ADBAC7">time z </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> torch.matmul(x,y)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">s </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #005CC5">10000</span></span>
<span class="line"><span style="color: #24292E">device </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;cpu&quot;</span></span>
<span class="line"><span style="color: #24292E">x </span><span style="color: #D73A49">=</span><span style="color: #24292E"> torch.rand(s, s, </span><span style="color: #E36209">device</span><span style="color: #D73A49">=</span><span style="color: #24292E">device, </span><span style="color: #E36209">dtype</span><span style="color: #D73A49">=</span><span style="color: #24292E">torch.float32)</span></span>
<span class="line"><span style="color: #24292E">y </span><span style="color: #D73A49">=</span><span style="color: #24292E"> torch.rand(s, s, </span><span style="color: #E36209">device</span><span style="color: #D73A49">=</span><span style="color: #24292E">device, </span><span style="color: #E36209">dtype</span><span style="color: #D73A49">=</span><span style="color: #24292E">torch.float32)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D73A49">%</span><span style="color: #24292E">time z </span><span style="color: #D73A49">=</span><span style="color: #24292E"> torch.matmul(x,y)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br></div></div><p>出力は以下のようなものが得られるだろう． これは，行列積の計算に実時間で 5.8 秒かかったことを意味する (実行のたびに計測される時間はばらつくことに留意)．</p>
<p>CPU times: user 11.5 s, sys: 140 ms, total: 11.6 s Wall time: 5.8 s&lt;/programlisting&gt;</p>
<p>次に， GPU を使用して，同じ演算を行った場合の速度を計測しよう．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">s </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">10000</span></span>
<span class="line"><span style="color: #ADBAC7">device </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;cuda&quot;</span></span>
<span class="line"><span style="color: #ADBAC7">x </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> torch.rand(s, s, </span><span style="color: #F69D50">device</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">device, </span><span style="color: #F69D50">dtype</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">torch.float32)</span></span>
<span class="line"><span style="color: #ADBAC7">y </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> torch.rand(s, s, </span><span style="color: #F69D50">device</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">device, </span><span style="color: #F69D50">dtype</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">torch.float32)</span></span>
<span class="line"><span style="color: #ADBAC7">torch.cuda.synchronize()</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F47067">%</span><span style="color: #ADBAC7">time z </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> torch.matmul(x,y); torch.cuda.synchronize()</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">s </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #005CC5">10000</span></span>
<span class="line"><span style="color: #24292E">device </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;cuda&quot;</span></span>
<span class="line"><span style="color: #24292E">x </span><span style="color: #D73A49">=</span><span style="color: #24292E"> torch.rand(s, s, </span><span style="color: #E36209">device</span><span style="color: #D73A49">=</span><span style="color: #24292E">device, </span><span style="color: #E36209">dtype</span><span style="color: #D73A49">=</span><span style="color: #24292E">torch.float32)</span></span>
<span class="line"><span style="color: #24292E">y </span><span style="color: #D73A49">=</span><span style="color: #24292E"> torch.rand(s, s, </span><span style="color: #E36209">device</span><span style="color: #D73A49">=</span><span style="color: #24292E">device, </span><span style="color: #E36209">dtype</span><span style="color: #D73A49">=</span><span style="color: #24292E">torch.float32)</span></span>
<span class="line"><span style="color: #24292E">torch.cuda.synchronize()</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D73A49">%</span><span style="color: #24292E">time z </span><span style="color: #D73A49">=</span><span style="color: #24292E"> torch.matmul(x,y); torch.cuda.synchronize()</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br></div></div><p>出力は以下のようなものになるだろう． GPU では 553 ミリ秒 で計算を終えることができた！</p>
<p>CPU times: user 334 ms, sys: 220 ms, total: 554 ms Wall time: 553 ms&lt;/programlisting&gt;</p>
<p>PyTorch において， GPU での演算は asynchronous (非同期) で実行される． その理由で，上のベンチマークコードでは， <code>torch.cuda.synchronize()</code> というステートメントを埋め込んである．</p>
<p>このベンチマークでは， <code>dtype=torch.float32</code> と指定することで，32bit の浮動小数点型を用いている． ディープラーニングの学習および推論の計算には，32bit 型，場合によっては 16bit 型が使われるのが一般的である． これの主な理由として，教師データやミニバッチに起因するノイズが，浮動小数点の精度よりも大きいことがあげられる． 32bit/16bit を採用することで，メモリー消費を抑えたり，計算速度の向上が達成できる．</p>
<p>上記のベンチマークから，GPU を用いることで，<strong>約 10 倍のスピードアップ</strong>を実現することができた． スピードアップの性能は，演算の種類や行列のサイズに依存する． 行列積は，そのなかでも最も速度向上が見込まれる演算の一つである．</p>
<h2 id="実践ディープラーニング-mnist-手書き数字認識タスク" tabindex="-1">実践ディープラーニング! MNIST 手書き数字認識タスク <a class="header-anchor" href="#実践ディープラーニング-mnist-手書き数字認識タスク" aria-label="Permalink to &quot;実践ディープラーニング! MNIST 手書き数字認識タスク&quot;">&ZeroWidthSpace;</a></h2>
<p>ここまで，AWS 上でディープラーニングの計算をするための概念や前提知識をながながと説明してきたが，ついにここからディープラーニングの計算を実際に走らせてみる．</p>
<p>ここでは，機械学習のタスクで最も初歩的かつ有名な <strong>MNIST データセットを使った数字認識</strong>を扱う (<a href="#handson_02_mnist_examples">figure_title</a>)． これは，0 から 9 までの手書きの数字の画像が与えられ，その数字が何の数字なのかを当てる，というシンプルなタスクである．</p>
<p><img src="./assets/handson-jupyter/mnist_examples.png" alt="MNIST 手書き数字データセット"></p>
<p>今回は， MNIST 文字認識タスクを，<strong>畳み込みニューラルネットワーク (Convolutional Neural Network; CNN)</strong> を使って解く． ソースコードは <a href="https://github.com/tomomano/learn-aws-by-coding-source-code/tree/main/handson/mnist/pytorch" target="_blank" rel="noreferrer">/handson/minist/pytorch/</a> にある <code>mnist.ipynb</code> と <code>simple_mnist.py</code> である． なお，このプログラムは， <a href="https://github.com/pytorch/examples/tree/master/mnist" target="_blank" rel="noreferrer">PyTorch の公式 Example Project 集</a> を参考に，多少の改変を行ったものである．</p>
<p>まずは，カスタムのクラスや関数が定義された <code>simple_mnist.py</code> をアップロードしよう (<a href="#handson_02_jupyter_upload">figure_title</a>)． 画面右上の &quot;Upload&quot; ボタンをクリックし，ファイルを選択することでアップロードができる． この Python プログラムの中に，CNN のモデルや，学習の各イテレーションにおけるパラメータの更新などが記述されている． 今回はこの中身を説明することはしないが，興味のある読者は自身でソースコードを読んでみるとよい．</p>
<p><img src="./assets/handson-jupyter/jupyter_upload.png" alt=" をアップロード"></p>
<p><code>simple_mnist.py</code> をアップロードできたら，次に新しい notebook を作成しよう． &quot;conda_pytorch_p36&quot; の環境を選択することを忘れずに．</p>
<p>新しいノートブックが起動したら，まずは必要なライブラリをインポートしよう．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> torch</span></span>
<span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> torch.optim </span><span style="color: #F47067">as</span><span style="color: #ADBAC7"> optim</span></span>
<span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> torchvision</span></span>
<span class="line"><span style="color: #F47067">from</span><span style="color: #ADBAC7"> torchvision </span><span style="color: #F47067">import</span><span style="color: #ADBAC7"> datasets, transforms</span></span>
<span class="line"><span style="color: #F47067">from</span><span style="color: #ADBAC7"> matplotlib </span><span style="color: #F47067">import</span><span style="color: #ADBAC7"> pyplot </span><span style="color: #F47067">as</span><span style="color: #ADBAC7"> plt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># custom functions and classes</span></span>
<span class="line"><span style="color: #F47067">from</span><span style="color: #ADBAC7"> simple_mnist </span><span style="color: #F47067">import</span><span style="color: #ADBAC7"> Model, train, evaluate</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> torch</span></span>
<span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> torch.optim </span><span style="color: #D73A49">as</span><span style="color: #24292E"> optim</span></span>
<span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> torchvision</span></span>
<span class="line"><span style="color: #D73A49">from</span><span style="color: #24292E"> torchvision </span><span style="color: #D73A49">import</span><span style="color: #24292E"> datasets, transforms</span></span>
<span class="line"><span style="color: #D73A49">from</span><span style="color: #24292E"> matplotlib </span><span style="color: #D73A49">import</span><span style="color: #24292E"> pyplot </span><span style="color: #D73A49">as</span><span style="color: #24292E"> plt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># custom functions and classes</span></span>
<span class="line"><span style="color: #D73A49">from</span><span style="color: #24292E"> simple_mnist </span><span style="color: #D73A49">import</span><span style="color: #24292E"> Model, train, evaluate</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br></div></div><p><a href="https://pytorch.org/docs/stable/torchvision/index.html" target="_blank" rel="noreferrer">torchvision</a> パッケージには，MNIST データセットをロードするなどの便利な関数が含まれている． また，今回のハンズオンで使うカスタムのクラス・関数 (<code>Model</code>, <code>train</code>, <code>evaluate</code>) のインポートを行っている．</p>
<p>次に，MNIST テストデータをダウンロードしよう． 同時に，画像データの輝度の正規化も行っている．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">transf </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> transforms.Compose([transforms.ToTensor(),</span></span>
<span class="line"><span style="color: #ADBAC7">                             transforms.Normalize((</span><span style="color: #6CB6FF">0.1307</span><span style="color: #ADBAC7">,), (</span><span style="color: #6CB6FF">0.3081</span><span style="color: #ADBAC7">,))])</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">trainset </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> datasets.MNIST(</span><span style="color: #F69D50">root</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&#39;./data&#39;</span><span style="color: #ADBAC7">, </span><span style="color: #F69D50">train</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">True</span><span style="color: #ADBAC7">, </span><span style="color: #F69D50">download</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">True</span><span style="color: #ADBAC7">, </span><span style="color: #F69D50">transform</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">transf)</span></span>
<span class="line"><span style="color: #ADBAC7">trainloader </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> torch.utils.data.DataLoader(trainset, </span><span style="color: #F69D50">batch_size</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">64</span><span style="color: #ADBAC7">, </span><span style="color: #F69D50">shuffle</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">True</span><span style="color: #ADBAC7">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">testset </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> datasets.MNIST(</span><span style="color: #F69D50">root</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&#39;./data&#39;</span><span style="color: #ADBAC7">, </span><span style="color: #F69D50">train</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">False</span><span style="color: #ADBAC7">, </span><span style="color: #F69D50">download</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">True</span><span style="color: #ADBAC7">, </span><span style="color: #F69D50">transform</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">transf)</span></span>
<span class="line"><span style="color: #ADBAC7">testloader </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> torch.utils.data.DataLoader(testset, </span><span style="color: #F69D50">batch_size</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">1000</span><span style="color: #ADBAC7">, </span><span style="color: #F69D50">shuffle</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">True</span><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">transf </span><span style="color: #D73A49">=</span><span style="color: #24292E"> transforms.Compose([transforms.ToTensor(),</span></span>
<span class="line"><span style="color: #24292E">                             transforms.Normalize((</span><span style="color: #005CC5">0.1307</span><span style="color: #24292E">,), (</span><span style="color: #005CC5">0.3081</span><span style="color: #24292E">,))])</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">trainset </span><span style="color: #D73A49">=</span><span style="color: #24292E"> datasets.MNIST(</span><span style="color: #E36209">root</span><span style="color: #D73A49">=</span><span style="color: #032F62">&#39;./data&#39;</span><span style="color: #24292E">, </span><span style="color: #E36209">train</span><span style="color: #D73A49">=</span><span style="color: #005CC5">True</span><span style="color: #24292E">, </span><span style="color: #E36209">download</span><span style="color: #D73A49">=</span><span style="color: #005CC5">True</span><span style="color: #24292E">, </span><span style="color: #E36209">transform</span><span style="color: #D73A49">=</span><span style="color: #24292E">transf)</span></span>
<span class="line"><span style="color: #24292E">trainloader </span><span style="color: #D73A49">=</span><span style="color: #24292E"> torch.utils.data.DataLoader(trainset, </span><span style="color: #E36209">batch_size</span><span style="color: #D73A49">=</span><span style="color: #005CC5">64</span><span style="color: #24292E">, </span><span style="color: #E36209">shuffle</span><span style="color: #D73A49">=</span><span style="color: #005CC5">True</span><span style="color: #24292E">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">testset </span><span style="color: #D73A49">=</span><span style="color: #24292E"> datasets.MNIST(</span><span style="color: #E36209">root</span><span style="color: #D73A49">=</span><span style="color: #032F62">&#39;./data&#39;</span><span style="color: #24292E">, </span><span style="color: #E36209">train</span><span style="color: #D73A49">=</span><span style="color: #005CC5">False</span><span style="color: #24292E">, </span><span style="color: #E36209">download</span><span style="color: #D73A49">=</span><span style="color: #005CC5">True</span><span style="color: #24292E">, </span><span style="color: #E36209">transform</span><span style="color: #D73A49">=</span><span style="color: #24292E">transf)</span></span>
<span class="line"><span style="color: #24292E">testloader </span><span style="color: #D73A49">=</span><span style="color: #24292E"> torch.utils.data.DataLoader(testset, </span><span style="color: #E36209">batch_size</span><span style="color: #D73A49">=</span><span style="color: #005CC5">1000</span><span style="color: #24292E">, </span><span style="color: #E36209">shuffle</span><span style="color: #D73A49">=</span><span style="color: #005CC5">True</span><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br></div></div><p>今回扱う MNIST データは 28x28 ピクセルの正方形の画像(モノクロ)と，それぞれのラベル(0 - 9 の数字)の組で構成されている． いくつかのデータを抽出して，可視化してみよう． <a href="#handson_02_mnist_ground_truth">figure_title</a> のような出力が得られるはずである．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">examples </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">iter</span><span style="color: #ADBAC7">(testloader)</span></span>
<span class="line"><span style="color: #ADBAC7">example_data, example_targets </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> examples.next()</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6CB6FF">print</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;Example data size:&quot;</span><span style="color: #ADBAC7">, example_data.shape)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">fig </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> plt.figure(</span><span style="color: #F69D50">figsize</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">10</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">4</span><span style="color: #ADBAC7">))</span></span>
<span class="line"><span style="color: #F47067">for</span><span style="color: #ADBAC7"> i </span><span style="color: #F47067">in</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">range</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">10</span><span style="color: #ADBAC7">):</span></span>
<span class="line"><span style="color: #ADBAC7">    plt.subplot(</span><span style="color: #6CB6FF">2</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">5</span><span style="color: #ADBAC7">,i</span><span style="color: #F47067">+</span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">    plt.tight_layout()</span></span>
<span class="line"><span style="color: #ADBAC7">    plt.imshow(example_data[i][</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">], </span><span style="color: #F69D50">cmap</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&#39;gray&#39;</span><span style="color: #ADBAC7">, </span><span style="color: #F69D50">interpolation</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&#39;none&#39;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">    plt.title(</span><span style="color: #96D0FF">&quot;Ground Truth: </span><span style="color: #F47067">{}</span><span style="color: #96D0FF">&quot;</span><span style="color: #ADBAC7">.format(example_targets[i]))</span></span>
<span class="line"><span style="color: #ADBAC7">    plt.xticks([])</span></span>
<span class="line"><span style="color: #ADBAC7">    plt.yticks([])</span></span>
<span class="line"><span style="color: #ADBAC7">plt.show()</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">examples </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #005CC5">iter</span><span style="color: #24292E">(testloader)</span></span>
<span class="line"><span style="color: #24292E">example_data, example_targets </span><span style="color: #D73A49">=</span><span style="color: #24292E"> examples.next()</span></span>
<span class="line"></span>
<span class="line"><span style="color: #005CC5">print</span><span style="color: #24292E">(</span><span style="color: #032F62">&quot;Example data size:&quot;</span><span style="color: #24292E">, example_data.shape)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">fig </span><span style="color: #D73A49">=</span><span style="color: #24292E"> plt.figure(</span><span style="color: #E36209">figsize</span><span style="color: #D73A49">=</span><span style="color: #24292E">(</span><span style="color: #005CC5">10</span><span style="color: #24292E">,</span><span style="color: #005CC5">4</span><span style="color: #24292E">))</span></span>
<span class="line"><span style="color: #D73A49">for</span><span style="color: #24292E"> i </span><span style="color: #D73A49">in</span><span style="color: #24292E"> </span><span style="color: #005CC5">range</span><span style="color: #24292E">(</span><span style="color: #005CC5">10</span><span style="color: #24292E">):</span></span>
<span class="line"><span style="color: #24292E">    plt.subplot(</span><span style="color: #005CC5">2</span><span style="color: #24292E">,</span><span style="color: #005CC5">5</span><span style="color: #24292E">,i</span><span style="color: #D73A49">+</span><span style="color: #005CC5">1</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">    plt.tight_layout()</span></span>
<span class="line"><span style="color: #24292E">    plt.imshow(example_data[i][</span><span style="color: #005CC5">0</span><span style="color: #24292E">], </span><span style="color: #E36209">cmap</span><span style="color: #D73A49">=</span><span style="color: #032F62">&#39;gray&#39;</span><span style="color: #24292E">, </span><span style="color: #E36209">interpolation</span><span style="color: #D73A49">=</span><span style="color: #032F62">&#39;none&#39;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">    plt.title(</span><span style="color: #032F62">&quot;Ground Truth: </span><span style="color: #005CC5">{}</span><span style="color: #032F62">&quot;</span><span style="color: #24292E">.format(example_targets[i]))</span></span>
<span class="line"><span style="color: #24292E">    plt.xticks([])</span></span>
<span class="line"><span style="color: #24292E">    plt.yticks([])</span></span>
<span class="line"><span style="color: #24292E">plt.show()</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br></div></div><p><img src="./assets/handson-jupyter/mnist_ground_truth.png" alt="MNIST の手書き数字画像とその教師ラベル"></p>
<p>次に， CNN のモデルを定義する．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">model </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> Model()</span></span>
<span class="line"><span style="color: #ADBAC7">model.to(</span><span style="color: #96D0FF">&quot;cuda&quot;</span><span style="color: #ADBAC7">) </span><span style="color: #768390"># load to GPU</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">model </span><span style="color: #D73A49">=</span><span style="color: #24292E"> Model()</span></span>
<span class="line"><span style="color: #24292E">model.to(</span><span style="color: #032F62">&quot;cuda&quot;</span><span style="color: #24292E">) </span><span style="color: #6A737D"># load to GPU</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>今回使う <code>Model</code> は <code>simple_mnist.py</code> の中で定義されている． このモデルは，<a href="#handson_02_cnn_architecture">figure_title</a> に示したような，２層の畳み込み層と 2 層の全結合層からなるネットワークである． 出力層 (output layer) には Softmax 関数を使用し，損失関数 (Loss function) には 負の対数尤度関数 (Negative log likelyhood; NLL) を使用している．</p>
<p><img src="./assets/handson-jupyter/cnn_architecture.png" alt="本ハンズオンで使用するニューラルネットの構造．"></p>
<p>続いて， CNN のパラメータを更新する最適化アルゴリズムを定義する． ここでは， <strong>確率的勾配降下法 (Stochastic Gradient Descent; SGD)</strong> を使用している．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">optimizer </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> optim.SGD(model.parameters(), </span><span style="color: #F69D50">lr</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">0.01</span><span style="color: #ADBAC7">, </span><span style="color: #F69D50">momentum</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">0.5</span><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">optimizer </span><span style="color: #D73A49">=</span><span style="color: #24292E"> optim.SGD(model.parameters(), </span><span style="color: #E36209">lr</span><span style="color: #D73A49">=</span><span style="color: #005CC5">0.01</span><span style="color: #24292E">, </span><span style="color: #E36209">momentum</span><span style="color: #D73A49">=</span><span style="color: #005CC5">0.5</span><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>これで，準備が整った． CNN の学習ループを開始しよう!</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">train_losses </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> []</span></span>
<span class="line"><span style="color: #F47067">for</span><span style="color: #ADBAC7"> epoch </span><span style="color: #F47067">in</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">range</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">5</span><span style="color: #ADBAC7">):</span></span>
<span class="line"><span style="color: #ADBAC7">    losses </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> train(model, trainloader, optimizer, epoch)</span></span>
<span class="line"><span style="color: #ADBAC7">    train_losses </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> train_losses </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> losses</span></span>
<span class="line"><span style="color: #ADBAC7">    test_loss, test_accuracy </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> evaluate(model, testloader)</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">print</span><span style="color: #ADBAC7">(</span><span style="color: #F47067">f</span><span style="color: #96D0FF">&quot;</span><span style="color: #F47067">\n</span><span style="color: #96D0FF">Test set: Average loss: </span><span style="color: #F47067">{</span><span style="color: #ADBAC7">test_loss</span><span style="color: #F47067">:.4f}</span><span style="color: #96D0FF">, Accuracy: </span><span style="color: #F47067">{</span><span style="color: #ADBAC7">test_accuracy</span><span style="color: #F47067">:.1f}</span><span style="color: #96D0FF">%</span><span style="color: #F47067">\n</span><span style="color: #96D0FF">&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">plt.figure(</span><span style="color: #F69D50">figsize</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">7</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">5</span><span style="color: #ADBAC7">))</span></span>
<span class="line"><span style="color: #ADBAC7">plt.plot(train_losses)</span></span>
<span class="line"><span style="color: #ADBAC7">plt.xlabel(</span><span style="color: #96D0FF">&quot;Iterations&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">plt.ylabel(</span><span style="color: #96D0FF">&quot;Train loss&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">plt.show()</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">train_losses </span><span style="color: #D73A49">=</span><span style="color: #24292E"> []</span></span>
<span class="line"><span style="color: #D73A49">for</span><span style="color: #24292E"> epoch </span><span style="color: #D73A49">in</span><span style="color: #24292E"> </span><span style="color: #005CC5">range</span><span style="color: #24292E">(</span><span style="color: #005CC5">5</span><span style="color: #24292E">):</span></span>
<span class="line"><span style="color: #24292E">    losses </span><span style="color: #D73A49">=</span><span style="color: #24292E"> train(model, trainloader, optimizer, epoch)</span></span>
<span class="line"><span style="color: #24292E">    train_losses </span><span style="color: #D73A49">=</span><span style="color: #24292E"> train_losses </span><span style="color: #D73A49">+</span><span style="color: #24292E"> losses</span></span>
<span class="line"><span style="color: #24292E">    test_loss, test_accuracy </span><span style="color: #D73A49">=</span><span style="color: #24292E"> evaluate(model, testloader)</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">print</span><span style="color: #24292E">(</span><span style="color: #D73A49">f</span><span style="color: #032F62">&quot;</span><span style="color: #005CC5">\n</span><span style="color: #032F62">Test set: Average loss: </span><span style="color: #005CC5">{</span><span style="color: #24292E">test_loss</span><span style="color: #D73A49">:.4f</span><span style="color: #005CC5">}</span><span style="color: #032F62">, Accuracy: </span><span style="color: #005CC5">{</span><span style="color: #24292E">test_accuracy</span><span style="color: #D73A49">:.1f</span><span style="color: #005CC5">}</span><span style="color: #032F62">%</span><span style="color: #005CC5">\n</span><span style="color: #032F62">&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">plt.figure(</span><span style="color: #E36209">figsize</span><span style="color: #D73A49">=</span><span style="color: #24292E">(</span><span style="color: #005CC5">7</span><span style="color: #24292E">,</span><span style="color: #005CC5">5</span><span style="color: #24292E">))</span></span>
<span class="line"><span style="color: #24292E">plt.plot(train_losses)</span></span>
<span class="line"><span style="color: #24292E">plt.xlabel(</span><span style="color: #032F62">&quot;Iterations&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">plt.ylabel(</span><span style="color: #032F62">&quot;Train loss&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">plt.show()</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br></div></div><p>ここでは 5 エポック分の学習を行っている． GPU を使えば，これくらいの計算であれば 1 分程度で完了するだろう．</p>
<p>出力として， <a href="#handson_02_train_loss">figure_title</a> のようなプロットが得られるはずである． イテレーションを重ねるにつれて，損失関数 (Loss function) の値が減少している (=精度が向上している) ことがわかる．</p>
<p><img src="./assets/handson-jupyter/train_loss.png" alt="学習の進行に対する Train loss の変化"></p>
<p>出力にはテキスト形式で各エポック終了後のテストデータに対する精度も表示されている． 最終的には 98% 以上の極めて高い精度を実現できていることが確認できるだろう (<a href="#handson_02_mnist_final_score">figure_title</a>)．</p>
<p><img src="./assets/handson-jupyter/mnist_final_score.png" alt="学習したCNNのテストデータに対するスコア (5エポック後)"></p>
<p>学習した CNN の推論結果を可視化してみよう． 次のコードを実行することで， <a href="#handson_02_mnist_mnist_prediction">figure_title</a> のような出力が得られるだろう． この図で，下段右から二番目は，&quot;1&quot;に近い見た目をしているが，きちんと&quot;9&quot;と推論できている． なかなか賢い CNN を作り出すことができたようだ！</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">model.eval()</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F47067">with</span><span style="color: #ADBAC7"> torch.no_grad():</span></span>
<span class="line"><span style="color: #ADBAC7">    output </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> model(example_data.to(</span><span style="color: #96D0FF">&quot;cuda&quot;</span><span style="color: #ADBAC7">))</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">fig </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> plt.figure(</span><span style="color: #F69D50">figsize</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">10</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">4</span><span style="color: #ADBAC7">))</span></span>
<span class="line"><span style="color: #F47067">for</span><span style="color: #ADBAC7"> i </span><span style="color: #F47067">in</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">range</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">10</span><span style="color: #ADBAC7">):</span></span>
<span class="line"><span style="color: #ADBAC7">    plt.subplot(</span><span style="color: #6CB6FF">2</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">5</span><span style="color: #ADBAC7">,i</span><span style="color: #F47067">+</span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">    plt.tight_layout()</span></span>
<span class="line"><span style="color: #ADBAC7">    plt.imshow(example_data[i][</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">], </span><span style="color: #F69D50">cmap</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&#39;gray&#39;</span><span style="color: #ADBAC7">, </span><span style="color: #F69D50">interpolation</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&#39;none&#39;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">    plt.title(</span><span style="color: #96D0FF">&quot;Prediction: </span><span style="color: #F47067">{}</span><span style="color: #96D0FF">&quot;</span><span style="color: #ADBAC7">.format(output.data.max(</span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">, </span><span style="color: #F69D50">keepdim</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">True</span><span style="color: #ADBAC7">)[</span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">][i].item()))</span></span>
<span class="line"><span style="color: #ADBAC7">    plt.xticks([])</span></span>
<span class="line"><span style="color: #ADBAC7">    plt.yticks([])</span></span>
<span class="line"><span style="color: #ADBAC7">plt.show()</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">model.eval()</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D73A49">with</span><span style="color: #24292E"> torch.no_grad():</span></span>
<span class="line"><span style="color: #24292E">    output </span><span style="color: #D73A49">=</span><span style="color: #24292E"> model(example_data.to(</span><span style="color: #032F62">&quot;cuda&quot;</span><span style="color: #24292E">))</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">fig </span><span style="color: #D73A49">=</span><span style="color: #24292E"> plt.figure(</span><span style="color: #E36209">figsize</span><span style="color: #D73A49">=</span><span style="color: #24292E">(</span><span style="color: #005CC5">10</span><span style="color: #24292E">,</span><span style="color: #005CC5">4</span><span style="color: #24292E">))</span></span>
<span class="line"><span style="color: #D73A49">for</span><span style="color: #24292E"> i </span><span style="color: #D73A49">in</span><span style="color: #24292E"> </span><span style="color: #005CC5">range</span><span style="color: #24292E">(</span><span style="color: #005CC5">10</span><span style="color: #24292E">):</span></span>
<span class="line"><span style="color: #24292E">    plt.subplot(</span><span style="color: #005CC5">2</span><span style="color: #24292E">,</span><span style="color: #005CC5">5</span><span style="color: #24292E">,i</span><span style="color: #D73A49">+</span><span style="color: #005CC5">1</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">    plt.tight_layout()</span></span>
<span class="line"><span style="color: #24292E">    plt.imshow(example_data[i][</span><span style="color: #005CC5">0</span><span style="color: #24292E">], </span><span style="color: #E36209">cmap</span><span style="color: #D73A49">=</span><span style="color: #032F62">&#39;gray&#39;</span><span style="color: #24292E">, </span><span style="color: #E36209">interpolation</span><span style="color: #D73A49">=</span><span style="color: #032F62">&#39;none&#39;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">    plt.title(</span><span style="color: #032F62">&quot;Prediction: </span><span style="color: #005CC5">{}</span><span style="color: #032F62">&quot;</span><span style="color: #24292E">.format(output.data.max(</span><span style="color: #005CC5">1</span><span style="color: #24292E">, </span><span style="color: #E36209">keepdim</span><span style="color: #D73A49">=</span><span style="color: #005CC5">True</span><span style="color: #24292E">)[</span><span style="color: #005CC5">1</span><span style="color: #24292E">][i].item()))</span></span>
<span class="line"><span style="color: #24292E">    plt.xticks([])</span></span>
<span class="line"><span style="color: #24292E">    plt.yticks([])</span></span>
<span class="line"><span style="color: #24292E">plt.show()</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br></div></div><p><img src="./assets/handson-jupyter/mnist_prediction.png" alt="学習した CNN による，MNIST画像の推論結果"></p>
<p>最後に，学習したニューラルネットワークのパラメータを <code>mnist_cnn.pt</code> というファイル名で保存しておこう． これで，将来いつでも今回学習したモデルを再現し，別の実験に使用することができる．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">torch.save(model.state_dict(), </span><span style="color: #96D0FF">&quot;mnist_cnn.pt&quot;</span><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">torch.save(model.state_dict(), </span><span style="color: #032F62">&quot;mnist_cnn.pt&quot;</span><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>以上が， AWS クラウドの仮想サーバーを立ち上げ，最初のディープラーニングの計算を行う一連の流れである． MNIST 文字認識のタスクを行うニューラルネットを，クラウド上の GPU を使って高速に学習させ，現実的な問題を一つ解くことができたのである． 興味のある読者は，今回のハンズオンを雛形に，自分の所望の計算を走らせてみるとよいだろう．</p>
<h2 id="スタックの削除" tabindex="-1">スタックの削除 <a class="header-anchor" href="#スタックの削除" aria-label="Permalink to &quot;スタックの削除&quot;">&ZeroWidthSpace;</a></h2>
<p>これにて，ハンズオン第二回の内容はすべて説明した． クラウドの利用料金を最小化するため，使い終わった EC2 インスタンスはすぐさま削除しよう．</p>
<p>ハンズオン第一回と同様に， AWS の CloudFormation コンソールか， AWS CLI により削除を実行する (詳細は (#handson_01_delete_stack) 参照)．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cdk</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">destroy</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cdk</span><span style="color: #24292E"> </span><span style="color: #032F62">destroy</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p><strong>スタックの削除は各自で必ず行うこと！</strong> 行わなかった場合，EC2 インスタンスの料金が発生し続けることになる！ <code>g4dn.xlarge</code> は $0.71 / hour の料金設定なので，一日起動しつづけると約$17 の請求が発生することになる！</p>
<p><strong>AWS のバジェットアラート</strong></p>
<p>AWS の初心者が (あるいは経験者も) しばしば陥る失敗が，インスタンスの停止忘れなどで無駄なリソースがクラウドで放置されてしまい，巨大な額の請求が届く，というミスだ． 特に，開発を行っている間はこのような事態は起こりうるものだと思って，備えておかなければならない． このような事態を未然に防ぐため， AWS Budgets という機能が無料で提供されている． AWS Budgets を利用することで，月の利用金額がある閾値を超えた場合にユーザーにメールが送信される，などのアラートを設定することができる． 詳細な手順は <a href="https://aws.amazon.com/blogs/aws-cost-management/getting-started-with-aws-budgets/" target="_blank" rel="noreferrer">AWS の公式ブログ &quot;Getting Started with AWS Budgets&quot;</a> を参照のこと． 本書の読者も，ぜひこのタイミングでアラートを設定しておくことを推奨する．</p>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hands-on #3: AWS で自動質問回答ボットを走らせる ]]></title>
            <link>https://note.toshiki.devdevelopment/aws/handson-qabot</link>
            <guid>https://note.toshiki.devdevelopment/aws/handson-qabot</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="hands-on-3-aws-で自動質問回答ボットを走らせる" tabindex="-1">Hands-on #3: AWS で自動質問回答ボットを走らせる <a class="header-anchor" href="#hands-on-3-aws-で自動質問回答ボットを走らせる" aria-label="Permalink to &quot;Hands-on \#3: AWS で自動質問回答ボットを走らせる&quot;">&ZeroWidthSpace;</a></h1>
<p>ハンズオン第三回では， Docker と ECS を駆使した機械学習アプリケーションを実装しよう． 具体的には，深層学習による自然言語処理を行うことで，クライアントから与えられた文章題に対して回答を生成する，自動 Question &amp; Answering ボットを作成しよう． ECS を利用することで，ジョブの数によって動的にインスタンスの数を制御し，並列にタスクを実行するようなシステムを構築しよう．</p>
<p>通常の機械学習のワークフローでは，モデルの訓練 ⇒ 推論 (データへの適用) が基本的な流れである． しかしながら， GPU 搭載型の EC2 クラスターを使ったモデルの訓練はやや難易度が高いため，次章 ( (#sec_aws_batch)) で取り扱う． 本章は，クラウド上でのクラスターの構築・タスクの管理などの概念に慣れるため，よりシンプルな実装で実現できる Fargate クラスターを用いた推論計算の並列化を紹介する．</p>
<h2 id="fargate" tabindex="-1">Fargate <a class="header-anchor" href="#fargate" aria-label="Permalink to &quot;Fargate&quot;">&ZeroWidthSpace;</a></h2>
<p>ハンズオンに入っていく前に， <strong>Fargate</strong> という AWS の機能を知っておく必要がある (<a href="#fig:fargate_logo">figure_title</a>)．</p>
<p><img src="./assets/aws_logos/Fargate.png" alt="Fargate のアイコン"></p>
<p>ECS の概要を示した (#ecs_overview) をもう一度見てみよう． この図で， ECS の管理下にあるクラスターが示されているが，このクラスターの中で計算を行う実体としては二つの選択肢がある． <strong>EC2 あるいは Fargate</strong> のいずれかである． EC2 を用いた場合は，先の章 ( (#sec_first_ec2), (#sec_jupyter_and_deep_learning)) で説明したような流れでインスタンスが起動し，計算が実行される． しかし， EC2 を用いた計算機クラスターの作成・管理は技術的な難易度がやや高いので，次章 ( (#sec_aws_batch)) で説明することにする．</p>
<p>Fargate とは， <strong>ECS での利用に特化</strong>して設計された，<strong>コンテナを使用した計算タスク</strong>を走らせるための仕組みである． 計算を走らせるという点では EC2 と役割は似ているが， Fargate は EC2 インスタンスのような物理的実体はもたない． 物理的実体をもたないというのは，たとえば SSH でログインすることは基本的に想定されていないし，なにかのソフトウェアをインストールしたりなどの概念も存在しない． Fargate ではすべての計算は Docker コンテナを介して行われる． すなわち， Fargate を利用するには，ユーザーは最初に所望の Docker イメージを指定しておき， Fargate は <code>docker run</code> のコマンドを使用することで計算タスクを実行する． Fargate を用いる利点は， Fargate を ECS のクラスターに指定すると，スケーリングなどの操作が簡単な設定・プログラムで構築できる点である．</p>
<p>Fargate では， EC2 と同様に CPU とメモリーのサイズを必要な分だけ指定できる． 執筆時点では， CPU は 0.25 - 4 コア， RAM は 0.5 - 30 GB の間で選択することができる (詳しくは <a href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/AWS_Fargate.html" target="_blank" rel="noreferrer">公式ドキュメンテーション &quot;Amazon ECS on AWS Fargate&quot;</a> 参照)． クラスターのスケーリングが容易な分， Fargate では EC2 ほど大きな CPU コア・ RAM 容量を単一インスタンスに付与することができず，また GPU を利用することもできない．</p>
<p>以上が Fargate の概要であったが，くどくど言葉で説明してもなかなかピンとこないだろう． ここからは実際に手を動かしながら， ECS と Fargate を使った並列タスクの処理の仕方を学んでいこう．</p>
<p>厳密には， ECS に付与するクラスターには EC2 と Fargate のハイブリッドを使用することも可能である．</p>
<h2 id="準備" tabindex="-1">準備 <a class="header-anchor" href="#準備" aria-label="Permalink to &quot;準備&quot;">&ZeroWidthSpace;</a></h2>
<p>ハンズオンのソースコードは GitHub の <a href="https://github.com/andatoshiki/toshiki-notebooktree/main/handson/qa-bot" target="_blank" rel="noreferrer">handson/qa-bot</a> にある．</p>
<p>本ハンズオンの実行には，第一回ハンズオンで説明した準備 ( (#handson_01_prep)) が整っていることを前提とする． また， Docker が自身のローカルマシンにインストール済みであることも必要である．</p>
<p>このハンズオンでは 1CPU/4GB RAM の Fargate インスタンスを使用する． 計算の実行には 0.025 $/hour のコストが発生することに注意．</p>
<h2 id="transformer-を用いた-question-answering-プログラム" tabindex="-1">Transformer を用いた question-answering プログラム <a class="header-anchor" href="#transformer-を用いた-question-answering-プログラム" aria-label="Permalink to &quot;Transformer を用いた question-answering プログラム&quot;">&ZeroWidthSpace;</a></h2>
<p>このハンズオンで開発する，自動質問回答システムをより具体的に定義しよう． 次のような文脈 (context) と質問 (question) が与えられた状況を想定する．</p>
<div class="language-txt vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">txt</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #adbac7">context: Albert Einstein (14 March 1879 – 18 April 1955) was a German-born theoretical physicist who developed the theory of relativity, one of the two pillars of modern physics (alongside quantum mechanics). His work is also known for its influence on the philosophy of science. He is best known to the general public for his mass–energy equivalence formula E = mc2, which has been dubbed \&quot;the world&#39;s most famous equation\&quot;. He received the 1921 Nobel Prize in Physics \&quot;for his services to theoretical physics, and especially for his discovery of the law of the photoelectric effect\&quot;, a pivotal step in the development of quantum theory.</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">question: In what year did Einstein win the Nobel prize?</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292e">context: Albert Einstein (14 March 1879 – 18 April 1955) was a German-born theoretical physicist who developed the theory of relativity, one of the two pillars of modern physics (alongside quantum mechanics). His work is also known for its influence on the philosophy of science. He is best known to the general public for his mass–energy equivalence formula E = mc2, which has been dubbed \&quot;the world&#39;s most famous equation\&quot;. He received the 1921 Nobel Prize in Physics \&quot;for his services to theoretical physics, and especially for his discovery of the law of the photoelectric effect\&quot;, a pivotal step in the development of quantum theory.</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">question: In what year did Einstein win the Nobel prize?</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><p>今回作成する自動回答システムは，このような問題に対して， context に含まれる文字列から正解となる言葉を見つけ出すものとする． 上の問題では，次のような回答を返すべきである．</p>
<pre><code>answer: 1921
</code></pre>
<p>人間にとっては，このような文章を理解することは容易であるが，コンピュータにそれを解かせるのは難しいことは容易に想像ができるだろう． しかし，近年の深層学習を使った自然言語処理の進歩は著しく，上で示したような例題などは極めて高い正答率で回答できるモデルを作ることができる．</p>
<p>今回は， <a href="https://github.com/huggingface/transformers" target="_blank" rel="noreferrer">huggingface/transformers</a> で公開されている学習済みの言語モデルを利用することで，上で定義した問題を解く Q&amp;A ボットを作る． この Q&amp;A ボットは <a href="https://en.wikipedia.org/wiki/Transformer_(machine_learning_model)" target="_blank" rel="noreferrer">Transformer</a> とよばれるモデルを使った自然言語処理に支えられえている (<a href="#transformer_architecture">figure_title</a>)． このプログラムを， Docker にパッケージしたものが <a href="https://hub.docker.com/repository/docker/tomomano/qabot" target="_blank" rel="noreferrer">著者の Docker Hub リポジトリ</a> に用意してある． クラウドの設計に入る前に，まずはこのプログラムを単体で動かしてみよう．</p>
<p><img src="./assets/transformer.png" alt="Transformer モデルアーキテクチャ (画像出典: Vaswani+ 2017)"></p>
<p>なお，今回は学習済みのモデルを用いているので，私達が行うのは与えられた入力をモデルに投入して予測を行う (推論) のみである． 推論の演算は， CPU だけでも十分高速に行うことができるので，コストの削減と，実装をシンプルにする目的で，このハンズオンでは GPU は利用しない． 一般的に， ニューラルネットは学習のほうが圧倒的に計算コストが大きく，そのような場合に GPU はより威力を発揮する．</p>
<p>次のコマンドで，今回使う Docker image を ローカルにダウンロード (pull) してこよう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">docker</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">pull</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">tomomano/qabot:latest</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">docker</span><span style="color: #24292E"> </span><span style="color: #032F62">pull</span><span style="color: #24292E"> </span><span style="color: #032F62">tomomano/qabot:latest</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>pull できたら，早速この Docker に質問を投げかけてみよう． まずは context と question をコマンドラインの変数として定義する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">context=&quot;Albert Einstein (14 March 1879 – 18 April 1955) was a German-born theoretical physicist who developed the theory of relativity, one of the two pillars of modern physics (alongside quantum mechanics). His work is also known for its influence on the philosophy of science. He is best known to the general public for his mass–energy equivalence formula E = mc2, which has been dubbed the world&#39;s most famous equation. He received the 1921 Nobel Prize in Physics for his services to theoretical physics, and especially for his discovery of the law of the photoelectric effect, a pivotal step in the development of quantum theory.&quot;</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">question=&quot;In what year did Einstein win the Nobel prize ?&quot;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">context=&quot;Albert Einstein (14 March 1879 – 18 April 1955) was a German-born theoretical physicist who developed the theory of relativity, one of the two pillars of modern physics (alongside quantum mechanics). His work is also known for its influence on the philosophy of science. He is best known to the general public for his mass–energy equivalence formula E = mc2, which has been dubbed the world&#39;s most famous equation. He received the 1921 Nobel Prize in Physics for his services to theoretical physics, and especially for his discovery of the law of the photoelectric effect, a pivotal step in the development of quantum theory.&quot;</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">question=&quot;In what year did Einstein win the Nobel prize ?&quot;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>そうしたら，次のコマンドによってコンテナを実行する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">docker</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">run</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">tomomano/qabot</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;${</span><span style="color: #ADBAC7">context</span><span style="color: #96D0FF">}&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;${</span><span style="color: #ADBAC7">question</span><span style="color: #96D0FF">}&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">foo</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--no_save</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">docker</span><span style="color: #24292E"> </span><span style="color: #032F62">run</span><span style="color: #24292E"> </span><span style="color: #032F62">tomomano/qabot</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;${</span><span style="color: #24292E">context</span><span style="color: #032F62">}&quot;</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;${</span><span style="color: #24292E">question</span><span style="color: #032F62">}&quot;</span><span style="color: #24292E"> </span><span style="color: #032F62">foo</span><span style="color: #24292E"> </span><span style="color: #005CC5">--no_save</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>今回用意した Docker image は，第一引数に context となる文字列を，第二引数に question に相当する文字列を受けつける． 第三引数，第四引数については，クラウドに展開するときの実装上の都合なので，いまは気にしなくてよい．</p>
<p>このコマンドを実行すると，次のような出力が得られるはずである．</p>
<div class="language-json vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">json</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">{ </span><span style="color: #8DDB8C">&quot;score&quot;</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">0.9881729286683587</span><span style="color: #ADBAC7">, </span><span style="color: #8DDB8C">&quot;start&quot;</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">437</span><span style="color: #ADBAC7">, </span><span style="color: #8DDB8C">&quot;end&quot;</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">441</span><span style="color: #ADBAC7">, </span><span style="color: #8DDB8C">&quot;answer&quot;</span><span style="color: #ADBAC7">: </span><span style="color: #96D0FF">&quot;1921&quot;</span><span style="color: #ADBAC7"> }</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">{ </span><span style="color: #005CC5">&quot;score&quot;</span><span style="color: #24292E">: </span><span style="color: #005CC5">0.9881729286683587</span><span style="color: #24292E">, </span><span style="color: #005CC5">&quot;start&quot;</span><span style="color: #24292E">: </span><span style="color: #005CC5">437</span><span style="color: #24292E">, </span><span style="color: #005CC5">&quot;end&quot;</span><span style="color: #24292E">: </span><span style="color: #005CC5">441</span><span style="color: #24292E">, </span><span style="color: #005CC5">&quot;answer&quot;</span><span style="color: #24292E">: </span><span style="color: #032F62">&quot;1921&quot;</span><span style="color: #24292E"> }</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>&quot;score&quot; は正解の自信度を表す数字で， [0,1] の範囲で与えられる． &quot;start&quot;, &quot;end&quot; は， context 中の何文字目が正解に相当するかを示しており， &quot;answer&quot; が正解と予測された文字列である． 1921 年という，正しい答えが返ってきていることに注目してほしい．</p>
<p>もう少し難しい質問を投げかけてみよう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">question=&quot;Why did Einstein win the Nobel prize ?&quot;</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">docker</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">run</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">tomomano/qabot</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;${</span><span style="color: #ADBAC7">context</span><span style="color: #96D0FF">}&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;${</span><span style="color: #ADBAC7">question</span><span style="color: #96D0FF">}&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">foo</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--no_save</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">question=&quot;Why did Einstein win the Nobel prize ?&quot;</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">docker</span><span style="color: #24292E"> </span><span style="color: #032F62">run</span><span style="color: #24292E"> </span><span style="color: #032F62">tomomano/qabot</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;${</span><span style="color: #24292E">context</span><span style="color: #032F62">}&quot;</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;${</span><span style="color: #24292E">question</span><span style="color: #032F62">}&quot;</span><span style="color: #24292E"> </span><span style="color: #032F62">foo</span><span style="color: #24292E"> </span><span style="color: #005CC5">--no_save</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>出力：</p>
<div class="language-json vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">json</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">{</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #8DDB8C">&quot;score&quot;</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">0.5235594527494207</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #8DDB8C">&quot;start&quot;</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">470</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #8DDB8C">&quot;end&quot;</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">506</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #8DDB8C">&quot;answer&quot;</span><span style="color: #ADBAC7">: </span><span style="color: #96D0FF">&quot;his services to theoretical physics,&quot;</span></span>
<span class="line"><span style="color: #ADBAC7">}</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">{</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">&quot;score&quot;</span><span style="color: #24292E">: </span><span style="color: #005CC5">0.5235594527494207</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">&quot;start&quot;</span><span style="color: #24292E">: </span><span style="color: #005CC5">470</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">&quot;end&quot;</span><span style="color: #24292E">: </span><span style="color: #005CC5">506</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">&quot;answer&quot;</span><span style="color: #24292E">: </span><span style="color: #032F62">&quot;his services to theoretical physics,&quot;</span></span>
<span class="line"><span style="color: #24292E">}</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br></div></div><p>今度は， score が 0.52 と，少し自信がないようだが，それでも正しい答えにたどりつけていることがわかる．</p>
<p>このように， 深層学習に支えられた言語モデルを用いることで，実用にも役に立ちそうな Q&amp;A ボットを実現できていることがわかる． 以降では，このプログラムをクラウドに展開することで，大量の質問に自動で対応できるようなシステムを設計していく．</p>
<p>今回使用する Question &amp; Answering システムには， DistilBERT という Transformer を基にした言語モデルが用いられている． 興味のある読者は， <a href="https://arxiv.org/abs/1910.01108" target="_blank" rel="noreferrer">原著論文</a> を参照してもらいたい． また， huggingface/transformers による DistilBert の実装のドキュメンテーションは <a href="https://huggingface.co/transformers/model_doc/distilbert.html" target="_blank" rel="noreferrer">公式ドキュメンテーション</a> を参照のこと．</p>
<p>今回提供する Q-A ボットの Docker のソースコードは <a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/qa-bot/docker/Dockerfile" target="_blank" rel="noreferrer">https://github.com/andatoshiki/toshiki-notebookblob/main/handson/qa-bot/docker/Dockerfile</a> にある．</p>
<h2 id="アプリケーションの説明" tabindex="-1">アプリケーションの説明 <a class="header-anchor" href="#アプリケーションの説明" aria-label="Permalink to &quot;アプリケーションの説明&quot;">&ZeroWidthSpace;</a></h2>
<p>このハンズオンで作成するアプリケーションの概要を <a href="#handson_03_architecture">figure_title</a> に示す．</p>
<p><img src="./assets/handson-03/handson-03-architecture.png" alt="アプリケーションのアーキテクチャ"></p>
<p>簡単にまとめると，以下のような設計である．</p>
<ul>
<li>
<p>クライアントは，質問を AWS 上のアプリケーションに送信する．</p>
</li>
<li>
<p>質問のタスクは ECS によって処理される．</p>
</li>
<li>
<p>ECS は， Docker Hub から，イメージをダウンロードする．</p>
</li>
<li>
<p>次に，ECS はクラスター内に新たな Fargate インスタンスを立ち上げ，ダウンロードされた Docker イメージをこの新規インスタンスに配置する．</p>
<ul>
<li>このとき，一つの質問に対し一つの Fargate インスタンスを立ち上げることで，複数の質問を並列的に処理できるようにする．</li>
</ul>
</li>
<li>
<p>ジョブが実行される．</p>
</li>
<li>
<p>ジョブの実行結果 (質問への回答) は， データベース (DynamoDB) に書き込まれる．</p>
</li>
<li>
<p>最後に，クライアントは DynamoDB から質問への回答を読み取る．</p>
</li>
</ul>
<p>それでは，プログラムのソースコードを見てみよう (<a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/qa-bot/app.py" target="_blank" rel="noreferrer">handson/qa-bot/app.py</a>)．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">class</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50">EcsClusterQaBot</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">core</span><span style="color: #ADBAC7">.</span><span style="color: #6CB6FF">Stack</span><span style="color: #ADBAC7">):</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">def</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">__init__</span><span style="color: #ADBAC7">(self, scope: core.App, name: </span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">, </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">kwargs) -&gt; </span><span style="color: #6CB6FF">None</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #6CB6FF">super</span><span style="color: #ADBAC7">().</span><span style="color: #6CB6FF">__init__</span><span style="color: #ADBAC7">(scope, name, </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">kwargs)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390"># dynamoDB table to store questions and answers</span></span>
<span class="line"><span style="color: #ADBAC7">        table </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> dynamodb.Table(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;EcsClusterQaBot-Table&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">partition_key</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">dynamodb.Attribute(</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">name</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;item_id&quot;</span><span style="color: #ADBAC7">, </span><span style="color: #F69D50">type</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">dynamodb.AttributeType.</span><span style="color: #6CB6FF">STRING</span></span>
<span class="line"><span style="color: #ADBAC7">            ),</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">billing_mode</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">dynamodb.BillingMode.</span><span style="color: #6CB6FF">PAY_PER_REQUEST</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">removal_policy</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">core.RemovalPolicy.</span><span style="color: #6CB6FF">DESTROY</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        vpc </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ec2.Vpc(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;EcsClusterQaBot-Vpc&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">max_azs</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        cluster </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ecs.Cluster(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;EcsClusterQaBot-Cluster&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">vpc</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">vpc,</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        taskdef </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ecs.FargateTaskDefinition(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;EcsClusterQaBot-TaskDef&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">cpu</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">1024</span><span style="color: #ADBAC7">, </span><span style="color: #768390"># 1 CPU</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">memory_limit_mib</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">4096</span><span style="color: #ADBAC7">, </span><span style="color: #768390"># 4GB RAM</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390"># grant permissions</span></span>
<span class="line"><span style="color: #ADBAC7">        table.grant_read_write_data(taskdef.task_role)</span></span>
<span class="line"><span style="color: #ADBAC7">        taskdef.add_to_task_role_policy(</span></span>
<span class="line"><span style="color: #ADBAC7">            iam.PolicyStatement(</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">effect</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">iam.Effect.</span><span style="color: #6CB6FF">ALLOW</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">resources</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">[</span><span style="color: #96D0FF">&quot;*&quot;</span><span style="color: #ADBAC7">],</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">actions</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">[</span><span style="color: #96D0FF">&quot;ssm:GetParameter&quot;</span><span style="color: #ADBAC7">]</span></span>
<span class="line"><span style="color: #ADBAC7">            )</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        container </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> taskdef.add_container(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #96D0FF">&quot;EcsClusterQaBot-Container&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">image</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ecs.ContainerImage.from_registry(</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #96D0FF">&quot;tomomano/qabot:latest&quot;</span></span>
<span class="line"><span style="color: #ADBAC7">            ),</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">class</span><span style="color: #24292E"> </span><span style="color: #6F42C1">EcsClusterQaBot</span><span style="color: #24292E">(</span><span style="color: #6F42C1">core</span><span style="color: #24292E">.</span><span style="color: #6F42C1">Stack</span><span style="color: #24292E">):</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">def</span><span style="color: #24292E"> </span><span style="color: #005CC5">__init__</span><span style="color: #24292E">(self, scope: core.App, name: </span><span style="color: #005CC5">str</span><span style="color: #24292E">, </span><span style="color: #D73A49">**</span><span style="color: #24292E">kwargs) -&gt; </span><span style="color: #005CC5">None</span><span style="color: #24292E">:</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #005CC5">super</span><span style="color: #24292E">().</span><span style="color: #005CC5">__init__</span><span style="color: #24292E">(scope, name, </span><span style="color: #D73A49">**</span><span style="color: #24292E">kwargs)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D"># dynamoDB table to store questions and answers</span></span>
<span class="line"><span style="color: #24292E">        table </span><span style="color: #D73A49">=</span><span style="color: #24292E"> dynamodb.Table(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;EcsClusterQaBot-Table&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">partition_key</span><span style="color: #D73A49">=</span><span style="color: #24292E">dynamodb.Attribute(</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">name</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;item_id&quot;</span><span style="color: #24292E">, </span><span style="color: #E36209">type</span><span style="color: #D73A49">=</span><span style="color: #24292E">dynamodb.AttributeType.</span><span style="color: #005CC5">STRING</span></span>
<span class="line"><span style="color: #24292E">            ),</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">billing_mode</span><span style="color: #D73A49">=</span><span style="color: #24292E">dynamodb.BillingMode.</span><span style="color: #005CC5">PAY_PER_REQUEST</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">removal_policy</span><span style="color: #D73A49">=</span><span style="color: #24292E">core.RemovalPolicy.</span><span style="color: #005CC5">DESTROY</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        vpc </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ec2.Vpc(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;EcsClusterQaBot-Vpc&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">max_azs</span><span style="color: #D73A49">=</span><span style="color: #005CC5">1</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        cluster </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ecs.Cluster(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;EcsClusterQaBot-Cluster&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">vpc</span><span style="color: #D73A49">=</span><span style="color: #24292E">vpc,</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        taskdef </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ecs.FargateTaskDefinition(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;EcsClusterQaBot-TaskDef&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">cpu</span><span style="color: #D73A49">=</span><span style="color: #005CC5">1024</span><span style="color: #24292E">, </span><span style="color: #6A737D"># 1 CPU</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">memory_limit_mib</span><span style="color: #D73A49">=</span><span style="color: #005CC5">4096</span><span style="color: #24292E">, </span><span style="color: #6A737D"># 4GB RAM</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D"># grant permissions</span></span>
<span class="line"><span style="color: #24292E">        table.grant_read_write_data(taskdef.task_role)</span></span>
<span class="line"><span style="color: #24292E">        taskdef.add_to_task_role_policy(</span></span>
<span class="line"><span style="color: #24292E">            iam.PolicyStatement(</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">effect</span><span style="color: #D73A49">=</span><span style="color: #24292E">iam.Effect.</span><span style="color: #005CC5">ALLOW</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">resources</span><span style="color: #D73A49">=</span><span style="color: #24292E">[</span><span style="color: #032F62">&quot;*&quot;</span><span style="color: #24292E">],</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">actions</span><span style="color: #D73A49">=</span><span style="color: #24292E">[</span><span style="color: #032F62">&quot;ssm:GetParameter&quot;</span><span style="color: #24292E">]</span></span>
<span class="line"><span style="color: #24292E">            )</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        container </span><span style="color: #D73A49">=</span><span style="color: #24292E"> taskdef.add_container(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #032F62">&quot;EcsClusterQaBot-Container&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">image</span><span style="color: #D73A49">=</span><span style="color: #24292E">ecs.ContainerImage.from_registry(</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #032F62">&quot;tomomano/qabot:latest&quot;</span></span>
<span class="line"><span style="color: #24292E">            ),</span></span>
<span class="line"><span style="color: #24292E">        )</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br><span class="line-number">36</span><br><span class="line-number">37</span><br><span class="line-number">38</span><br><span class="line-number">39</span><br><span class="line-number">40</span><br><span class="line-number">41</span><br><span class="line-number">42</span><br><span class="line-number">43</span><br><span class="line-number">44</span><br><span class="line-number">45</span><br><span class="line-number">46</span><br><span class="line-number">47</span><br><span class="line-number">48</span><br><span class="line-number">49</span><br><span class="line-number">50</span><br><span class="line-number">51</span><br><span class="line-number">52</span><br></div></div><ul>
<li>
<p>ここでは，回答の結果を書き込むためのデータベースを用意している． DynamoDB については，サーバーレスアーキテクチャの章で扱うので，今は気にしなくてよい．</p>
</li>
<li>
<p>ここでは，ハンズオン #1, #2 で行ったのと同様に， VPC を定義している．</p>
</li>
<li>
<p>ここで， ECS のクラスター (cluster) を定義している． クラスターとは，仮想サーバーのプールのことであり，クラスターの中に複数の仮想インスタンスを配置する．</p>
</li>
<li>
<p>ここで，実行するタスクを定義している (task definition)．</p>
</li>
<li>
<p>ここで， タスクの実行で使用する Docker イメージを定義している．</p>
</li>
</ul>
<h3 id="ecs-と-fargate" tabindex="-1">ECS と Fargate <a class="header-anchor" href="#ecs-と-fargate" aria-label="Permalink to &quot;ECS と Fargate&quot;">&ZeroWidthSpace;</a></h3>
<p>ECS と Fargate の部分について，コードをくわしく見てみよう．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">cluster </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ecs.Cluster(</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;EcsClusterQaBot-Cluster&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">vpc</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">vpc,</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">taskdef </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ecs.FargateTaskDefinition(</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;EcsClusterQaBot-TaskDef&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">cpu</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">1024</span><span style="color: #ADBAC7">, </span><span style="color: #768390"># 1 CPU</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">memory_limit_mib</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">4096</span><span style="color: #ADBAC7">, </span><span style="color: #768390"># 4GB RAM</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">container </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> taskdef.add_container(</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #96D0FF">&quot;EcsClusterQaBot-Container&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">image</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ecs.ContainerImage.from_registry(</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #96D0FF">&quot;tomomano/qabot:latest&quot;</span></span>
<span class="line"><span style="color: #ADBAC7">    ),</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">cluster </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ecs.Cluster(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;EcsClusterQaBot-Cluster&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">vpc</span><span style="color: #D73A49">=</span><span style="color: #24292E">vpc,</span></span>
<span class="line"><span style="color: #24292E">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">taskdef </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ecs.FargateTaskDefinition(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;EcsClusterQaBot-TaskDef&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">cpu</span><span style="color: #D73A49">=</span><span style="color: #005CC5">1024</span><span style="color: #24292E">, </span><span style="color: #6A737D"># 1 CPU</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">memory_limit_mib</span><span style="color: #D73A49">=</span><span style="color: #005CC5">4096</span><span style="color: #24292E">, </span><span style="color: #6A737D"># 4GB RAM</span></span>
<span class="line"><span style="color: #24292E">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">container </span><span style="color: #D73A49">=</span><span style="color: #24292E"> taskdef.add_container(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #032F62">&quot;EcsClusterQaBot-Container&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">image</span><span style="color: #D73A49">=</span><span style="color: #24292E">ecs.ContainerImage.from_registry(</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #032F62">&quot;tomomano/qabot:latest&quot;</span></span>
<span class="line"><span style="color: #24292E">    ),</span></span>
<span class="line"><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br></div></div><p><code>cluster =</code> の箇所で，空の ECS クラスターを定義している．</p>
<p>次に， <code>taskdef=ecs.FargateTaskDefinition</code> の箇所で， Fargate インスタンスを使ったタスクを定義しており，とくにここでは 1 CPU, 4GB RAM というマシンスペックを指定している． また，このようにして定義されたタスクは，デフォルトで 1 タスクにつき 1 インスタンスが使用される．</p>
<p>最後に， <code>container =</code> の箇所で，タスクの実行で使用する Docker image を定義している． ここでは， Docker Hub に置いてある image をダウンロードしてくるよう指定している．</p>
<p>このようにわずか数行のコードであるが，これだけで前述したような，タスクのスケジューリングなどが自動で実行される．</p>
<p>このコードで <code>cpu=1024</code> と指定されているのに注目してほしい． これは CPU ユニットと呼ばれる数で， 以下の換算表に従って仮想 CPU (virtual CPU; vCPU) が割り当てられる． 1024 が 1 CPU に相当する． 0.25 や 0.5 vCPU などの数字は，それぞれ実効的に 1/4, 1/2 の CPU 時間が割り当てられることを意味する． また， CPU ユニットによって使用できるメモリー量も変わってくる． たとえば， 1024 CPU ユニットを選択した場合は， 2 から 8 GB の範囲でのみメモリー量を指定することができる． 最新の情報は <a href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/AWS_Fargate.html" target="_blank" rel="noreferrer">公式ドキュメンテーション &quot;Amazon ECS on AWS Fargate&quot;</a> を参照のこと．</p>
<table><caption>CPU　ユニットと 指定可能なメモリー量の換算表</caption><colgroup><col style="width: 50%" /><col style="width: 50%" /></colgroup><tbody><tr class="odd"><td><p>CPU ユニット</p></td><td><p>メモリーの値</p></td></tr><tr class="even"><td><p>256 (.25 vCPU)</p></td><td><p>0.5 GB, 1 GB, 2 GB</p></td></tr><tr class="odd"><td><p>512 (.5 vCPU)</p></td><td><p>1 GB, 2 GB, 3 GB, 4 GB</p></td></tr><tr class="even"><td><p>1024 (1 vCPU)</p></td><td><p>2 GB, 3 GB, 4 GB, 5 GB, 6 GB, 7 GB, 8 GB</p></td></tr><tr class="odd"><td><p>2048 (2 vCPU)</p></td><td><p>Between 4 GB and 16 GB in 1-GB increments</p></td></tr><tr class="even"><td><p>4096 (4 vCPU)</p></td><td><p>Between 8 GB and 30 GB in 1-GB increments</p></td></tr></tbody></table>
<h2 id="スタックのデプロイ" tabindex="-1">スタックのデプロイ <a class="header-anchor" href="#スタックのデプロイ" aria-label="Permalink to &quot;スタックのデプロイ&quot;">&ZeroWidthSpace;</a></h2>
<p>スタックの中身が理解できたところで，早速スタックをデプロイしてみよう．</p>
<p>デプロイの手順は，これまでのハンズオンとほとんど共通である． SSH によるログインの必要がないので，むしろ単純なくらいである． ここでは，コマンドのみ列挙する (<code>#</code> で始まる行はコメントである)． それぞれの意味を忘れてしまった場合は，ハンズオン 1, 2 に戻って復習していただきたい． シークレットキーの設定も忘れずに ( (#aws_cli_install))．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390"># プロジェクトのディレクトリに移動</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cd</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">handson/qa-bot</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># venv を作成し，依存ライブラリのインストールを行う</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python3</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-m</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">venv</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.env</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">source</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.env/bin/activate</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">pip</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">install</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-r</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">requirements.txt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># デプロイを実行</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cdk</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">deploy</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D"># プロジェクトのディレクトリに移動</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cd</span><span style="color: #24292E"> </span><span style="color: #032F62">handson/qa-bot</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># venv を作成し，依存ライブラリのインストールを行う</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python3</span><span style="color: #24292E"> </span><span style="color: #005CC5">-m</span><span style="color: #24292E"> </span><span style="color: #032F62">venv</span><span style="color: #24292E"> </span><span style="color: #032F62">.env</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">source</span><span style="color: #24292E"> </span><span style="color: #032F62">.env/bin/activate</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">pip</span><span style="color: #24292E"> </span><span style="color: #032F62">install</span><span style="color: #24292E"> </span><span style="color: #005CC5">-r</span><span style="color: #24292E"> </span><span style="color: #032F62">requirements.txt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># デプロイを実行</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cdk</span><span style="color: #24292E"> </span><span style="color: #032F62">deploy</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br></div></div><p>デプロイのコマンドが無事に実行されれば， <a href="#handson_03_cdk_output">figure_title</a> のような出力が得られるはずである．</p>
<p><img src="./assets/handson-03/cdk_output.png" alt="CDKデプロイ実行後の出力"></p>
<p>AWS コンソールにログインして，デプロイされたスタックの中身を確認してみよう． コンソールから，ECS のページに行くと <a href="#handson_03_ecs_console">figure_title</a> のような画面が表示されるはずである． <code>EcsClusterQaBot-XXXX</code> という名前ついたクラスターを見つけよう．</p>
<p>Cluster というのが，先ほど説明したとおり，複数の仮想インスタンスを束ねる一つの単位である． <a href="#handson_03_ecs_console">figure_title</a> で， FARGATE という文字の下に <code>0 Running tasks</code>, <code>0 Pending tasks</code> と表示されていることを確認しよう． この時点では一つもタスクが走っていないので，数字はすべて 0 になっている．</p>
<p><img src="./assets/handson-03/ecs_console.png" alt="ECS コンソール画面"></p>
<p>続いて，この画面の左のメニューバーから <code>Task Definitions</code> という項目を見つけ，クリックしよう． 移動した先のページで <code>EcsClusterQaBotEcsClusterQaBotTaskDefXXXX</code> という項目が見つかるので，開く． 開いた先のページをスクロールすると <a href="#handson_03_ecs_task_definition">figure_title</a> に示したような情報が見つかるだろう． 使用する CPU ・メモリーの量や， Docker container の実行に関する設定などが，この Task Definition の画面から確認することができる．</p>
<p><img src="./assets/handson-03/ecs_task_definition.png" alt="Task definition の確認"></p>
<h2 id="タスクの実行" tabindex="-1">タスクの実行 <a class="header-anchor" href="#タスクの実行" aria-label="Permalink to &quot;タスクの実行&quot;">&ZeroWidthSpace;</a></h2>
<p>それでは，質問をデプロイしたクラウドに提出してみよう．</p>
<p>ECS にタスクを投入するのはやや複雑なので，タスクの投入を簡単にするプログラム (<code>run_task.py</code>) を用意した (<a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/qa-bot/run_task.py" target="_blank" rel="noreferrer">handson/qa-bot/run_task.py</a>)．</p>
<p>次のようなコマンドで，ECS クラスターに新しい質問を投入することができる．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">run_task.py</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ask</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;A giant peach was flowing in the river. She picked it up and brought it home. Later, a healthy baby was born from the peach. She named the baby Momotaro.&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;What is the name of the baby?&quot;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python</span><span style="color: #24292E"> </span><span style="color: #032F62">run_task.py</span><span style="color: #24292E"> </span><span style="color: #032F62">ask</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;A giant peach was flowing in the river. She picked it up and brought it home. Later, a healthy baby was born from the peach. She named the baby Momotaro.&quot;</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;What is the name of the baby?&quot;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p><code>run_task.py</code> を実行するには， コマンドラインで AWS の認証情報が設定されていることが前提である．</p>
<p>&quot;ask&quot; の引数に続き，文脈 (context) と質問 (question) を引数として渡している．</p>
<p>このコマンドを実行すると， &quot;Waiting for the task to finish…&quot; と出力が表示され，回答を得るまでしばらく待たされる． この間， AWS では ECS がタスクを受理し，新しい Fargate のインスタンスを起動し， Docker イメージをそのインスタンスに配置する，という一連の処理がなされている． AWS コンソールから，この一連の様子をモニタリングしてみよう．</p>
<p>先ほどの ECS コンソール画面にもどり，クラスターの名前をクリックすることで，クラスターの詳細画面を開く． 次に， &quot;Tasks&quot; という名前のタブがあるので，それを開く (<a href="#ecs_task_monitoring">figure_title</a>)． すると，実行中のタスクの一覧が表示されるだろう．</p>
<p><img src="./assets/handson-03/ecs_task_monitoring.png" alt="ECS のタスクの実行状況をモニタリング"></p>
<p><a href="#ecs_task_monitoring">figure_title</a> で見て取れるように， &quot;Last status = Pending&quot; となっていることから，この時点では，タスクを実行する準備をしている段階である，ということがわかる． Fargate のインスタンスを起動し， Docker image を配置するまでおよそ 1-2 分の時間がかかる．</p>
<p>しばらく待つうちに， Status が &quot;RUNNING&quot; に遷移し，計算が始まる． 計算が終わると， Status は &quot;STOPPED&quot; に遷移し， ECS によって Fargate インスタンスは自動的にシャットダウンされる．</p>
<p><a href="#ecs_task_monitoring">figure_title</a> の画面から， &quot;Task&quot; の列にあるタスク ID クリックすることで，タスクの詳細画面を開いてみよう (<a href="#ecs_task_detail">figure_title</a>)． &quot;Last status&quot;, &quot;Platform version&quot; など，タスクの情報が表示されている． また， &quot;Logs&quot; のタブを開くことで，コンテナの吐き出した実行ログを閲覧することができる．</p>
<p><img src="./assets/handson-03/ecs_task_detail.png" alt="質問タスクの実行結果"></p>
<p>さて， <code>run_task.py</code> を実行したコマンドラインに戻ってきてみると， <a href="#ask_question_output">figure_title</a> のような出力が得られているはずである． &quot;Momotaro&quot; という正しい回答が返ってきている！</p>
<p><img src="./assets/handson-03/ask_question_output.png" alt="質問タスクの実行結果"></p>
<h2 id="タスクの同時実行" tabindex="-1">タスクの同時実行 <a class="header-anchor" href="#タスクの同時実行" aria-label="Permalink to &quot;タスクの同時実行&quot;">&ZeroWidthSpace;</a></h2>
<p>さて，先ほどはたった一つの質問を投入したわけだが，今回設計したアプリケーションは， ECS と Fargate を使うことで同時にたくさんの質問を処理することができる． 実際に，たくさんの質問を一度に投入してみよう． <code>run_task.py</code> に <code>ask_many</code> というオプションを付けることで，複数の質問を一度に送信できる． 質問の内容は <a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/qa-bot/problems.json" target="_blank" rel="noreferrer">handson/qa-bot/problems.json</a> に定義されている．</p>
<p>次のようなコマンドを実行しよう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">run_task.py</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ask_many</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python</span><span style="color: #24292E"> </span><span style="color: #032F62">run_task.py</span><span style="color: #24292E"> </span><span style="color: #032F62">ask_many</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>このコマンドを実行した後で，先ほどの ECS コンソールに行き，タスクの一覧を見てみよう (<a href="#ecs_many_tasks">figure_title</a>)． 複数の Fargate インスタンスが起動され，タスクが並列に実行されているのがわかる．</p>
<p><img src="./assets/handson-03/ecs_many_tasks.png" alt="複数の質問タスクを同時に投入する"></p>
<p>すべてのタスクのステータスが &quot;STOPPED&quot; になったことを確認した上で，質問への回答を取得しよう． それには，次のコマンドを実行する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">run_task.py</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">list_answers</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python</span><span style="color: #24292E"> </span><span style="color: #032F62">run_task.py</span><span style="color: #24292E"> </span><span style="color: #032F62">list_answers</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>結果として， <a href="#ask_many_output">figure_title</a> のような出力が得られるだろう． 複雑な文章問題に対し，高い正答率で回答できていることがわかるだろう．</p>
<p><img src="./assets/handson-03/ask_many_output.png" alt=" の実行結果"></p>
<p>おめでとう！ ここまでついてこれた読者はとても初歩的ながらも，深層学習による言語モデルを使って自動で質問への回答を生成するシステムを創り上げることができた！ それも，数百の質問にも同時に対応できるような，とても高いスケーラビリティーをもったシステムである！ 今回は GUI (Graphical User Interface) を用意することはしなかったが，このシステムに簡単な GUI を追加すればなかなか立派なウェブサービスとして運用できるだろう．</p>
<p><code>run_task.py</code> で質問を投入し続けると，回答を記録しているデータベースにどんどんエントリーが溜まっていく． これらのエントリーをすべて消去するには，次のコマンドを使う．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">run_task.py</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">clear</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python</span><span style="color: #24292E"> </span><span style="color: #032F62">run_task.py</span><span style="color: #24292E"> </span><span style="color: #032F62">clear</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><h2 id="スタックの削除" tabindex="-1">スタックの削除 <a class="header-anchor" href="#スタックの削除" aria-label="Permalink to &quot;スタックの削除&quot;">&ZeroWidthSpace;</a></h2>
<p>これにて，今回のハンズオンは終了である． 最後にスタックを削除しよう．</p>
<p>スタックを削除するには，前回までと同様に， AWS コンソールにログインし CloudFormation の画面から DELETE ボタンをクリックするか，コマンドラインからコマンドを実行する． コマンドラインから行う場合は，次のコマンドを使用する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cdk</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">destroy</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cdk</span><span style="color: #24292E"> </span><span style="color: #032F62">destroy</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div>]]></description>
            <content:encoded><![CDATA[<h1 id="hands-on-3-aws-で自動質問回答ボットを走らせる" tabindex="-1">Hands-on #3: AWS で自動質問回答ボットを走らせる <a class="header-anchor" href="#hands-on-3-aws-で自動質問回答ボットを走らせる" aria-label="Permalink to &quot;Hands-on \#3: AWS で自動質問回答ボットを走らせる&quot;">&ZeroWidthSpace;</a></h1>
<p>ハンズオン第三回では， Docker と ECS を駆使した機械学習アプリケーションを実装しよう． 具体的には，深層学習による自然言語処理を行うことで，クライアントから与えられた文章題に対して回答を生成する，自動 Question &amp; Answering ボットを作成しよう． ECS を利用することで，ジョブの数によって動的にインスタンスの数を制御し，並列にタスクを実行するようなシステムを構築しよう．</p>
<p>通常の機械学習のワークフローでは，モデルの訓練 ⇒ 推論 (データへの適用) が基本的な流れである． しかしながら， GPU 搭載型の EC2 クラスターを使ったモデルの訓練はやや難易度が高いため，次章 ( (#sec_aws_batch)) で取り扱う． 本章は，クラウド上でのクラスターの構築・タスクの管理などの概念に慣れるため，よりシンプルな実装で実現できる Fargate クラスターを用いた推論計算の並列化を紹介する．</p>
<h2 id="fargate" tabindex="-1">Fargate <a class="header-anchor" href="#fargate" aria-label="Permalink to &quot;Fargate&quot;">&ZeroWidthSpace;</a></h2>
<p>ハンズオンに入っていく前に， <strong>Fargate</strong> という AWS の機能を知っておく必要がある (<a href="#fig:fargate_logo">figure_title</a>)．</p>
<p><img src="./assets/aws_logos/Fargate.png" alt="Fargate のアイコン"></p>
<p>ECS の概要を示した (#ecs_overview) をもう一度見てみよう． この図で， ECS の管理下にあるクラスターが示されているが，このクラスターの中で計算を行う実体としては二つの選択肢がある． <strong>EC2 あるいは Fargate</strong> のいずれかである． EC2 を用いた場合は，先の章 ( (#sec_first_ec2), (#sec_jupyter_and_deep_learning)) で説明したような流れでインスタンスが起動し，計算が実行される． しかし， EC2 を用いた計算機クラスターの作成・管理は技術的な難易度がやや高いので，次章 ( (#sec_aws_batch)) で説明することにする．</p>
<p>Fargate とは， <strong>ECS での利用に特化</strong>して設計された，<strong>コンテナを使用した計算タスク</strong>を走らせるための仕組みである． 計算を走らせるという点では EC2 と役割は似ているが， Fargate は EC2 インスタンスのような物理的実体はもたない． 物理的実体をもたないというのは，たとえば SSH でログインすることは基本的に想定されていないし，なにかのソフトウェアをインストールしたりなどの概念も存在しない． Fargate ではすべての計算は Docker コンテナを介して行われる． すなわち， Fargate を利用するには，ユーザーは最初に所望の Docker イメージを指定しておき， Fargate は <code>docker run</code> のコマンドを使用することで計算タスクを実行する． Fargate を用いる利点は， Fargate を ECS のクラスターに指定すると，スケーリングなどの操作が簡単な設定・プログラムで構築できる点である．</p>
<p>Fargate では， EC2 と同様に CPU とメモリーのサイズを必要な分だけ指定できる． 執筆時点では， CPU は 0.25 - 4 コア， RAM は 0.5 - 30 GB の間で選択することができる (詳しくは <a href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/AWS_Fargate.html" target="_blank" rel="noreferrer">公式ドキュメンテーション &quot;Amazon ECS on AWS Fargate&quot;</a> 参照)． クラスターのスケーリングが容易な分， Fargate では EC2 ほど大きな CPU コア・ RAM 容量を単一インスタンスに付与することができず，また GPU を利用することもできない．</p>
<p>以上が Fargate の概要であったが，くどくど言葉で説明してもなかなかピンとこないだろう． ここからは実際に手を動かしながら， ECS と Fargate を使った並列タスクの処理の仕方を学んでいこう．</p>
<p>厳密には， ECS に付与するクラスターには EC2 と Fargate のハイブリッドを使用することも可能である．</p>
<h2 id="準備" tabindex="-1">準備 <a class="header-anchor" href="#準備" aria-label="Permalink to &quot;準備&quot;">&ZeroWidthSpace;</a></h2>
<p>ハンズオンのソースコードは GitHub の <a href="https://github.com/andatoshiki/toshiki-notebooktree/main/handson/qa-bot" target="_blank" rel="noreferrer">handson/qa-bot</a> にある．</p>
<p>本ハンズオンの実行には，第一回ハンズオンで説明した準備 ( (#handson_01_prep)) が整っていることを前提とする． また， Docker が自身のローカルマシンにインストール済みであることも必要である．</p>
<p>このハンズオンでは 1CPU/4GB RAM の Fargate インスタンスを使用する． 計算の実行には 0.025 $/hour のコストが発生することに注意．</p>
<h2 id="transformer-を用いた-question-answering-プログラム" tabindex="-1">Transformer を用いた question-answering プログラム <a class="header-anchor" href="#transformer-を用いた-question-answering-プログラム" aria-label="Permalink to &quot;Transformer を用いた question-answering プログラム&quot;">&ZeroWidthSpace;</a></h2>
<p>このハンズオンで開発する，自動質問回答システムをより具体的に定義しよう． 次のような文脈 (context) と質問 (question) が与えられた状況を想定する．</p>
<div class="language-txt vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">txt</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #adbac7">context: Albert Einstein (14 March 1879 – 18 April 1955) was a German-born theoretical physicist who developed the theory of relativity, one of the two pillars of modern physics (alongside quantum mechanics). His work is also known for its influence on the philosophy of science. He is best known to the general public for his mass–energy equivalence formula E = mc2, which has been dubbed \&quot;the world&#39;s most famous equation\&quot;. He received the 1921 Nobel Prize in Physics \&quot;for his services to theoretical physics, and especially for his discovery of the law of the photoelectric effect\&quot;, a pivotal step in the development of quantum theory.</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">question: In what year did Einstein win the Nobel prize?</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292e">context: Albert Einstein (14 March 1879 – 18 April 1955) was a German-born theoretical physicist who developed the theory of relativity, one of the two pillars of modern physics (alongside quantum mechanics). His work is also known for its influence on the philosophy of science. He is best known to the general public for his mass–energy equivalence formula E = mc2, which has been dubbed \&quot;the world&#39;s most famous equation\&quot;. He received the 1921 Nobel Prize in Physics \&quot;for his services to theoretical physics, and especially for his discovery of the law of the photoelectric effect\&quot;, a pivotal step in the development of quantum theory.</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">question: In what year did Einstein win the Nobel prize?</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><p>今回作成する自動回答システムは，このような問題に対して， context に含まれる文字列から正解となる言葉を見つけ出すものとする． 上の問題では，次のような回答を返すべきである．</p>
<pre><code>answer: 1921
</code></pre>
<p>人間にとっては，このような文章を理解することは容易であるが，コンピュータにそれを解かせるのは難しいことは容易に想像ができるだろう． しかし，近年の深層学習を使った自然言語処理の進歩は著しく，上で示したような例題などは極めて高い正答率で回答できるモデルを作ることができる．</p>
<p>今回は， <a href="https://github.com/huggingface/transformers" target="_blank" rel="noreferrer">huggingface/transformers</a> で公開されている学習済みの言語モデルを利用することで，上で定義した問題を解く Q&amp;A ボットを作る． この Q&amp;A ボットは <a href="https://en.wikipedia.org/wiki/Transformer_(machine_learning_model)" target="_blank" rel="noreferrer">Transformer</a> とよばれるモデルを使った自然言語処理に支えられえている (<a href="#transformer_architecture">figure_title</a>)． このプログラムを， Docker にパッケージしたものが <a href="https://hub.docker.com/repository/docker/tomomano/qabot" target="_blank" rel="noreferrer">著者の Docker Hub リポジトリ</a> に用意してある． クラウドの設計に入る前に，まずはこのプログラムを単体で動かしてみよう．</p>
<p><img src="./assets/transformer.png" alt="Transformer モデルアーキテクチャ (画像出典: Vaswani+ 2017)"></p>
<p>なお，今回は学習済みのモデルを用いているので，私達が行うのは与えられた入力をモデルに投入して予測を行う (推論) のみである． 推論の演算は， CPU だけでも十分高速に行うことができるので，コストの削減と，実装をシンプルにする目的で，このハンズオンでは GPU は利用しない． 一般的に， ニューラルネットは学習のほうが圧倒的に計算コストが大きく，そのような場合に GPU はより威力を発揮する．</p>
<p>次のコマンドで，今回使う Docker image を ローカルにダウンロード (pull) してこよう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">docker</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">pull</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">tomomano/qabot:latest</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">docker</span><span style="color: #24292E"> </span><span style="color: #032F62">pull</span><span style="color: #24292E"> </span><span style="color: #032F62">tomomano/qabot:latest</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>pull できたら，早速この Docker に質問を投げかけてみよう． まずは context と question をコマンドラインの変数として定義する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">context=&quot;Albert Einstein (14 March 1879 – 18 April 1955) was a German-born theoretical physicist who developed the theory of relativity, one of the two pillars of modern physics (alongside quantum mechanics). His work is also known for its influence on the philosophy of science. He is best known to the general public for his mass–energy equivalence formula E = mc2, which has been dubbed the world&#39;s most famous equation. He received the 1921 Nobel Prize in Physics for his services to theoretical physics, and especially for his discovery of the law of the photoelectric effect, a pivotal step in the development of quantum theory.&quot;</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">question=&quot;In what year did Einstein win the Nobel prize ?&quot;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">context=&quot;Albert Einstein (14 March 1879 – 18 April 1955) was a German-born theoretical physicist who developed the theory of relativity, one of the two pillars of modern physics (alongside quantum mechanics). His work is also known for its influence on the philosophy of science. He is best known to the general public for his mass–energy equivalence formula E = mc2, which has been dubbed the world&#39;s most famous equation. He received the 1921 Nobel Prize in Physics for his services to theoretical physics, and especially for his discovery of the law of the photoelectric effect, a pivotal step in the development of quantum theory.&quot;</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">question=&quot;In what year did Einstein win the Nobel prize ?&quot;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>そうしたら，次のコマンドによってコンテナを実行する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">docker</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">run</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">tomomano/qabot</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;${</span><span style="color: #ADBAC7">context</span><span style="color: #96D0FF">}&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;${</span><span style="color: #ADBAC7">question</span><span style="color: #96D0FF">}&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">foo</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--no_save</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">docker</span><span style="color: #24292E"> </span><span style="color: #032F62">run</span><span style="color: #24292E"> </span><span style="color: #032F62">tomomano/qabot</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;${</span><span style="color: #24292E">context</span><span style="color: #032F62">}&quot;</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;${</span><span style="color: #24292E">question</span><span style="color: #032F62">}&quot;</span><span style="color: #24292E"> </span><span style="color: #032F62">foo</span><span style="color: #24292E"> </span><span style="color: #005CC5">--no_save</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>今回用意した Docker image は，第一引数に context となる文字列を，第二引数に question に相当する文字列を受けつける． 第三引数，第四引数については，クラウドに展開するときの実装上の都合なので，いまは気にしなくてよい．</p>
<p>このコマンドを実行すると，次のような出力が得られるはずである．</p>
<div class="language-json vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">json</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">{ </span><span style="color: #8DDB8C">&quot;score&quot;</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">0.9881729286683587</span><span style="color: #ADBAC7">, </span><span style="color: #8DDB8C">&quot;start&quot;</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">437</span><span style="color: #ADBAC7">, </span><span style="color: #8DDB8C">&quot;end&quot;</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">441</span><span style="color: #ADBAC7">, </span><span style="color: #8DDB8C">&quot;answer&quot;</span><span style="color: #ADBAC7">: </span><span style="color: #96D0FF">&quot;1921&quot;</span><span style="color: #ADBAC7"> }</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">{ </span><span style="color: #005CC5">&quot;score&quot;</span><span style="color: #24292E">: </span><span style="color: #005CC5">0.9881729286683587</span><span style="color: #24292E">, </span><span style="color: #005CC5">&quot;start&quot;</span><span style="color: #24292E">: </span><span style="color: #005CC5">437</span><span style="color: #24292E">, </span><span style="color: #005CC5">&quot;end&quot;</span><span style="color: #24292E">: </span><span style="color: #005CC5">441</span><span style="color: #24292E">, </span><span style="color: #005CC5">&quot;answer&quot;</span><span style="color: #24292E">: </span><span style="color: #032F62">&quot;1921&quot;</span><span style="color: #24292E"> }</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>&quot;score&quot; は正解の自信度を表す数字で， [0,1] の範囲で与えられる． &quot;start&quot;, &quot;end&quot; は， context 中の何文字目が正解に相当するかを示しており， &quot;answer&quot; が正解と予測された文字列である． 1921 年という，正しい答えが返ってきていることに注目してほしい．</p>
<p>もう少し難しい質問を投げかけてみよう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">question=&quot;Why did Einstein win the Nobel prize ?&quot;</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">docker</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">run</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">tomomano/qabot</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;${</span><span style="color: #ADBAC7">context</span><span style="color: #96D0FF">}&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;${</span><span style="color: #ADBAC7">question</span><span style="color: #96D0FF">}&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">foo</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--no_save</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">question=&quot;Why did Einstein win the Nobel prize ?&quot;</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">docker</span><span style="color: #24292E"> </span><span style="color: #032F62">run</span><span style="color: #24292E"> </span><span style="color: #032F62">tomomano/qabot</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;${</span><span style="color: #24292E">context</span><span style="color: #032F62">}&quot;</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;${</span><span style="color: #24292E">question</span><span style="color: #032F62">}&quot;</span><span style="color: #24292E"> </span><span style="color: #032F62">foo</span><span style="color: #24292E"> </span><span style="color: #005CC5">--no_save</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>出力：</p>
<div class="language-json vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">json</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">{</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #8DDB8C">&quot;score&quot;</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">0.5235594527494207</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #8DDB8C">&quot;start&quot;</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">470</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #8DDB8C">&quot;end&quot;</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">506</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #8DDB8C">&quot;answer&quot;</span><span style="color: #ADBAC7">: </span><span style="color: #96D0FF">&quot;his services to theoretical physics,&quot;</span></span>
<span class="line"><span style="color: #ADBAC7">}</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">{</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">&quot;score&quot;</span><span style="color: #24292E">: </span><span style="color: #005CC5">0.5235594527494207</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">&quot;start&quot;</span><span style="color: #24292E">: </span><span style="color: #005CC5">470</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">&quot;end&quot;</span><span style="color: #24292E">: </span><span style="color: #005CC5">506</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">&quot;answer&quot;</span><span style="color: #24292E">: </span><span style="color: #032F62">&quot;his services to theoretical physics,&quot;</span></span>
<span class="line"><span style="color: #24292E">}</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br></div></div><p>今度は， score が 0.52 と，少し自信がないようだが，それでも正しい答えにたどりつけていることがわかる．</p>
<p>このように， 深層学習に支えられた言語モデルを用いることで，実用にも役に立ちそうな Q&amp;A ボットを実現できていることがわかる． 以降では，このプログラムをクラウドに展開することで，大量の質問に自動で対応できるようなシステムを設計していく．</p>
<p>今回使用する Question &amp; Answering システムには， DistilBERT という Transformer を基にした言語モデルが用いられている． 興味のある読者は， <a href="https://arxiv.org/abs/1910.01108" target="_blank" rel="noreferrer">原著論文</a> を参照してもらいたい． また， huggingface/transformers による DistilBert の実装のドキュメンテーションは <a href="https://huggingface.co/transformers/model_doc/distilbert.html" target="_blank" rel="noreferrer">公式ドキュメンテーション</a> を参照のこと．</p>
<p>今回提供する Q-A ボットの Docker のソースコードは <a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/qa-bot/docker/Dockerfile" target="_blank" rel="noreferrer">https://github.com/andatoshiki/toshiki-notebookblob/main/handson/qa-bot/docker/Dockerfile</a> にある．</p>
<h2 id="アプリケーションの説明" tabindex="-1">アプリケーションの説明 <a class="header-anchor" href="#アプリケーションの説明" aria-label="Permalink to &quot;アプリケーションの説明&quot;">&ZeroWidthSpace;</a></h2>
<p>このハンズオンで作成するアプリケーションの概要を <a href="#handson_03_architecture">figure_title</a> に示す．</p>
<p><img src="./assets/handson-03/handson-03-architecture.png" alt="アプリケーションのアーキテクチャ"></p>
<p>簡単にまとめると，以下のような設計である．</p>
<ul>
<li>
<p>クライアントは，質問を AWS 上のアプリケーションに送信する．</p>
</li>
<li>
<p>質問のタスクは ECS によって処理される．</p>
</li>
<li>
<p>ECS は， Docker Hub から，イメージをダウンロードする．</p>
</li>
<li>
<p>次に，ECS はクラスター内に新たな Fargate インスタンスを立ち上げ，ダウンロードされた Docker イメージをこの新規インスタンスに配置する．</p>
<ul>
<li>このとき，一つの質問に対し一つの Fargate インスタンスを立ち上げることで，複数の質問を並列的に処理できるようにする．</li>
</ul>
</li>
<li>
<p>ジョブが実行される．</p>
</li>
<li>
<p>ジョブの実行結果 (質問への回答) は， データベース (DynamoDB) に書き込まれる．</p>
</li>
<li>
<p>最後に，クライアントは DynamoDB から質問への回答を読み取る．</p>
</li>
</ul>
<p>それでは，プログラムのソースコードを見てみよう (<a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/qa-bot/app.py" target="_blank" rel="noreferrer">handson/qa-bot/app.py</a>)．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">class</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50">EcsClusterQaBot</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">core</span><span style="color: #ADBAC7">.</span><span style="color: #6CB6FF">Stack</span><span style="color: #ADBAC7">):</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">def</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">__init__</span><span style="color: #ADBAC7">(self, scope: core.App, name: </span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">, </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">kwargs) -&gt; </span><span style="color: #6CB6FF">None</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #6CB6FF">super</span><span style="color: #ADBAC7">().</span><span style="color: #6CB6FF">__init__</span><span style="color: #ADBAC7">(scope, name, </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">kwargs)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390"># dynamoDB table to store questions and answers</span></span>
<span class="line"><span style="color: #ADBAC7">        table </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> dynamodb.Table(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;EcsClusterQaBot-Table&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">partition_key</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">dynamodb.Attribute(</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">name</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;item_id&quot;</span><span style="color: #ADBAC7">, </span><span style="color: #F69D50">type</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">dynamodb.AttributeType.</span><span style="color: #6CB6FF">STRING</span></span>
<span class="line"><span style="color: #ADBAC7">            ),</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">billing_mode</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">dynamodb.BillingMode.</span><span style="color: #6CB6FF">PAY_PER_REQUEST</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">removal_policy</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">core.RemovalPolicy.</span><span style="color: #6CB6FF">DESTROY</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        vpc </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ec2.Vpc(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;EcsClusterQaBot-Vpc&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">max_azs</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        cluster </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ecs.Cluster(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;EcsClusterQaBot-Cluster&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">vpc</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">vpc,</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        taskdef </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ecs.FargateTaskDefinition(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;EcsClusterQaBot-TaskDef&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">cpu</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">1024</span><span style="color: #ADBAC7">, </span><span style="color: #768390"># 1 CPU</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">memory_limit_mib</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">4096</span><span style="color: #ADBAC7">, </span><span style="color: #768390"># 4GB RAM</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390"># grant permissions</span></span>
<span class="line"><span style="color: #ADBAC7">        table.grant_read_write_data(taskdef.task_role)</span></span>
<span class="line"><span style="color: #ADBAC7">        taskdef.add_to_task_role_policy(</span></span>
<span class="line"><span style="color: #ADBAC7">            iam.PolicyStatement(</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">effect</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">iam.Effect.</span><span style="color: #6CB6FF">ALLOW</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">resources</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">[</span><span style="color: #96D0FF">&quot;*&quot;</span><span style="color: #ADBAC7">],</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">actions</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">[</span><span style="color: #96D0FF">&quot;ssm:GetParameter&quot;</span><span style="color: #ADBAC7">]</span></span>
<span class="line"><span style="color: #ADBAC7">            )</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        container </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> taskdef.add_container(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #96D0FF">&quot;EcsClusterQaBot-Container&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">image</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ecs.ContainerImage.from_registry(</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #96D0FF">&quot;tomomano/qabot:latest&quot;</span></span>
<span class="line"><span style="color: #ADBAC7">            ),</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">class</span><span style="color: #24292E"> </span><span style="color: #6F42C1">EcsClusterQaBot</span><span style="color: #24292E">(</span><span style="color: #6F42C1">core</span><span style="color: #24292E">.</span><span style="color: #6F42C1">Stack</span><span style="color: #24292E">):</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">def</span><span style="color: #24292E"> </span><span style="color: #005CC5">__init__</span><span style="color: #24292E">(self, scope: core.App, name: </span><span style="color: #005CC5">str</span><span style="color: #24292E">, </span><span style="color: #D73A49">**</span><span style="color: #24292E">kwargs) -&gt; </span><span style="color: #005CC5">None</span><span style="color: #24292E">:</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #005CC5">super</span><span style="color: #24292E">().</span><span style="color: #005CC5">__init__</span><span style="color: #24292E">(scope, name, </span><span style="color: #D73A49">**</span><span style="color: #24292E">kwargs)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D"># dynamoDB table to store questions and answers</span></span>
<span class="line"><span style="color: #24292E">        table </span><span style="color: #D73A49">=</span><span style="color: #24292E"> dynamodb.Table(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;EcsClusterQaBot-Table&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">partition_key</span><span style="color: #D73A49">=</span><span style="color: #24292E">dynamodb.Attribute(</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">name</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;item_id&quot;</span><span style="color: #24292E">, </span><span style="color: #E36209">type</span><span style="color: #D73A49">=</span><span style="color: #24292E">dynamodb.AttributeType.</span><span style="color: #005CC5">STRING</span></span>
<span class="line"><span style="color: #24292E">            ),</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">billing_mode</span><span style="color: #D73A49">=</span><span style="color: #24292E">dynamodb.BillingMode.</span><span style="color: #005CC5">PAY_PER_REQUEST</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">removal_policy</span><span style="color: #D73A49">=</span><span style="color: #24292E">core.RemovalPolicy.</span><span style="color: #005CC5">DESTROY</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        vpc </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ec2.Vpc(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;EcsClusterQaBot-Vpc&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">max_azs</span><span style="color: #D73A49">=</span><span style="color: #005CC5">1</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        cluster </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ecs.Cluster(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;EcsClusterQaBot-Cluster&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">vpc</span><span style="color: #D73A49">=</span><span style="color: #24292E">vpc,</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        taskdef </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ecs.FargateTaskDefinition(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;EcsClusterQaBot-TaskDef&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">cpu</span><span style="color: #D73A49">=</span><span style="color: #005CC5">1024</span><span style="color: #24292E">, </span><span style="color: #6A737D"># 1 CPU</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">memory_limit_mib</span><span style="color: #D73A49">=</span><span style="color: #005CC5">4096</span><span style="color: #24292E">, </span><span style="color: #6A737D"># 4GB RAM</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D"># grant permissions</span></span>
<span class="line"><span style="color: #24292E">        table.grant_read_write_data(taskdef.task_role)</span></span>
<span class="line"><span style="color: #24292E">        taskdef.add_to_task_role_policy(</span></span>
<span class="line"><span style="color: #24292E">            iam.PolicyStatement(</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">effect</span><span style="color: #D73A49">=</span><span style="color: #24292E">iam.Effect.</span><span style="color: #005CC5">ALLOW</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">resources</span><span style="color: #D73A49">=</span><span style="color: #24292E">[</span><span style="color: #032F62">&quot;*&quot;</span><span style="color: #24292E">],</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">actions</span><span style="color: #D73A49">=</span><span style="color: #24292E">[</span><span style="color: #032F62">&quot;ssm:GetParameter&quot;</span><span style="color: #24292E">]</span></span>
<span class="line"><span style="color: #24292E">            )</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        container </span><span style="color: #D73A49">=</span><span style="color: #24292E"> taskdef.add_container(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #032F62">&quot;EcsClusterQaBot-Container&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">image</span><span style="color: #D73A49">=</span><span style="color: #24292E">ecs.ContainerImage.from_registry(</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #032F62">&quot;tomomano/qabot:latest&quot;</span></span>
<span class="line"><span style="color: #24292E">            ),</span></span>
<span class="line"><span style="color: #24292E">        )</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br><span class="line-number">36</span><br><span class="line-number">37</span><br><span class="line-number">38</span><br><span class="line-number">39</span><br><span class="line-number">40</span><br><span class="line-number">41</span><br><span class="line-number">42</span><br><span class="line-number">43</span><br><span class="line-number">44</span><br><span class="line-number">45</span><br><span class="line-number">46</span><br><span class="line-number">47</span><br><span class="line-number">48</span><br><span class="line-number">49</span><br><span class="line-number">50</span><br><span class="line-number">51</span><br><span class="line-number">52</span><br></div></div><ul>
<li>
<p>ここでは，回答の結果を書き込むためのデータベースを用意している． DynamoDB については，サーバーレスアーキテクチャの章で扱うので，今は気にしなくてよい．</p>
</li>
<li>
<p>ここでは，ハンズオン #1, #2 で行ったのと同様に， VPC を定義している．</p>
</li>
<li>
<p>ここで， ECS のクラスター (cluster) を定義している． クラスターとは，仮想サーバーのプールのことであり，クラスターの中に複数の仮想インスタンスを配置する．</p>
</li>
<li>
<p>ここで，実行するタスクを定義している (task definition)．</p>
</li>
<li>
<p>ここで， タスクの実行で使用する Docker イメージを定義している．</p>
</li>
</ul>
<h3 id="ecs-と-fargate" tabindex="-1">ECS と Fargate <a class="header-anchor" href="#ecs-と-fargate" aria-label="Permalink to &quot;ECS と Fargate&quot;">&ZeroWidthSpace;</a></h3>
<p>ECS と Fargate の部分について，コードをくわしく見てみよう．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">cluster </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ecs.Cluster(</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;EcsClusterQaBot-Cluster&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">vpc</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">vpc,</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">taskdef </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ecs.FargateTaskDefinition(</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;EcsClusterQaBot-TaskDef&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">cpu</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">1024</span><span style="color: #ADBAC7">, </span><span style="color: #768390"># 1 CPU</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">memory_limit_mib</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">4096</span><span style="color: #ADBAC7">, </span><span style="color: #768390"># 4GB RAM</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">container </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> taskdef.add_container(</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #96D0FF">&quot;EcsClusterQaBot-Container&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">image</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ecs.ContainerImage.from_registry(</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #96D0FF">&quot;tomomano/qabot:latest&quot;</span></span>
<span class="line"><span style="color: #ADBAC7">    ),</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">cluster </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ecs.Cluster(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;EcsClusterQaBot-Cluster&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">vpc</span><span style="color: #D73A49">=</span><span style="color: #24292E">vpc,</span></span>
<span class="line"><span style="color: #24292E">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">taskdef </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ecs.FargateTaskDefinition(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;EcsClusterQaBot-TaskDef&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">cpu</span><span style="color: #D73A49">=</span><span style="color: #005CC5">1024</span><span style="color: #24292E">, </span><span style="color: #6A737D"># 1 CPU</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">memory_limit_mib</span><span style="color: #D73A49">=</span><span style="color: #005CC5">4096</span><span style="color: #24292E">, </span><span style="color: #6A737D"># 4GB RAM</span></span>
<span class="line"><span style="color: #24292E">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">container </span><span style="color: #D73A49">=</span><span style="color: #24292E"> taskdef.add_container(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #032F62">&quot;EcsClusterQaBot-Container&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">image</span><span style="color: #D73A49">=</span><span style="color: #24292E">ecs.ContainerImage.from_registry(</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #032F62">&quot;tomomano/qabot:latest&quot;</span></span>
<span class="line"><span style="color: #24292E">    ),</span></span>
<span class="line"><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br></div></div><p><code>cluster =</code> の箇所で，空の ECS クラスターを定義している．</p>
<p>次に， <code>taskdef=ecs.FargateTaskDefinition</code> の箇所で， Fargate インスタンスを使ったタスクを定義しており，とくにここでは 1 CPU, 4GB RAM というマシンスペックを指定している． また，このようにして定義されたタスクは，デフォルトで 1 タスクにつき 1 インスタンスが使用される．</p>
<p>最後に， <code>container =</code> の箇所で，タスクの実行で使用する Docker image を定義している． ここでは， Docker Hub に置いてある image をダウンロードしてくるよう指定している．</p>
<p>このようにわずか数行のコードであるが，これだけで前述したような，タスクのスケジューリングなどが自動で実行される．</p>
<p>このコードで <code>cpu=1024</code> と指定されているのに注目してほしい． これは CPU ユニットと呼ばれる数で， 以下の換算表に従って仮想 CPU (virtual CPU; vCPU) が割り当てられる． 1024 が 1 CPU に相当する． 0.25 や 0.5 vCPU などの数字は，それぞれ実効的に 1/4, 1/2 の CPU 時間が割り当てられることを意味する． また， CPU ユニットによって使用できるメモリー量も変わってくる． たとえば， 1024 CPU ユニットを選択した場合は， 2 から 8 GB の範囲でのみメモリー量を指定することができる． 最新の情報は <a href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/AWS_Fargate.html" target="_blank" rel="noreferrer">公式ドキュメンテーション &quot;Amazon ECS on AWS Fargate&quot;</a> を参照のこと．</p>
<table><caption>CPU　ユニットと 指定可能なメモリー量の換算表</caption><colgroup><col style="width: 50%" /><col style="width: 50%" /></colgroup><tbody><tr class="odd"><td><p>CPU ユニット</p></td><td><p>メモリーの値</p></td></tr><tr class="even"><td><p>256 (.25 vCPU)</p></td><td><p>0.5 GB, 1 GB, 2 GB</p></td></tr><tr class="odd"><td><p>512 (.5 vCPU)</p></td><td><p>1 GB, 2 GB, 3 GB, 4 GB</p></td></tr><tr class="even"><td><p>1024 (1 vCPU)</p></td><td><p>2 GB, 3 GB, 4 GB, 5 GB, 6 GB, 7 GB, 8 GB</p></td></tr><tr class="odd"><td><p>2048 (2 vCPU)</p></td><td><p>Between 4 GB and 16 GB in 1-GB increments</p></td></tr><tr class="even"><td><p>4096 (4 vCPU)</p></td><td><p>Between 8 GB and 30 GB in 1-GB increments</p></td></tr></tbody></table>
<h2 id="スタックのデプロイ" tabindex="-1">スタックのデプロイ <a class="header-anchor" href="#スタックのデプロイ" aria-label="Permalink to &quot;スタックのデプロイ&quot;">&ZeroWidthSpace;</a></h2>
<p>スタックの中身が理解できたところで，早速スタックをデプロイしてみよう．</p>
<p>デプロイの手順は，これまでのハンズオンとほとんど共通である． SSH によるログインの必要がないので，むしろ単純なくらいである． ここでは，コマンドのみ列挙する (<code>#</code> で始まる行はコメントである)． それぞれの意味を忘れてしまった場合は，ハンズオン 1, 2 に戻って復習していただきたい． シークレットキーの設定も忘れずに ( (#aws_cli_install))．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390"># プロジェクトのディレクトリに移動</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cd</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">handson/qa-bot</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># venv を作成し，依存ライブラリのインストールを行う</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python3</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-m</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">venv</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.env</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">source</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.env/bin/activate</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">pip</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">install</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-r</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">requirements.txt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># デプロイを実行</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cdk</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">deploy</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D"># プロジェクトのディレクトリに移動</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cd</span><span style="color: #24292E"> </span><span style="color: #032F62">handson/qa-bot</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># venv を作成し，依存ライブラリのインストールを行う</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python3</span><span style="color: #24292E"> </span><span style="color: #005CC5">-m</span><span style="color: #24292E"> </span><span style="color: #032F62">venv</span><span style="color: #24292E"> </span><span style="color: #032F62">.env</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">source</span><span style="color: #24292E"> </span><span style="color: #032F62">.env/bin/activate</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">pip</span><span style="color: #24292E"> </span><span style="color: #032F62">install</span><span style="color: #24292E"> </span><span style="color: #005CC5">-r</span><span style="color: #24292E"> </span><span style="color: #032F62">requirements.txt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># デプロイを実行</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cdk</span><span style="color: #24292E"> </span><span style="color: #032F62">deploy</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br></div></div><p>デプロイのコマンドが無事に実行されれば， <a href="#handson_03_cdk_output">figure_title</a> のような出力が得られるはずである．</p>
<p><img src="./assets/handson-03/cdk_output.png" alt="CDKデプロイ実行後の出力"></p>
<p>AWS コンソールにログインして，デプロイされたスタックの中身を確認してみよう． コンソールから，ECS のページに行くと <a href="#handson_03_ecs_console">figure_title</a> のような画面が表示されるはずである． <code>EcsClusterQaBot-XXXX</code> という名前ついたクラスターを見つけよう．</p>
<p>Cluster というのが，先ほど説明したとおり，複数の仮想インスタンスを束ねる一つの単位である． <a href="#handson_03_ecs_console">figure_title</a> で， FARGATE という文字の下に <code>0 Running tasks</code>, <code>0 Pending tasks</code> と表示されていることを確認しよう． この時点では一つもタスクが走っていないので，数字はすべて 0 になっている．</p>
<p><img src="./assets/handson-03/ecs_console.png" alt="ECS コンソール画面"></p>
<p>続いて，この画面の左のメニューバーから <code>Task Definitions</code> という項目を見つけ，クリックしよう． 移動した先のページで <code>EcsClusterQaBotEcsClusterQaBotTaskDefXXXX</code> という項目が見つかるので，開く． 開いた先のページをスクロールすると <a href="#handson_03_ecs_task_definition">figure_title</a> に示したような情報が見つかるだろう． 使用する CPU ・メモリーの量や， Docker container の実行に関する設定などが，この Task Definition の画面から確認することができる．</p>
<p><img src="./assets/handson-03/ecs_task_definition.png" alt="Task definition の確認"></p>
<h2 id="タスクの実行" tabindex="-1">タスクの実行 <a class="header-anchor" href="#タスクの実行" aria-label="Permalink to &quot;タスクの実行&quot;">&ZeroWidthSpace;</a></h2>
<p>それでは，質問をデプロイしたクラウドに提出してみよう．</p>
<p>ECS にタスクを投入するのはやや複雑なので，タスクの投入を簡単にするプログラム (<code>run_task.py</code>) を用意した (<a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/qa-bot/run_task.py" target="_blank" rel="noreferrer">handson/qa-bot/run_task.py</a>)．</p>
<p>次のようなコマンドで，ECS クラスターに新しい質問を投入することができる．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">run_task.py</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ask</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;A giant peach was flowing in the river. She picked it up and brought it home. Later, a healthy baby was born from the peach. She named the baby Momotaro.&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;What is the name of the baby?&quot;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python</span><span style="color: #24292E"> </span><span style="color: #032F62">run_task.py</span><span style="color: #24292E"> </span><span style="color: #032F62">ask</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;A giant peach was flowing in the river. She picked it up and brought it home. Later, a healthy baby was born from the peach. She named the baby Momotaro.&quot;</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;What is the name of the baby?&quot;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p><code>run_task.py</code> を実行するには， コマンドラインで AWS の認証情報が設定されていることが前提である．</p>
<p>&quot;ask&quot; の引数に続き，文脈 (context) と質問 (question) を引数として渡している．</p>
<p>このコマンドを実行すると， &quot;Waiting for the task to finish…&quot; と出力が表示され，回答を得るまでしばらく待たされる． この間， AWS では ECS がタスクを受理し，新しい Fargate のインスタンスを起動し， Docker イメージをそのインスタンスに配置する，という一連の処理がなされている． AWS コンソールから，この一連の様子をモニタリングしてみよう．</p>
<p>先ほどの ECS コンソール画面にもどり，クラスターの名前をクリックすることで，クラスターの詳細画面を開く． 次に， &quot;Tasks&quot; という名前のタブがあるので，それを開く (<a href="#ecs_task_monitoring">figure_title</a>)． すると，実行中のタスクの一覧が表示されるだろう．</p>
<p><img src="./assets/handson-03/ecs_task_monitoring.png" alt="ECS のタスクの実行状況をモニタリング"></p>
<p><a href="#ecs_task_monitoring">figure_title</a> で見て取れるように， &quot;Last status = Pending&quot; となっていることから，この時点では，タスクを実行する準備をしている段階である，ということがわかる． Fargate のインスタンスを起動し， Docker image を配置するまでおよそ 1-2 分の時間がかかる．</p>
<p>しばらく待つうちに， Status が &quot;RUNNING&quot; に遷移し，計算が始まる． 計算が終わると， Status は &quot;STOPPED&quot; に遷移し， ECS によって Fargate インスタンスは自動的にシャットダウンされる．</p>
<p><a href="#ecs_task_monitoring">figure_title</a> の画面から， &quot;Task&quot; の列にあるタスク ID クリックすることで，タスクの詳細画面を開いてみよう (<a href="#ecs_task_detail">figure_title</a>)． &quot;Last status&quot;, &quot;Platform version&quot; など，タスクの情報が表示されている． また， &quot;Logs&quot; のタブを開くことで，コンテナの吐き出した実行ログを閲覧することができる．</p>
<p><img src="./assets/handson-03/ecs_task_detail.png" alt="質問タスクの実行結果"></p>
<p>さて， <code>run_task.py</code> を実行したコマンドラインに戻ってきてみると， <a href="#ask_question_output">figure_title</a> のような出力が得られているはずである． &quot;Momotaro&quot; という正しい回答が返ってきている！</p>
<p><img src="./assets/handson-03/ask_question_output.png" alt="質問タスクの実行結果"></p>
<h2 id="タスクの同時実行" tabindex="-1">タスクの同時実行 <a class="header-anchor" href="#タスクの同時実行" aria-label="Permalink to &quot;タスクの同時実行&quot;">&ZeroWidthSpace;</a></h2>
<p>さて，先ほどはたった一つの質問を投入したわけだが，今回設計したアプリケーションは， ECS と Fargate を使うことで同時にたくさんの質問を処理することができる． 実際に，たくさんの質問を一度に投入してみよう． <code>run_task.py</code> に <code>ask_many</code> というオプションを付けることで，複数の質問を一度に送信できる． 質問の内容は <a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/qa-bot/problems.json" target="_blank" rel="noreferrer">handson/qa-bot/problems.json</a> に定義されている．</p>
<p>次のようなコマンドを実行しよう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">run_task.py</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ask_many</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python</span><span style="color: #24292E"> </span><span style="color: #032F62">run_task.py</span><span style="color: #24292E"> </span><span style="color: #032F62">ask_many</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>このコマンドを実行した後で，先ほどの ECS コンソールに行き，タスクの一覧を見てみよう (<a href="#ecs_many_tasks">figure_title</a>)． 複数の Fargate インスタンスが起動され，タスクが並列に実行されているのがわかる．</p>
<p><img src="./assets/handson-03/ecs_many_tasks.png" alt="複数の質問タスクを同時に投入する"></p>
<p>すべてのタスクのステータスが &quot;STOPPED&quot; になったことを確認した上で，質問への回答を取得しよう． それには，次のコマンドを実行する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">run_task.py</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">list_answers</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python</span><span style="color: #24292E"> </span><span style="color: #032F62">run_task.py</span><span style="color: #24292E"> </span><span style="color: #032F62">list_answers</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>結果として， <a href="#ask_many_output">figure_title</a> のような出力が得られるだろう． 複雑な文章問題に対し，高い正答率で回答できていることがわかるだろう．</p>
<p><img src="./assets/handson-03/ask_many_output.png" alt=" の実行結果"></p>
<p>おめでとう！ ここまでついてこれた読者はとても初歩的ながらも，深層学習による言語モデルを使って自動で質問への回答を生成するシステムを創り上げることができた！ それも，数百の質問にも同時に対応できるような，とても高いスケーラビリティーをもったシステムである！ 今回は GUI (Graphical User Interface) を用意することはしなかったが，このシステムに簡単な GUI を追加すればなかなか立派なウェブサービスとして運用できるだろう．</p>
<p><code>run_task.py</code> で質問を投入し続けると，回答を記録しているデータベースにどんどんエントリーが溜まっていく． これらのエントリーをすべて消去するには，次のコマンドを使う．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">run_task.py</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">clear</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python</span><span style="color: #24292E"> </span><span style="color: #032F62">run_task.py</span><span style="color: #24292E"> </span><span style="color: #032F62">clear</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><h2 id="スタックの削除" tabindex="-1">スタックの削除 <a class="header-anchor" href="#スタックの削除" aria-label="Permalink to &quot;スタックの削除&quot;">&ZeroWidthSpace;</a></h2>
<p>これにて，今回のハンズオンは終了である． 最後にスタックを削除しよう．</p>
<p>スタックを削除するには，前回までと同様に， AWS コンソールにログインし CloudFormation の画面から DELETE ボタンをクリックするか，コマンドラインからコマンドを実行する． コマンドラインから行う場合は，次のコマンドを使用する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cdk</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">destroy</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cdk</span><span style="color: #24292E"> </span><span style="color: #032F62">destroy</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hands-on #5: サーバーレス入門 ]]></title>
            <link>https://note.toshiki.devdevelopment/aws/handson-serverless</link>
            <guid>https://note.toshiki.devdevelopment/aws/handson-serverless</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="hands-on-5-サーバーレス入門" tabindex="-1">Hands-on #5: サーバーレス入門 <a class="header-anchor" href="#hands-on-5-サーバーレス入門" aria-label="Permalink to &quot;Hands-on \#5: サーバーレス入門&quot;">&ZeroWidthSpace;</a></h1>
<p>前章ではサーバーレスアーキテクチャの概要の説明を行った． 本章では，ハンズオン形式でサーバーレスクラウドを実際に動かしながら，具体的な使用方法を学んでいこう． 今回のハンズオンでは Lambda, S3, DynamoDB の三つのサーバーレスクラウドの構成要素に触れていく． それぞれについて，短いチュートリアルを用意してある．</p>
<h2 id="lambda-ハンズオン" tabindex="-1">Lambda ハンズオン <a class="header-anchor" href="#lambda-ハンズオン" aria-label="Permalink to &quot;Lambda ハンズオン&quot;">&ZeroWidthSpace;</a></h2>
<p>まずは， Lambda を実際に動かしてみよう． ハンズオンのソースコードは GitHub の <a href="https://github.com/andatoshiki/toshiki-notebooktree/main/handson/serverless/lambda" target="_blank" rel="noreferrer">handson/serverless/lambda</a> に置いてある．</p>
<p>このハンズオンで使用するアプリケーションのスケッチを <a href="#fig:lambda_deploy">figure_title</a> に示す． STEP 1 では，AWS CDK を使用して Python で書かれたコードを Lambda に登録する． 続いて STEP 2 では， Invoke API を使用して，同時にいくつもの Lambda を起動し，並列な計算を行う． Lambda のワークフローを体験する目的で最小限の設定である．</p>
<p><img src="./assets/handson-serverless/lambda_deploy.png" alt="Lambda チュートリアルの概要"></p>
<p>このハンズオンは，基本的に <a href="https://aws.amazon.com/free/?all-free-tier.sort-by=item.additionalFields.SortRank&amp;all-free-tier.sort-order=asc" target="_blank" rel="noreferrer">AWS Lambda の無料枠</a> の範囲内で実行することができる．</p>
<p><a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/serverless/lambda/app.py" target="_blank" rel="noreferrer">app.py</a> にデプロイするプログラムが書かれている． 中身を見てみよう．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #6CB6FF">FUNC</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;&quot;&quot;</span></span>
<span class="line"><span style="color: #96D0FF">import time</span></span>
<span class="line"><span style="color: #96D0FF">from random import choice, randint</span></span>
<span class="line"><span style="color: #96D0FF">def handler(event, context):</span></span>
<span class="line"><span style="color: #96D0FF">    time.sleep(randint(2,5))</span></span>
<span class="line"><span style="color: #96D0FF">    sushi = [&quot;salmon&quot;, &quot;tuna&quot;, &quot;squid&quot;]</span></span>
<span class="line"><span style="color: #96D0FF">    message = &quot;Welcome to Cloud Sushi. Your order is &quot; + choice(sushi)</span></span>
<span class="line"><span style="color: #96D0FF">    print(message)</span></span>
<span class="line"><span style="color: #96D0FF">    return message</span></span>
<span class="line"><span style="color: #96D0FF">&quot;&quot;&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F47067">class</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50">SimpleLambda</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">core</span><span style="color: #ADBAC7">.</span><span style="color: #6CB6FF">Stack</span><span style="color: #ADBAC7">):</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">def</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">__init__</span><span style="color: #ADBAC7">(self, scope: core.App, name: </span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">, </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">kwargs) -&gt; </span><span style="color: #6CB6FF">None</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #6CB6FF">super</span><span style="color: #ADBAC7">().</span><span style="color: #6CB6FF">__init__</span><span style="color: #ADBAC7">(scope, name, </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">kwargs)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        handler </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> _lambda.Function(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&#39;LambdaHandler&#39;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">runtime</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">_lambda.Runtime.</span><span style="color: #6CB6FF">PYTHON_3_7</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">code</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">_lambda.Code.from_inline(</span><span style="color: #6CB6FF">FUNC</span><span style="color: #ADBAC7">),</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">handler</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;index.handler&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">memory_size</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">128</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">timeout</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">core.Duration.seconds(</span><span style="color: #6CB6FF">10</span><span style="color: #ADBAC7">),</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">dead_letter_queue_enabled</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">True</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #005CC5">FUNC</span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;&quot;&quot;</span></span>
<span class="line"><span style="color: #032F62">import time</span></span>
<span class="line"><span style="color: #032F62">from random import choice, randint</span></span>
<span class="line"><span style="color: #032F62">def handler(event, context):</span></span>
<span class="line"><span style="color: #032F62">    time.sleep(randint(2,5))</span></span>
<span class="line"><span style="color: #032F62">    sushi = [&quot;salmon&quot;, &quot;tuna&quot;, &quot;squid&quot;]</span></span>
<span class="line"><span style="color: #032F62">    message = &quot;Welcome to Cloud Sushi. Your order is &quot; + choice(sushi)</span></span>
<span class="line"><span style="color: #032F62">    print(message)</span></span>
<span class="line"><span style="color: #032F62">    return message</span></span>
<span class="line"><span style="color: #032F62">&quot;&quot;&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D73A49">class</span><span style="color: #24292E"> </span><span style="color: #6F42C1">SimpleLambda</span><span style="color: #24292E">(</span><span style="color: #6F42C1">core</span><span style="color: #24292E">.</span><span style="color: #6F42C1">Stack</span><span style="color: #24292E">):</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">def</span><span style="color: #24292E"> </span><span style="color: #005CC5">__init__</span><span style="color: #24292E">(self, scope: core.App, name: </span><span style="color: #005CC5">str</span><span style="color: #24292E">, </span><span style="color: #D73A49">**</span><span style="color: #24292E">kwargs) -&gt; </span><span style="color: #005CC5">None</span><span style="color: #24292E">:</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #005CC5">super</span><span style="color: #24292E">().</span><span style="color: #005CC5">__init__</span><span style="color: #24292E">(scope, name, </span><span style="color: #D73A49">**</span><span style="color: #24292E">kwargs)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        handler </span><span style="color: #D73A49">=</span><span style="color: #24292E"> _lambda.Function(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&#39;LambdaHandler&#39;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">runtime</span><span style="color: #D73A49">=</span><span style="color: #24292E">_lambda.Runtime.</span><span style="color: #005CC5">PYTHON_3_7</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">code</span><span style="color: #D73A49">=</span><span style="color: #24292E">_lambda.Code.from_inline(</span><span style="color: #005CC5">FUNC</span><span style="color: #24292E">),</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">handler</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;index.handler&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">memory_size</span><span style="color: #D73A49">=</span><span style="color: #005CC5">128</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">timeout</span><span style="color: #D73A49">=</span><span style="color: #24292E">core.Duration.seconds(</span><span style="color: #005CC5">10</span><span style="color: #24292E">),</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">dead_letter_queue_enabled</span><span style="color: #D73A49">=</span><span style="color: #005CC5">True</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        )</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br></div></div><ul>
<li>
<p>ここで， Lambda で実行されるべき関数を定義している． これは非常に単純な関数で，2-5 秒のランダムな時間スリープした後，[&quot;salmon&quot;, &quot;tuna&quot;, &quot;squid&quot;] のいずれかの文字列をランダムに選択し， &quot;Welcome to Cloud Sushi. Your order is XXXX&quot; (XXXX は選ばれた寿司のネタ) というメッセージをリターンする．</p>
</li>
<li>
<p>次に， Lambda に &lt;1&gt; で書いた関数を配置している． パラメータの意味は，文字どおりの意味なので難しくはないが，以下に解説する．</p>
<ul>
<li>
<p><code>runtime=_lambda.Runtime.PYTHON_3_7</code>: ここでは， Python3.7 を使って上記で定義された関数を実行せよ，と指定している． Python3.7 のほかに， Node.js, Java, Ruby, Go などの言語を指定することが可能である．</p>
</li>
<li>
<p><code>code=_lambda.Code.from_inline(FUNC)</code>: 実行されるべき関数が書かれたコードを指定する． ここでは， <code>FUNC=...</code> で定義した文字列を渡しているが，文字列以外にもファイルのパスを渡すことも可能である．</p>
</li>
<li>
<p><code>handler=&quot;index.handler&quot;</code>: これは，コードの中にいくつかのサブ関数が含まれているときに，メインとサブを区別するためのパラメータである． <code>handler</code> という名前の関数をメイン関数として実行せよ，という意味である．</p>
</li>
<li>
<p><code>memory_size=128</code>: メモリーは 128MB を最大で使用することを指定している．</p>
</li>
<li>
<p><code>timeout=core.Duration.seconds(10)</code> タイムアウト時間を 10 秒に設定している． 10 秒以内に関数の実行が終了しなかった場合，エラーが返される．</p>
</li>
<li>
<p><code>dead_letter_queue_enabled=True</code>: アドバンストな設定なので説明は省略する．</p>
</li>
</ul>
</li>
</ul>
<p>上記のプログラムを実行することで， Lambda 関数がクラウド上に作成される． 早速デプロイしてみよう．</p>
<h3 id="デプロイ" tabindex="-1">デプロイ <a class="header-anchor" href="#デプロイ" aria-label="Permalink to &quot;デプロイ&quot;">&ZeroWidthSpace;</a></h3>
<p>デプロイの手順は，これまでのハンズオンとほとんど共通である． ここでは，コマンドのみ列挙する (<code>#</code> で始まる行はコメントである)． それぞれの意味を忘れてしまった場合は，ハンズオン 1, 2 に戻って復習していただきたい． シークレットキーの設定も忘れずに ( (#aws_cli_install))．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390"># プロジェクトのディレクトリに移動</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cd</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">handson/serverless/lambda</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># venv を作成し，依存ライブラリのインストールを行う</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python3</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-m</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">venv</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.env</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">source</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.env/bin/activate</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">pip</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">install</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-r</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">requirements.txt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># デプロイを実行</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cdk</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">deploy</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D"># プロジェクトのディレクトリに移動</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cd</span><span style="color: #24292E"> </span><span style="color: #032F62">handson/serverless/lambda</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># venv を作成し，依存ライブラリのインストールを行う</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python3</span><span style="color: #24292E"> </span><span style="color: #005CC5">-m</span><span style="color: #24292E"> </span><span style="color: #032F62">venv</span><span style="color: #24292E"> </span><span style="color: #032F62">.env</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">source</span><span style="color: #24292E"> </span><span style="color: #032F62">.env/bin/activate</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">pip</span><span style="color: #24292E"> </span><span style="color: #032F62">install</span><span style="color: #24292E"> </span><span style="color: #005CC5">-r</span><span style="color: #24292E"> </span><span style="color: #032F62">requirements.txt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># デプロイを実行</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cdk</span><span style="color: #24292E"> </span><span style="color: #032F62">deploy</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br></div></div><p>デプロイのコマンドが無事に実行されれば， <a href="#handson_04_lambda_cdk_output">figure_title</a> のような出力が得られるはずである． ここで表示されている <code>SimpleLambda.FunctionName = XXXX</code> の XXXX の文字列は後で使うのでメモしておこう．</p>
<p><img src="./assets/handson-serverless/handson_04_lambda_cdk_output.png" alt="CDKデプロイ実行後の出力"></p>
<p>AWS コンソールにログインして，デプロイされたスタックを確認してみよう． コンソールから，Lambda のページに行くと <a href="#handson_04_lambda_console_func_list">figure_title</a> のような画面から Lambda の関数の一覧が確認できる．</p>
<p><img src="./assets/handson-serverless/lambda_console_func_list.png" alt="Lambda コンソール - 関数の一覧"></p>
<p>今回のアプリケーションで作成したのが <code>SimpleLambda</code> で始まるランダムな名前のついた関数だ． 関数の名前をクリックして，詳細を見てみる． すると <a href="#handson_04_lambda_console_func_detail">figure_title</a> のような画面が表示されるはずだ． 先ほどプログラムの中で定義した Python の関数がエディターから確認できる． さらに下の方にスクロールすると，関数の各種設定も確認できる．</p>
<p><img src="./assets/handson-serverless/lambda_console_func_detail.png" alt="Lambda コンソール - 関数の詳細"></p>
<p>Lambda で実行されるコードは， Lambda のコンソール画面 (<a href="#handson_04_lambda_console_func_detail">figure_title</a>) のエディターで編集することもできる． デバッグをするときなどは，こちらを直接いじる方が早い場合もある． その場合は， CDK のコードに行った編集を反映させなおすことを忘れずに．</p>
<h3 id="lambda-関数の実行" tabindex="-1">Lambda 関数の実行 <a class="header-anchor" href="#lambda-関数の実行" aria-label="Permalink to &quot;Lambda 関数の実行&quot;">&ZeroWidthSpace;</a></h3>
<p>それでは，作成した Lambda 関数を実行 (invoke) してみよう． AWS の API を使うことで，関数の実行をスタートすることができる． 今回は， <a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/serverless/lambda/invoke_one.py" target="_blank" rel="noreferrer">handson/serverless/lambda/invoke_one.py</a> に関数を実行するための簡単なプログラムを提供している． 興味のある読者はコードを読んでもらいたい．</p>
<p>以下のコマンドで，Lambda の関数を実行する． コマンドの <code>XXXX</code> の部分は，先ほどデプロイしたときに <code>SimpleLambda.FunctionName = XXXX</code> で得られた XXXX の文字列で置換する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">invoke_one.py</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">XXXX</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python</span><span style="color: #24292E"> </span><span style="color: #032F62">invoke_one.py</span><span style="color: #24292E"> </span><span style="color: #032F62">XXXX</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>すると， <code>&quot;Welcome to Cloud Sushi. Your order is salmon&quot;</code> という出力が得られるはずだ． とてもシンプルではあるが，クラウド上で先ほどの関数が走り，乱数が生成されたうえで，ランダムな寿司ネタが選択されて出力が返されている． このコマンドを何度か打ってみて，実行ごとに異なる寿司ネタが返されることを確認しよう．</p>
<p>さて，このコマンドは，一度につき一回の関数を実行したわけであるが， Lambda の本領は一度に大量のタスクを同時に実行できる点である． そこで，今度は一度に 100 個のタスクを同時に送信してみよう． <a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/serverless/lambda/invoke_many.py" target="_blank" rel="noreferrer">handson/serverless/lambda/invoke_many.py</a> のスクリプトを使用する．</p>
<p>次のコマンドを実行しよう． XXXX の部分は前述と同様に置き換える． 第二引数の <code>100</code> は 100 個のタスクを投入せよ，という意味である．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">invoke_many.py</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">XXXX</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">100</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python</span><span style="color: #24292E"> </span><span style="color: #032F62">invoke_many.py</span><span style="color: #24292E"> </span><span style="color: #032F62">XXXX</span><span style="color: #24292E"> </span><span style="color: #005CC5">100</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>すると次のような出力が得られるはずだ．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #6CB6FF">....................................................................................................</span></span>
<span class="line"><span style="color: #F69D50">Submitted</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">100</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">tasks</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">to</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">Lambda!</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #005CC5">....................................................................................................</span></span>
<span class="line"><span style="color: #6F42C1">Submitted</span><span style="color: #24292E"> </span><span style="color: #005CC5">100</span><span style="color: #24292E"> </span><span style="color: #032F62">tasks</span><span style="color: #24292E"> </span><span style="color: #032F62">to</span><span style="color: #24292E"> </span><span style="color: #032F62">Lambda!</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>実際に，100 個のタスクが同時に実行されていることを確認しよう． <a href="#handson_04_lambda_console_func_detail">figure_title</a> の画面に戻り， &quot;Monitoring&quot; というタブがあるので，それをクリックする． すると， <a href="#handson_04_lambda_console_monitoring">figure_title</a> のようなグラフが表示されるだろう．</p>
<p><img src="./assets/handson-serverless/lambda_console_monitoring.png" alt="Lambda コンソール - 関数の実行のモニタリング"></p>
<p><a href="#handson_04_lambda_console_monitoring">figure_title</a> のグラフの更新には数分かかることがあるので，なにも表示されない場合は少し待つ．</p>
<p><a href="#handson_04_lambda_console_monitoring">figure_title</a> で &quot;Invocations&quot; が関数が何度実行されたかを意味している． たしかに 100 回実行されていることがわかる． さらに， &quot;Concurrent executions&quot; は何個のタスクが同時に行われたかを示している． ここでは 96 となっていることから，96 個のタスクが並列的に実行されたことを意味している (これが 100 とならないのは，タスクの開始のコマンドが送られたのが完全には同タイミングではないことに起因する)．</p>
<p>このように，非常にシンプルではあるが， Lambda を使うことで，同時並列的に処理を実行することのできるクラウドシステムを簡単に作ることができた．</p>
<p>もしこのようなことを従来的な serverful なクラウドで行おうとした場合，クラスターのスケーリングなど多くのコードを書くことに加えて，いろいろなパラメータを調節する必要がある．</p>
<p>興味がある人は，一気に 1000 個などのジョブを投入してみるとよい． Lambda はそのような大量のリクエストにも対応できることが確認できるだろう． が，あまりやりすぎると Lambda の無料利用枠を超えて料金が発生してしまうので注意．</p>
<h3 id="スタックの削除" tabindex="-1">スタックの削除 <a class="header-anchor" href="#スタックの削除" aria-label="Permalink to &quot;スタックの削除&quot;">&ZeroWidthSpace;</a></h3>
<p>最後にスタックを削除しよう． スタックを削除するには，次のコマンドを実行すればよい．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cdk</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">destroy</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cdk</span><span style="color: #24292E"> </span><span style="color: #032F62">destroy</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><h2 id="dynamodb-ハンズオン" tabindex="-1">DynamoDB ハンズオン <a class="header-anchor" href="#dynamodb-ハンズオン" aria-label="Permalink to &quot;DynamoDB ハンズオン&quot;">&ZeroWidthSpace;</a></h2>
<p>続いて， DynamoDB の簡単なチュートリアルをやってみよう． ハンズオンのソースコードは GitHub の <a href="https://github.com/andatoshiki/toshiki-notebooktree/main/handson/serverless/dynamodb" target="_blank" rel="noreferrer">/handson/serverless/dynamodb</a> に置いてある．</p>
<p>このハンズオンで使用するアプリケーションのスケッチを <a href="#fig:dynamodb_deploy">figure_title</a> に示す． STEP 1 では，AWS CDK を使用して DynamoDB のテーブルを初期化し，デプロイする． 続いて STEP 2 では， API を使用してデータベースのデータの書き込み・読み出し・削除などの操作を練習する．</p>
<p><img src="./assets/handson-serverless/dynamodb_deploy.png" alt="DynamoDB チュートリアルの概要"></p>
<p>このハンズオンは，基本的に <a href="https://aws.amazon.com/free/?all-free-tier.sort-by=item.additionalFields.SortRank&amp;all-free-tier.sort-order=asc" target="_blank" rel="noreferrer">AWS DynamoDB の無料枠</a> の範囲内で実行できる．</p>
<p><a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/serverless/dynamodb/app.py" target="_blank" rel="noreferrer">handson/serverless/dynamodb/app.py</a> にデプロイするプログラムが書かれている． 中身を見てみよう．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">class</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50">SimpleDynamoDb</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">core</span><span style="color: #ADBAC7">.</span><span style="color: #6CB6FF">Stack</span><span style="color: #ADBAC7">):</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">def</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">__init__</span><span style="color: #ADBAC7">(self, scope: core.App, name: </span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">, </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">kwargs) -&gt; </span><span style="color: #6CB6FF">None</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #6CB6FF">super</span><span style="color: #ADBAC7">().</span><span style="color: #6CB6FF">__init__</span><span style="color: #ADBAC7">(scope, name, </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">kwargs)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        table </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ddb.Table(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;SimpleTable&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">partition_key</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ddb.Attribute(</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">name</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;item_id&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">type</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ddb.AttributeType.</span><span style="color: #6CB6FF">STRING</span></span>
<span class="line"><span style="color: #ADBAC7">            ),</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">billing_mode</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ddb.BillingMode.</span><span style="color: #6CB6FF">PAY_PER_REQUEST</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">removal_policy</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">core.RemovalPolicy.</span><span style="color: #6CB6FF">DESTROY</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">class</span><span style="color: #24292E"> </span><span style="color: #6F42C1">SimpleDynamoDb</span><span style="color: #24292E">(</span><span style="color: #6F42C1">core</span><span style="color: #24292E">.</span><span style="color: #6F42C1">Stack</span><span style="color: #24292E">):</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">def</span><span style="color: #24292E"> </span><span style="color: #005CC5">__init__</span><span style="color: #24292E">(self, scope: core.App, name: </span><span style="color: #005CC5">str</span><span style="color: #24292E">, </span><span style="color: #D73A49">**</span><span style="color: #24292E">kwargs) -&gt; </span><span style="color: #005CC5">None</span><span style="color: #24292E">:</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #005CC5">super</span><span style="color: #24292E">().</span><span style="color: #005CC5">__init__</span><span style="color: #24292E">(scope, name, </span><span style="color: #D73A49">**</span><span style="color: #24292E">kwargs)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        table </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ddb.Table(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;SimpleTable&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">partition_key</span><span style="color: #D73A49">=</span><span style="color: #24292E">ddb.Attribute(</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">name</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;item_id&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">type</span><span style="color: #D73A49">=</span><span style="color: #24292E">ddb.AttributeType.</span><span style="color: #005CC5">STRING</span></span>
<span class="line"><span style="color: #24292E">            ),</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">billing_mode</span><span style="color: #D73A49">=</span><span style="color: #24292E">ddb.BillingMode.</span><span style="color: #005CC5">PAY_PER_REQUEST</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">removal_policy</span><span style="color: #D73A49">=</span><span style="color: #24292E">core.RemovalPolicy.</span><span style="color: #005CC5">DESTROY</span></span>
<span class="line"><span style="color: #24292E">        )</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br></div></div><p>このコードで，最低限の設定がなされた空の DynamoDB テーブルが作成される． それぞれのパラメータの意味を簡単に解説しよう．</p>
<ul>
<li>
<p><code>partition_key</code>: すべての DynamoDB テーブルには Partition key が定義されていなければならない． Partition key とは，テーブル内の要素 (レコード) ごとに存在する固有の ID のことである． 同一の Partition key をもった要素がテーブルの中に二つ以上存在することはできない (注: Sort Key を使用している場合は除く．詳しくは <a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.CoreComponents.html" target="_blank" rel="noreferrer">公式ドキュメンテーション &quot;Core Components of Amazon DynamoDB&quot;</a> 参照)． また， Partition key が定義されていない要素はテーブルの中に存在することはできない． ここでは， Partition key に <code>item_id</code> という名前をつけている．</p>
</li>
<li>
<p><code>billing_mode</code>: <code>ddb.BillingMode.PAY_PER_REQUEST</code> を指定することで， <a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.ReadWriteCapacityMode.html#HowItWorks.OnDemand" target="_blank" rel="noreferrer">On-demand Capacity Mode</a> の DynamoDB が作成される． ほかに <code>PROVISIONED</code> というモードがあるが，これはかなり高度なケースを除いて使用しないだろう．</p>
</li>
<li>
<p><code>removal_policy</code>: CloudFormation のスタックが消去されたときに， DynamoDB も一緒に消去されるかどうかを指定する． このコードでは <code>DESTROY</code> を選んでいるので，すべて消去される． ほかのオプションを選択すると，スタックを消去しても DynamoDB のバックアップを残す，などの動作を定義することができる．</p>
</li>
</ul>
<h3 id="デプロイ-1" tabindex="-1">デプロイ <a class="header-anchor" href="#デプロイ-1" aria-label="Permalink to &quot;デプロイ&quot;">&ZeroWidthSpace;</a></h3>
<p>デプロイの手順は，これまでのハンズオンとほとんど共通である． ここでは，コマンドのみ列挙する (<code>#</code> で始まる行はコメントである)． シークレットキーの設定も忘れずに ( (#aws_cli_install))．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390"># プロジェクトのディレクトリに移動</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cd</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">handson/serverless/dynamodb</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># venv を作成し，依存ライブラリのインストールを行う</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python3</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-m</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">venv</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.env</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">source</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.env/bin/activate</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">pip</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">install</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-r</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">requirements.txt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># デプロイを実行</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cdk</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">deploy</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D"># プロジェクトのディレクトリに移動</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cd</span><span style="color: #24292E"> </span><span style="color: #032F62">handson/serverless/dynamodb</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># venv を作成し，依存ライブラリのインストールを行う</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python3</span><span style="color: #24292E"> </span><span style="color: #005CC5">-m</span><span style="color: #24292E"> </span><span style="color: #032F62">venv</span><span style="color: #24292E"> </span><span style="color: #032F62">.env</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">source</span><span style="color: #24292E"> </span><span style="color: #032F62">.env/bin/activate</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">pip</span><span style="color: #24292E"> </span><span style="color: #032F62">install</span><span style="color: #24292E"> </span><span style="color: #005CC5">-r</span><span style="color: #24292E"> </span><span style="color: #032F62">requirements.txt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># デプロイを実行</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cdk</span><span style="color: #24292E"> </span><span style="color: #032F62">deploy</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br></div></div><p>デプロイのコマンドが無事に実行されれば， <a href="#handson_04_dynamodb_cdk_output">figure_title</a> のような出力が得られるはずである． ここで表示されている <code>SimpleDynamoDb.TableName = XXXX</code> の XXXX の文字列は後で使うのでメモしておこう．</p>
<p><img src="./assets/handson-serverless/handson_04_dynamodb_cdk_output.png" alt="CDKデプロイ実行後の出力"></p>
<p>AWS コンソールにログインして，デプロイされたスタックを確認してみよう． コンソールから， DynamoDB のページに行き，左のメニューバーから &quot;Tables&quot; を選択する． すると， <a href="#handson_04_dynamodb_table_list">figure_title</a> のような画面からテーブルの一覧が確認できる．</p>
<p><img src="./assets/handson-serverless/dynamodb_table_list.png" alt="DynamoDB のコンソール (テーブルの一覧)"></p>
<p>今回のアプリケーションで作成したのが <code>SimpleDynamoDb</code> で始まるランダムな名前のついたテーブルだ． テーブルの名前をクリックして，詳細を見てみる． すると <a href="#handson_04_dynamodb_table_detail">figure_title</a> のような画面が表示されるはずだ． &quot;Items&quot; のタブをクリックすると，テーブルの中のレコードを確認できる． 現時点ではなにもデータを書き込んでいないので，空である．</p>
<p><img src="./assets/handson-serverless/dynamodb_table_detail.png" alt="DynamoDB のコンソール (テーブルの詳細画面)"></p>
<h3 id="データの読み書き" tabindex="-1">データの読み書き <a class="header-anchor" href="#データの読み書き" aria-label="Permalink to &quot;データの読み書き&quot;">&ZeroWidthSpace;</a></h3>
<p>それでは， <a href="#sec:serverless_dynamodb_deploy">デプロイ</a> で作ったテーブルを使ってデータの読み書きを実践してみよう． ここでは Python と <a href="https://boto3.amazonaws.com/v1/documentation/api/latest/index.html" target="_blank" rel="noreferrer">boto3</a> ライブラリを用いた方法を紹介する．</p>
<p>まずは，テーブルに新しい要素を追加してみよう． ハンズオンのディレクトリにある <a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/serverless/dynamodb/simple_write.py" target="_blank" rel="noreferrer">simple_write.py</a> を開いてみよう． 中には次のような関数が書かれている．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> boto3</span></span>
<span class="line"><span style="color: #F47067">from</span><span style="color: #ADBAC7"> uuid </span><span style="color: #F47067">import</span><span style="color: #ADBAC7"> uuid4</span></span>
<span class="line"><span style="color: #ADBAC7">ddb </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> boto3.resource(</span><span style="color: #96D0FF">&#39;dynamodb&#39;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F47067">def</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">write_item</span><span style="color: #ADBAC7">(table_name):</span></span>
<span class="line"><span style="color: #ADBAC7">    table </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ddb.Table(table_name)</span></span>
<span class="line"><span style="color: #ADBAC7">    table.put_item(</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">Item</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">{</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #96D0FF">&#39;item_id&#39;</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">(uuid4()),</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #96D0FF">&#39;first_name&#39;</span><span style="color: #ADBAC7">: </span><span style="color: #96D0FF">&#39;John&#39;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #96D0FF">&#39;last_name&#39;</span><span style="color: #ADBAC7">: </span><span style="color: #96D0FF">&#39;Doe&#39;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #96D0FF">&#39;age&#39;</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">25</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        }</span></span>
<span class="line"><span style="color: #ADBAC7">    )</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> boto3</span></span>
<span class="line"><span style="color: #D73A49">from</span><span style="color: #24292E"> uuid </span><span style="color: #D73A49">import</span><span style="color: #24292E"> uuid4</span></span>
<span class="line"><span style="color: #24292E">ddb </span><span style="color: #D73A49">=</span><span style="color: #24292E"> boto3.resource(</span><span style="color: #032F62">&#39;dynamodb&#39;</span><span style="color: #24292E">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D73A49">def</span><span style="color: #24292E"> </span><span style="color: #6F42C1">write_item</span><span style="color: #24292E">(table_name):</span></span>
<span class="line"><span style="color: #24292E">    table </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ddb.Table(table_name)</span></span>
<span class="line"><span style="color: #24292E">    table.put_item(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">Item</span><span style="color: #D73A49">=</span><span style="color: #24292E">{</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #032F62">&#39;item_id&#39;</span><span style="color: #24292E">: </span><span style="color: #005CC5">str</span><span style="color: #24292E">(uuid4()),</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #032F62">&#39;first_name&#39;</span><span style="color: #24292E">: </span><span style="color: #032F62">&#39;John&#39;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #032F62">&#39;last_name&#39;</span><span style="color: #24292E">: </span><span style="color: #032F62">&#39;Doe&#39;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #032F62">&#39;age&#39;</span><span style="color: #24292E">: </span><span style="color: #005CC5">25</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        }</span></span>
<span class="line"><span style="color: #24292E">    )</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br></div></div><p>コードを上から読んでいくと，まず最初に boto3 ライブラリをインポートし， <code>dynamodb</code> のリソースを呼び出している． <code>write_item()</code> 関数は， DynamoDB のテーブルの名前 (上で見た SimpleDynamoDb-XXXX) を引数として受け取る． そして， <code>put_item()</code> メソッドを呼ぶことで，新しいアイテムを DB に書き込んでいる． アイテムには <code>item_id</code>, <code>first_name</code>, <code>last_name</code>, <code>age</code> の 4 つの属性が定義されている． ここで， <code>item_id</code> は先ほど説明した Partition key に相当しており， <a href="https://en.wikipedia.org/wiki/Universally_unique_identifier" target="_blank" rel="noreferrer">UUID4</a> を用いたランダムな文字列を割り当てている．</p>
<p>では， <code>simple_write.py</code> を実行してみよう． &quot;XXXX&quot; の部分を自分がデプロイしたテーブルの名前 (<code>SimpleDynamoDb</code> で始まる文字列) に置き換えたうえで，次のコマンドを実行する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">simple_write.py</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">XXXX</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python</span><span style="color: #24292E"> </span><span style="color: #032F62">simple_write.py</span><span style="color: #24292E"> </span><span style="color: #032F62">XXXX</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>新しい要素が正しく書き込めたか， AWS コンソールから確認してみよう． <a href="#handson_04_dynamodb_table_detail">figure_title</a> と同じ手順で，テーブルの中身の要素の一覧を表示する． すると <a href="#fig:dynamodb_table_new_item">figure_title</a> のように，期待通り新しい要素が見つかるだろう．</p>
<p><img src="./assets/handson-serverless/dynamodb_table_new_item.png" alt="DynamoDB に新しい要素が追加されたことを確認"></p>
<p>boto3 を使ってテーブルから要素を読みだすことも可能である． ハンズオンのディレクトリにある <a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/serverless/dynamodb/simple_read.py" target="_blank" rel="noreferrer">simple_read.py</a> を見てみよう．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> boto3</span></span>
<span class="line"><span style="color: #ADBAC7">ddb </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> boto3.resource(</span><span style="color: #96D0FF">&#39;dynamodb&#39;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F47067">def</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">scan_table</span><span style="color: #ADBAC7">(table_name):</span></span>
<span class="line"><span style="color: #ADBAC7">    table </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ddb.Table(table_name)</span></span>
<span class="line"><span style="color: #ADBAC7">    items </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> table.scan().get(</span><span style="color: #96D0FF">&quot;Items&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">print</span><span style="color: #ADBAC7">(items)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> boto3</span></span>
<span class="line"><span style="color: #24292E">ddb </span><span style="color: #D73A49">=</span><span style="color: #24292E"> boto3.resource(</span><span style="color: #032F62">&#39;dynamodb&#39;</span><span style="color: #24292E">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D73A49">def</span><span style="color: #24292E"> </span><span style="color: #6F42C1">scan_table</span><span style="color: #24292E">(table_name):</span></span>
<span class="line"><span style="color: #24292E">    table </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ddb.Table(table_name)</span></span>
<span class="line"><span style="color: #24292E">    items </span><span style="color: #D73A49">=</span><span style="color: #24292E"> table.scan().get(</span><span style="color: #032F62">&quot;Items&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">print</span><span style="color: #24292E">(items)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br></div></div><p><code>table.scan().get(&quot;Items&quot;)</code> によって，テーブルの中にあるすべての要素を読みだしている．</p>
<p>次のコマンドで，このスクリプトを実行してみよう (&quot;XXXX&quot; の部分を正しく置き換えることを忘れずに）．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">simple_read.py</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">XXXX</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python</span><span style="color: #24292E"> </span><span style="color: #032F62">simple_read.py</span><span style="color: #24292E"> </span><span style="color: #032F62">XXXX</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>先ほど書き込んだ要素が出力されることを確認しよう．</p>
<h3 id="大量のデータの読み書き" tabindex="-1">大量のデータの読み書き <a class="header-anchor" href="#大量のデータの読み書き" aria-label="Permalink to &quot;大量のデータの読み書き&quot;">&ZeroWidthSpace;</a></h3>
<p>DynamoDB の利点は，最初に述べたとおり，負荷に応じて自在にその処理能力を拡大できる点である．</p>
<p>そこで，ここでは一度に大量のデータを書き込む場合をシミュレートしてみよう． <a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/serverless/dynamodb/batch_rw.py" target="_blank" rel="noreferrer">batch_rw.py</a> に，一度に大量の書き込みを実行するためのプログラムが書いてある．</p>
<p>次のコマンドを実行してみよう (XXXX は自分のテーブルの名前に置き換える)．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">batch_rw.py</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">XXXX</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">write</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">1000</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python</span><span style="color: #24292E"> </span><span style="color: #032F62">batch_rw.py</span><span style="color: #24292E"> </span><span style="color: #032F62">XXXX</span><span style="color: #24292E"> </span><span style="color: #032F62">write</span><span style="color: #24292E"> </span><span style="color: #005CC5">1000</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>このコマンドを実行することで，ランダムなデータが 1000 個データベースに書き込まれる．</p>
<p>さらに，データベースの検索をかけてみよう． 今回書き込んだデータには <code>age</code> という属性に 1 から 50 のランダムな整数が割り当てられている． <code>age</code> が 2 以下であるような要素だけを検索し拾ってくるには，次のコマンドを実行すればよい．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">batch_rw.py</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">XXXX</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">search_under_age</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">2</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python</span><span style="color: #24292E"> </span><span style="color: #032F62">batch_rw.py</span><span style="color: #24292E"> </span><span style="color: #032F62">XXXX</span><span style="color: #24292E"> </span><span style="color: #032F62">search_under_age</span><span style="color: #24292E"> </span><span style="color: #005CC5">2</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>上の 2 つのコマンドを何回か繰り返し実行してみて，データベースに負荷をかけてみよう． とくに大きな遅延なく結果が返ってくることが確認できるだろう．</p>
<h3 id="スタックの削除-1" tabindex="-1">スタックの削除 <a class="header-anchor" href="#スタックの削除-1" aria-label="Permalink to &quot;スタックの削除&quot;">&ZeroWidthSpace;</a></h3>
<p>DynamoDB で十分に遊ぶことができたら，忘れずにスタックを削除しよう．</p>
<p>これまでのハンズオンと同様，スタックを削除するには，次のコマンドを実行すればよい．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cdk</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">destroy</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cdk</span><span style="color: #24292E"> </span><span style="color: #032F62">destroy</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><h2 id="s3-ハンズオン" tabindex="-1">S3 ハンズオン <a class="header-anchor" href="#s3-ハンズオン" aria-label="Permalink to &quot;S3 ハンズオン&quot;">&ZeroWidthSpace;</a></h2>
<p>最後に， S3 の簡単なチュートリアルを紹介する． ハンズオンのソースコードは GitHub の <a href="https://github.com/andatoshiki/toshiki-notebooktree/main/handson/serverless/s3" target="_blank" rel="noreferrer">handson/serverless/s3</a> に置いてある．</p>
<p><a href="#fig:s3_deploy">figure_title</a> が今回提供する S3 チュートリアルの概要である． STEP 1 として， AWS CDK を用いて S3 に新しい空のバケット (Bucket) を作成する． 続いて STEP 2 では，データのアップロード・ダウンロードの方法を解説する．</p>
<p><img src="./assets/handson-serverless/s3_deploy.png" alt="S3 チュートリアルの概要"></p>
<p>このハンズオンは，基本的に <a href="https://aws.amazon.com/free/?all-free-tier.sort-by=item.additionalFields.SortRank&amp;all-free-tier.sort-order=asc" target="_blank" rel="noreferrer">S3 の無料枠</a> の範囲内で実行することができる．</p>
<p><a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/serverless/s3/app.py" target="_blank" rel="noreferrer">app.py</a> にデプロイするプログラムが書かれている． 中身を見てみよう．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">class</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50">SimpleS3</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">core</span><span style="color: #ADBAC7">.</span><span style="color: #6CB6FF">Stack</span><span style="color: #ADBAC7">):</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">def</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">__init__</span><span style="color: #ADBAC7">(self, scope: core.App, name: </span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">, </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">kwargs) -&gt; </span><span style="color: #6CB6FF">None</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #6CB6FF">super</span><span style="color: #ADBAC7">().</span><span style="color: #6CB6FF">__init__</span><span style="color: #ADBAC7">(scope, name, </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">kwargs)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390"># S3 bucket to store data</span></span>
<span class="line"><span style="color: #ADBAC7">        bucket </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> s3.Bucket(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;bucket&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">removal_policy</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">core.RemovalPolicy.</span><span style="color: #6CB6FF">DESTROY</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">auto_delete_objects</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">True</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">class</span><span style="color: #24292E"> </span><span style="color: #6F42C1">SimpleS3</span><span style="color: #24292E">(</span><span style="color: #6F42C1">core</span><span style="color: #24292E">.</span><span style="color: #6F42C1">Stack</span><span style="color: #24292E">):</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">def</span><span style="color: #24292E"> </span><span style="color: #005CC5">__init__</span><span style="color: #24292E">(self, scope: core.App, name: </span><span style="color: #005CC5">str</span><span style="color: #24292E">, </span><span style="color: #D73A49">**</span><span style="color: #24292E">kwargs) -&gt; </span><span style="color: #005CC5">None</span><span style="color: #24292E">:</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #005CC5">super</span><span style="color: #24292E">().</span><span style="color: #005CC5">__init__</span><span style="color: #24292E">(scope, name, </span><span style="color: #D73A49">**</span><span style="color: #24292E">kwargs)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D"># S3 bucket to store data</span></span>
<span class="line"><span style="color: #24292E">        bucket </span><span style="color: #D73A49">=</span><span style="color: #24292E"> s3.Bucket(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;bucket&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">removal_policy</span><span style="color: #D73A49">=</span><span style="color: #24292E">core.RemovalPolicy.</span><span style="color: #005CC5">DESTROY</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">auto_delete_objects</span><span style="color: #D73A49">=</span><span style="color: #005CC5">True</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        )</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br></div></div><p><code>s3.Bucket()</code> を呼ぶことによって空のバケットが新規に作成される． 上記のコードだと，バケットの名前は自動生成される． もし，自分の指定した名前を与えたい場合は， <code>bucket_name</code> というパラメータを指定すればよい． その際， バケットの名前はユニークでなければならない (i.e. AWS のデプロイが行われるリージョン内で名前の重複がない) 点に注意しよう． もし，同じ名前のバケットが既に存在する場合はエラーが返ってくる．</p>
<p>デフォルトでは， CloudFormation スタックが削除されたとき， S3 バケットとその中に保存されたファイルは削除されない． これは，大切なデータを誤って消してしまうことを防止するための安全策である． <code>cdk destroy</code> を実行したときにバケットも含めてすべて削除されるようにするには， <code>removal_policy=core.RemovalPolicy.DESTROY, auto_delete_objects=True</code> とパラメータを設定する． 結果もよく理解したうえで，自分の用途にあった適切なパラメータを設定しよう．</p>
<h3 id="デプロイ-2" tabindex="-1">デプロイ <a class="header-anchor" href="#デプロイ-2" aria-label="Permalink to &quot;デプロイ&quot;">&ZeroWidthSpace;</a></h3>
<p>デプロイの手順は，これまでのハンズオンとほとんど共通である． ここでは，コマンドのみ列挙する (<code>#</code> で始まる行はコメントである)． シークレットキーの設定も忘れずに ( (#aws_cli_install))．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390"># プロジェクトのディレクトリに移動</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cd</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">handson/serverless/s3</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># venv を作成し，依存ライブラリのインストールを行う</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python3</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-m</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">venv</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.env</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">source</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.env/bin/activate</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">pip</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">install</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-r</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">requirements.txt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># デプロイを実行</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cdk</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">deploy</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D"># プロジェクトのディレクトリに移動</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cd</span><span style="color: #24292E"> </span><span style="color: #032F62">handson/serverless/s3</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># venv を作成し，依存ライブラリのインストールを行う</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python3</span><span style="color: #24292E"> </span><span style="color: #005CC5">-m</span><span style="color: #24292E"> </span><span style="color: #032F62">venv</span><span style="color: #24292E"> </span><span style="color: #032F62">.env</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">source</span><span style="color: #24292E"> </span><span style="color: #032F62">.env/bin/activate</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">pip</span><span style="color: #24292E"> </span><span style="color: #032F62">install</span><span style="color: #24292E"> </span><span style="color: #005CC5">-r</span><span style="color: #24292E"> </span><span style="color: #032F62">requirements.txt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># デプロイを実行</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cdk</span><span style="color: #24292E"> </span><span style="color: #032F62">deploy</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br></div></div><p>デプロイを実行すると， <a href="#fig:s3_deploy_output">figure_title</a> のような出力が得られるはずである． ここで表示されている <code>SimpleS3.BucketName = XXXX</code> が，新しく作られたバケットの名前である (今回提供しているコードを使うとランダムな名前がバケットに割り当てられる）． これはあとで使うのでメモしておこう．</p>
<p><img src="./assets/handson-serverless/s3_deploy_output.png" alt="デプロイ実行後の出力"></p>
<h3 id="データの読み書き-1" tabindex="-1">データの読み書き <a class="header-anchor" href="#データの読み書き-1" aria-label="Permalink to &quot;データの読み書き&quot;">&ZeroWidthSpace;</a></h3>
<p>スタックのデプロイが完了したら，早速バケットにデータをアップロードしてみよう．</p>
<p>まずは，以下のコマンドを実行して， <code>tmp.txt</code> という仮のファイルを生成する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">echo</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;Hello world!&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">&gt;&gt;</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">tmp.txt</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">echo</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;Hello world!&quot;</span><span style="color: #24292E"> </span><span style="color: #D73A49">&gt;&gt;</span><span style="color: #24292E"> </span><span style="color: #032F62">tmp.txt</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>ハンズオンのディレクトリにある <a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/serverless/s3/simple_s3.py" target="_blank" rel="noreferrer">simple_s3.py</a> に <a href="https://boto3.amazonaws.com/v1/documentation/api/latest/index.html" target="_blank" rel="noreferrer">boto3</a> ライブラリを使用した S3 のファイルのアップロード・ダウンロードのスクリプトが書いてある． <code>simple_s3.py</code> を使って，上で作成した <code>tmp.txt</code> を以下のコマンドによりバケットにアップロードする． <code>XXXX</code> のところは，自分自身のバケットの名前で置き換えること．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">simple_s3.py</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">XXXX</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">upload</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">tmp.txt</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python</span><span style="color: #24292E"> </span><span style="color: #032F62">simple_s3.py</span><span style="color: #24292E"> </span><span style="color: #032F62">XXXX</span><span style="color: #24292E"> </span><span style="color: #032F62">upload</span><span style="color: #24292E"> </span><span style="color: #032F62">tmp.txt</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p><code>simple_s3.py</code> のアップロードを担当している部分を以下に抜粋する．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">def</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">upload_file</span><span style="color: #ADBAC7">(bucket_name, filename, key</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">None</span><span style="color: #ADBAC7">):</span></span>
<span class="line"><span style="color: #ADBAC7">    bucket </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> s3.Bucket(bucket_name)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> key </span><span style="color: #F47067">is</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">None</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">        key </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> os.path.basename(filename)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    bucket.upload_file(filename, key)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">def</span><span style="color: #24292E"> </span><span style="color: #6F42C1">upload_file</span><span style="color: #24292E">(bucket_name, filename, key</span><span style="color: #D73A49">=</span><span style="color: #005CC5">None</span><span style="color: #24292E">):</span></span>
<span class="line"><span style="color: #24292E">    bucket </span><span style="color: #D73A49">=</span><span style="color: #24292E"> s3.Bucket(bucket_name)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">if</span><span style="color: #24292E"> key </span><span style="color: #D73A49">is</span><span style="color: #24292E"> </span><span style="color: #005CC5">None</span><span style="color: #24292E">:</span></span>
<span class="line"><span style="color: #24292E">        key </span><span style="color: #D73A49">=</span><span style="color: #24292E"> os.path.basename(filename)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">    bucket.upload_file(filename, key)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br></div></div><p><code>bucket = s3.Bucket(bucket_name)</code> の行で <code>Bucket()</code> オブジェクトを呼び出している． そして， <code>upload_file()</code> メソッドを呼ぶことでファイルのアップロードを実行している．</p>
<p>S3 においてファイルの識別子として使われるのが <strong>Key</strong> である． これは，従来的なファイルシステムにおけるパス (Path) と相同な概念で，それぞれのファイルに固有な Key が割り当てられる必要がある． Key という呼び方は， S3 が <a href="https://en.wikipedia.org/wiki/Object_storage" target="_blank" rel="noreferrer">Object storage</a> と呼ばれるシステムに立脚していることに由来する． <code>--key</code> のオプションを追加して <code>simple_s3.py</code> を実行することで， Key を指定してアップロードを実行することができる．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">simple_s3.py</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">XXXX</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">upload</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">tmp.txt</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--key</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">a/b/tmp.txt</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python</span><span style="color: #24292E"> </span><span style="color: #032F62">simple_s3.py</span><span style="color: #24292E"> </span><span style="color: #032F62">XXXX</span><span style="color: #24292E"> </span><span style="color: #032F62">upload</span><span style="color: #24292E"> </span><span style="color: #032F62">tmp.txt</span><span style="color: #24292E"> </span><span style="color: #005CC5">--key</span><span style="color: #24292E"> </span><span style="color: #032F62">a/b/tmp.txt</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>ここではアップロードされたファイルに <code>a/b/tmp.txt</code> という Key を割り当てている．</p>
<p>ここまでコマンドを実行し終えたところで，一度 AWS コンソールに行き S3 の中身を確認してみよう． S3 のコンソールに行くと，バケットの一覧が見つかるはずである． その中から， <code>simples3-bucket</code> から始まるランダムな名前のついたバケットを探し，クリックする． するとバケットの中に含まれるファイルの一覧が表示される (<a href="#fig:s3_bucket_filelist">figure_title</a>)．</p>
<p><img src="./assets/handson-serverless/s3_bucket_filelist.png" alt="S3 バケットの中のファイル一覧"></p>
<p>ここで実行した 2 つのコマンドによって， <code>tmp.txt</code> というファイルと， <code>a/b/tmp.txt</code> というファイルが見つかることに注目しよう． 従来的なファイルシステムと似た体験を提供するため， S3 では Key が <strong>&quot;/&quot; (スラッシュ)</strong> によって区切られていた場合，<strong>ツリー状の階層構造</strong>によってファイルを管理することができる．</p>
<p>オブジェクトストレージには本来ディレクトリという概念はない． 上で紹介した &quot;/&quot; による階層づけはあくまでユーザー体験向上の目的のお化粧的な機能である．</p>
<p>次に，バケットからファイルのダウンロードを実行してみよう． <code>simple_s3.py</code> を使って，以下のコマンドを実行すればよい． <code>XXXX</code> のところは，自分自身のバケットの名前で置き換えること．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">simple_s3.py</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">XXXX</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">download</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">tmp.txt</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python</span><span style="color: #24292E"> </span><span style="color: #032F62">simple_s3.py</span><span style="color: #24292E"> </span><span style="color: #032F62">XXXX</span><span style="color: #24292E"> </span><span style="color: #032F62">download</span><span style="color: #24292E"> </span><span style="color: #032F62">tmp.txt</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p><code>simple_s3.py</code> のダウンロードを担当している部分を以下に抜粋する．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">def</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">download_file</span><span style="color: #ADBAC7">(bucket_name, key, filename</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">None</span><span style="color: #ADBAC7">):</span></span>
<span class="line"><span style="color: #ADBAC7">    bucket </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> s3.Bucket(bucket_name)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> filename </span><span style="color: #F47067">is</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">None</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">        filename </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> os.path.basename(key)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    bucket.download_file(key, filename)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">def</span><span style="color: #24292E"> </span><span style="color: #6F42C1">download_file</span><span style="color: #24292E">(bucket_name, key, filename</span><span style="color: #D73A49">=</span><span style="color: #005CC5">None</span><span style="color: #24292E">):</span></span>
<span class="line"><span style="color: #24292E">    bucket </span><span style="color: #D73A49">=</span><span style="color: #24292E"> s3.Bucket(bucket_name)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">if</span><span style="color: #24292E"> filename </span><span style="color: #D73A49">is</span><span style="color: #24292E"> </span><span style="color: #005CC5">None</span><span style="color: #24292E">:</span></span>
<span class="line"><span style="color: #24292E">        filename </span><span style="color: #D73A49">=</span><span style="color: #24292E"> os.path.basename(key)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">    bucket.download_file(key, filename)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br></div></div><p>S3 からのダウンロードはシンプルで， <code>download_file()</code> メソッドを使って，ダウンロードしたい対象の Key を指定すればよい． ローカルのコンピュータでの保存先のパスを 2 個目の引数として渡している．</p>
<h3 id="スタックの削除-2" tabindex="-1">スタックの削除 <a class="header-anchor" href="#スタックの削除-2" aria-label="Permalink to &quot;スタックの削除&quot;">&ZeroWidthSpace;</a></h3>
<p>以上のハンズオンで， S3 の一番基本的な使い方を紹介した． ここまでのハンズオンが理解できたら，忘れずにスタックを削除しよう． これまでのハンズオンと同様，スタックを削除するには，次のコマンドを実行すればよい．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cdk</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">destroy</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cdk</span><span style="color: #24292E"> </span><span style="color: #032F62">destroy</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div>]]></description>
            <content:encoded><![CDATA[<h1 id="hands-on-5-サーバーレス入門" tabindex="-1">Hands-on #5: サーバーレス入門 <a class="header-anchor" href="#hands-on-5-サーバーレス入門" aria-label="Permalink to &quot;Hands-on \#5: サーバーレス入門&quot;">&ZeroWidthSpace;</a></h1>
<p>前章ではサーバーレスアーキテクチャの概要の説明を行った． 本章では，ハンズオン形式でサーバーレスクラウドを実際に動かしながら，具体的な使用方法を学んでいこう． 今回のハンズオンでは Lambda, S3, DynamoDB の三つのサーバーレスクラウドの構成要素に触れていく． それぞれについて，短いチュートリアルを用意してある．</p>
<h2 id="lambda-ハンズオン" tabindex="-1">Lambda ハンズオン <a class="header-anchor" href="#lambda-ハンズオン" aria-label="Permalink to &quot;Lambda ハンズオン&quot;">&ZeroWidthSpace;</a></h2>
<p>まずは， Lambda を実際に動かしてみよう． ハンズオンのソースコードは GitHub の <a href="https://github.com/andatoshiki/toshiki-notebooktree/main/handson/serverless/lambda" target="_blank" rel="noreferrer">handson/serverless/lambda</a> に置いてある．</p>
<p>このハンズオンで使用するアプリケーションのスケッチを <a href="#fig:lambda_deploy">figure_title</a> に示す． STEP 1 では，AWS CDK を使用して Python で書かれたコードを Lambda に登録する． 続いて STEP 2 では， Invoke API を使用して，同時にいくつもの Lambda を起動し，並列な計算を行う． Lambda のワークフローを体験する目的で最小限の設定である．</p>
<p><img src="./assets/handson-serverless/lambda_deploy.png" alt="Lambda チュートリアルの概要"></p>
<p>このハンズオンは，基本的に <a href="https://aws.amazon.com/free/?all-free-tier.sort-by=item.additionalFields.SortRank&amp;all-free-tier.sort-order=asc" target="_blank" rel="noreferrer">AWS Lambda の無料枠</a> の範囲内で実行することができる．</p>
<p><a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/serverless/lambda/app.py" target="_blank" rel="noreferrer">app.py</a> にデプロイするプログラムが書かれている． 中身を見てみよう．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #6CB6FF">FUNC</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;&quot;&quot;</span></span>
<span class="line"><span style="color: #96D0FF">import time</span></span>
<span class="line"><span style="color: #96D0FF">from random import choice, randint</span></span>
<span class="line"><span style="color: #96D0FF">def handler(event, context):</span></span>
<span class="line"><span style="color: #96D0FF">    time.sleep(randint(2,5))</span></span>
<span class="line"><span style="color: #96D0FF">    sushi = [&quot;salmon&quot;, &quot;tuna&quot;, &quot;squid&quot;]</span></span>
<span class="line"><span style="color: #96D0FF">    message = &quot;Welcome to Cloud Sushi. Your order is &quot; + choice(sushi)</span></span>
<span class="line"><span style="color: #96D0FF">    print(message)</span></span>
<span class="line"><span style="color: #96D0FF">    return message</span></span>
<span class="line"><span style="color: #96D0FF">&quot;&quot;&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F47067">class</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50">SimpleLambda</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">core</span><span style="color: #ADBAC7">.</span><span style="color: #6CB6FF">Stack</span><span style="color: #ADBAC7">):</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">def</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">__init__</span><span style="color: #ADBAC7">(self, scope: core.App, name: </span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">, </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">kwargs) -&gt; </span><span style="color: #6CB6FF">None</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #6CB6FF">super</span><span style="color: #ADBAC7">().</span><span style="color: #6CB6FF">__init__</span><span style="color: #ADBAC7">(scope, name, </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">kwargs)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        handler </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> _lambda.Function(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&#39;LambdaHandler&#39;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">runtime</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">_lambda.Runtime.</span><span style="color: #6CB6FF">PYTHON_3_7</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">code</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">_lambda.Code.from_inline(</span><span style="color: #6CB6FF">FUNC</span><span style="color: #ADBAC7">),</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">handler</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;index.handler&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">memory_size</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">128</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">timeout</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">core.Duration.seconds(</span><span style="color: #6CB6FF">10</span><span style="color: #ADBAC7">),</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">dead_letter_queue_enabled</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">True</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #005CC5">FUNC</span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;&quot;&quot;</span></span>
<span class="line"><span style="color: #032F62">import time</span></span>
<span class="line"><span style="color: #032F62">from random import choice, randint</span></span>
<span class="line"><span style="color: #032F62">def handler(event, context):</span></span>
<span class="line"><span style="color: #032F62">    time.sleep(randint(2,5))</span></span>
<span class="line"><span style="color: #032F62">    sushi = [&quot;salmon&quot;, &quot;tuna&quot;, &quot;squid&quot;]</span></span>
<span class="line"><span style="color: #032F62">    message = &quot;Welcome to Cloud Sushi. Your order is &quot; + choice(sushi)</span></span>
<span class="line"><span style="color: #032F62">    print(message)</span></span>
<span class="line"><span style="color: #032F62">    return message</span></span>
<span class="line"><span style="color: #032F62">&quot;&quot;&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D73A49">class</span><span style="color: #24292E"> </span><span style="color: #6F42C1">SimpleLambda</span><span style="color: #24292E">(</span><span style="color: #6F42C1">core</span><span style="color: #24292E">.</span><span style="color: #6F42C1">Stack</span><span style="color: #24292E">):</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">def</span><span style="color: #24292E"> </span><span style="color: #005CC5">__init__</span><span style="color: #24292E">(self, scope: core.App, name: </span><span style="color: #005CC5">str</span><span style="color: #24292E">, </span><span style="color: #D73A49">**</span><span style="color: #24292E">kwargs) -&gt; </span><span style="color: #005CC5">None</span><span style="color: #24292E">:</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #005CC5">super</span><span style="color: #24292E">().</span><span style="color: #005CC5">__init__</span><span style="color: #24292E">(scope, name, </span><span style="color: #D73A49">**</span><span style="color: #24292E">kwargs)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        handler </span><span style="color: #D73A49">=</span><span style="color: #24292E"> _lambda.Function(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&#39;LambdaHandler&#39;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">runtime</span><span style="color: #D73A49">=</span><span style="color: #24292E">_lambda.Runtime.</span><span style="color: #005CC5">PYTHON_3_7</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">code</span><span style="color: #D73A49">=</span><span style="color: #24292E">_lambda.Code.from_inline(</span><span style="color: #005CC5">FUNC</span><span style="color: #24292E">),</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">handler</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;index.handler&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">memory_size</span><span style="color: #D73A49">=</span><span style="color: #005CC5">128</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">timeout</span><span style="color: #D73A49">=</span><span style="color: #24292E">core.Duration.seconds(</span><span style="color: #005CC5">10</span><span style="color: #24292E">),</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">dead_letter_queue_enabled</span><span style="color: #D73A49">=</span><span style="color: #005CC5">True</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        )</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br></div></div><ul>
<li>
<p>ここで， Lambda で実行されるべき関数を定義している． これは非常に単純な関数で，2-5 秒のランダムな時間スリープした後，[&quot;salmon&quot;, &quot;tuna&quot;, &quot;squid&quot;] のいずれかの文字列をランダムに選択し， &quot;Welcome to Cloud Sushi. Your order is XXXX&quot; (XXXX は選ばれた寿司のネタ) というメッセージをリターンする．</p>
</li>
<li>
<p>次に， Lambda に &lt;1&gt; で書いた関数を配置している． パラメータの意味は，文字どおりの意味なので難しくはないが，以下に解説する．</p>
<ul>
<li>
<p><code>runtime=_lambda.Runtime.PYTHON_3_7</code>: ここでは， Python3.7 を使って上記で定義された関数を実行せよ，と指定している． Python3.7 のほかに， Node.js, Java, Ruby, Go などの言語を指定することが可能である．</p>
</li>
<li>
<p><code>code=_lambda.Code.from_inline(FUNC)</code>: 実行されるべき関数が書かれたコードを指定する． ここでは， <code>FUNC=...</code> で定義した文字列を渡しているが，文字列以外にもファイルのパスを渡すことも可能である．</p>
</li>
<li>
<p><code>handler=&quot;index.handler&quot;</code>: これは，コードの中にいくつかのサブ関数が含まれているときに，メインとサブを区別するためのパラメータである． <code>handler</code> という名前の関数をメイン関数として実行せよ，という意味である．</p>
</li>
<li>
<p><code>memory_size=128</code>: メモリーは 128MB を最大で使用することを指定している．</p>
</li>
<li>
<p><code>timeout=core.Duration.seconds(10)</code> タイムアウト時間を 10 秒に設定している． 10 秒以内に関数の実行が終了しなかった場合，エラーが返される．</p>
</li>
<li>
<p><code>dead_letter_queue_enabled=True</code>: アドバンストな設定なので説明は省略する．</p>
</li>
</ul>
</li>
</ul>
<p>上記のプログラムを実行することで， Lambda 関数がクラウド上に作成される． 早速デプロイしてみよう．</p>
<h3 id="デプロイ" tabindex="-1">デプロイ <a class="header-anchor" href="#デプロイ" aria-label="Permalink to &quot;デプロイ&quot;">&ZeroWidthSpace;</a></h3>
<p>デプロイの手順は，これまでのハンズオンとほとんど共通である． ここでは，コマンドのみ列挙する (<code>#</code> で始まる行はコメントである)． それぞれの意味を忘れてしまった場合は，ハンズオン 1, 2 に戻って復習していただきたい． シークレットキーの設定も忘れずに ( (#aws_cli_install))．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390"># プロジェクトのディレクトリに移動</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cd</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">handson/serverless/lambda</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># venv を作成し，依存ライブラリのインストールを行う</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python3</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-m</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">venv</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.env</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">source</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.env/bin/activate</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">pip</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">install</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-r</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">requirements.txt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># デプロイを実行</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cdk</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">deploy</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D"># プロジェクトのディレクトリに移動</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cd</span><span style="color: #24292E"> </span><span style="color: #032F62">handson/serverless/lambda</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># venv を作成し，依存ライブラリのインストールを行う</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python3</span><span style="color: #24292E"> </span><span style="color: #005CC5">-m</span><span style="color: #24292E"> </span><span style="color: #032F62">venv</span><span style="color: #24292E"> </span><span style="color: #032F62">.env</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">source</span><span style="color: #24292E"> </span><span style="color: #032F62">.env/bin/activate</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">pip</span><span style="color: #24292E"> </span><span style="color: #032F62">install</span><span style="color: #24292E"> </span><span style="color: #005CC5">-r</span><span style="color: #24292E"> </span><span style="color: #032F62">requirements.txt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># デプロイを実行</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cdk</span><span style="color: #24292E"> </span><span style="color: #032F62">deploy</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br></div></div><p>デプロイのコマンドが無事に実行されれば， <a href="#handson_04_lambda_cdk_output">figure_title</a> のような出力が得られるはずである． ここで表示されている <code>SimpleLambda.FunctionName = XXXX</code> の XXXX の文字列は後で使うのでメモしておこう．</p>
<p><img src="./assets/handson-serverless/handson_04_lambda_cdk_output.png" alt="CDKデプロイ実行後の出力"></p>
<p>AWS コンソールにログインして，デプロイされたスタックを確認してみよう． コンソールから，Lambda のページに行くと <a href="#handson_04_lambda_console_func_list">figure_title</a> のような画面から Lambda の関数の一覧が確認できる．</p>
<p><img src="./assets/handson-serverless/lambda_console_func_list.png" alt="Lambda コンソール - 関数の一覧"></p>
<p>今回のアプリケーションで作成したのが <code>SimpleLambda</code> で始まるランダムな名前のついた関数だ． 関数の名前をクリックして，詳細を見てみる． すると <a href="#handson_04_lambda_console_func_detail">figure_title</a> のような画面が表示されるはずだ． 先ほどプログラムの中で定義した Python の関数がエディターから確認できる． さらに下の方にスクロールすると，関数の各種設定も確認できる．</p>
<p><img src="./assets/handson-serverless/lambda_console_func_detail.png" alt="Lambda コンソール - 関数の詳細"></p>
<p>Lambda で実行されるコードは， Lambda のコンソール画面 (<a href="#handson_04_lambda_console_func_detail">figure_title</a>) のエディターで編集することもできる． デバッグをするときなどは，こちらを直接いじる方が早い場合もある． その場合は， CDK のコードに行った編集を反映させなおすことを忘れずに．</p>
<h3 id="lambda-関数の実行" tabindex="-1">Lambda 関数の実行 <a class="header-anchor" href="#lambda-関数の実行" aria-label="Permalink to &quot;Lambda 関数の実行&quot;">&ZeroWidthSpace;</a></h3>
<p>それでは，作成した Lambda 関数を実行 (invoke) してみよう． AWS の API を使うことで，関数の実行をスタートすることができる． 今回は， <a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/serverless/lambda/invoke_one.py" target="_blank" rel="noreferrer">handson/serverless/lambda/invoke_one.py</a> に関数を実行するための簡単なプログラムを提供している． 興味のある読者はコードを読んでもらいたい．</p>
<p>以下のコマンドで，Lambda の関数を実行する． コマンドの <code>XXXX</code> の部分は，先ほどデプロイしたときに <code>SimpleLambda.FunctionName = XXXX</code> で得られた XXXX の文字列で置換する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">invoke_one.py</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">XXXX</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python</span><span style="color: #24292E"> </span><span style="color: #032F62">invoke_one.py</span><span style="color: #24292E"> </span><span style="color: #032F62">XXXX</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>すると， <code>&quot;Welcome to Cloud Sushi. Your order is salmon&quot;</code> という出力が得られるはずだ． とてもシンプルではあるが，クラウド上で先ほどの関数が走り，乱数が生成されたうえで，ランダムな寿司ネタが選択されて出力が返されている． このコマンドを何度か打ってみて，実行ごとに異なる寿司ネタが返されることを確認しよう．</p>
<p>さて，このコマンドは，一度につき一回の関数を実行したわけであるが， Lambda の本領は一度に大量のタスクを同時に実行できる点である． そこで，今度は一度に 100 個のタスクを同時に送信してみよう． <a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/serverless/lambda/invoke_many.py" target="_blank" rel="noreferrer">handson/serverless/lambda/invoke_many.py</a> のスクリプトを使用する．</p>
<p>次のコマンドを実行しよう． XXXX の部分は前述と同様に置き換える． 第二引数の <code>100</code> は 100 個のタスクを投入せよ，という意味である．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">invoke_many.py</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">XXXX</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">100</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python</span><span style="color: #24292E"> </span><span style="color: #032F62">invoke_many.py</span><span style="color: #24292E"> </span><span style="color: #032F62">XXXX</span><span style="color: #24292E"> </span><span style="color: #005CC5">100</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>すると次のような出力が得られるはずだ．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #6CB6FF">....................................................................................................</span></span>
<span class="line"><span style="color: #F69D50">Submitted</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">100</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">tasks</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">to</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">Lambda!</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #005CC5">....................................................................................................</span></span>
<span class="line"><span style="color: #6F42C1">Submitted</span><span style="color: #24292E"> </span><span style="color: #005CC5">100</span><span style="color: #24292E"> </span><span style="color: #032F62">tasks</span><span style="color: #24292E"> </span><span style="color: #032F62">to</span><span style="color: #24292E"> </span><span style="color: #032F62">Lambda!</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>実際に，100 個のタスクが同時に実行されていることを確認しよう． <a href="#handson_04_lambda_console_func_detail">figure_title</a> の画面に戻り， &quot;Monitoring&quot; というタブがあるので，それをクリックする． すると， <a href="#handson_04_lambda_console_monitoring">figure_title</a> のようなグラフが表示されるだろう．</p>
<p><img src="./assets/handson-serverless/lambda_console_monitoring.png" alt="Lambda コンソール - 関数の実行のモニタリング"></p>
<p><a href="#handson_04_lambda_console_monitoring">figure_title</a> のグラフの更新には数分かかることがあるので，なにも表示されない場合は少し待つ．</p>
<p><a href="#handson_04_lambda_console_monitoring">figure_title</a> で &quot;Invocations&quot; が関数が何度実行されたかを意味している． たしかに 100 回実行されていることがわかる． さらに， &quot;Concurrent executions&quot; は何個のタスクが同時に行われたかを示している． ここでは 96 となっていることから，96 個のタスクが並列的に実行されたことを意味している (これが 100 とならないのは，タスクの開始のコマンドが送られたのが完全には同タイミングではないことに起因する)．</p>
<p>このように，非常にシンプルではあるが， Lambda を使うことで，同時並列的に処理を実行することのできるクラウドシステムを簡単に作ることができた．</p>
<p>もしこのようなことを従来的な serverful なクラウドで行おうとした場合，クラスターのスケーリングなど多くのコードを書くことに加えて，いろいろなパラメータを調節する必要がある．</p>
<p>興味がある人は，一気に 1000 個などのジョブを投入してみるとよい． Lambda はそのような大量のリクエストにも対応できることが確認できるだろう． が，あまりやりすぎると Lambda の無料利用枠を超えて料金が発生してしまうので注意．</p>
<h3 id="スタックの削除" tabindex="-1">スタックの削除 <a class="header-anchor" href="#スタックの削除" aria-label="Permalink to &quot;スタックの削除&quot;">&ZeroWidthSpace;</a></h3>
<p>最後にスタックを削除しよう． スタックを削除するには，次のコマンドを実行すればよい．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cdk</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">destroy</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cdk</span><span style="color: #24292E"> </span><span style="color: #032F62">destroy</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><h2 id="dynamodb-ハンズオン" tabindex="-1">DynamoDB ハンズオン <a class="header-anchor" href="#dynamodb-ハンズオン" aria-label="Permalink to &quot;DynamoDB ハンズオン&quot;">&ZeroWidthSpace;</a></h2>
<p>続いて， DynamoDB の簡単なチュートリアルをやってみよう． ハンズオンのソースコードは GitHub の <a href="https://github.com/andatoshiki/toshiki-notebooktree/main/handson/serverless/dynamodb" target="_blank" rel="noreferrer">/handson/serverless/dynamodb</a> に置いてある．</p>
<p>このハンズオンで使用するアプリケーションのスケッチを <a href="#fig:dynamodb_deploy">figure_title</a> に示す． STEP 1 では，AWS CDK を使用して DynamoDB のテーブルを初期化し，デプロイする． 続いて STEP 2 では， API を使用してデータベースのデータの書き込み・読み出し・削除などの操作を練習する．</p>
<p><img src="./assets/handson-serverless/dynamodb_deploy.png" alt="DynamoDB チュートリアルの概要"></p>
<p>このハンズオンは，基本的に <a href="https://aws.amazon.com/free/?all-free-tier.sort-by=item.additionalFields.SortRank&amp;all-free-tier.sort-order=asc" target="_blank" rel="noreferrer">AWS DynamoDB の無料枠</a> の範囲内で実行できる．</p>
<p><a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/serverless/dynamodb/app.py" target="_blank" rel="noreferrer">handson/serverless/dynamodb/app.py</a> にデプロイするプログラムが書かれている． 中身を見てみよう．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">class</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50">SimpleDynamoDb</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">core</span><span style="color: #ADBAC7">.</span><span style="color: #6CB6FF">Stack</span><span style="color: #ADBAC7">):</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">def</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">__init__</span><span style="color: #ADBAC7">(self, scope: core.App, name: </span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">, </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">kwargs) -&gt; </span><span style="color: #6CB6FF">None</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #6CB6FF">super</span><span style="color: #ADBAC7">().</span><span style="color: #6CB6FF">__init__</span><span style="color: #ADBAC7">(scope, name, </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">kwargs)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        table </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ddb.Table(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;SimpleTable&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">partition_key</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ddb.Attribute(</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">name</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;item_id&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">type</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ddb.AttributeType.</span><span style="color: #6CB6FF">STRING</span></span>
<span class="line"><span style="color: #ADBAC7">            ),</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">billing_mode</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ddb.BillingMode.</span><span style="color: #6CB6FF">PAY_PER_REQUEST</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">removal_policy</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">core.RemovalPolicy.</span><span style="color: #6CB6FF">DESTROY</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">class</span><span style="color: #24292E"> </span><span style="color: #6F42C1">SimpleDynamoDb</span><span style="color: #24292E">(</span><span style="color: #6F42C1">core</span><span style="color: #24292E">.</span><span style="color: #6F42C1">Stack</span><span style="color: #24292E">):</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">def</span><span style="color: #24292E"> </span><span style="color: #005CC5">__init__</span><span style="color: #24292E">(self, scope: core.App, name: </span><span style="color: #005CC5">str</span><span style="color: #24292E">, </span><span style="color: #D73A49">**</span><span style="color: #24292E">kwargs) -&gt; </span><span style="color: #005CC5">None</span><span style="color: #24292E">:</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #005CC5">super</span><span style="color: #24292E">().</span><span style="color: #005CC5">__init__</span><span style="color: #24292E">(scope, name, </span><span style="color: #D73A49">**</span><span style="color: #24292E">kwargs)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        table </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ddb.Table(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;SimpleTable&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">partition_key</span><span style="color: #D73A49">=</span><span style="color: #24292E">ddb.Attribute(</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">name</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;item_id&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">type</span><span style="color: #D73A49">=</span><span style="color: #24292E">ddb.AttributeType.</span><span style="color: #005CC5">STRING</span></span>
<span class="line"><span style="color: #24292E">            ),</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">billing_mode</span><span style="color: #D73A49">=</span><span style="color: #24292E">ddb.BillingMode.</span><span style="color: #005CC5">PAY_PER_REQUEST</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">removal_policy</span><span style="color: #D73A49">=</span><span style="color: #24292E">core.RemovalPolicy.</span><span style="color: #005CC5">DESTROY</span></span>
<span class="line"><span style="color: #24292E">        )</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br></div></div><p>このコードで，最低限の設定がなされた空の DynamoDB テーブルが作成される． それぞれのパラメータの意味を簡単に解説しよう．</p>
<ul>
<li>
<p><code>partition_key</code>: すべての DynamoDB テーブルには Partition key が定義されていなければならない． Partition key とは，テーブル内の要素 (レコード) ごとに存在する固有の ID のことである． 同一の Partition key をもった要素がテーブルの中に二つ以上存在することはできない (注: Sort Key を使用している場合は除く．詳しくは <a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.CoreComponents.html" target="_blank" rel="noreferrer">公式ドキュメンテーション &quot;Core Components of Amazon DynamoDB&quot;</a> 参照)． また， Partition key が定義されていない要素はテーブルの中に存在することはできない． ここでは， Partition key に <code>item_id</code> という名前をつけている．</p>
</li>
<li>
<p><code>billing_mode</code>: <code>ddb.BillingMode.PAY_PER_REQUEST</code> を指定することで， <a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.ReadWriteCapacityMode.html#HowItWorks.OnDemand" target="_blank" rel="noreferrer">On-demand Capacity Mode</a> の DynamoDB が作成される． ほかに <code>PROVISIONED</code> というモードがあるが，これはかなり高度なケースを除いて使用しないだろう．</p>
</li>
<li>
<p><code>removal_policy</code>: CloudFormation のスタックが消去されたときに， DynamoDB も一緒に消去されるかどうかを指定する． このコードでは <code>DESTROY</code> を選んでいるので，すべて消去される． ほかのオプションを選択すると，スタックを消去しても DynamoDB のバックアップを残す，などの動作を定義することができる．</p>
</li>
</ul>
<h3 id="デプロイ-1" tabindex="-1">デプロイ <a class="header-anchor" href="#デプロイ-1" aria-label="Permalink to &quot;デプロイ&quot;">&ZeroWidthSpace;</a></h3>
<p>デプロイの手順は，これまでのハンズオンとほとんど共通である． ここでは，コマンドのみ列挙する (<code>#</code> で始まる行はコメントである)． シークレットキーの設定も忘れずに ( (#aws_cli_install))．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390"># プロジェクトのディレクトリに移動</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cd</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">handson/serverless/dynamodb</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># venv を作成し，依存ライブラリのインストールを行う</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python3</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-m</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">venv</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.env</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">source</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.env/bin/activate</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">pip</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">install</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-r</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">requirements.txt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># デプロイを実行</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cdk</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">deploy</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D"># プロジェクトのディレクトリに移動</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cd</span><span style="color: #24292E"> </span><span style="color: #032F62">handson/serverless/dynamodb</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># venv を作成し，依存ライブラリのインストールを行う</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python3</span><span style="color: #24292E"> </span><span style="color: #005CC5">-m</span><span style="color: #24292E"> </span><span style="color: #032F62">venv</span><span style="color: #24292E"> </span><span style="color: #032F62">.env</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">source</span><span style="color: #24292E"> </span><span style="color: #032F62">.env/bin/activate</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">pip</span><span style="color: #24292E"> </span><span style="color: #032F62">install</span><span style="color: #24292E"> </span><span style="color: #005CC5">-r</span><span style="color: #24292E"> </span><span style="color: #032F62">requirements.txt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># デプロイを実行</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cdk</span><span style="color: #24292E"> </span><span style="color: #032F62">deploy</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br></div></div><p>デプロイのコマンドが無事に実行されれば， <a href="#handson_04_dynamodb_cdk_output">figure_title</a> のような出力が得られるはずである． ここで表示されている <code>SimpleDynamoDb.TableName = XXXX</code> の XXXX の文字列は後で使うのでメモしておこう．</p>
<p><img src="./assets/handson-serverless/handson_04_dynamodb_cdk_output.png" alt="CDKデプロイ実行後の出力"></p>
<p>AWS コンソールにログインして，デプロイされたスタックを確認してみよう． コンソールから， DynamoDB のページに行き，左のメニューバーから &quot;Tables&quot; を選択する． すると， <a href="#handson_04_dynamodb_table_list">figure_title</a> のような画面からテーブルの一覧が確認できる．</p>
<p><img src="./assets/handson-serverless/dynamodb_table_list.png" alt="DynamoDB のコンソール (テーブルの一覧)"></p>
<p>今回のアプリケーションで作成したのが <code>SimpleDynamoDb</code> で始まるランダムな名前のついたテーブルだ． テーブルの名前をクリックして，詳細を見てみる． すると <a href="#handson_04_dynamodb_table_detail">figure_title</a> のような画面が表示されるはずだ． &quot;Items&quot; のタブをクリックすると，テーブルの中のレコードを確認できる． 現時点ではなにもデータを書き込んでいないので，空である．</p>
<p><img src="./assets/handson-serverless/dynamodb_table_detail.png" alt="DynamoDB のコンソール (テーブルの詳細画面)"></p>
<h3 id="データの読み書き" tabindex="-1">データの読み書き <a class="header-anchor" href="#データの読み書き" aria-label="Permalink to &quot;データの読み書き&quot;">&ZeroWidthSpace;</a></h3>
<p>それでは， <a href="#sec:serverless_dynamodb_deploy">デプロイ</a> で作ったテーブルを使ってデータの読み書きを実践してみよう． ここでは Python と <a href="https://boto3.amazonaws.com/v1/documentation/api/latest/index.html" target="_blank" rel="noreferrer">boto3</a> ライブラリを用いた方法を紹介する．</p>
<p>まずは，テーブルに新しい要素を追加してみよう． ハンズオンのディレクトリにある <a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/serverless/dynamodb/simple_write.py" target="_blank" rel="noreferrer">simple_write.py</a> を開いてみよう． 中には次のような関数が書かれている．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> boto3</span></span>
<span class="line"><span style="color: #F47067">from</span><span style="color: #ADBAC7"> uuid </span><span style="color: #F47067">import</span><span style="color: #ADBAC7"> uuid4</span></span>
<span class="line"><span style="color: #ADBAC7">ddb </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> boto3.resource(</span><span style="color: #96D0FF">&#39;dynamodb&#39;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F47067">def</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">write_item</span><span style="color: #ADBAC7">(table_name):</span></span>
<span class="line"><span style="color: #ADBAC7">    table </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ddb.Table(table_name)</span></span>
<span class="line"><span style="color: #ADBAC7">    table.put_item(</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">Item</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">{</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #96D0FF">&#39;item_id&#39;</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">(uuid4()),</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #96D0FF">&#39;first_name&#39;</span><span style="color: #ADBAC7">: </span><span style="color: #96D0FF">&#39;John&#39;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #96D0FF">&#39;last_name&#39;</span><span style="color: #ADBAC7">: </span><span style="color: #96D0FF">&#39;Doe&#39;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #96D0FF">&#39;age&#39;</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">25</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        }</span></span>
<span class="line"><span style="color: #ADBAC7">    )</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> boto3</span></span>
<span class="line"><span style="color: #D73A49">from</span><span style="color: #24292E"> uuid </span><span style="color: #D73A49">import</span><span style="color: #24292E"> uuid4</span></span>
<span class="line"><span style="color: #24292E">ddb </span><span style="color: #D73A49">=</span><span style="color: #24292E"> boto3.resource(</span><span style="color: #032F62">&#39;dynamodb&#39;</span><span style="color: #24292E">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D73A49">def</span><span style="color: #24292E"> </span><span style="color: #6F42C1">write_item</span><span style="color: #24292E">(table_name):</span></span>
<span class="line"><span style="color: #24292E">    table </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ddb.Table(table_name)</span></span>
<span class="line"><span style="color: #24292E">    table.put_item(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">Item</span><span style="color: #D73A49">=</span><span style="color: #24292E">{</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #032F62">&#39;item_id&#39;</span><span style="color: #24292E">: </span><span style="color: #005CC5">str</span><span style="color: #24292E">(uuid4()),</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #032F62">&#39;first_name&#39;</span><span style="color: #24292E">: </span><span style="color: #032F62">&#39;John&#39;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #032F62">&#39;last_name&#39;</span><span style="color: #24292E">: </span><span style="color: #032F62">&#39;Doe&#39;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #032F62">&#39;age&#39;</span><span style="color: #24292E">: </span><span style="color: #005CC5">25</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        }</span></span>
<span class="line"><span style="color: #24292E">    )</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br></div></div><p>コードを上から読んでいくと，まず最初に boto3 ライブラリをインポートし， <code>dynamodb</code> のリソースを呼び出している． <code>write_item()</code> 関数は， DynamoDB のテーブルの名前 (上で見た SimpleDynamoDb-XXXX) を引数として受け取る． そして， <code>put_item()</code> メソッドを呼ぶことで，新しいアイテムを DB に書き込んでいる． アイテムには <code>item_id</code>, <code>first_name</code>, <code>last_name</code>, <code>age</code> の 4 つの属性が定義されている． ここで， <code>item_id</code> は先ほど説明した Partition key に相当しており， <a href="https://en.wikipedia.org/wiki/Universally_unique_identifier" target="_blank" rel="noreferrer">UUID4</a> を用いたランダムな文字列を割り当てている．</p>
<p>では， <code>simple_write.py</code> を実行してみよう． &quot;XXXX&quot; の部分を自分がデプロイしたテーブルの名前 (<code>SimpleDynamoDb</code> で始まる文字列) に置き換えたうえで，次のコマンドを実行する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">simple_write.py</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">XXXX</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python</span><span style="color: #24292E"> </span><span style="color: #032F62">simple_write.py</span><span style="color: #24292E"> </span><span style="color: #032F62">XXXX</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>新しい要素が正しく書き込めたか， AWS コンソールから確認してみよう． <a href="#handson_04_dynamodb_table_detail">figure_title</a> と同じ手順で，テーブルの中身の要素の一覧を表示する． すると <a href="#fig:dynamodb_table_new_item">figure_title</a> のように，期待通り新しい要素が見つかるだろう．</p>
<p><img src="./assets/handson-serverless/dynamodb_table_new_item.png" alt="DynamoDB に新しい要素が追加されたことを確認"></p>
<p>boto3 を使ってテーブルから要素を読みだすことも可能である． ハンズオンのディレクトリにある <a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/serverless/dynamodb/simple_read.py" target="_blank" rel="noreferrer">simple_read.py</a> を見てみよう．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> boto3</span></span>
<span class="line"><span style="color: #ADBAC7">ddb </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> boto3.resource(</span><span style="color: #96D0FF">&#39;dynamodb&#39;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F47067">def</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">scan_table</span><span style="color: #ADBAC7">(table_name):</span></span>
<span class="line"><span style="color: #ADBAC7">    table </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ddb.Table(table_name)</span></span>
<span class="line"><span style="color: #ADBAC7">    items </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> table.scan().get(</span><span style="color: #96D0FF">&quot;Items&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">print</span><span style="color: #ADBAC7">(items)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> boto3</span></span>
<span class="line"><span style="color: #24292E">ddb </span><span style="color: #D73A49">=</span><span style="color: #24292E"> boto3.resource(</span><span style="color: #032F62">&#39;dynamodb&#39;</span><span style="color: #24292E">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D73A49">def</span><span style="color: #24292E"> </span><span style="color: #6F42C1">scan_table</span><span style="color: #24292E">(table_name):</span></span>
<span class="line"><span style="color: #24292E">    table </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ddb.Table(table_name)</span></span>
<span class="line"><span style="color: #24292E">    items </span><span style="color: #D73A49">=</span><span style="color: #24292E"> table.scan().get(</span><span style="color: #032F62">&quot;Items&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">print</span><span style="color: #24292E">(items)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br></div></div><p><code>table.scan().get(&quot;Items&quot;)</code> によって，テーブルの中にあるすべての要素を読みだしている．</p>
<p>次のコマンドで，このスクリプトを実行してみよう (&quot;XXXX&quot; の部分を正しく置き換えることを忘れずに）．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">simple_read.py</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">XXXX</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python</span><span style="color: #24292E"> </span><span style="color: #032F62">simple_read.py</span><span style="color: #24292E"> </span><span style="color: #032F62">XXXX</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>先ほど書き込んだ要素が出力されることを確認しよう．</p>
<h3 id="大量のデータの読み書き" tabindex="-1">大量のデータの読み書き <a class="header-anchor" href="#大量のデータの読み書き" aria-label="Permalink to &quot;大量のデータの読み書き&quot;">&ZeroWidthSpace;</a></h3>
<p>DynamoDB の利点は，最初に述べたとおり，負荷に応じて自在にその処理能力を拡大できる点である．</p>
<p>そこで，ここでは一度に大量のデータを書き込む場合をシミュレートしてみよう． <a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/serverless/dynamodb/batch_rw.py" target="_blank" rel="noreferrer">batch_rw.py</a> に，一度に大量の書き込みを実行するためのプログラムが書いてある．</p>
<p>次のコマンドを実行してみよう (XXXX は自分のテーブルの名前に置き換える)．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">batch_rw.py</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">XXXX</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">write</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">1000</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python</span><span style="color: #24292E"> </span><span style="color: #032F62">batch_rw.py</span><span style="color: #24292E"> </span><span style="color: #032F62">XXXX</span><span style="color: #24292E"> </span><span style="color: #032F62">write</span><span style="color: #24292E"> </span><span style="color: #005CC5">1000</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>このコマンドを実行することで，ランダムなデータが 1000 個データベースに書き込まれる．</p>
<p>さらに，データベースの検索をかけてみよう． 今回書き込んだデータには <code>age</code> という属性に 1 から 50 のランダムな整数が割り当てられている． <code>age</code> が 2 以下であるような要素だけを検索し拾ってくるには，次のコマンドを実行すればよい．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">batch_rw.py</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">XXXX</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">search_under_age</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">2</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python</span><span style="color: #24292E"> </span><span style="color: #032F62">batch_rw.py</span><span style="color: #24292E"> </span><span style="color: #032F62">XXXX</span><span style="color: #24292E"> </span><span style="color: #032F62">search_under_age</span><span style="color: #24292E"> </span><span style="color: #005CC5">2</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>上の 2 つのコマンドを何回か繰り返し実行してみて，データベースに負荷をかけてみよう． とくに大きな遅延なく結果が返ってくることが確認できるだろう．</p>
<h3 id="スタックの削除-1" tabindex="-1">スタックの削除 <a class="header-anchor" href="#スタックの削除-1" aria-label="Permalink to &quot;スタックの削除&quot;">&ZeroWidthSpace;</a></h3>
<p>DynamoDB で十分に遊ぶことができたら，忘れずにスタックを削除しよう．</p>
<p>これまでのハンズオンと同様，スタックを削除するには，次のコマンドを実行すればよい．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cdk</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">destroy</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cdk</span><span style="color: #24292E"> </span><span style="color: #032F62">destroy</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><h2 id="s3-ハンズオン" tabindex="-1">S3 ハンズオン <a class="header-anchor" href="#s3-ハンズオン" aria-label="Permalink to &quot;S3 ハンズオン&quot;">&ZeroWidthSpace;</a></h2>
<p>最後に， S3 の簡単なチュートリアルを紹介する． ハンズオンのソースコードは GitHub の <a href="https://github.com/andatoshiki/toshiki-notebooktree/main/handson/serverless/s3" target="_blank" rel="noreferrer">handson/serverless/s3</a> に置いてある．</p>
<p><a href="#fig:s3_deploy">figure_title</a> が今回提供する S3 チュートリアルの概要である． STEP 1 として， AWS CDK を用いて S3 に新しい空のバケット (Bucket) を作成する． 続いて STEP 2 では，データのアップロード・ダウンロードの方法を解説する．</p>
<p><img src="./assets/handson-serverless/s3_deploy.png" alt="S3 チュートリアルの概要"></p>
<p>このハンズオンは，基本的に <a href="https://aws.amazon.com/free/?all-free-tier.sort-by=item.additionalFields.SortRank&amp;all-free-tier.sort-order=asc" target="_blank" rel="noreferrer">S3 の無料枠</a> の範囲内で実行することができる．</p>
<p><a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/serverless/s3/app.py" target="_blank" rel="noreferrer">app.py</a> にデプロイするプログラムが書かれている． 中身を見てみよう．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">class</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50">SimpleS3</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">core</span><span style="color: #ADBAC7">.</span><span style="color: #6CB6FF">Stack</span><span style="color: #ADBAC7">):</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">def</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">__init__</span><span style="color: #ADBAC7">(self, scope: core.App, name: </span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">, </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">kwargs) -&gt; </span><span style="color: #6CB6FF">None</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #6CB6FF">super</span><span style="color: #ADBAC7">().</span><span style="color: #6CB6FF">__init__</span><span style="color: #ADBAC7">(scope, name, </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">kwargs)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390"># S3 bucket to store data</span></span>
<span class="line"><span style="color: #ADBAC7">        bucket </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> s3.Bucket(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;bucket&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">removal_policy</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">core.RemovalPolicy.</span><span style="color: #6CB6FF">DESTROY</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">auto_delete_objects</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">True</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">class</span><span style="color: #24292E"> </span><span style="color: #6F42C1">SimpleS3</span><span style="color: #24292E">(</span><span style="color: #6F42C1">core</span><span style="color: #24292E">.</span><span style="color: #6F42C1">Stack</span><span style="color: #24292E">):</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">def</span><span style="color: #24292E"> </span><span style="color: #005CC5">__init__</span><span style="color: #24292E">(self, scope: core.App, name: </span><span style="color: #005CC5">str</span><span style="color: #24292E">, </span><span style="color: #D73A49">**</span><span style="color: #24292E">kwargs) -&gt; </span><span style="color: #005CC5">None</span><span style="color: #24292E">:</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #005CC5">super</span><span style="color: #24292E">().</span><span style="color: #005CC5">__init__</span><span style="color: #24292E">(scope, name, </span><span style="color: #D73A49">**</span><span style="color: #24292E">kwargs)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D"># S3 bucket to store data</span></span>
<span class="line"><span style="color: #24292E">        bucket </span><span style="color: #D73A49">=</span><span style="color: #24292E"> s3.Bucket(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;bucket&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">removal_policy</span><span style="color: #D73A49">=</span><span style="color: #24292E">core.RemovalPolicy.</span><span style="color: #005CC5">DESTROY</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">auto_delete_objects</span><span style="color: #D73A49">=</span><span style="color: #005CC5">True</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        )</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br></div></div><p><code>s3.Bucket()</code> を呼ぶことによって空のバケットが新規に作成される． 上記のコードだと，バケットの名前は自動生成される． もし，自分の指定した名前を与えたい場合は， <code>bucket_name</code> というパラメータを指定すればよい． その際， バケットの名前はユニークでなければならない (i.e. AWS のデプロイが行われるリージョン内で名前の重複がない) 点に注意しよう． もし，同じ名前のバケットが既に存在する場合はエラーが返ってくる．</p>
<p>デフォルトでは， CloudFormation スタックが削除されたとき， S3 バケットとその中に保存されたファイルは削除されない． これは，大切なデータを誤って消してしまうことを防止するための安全策である． <code>cdk destroy</code> を実行したときにバケットも含めてすべて削除されるようにするには， <code>removal_policy=core.RemovalPolicy.DESTROY, auto_delete_objects=True</code> とパラメータを設定する． 結果もよく理解したうえで，自分の用途にあった適切なパラメータを設定しよう．</p>
<h3 id="デプロイ-2" tabindex="-1">デプロイ <a class="header-anchor" href="#デプロイ-2" aria-label="Permalink to &quot;デプロイ&quot;">&ZeroWidthSpace;</a></h3>
<p>デプロイの手順は，これまでのハンズオンとほとんど共通である． ここでは，コマンドのみ列挙する (<code>#</code> で始まる行はコメントである)． シークレットキーの設定も忘れずに ( (#aws_cli_install))．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390"># プロジェクトのディレクトリに移動</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cd</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">handson/serverless/s3</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># venv を作成し，依存ライブラリのインストールを行う</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python3</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-m</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">venv</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.env</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">source</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.env/bin/activate</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">pip</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">install</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-r</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">requirements.txt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># デプロイを実行</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cdk</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">deploy</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D"># プロジェクトのディレクトリに移動</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cd</span><span style="color: #24292E"> </span><span style="color: #032F62">handson/serverless/s3</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># venv を作成し，依存ライブラリのインストールを行う</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python3</span><span style="color: #24292E"> </span><span style="color: #005CC5">-m</span><span style="color: #24292E"> </span><span style="color: #032F62">venv</span><span style="color: #24292E"> </span><span style="color: #032F62">.env</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">source</span><span style="color: #24292E"> </span><span style="color: #032F62">.env/bin/activate</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">pip</span><span style="color: #24292E"> </span><span style="color: #032F62">install</span><span style="color: #24292E"> </span><span style="color: #005CC5">-r</span><span style="color: #24292E"> </span><span style="color: #032F62">requirements.txt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># デプロイを実行</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cdk</span><span style="color: #24292E"> </span><span style="color: #032F62">deploy</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br></div></div><p>デプロイを実行すると， <a href="#fig:s3_deploy_output">figure_title</a> のような出力が得られるはずである． ここで表示されている <code>SimpleS3.BucketName = XXXX</code> が，新しく作られたバケットの名前である (今回提供しているコードを使うとランダムな名前がバケットに割り当てられる）． これはあとで使うのでメモしておこう．</p>
<p><img src="./assets/handson-serverless/s3_deploy_output.png" alt="デプロイ実行後の出力"></p>
<h3 id="データの読み書き-1" tabindex="-1">データの読み書き <a class="header-anchor" href="#データの読み書き-1" aria-label="Permalink to &quot;データの読み書き&quot;">&ZeroWidthSpace;</a></h3>
<p>スタックのデプロイが完了したら，早速バケットにデータをアップロードしてみよう．</p>
<p>まずは，以下のコマンドを実行して， <code>tmp.txt</code> という仮のファイルを生成する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">echo</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;Hello world!&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">&gt;&gt;</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">tmp.txt</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">echo</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;Hello world!&quot;</span><span style="color: #24292E"> </span><span style="color: #D73A49">&gt;&gt;</span><span style="color: #24292E"> </span><span style="color: #032F62">tmp.txt</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>ハンズオンのディレクトリにある <a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/serverless/s3/simple_s3.py" target="_blank" rel="noreferrer">simple_s3.py</a> に <a href="https://boto3.amazonaws.com/v1/documentation/api/latest/index.html" target="_blank" rel="noreferrer">boto3</a> ライブラリを使用した S3 のファイルのアップロード・ダウンロードのスクリプトが書いてある． <code>simple_s3.py</code> を使って，上で作成した <code>tmp.txt</code> を以下のコマンドによりバケットにアップロードする． <code>XXXX</code> のところは，自分自身のバケットの名前で置き換えること．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">simple_s3.py</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">XXXX</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">upload</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">tmp.txt</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python</span><span style="color: #24292E"> </span><span style="color: #032F62">simple_s3.py</span><span style="color: #24292E"> </span><span style="color: #032F62">XXXX</span><span style="color: #24292E"> </span><span style="color: #032F62">upload</span><span style="color: #24292E"> </span><span style="color: #032F62">tmp.txt</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p><code>simple_s3.py</code> のアップロードを担当している部分を以下に抜粋する．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">def</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">upload_file</span><span style="color: #ADBAC7">(bucket_name, filename, key</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">None</span><span style="color: #ADBAC7">):</span></span>
<span class="line"><span style="color: #ADBAC7">    bucket </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> s3.Bucket(bucket_name)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> key </span><span style="color: #F47067">is</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">None</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">        key </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> os.path.basename(filename)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    bucket.upload_file(filename, key)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">def</span><span style="color: #24292E"> </span><span style="color: #6F42C1">upload_file</span><span style="color: #24292E">(bucket_name, filename, key</span><span style="color: #D73A49">=</span><span style="color: #005CC5">None</span><span style="color: #24292E">):</span></span>
<span class="line"><span style="color: #24292E">    bucket </span><span style="color: #D73A49">=</span><span style="color: #24292E"> s3.Bucket(bucket_name)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">if</span><span style="color: #24292E"> key </span><span style="color: #D73A49">is</span><span style="color: #24292E"> </span><span style="color: #005CC5">None</span><span style="color: #24292E">:</span></span>
<span class="line"><span style="color: #24292E">        key </span><span style="color: #D73A49">=</span><span style="color: #24292E"> os.path.basename(filename)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">    bucket.upload_file(filename, key)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br></div></div><p><code>bucket = s3.Bucket(bucket_name)</code> の行で <code>Bucket()</code> オブジェクトを呼び出している． そして， <code>upload_file()</code> メソッドを呼ぶことでファイルのアップロードを実行している．</p>
<p>S3 においてファイルの識別子として使われるのが <strong>Key</strong> である． これは，従来的なファイルシステムにおけるパス (Path) と相同な概念で，それぞれのファイルに固有な Key が割り当てられる必要がある． Key という呼び方は， S3 が <a href="https://en.wikipedia.org/wiki/Object_storage" target="_blank" rel="noreferrer">Object storage</a> と呼ばれるシステムに立脚していることに由来する． <code>--key</code> のオプションを追加して <code>simple_s3.py</code> を実行することで， Key を指定してアップロードを実行することができる．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">simple_s3.py</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">XXXX</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">upload</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">tmp.txt</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--key</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">a/b/tmp.txt</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python</span><span style="color: #24292E"> </span><span style="color: #032F62">simple_s3.py</span><span style="color: #24292E"> </span><span style="color: #032F62">XXXX</span><span style="color: #24292E"> </span><span style="color: #032F62">upload</span><span style="color: #24292E"> </span><span style="color: #032F62">tmp.txt</span><span style="color: #24292E"> </span><span style="color: #005CC5">--key</span><span style="color: #24292E"> </span><span style="color: #032F62">a/b/tmp.txt</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>ここではアップロードされたファイルに <code>a/b/tmp.txt</code> という Key を割り当てている．</p>
<p>ここまでコマンドを実行し終えたところで，一度 AWS コンソールに行き S3 の中身を確認してみよう． S3 のコンソールに行くと，バケットの一覧が見つかるはずである． その中から， <code>simples3-bucket</code> から始まるランダムな名前のついたバケットを探し，クリックする． するとバケットの中に含まれるファイルの一覧が表示される (<a href="#fig:s3_bucket_filelist">figure_title</a>)．</p>
<p><img src="./assets/handson-serverless/s3_bucket_filelist.png" alt="S3 バケットの中のファイル一覧"></p>
<p>ここで実行した 2 つのコマンドによって， <code>tmp.txt</code> というファイルと， <code>a/b/tmp.txt</code> というファイルが見つかることに注目しよう． 従来的なファイルシステムと似た体験を提供するため， S3 では Key が <strong>&quot;/&quot; (スラッシュ)</strong> によって区切られていた場合，<strong>ツリー状の階層構造</strong>によってファイルを管理することができる．</p>
<p>オブジェクトストレージには本来ディレクトリという概念はない． 上で紹介した &quot;/&quot; による階層づけはあくまでユーザー体験向上の目的のお化粧的な機能である．</p>
<p>次に，バケットからファイルのダウンロードを実行してみよう． <code>simple_s3.py</code> を使って，以下のコマンドを実行すればよい． <code>XXXX</code> のところは，自分自身のバケットの名前で置き換えること．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">simple_s3.py</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">XXXX</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">download</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">tmp.txt</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python</span><span style="color: #24292E"> </span><span style="color: #032F62">simple_s3.py</span><span style="color: #24292E"> </span><span style="color: #032F62">XXXX</span><span style="color: #24292E"> </span><span style="color: #032F62">download</span><span style="color: #24292E"> </span><span style="color: #032F62">tmp.txt</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p><code>simple_s3.py</code> のダウンロードを担当している部分を以下に抜粋する．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">def</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">download_file</span><span style="color: #ADBAC7">(bucket_name, key, filename</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">None</span><span style="color: #ADBAC7">):</span></span>
<span class="line"><span style="color: #ADBAC7">    bucket </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> s3.Bucket(bucket_name)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> filename </span><span style="color: #F47067">is</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">None</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">        filename </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> os.path.basename(key)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    bucket.download_file(key, filename)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">def</span><span style="color: #24292E"> </span><span style="color: #6F42C1">download_file</span><span style="color: #24292E">(bucket_name, key, filename</span><span style="color: #D73A49">=</span><span style="color: #005CC5">None</span><span style="color: #24292E">):</span></span>
<span class="line"><span style="color: #24292E">    bucket </span><span style="color: #D73A49">=</span><span style="color: #24292E"> s3.Bucket(bucket_name)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">if</span><span style="color: #24292E"> filename </span><span style="color: #D73A49">is</span><span style="color: #24292E"> </span><span style="color: #005CC5">None</span><span style="color: #24292E">:</span></span>
<span class="line"><span style="color: #24292E">        filename </span><span style="color: #D73A49">=</span><span style="color: #24292E"> os.path.basename(key)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">    bucket.download_file(key, filename)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br></div></div><p>S3 からのダウンロードはシンプルで， <code>download_file()</code> メソッドを使って，ダウンロードしたい対象の Key を指定すればよい． ローカルのコンピュータでの保存先のパスを 2 個目の引数として渡している．</p>
<h3 id="スタックの削除-2" tabindex="-1">スタックの削除 <a class="header-anchor" href="#スタックの削除-2" aria-label="Permalink to &quot;スタックの削除&quot;">&ZeroWidthSpace;</a></h3>
<p>以上のハンズオンで， S3 の一番基本的な使い方を紹介した． ここまでのハンズオンが理解できたら，忘れずにスタックを削除しよう． これまでのハンズオンと同様，スタックを削除するには，次のコマンドを実行すればよい．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cdk</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">destroy</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cdk</span><span style="color: #24292E"> </span><span style="color: #032F62">destroy</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[はじめに ]]></title>
            <link>https://note.toshiki.devdevelopment/aws/</link>
            <guid>https://note.toshiki.devdevelopment/aws/</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="はじめに" tabindex="-1">はじめに <a class="header-anchor" href="#はじめに" aria-label="Permalink to &quot;はじめに&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="本書の目的・内容" tabindex="-1">本書の目的・内容 <a class="header-anchor" href="#本書の目的・内容" aria-label="Permalink to &quot;本書の目的・内容&quot;">&ZeroWidthSpace;</a></h2>
<p>本書は，東京大学計数工学科で 2021 年度 S1/S2 タームに開講されている&quot;システム情報工学特論&quot;の講義資料として作成された．</p>
<p>本書の目的は，クラウドの初心者を対象とし，クラウドの基礎的な知識・概念を解説する． また， Amazon Web Services (以下， AWS) の提供するクラウド環境を実例として，具体的なクラウドの利用方法をハンズオンを通して学ぶ．</p>
<p>とくに，科学・エンジニアリングの学生を対象として，研究などの目的でクラウドを利用するための実践的な手順を紹介する． 知識・理論の説明は最小限に留め，実践を行う中で必要な概念の解説を行う予定である． 読者が今後，研究などでクラウドを利用する際の，足がかりとなれば本書の目的は十分達成されたことになる．</p>
<p>本書は以下のような三部構成になっている．</p>
<table><caption>本書の構成</caption><colgroup><col style="width: 20%" /><col style="width: 40%" /><col style="width: 40%" /></colgroup><thead><tr class="header"><th></th><th>テーマ</th><th>ハンズオン</th></tr></thead><tbody><tr class="odd"><td><p>第一部 (1章-4章)</p></td><td><p>クラウドの基礎</p></td><td><ul><li><p>AWSに自分のサーバーを立ち上げる</p></li></ul></td></tr><tr class="even"><td><p>第二部 (5章-9章)</p></td><td><p>クラウドを活用した機械学習</p></td><td><ul><li><p>AWS と Jupyter を使って始めるディープラーニング</p></li><li><p>スケーラブルな自動質問回答ボットを作る</p></li><li><p>並列化されたハイパーパラメータサーチの実装</p></li></ul></td></tr><tr class="odd"><td><p>第三部 (10章-13章)</p></td><td><p>サーバーレスアーキテクチャ入門</p></td><td><ul><li><p>Lambda, DynamoDB, S3 の演習</p></li><li><p>俳句を投稿する SNS "Bashoutter" を作る</p></li></ul></td></tr></tbody></table>
<p>第一部は，クラウドの基礎となる概念・知識を解説する． セキュリティやネットワークなど，クラウドを利用する上で最低限おさえなければいけないポイントを説明する． ハンズオンでは，はじめての仮想サーバーを AWS に立ち上げる演習を行う．</p>
<p>第二部では，クラウド上で科学計算 (とくに機械学習) を走らせるための入門となる知識・技術を解説する． あわせて， <a href="https://www.docker.com/" target="_blank" rel="noreferrer">Docker</a> とよばれる仮想計算環境の使用方法を紹介する． 一つ目のハンズオンでは， AWS のクラウドで Jupyter Notebook を起動し簡単な機械学習の計算を走らせる課題を実践する． 二つ目のハンズオンでは，深層学習を用いた自然言語処理により，質問に自動で回答を生成するボットを作成する． 最後に，複数台の GPU インスタンスからなるクラスターを起動し，並列に深層学習のハイパーパラメータサーチを行う方法を紹介する．</p>
<p>第三部では，サーバーレスアーキテクチャとよばれる最新のクラウドのアーキテクチャを紹介する． これは，サーバーの処理能力を負荷に応じてより柔軟に拡大・縮小するための概念であり，それ以前 (Serverful としばしばよばれる) と質的に異なる設計思想をクラウドに導入するものである． ハンズオンでは，サーバーレスクラウドの主要なコンポーネントである Lambda, DynamoDB, S3 の演習を提供する． さらに，サーバーレスの技術を使用して簡単な SNS をクラウド上に作成する．</p>
<p>これらの豊富なハンズオンにより， AWS 上にクラウドシステムを開発するための知識と技術が身につくはずである． いずれのハンズオンも，実用性を重視したものになっており，これらをベースにカスタマイズを施すことで様々な応用が可能である．</p>
<h2 id="本書のフィロソフィー" tabindex="-1">本書のフィロソフィー <a class="header-anchor" href="#本書のフィロソフィー" aria-label="Permalink to &quot;本書のフィロソフィー&quot;">&ZeroWidthSpace;</a></h2>
<p>本書のフィロソフィーを一言で表すなら， <strong>&quot;ロケットで宇宙まで飛んでいって一度地球を眺めてみよう！&quot;</strong> である．</p>
<p>どういうことか？</p>
<p>ここでいう&quot;地球&quot;とは，クラウドコンピューティングの全体像のことである． 言うまでもなく，クラウドという技術は非常に広範かつ複雑な概念で，幾多の情報技術・ハードウェア・アルゴリズムが精緻に組み合わさってできた総体である． そして，今日では科学研究から日常のインフラ設備に至るまで，我々の社会の多くの部分がクラウド技術によって支えられている．</p>
<p>ここでいう&quot;ロケット&quot;とはこの講義のことである． この講義では，ロケットに乗って宇宙まで飛び立ち，地球(クラウド)の全体を自身の目で眺めてもらう． その際，ロケットの成り立ちや仕組み (背後にある要素技術やプログラムのソースコード) を深くは問わない． 将来，自分が研究などの目的でクラウドを利用することになった際に，改めて学んでもらえば良い． 本書の目的はむしろ，クラウドの最先端に実際に触れ，そこからどんな景色が見えるか(どんな応用が可能か)を実感してもらうことである．</p>
<p>そのような理由で，本書はクラウドの基礎から応用まで幅広いテーマを取り扱う． 第一部はクラウドの基礎から始め，第二部では一気にレベルアップし機械学習(深層学習)をクラウドで実行する手法を解説する． さらに第三部では，サーバーレス・アーキテクチャというここ数年のうちに確立した全く新しいクラウドの設計について解説する． それぞれで本一冊分以上の内容に相当するものであるが，本書はあえてこれらを一冊にまとめ連続的に俯瞰するという野心的な意図をもって執筆された．</p>
<p>決して楽な搭乗体験ではないかもしれないが，このロケットにしがみついてきてもらえれば，とてもエキサイティングな景色が見られることを約束したい．</p>
<p><img src="./assets/earth_from_earth.jpg" alt="宇宙からみた地球 (Image from NASA https://www.nasa.gov/image-feature/planet-of-clouds)"></p>
<h2 id="aws-アカウント" tabindex="-1">AWS アカウント <a class="header-anchor" href="#aws-アカウント" aria-label="Permalink to &quot;AWS アカウント&quot;">&ZeroWidthSpace;</a></h2>
<p>本書では，ハンズオン形式で AWS のクラウドを実際に動かす演習を提供する． 自分でハンズオンを実行してみたい読者は，各自で AWS のアカウントの作成をしていただく． AWS のアカウントの作成の仕方は巻末付録 ( (#sec:create_aws_account)) に簡単に記載したので，必要に応じて参照していただきたい．</p>
<p>AWS にはいくつかの機能に対して無料利用枠が設定されており，いくつかのハンズオンは無料の範囲内で実行できる． 一方，ほかのハンズオン (とくに機械学習を扱うもの) では数ドル程度のコストが発生する． ハンズオンごとに発生するおおよそのコストについて記述があるので，注意をしながらハンズオンに取り組んでいただきたい．</p>
<p>また，大学などの教育機関における講義で AWS を使用する際は， <a href="https://aws.amazon.com/education/awseducate/" target="_blank" rel="noreferrer">AWS Educate</a> というプログラムを利用することも可能である． これは，講義の担当者が申請を行うことで，受講する学生に対し AWS クレジットが提供されるというプログラムである． AWS Educate を利用することで金銭的な負担なしに AWS を体験することができる． また，講義を経由せず個人でも AWS Educate に参加することも可能である． AWS Educate からは様々な学習教材が提供されているので，ぜひ活用してもらいたい．</p>
<h2 id="環境構築" tabindex="-1">環境構築 <a class="header-anchor" href="#環境構築" aria-label="Permalink to &quot;環境構築&quot;">&ZeroWidthSpace;</a></h2>
<p>本書では， AWS 上にクラウドアプリケーションを展開するハンズオンを実施する． そこで紹介するプログラムを実行するためには，以下の計算機環境が必要である． インストールの方法については，巻末付録 ( (#sec:appendix_settingup)) に記してある． 必要に応じて参照し，環境構築を各自実施していただきたい．</p>
<ul>
<li>
<p><strong>UNIX 系コンソール</strong>: ハンズオンで紹介するコマンドを実行したり， SSH でサーバーにアクセスするため， UNIX 系のコンソール環境が必要である． Mac または Linux のユーザーは， OS に標準搭載のコンソール(ターミナルとも呼ばれる)を使用すればよい． Windows のユーザーは， <a href="https://docs.microsoft.com/en-us/windows/wsl/about" target="_blank" rel="noreferrer">Windows Subsystem for Linux (WSL)</a> を使い， Linux の仮想環境のインストールを推奨する ( (#sec:install_wsl) 参照)．</p>
</li>
<li>
<p><strong>Docker</strong>: 本書では Docker とよばれる仮想計算環境の利用方法を解説する． インストール手順については (#sec:install_docker) を参照のこと．</p>
</li>
<li>
<p><strong>Python</strong>: Version 3.6 以上をインストールする． とくに，ハンズオンでは <code>venv</code> モジュールを使用する． <code>venv</code> の使い方は (#venv_quick_guide) 参照のこと．</p>
</li>
<li>
<p><strong>Node.js</strong>: version 12.0 以上 をインストールする．</p>
</li>
<li>
<p><strong>AWS CLI</strong>: <a href="https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html" target="_blank" rel="noreferrer">Version 2</a> をインストールする． インストール手順については (#aws_cli_install) 参照のこと．</p>
</li>
<li>
<p><strong>AWS CDK</strong>: Version 1.100 以上をインストールする． Version 2 以降には未対応である． インストール手順については (#aws_cdk_install) 参照のこと．</p>
</li>
<li>
<p><strong>AWS 認証鍵の設定</strong>: AWS API をコマンドラインから呼ぶには，認証鍵 (secret key) が設定されている必要がある． 認証鍵の設定については (#aws_cli_install) 参照のこと．</p>
</li>
</ul>
<h3 id="ハンズオン実行用の-docker-image" tabindex="-1">ハンズオン実行用の Docker Image <a class="header-anchor" href="#ハンズオン実行用の-docker-image" aria-label="Permalink to &quot;ハンズオン実行用の Docker Image&quot;">&ZeroWidthSpace;</a></h3>
<p>Python, Node.js, AWS CDK など，ハンズオンのプログラムを実行するために必要なプログラム/ライブラリがインストール済みの Docker image を用意した． また，ハンズオンのソースコードもクローン済みである． Docker の使い方を知っている読者は，これを使えば，諸々のインストールをする必要なく，すぐにハンズオンのプログラムを実行できる．</p>
<p>次のコマンドで起動する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">docker</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">run</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-it</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">tomomano/labc</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">docker</span><span style="color: #24292E"> </span><span style="color: #032F62">run</span><span style="color: #24292E"> </span><span style="color: #005CC5">-it</span><span style="color: #24292E"> </span><span style="color: #032F62">tomomano/labc</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>この Docker image の使い方や詳細は (#sec_handson_docker) に記載している．</p>
<h2 id="前提知識" tabindex="-1">前提知識 <a class="header-anchor" href="#前提知識" aria-label="Permalink to &quot;前提知識&quot;">&ZeroWidthSpace;</a></h2>
<p>本書を読むにあたり，要求する前提知識は大学初等程度の計算機科学の知識 (OS，プログラミングなど)のみである． それ以上の前提知識はとくに仮定しない． クラウドの利用経験もゼロで問題ない． が，以下の事前知識があるとよりスムーズに理解をすることができるだろう．</p>
<ul>
<li>
<p><strong>Python の基本的な理解</strong>: 本書では Python を使ってプログラムの作成を行う． 使用するライブラリは十分抽象化されており，関数の名前を見ただけで意味が明瞭なものがほとんどであるので， Python に詳しくなくても心配する必要はない．</p>
</li>
<li>
<p><strong>Linux コマンドラインの基礎的な理解</strong>: クラウドを利用する際，クラウド上に立ち上がるサーバーは基本的に Linux である． Linux のコマンドラインについて知識があると，トラブルシュートなどが容易になる． 筆者のおすすめの参考書は <a href="http://linuxcommand.org/tlcl.php" target="_blank" rel="noreferrer">The Linux Command Line by William Shotts</a> である． ウェブで無料で読むことができるので，読んだことのない人はぜひ一読を．</p>
</li>
</ul>
<h2 id="講義に関連する資料" tabindex="-1">講義に関連する資料 <a class="header-anchor" href="#講義に関連する資料" aria-label="Permalink to &quot;講義に関連する資料&quot;">&ZeroWidthSpace;</a></h2>
<p>ハンズオンで使うプログラムや教科書のソースコードは以下のウェブページで公開している．</p>
<h2 id="本書で使用するノーテーションなど" tabindex="-1">本書で使用するノーテーションなど <a class="header-anchor" href="#本書で使用するノーテーションなど" aria-label="Permalink to &quot;本書で使用するノーテーションなど&quot;">&ZeroWidthSpace;</a></h2>
<ul>
<li>
<p>コードやシェルのコマンドは <code>monospace letter</code> で記述する．</p>
</li>
<li>
<p>シェルに入力するコマンドは，それがシェルコマンドであると明示する目的で，先頭に <code>$</code> がつけてある． <code>$</code> はコマンドをコピー&amp;ペーストするときは除かなければならない． 逆に，コマンドの出力には <code>$</code> はついていない点に留意する．</p>
</li>
</ul>
<p>また，以下のような形式で注意やチップスを提供する．</p>
<p>追加のコメントなどを記す．</p>
<p>発展的な議論やアイディアなどを紹介する．</p>
<p>陥りやすいミスなどの注意事項を述べる．</p>
<p>絶対に犯してはならないミスを指摘する．</p>
]]></description>
            <content:encoded><![CDATA[<h1 id="はじめに" tabindex="-1">はじめに <a class="header-anchor" href="#はじめに" aria-label="Permalink to &quot;はじめに&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="本書の目的・内容" tabindex="-1">本書の目的・内容 <a class="header-anchor" href="#本書の目的・内容" aria-label="Permalink to &quot;本書の目的・内容&quot;">&ZeroWidthSpace;</a></h2>
<p>本書は，東京大学計数工学科で 2021 年度 S1/S2 タームに開講されている&quot;システム情報工学特論&quot;の講義資料として作成された．</p>
<p>本書の目的は，クラウドの初心者を対象とし，クラウドの基礎的な知識・概念を解説する． また， Amazon Web Services (以下， AWS) の提供するクラウド環境を実例として，具体的なクラウドの利用方法をハンズオンを通して学ぶ．</p>
<p>とくに，科学・エンジニアリングの学生を対象として，研究などの目的でクラウドを利用するための実践的な手順を紹介する． 知識・理論の説明は最小限に留め，実践を行う中で必要な概念の解説を行う予定である． 読者が今後，研究などでクラウドを利用する際の，足がかりとなれば本書の目的は十分達成されたことになる．</p>
<p>本書は以下のような三部構成になっている．</p>
<table><caption>本書の構成</caption><colgroup><col style="width: 20%" /><col style="width: 40%" /><col style="width: 40%" /></colgroup><thead><tr class="header"><th></th><th>テーマ</th><th>ハンズオン</th></tr></thead><tbody><tr class="odd"><td><p>第一部 (1章-4章)</p></td><td><p>クラウドの基礎</p></td><td><ul><li><p>AWSに自分のサーバーを立ち上げる</p></li></ul></td></tr><tr class="even"><td><p>第二部 (5章-9章)</p></td><td><p>クラウドを活用した機械学習</p></td><td><ul><li><p>AWS と Jupyter を使って始めるディープラーニング</p></li><li><p>スケーラブルな自動質問回答ボットを作る</p></li><li><p>並列化されたハイパーパラメータサーチの実装</p></li></ul></td></tr><tr class="odd"><td><p>第三部 (10章-13章)</p></td><td><p>サーバーレスアーキテクチャ入門</p></td><td><ul><li><p>Lambda, DynamoDB, S3 の演習</p></li><li><p>俳句を投稿する SNS "Bashoutter" を作る</p></li></ul></td></tr></tbody></table>
<p>第一部は，クラウドの基礎となる概念・知識を解説する． セキュリティやネットワークなど，クラウドを利用する上で最低限おさえなければいけないポイントを説明する． ハンズオンでは，はじめての仮想サーバーを AWS に立ち上げる演習を行う．</p>
<p>第二部では，クラウド上で科学計算 (とくに機械学習) を走らせるための入門となる知識・技術を解説する． あわせて， <a href="https://www.docker.com/" target="_blank" rel="noreferrer">Docker</a> とよばれる仮想計算環境の使用方法を紹介する． 一つ目のハンズオンでは， AWS のクラウドで Jupyter Notebook を起動し簡単な機械学習の計算を走らせる課題を実践する． 二つ目のハンズオンでは，深層学習を用いた自然言語処理により，質問に自動で回答を生成するボットを作成する． 最後に，複数台の GPU インスタンスからなるクラスターを起動し，並列に深層学習のハイパーパラメータサーチを行う方法を紹介する．</p>
<p>第三部では，サーバーレスアーキテクチャとよばれる最新のクラウドのアーキテクチャを紹介する． これは，サーバーの処理能力を負荷に応じてより柔軟に拡大・縮小するための概念であり，それ以前 (Serverful としばしばよばれる) と質的に異なる設計思想をクラウドに導入するものである． ハンズオンでは，サーバーレスクラウドの主要なコンポーネントである Lambda, DynamoDB, S3 の演習を提供する． さらに，サーバーレスの技術を使用して簡単な SNS をクラウド上に作成する．</p>
<p>これらの豊富なハンズオンにより， AWS 上にクラウドシステムを開発するための知識と技術が身につくはずである． いずれのハンズオンも，実用性を重視したものになっており，これらをベースにカスタマイズを施すことで様々な応用が可能である．</p>
<h2 id="本書のフィロソフィー" tabindex="-1">本書のフィロソフィー <a class="header-anchor" href="#本書のフィロソフィー" aria-label="Permalink to &quot;本書のフィロソフィー&quot;">&ZeroWidthSpace;</a></h2>
<p>本書のフィロソフィーを一言で表すなら， <strong>&quot;ロケットで宇宙まで飛んでいって一度地球を眺めてみよう！&quot;</strong> である．</p>
<p>どういうことか？</p>
<p>ここでいう&quot;地球&quot;とは，クラウドコンピューティングの全体像のことである． 言うまでもなく，クラウドという技術は非常に広範かつ複雑な概念で，幾多の情報技術・ハードウェア・アルゴリズムが精緻に組み合わさってできた総体である． そして，今日では科学研究から日常のインフラ設備に至るまで，我々の社会の多くの部分がクラウド技術によって支えられている．</p>
<p>ここでいう&quot;ロケット&quot;とはこの講義のことである． この講義では，ロケットに乗って宇宙まで飛び立ち，地球(クラウド)の全体を自身の目で眺めてもらう． その際，ロケットの成り立ちや仕組み (背後にある要素技術やプログラムのソースコード) を深くは問わない． 将来，自分が研究などの目的でクラウドを利用することになった際に，改めて学んでもらえば良い． 本書の目的はむしろ，クラウドの最先端に実際に触れ，そこからどんな景色が見えるか(どんな応用が可能か)を実感してもらうことである．</p>
<p>そのような理由で，本書はクラウドの基礎から応用まで幅広いテーマを取り扱う． 第一部はクラウドの基礎から始め，第二部では一気にレベルアップし機械学習(深層学習)をクラウドで実行する手法を解説する． さらに第三部では，サーバーレス・アーキテクチャというここ数年のうちに確立した全く新しいクラウドの設計について解説する． それぞれで本一冊分以上の内容に相当するものであるが，本書はあえてこれらを一冊にまとめ連続的に俯瞰するという野心的な意図をもって執筆された．</p>
<p>決して楽な搭乗体験ではないかもしれないが，このロケットにしがみついてきてもらえれば，とてもエキサイティングな景色が見られることを約束したい．</p>
<p><img src="./assets/earth_from_earth.jpg" alt="宇宙からみた地球 (Image from NASA https://www.nasa.gov/image-feature/planet-of-clouds)"></p>
<h2 id="aws-アカウント" tabindex="-1">AWS アカウント <a class="header-anchor" href="#aws-アカウント" aria-label="Permalink to &quot;AWS アカウント&quot;">&ZeroWidthSpace;</a></h2>
<p>本書では，ハンズオン形式で AWS のクラウドを実際に動かす演習を提供する． 自分でハンズオンを実行してみたい読者は，各自で AWS のアカウントの作成をしていただく． AWS のアカウントの作成の仕方は巻末付録 ( (#sec:create_aws_account)) に簡単に記載したので，必要に応じて参照していただきたい．</p>
<p>AWS にはいくつかの機能に対して無料利用枠が設定されており，いくつかのハンズオンは無料の範囲内で実行できる． 一方，ほかのハンズオン (とくに機械学習を扱うもの) では数ドル程度のコストが発生する． ハンズオンごとに発生するおおよそのコストについて記述があるので，注意をしながらハンズオンに取り組んでいただきたい．</p>
<p>また，大学などの教育機関における講義で AWS を使用する際は， <a href="https://aws.amazon.com/education/awseducate/" target="_blank" rel="noreferrer">AWS Educate</a> というプログラムを利用することも可能である． これは，講義の担当者が申請を行うことで，受講する学生に対し AWS クレジットが提供されるというプログラムである． AWS Educate を利用することで金銭的な負担なしに AWS を体験することができる． また，講義を経由せず個人でも AWS Educate に参加することも可能である． AWS Educate からは様々な学習教材が提供されているので，ぜひ活用してもらいたい．</p>
<h2 id="環境構築" tabindex="-1">環境構築 <a class="header-anchor" href="#環境構築" aria-label="Permalink to &quot;環境構築&quot;">&ZeroWidthSpace;</a></h2>
<p>本書では， AWS 上にクラウドアプリケーションを展開するハンズオンを実施する． そこで紹介するプログラムを実行するためには，以下の計算機環境が必要である． インストールの方法については，巻末付録 ( (#sec:appendix_settingup)) に記してある． 必要に応じて参照し，環境構築を各自実施していただきたい．</p>
<ul>
<li>
<p><strong>UNIX 系コンソール</strong>: ハンズオンで紹介するコマンドを実行したり， SSH でサーバーにアクセスするため， UNIX 系のコンソール環境が必要である． Mac または Linux のユーザーは， OS に標準搭載のコンソール(ターミナルとも呼ばれる)を使用すればよい． Windows のユーザーは， <a href="https://docs.microsoft.com/en-us/windows/wsl/about" target="_blank" rel="noreferrer">Windows Subsystem for Linux (WSL)</a> を使い， Linux の仮想環境のインストールを推奨する ( (#sec:install_wsl) 参照)．</p>
</li>
<li>
<p><strong>Docker</strong>: 本書では Docker とよばれる仮想計算環境の利用方法を解説する． インストール手順については (#sec:install_docker) を参照のこと．</p>
</li>
<li>
<p><strong>Python</strong>: Version 3.6 以上をインストールする． とくに，ハンズオンでは <code>venv</code> モジュールを使用する． <code>venv</code> の使い方は (#venv_quick_guide) 参照のこと．</p>
</li>
<li>
<p><strong>Node.js</strong>: version 12.0 以上 をインストールする．</p>
</li>
<li>
<p><strong>AWS CLI</strong>: <a href="https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html" target="_blank" rel="noreferrer">Version 2</a> をインストールする． インストール手順については (#aws_cli_install) 参照のこと．</p>
</li>
<li>
<p><strong>AWS CDK</strong>: Version 1.100 以上をインストールする． Version 2 以降には未対応である． インストール手順については (#aws_cdk_install) 参照のこと．</p>
</li>
<li>
<p><strong>AWS 認証鍵の設定</strong>: AWS API をコマンドラインから呼ぶには，認証鍵 (secret key) が設定されている必要がある． 認証鍵の設定については (#aws_cli_install) 参照のこと．</p>
</li>
</ul>
<h3 id="ハンズオン実行用の-docker-image" tabindex="-1">ハンズオン実行用の Docker Image <a class="header-anchor" href="#ハンズオン実行用の-docker-image" aria-label="Permalink to &quot;ハンズオン実行用の Docker Image&quot;">&ZeroWidthSpace;</a></h3>
<p>Python, Node.js, AWS CDK など，ハンズオンのプログラムを実行するために必要なプログラム/ライブラリがインストール済みの Docker image を用意した． また，ハンズオンのソースコードもクローン済みである． Docker の使い方を知っている読者は，これを使えば，諸々のインストールをする必要なく，すぐにハンズオンのプログラムを実行できる．</p>
<p>次のコマンドで起動する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">docker</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">run</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-it</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">tomomano/labc</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">docker</span><span style="color: #24292E"> </span><span style="color: #032F62">run</span><span style="color: #24292E"> </span><span style="color: #005CC5">-it</span><span style="color: #24292E"> </span><span style="color: #032F62">tomomano/labc</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>この Docker image の使い方や詳細は (#sec_handson_docker) に記載している．</p>
<h2 id="前提知識" tabindex="-1">前提知識 <a class="header-anchor" href="#前提知識" aria-label="Permalink to &quot;前提知識&quot;">&ZeroWidthSpace;</a></h2>
<p>本書を読むにあたり，要求する前提知識は大学初等程度の計算機科学の知識 (OS，プログラミングなど)のみである． それ以上の前提知識はとくに仮定しない． クラウドの利用経験もゼロで問題ない． が，以下の事前知識があるとよりスムーズに理解をすることができるだろう．</p>
<ul>
<li>
<p><strong>Python の基本的な理解</strong>: 本書では Python を使ってプログラムの作成を行う． 使用するライブラリは十分抽象化されており，関数の名前を見ただけで意味が明瞭なものがほとんどであるので， Python に詳しくなくても心配する必要はない．</p>
</li>
<li>
<p><strong>Linux コマンドラインの基礎的な理解</strong>: クラウドを利用する際，クラウド上に立ち上がるサーバーは基本的に Linux である． Linux のコマンドラインについて知識があると，トラブルシュートなどが容易になる． 筆者のおすすめの参考書は <a href="http://linuxcommand.org/tlcl.php" target="_blank" rel="noreferrer">The Linux Command Line by William Shotts</a> である． ウェブで無料で読むことができるので，読んだことのない人はぜひ一読を．</p>
</li>
</ul>
<h2 id="講義に関連する資料" tabindex="-1">講義に関連する資料 <a class="header-anchor" href="#講義に関連する資料" aria-label="Permalink to &quot;講義に関連する資料&quot;">&ZeroWidthSpace;</a></h2>
<p>ハンズオンで使うプログラムや教科書のソースコードは以下のウェブページで公開している．</p>
<h2 id="本書で使用するノーテーションなど" tabindex="-1">本書で使用するノーテーションなど <a class="header-anchor" href="#本書で使用するノーテーションなど" aria-label="Permalink to &quot;本書で使用するノーテーションなど&quot;">&ZeroWidthSpace;</a></h2>
<ul>
<li>
<p>コードやシェルのコマンドは <code>monospace letter</code> で記述する．</p>
</li>
<li>
<p>シェルに入力するコマンドは，それがシェルコマンドであると明示する目的で，先頭に <code>$</code> がつけてある． <code>$</code> はコマンドをコピー&amp;ペーストするときは除かなければならない． 逆に，コマンドの出力には <code>$</code> はついていない点に留意する．</p>
</li>
</ul>
<p>また，以下のような形式で注意やチップスを提供する．</p>
<p>追加のコメントなどを記す．</p>
<p>発展的な議論やアイディアなどを紹介する．</p>
<p>陥りやすいミスなどの注意事項を述べる．</p>
<p>絶対に犯してはならないミスを指摘する．</p>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ライセンス ]]></title>
            <link>https://note.toshiki.devdevelopment/aws/license</link>
            <guid>https://note.toshiki.devdevelopment/aws/license</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="ライセンス" tabindex="-1">ライセンス <a class="header-anchor" href="#ライセンス" aria-label="Permalink to &quot;ライセンス&quot;">&ZeroWidthSpace;</a></h1>
<p>本教科書およびハンズオンのソースコードは <a href="https://creativecommons.org/licenses/by-nc-nd/4.0/" target="_blank" rel="noreferrer">CC BY-NC-ND 4.0</a> に従うライセンスで公開しています．</p>
<p>教育など非商用の目的での本教科書の使用や再配布は自由に行うことが可能です． 商用目的で本書の全体またはその一部を無断で転載する行為は，これを固く禁じます．</p>
<p><img src="./assets/cc_by_nc_nd.png" alt="cc_by_nc_nd"></p>
]]></description>
            <content:encoded><![CDATA[<h1 id="ライセンス" tabindex="-1">ライセンス <a class="header-anchor" href="#ライセンス" aria-label="Permalink to &quot;ライセンス&quot;">&ZeroWidthSpace;</a></h1>
<p>本教科書およびハンズオンのソースコードは <a href="https://creativecommons.org/licenses/by-nc-nd/4.0/" target="_blank" rel="noreferrer">CC BY-NC-ND 4.0</a> に従うライセンスで公開しています．</p>
<p>教育など非商用の目的での本教科書の使用や再配布は自由に行うことが可能です． 商用目的で本書の全体またはその一部を無断で転載する行為は，これを固く禁じます．</p>
<p><img src="./assets/cc_by_nc_nd.png" alt="cc_by_nc_nd"></p>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[はじめに! ]]></title>
            <link>https://note.toshiki.devdevelopment/aws/main</link>
            <guid>https://note.toshiki.devdevelopment/aws/main</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="はじめに" tabindex="-1">はじめに! <a class="header-anchor" href="#はじめに" aria-label="Permalink to &quot;はじめに!&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="本書の目的・内容" tabindex="-1">本書の目的・内容 <a class="header-anchor" href="#本書の目的・内容" aria-label="Permalink to &quot;本書の目的・内容&quot;">&ZeroWidthSpace;</a></h2>
<p>本書は，東京大学計数工学科で 2021 年度 S1/S2 タームに開講されている&quot;システム情報工学特論&quot;の講義資料として作成された．</p>
<p>本書の目的は，クラウドの初心者を対象とし，クラウドの基礎的な知識・概念を解説する． また， Amazon Web Services (以下， AWS) の提供するクラウド環境を実例として，具体的なクラウドの利用方法をハンズオンを通して学ぶ．</p>
<p>とくに，科学・エンジニアリングの学生を対象として，研究などの目的でクラウドを利用するための実践的な手順を紹介する． 知識・理論の説明は最小限に留め，実践を行う中で必要な概念の解説を行う予定である． 読者が今後，研究などでクラウドを利用する際の，足がかりとなれば本書の目的は十分達成されたことになる．</p>
<p>本書は以下のような三部構成になっている．</p>
<table><caption>本書の構成</caption><colgroup><col style="width: 20%" /><col style="width: 40%" /><col style="width: 40%" /></colgroup><thead><tr class="header"><th></th><th>テーマ</th><th>ハンズオン</th></tr></thead><tbody><tr class="odd"><td><p>第一部 (1章-4章)</p></td><td><p>クラウドの基礎</p></td><td><ul><li><p>AWSに自分のサーバーを立ち上げる</p></li></ul></td></tr><tr class="even"><td><p>第二部 (5章-9章)</p></td><td><p>クラウドを活用した機械学習</p></td><td><ul><li><p>AWS と Jupyter を使って始めるディープラーニング</p></li><li><p>スケーラブルな自動質問回答ボットを作る</p></li><li><p>並列化されたハイパーパラメータサーチの実装</p></li></ul></td></tr><tr class="odd"><td><p>第三部 (10章-13章)</p></td><td><p>サーバーレスアーキテクチャ入門</p></td><td><ul><li><p>Lambda, DynamoDB, S3 の演習</p></li><li><p>俳句を投稿する SNS "Bashoutter" を作る</p></li></ul></td></tr></tbody></table>
<p>第一部は，クラウドの基礎となる概念・知識を解説する． セキュリティやネットワークなど，クラウドを利用する上で最低限おさえなければいけないポイントを説明する． ハンズオンでは，はじめての仮想サーバーを AWS に立ち上げる演習を行う．</p>
<p>第二部では，クラウド上で科学計算 (とくに機械学習) を走らせるための入門となる知識・技術を解説する． あわせて， <a href="https://www.docker.com/" target="_blank" rel="noreferrer">Docker</a> とよばれる仮想計算環境の使用方法を紹介する． 一つ目のハンズオンでは， AWS のクラウドで Jupyter Notebook を起動し簡単な機械学習の計算を走らせる課題を実践する． 二つ目のハンズオンでは，深層学習を用いた自然言語処理により，質問に自動で回答を生成するボットを作成する． 最後に，複数台の GPU インスタンスからなるクラスターを起動し，並列に深層学習のハイパーパラメータサーチを行う方法を紹介する．</p>
<p>第三部では，サーバーレスアーキテクチャとよばれる最新のクラウドのアーキテクチャを紹介する． これは，サーバーの処理能力を負荷に応じてより柔軟に拡大・縮小するための概念であり，それ以前 (Serverful としばしばよばれる) と質的に異なる設計思想をクラウドに導入するものである． ハンズオンでは，サーバーレスクラウドの主要なコンポーネントである Lambda, DynamoDB, S3 の演習を提供する． さらに，サーバーレスの技術を使用して簡単な SNS をクラウド上に作成する．</p>
<p>これらの豊富なハンズオンにより， AWS 上にクラウドシステムを開発するための知識と技術が身につくはずである． いずれのハンズオンも，実用性を重視したものになっており，これらをベースにカスタマイズを施すことで様々な応用が可能である．</p>
<h2 id="本書のフィロソフィー" tabindex="-1">本書のフィロソフィー <a class="header-anchor" href="#本書のフィロソフィー" aria-label="Permalink to &quot;本書のフィロソフィー&quot;">&ZeroWidthSpace;</a></h2>
<p>本書のフィロソフィーを一言で表すなら， <strong>&quot;ロケットで宇宙まで飛んでいって一度地球を眺めてみよう！&quot;</strong> である．</p>
<p>どういうことか？</p>
<p>ここでいう&quot;地球&quot;とは，クラウドコンピューティングの全体像のことである． 言うまでもなく，クラウドという技術は非常に広範かつ複雑な概念で，幾多の情報技術・ハードウェア・アルゴリズムが精緻に組み合わさってできた総体である． そして，今日では科学研究から日常のインフラ設備に至るまで，我々の社会の多くの部分がクラウド技術によって支えられている．</p>
<p>ここでいう&quot;ロケット&quot;とはこの講義のことである． この講義では，ロケットに乗って宇宙まで飛び立ち，地球(クラウド)の全体を自身の目で眺めてもらう． その際，ロケットの成り立ちや仕組み (背後にある要素技術やプログラムのソースコード) を深くは問わない． 将来，自分が研究などの目的でクラウドを利用することになった際に，改めて学んでもらえば良い． 本書の目的はむしろ，クラウドの最先端に実際に触れ，そこからどんな景色が見えるか(どんな応用が可能か)を実感してもらうことである．</p>
<p>そのような理由で，本書はクラウドの基礎から応用まで幅広いテーマを取り扱う． 第一部はクラウドの基礎から始め，第二部では一気にレベルアップし機械学習(深層学習)をクラウドで実行する手法を解説する． さらに第三部では，サーバーレス・アーキテクチャというここ数年のうちに確立した全く新しいクラウドの設計について解説する． それぞれで本一冊分以上の内容に相当するものであるが，本書はあえてこれらを一冊にまとめ連続的に俯瞰するという野心的な意図をもって執筆された．</p>
<p>決して楽な搭乗体験ではないかもしれないが，このロケットにしがみついてきてもらえれば，とてもエキサイティングな景色が見られることを約束したい．</p>
<p><img src="./assets/earth_from_earth.jpg" alt="宇宙からみた地球 (Image from NASA https://www.nasa.gov/image-feature/planet-of-clouds)"></p>
<h2 id="aws-アカウント" tabindex="-1">AWS アカウント <a class="header-anchor" href="#aws-アカウント" aria-label="Permalink to &quot;AWS アカウント&quot;">&ZeroWidthSpace;</a></h2>
<p>本書では，ハンズオン形式で AWS のクラウドを実際に動かす演習を提供する． 自分でハンズオンを実行してみたい読者は，各自で AWS のアカウントの作成をしていただく． AWS のアカウントの作成の仕方は巻末付録 (<a href="#sec:create_aws_account">AWS アカウントの取得</a>) に簡単に記載したので，必要に応じて参照していただきたい．</p>
<p>AWS にはいくつかの機能に対して無料利用枠が設定されており，いくつかのハンズオンは無料の範囲内で実行できる． 一方，ほかのハンズオン (とくに機械学習を扱うもの) では数ドル程度のコストが発生する． ハンズオンごとに発生するおおよそのコストについて記述があるので，注意をしながらハンズオンに取り組んでいただきたい．</p>
<p>また，大学などの教育機関における講義で AWS を使用する際は， <a href="https://aws.amazon.com/education/awseducate/" target="_blank" rel="noreferrer">AWS Educate</a> というプログラムを利用することも可能である． これは，講義の担当者が申請を行うことで，受講する学生に対し AWS クレジットが提供されるというプログラムである． AWS Educate を利用することで金銭的な負担なしに AWS を体験することができる． また，講義を経由せず個人でも AWS Educate に参加することも可能である． AWS Educate からは様々な学習教材が提供されているので，ぜひ活用してもらいたい．</p>
<h2 id="環境構築" tabindex="-1">環境構築 <a class="header-anchor" href="#環境構築" aria-label="Permalink to &quot;環境構築&quot;">&ZeroWidthSpace;</a></h2>
<p>本書では， AWS 上にクラウドアプリケーションを展開するハンズオンを実施する． そこで紹介するプログラムを実行するためには，以下の計算機環境が必要である． インストールの方法については，巻末付録 (<a href="#sec:appendix_settingup">Appendix: 環境構築</a>) に記してある． 必要に応じて参照し，環境構築を各自実施していただきたい．</p>
<ul>
<li>
<p><strong>UNIX 系コンソール</strong>: ハンズオンで紹介するコマンドを実行したり， SSH でサーバーにアクセスするため， UNIX 系のコンソール環境が必要である． Mac または Linux のユーザーは， OS に標準搭載のコンソール(ターミナルとも呼ばれる)を使用すればよい． Windows のユーザーは， <a href="https://docs.microsoft.com/en-us/windows/wsl/about" target="_blank" rel="noreferrer">Windows Subsystem for Linux (WSL)</a> を使い， Linux の仮想環境のインストールを推奨する (<a href="#sec:install_wsl">WSL のインストール</a> 参照)．</p>
</li>
<li>
<p><strong>Docker</strong>: 本書では Docker とよばれる仮想計算環境の利用方法を解説する． インストール手順については <a href="#sec:install_docker">Docker のインストール</a> を参照のこと．</p>
</li>
<li>
<p><strong>Python</strong>: Version 3.6 以上をインストールする． とくに，ハンズオンでは <code>venv</code> モジュールを使用する． <code>venv</code> の使い方は <a href="#venv_quick_guide">Python クイックガイド</a> 参照のこと．</p>
</li>
<li>
<p><strong>Node.js</strong>: version 12.0 以上 をインストールする．</p>
</li>
<li>
<p><strong>AWS CLI</strong>: <a href="https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html" target="_blank" rel="noreferrer">Version 2</a> をインストールする． インストール手順については <a href="#aws_cli_install">AWS CLI のインストール</a> 参照のこと．</p>
</li>
<li>
<p><strong>AWS CDK</strong>: Version 1.100 以上をインストールする． Version 2 以降には未対応である． インストール手順については <a href="#aws_cdk_install">AWS CDK のインストール</a> 参照のこと．</p>
</li>
<li>
<p><strong>AWS 認証鍵の設定</strong>: AWS API をコマンドラインから呼ぶには，認証鍵 (secret key) が設定されている必要がある． 認証鍵の設定については <a href="#aws_cli_install">AWS CLI のインストール</a> 参照のこと．</p>
</li>
</ul>
<h3 id="ハンズオン実行用の-docker-image" tabindex="-1">ハンズオン実行用の Docker Image <a class="header-anchor" href="#ハンズオン実行用の-docker-image" aria-label="Permalink to &quot;ハンズオン実行用の Docker Image&quot;">&ZeroWidthSpace;</a></h3>
<p>Python, Node.js, AWS CDK など，ハンズオンのプログラムを実行するために必要なプログラム/ライブラリがインストール済みの Docker image を用意した． また，ハンズオンのソースコードもクローン済みである． Docker の使い方を知っている読者は，これを使えば，諸々のインストールをする必要なく，すぐにハンズオンのプログラムを実行できる．</p>
<p>次のコマンドで起動する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">docker</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">run</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-it</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">tomomano/labc</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">docker</span><span style="color: #24292E"> </span><span style="color: #032F62">run</span><span style="color: #24292E"> </span><span style="color: #005CC5">-it</span><span style="color: #24292E"> </span><span style="color: #032F62">tomomano/labc</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>この Docker image の使い方や詳細は <a href="#sec_handson_docker">ハンズオン実行用の Docker image の使い方</a> に記載している．</p>
<h2 id="前提知識" tabindex="-1">前提知識 <a class="header-anchor" href="#前提知識" aria-label="Permalink to &quot;前提知識&quot;">&ZeroWidthSpace;</a></h2>
<p>本書を読むにあたり，要求する前提知識は大学初等程度の計算機科学の知識 (OS，プログラミングなど)のみである． それ以上の前提知識はとくに仮定しない． クラウドの利用経験もゼロで問題ない． が，以下の事前知識があるとよりスムーズに理解をすることができるだろう．</p>
<ul>
<li>
<p><strong>Python の基本的な理解</strong>: 本書では Python を使ってプログラムの作成を行う． 使用するライブラリは十分抽象化されており，関数の名前を見ただけで意味が明瞭なものがほとんどであるので， Python に詳しくなくても心配する必要はない．</p>
</li>
<li>
<p><strong>Linux コマンドラインの基礎的な理解</strong>: クラウドを利用する際，クラウド上に立ち上がるサーバーは基本的に Linux である． Linux のコマンドラインについて知識があると，トラブルシュートなどが容易になる． 筆者のおすすめの参考書は <a href="http://linuxcommand.org/tlcl.php" target="_blank" rel="noreferrer">The Linux Command Line by William Shotts</a> である． ウェブで無料で読むことができるので，読んだことのない人はぜひ一読を．</p>
</li>
</ul>
<h2 id="講義に関連する資料" tabindex="-1">講義に関連する資料 <a class="header-anchor" href="#講義に関連する資料" aria-label="Permalink to &quot;講義に関連する資料&quot;">&ZeroWidthSpace;</a></h2>
<p>ハンズオンで使うプログラムや教科書のソースコードは以下のウェブページで公開している．</p>
<p><a href="https://github.com/tomomano/learn-aws-by-coding" target="_blank" rel="noreferrer">https://github.com/tomomano/learn-aws-by-coding</a></p>
<h2 id="本書で使用するノーテーションなど" tabindex="-1">本書で使用するノーテーションなど <a class="header-anchor" href="#本書で使用するノーテーションなど" aria-label="Permalink to &quot;本書で使用するノーテーションなど&quot;">&ZeroWidthSpace;</a></h2>
<ul>
<li>
<p>コードやシェルのコマンドは <code>monospace letter</code> で記述する．</p>
</li>
<li>
<p>シェルに入力するコマンドは，それがシェルコマンドであると明示する目的で，先頭に <code>$</code> がつけてある． <code>$</code> はコマンドをコピー&amp;ペーストするときは除かなければならない． 逆に，コマンドの出力には <code>$</code> はついていない点に留意する．</p>
</li>
</ul>
<p>また，以下のような形式で注意やチップスを提供する．</p>
<p>追加のコメントなどを記す．</p>
<p>発展的な議論やアイディアなどを紹介する．</p>
<p>陥りやすいミスなどの注意事項を述べる．</p>
<p>絶対に犯してはならないミスを指摘する．</p>
<h1 id="クラウド概論" tabindex="-1">クラウド概論 <a class="header-anchor" href="#クラウド概論" aria-label="Permalink to &quot;クラウド概論&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="クラウドとは" tabindex="-1">クラウドとは？ <a class="header-anchor" href="#クラウドとは" aria-label="Permalink to &quot;クラウドとは？&quot;">&ZeroWidthSpace;</a></h2>
<p><img src="./assets/cloud_word_art.png" alt="Cloud"></p>
<p>クラウドとはなにか？ クラウドという言葉は，それ自身がとても広い意味をもつので，厳密な定義付けを行うことは難しい．</p>
<p>学術的な意味でのクラウドの定義づけをするとしたら，NIST(米国・国立標準技術研究所) による <a href="https://csrc.nist.gov/publications/detail/sp/800-145/final" target="_blank" rel="noreferrer">The NIST Definition of Cloud Computing</a> が引用されることが多い． ここに記載されたクラウドの定義・モデルを図示したのが <a href="#fig:nist_cloud_definition">figure_title</a> である．</p>
<p><img src="./assets/nist_cloud_definition.png" alt="The NIST Definition of Cloud Computing"></p>
<p>これによると，クラウドとは以下の要件が満たされたハードウェア/ソフトウェアの総体のことをいう．</p>
<ul>
<li>
<p><strong>On-demand self-service</strong> 利用者のリクエストに応じて計算資源が自動的に割り当てられる．</p>
</li>
<li>
<p><strong>Broad network access</strong> 利用者はネットワークを通じてクラウドにアクセスできる．</p>
</li>
<li>
<p><strong>Resource pooling</strong> クラウドプロバイダーは，所有する計算資源を分割することで複数の利用者に計算資源を割り当てる．</p>
</li>
<li>
<p><strong>Rapid elasticity</strong> 利用者のリクエストに応じて，迅速に計算資源の拡大あるいは縮小を行うことができる．</p>
</li>
<li>
<p><strong>Measured service</strong> 計算資源の利用量を計測・監視することができる．</p>
</li>
</ul>
<p>…と，いわれても抽象的でよくわからないかもしれない．もう少し具体的な話をする．</p>
<p>個人が所有する計算機で， CPU をアップグレードしようと思ったら，物理的に筐体を開け，CPU ソケットを露出させ，新しい CPU に交換する必要があるだろう． あるいは，ストレージがいっぱいになってしまったら，古いディスクを抜き取り，新しいディスクを挿入する必要がある． 計算機の場所を移動させたときには，新しい部屋の LAN ケーブルを差し込まないとネットワークには接続できない．</p>
<p>クラウドでは，これらの操作が<strong>プログラムからのコマンドによって実行できる</strong>． CPU が 1000 個欲しいと思ったならば，そのようにクラウドプロバイダーにリクエストを送れば良い． すると，数分もしないうちに 1000 CPU の計算資源が割り当てられる． ストレージを 1TB から 10TB に拡張しようと思ったならば，そのようにコマンドを送ればよい (これは，Google Drive や Dropbox などのサービスなどで馴染みのある人も多いだろう)． 計算資源を使い終わったら，そのことをプロバイダーに伝えれば，割り当て分はすぐさま削除される． クラウドプロバイダーは，使った計算資源の量を正確にモニタリングしており，その量をもとに利用料金の計算が行われる．</p>
<p>このように，クラウドの本質は物理的なハードウェアの仮想化・抽象化であり，利用者はコマンドを通じて，<strong>まるでソフトウェアの一部かのように，物理的なハードウェアの管理・運用を行うことができる</strong>． もちろん，背後では，データセンターに置かれた膨大な数の計算機が大量の電力を消費しながら稼働している． クラウドプロバイダーはデータセンターの計算資源を上手にやりくりし，ソフトウェアとしてのインターフェースをユーザーに提供することで，このような仮想化・抽象化を達成しているわけである． クラウドプロバイダーの視点からすると，大勢のユーザーに計算機を貸し出し，データセンターの稼働率を常時 100%に近づけることで，利益率の最大化を図っているのである．</p>
<p>著者の言葉で，クラウドの重要な特性を定義するならば，以下のようになる．</p>
<blockquote>
<p>クラウドとは計算機ハードウェアの抽象化である．つまり，物理的なハードウェアをソフトウェアの一部かのように自在に操作・拡大・接続することを可能にする技術である．</p>
</blockquote>
<p>先述の The NIST Definition of Cloud Computing に戻ると，クラウドプロバイダーによるクラウドサービスの形態としては，次の三つが定義されている (<a href="#fig:nist_cloud_definition">figure_title</a>)．</p>
<ul>
<li>
<p>Software as a Service (SaaS): クラウド上で実行されるアプリケーションをサービスとして利用者に提供する形態． 例として， Google Drive や Slack などが挙げられる． 利用者は，背後にあるクラウドのインフラ (ネットワークやサーバーなど) には直接触れず，アプリケーションとして提供されているクラウドサービスを享受する．</p>
</li>
<li>
<p>Platform as a Service (PaaS): 顧客の作成したアプリケーション (多くの場合データベースと API リクエスト処理を行うサーバーのコードから構成される) をデプロイする環境をサービスとして利用者に提供する形態． PaaS では利用者はクラウドのインフラに直接触れることはなく，計算負荷が増減した際のサーバーのスケーリングはクラウドプロバイダーによってなされる． 例としては， Google App Engine や Heroku などがある．</p>
</li>
<li>
<p>Infrastructure as a Service (IaaS): クラウド上の計算インフラストラクチャーを従量課金制で利用者に提供する形態． 利用者は必要なネットワーク・サーバー・ストレージをプロバイダーから借り受け，そこに自身のアプリケーションを展開し運用する． IaaS の例としては AWS EC2 などが挙げられる．</p>
</li>
</ul>
<p>本書が扱うのは，主に IaaS におけるクラウド開発である． すなわち，開発者がクラウドのインフラを直接操作し，所望のネットワーク・サーバー・ストレージなどを一から構成し，そこにアプリケーションを展開するというクラウド開発である． この意味において，クラウドの開発とは<strong>クラウドインフラストラクチャーを定義・展開するプログラムを構築するステップ</strong>と<strong>インフラ上で実際に走るアプリケーションを作成するステップ</strong>の二つに分けることができる． この二つは，プログラマーの技術としてはある程度分業を行うことが可能であるが，最も効率化・最適化されたクラウドシステムを構築するためには両方の理解が必須である． 本書では，前者 (クラウドインフラの記述) に重きを置きつつ，アプリケーションレイヤーの話題も取り扱う． PaaS とは，開発者はアプリケーションレイヤーの開発に注力し，クラウドインフラの部分はクラウドプロバイダーに依存するという概念である． PaaS は，クラウドインフラの開発が不要になることで開発の時間が短縮されるが，細かなインフラの挙動はコントロールできないという限界がある． 本書では PaaS についてはとくに取り扱わない．</p>
<p>SaaS は本書の文脈では開発による&quot;成果物&quot;と捉えられるだろう． すなわち， IaaS を構成するプログラムを作成し展開することによって，一般の人が利用できるようなウェブ上の計算サービスやデータベースを提供することが開発の最終ゴールである． 本書のハンズオンではその実例として，シンプルな SNS の作成 (<a href="#sec_bashoutter">Hands-on #6: Bashoutter</a>) などの演習を提供する．</p>
<p>なお，最近では Function as a Service (FaaS) やサーバーレスコンピューティングなども新たなクラウドのカテゴリとして認知されている． これらの概念については <a href="#sec_intro_serverless">Hands-on #5: サーバーレス入門</a> などの章で詳しく触れていく． 本書を読み進める中で明らかになるように，クラウドの技術は日進月歩である． 本書では実用的・教育的な観点から，従来的なクラウドの設計概念に触れたあと，サーバーレスなどの最新の技術も網羅するので，楽しみにしながら読み進めていただきたい．</p>
<p>最後に，The NIST Definition of Cloud Computing によると，クラウドの運用形態について次のような定義がなされている (<a href="#fig:nist_cloud_definition">figure_title</a>)． 特定の組織・団体・企業の内部のみで使用されるクラウドを，<strong>プライベートクラウド (private cloud)</strong> とよぶ． 例えば，大学や研究機関では，その機関の構成員向けの大規模計算機サーバーが運用されていることが多い． プライベートクラウドは，組織の構成員ならば無料もしくは極めて割安のコストで計算を実行できる． しかし，使用できる計算資源の上限は限られる場合が多く，拡張時の柔軟性に欠ける場合もある．</p>
<p>一方，商用のサービスとして一般の顧客に向けたクラウドのことを，<strong>パブリッククラウド (public cloud)</strong> とよぶ． 有名なパブリッククラウドプラットフォームの例を挙げると， Google 社が提供する <a href="https://cloud.google.com/" target="_blank" rel="noreferrer">Google Cloud Platform (GCP)</a>， Microsoft 社が提供する <a href="https://azure.microsoft.com" target="_blank" rel="noreferrer">Azure</a>， Amazon 社が提供する <a href="https://aws.amazon.com" target="_blank" rel="noreferrer">Amazon Web Services (AWS)</a> などがある． パブリッククラウドを利用する場合は，プロバイダーの設定した利用料金を支払うことになる． その分，巨大なデータセンターを運用する企業の計算資源にアクセスすることができるので，計算のキャパシティは無尽蔵にあるといって過言でない．</p>
<p>第三のクラウドの運用形態として，コミュニティクラウド (community cloud) が挙げられる． これは，例えば政府の省庁・機関など目的・役割を共有する団体・組織が共有して運用するクラウドを指す． 最後に，ハイブリッドクラウド (hybrid cloud) という形態もあり，これはプライベート・パブリック・コミュニティクラウドの二つ以上の組み合わせによって構成されるクラウドのことである． データ保護の観点から，いくつかの機密データやプライバシーに関わる情報はプライベートクラウドに保持し，残りのシステムをパブリッククラウドに依存する，などの形態が想定される．</p>
<p>本書で説明するのは，基本的にパブリッククラウドを使ったクラウド開発である． 特に，Amazon Web Services (AWS) を使用して，具体的な技術と概念を学んでいく． 一方で，サーバーのスケーリングや仮想計算環境などのテクニックはすべてのクラウドに共通な概念であるので，クラウドのプラットフォームが変わろうと一般に通用する知識も同時に身につくはずだ．</p>
<h2 id="なぜクラウドを使うのか" tabindex="-1">なぜクラウドを使うのか？ <a class="header-anchor" href="#なぜクラウドを使うのか" aria-label="Permalink to &quot;なぜクラウドを使うのか？&quot;">&ZeroWidthSpace;</a></h2>
<p>上述のように，クラウドとはプログラムを通じて自由に計算資源を操作することのできる計算環境である． ここでは，リアルなローカル計算環境と比べて，なぜクラウドを使うと良いことがあるのかについて述べたい．</p>
<ol>
<li>
<p><strong>自由にサーバーのサイズをスケールできる</strong></p>
<p>なにか新しいプロジェクトを始めるとき，あらかじめ必要なサーバーのスペックを知るのは難しい． いきなり大きなサーバーを買うのはリスクが高い． 一方で，小さすぎるサーバーでは，後のアップグレードが面倒である． クラウドを利用すれば，プロジェクトを進めながら，必要な分だけの計算資源を確保することができる． 2. <strong>自分でサーバーをメンテナンスする必要がない</strong></p>
<p>悲しいことに，コンピュータとは古くなるものである．最近の技術の進歩の速度からすると，5 年も経てば，もはや当時の最新コンピュータも化石と同じである． 5 年ごとにサーバーを入れ替えるのは相当な手間である． またサーバーの停電や故障など不意の障害への対応も必要である． クラウドでは，そのようなインフラの整備やメンテナンスはプロバイダーが自動でやってくれるので，ユーザーが心配する必要がない． 3. <strong>初期コスト 0</strong></p>
<p>自前の計算環境とクラウドの，経済的なコストのイメージを示したのが <a href="#cloud_economic_curve">figure_title</a> である． クラウドを利用する場合の初期コストは基本的に 0 である． その後，使った利用量に応じてコストが増大していく． 一方，自前の計算環境では，大きな初期コストが生じる． その分，初期投資後のコストの増加は，電気利用料やサーバー維持費などに留まるため，クラウドを利用した場合よりも傾きは小さくなる． 自前の計算機では，ある一定期間後，サーバーのアップグレードなどによる支出が生じることがある． 一方，クラウドを利用する場合は，そのような非連続なコストの増大は基本的に生じない． クラウドのコストのカーブが，自前計算環境のコストのカーブの下にある範囲においては，クラウドを使うことは経済的なコスト削減につながる．</p>
<p><img src="./assets/cloud_cost.png" alt="クラウドと自前計算機環境の経済的コストの比較"></p>
</li>
</ol>
<p>とくに，**1.**の点は研究の場面では重要であると筆者は感じる． 研究をやっていて，四六時中計算を走らせ続けるという場合は少ない． むしろ，新しいアルゴリズムが完成したとき・新しいデータが届いたとき，集中的・突発的に計算タスクが増大することが多いだろう． そういったときに，フレキシブルに計算力を増強させることができるのは，クラウドを使う大きなメリットである．</p>
<p>ここまでクラウドを使うメリットを述べたが，逆に，デメリットというのも当然存在する．</p>
<ol>
<li>
<p><strong>クラウドは賢く使わないといけない</strong></p>
<p><a href="#cloud_economic_curve">figure_title</a> で示したコストのカーブにあるとおり，使い方によっては自前の計算環境のほうがコスト的に有利な場面は存在しうる． クラウドを利用する際は，使い終わった計算資源はすぐに削除するなど，利用者が賢く管理を行う必要があり，これを怠ると思いもしない額の請求が届く可能性がある． 2. <strong>セキュリティ</strong></p>
<p>クラウドは，インターネットを通じて世界のどこからでもアクセスできる状態にあり，セキュリティ管理を怠ると簡単にハッキングの対象となりうる． ハッキングを受けると，情報流出だけでなく，経済的な損失を被る可能性がある． 3. <strong>ラーニングカーブ</strong></p>
<p>上記のように，コスト・セキュリティなど，クラウドを利用する際に留意しなければならない点は多い． 賢くクラウドを使うには，十分なクラウドの理解が必要であり，そのラーニングカーブを乗り越える必要がある．</p>
</li>
</ol>
<p>Mac/Linux などでコマンドを入力するときに使用する，あの黒い画面のことを Terminal とよんだりする． この言葉の語源をご存知だろうか？</p>
<p><img src="./assets/terminal.png" alt="Terminal"></p>
<p>この言葉の語源は，コンピュータが誕生して間もない頃の時代に遡る． その頃のコンピュータというと，何千何万のという数の真空管が接続された，会議室一個分くらいのサイズのマシンであった． そのような高価でメンテが大変な機材であるから，当然みんなでシェアして使うことが前提となる． ユーザーがコンピュータにアクセスするため，マシンからは何本かのケーブルが伸び，それぞれにキーボードとスクリーンが接続されていた… これを <strong>Terminal</strong> とよんでいたのである． 人々は，代わる代わる Terminal の前に座って，計算機との対話を行っていた.</p>
<p>時代は流れ，Windows や Mac などのいわゆるパーソナルコンピュータの出現により，コンピュータはみんなで共有するものではなく，個人が所有するものになった．</p>
<p>最近のクラウドの台頭は，みんなで大きなコンピュータをシェアするという，最初のコンピュータの使われ方に原点回帰していると捉えることもできる． 一方で，スマートフォンやウェアラブルなどのエッジデバイスの普及も盛んであり，個人が複数の&quot;小さな&quot;コンピュータを所有する，という流れも同時に進行しているのである．</p>
<h1 id="aws-入門" tabindex="-1">AWS 入門 <a class="header-anchor" href="#aws-入門" aria-label="Permalink to &quot;AWS 入門&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="aws-とは" tabindex="-1">AWS とは？ <a class="header-anchor" href="#aws-とは" aria-label="Permalink to &quot;AWS とは？&quot;">&ZeroWidthSpace;</a></h2>
<p>本書では，クラウドの実践を行うプラットフォームとして， AWS を用いる． 実践にあたって，最低限必要な AWS の知識を本章では解説しよう．</p>
<p><a href="https://aws.amazon.com" target="_blank" rel="noreferrer">AWS (Amazon Web Services)</a> は Amazon 社が提供する総合的なクラウドプラットフォームである． AWS は Amazon 社が持つ膨大な計算リソースを貸し出すクラウドサービスとして，2006 年に誕生した． 2021 年では，クラウドプロバイダーとして最大のマーケットシェア (約 32%) を保持している (<a href="https://www.canalys.com/newsroom/global-cloud-market-Q121" target="_blank" rel="noreferrer">参照</a>)． Netflix や Slack をはじめとした多くのウェブ関連のサービスで，一部または全てのサーバーリソースが AWS から提供されているとのことである． よって，知らないうちに AWS の恩恵にあずかっている人も少なくないはずだ．</p>
<p>最大のシェアをもつだけに，機能・サービスの幅広さはほかのクラウドプラットフォームと比べ抜きんでている． また，利用者数が多いことを反映して，公式あるいはサードパーティによる技術紹介記事が数多くウェブ上に存在しているだけでなく，ライブラリのユーザーコミュニティも大きく問題解決が捗るのも魅力の一つだ． 初期のころウェブビジネスを行う企業がユーザーの大半を占めていたが，最近は大学などでの科学研究用途としても頻繁に用いられるようになってきている．</p>
<h2 id="aws-の機能・サービス" tabindex="-1">AWS の機能・サービス <a class="header-anchor" href="#aws-の機能・サービス" aria-label="Permalink to &quot;AWS の機能・サービス&quot;">&ZeroWidthSpace;</a></h2>
<p><a href="#fig_aws_services">figure_title</a> は，執筆時点において AWS で提供されている主要な機能・サービスの一覧である．</p>
<p><img src="./assets/aws_services.png" alt="AWSで提供されている主要なサービス一覧"></p>
<p>計算，ストレージ，データベース，ネットワーク，セキュリティなど，クラウドの構築に必要な様々な要素が<strong>独立したコンポーネント</strong>として提供されている． 基本的に，これらを組み合わせることで一つのクラウドシステムができあがる．</p>
<p>また，機械学習・音声認識・AR/VR など，特定のアプリケーションにパッケージ済みのサービスも提供されている． これらを合計すると全部で 170 個以上のサービスが提供されているとのことである (<a href="https://dev.classmethod.jp/articles/aws-summary-2020/" target="_blank" rel="noreferrer">参照</a>)．</p>
<p>AWS の初心者が陥りがちなのは，<strong>大量のサービスの数に圧倒され，どこから手をつけたらよいのかわからなくなる</strong>，という状況である． たくさんのサービスの中から，どのサービスをどの順番で学んでいったらいいのか，その道筋すら明らかでなく，大きな参入障壁となっていることは間違いない． だが実のところ， AWS の<strong>基本的な構成要素はそのうちの数個</strong>のみに限られる． 基本要素となる機能の使い方を知れば， AWS のおおよそのリソースを使いこなすことが可能になる． ほかの機能の多くは，基本の要素を組み合わせて特定のアプリケーションに特化したパッケージとして AWS が用意したものである． そのポイントを認知することが， AWS の学習の最初のステップである．</p>
<p>ここでは， AWS 上でクラウドシステムを構築するときの基本となる構成要素を列挙する． これらは後のハンズオンで実際にプログラムを書きながら体験する． 現時点では，名前だけでも頭の片隅に記憶してもらえればよい．</p>
<h3 id="計算" tabindex="-1">計算 <a class="header-anchor" href="#計算" aria-label="Permalink to &quot;計算&quot;">&ZeroWidthSpace;</a></h3>
<p><img src="./assets/aws_logos/EC2.png" alt="S3"> <strong>EC2 (Elastic Compute Cloud)</strong> 様々なスペックの仮想マシンを作成し，計算を実行することができる． クラウドの最も基本となる構成要素である． <a href="#sec_first_ec2">Hands-on #1: 初めての EC2 インスタンスを起動する</a>, <a href="#sec_jupyter_and_deep_learning">Hands-on #2: AWS でディープラーニングを実践</a>, <a href="#sec_aws_batch">Hands-on #4: AWS Batch を使って機械学習のハイパーパラメータサーチを並列化する</a> で詳しく触れる．</p>
<p><img src="./assets/aws_logos/Lambda.png" alt="S3"> <strong>Lambda</strong> Function as a Service (FaaS) とよばれる，小さな計算を<strong>サーバーなし</strong>で実行するためのサービス． サーバーレスアーキテクチャの章 (<a href="#sec_serverless">Serverless architecture</a>) で詳しく解説する．</p>
<h3 id="ストレージ" tabindex="-1">ストレージ <a class="header-anchor" href="#ストレージ" aria-label="Permalink to &quot;ストレージ&quot;">&ZeroWidthSpace;</a></h3>
<p><img src="./assets/aws_logos/EBS.png" alt="S3"> <strong>EBS (Elastic Block Store)</strong> EC2 に付与することのできる仮想データドライブ． いわゆる&quot;普通の&quot;(一般的な OS で使われている)ファイルシステムを思い浮かべてくれたらよい．</p>
<p><img src="./assets/aws_logos/S3.png" alt="S3"> <strong>S3 (Simple Storage Service)</strong> Object Storage とよばれる，API を使ってデータの読み書きを行う，いうなれば”クラウド・ネイティブ”なデータの格納システムである． サーバーレスアーキテクチャの章 (<a href="#sec_serverless">Serverless architecture</a>) で詳しく解説する．</p>
<h3 id="データベース" tabindex="-1">データベース <a class="header-anchor" href="#データベース" aria-label="Permalink to &quot;データベース&quot;">&ZeroWidthSpace;</a></h3>
<p><img src="./assets/aws_logos/DynamoDB.png" alt="S3"> <strong>DynamoDB</strong> NoSQL 型のデータベースサービス (知っている人は <code>mongoDB</code> などを思い浮かべたらよい)． サーバーレスアーキテクチャの章 (<a href="#sec_serverless">Serverless architecture</a>) で詳しく解説する．</p>
<h3 id="ネットワーク" tabindex="-1">ネットワーク <a class="header-anchor" href="#ネットワーク" aria-label="Permalink to &quot;ネットワーク&quot;">&ZeroWidthSpace;</a></h3>
<p><img src="./assets/aws_logos/VPC.png" alt="S3"> <strong>VPC(Virtual Private Cloud)</strong> AWS 上に仮想ネットワーク環境を作成し，仮想サーバー間の接続を定義したり，外部からのアクセスなどを管理する． EC2 は VPC の内部に配置されなければならない．</p>
<p><strong>API Gateway</strong> <img src="./assets/aws_logos/APIGateway.png" alt="S3"> API のエンドポイントとバックエンドのサービス (Lambda など) を接続する際に用いる，リバースプロキシとしての役割を担う． <a href="#sec_bashoutter">Hands-on #6: Bashoutter</a> で詳しく解説する．</p>
<h2 id="region-と-availability-zone" tabindex="-1">Region と Availability Zone <a class="header-anchor" href="#region-と-availability-zone" aria-label="Permalink to &quot;Region と Availability Zone&quot;">&ZeroWidthSpace;</a></h2>
<p>AWS を使用する際に知っておかなければならない重要な概念として， <strong>リージョン (Region)</strong> と <strong>Availability Zone (AZ)</strong> がある (<a href="#fig_aws_regions_and_azs">figure_title</a>)． 以下ではこの概念について簡単に記述する．</p>
<p><img src="./assets/aws_region_and_az.png" alt="AWSにおける Region と Availability Zones"></p>
<p><strong>リージョン (Region)</strong> とは，おおまかに言うとデータセンターの所在地のことである． 執筆時点において， AWS は世界の 25 の国と地域でデータセンターを所有している． <a href="#fig_aws_regions">figure_title</a> は執筆時点で利用できるリージョンの世界地図を示している． 日本では東京と大阪にデータセンターがある． 各リージョンには固有の ID がついており，例えば東京は <code>ap-northeast-1</code>, 米国オハイオ州は <code>us-east-2</code>，などと定義されている．</p>
<p><img src="./assets/aws_regions.png" alt="Regions in AWS(出典: https://aws.amazon.com/about-aws/global-infrastructure/)"></p>
<p>AWS コンソールにログインすると，画面右上のメニューバーでリージョンを選択することができる(<a href="#fig_aws_console_regions">figure_title</a>, 赤丸で囲った箇所)． EC2, S3 などの AWS のリソースは，リージョンごとに完全に独立である． したがって，<strong>リソースを新たにデプロイする際，あるいはデプロイ済みのリソースを閲覧する際は，コンソールのリージョンが正しく設定されているか，確認する必要がある</strong>． ウェブビジネスを展開する場合などは，世界の各地にクラウドを展開する必要があるが，個人的な研究用途として用いる場合は，最寄りのリージョン (i.e. 東京) を使えば基本的に問題ない．</p>
<p><img src="./assets/aws_regions2.png" alt="AWSコンソールでリージョンを選択"></p>
<p><code>Avaialibity Zone (AZ)</code> とは，リージョン内で地理的に隔離されたデータセンターのことである． それぞれのリージョンは 2 個以上の AZ を有しており，もし一つの AZ で火災や停電などが起きた場合でも，ほかの AZ がその障害をカバーすることができる． また， AZ 間は高速な AWS 専用ネットワーク回線で結ばれているため， AZ 間のデータ転送は極めて早い． AZ は，ビジネスなどでサーバーダウンが許容されない場合などに注意すべき概念であり，個人的な用途で使う限りにおいてはあまり深く考慮する必要はない．言葉の意味だけ知っておけば十分である．</p>
<p>AWS を使用する際，どこのリージョンを指定するのがよいのだろうか？ インターネットの接続速度の観点からは，地理的に一番近いリージョンを使用するのが一般的によいだろう． 一方， EC2 の利用料などはリージョンごとに価格設定が若干 (10-20%程度) 異なる． したがって，自分が最も頻繁に利用するサービスの価格が最も安く設定されているリージョンを選択する，というのも重要な視点である． また，いくつかのサービスは，特定のリージョンで利用できない場合もある． これらのポイントから総合的に判断して使用するリージョンを決めると良い．</p>
<p>AWS Educate を利用している読者へ</p>
<p>執筆時点において，AWS Educate による Starter Account を使用している場合は <code>us-east-1</code> region のみ利用できる (<a href="https://awseducate-starter-account-services.s3.amazonaws.com/AWS_Educate_Starter_Account_Services_Supported.pdf" target="_blank" rel="noreferrer">参照</a>)．</p>
<ul>
<li><a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-regions-availability-zones.html" target="_blank" rel="noreferrer">AWS documentation &quot;Regions, Availability Zones, and Local Zones&quot;</a></li>
</ul>
<h2 id="aws-でのクラウド開発" tabindex="-1">AWS でのクラウド開発 <a class="header-anchor" href="#aws-でのクラウド開発" aria-label="Permalink to &quot;AWS でのクラウド開発&quot;">&ZeroWidthSpace;</a></h2>
<p>AWS のクラウドの全体像がわかってきたところで，次のトピックとして，どのようにして AWS 上にクラウドの開発を行い，展開していくかについての概略を解説しよう．</p>
<p>AWS のリソースを追加・編集・削除するなどの操作を実行するには，<strong>コンソールを用いる</strong>方法と，<strong>API を用いる方法</strong>の，二つの経路がある．</p>
<h3 id="コンソール画面からリソースを操作する" tabindex="-1">コンソール画面からリソースを操作する <a class="header-anchor" href="#コンソール画面からリソースを操作する" aria-label="Permalink to &quot;コンソール画面からリソースを操作する&quot;">&ZeroWidthSpace;</a></h3>
<p>AWS のアカウントにログインすると，まず最初に表示されるのが<strong>AWS コンソール</strong>である (<a href="#aws_console_window">figure_title</a>)．</p>
<p><img src="./assets/aws_console.png" alt="AWSマネージメントコンソール画面"></p>
<p>コンソールを使うことで， EC2 のインスタンスを立ち上げたり，S3 のデータを追加・削除したり，ログを閲覧したりなど，AWS 上のあらゆるリソースの操作を GUI (Graphical User Interface) を通して実行することができる． <strong>初めて触る機能をポチポチと試したり，デバッグを行うときなどにとても便利である</strong>．</p>
<p>コンソールはさらっと機能を試したり，開発中のクラウドのデバッグをするときには便利なのであるが，実際にクラウドの開発をする場面でこれを直接いじることはあまりない． むしろ，次に紹介する API を使用して，プログラムとしてクラウドのリソースを記述することで開発を行うのが一般的である． そのような理由で，本書では AWS コンソールを使った AWS の使い方はあまり触れない． AWS のドキュメンテーションには，たくさんの <a href="https://aws.amazon.com/getting-started/hands-on/" target="_blank" rel="noreferrer">チュートリアル</a> が用意されており，コンソール画面から様々な操作を行う方法が記述されているので，興味がある読者はそちらを参照されたい．</p>
<h3 id="api-からリソースを操作する" tabindex="-1">API からリソースを操作する <a class="header-anchor" href="#api-からリソースを操作する" aria-label="Permalink to &quot;API からリソースを操作する&quot;">&ZeroWidthSpace;</a></h3>
<p><strong>API (Application Programming Interface)</strong> を使うことで，コマンドを AWS に送信し，クラウドのリソースの操作をすることができる． API とは，端的に言えば AWS が公開しているコマンドの一覧であり，<code>GET</code>, <code>POST</code>, <code>DELETE</code> などの <strong>REST API</strong> から構成されている (REST API については <a href="#sec_rest_api">REST API</a> で簡単に解説する)． が，直接 REST API を入力するのは面倒であるので，その手間を解消するための様々なツールが提供されている．</p>
<p>例えば， <a href="https://docs.aws.amazon.com/cli/latest/index.html" target="_blank" rel="noreferrer">AWS CLI</a> は， UNIX コンソールから AWS API を実行するための CLI (Command Line Interface) である． CLI に加えて，いろいろなプログラミング言語での SDK (Software Development Kit) が提供されている．以下に一例を挙げる．</p>
<ul>
<li>
<p>Python ⇒ <a href="https://boto3.amazonaws.com/v1/documentation/api/latest/index.html" target="_blank" rel="noreferrer">boto3</a></p>
</li>
<li>
<p>Ruby ⇒ <a href="https://aws.amazon.com/sdk-for-ruby/" target="_blank" rel="noreferrer">AWS SDK for Ruby</a></p>
</li>
<li>
<p>Node.js ⇒ <a href="https://aws.amazon.com/sdk-for-node-js/" target="_blank" rel="noreferrer">AWS SDK for Node.js</a></p>
</li>
</ul>
<p>具体的な API の使用例を見てみよう．</p>
<p>S3 に新しい保存領域 (<code>Bucket (バケット)</code> とよばれる) を追加したいとしよう． AWS CLI を使った場合は，次のようなコマンドを打てばよい．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">s3</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">mb</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">s3://my-bucket</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--region</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ap-northeast-1</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">aws</span><span style="color: #24292E"> </span><span style="color: #032F62">s3</span><span style="color: #24292E"> </span><span style="color: #032F62">mb</span><span style="color: #24292E"> </span><span style="color: #032F62">s3://my-bucket</span><span style="color: #24292E"> </span><span style="color: #005CC5">--region</span><span style="color: #24292E"> </span><span style="color: #032F62">ap-northeast-1</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>上記のコマンドは， <code>my-bucket</code> という名前のバケットを， <code>ap-northeast-1</code> のリージョンに作成する．</p>
<p>Python からこれと同じ操作を実行するには， <code>boto3</code> ライブラリを使って，次のようなスクリプトを実行する．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> boto3</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">s3_client </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> boto3.client(</span><span style="color: #96D0FF">&quot;s3&quot;</span><span style="color: #ADBAC7">, </span><span style="color: #F69D50">region_name</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;ap-northeast-1&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">s3_client.create_bucket(</span><span style="color: #F69D50">Bucket</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;my-bucket&quot;</span><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> boto3</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">s3_client </span><span style="color: #D73A49">=</span><span style="color: #24292E"> boto3.client(</span><span style="color: #032F62">&quot;s3&quot;</span><span style="color: #24292E">, </span><span style="color: #E36209">region_name</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;ap-northeast-1&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">s3_client.create_bucket(</span><span style="color: #E36209">Bucket</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;my-bucket&quot;</span><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br></div></div><p>もう一つ例をあげよう．</p>
<p>新しい EC2 のインスタンス(インスタンスとは，起動状態にある仮想サーバーの意味である)を起動するには，次のようなコマンドを打てば良い．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ec2</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">run-instances</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--image-id</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ami-xxxxxxxx</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--count</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--instance-type</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">t2.micro</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--key-name</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">MyKeyPair</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--security-group-ids</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">sg-903004f8</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--subnet-id</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">subnet-6e7f829e</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">aws</span><span style="color: #24292E"> </span><span style="color: #032F62">ec2</span><span style="color: #24292E"> </span><span style="color: #032F62">run-instances</span><span style="color: #24292E"> </span><span style="color: #005CC5">--image-id</span><span style="color: #24292E"> </span><span style="color: #032F62">ami-xxxxxxxx</span><span style="color: #24292E"> </span><span style="color: #005CC5">--count</span><span style="color: #24292E"> </span><span style="color: #005CC5">1</span><span style="color: #24292E"> </span><span style="color: #005CC5">--instance-type</span><span style="color: #24292E"> </span><span style="color: #032F62">t2.micro</span><span style="color: #24292E"> </span><span style="color: #005CC5">--key-name</span><span style="color: #24292E"> </span><span style="color: #032F62">MyKeyPair</span><span style="color: #24292E"> </span><span style="color: #005CC5">--security-group-ids</span><span style="color: #24292E"> </span><span style="color: #032F62">sg-903004f8</span><span style="color: #24292E"> </span><span style="color: #005CC5">--subnet-id</span><span style="color: #24292E"> </span><span style="color: #032F62">subnet-6e7f829e</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>このコマンドにより， <a href="https://aws.amazon.com/ec2/instance-types/t2/" target="_blank" rel="noreferrer">t2.micro</a> というタイプ (1 vCPU, 1.0 GB RAM) のインスタンスが起動する． ここではその他のパラメータの詳細の説明は省略する (ハンズオン (<a href="#sec_first_ec2">Hands-on #1: 初めての EC2 インスタンスを起動する</a>) で詳しく解説する)．</p>
<p>Python から上記と同じ操作を実行するには，以下のようなスクリプトを使う．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> boto3</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">ec2_client </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> boto3.client(</span><span style="color: #96D0FF">&quot;ec2&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">ec2_client.run_instances(</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">ImageId</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;ami-xxxxxxxxx&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">MinCount</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">MaxCount</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">KeyName</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;MyKeyPair&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">InstanceType</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;t2.micro&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">SecurityGroupIds</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">[</span><span style="color: #96D0FF">&quot;sg-903004f8&quot;</span><span style="color: #ADBAC7">],</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">SubnetId</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;subnet-6e7f829e&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> boto3</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">ec2_client </span><span style="color: #D73A49">=</span><span style="color: #24292E"> boto3.client(</span><span style="color: #032F62">&quot;ec2&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">ec2_client.run_instances(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">ImageId</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;ami-xxxxxxxxx&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">MinCount</span><span style="color: #D73A49">=</span><span style="color: #005CC5">1</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">MaxCount</span><span style="color: #D73A49">=</span><span style="color: #005CC5">1</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">KeyName</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;MyKeyPair&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">InstanceType</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;t2.micro&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">SecurityGroupIds</span><span style="color: #D73A49">=</span><span style="color: #24292E">[</span><span style="color: #032F62">&quot;sg-903004f8&quot;</span><span style="color: #24292E">],</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">SubnetId</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;subnet-6e7f829e&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br></div></div><p>以上の例を通じて，API によるクラウドのリソースの操作のイメージがつかめてきただろうか？ コマンド一つで，新しい仮想サーバーを起動したり，データの保存領域を追加したり，任意の操作を実行できるわけである． 基本的に，このようなコマンドを複数組み合わせていくことで，自分の望む CPU・RAM・ネットワーク・ストレージが備わった計算環境を構築することができる． もちろん，逆の操作 (リソースの削除) も API を使って実行できる．</p>
<h3 id="ミニ・ハンズオン-aws-cli-を使ってみよう" tabindex="-1">ミニ・ハンズオン: AWS CLI を使ってみよう <a class="header-anchor" href="#ミニ・ハンズオン-aws-cli-を使ってみよう" aria-label="Permalink to &quot;ミニ・ハンズオン: AWS CLI を使ってみよう&quot;">&ZeroWidthSpace;</a></h3>
<p>ここでは，ミニ・ハンズオンとして，AWS CLI を実際に使ってみる． AWS CLI は先述のとおり， AWS 上の任意のリソースの操作が可能であるが，ここでは一番シンプルな，<strong>S3 を使ったファイルの読み書きを実践する</strong> (EC2 の操作は少し複雑なので，第一回ハンズオンで行う)． <code>aws s3</code> コマンドの詳しい使い方は <a href="https://docs.aws.amazon.com/cli/latest/reference/s3/index.html#cli-aws-s3" target="_blank" rel="noreferrer">公式ドキュメンテーション</a>を参照．</p>
<p>AWS CLI のインストールについては， <a href="#aws_cli_install">AWS CLI のインストール</a> を参照．</p>
<p>以下に紹介するハンズオンは，基本的に <a href="https://aws.amazon.com/free/?all-free-tier.sort-by=item.additionalFields.SortRank&amp;all-free-tier.sort-order=asc" target="_blank" rel="noreferrer">S3 の無料枠</a> の範囲内で実行することができる．</p>
<p>以下のコマンドを実行する前に，AWS の認証情報が正しく設定されていることを確認する． これには <code>~/.aws/credentials</code> のファイルに設定が書き込まれているか，環境変数 (<code>AWS_ACCESS_KEY_ID</code>, <code>AWS_SECRET_ACCESS_KEY</code>, <code>AWS_DEFAULT_REGION</code>) が定義されている必要がある． 詳しくは <a href="#aws_cli_install">AWS CLI のインストール</a> を参照．</p>
<p>まずは，S3 にデータの格納領域 (<code>Bucket</code> とよばれる．一般的な OS での&quot;ドライブ&quot;に相当する) を作成するところから始めよう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">bucketName=&quot;mybucket-$(</span><span style="color: #F69D50">openssl</span><span style="color: #96D0FF"> rand </span><span style="color: #6CB6FF">-hex</span><span style="color: #96D0FF"> </span><span style="color: #6CB6FF">12</span><span style="color: #96D0FF">)&quot;</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">echo</span><span style="color: #ADBAC7"> $bucketName</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">s3</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">mb</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;s3://${</span><span style="color: #ADBAC7">bucketName</span><span style="color: #96D0FF">}&quot;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">bucketName=&quot;mybucket-$(</span><span style="color: #6F42C1">openssl</span><span style="color: #032F62"> rand </span><span style="color: #005CC5">-hex</span><span style="color: #032F62"> </span><span style="color: #005CC5">12</span><span style="color: #032F62">)&quot;</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">echo</span><span style="color: #24292E"> $bucketName</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">aws</span><span style="color: #24292E"> </span><span style="color: #032F62">s3</span><span style="color: #24292E"> </span><span style="color: #032F62">mb</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;s3://${</span><span style="color: #24292E">bucketName</span><span style="color: #032F62">}&quot;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><p>S3 のバケットの名前は， AWS 全体で一意的でなければならないことから，前述のコマンドではランダムな文字列を含んだバケットの名前を生成し，<code>bucketName</code> という変数に格納している． そして， <code>aws s3 mb</code> (<code>mb</code> は make bucket の略) によって，新しいバケットを作成する．</p>
<p>次に，バケットの一覧を取得してみよう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">s3</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ls</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F69D50">2020-06-07</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">23</span><span style="color: #96D0FF">:45:44</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">mybucket-c6f93855550a72b5b66f5efe</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">aws</span><span style="color: #24292E"> </span><span style="color: #032F62">s3</span><span style="color: #24292E"> </span><span style="color: #032F62">ls</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6F42C1">2020-06-07</span><span style="color: #24292E"> </span><span style="color: #005CC5">23</span><span style="color: #032F62">:45:44</span><span style="color: #24292E"> </span><span style="color: #032F62">mybucket-c6f93855550a72b5b66f5efe</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><p>先ほど作成したバケットがリストにあることを確認できる．</p>
<p>本書のノーテーションとして，コマンドラインに入力するコマンドは，それがコマンドであると明示する目的で先頭に <code>$</code> がつけてある． <code>$</code> はコマンドをコピー&amp;ペーストするときは除かなければならない． 逆に，コマンドの出力は <code>$</code> なしで表示されている．</p>
<p>次に，バケットにファイルをアップロードする．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">echo</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;Hello world&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">&gt;</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">hello_world.txt</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">s3</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cp</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">hello_world.txt</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;s3://${</span><span style="color: #ADBAC7">bucketName</span><span style="color: #96D0FF">}/hello_world.txt&quot;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">echo</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;Hello world&quot;</span><span style="color: #24292E"> </span><span style="color: #D73A49">&gt;</span><span style="color: #24292E"> </span><span style="color: #032F62">hello_world.txt</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">aws</span><span style="color: #24292E"> </span><span style="color: #032F62">s3</span><span style="color: #24292E"> </span><span style="color: #032F62">cp</span><span style="color: #24292E"> </span><span style="color: #032F62">hello_world.txt</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;s3://${</span><span style="color: #24292E">bucketName</span><span style="color: #032F62">}/hello_world.txt&quot;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>上では <code>hello_world.txt</code> というダミーのファイルを作成して，それをアップロードした．</p>
<p>それでは，バケットの中にあるファイルの一覧を取得してみる．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">s3</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ls</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;s3://${</span><span style="color: #ADBAC7">bucketName</span><span style="color: #96D0FF">}&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--human-readable</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F69D50">2020-06-07</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">23</span><span style="color: #96D0FF">:54:19</span><span style="color: #ADBAC7">   </span><span style="color: #6CB6FF">13</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">Bytes</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">hello_world.txt</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">aws</span><span style="color: #24292E"> </span><span style="color: #032F62">s3</span><span style="color: #24292E"> </span><span style="color: #032F62">ls</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;s3://${</span><span style="color: #24292E">bucketName</span><span style="color: #032F62">}&quot;</span><span style="color: #24292E"> </span><span style="color: #005CC5">--human-readable</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6F42C1">2020-06-07</span><span style="color: #24292E"> </span><span style="color: #005CC5">23</span><span style="color: #032F62">:54:19</span><span style="color: #24292E">   </span><span style="color: #005CC5">13</span><span style="color: #24292E"> </span><span style="color: #032F62">Bytes</span><span style="color: #24292E"> </span><span style="color: #032F62">hello_world.txt</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><p>先ほどアップロードしたファイルがたしかに存在することがわかる．</p>
<p>最後に，使い終わったバケットを削除する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">s3</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">rb</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;s3://${</span><span style="color: #ADBAC7">bucketName</span><span style="color: #96D0FF">}&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--force</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">aws</span><span style="color: #24292E"> </span><span style="color: #032F62">s3</span><span style="color: #24292E"> </span><span style="color: #032F62">rb</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;s3://${</span><span style="color: #24292E">bucketName</span><span style="color: #032F62">}&quot;</span><span style="color: #24292E"> </span><span style="color: #005CC5">--force</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p><code>rb</code> は remove bucket の略である． デフォルトでは，バケットの中にファイルが存在すると削除できない． 空でないバケットを強制的に削除するには <code>--force</code> のオプションを付ける．</p>
<p>以上のように，AWS CLI を使って S3 バケットに対しての一連の操作を実行できた． EC2 や Lambda, DynamoDB などについても同様に AWS CLI を使ってあらゆる操作を実行できる．</p>
<p><strong>Amazon Resource Name (ARN)</strong></p>
<p>AWS 上のあらゆるリソースには， Amazon Resource Name (ARN) という固有の ID が付与されている． ARN は <code>arn:aws:s3:::my_bucket/</code> のようなフォーマットで記述され，ARN を使用することで，特定の AWS リソース (S3 のバケットや EC2 のインスタンス) を一意的に参照することができる．</p>
<p>S3 バケットや EC2 インスタンスなどには ARN に加えて，人間が読みやすい名前を定義することも可能である． この場合は，ARN または名前のどちらを用いても同じリソースを参照することが可能である．</p>
<h2 id="cloudformation-と-aws-cdk" tabindex="-1">CloudFormation と AWS CDK <a class="header-anchor" href="#cloudformation-と-aws-cdk" aria-label="Permalink to &quot;CloudFormation と AWS CDK&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="cloudformation-による-infrastructure-as-code-iac" tabindex="-1">CloudFormation による Infrastructure as Code (IaC) <a class="header-anchor" href="#cloudformation-による-infrastructure-as-code-iac" aria-label="Permalink to &quot;CloudFormation による Infrastructure as Code (IaC)&quot;">&ZeroWidthSpace;</a></h3>
<p>前節で述べたように，AWS API を使うことでクラウドの<strong>あらゆる</strong>リソースの作成・管理が可能である． よって，原理上は， API のコマンドを組み合わせていくことで，自分の作りたいクラウドを設計することができる．</p>
<p>しかし，ここで実用上考慮しなければならない点が一つある． AWS API には大きく分けて，<strong>リソースを操作する</strong>コマンドと，<strong>タスクを実行する</strong>コマンドがあることである (<a href="#fig_aws_iac">figure_title</a>)．</p>
<p><img src="./assets/iac.png" alt="AWS APIはリソースを操作するコマンドとタスクを実行するコマンドに大きく分けられる．リソースを記述・管理するのに使われるのが， CloudFormation と CDK である．"></p>
<p><strong>リソースを操作する</strong>とは，EC2 のインスタンスを起動したり，S3 のバケットを作成したり，データベースに新たなテーブルを追加する，などの<strong>静的なリソースを準備する</strong> 操作を指す． &quot;ハコ&quot;を作る操作とよんでも良いだろう． このようなコマンドは，<strong>クラウドのデプロイ時にのみ，一度だけ実行されればよい</strong>．</p>
<p><strong>タスクを実行するコマンド</strong> とは， EC2 のインスタンスにジョブを投入したり， S3 のバケットにデータを読み書きするなどの操作を指す． これは， EC2 や S3 などのリソース (&quot;ハコ&quot;) を前提として，その内部で実行されるべき計算を記述するものである． 前者に比べてこちらは<strong>動的な操作</strong>を担当する，と捉えることもできる．</p>
<p>そのような観点から，<strong>インフラを記述するプログラム</strong>と<strong>タスクを実行するプログラム</strong>はある程度分けて管理されるべきである． クラウドの開発は，クラウドの(静的な)リソースを記述するプログラムを作成するステップと，インフラ上で動く動的な操作を行うプログラムを作成するステップの二段階に分けて考えることができる．</p>
<p>AWS での静的リソースを管理するための仕組みが， <a href="https://aws.amazon.com/cloudformation/" target="_blank" rel="noreferrer">CloudFormation</a> である． CloudFormation とは， CloudFormation の文法に従ったテキストファイルを使って，AWS のインフラを記述する仕組みである． CloudFormation を使って，たとえば，EC2 のインスタンスをどれくらいのスペックで，何個起動するか，インスタンス間はどのようなネットワークで結び，どのようなアクセス権限を付与するか，などのリソースの要件を逐次的に記述することができる． 一度 CloudFormation ファイルができ上がれば，それにしたがったクラウドシステムをコマンド一つで AWS 上に展開することができる． また，CloudFormation ファイルを交換することで，全く同一のクラウド環境を他者が簡単に再現することも可能になる． このように，本来は物理的な実体のあるハードウェアを，プログラムによって記述し，管理するという考え方を，**Infrastructure as Code (IaC)**とよぶ．</p>
<p>CloudFormation を記述するには，基本的に <strong>JSON</strong> (JavaScript Object Notation) とよばれるフォーマットを使う． 次のコードは，JSON で記述された CloudFormation ファイルの一例 (抜粋) である．</p>
<div class="language-json vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">json</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #96D0FF">&quot;Resources&quot;</span><span style="color: #ADBAC7"> : {</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #FF938A; font-style: italic">...</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #8DDB8C">&quot;WebServer&quot;</span><span style="color: #ADBAC7">: {</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #8DDB8C">&quot;Type&quot;</span><span style="color: #ADBAC7"> : </span><span style="color: #96D0FF">&quot;AWS::EC2::Instance&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #8DDB8C">&quot;Properties&quot;</span><span style="color: #ADBAC7">: {</span></span>
<span class="line"><span style="color: #ADBAC7">      </span><span style="color: #8DDB8C">&quot;ImageId&quot;</span><span style="color: #ADBAC7"> : { </span><span style="color: #8DDB8C">&quot;Fn::FindInMap&quot;</span><span style="color: #ADBAC7"> : [ </span><span style="color: #96D0FF">&quot;AWSRegionArch2AMI&quot;</span><span style="color: #ADBAC7">, { </span><span style="color: #8DDB8C">&quot;Ref&quot;</span><span style="color: #ADBAC7"> : </span><span style="color: #96D0FF">&quot;AWS::Region&quot;</span><span style="color: #ADBAC7"> },</span></span>
<span class="line"><span style="color: #ADBAC7">                        { </span><span style="color: #8DDB8C">&quot;Fn::FindInMap&quot;</span><span style="color: #ADBAC7"> : [ </span><span style="color: #96D0FF">&quot;AWSInstanceType2Arch&quot;</span><span style="color: #ADBAC7">, { </span><span style="color: #8DDB8C">&quot;Ref&quot;</span><span style="color: #ADBAC7"> : </span><span style="color: #96D0FF">&quot;InstanceType&quot;</span><span style="color: #ADBAC7"> }, </span><span style="color: #96D0FF">&quot;Arch&quot;</span><span style="color: #ADBAC7"> ] } ] },</span></span>
<span class="line"><span style="color: #ADBAC7">      </span><span style="color: #8DDB8C">&quot;InstanceType&quot;</span><span style="color: #ADBAC7">   : { </span><span style="color: #8DDB8C">&quot;Ref&quot;</span><span style="color: #ADBAC7"> : </span><span style="color: #96D0FF">&quot;InstanceType&quot;</span><span style="color: #ADBAC7"> },</span></span>
<span class="line"><span style="color: #ADBAC7">      </span><span style="color: #8DDB8C">&quot;SecurityGroups&quot;</span><span style="color: #ADBAC7"> : [ {</span><span style="color: #8DDB8C">&quot;Ref&quot;</span><span style="color: #ADBAC7"> : </span><span style="color: #96D0FF">&quot;WebServerSecurityGroup&quot;</span><span style="color: #ADBAC7">} ],</span></span>
<span class="line"><span style="color: #ADBAC7">      </span><span style="color: #8DDB8C">&quot;KeyName&quot;</span><span style="color: #ADBAC7">        : { </span><span style="color: #8DDB8C">&quot;Ref&quot;</span><span style="color: #ADBAC7"> : </span><span style="color: #96D0FF">&quot;KeyName&quot;</span><span style="color: #ADBAC7"> },</span></span>
<span class="line"><span style="color: #ADBAC7">      </span><span style="color: #8DDB8C">&quot;UserData&quot;</span><span style="color: #ADBAC7"> : { </span><span style="color: #8DDB8C">&quot;Fn::Base64&quot;</span><span style="color: #ADBAC7"> : { </span><span style="color: #8DDB8C">&quot;Fn::Join&quot;</span><span style="color: #ADBAC7"> : [</span><span style="color: #96D0FF">&quot;&quot;</span><span style="color: #ADBAC7">, [</span></span>
<span class="line"><span style="color: #ADBAC7">                     </span><span style="color: #96D0FF">&quot;#!/bin/bash -xe</span><span style="color: #F47067">\n</span><span style="color: #96D0FF">&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                     </span><span style="color: #96D0FF">&quot;yum update -y aws-cfn-bootstrap</span><span style="color: #F47067">\n</span><span style="color: #96D0FF">&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">                     </span><span style="color: #96D0FF">&quot;/opt/aws/bin/cfn-init -v &quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                     </span><span style="color: #96D0FF">&quot;         --stack &quot;</span><span style="color: #ADBAC7">, { </span><span style="color: #8DDB8C">&quot;Ref&quot;</span><span style="color: #ADBAC7"> : </span><span style="color: #96D0FF">&quot;AWS::StackName&quot;</span><span style="color: #ADBAC7"> },</span></span>
<span class="line"><span style="color: #ADBAC7">                     </span><span style="color: #96D0FF">&quot;         --resource WebServer &quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                     </span><span style="color: #96D0FF">&quot;         --configsets wordpress_install &quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                     </span><span style="color: #96D0FF">&quot;         --region &quot;</span><span style="color: #ADBAC7">, { </span><span style="color: #8DDB8C">&quot;Ref&quot;</span><span style="color: #ADBAC7"> : </span><span style="color: #96D0FF">&quot;AWS::Region&quot;</span><span style="color: #ADBAC7"> }, </span><span style="color: #96D0FF">&quot;</span><span style="color: #F47067">\n</span><span style="color: #96D0FF">&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">                     </span><span style="color: #96D0FF">&quot;/opt/aws/bin/cfn-signal -e $? &quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                     </span><span style="color: #96D0FF">&quot;         --stack &quot;</span><span style="color: #ADBAC7">, { </span><span style="color: #8DDB8C">&quot;Ref&quot;</span><span style="color: #ADBAC7"> : </span><span style="color: #96D0FF">&quot;AWS::StackName&quot;</span><span style="color: #ADBAC7"> },</span></span>
<span class="line"><span style="color: #ADBAC7">                     </span><span style="color: #96D0FF">&quot;         --resource WebServer &quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                     </span><span style="color: #96D0FF">&quot;         --region &quot;</span><span style="color: #ADBAC7">, { </span><span style="color: #8DDB8C">&quot;Ref&quot;</span><span style="color: #ADBAC7"> : </span><span style="color: #96D0FF">&quot;AWS::Region&quot;</span><span style="color: #ADBAC7"> }, </span><span style="color: #96D0FF">&quot;</span><span style="color: #F47067">\n</span><span style="color: #96D0FF">&quot;</span></span>
<span class="line"><span style="color: #ADBAC7">      ]]}}</span></span>
<span class="line"><span style="color: #ADBAC7">    },</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #FF938A; font-style: italic">...</span></span>
<span class="line"><span style="color: #ADBAC7">  },</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #FF938A; font-style: italic">...</span></span>
<span class="line"><span style="color: #ADBAC7">},</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #032F62">&quot;Resources&quot;</span><span style="color: #24292E"> : {</span></span>
<span class="line"><span style="color: #24292E">  </span><span style="color: #B31D28; font-style: italic">...</span></span>
<span class="line"><span style="color: #24292E">  </span><span style="color: #005CC5">&quot;WebServer&quot;</span><span style="color: #24292E">: {</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">&quot;Type&quot;</span><span style="color: #24292E"> : </span><span style="color: #032F62">&quot;AWS::EC2::Instance&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">&quot;Properties&quot;</span><span style="color: #24292E">: {</span></span>
<span class="line"><span style="color: #24292E">      </span><span style="color: #005CC5">&quot;ImageId&quot;</span><span style="color: #24292E"> : { </span><span style="color: #005CC5">&quot;Fn::FindInMap&quot;</span><span style="color: #24292E"> : [ </span><span style="color: #032F62">&quot;AWSRegionArch2AMI&quot;</span><span style="color: #24292E">, { </span><span style="color: #005CC5">&quot;Ref&quot;</span><span style="color: #24292E"> : </span><span style="color: #032F62">&quot;AWS::Region&quot;</span><span style="color: #24292E"> },</span></span>
<span class="line"><span style="color: #24292E">                        { </span><span style="color: #005CC5">&quot;Fn::FindInMap&quot;</span><span style="color: #24292E"> : [ </span><span style="color: #032F62">&quot;AWSInstanceType2Arch&quot;</span><span style="color: #24292E">, { </span><span style="color: #005CC5">&quot;Ref&quot;</span><span style="color: #24292E"> : </span><span style="color: #032F62">&quot;InstanceType&quot;</span><span style="color: #24292E"> }, </span><span style="color: #032F62">&quot;Arch&quot;</span><span style="color: #24292E"> ] } ] },</span></span>
<span class="line"><span style="color: #24292E">      </span><span style="color: #005CC5">&quot;InstanceType&quot;</span><span style="color: #24292E">   : { </span><span style="color: #005CC5">&quot;Ref&quot;</span><span style="color: #24292E"> : </span><span style="color: #032F62">&quot;InstanceType&quot;</span><span style="color: #24292E"> },</span></span>
<span class="line"><span style="color: #24292E">      </span><span style="color: #005CC5">&quot;SecurityGroups&quot;</span><span style="color: #24292E"> : [ {</span><span style="color: #005CC5">&quot;Ref&quot;</span><span style="color: #24292E"> : </span><span style="color: #032F62">&quot;WebServerSecurityGroup&quot;</span><span style="color: #24292E">} ],</span></span>
<span class="line"><span style="color: #24292E">      </span><span style="color: #005CC5">&quot;KeyName&quot;</span><span style="color: #24292E">        : { </span><span style="color: #005CC5">&quot;Ref&quot;</span><span style="color: #24292E"> : </span><span style="color: #032F62">&quot;KeyName&quot;</span><span style="color: #24292E"> },</span></span>
<span class="line"><span style="color: #24292E">      </span><span style="color: #005CC5">&quot;UserData&quot;</span><span style="color: #24292E"> : { </span><span style="color: #005CC5">&quot;Fn::Base64&quot;</span><span style="color: #24292E"> : { </span><span style="color: #005CC5">&quot;Fn::Join&quot;</span><span style="color: #24292E"> : [</span><span style="color: #032F62">&quot;&quot;</span><span style="color: #24292E">, [</span></span>
<span class="line"><span style="color: #24292E">                     </span><span style="color: #032F62">&quot;#!/bin/bash -xe</span><span style="color: #005CC5">\n</span><span style="color: #032F62">&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                     </span><span style="color: #032F62">&quot;yum update -y aws-cfn-bootstrap</span><span style="color: #005CC5">\n</span><span style="color: #032F62">&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">                     </span><span style="color: #032F62">&quot;/opt/aws/bin/cfn-init -v &quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                     </span><span style="color: #032F62">&quot;         --stack &quot;</span><span style="color: #24292E">, { </span><span style="color: #005CC5">&quot;Ref&quot;</span><span style="color: #24292E"> : </span><span style="color: #032F62">&quot;AWS::StackName&quot;</span><span style="color: #24292E"> },</span></span>
<span class="line"><span style="color: #24292E">                     </span><span style="color: #032F62">&quot;         --resource WebServer &quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                     </span><span style="color: #032F62">&quot;         --configsets wordpress_install &quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                     </span><span style="color: #032F62">&quot;         --region &quot;</span><span style="color: #24292E">, { </span><span style="color: #005CC5">&quot;Ref&quot;</span><span style="color: #24292E"> : </span><span style="color: #032F62">&quot;AWS::Region&quot;</span><span style="color: #24292E"> }, </span><span style="color: #032F62">&quot;</span><span style="color: #005CC5">\n</span><span style="color: #032F62">&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">                     </span><span style="color: #032F62">&quot;/opt/aws/bin/cfn-signal -e $? &quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                     </span><span style="color: #032F62">&quot;         --stack &quot;</span><span style="color: #24292E">, { </span><span style="color: #005CC5">&quot;Ref&quot;</span><span style="color: #24292E"> : </span><span style="color: #032F62">&quot;AWS::StackName&quot;</span><span style="color: #24292E"> },</span></span>
<span class="line"><span style="color: #24292E">                     </span><span style="color: #032F62">&quot;         --resource WebServer &quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                     </span><span style="color: #032F62">&quot;         --region &quot;</span><span style="color: #24292E">, { </span><span style="color: #005CC5">&quot;Ref&quot;</span><span style="color: #24292E"> : </span><span style="color: #032F62">&quot;AWS::Region&quot;</span><span style="color: #24292E"> }, </span><span style="color: #032F62">&quot;</span><span style="color: #005CC5">\n</span><span style="color: #032F62">&quot;</span></span>
<span class="line"><span style="color: #24292E">      ]]}}</span></span>
<span class="line"><span style="color: #24292E">    },</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #B31D28; font-style: italic">...</span></span>
<span class="line"><span style="color: #24292E">  },</span></span>
<span class="line"><span style="color: #24292E">  </span><span style="color: #B31D28; font-style: italic">...</span></span>
<span class="line"><span style="color: #24292E">},</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br></div></div><p>ここでは， &quot;WebServer&quot; という名前のつけられた EC2 インスタンスを定義している．かなり長大で複雑な記述であるが，これによって所望のスペック・OS をもつ EC2 インスタンスを自動的に生成することが可能になる．</p>
<h3 id="aws-cdk" tabindex="-1">AWS CDK <a class="header-anchor" href="#aws-cdk" aria-label="Permalink to &quot;AWS CDK&quot;">&ZeroWidthSpace;</a></h3>
<p>前節で紹介した CloudFormation は，見てわかるとおり大変記述が複雑であり，またそれのどれか一つにでも誤りがあってはいけない． また，基本的に&quot;テキスト&quot;を書いていくことになるので，プログラミング言語で使うような変数やクラスといった便利な概念が使えない　(厳密には， CloudFormation にも変数に相当するような機能は存在する)． また，記述の多くの部分は繰り返しが多く，自動化できる部分も多い．</p>
<p>そのような悩みを解決してくれるのが， <a href="https://aws.amazon.com/cdk/" target="_blank" rel="noreferrer">AWS Cloud Development Kit (CDK)</a> である． <strong>CDK は Python などのプログラミング言語を使って CloudFormation を自動的に生成してくれるツールである．</strong> CDK は 2019 年にリリースされたばかりの比較的新しいツールで，日々改良が進められている (<a href="https://github.com/aws/aws-cdk/releases" target="_blank" rel="noreferrer">GitHub リポジトリ</a> のリリースを見ればその開発のスピードの速さがわかるだろう)． CDK は TypeScript (JavaScript), Python, Java など複数の言語でサポートされている．</p>
<p>CDK を使うことで，CloudFormation に相当するクラウドリソースの記述を，より親しみのあるプログラミング言語を使って行うことができる． かつ，典型的なリソース操作に関してはパラメータの多くの部分を自動で決定してくれるので，記述しなければならない量もかなり削減される．</p>
<p>以下に Python を使った CDK のコードの一例 (抜粋) を示す．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">from</span><span style="color: #ADBAC7"> aws_cdk </span><span style="color: #F47067">import</span><span style="color: #ADBAC7"> (</span></span>
<span class="line"><span style="color: #ADBAC7">    core,</span></span>
<span class="line"><span style="color: #ADBAC7">    aws_ec2 </span><span style="color: #F47067">as</span><span style="color: #ADBAC7"> ec2,</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F47067">class</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50">MyFirstEc2</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">core</span><span style="color: #ADBAC7">.</span><span style="color: #6CB6FF">Stack</span><span style="color: #ADBAC7">):</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">def</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">__init__</span><span style="color: #ADBAC7">(self, scope, name, </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">kwargs):</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #6CB6FF">super</span><span style="color: #ADBAC7">().</span><span style="color: #6CB6FF">__init__</span><span style="color: #ADBAC7">(scope, name, </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">kwargs)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        vpc </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ec2.Vpc(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">...</span><span style="color: #ADBAC7"> </span><span style="color: #768390"># some parameters</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        sg </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ec2.SecurityGroup(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">...</span><span style="color: #ADBAC7"> </span><span style="color: #768390"># some parameters</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        host </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ec2.Instance(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;MyGreatEc2&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">instance_type</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.InstanceType(</span><span style="color: #96D0FF">&quot;t2.micro&quot;</span><span style="color: #ADBAC7">),</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">machine_image</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.MachineImage.latest_amazon_linux(),</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">vpc</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">vpc,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">...</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">from</span><span style="color: #24292E"> aws_cdk </span><span style="color: #D73A49">import</span><span style="color: #24292E"> (</span></span>
<span class="line"><span style="color: #24292E">    core,</span></span>
<span class="line"><span style="color: #24292E">    aws_ec2 </span><span style="color: #D73A49">as</span><span style="color: #24292E"> ec2,</span></span>
<span class="line"><span style="color: #24292E">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D73A49">class</span><span style="color: #24292E"> </span><span style="color: #6F42C1">MyFirstEc2</span><span style="color: #24292E">(</span><span style="color: #6F42C1">core</span><span style="color: #24292E">.</span><span style="color: #6F42C1">Stack</span><span style="color: #24292E">):</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">def</span><span style="color: #24292E"> </span><span style="color: #005CC5">__init__</span><span style="color: #24292E">(self, scope, name, </span><span style="color: #D73A49">**</span><span style="color: #24292E">kwargs):</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #005CC5">super</span><span style="color: #24292E">().</span><span style="color: #005CC5">__init__</span><span style="color: #24292E">(scope, name, </span><span style="color: #D73A49">**</span><span style="color: #24292E">kwargs)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        vpc </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ec2.Vpc(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">...</span><span style="color: #24292E"> </span><span style="color: #6A737D"># some parameters</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        sg </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ec2.SecurityGroup(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">...</span><span style="color: #24292E"> </span><span style="color: #6A737D"># some parameters</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        host </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ec2.Instance(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;MyGreatEc2&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">instance_type</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.InstanceType(</span><span style="color: #032F62">&quot;t2.micro&quot;</span><span style="color: #24292E">),</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">machine_image</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.MachineImage.latest_amazon_linux(),</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">vpc</span><span style="color: #D73A49">=</span><span style="color: #24292E">vpc,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">...</span></span>
<span class="line"><span style="color: #24292E">        )</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br></div></div><p>このコードは，一つ前に示した JSON を使った CloudFormation と実質的に同じことを記述している． とても煩雑だった CloudFormation ファイルに比べて， CDK と Python を使うことで格段に短く，わかりやすく記述できることができるのがわかるだろう．</p>
<p>本書の主題は，<strong>CDK を使って，コードを書きながら AWS の概念や開発方法を学んでいくことである</strong>． 後の章では CDK を使って様々なハンズオンを実施していく． 早速，最初のハンズオンでは， CDK を使って EC2 インスタンスを作成する方法を学んでいこう．</p>
<ul>
<li><a href="https://github.com/aws-samples/aws-cdk-examples" target="_blank" rel="noreferrer">AWS CDK Examples</a>: CDK を使ったプロジェクトの例が多数紹介されている． ここにある例をテンプレートに自分のアプリケーションの開発を進めるとよい．</li>
</ul>
<h1 id="hands-on-1-初めての-ec2-インスタンスを起動する" tabindex="-1">Hands-on #1: 初めての EC2 インスタンスを起動する <a class="header-anchor" href="#hands-on-1-初めての-ec2-インスタンスを起動する" aria-label="Permalink to &quot;Hands-on \#1: 初めての EC2 インスタンスを起動する&quot;">&ZeroWidthSpace;</a></h1>
<p>ハンズオンの第一回では， CDK を使って EC2 のインスタンス(仮想サーバー)を作成し，SSH でサーバーにログインする，という演習を行う． このハンズオンを終えれば，あなたは自分だけのサーバーを AWS 上に立ち上げ，自由に計算を走らせることができるようになるのである！</p>
<h2 id="準備" tabindex="-1">準備 <a class="header-anchor" href="#準備" aria-label="Permalink to &quot;準備&quot;">&ZeroWidthSpace;</a></h2>
<p>ハンズオンのソースコードは GitHub の <a href="https://github.com/andatoshiki/toshiki-notebooktree/main/handson/ec2-get-started" target="_blank" rel="noreferrer">handson/ec2-get-started</a> に置いてある．</p>
<p>このハンズオンは，基本的に <a href="https://aws.amazon.com/free/?all-free-tier.sort-by=item.additionalFields.SortRank&amp;all-free-tier.sort-order=asc" target="_blank" rel="noreferrer">AWS の無料枠</a> の範囲内で実行することができる．</p>
<p>まずは，ハンズオンを実行するための環境を整える． これらの環境整備は，後のハンズオンでも前提となるものなので確実にミスなく行っていただきたい．</p>
<ul>
<li><strong>AWS Account</strong>: ハンズオンを実行するには個人の AWS アカウントが必要である． AWS アカウントの取得については <a href="#sec:create_aws_account">AWS アカウントの取得</a> を参照のこと．</li>
<li><strong>Python と Node.js</strong>: 本ハンズオンを実行するには，Python (3.6 以上)，Node.js (12.0 以上) がインストールされていなければならない．</li>
<li><strong>AWS CLI</strong>: AWS CLI のインストールについては， <a href="#aws_cli_install">AWS CLI のインストール</a> を参照． ここに記載されている認証鍵の設定も済ませておくこと．</li>
<li><strong>AWS CDK</strong>: AWS CDK のインストールについては， <a href="#aws_cdk_install">AWS CDK のインストール</a> を参照．</li>
<li><strong>ソースコードのダウンロード</strong>: 本ハンズオンで使用するプログラムのソースコードを，以下のコマンドを使って GitHub からダウンロードする．</li>
</ul>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">git</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">clone</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">https://github.com/tomomano/learn-aws-by-coding.git</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">git</span><span style="color: #24292E"> </span><span style="color: #032F62">clone</span><span style="color: #24292E"> </span><span style="color: #032F62">https://github.com/tomomano/learn-aws-by-coding.git</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>あるいは， <code>https://github.com/tomomano/learn-aws-by-coding</code> のページに行って，右上のダウンロードボタンからダウンロードすることもできる．</p>
<p><strong>Docker を使用する場合</strong></p>
<p>Python, Node.js, AWS CDK など，ハンズオンのプログラムを実行するために必要なプログラム/ライブラリがインストール済みの Docker image を用意した． また，ハンズオンのソースコードもパッケージ済みである． Docker の使い方を知っている読者は，これを使えば，諸々のインストールをする必要なく，すぐにハンズオンのプログラムを実行できる．</p>
<p>使用方法については <a href="#sec_handson_docker">ハンズオン実行用の Docker image の使い方</a> を参照のこと．</p>
<h2 id="ssh" tabindex="-1">SSH <a class="header-anchor" href="#ssh" aria-label="Permalink to &quot;SSH&quot;">&ZeroWidthSpace;</a></h2>
<p><strong>SSH (secure shell)</strong> は Unix 系のリモートサーバーに安全にアクセスするためのツールである． 本ハンズオンでは， SSH を使って仮想サーバーにアクセスする． SSH に慣れていない読者のため，簡単な説明をここで行おう．</p>
<p>SSH による通信はすべて暗号化されているので，機密情報をインターネットを介して安全に送受信することができる． 本ハンズオンで，リモートのサーバーにアクセスするための SSH クライアントがローカルマシンにインストールされている必要がある． SSH クライアントは Linux/Mac には標準搭載されている． Windows の場合は WSL をインストールすることで SSH クライアントを利用することを推奨する (<a href="#environments">環境構築</a> を参照)．</p>
<p>SSH コマンドの基本的な使い方を次に示す． <code>&lt;host name&gt;</code> はアクセスする先のサーバーの IP アドレスや DNS によるホストネームが入る． <code>&lt;user name&gt;</code> は接続する先のユーザー名である．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ssh</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">&lt;</span><span style="color: #96D0FF">user</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">nam</span><span style="color: #ADBAC7">e</span><span style="color: #F47067">&gt;</span><span style="color: #96D0FF">@</span><span style="color: #F47067">&lt;</span><span style="color: #96D0FF">host</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">nam</span><span style="color: #ADBAC7">e</span><span style="color: #F47067">&gt;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">ssh</span><span style="color: #24292E"> </span><span style="color: #D73A49">&lt;</span><span style="color: #032F62">user</span><span style="color: #24292E"> </span><span style="color: #032F62">nam</span><span style="color: #24292E">e</span><span style="color: #D73A49">&gt;</span><span style="color: #032F62">@</span><span style="color: #D73A49">&lt;</span><span style="color: #032F62">host</span><span style="color: #24292E"> </span><span style="color: #032F62">nam</span><span style="color: #24292E">e</span><span style="color: #D73A49">&gt;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>SSH は平文のパスワードによる認証を行うこともできるが，より強固なセキュリティを施すため，<strong>公開鍵暗号方式(Public Key Cryptography)による認証</strong>を行うことが強く推奨されており， EC2 はこの方法でしかアクセスを許していない． 公開鍵暗号方式の仕組みについては各自勉強してほしい． 本ハンズオンにおいて大事なことは，<strong>EC2 インスタンスが公開鍵(Public key)を保持し，クライアントとなるコンピュータ(読者自身のコンピュータ)が秘密鍵(Private key)を保持する</strong>，という点である． EC2 のインスタンスには秘密鍵を持ったコンピュータのみがアクセスすることができる．逆に言うと，秘密鍵が漏洩すると第三者もサーバーにアクセスできることになるので，<strong>秘密鍵は絶対に漏洩することのないよう注意して管理する</strong>．</p>
<p>SSH コマンドでは，ログインのために使用する秘密鍵ファイルを <code>-i</code> もしくは <code>--identity_file</code> のオプションで指定することができる． たとえば，次のように使う．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ssh</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-i</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">Ec2SecretKey.pem</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">&lt;</span><span style="color: #96D0FF">user</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">nam</span><span style="color: #ADBAC7">e</span><span style="color: #F47067">&gt;</span><span style="color: #96D0FF">@</span><span style="color: #F47067">&lt;</span><span style="color: #96D0FF">host</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">nam</span><span style="color: #ADBAC7">e</span><span style="color: #F47067">&gt;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">ssh</span><span style="color: #24292E"> </span><span style="color: #005CC5">-i</span><span style="color: #24292E"> </span><span style="color: #032F62">Ec2SecretKey.pem</span><span style="color: #24292E"> </span><span style="color: #D73A49">&lt;</span><span style="color: #032F62">user</span><span style="color: #24292E"> </span><span style="color: #032F62">nam</span><span style="color: #24292E">e</span><span style="color: #D73A49">&gt;</span><span style="color: #032F62">@</span><span style="color: #D73A49">&lt;</span><span style="color: #032F62">host</span><span style="color: #24292E"> </span><span style="color: #032F62">nam</span><span style="color: #24292E">e</span><span style="color: #D73A49">&gt;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><h2 id="アプリケーションの説明" tabindex="-1">アプリケーションの説明 <a class="header-anchor" href="#アプリケーションの説明" aria-label="Permalink to &quot;アプリケーションの説明&quot;">&ZeroWidthSpace;</a></h2>
<p>このハンズオンで作成するアプリケーションの概要を <a href="#handson_01_architecture">figure_title</a> に示す．</p>
<p><img src="./assets/handson-01/app_architecture.png" alt="ハンズオン#1で作製するアプリケーションのアーキテクチャ"></p>
<p>このアプリケーションではまず，<strong>VPC (Virtual Private Cloud)</strong> を使ってプライベートな仮想ネットワーク環境を立ち上げている． その VPC の public subnet の内側に，<strong>EC2 (Elatic Compute Cloud)</strong> の仮想サーバーを配置する． さらに，セキュリティのため， <strong>Security Group</strong> による EC2 インスタンスへのアクセス制限を設定している． このようにして作成された仮想サーバーに，SSH を使ってアクセスし，簡単な計算を行う．</p>
<p><a href="#handson_01_architecture">figure_title</a> のようなアプリケーションを，CDK を使って構築する．</p>
<p>早速ではあるが，今回のハンズオンで使用するプログラムを見てみよう (<a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/ec2-get-started/app.py" target="_blank" rel="noreferrer">handson/ec2-get-started/app.py</a>)．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">class</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50">MyFirstEc2</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">core</span><span style="color: #ADBAC7">.</span><span style="color: #6CB6FF">Stack</span><span style="color: #ADBAC7">):</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">def</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">__init__</span><span style="color: #ADBAC7">(self, scope: core.App, name: </span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">, key_name: </span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">, </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">kwargs) -&gt; </span><span style="color: #6CB6FF">None</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #6CB6FF">super</span><span style="color: #ADBAC7">().</span><span style="color: #6CB6FF">__init__</span><span style="color: #ADBAC7">(scope, name, </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">kwargs)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        vpc </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ec2.Vpc(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;MyFirstEc2-Vpc&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">max_azs</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">cidr</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;10.10.0.0/23&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">subnet_configuration</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">[</span></span>
<span class="line"><span style="color: #ADBAC7">                ec2.SubnetConfiguration(</span></span>
<span class="line"><span style="color: #ADBAC7">                    </span><span style="color: #F69D50">name</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;public&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                    </span><span style="color: #F69D50">subnet_type</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.SubnetType.</span><span style="color: #6CB6FF">PUBLIC</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                )</span></span>
<span class="line"><span style="color: #ADBAC7">            ],</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">nat_gateways</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        sg </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ec2.SecurityGroup(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;MyFirstEc2Vpc-Sg&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">vpc</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">vpc,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">allow_all_outbound</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">True</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"><span style="color: #ADBAC7">        sg.add_ingress_rule(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">peer</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.Peer.any_ipv4(),</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">connection</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.Port.tcp(</span><span style="color: #6CB6FF">22</span><span style="color: #ADBAC7">),</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        host </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ec2.Instance(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;MyFirstEc2Instance&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">instance_type</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.InstanceType(</span><span style="color: #96D0FF">&quot;t2.micro&quot;</span><span style="color: #ADBAC7">),</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">machine_image</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.MachineImage.latest_amazon_linux(),</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">vpc</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">vpc,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">vpc_subnets</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.SubnetSelection(</span><span style="color: #F69D50">subnet_type</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.SubnetType.</span><span style="color: #6CB6FF">PUBLIC</span><span style="color: #ADBAC7">),</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">security_group</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">sg,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">key_name</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">key_name</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">class</span><span style="color: #24292E"> </span><span style="color: #6F42C1">MyFirstEc2</span><span style="color: #24292E">(</span><span style="color: #6F42C1">core</span><span style="color: #24292E">.</span><span style="color: #6F42C1">Stack</span><span style="color: #24292E">):</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">def</span><span style="color: #24292E"> </span><span style="color: #005CC5">__init__</span><span style="color: #24292E">(self, scope: core.App, name: </span><span style="color: #005CC5">str</span><span style="color: #24292E">, key_name: </span><span style="color: #005CC5">str</span><span style="color: #24292E">, </span><span style="color: #D73A49">**</span><span style="color: #24292E">kwargs) -&gt; </span><span style="color: #005CC5">None</span><span style="color: #24292E">:</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #005CC5">super</span><span style="color: #24292E">().</span><span style="color: #005CC5">__init__</span><span style="color: #24292E">(scope, name, </span><span style="color: #D73A49">**</span><span style="color: #24292E">kwargs)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        vpc </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ec2.Vpc(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;MyFirstEc2-Vpc&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">max_azs</span><span style="color: #D73A49">=</span><span style="color: #005CC5">1</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">cidr</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;10.10.0.0/23&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">subnet_configuration</span><span style="color: #D73A49">=</span><span style="color: #24292E">[</span></span>
<span class="line"><span style="color: #24292E">                ec2.SubnetConfiguration(</span></span>
<span class="line"><span style="color: #24292E">                    </span><span style="color: #E36209">name</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;public&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                    </span><span style="color: #E36209">subnet_type</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.SubnetType.</span><span style="color: #005CC5">PUBLIC</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                )</span></span>
<span class="line"><span style="color: #24292E">            ],</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">nat_gateways</span><span style="color: #D73A49">=</span><span style="color: #005CC5">0</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        sg </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ec2.SecurityGroup(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;MyFirstEc2Vpc-Sg&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">vpc</span><span style="color: #D73A49">=</span><span style="color: #24292E">vpc,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">allow_all_outbound</span><span style="color: #D73A49">=</span><span style="color: #005CC5">True</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"><span style="color: #24292E">        sg.add_ingress_rule(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">peer</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.Peer.any_ipv4(),</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">connection</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.Port.tcp(</span><span style="color: #005CC5">22</span><span style="color: #24292E">),</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        host </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ec2.Instance(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;MyFirstEc2Instance&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">instance_type</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.InstanceType(</span><span style="color: #032F62">&quot;t2.micro&quot;</span><span style="color: #24292E">),</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">machine_image</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.MachineImage.latest_amazon_linux(),</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">vpc</span><span style="color: #D73A49">=</span><span style="color: #24292E">vpc,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">vpc_subnets</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.SubnetSelection(</span><span style="color: #E36209">subnet_type</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.SubnetType.</span><span style="color: #005CC5">PUBLIC</span><span style="color: #24292E">),</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">security_group</span><span style="color: #D73A49">=</span><span style="color: #24292E">sg,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">key_name</span><span style="color: #D73A49">=</span><span style="color: #24292E">key_name</span></span>
<span class="line"><span style="color: #24292E">        )</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br><span class="line-number">36</span><br><span class="line-number">37</span><br><span class="line-number">38</span><br><span class="line-number">39</span><br><span class="line-number">40</span><br></div></div><ul>
<li>
<p>まず最初に，VPC を定義する．</p>
</li>
<li>
<p>次に， security group (SG) を定義している． ここでは，任意の IPv4 のアドレスからの，ポート 22 (SSH の接続に使用される)への接続を許可している． それ以外の接続は拒絶される．</p>
</li>
<li>
<p>最後に，上記で作った VPC と SG が付与された EC2 インスタンスを作成している． インスタンスタイプは <code>t2.micro</code> を選択し， <a href="https://aws.amazon.com/amazon-linux-ami/" target="_blank" rel="noreferrer">Amazon Linux</a> を OS として設定している．</p>
</li>
</ul>
<p>それぞれについて，もう少し詳しく説明しよう．</p>
<h3 id="vpc-virtual-private-cloud" tabindex="-1">VPC (Virtual Private Cloud) <a class="header-anchor" href="#vpc-virtual-private-cloud" aria-label="Permalink to &quot;VPC (Virtual Private Cloud)&quot;">&ZeroWidthSpace;</a></h3>
<p><strong>VPC のアイコン.</strong></p>
<p><img src="./assets/aws_logos/VPC.png" alt="VPC"></p>
<p>VPC は AWS 上にプライベートな仮想ネットワーク環境を構築するツールである．高度な計算システムを構築するには，複数のサーバーを連動させて計算を行う必要があるが，そのような場合に互いのアドレスなどを管理する必要があり，そういった目的で VPC は有用である．</p>
<p>本ハンズオンでは，サーバーは一つしか起動しないので，VPC の恩恵はよく分からないかもしれない．しかし，EC2 インスタンスは必ず VPC の中に配置されなければならない，という制約があるので，このハンズオンでもミニマルな VPC を構成している．</p>
<p>興味のある読者のために，VPC のコードについてもう少し詳しく説明しよう．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">vpc </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ec2.Vpc(</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;MyFirstEc2-Vpc&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">max_azs</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">cidr</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;10.10.0.0/23&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">subnet_configuration</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">[</span></span>
<span class="line"><span style="color: #ADBAC7">        ec2.SubnetConfiguration(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">name</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;public&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">subnet_type</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.SubnetType.</span><span style="color: #6CB6FF">PUBLIC</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"><span style="color: #ADBAC7">    ],</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">nat_gateways</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">vpc </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ec2.Vpc(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;MyFirstEc2-Vpc&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">max_azs</span><span style="color: #D73A49">=</span><span style="color: #005CC5">1</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">cidr</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;10.10.0.0/23&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">subnet_configuration</span><span style="color: #D73A49">=</span><span style="color: #24292E">[</span></span>
<span class="line"><span style="color: #24292E">        ec2.SubnetConfiguration(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">name</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;public&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">subnet_type</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.SubnetType.</span><span style="color: #005CC5">PUBLIC</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"><span style="color: #24292E">    ],</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">nat_gateways</span><span style="color: #D73A49">=</span><span style="color: #005CC5">0</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br></div></div><ul>
<li>
<p><code>max_azs=1</code> : このパラメータは，前章で説明した avaialibility zone (AZ) を設定している． このハンズオンでは，特にデータセンターの障害などを気にする必要はないので <code>1</code> にしている．</p>
</li>
<li>
<p><code>cidr=&quot;10.10.0.0/23&quot;</code> : このパラメータは，VPC 内の IPv4 のレンジを指定している． CIDR 記法については， <a href="https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing" target="_blank" rel="noreferrer">Wikipedia</a>などを参照． <code>10.10.0.0/23</code> は <code>10.10.0.0</code> から <code>10.10.1.255</code> までの 512 個の連続したアドレス範囲を指している． つまり，この VPC では最大で 512 個のユニークな IPv4 アドレスが使えることになる． 今回はサーバーは一つなので 512 個は明らかに多すぎるが，VPC はアドレスの数はどれだけ作成しても無料なので，多めに作成した．</p>
</li>
<li>
<p><code>subnet_configuration=...</code> : このパラメータは，VPC にどのようなサブネットを作るか，を決めている． サブネットの種類には <strong>private subnet</strong> と <strong>public subnet</strong> の二種類がある． private subnet は基本的にインターネットとは遮断されたサブネット環境である． インターネットと繋がっていないので，セキュリティは極めて高く， VPC 内のサーバーとのみ通信を行えばよい EC2 インスタンスはここに配置する． Public subnet とはインターネットに繋がったサブネットである． 本ハンズオンで作成するサーバーは，外から SSH でログインを行いたいので， Public subnet 内に配置する． より詳細な記述は <a href="https://docs.aws.amazon.com/vpc/latest/userguide/VPC_Subnets.html#vpc-subnet-basics" target="_blank" rel="noreferrer">公式ドキュメンテーション</a> を参照．</p>
</li>
<li>
<p><code>natgateways=0</code> : これは少し高度な内容なので省略する (興味のある読者は <a href="https://docs.aws.amazon.com/vpc/latest/userguide/vpc-nat-gateway.html" target="_blank" rel="noreferrer">公式ドキュメンテーション</a>を参照)． が，<strong>これを 0 にしておかないと，NAT Gateway の利用料金が発生してしまうので，注意！</strong></p>
</li>
</ul>
<h3 id="security-group" tabindex="-1">Security Group <a class="header-anchor" href="#security-group" aria-label="Permalink to &quot;Security Group&quot;">&ZeroWidthSpace;</a></h3>
<p>Security group (SG) は， EC2 インスタンスに付与することのできる仮想ファイアーウォールである． たとえば，特定の IP アドレスから来た接続を許可・拒絶したり　(インバウンド・トラフィックの制限) ，逆に特定の IP アドレスへのアクセスを禁止したり (アウトバウンド・トラフィックの制限) することができる．</p>
<p>コードの該当部分を見てみよう．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">sg </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ec2.SecurityGroup(</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;MyFirstEc2Vpc-Sg&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">vpc</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">vpc,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">allow_all_outbound</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">True</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">sg.add_ingress_rule(</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">peer</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.Peer.any_ipv4(),</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">connection</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.Port.tcp(</span><span style="color: #6CB6FF">22</span><span style="color: #ADBAC7">),</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">sg </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ec2.SecurityGroup(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;MyFirstEc2Vpc-Sg&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">vpc</span><span style="color: #D73A49">=</span><span style="color: #24292E">vpc,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">allow_all_outbound</span><span style="color: #D73A49">=</span><span style="color: #005CC5">True</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">sg.add_ingress_rule(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">peer</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.Peer.any_ipv4(),</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">connection</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.Port.tcp(</span><span style="color: #005CC5">22</span><span style="color: #24292E">),</span></span>
<span class="line"><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br></div></div><p>本ハンズオンでは， SSH による外部からの接続を許容するため， <code>sg.add_ingress_rule(peer=ec2.Peer.any_ipv4(), connection=ec2.Port.tcp(22))</code> により，すべての IPv4 アドレスからのポート 22 番へのアクセスを許容している． また， SSH で EC2 インスタンスにログインしたのち，インターネットからプログラムなどをダウンロードできるよう， <code>allow_all_outbound=True</code> のパラメータを設定している．</p>
<p>SSH はデフォルトでは 22 番ポートを使用するのが慣例である．</p>
<p>セキュリティ上の観点からは，SSH の接続は自宅や大学・職場など特定の地点からの接続のみを許す方が望ましい．</p>
<h3 id="ec2-elastic-compute-cloud" tabindex="-1">EC2 (Elastic Compute Cloud) <a class="header-anchor" href="#ec2-elastic-compute-cloud" aria-label="Permalink to &quot;EC2 (Elastic Compute Cloud)&quot;">&ZeroWidthSpace;</a></h3>
<p><strong>EC2 のアイコン.</strong></p>
<p><img src="./assets/aws_logos/EC2.png" alt="EC2"></p>
<p>EC2 は AWS 上に仮想サーバーを立ち上げるサービスである． 個々の起動状態にある仮想サーバーのことをインスタンス (instance) とよぶ (しかし，口語的なコミュニケーションにおいては，サーバーとインスタンスという言葉は相互互換的に用いられることが多い)．</p>
<p>EC2 では用途に応じて様々なインスタンスタイプが提供されている． <a href="#ec2_instance_types">table_title</a> に，代表的なインスタンスタイプの例を挙げる (執筆時点での情報)． EC2 のインスタンスタイプのすべてのリストは <a href="https://aws.amazon.com/ec2/instance-types/" target="_blank" rel="noreferrer">公式ドキュメンテーション &quot;Amazon EC2 Instance Types&quot;</a> で見ることができる．</p>
<table><caption>EC2 instance types</caption><colgroup><col style="width: 20%" /><col style="width: 20%" /><col style="width: 20%" /><col style="width: 20%" /><col style="width: 20%" /></colgroup><thead><tr class="header"><th>Instance</th><th>vCPU</th><th>Memory (GiB)</th><th>Network bandwidth (Gbps)</th><th>Price per hour ($)</th></tr></thead><tbody><tr class="odd"><td><p>t2.micro</p></td><td><p>1</p></td><td><p>1</p></td><td><p>-</p></td><td><p>0.0116</p></td></tr><tr class="even"><td><p>t2.small</p></td><td><p>1</p></td><td><p>2</p></td><td><p>-</p></td><td><p>0.023</p></td></tr><tr class="odd"><td><p>t2.medium</p></td><td><p>2</p></td><td><p>4</p></td><td><p>-</p></td><td><p>0.0464</p></td></tr><tr class="even"><td><p>c5.24xlarge</p></td><td><p>96</p></td><td><p>192</p></td><td><p>25</p></td><td><p>4.08</p></td></tr><tr class="odd"><td><p>c5n.18xlarge</p></td><td><p>72</p></td><td><p>192</p></td><td><p>100</p></td><td><p>3.888</p></td></tr><tr class="even"><td><p>x1e.16xlarge</p></td><td><p>64</p></td><td><p>1952</p></td><td><p>10</p></td><td><p>13.344</p></td></tr></tbody></table>
<p><a href="#ec2_instance_types">table_title</a> からわかるように， CPU は 1 コアから 96 コアまで，メモリーは 1GB から 2TB 以上まで，ネットワーク帯域は最大で 100Gbps まで，幅広く選択することができる． また，時間あたりの料金は，CPU・メモリーの占有数にほぼ比例する形で増加する． EC2 はサーバーの起動時間を秒単位で記録しており，<strong>利用料金は使用時間に比例する形で決定される</strong>． 例えば， <code>t2.medium</code> のインスタンスを 10 時間起動した場合，0.0464 * 10 = 0.464 ドルの料金が発生する．</p>
<p>AWS には <a href="https://aws.amazon.com/free/?all-free-tier.sort-by=item.additionalFields.SortRank&amp;all-free-tier.sort-order=asc" target="_blank" rel="noreferrer">無料利用枠</a> というものがあり， <code>t2.micro</code> であれば月に 750 時間までは無料で利用することができる．</p>
<p><a href="#ec2_instance_types">table_title</a> の価格は <code>us-east-1</code> のものである． リージョンによって多少価格設定が異なる．</p>
<p>上記で t2.micro の $0.0116 / hour という金額は， On-demand インスタンスというタイプを選択した場合の価格である． EC2 ではほかに， <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-spot-instances.html" target="_blank" rel="noreferrer">Spot instance</a> とよばれるインスタンスも存在しする． Spot instance は，AWS のデータセンターの負荷が増えた場合，ユーザーのプログラムが実行中であっても AWS の判断により強制シャットダウンされる，という不便さを抱えているのだが，その分大幅に安い料金設定になっている． AWS で一時的に生じた余剰な空き CPU をユーザーに割安で貸し出す，という発想である． 科学計算やウェブサーバーなどの用途でコストを削減する目的で， Spot Instance を活用する事例も多数報告されている．</p>
<p>EC2 インスタンスを定義しているコードの該当部分を見てみよう．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">host </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ec2.Instance(</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;MyFirstEc2Instance&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">instance_type</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.InstanceType(</span><span style="color: #96D0FF">&quot;t2.micro&quot;</span><span style="color: #ADBAC7">),</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">machine_image</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.MachineImage.latest_amazon_linux(),</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">vpc</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">vpc,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">vpc_subnets</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.SubnetSelection(</span><span style="color: #F69D50">subnet_type</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.SubnetType.</span><span style="color: #6CB6FF">PUBLIC</span><span style="color: #ADBAC7">),</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">security_group</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">sg,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">key_name</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">key_name</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">host </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ec2.Instance(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;MyFirstEc2Instance&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">instance_type</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.InstanceType(</span><span style="color: #032F62">&quot;t2.micro&quot;</span><span style="color: #24292E">),</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">machine_image</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.MachineImage.latest_amazon_linux(),</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">vpc</span><span style="color: #D73A49">=</span><span style="color: #24292E">vpc,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">vpc_subnets</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.SubnetSelection(</span><span style="color: #E36209">subnet_type</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.SubnetType.</span><span style="color: #005CC5">PUBLIC</span><span style="color: #24292E">),</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">security_group</span><span style="color: #D73A49">=</span><span style="color: #24292E">sg,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">key_name</span><span style="color: #D73A49">=</span><span style="color: #24292E">key_name</span></span>
<span class="line"><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br></div></div><p>ここでは， <code>t2.micro</code> というインスタンスタイプを選択している． さらに， <code>machine_image</code> として， <a href="https://aws.amazon.com/amazon-linux-ami/" target="_blank" rel="noreferrer">Amazon Linux</a> を選択している (Machine image は OS と似た概念である． Machine image については， <a href="#sec_jupyter_and_deep_learning">Hands-on #2: AWS でディープラーニングを実践</a> でより詳しく触れる)． さらに，上で定義した VPC, SG をこのインスタンスに付与している．</p>
<p>以上が，今回使用するプログラムの簡単な解説であった． ミニマルな形のプログラムではあるが，仮想サーバーを作成するのに必要なステップがおわかりいただけただろうか？</p>
<h2 id="プログラムを実行する" tabindex="-1">プログラムを実行する <a class="header-anchor" href="#プログラムを実行する" aria-label="Permalink to &quot;プログラムを実行する&quot;">&ZeroWidthSpace;</a></h2>
<p>さて，ハンズオンのコードの理解ができたところで，プログラムを実際に実行してみよう．繰り返しになるが， <a href="#handson_01_prep">準備</a> での準備ができていることが前提である．</p>
<h3 id="python-の依存ライブラリのインストール" tabindex="-1">Python の依存ライブラリのインストール <a class="header-anchor" href="#python-の依存ライブラリのインストール" aria-label="Permalink to &quot;Python の依存ライブラリのインストール&quot;">&ZeroWidthSpace;</a></h3>
<p>まずは，Python の依存ライブラリをインストールする．以下では，Python のライブラリを管理するツールとして， <a href="https://docs.python.org/3/library/venv.html" target="_blank" rel="noreferrer">venv</a> を使用する．</p>
<p>まずは， <code>handson/ec2-get-started</code> のディレクトリに移動しよう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cd</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">handson/ec2-get-started</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cd</span><span style="color: #24292E"> </span><span style="color: #032F62">handson/ec2-get-started</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>ディレクトリを移動したら， <code>venv</code> で新しい仮想環境を作成し，インストールを実行する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python3</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-m</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">venv</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.env</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">source</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.env/bin/activate</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">pip</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">install</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-r</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">requirements.txt</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python3</span><span style="color: #24292E"> </span><span style="color: #005CC5">-m</span><span style="color: #24292E"> </span><span style="color: #032F62">venv</span><span style="color: #24292E"> </span><span style="color: #032F62">.env</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">source</span><span style="color: #24292E"> </span><span style="color: #032F62">.env/bin/activate</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">pip</span><span style="color: #24292E"> </span><span style="color: #032F62">install</span><span style="color: #24292E"> </span><span style="color: #005CC5">-r</span><span style="color: #24292E"> </span><span style="color: #032F62">requirements.txt</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><p>これで Python の環境構築は完了だ．</p>
<p><code>venv</code> の簡単な説明は <a href="#venv_quick_guide">Python クイックガイド</a> に記述してある．</p>
<p>環境によっては <code>pip</code> ではなく <code>pip3</code> あるいは <code>python3 -m pip</code> に置き換える必要がある．</p>
<h3 id="aws-のシークレットキーをセットする" tabindex="-1">AWS のシークレットキーをセットする <a class="header-anchor" href="#aws-のシークレットキーをセットする" aria-label="Permalink to &quot;AWS のシークレットキーをセットする&quot;">&ZeroWidthSpace;</a></h3>
<p>AWS CLI および AWS CDK を使うには， AWS のシークレットキーが設定されている必要がある． シークレットキーの発行については <a href="#aws_secrets">AWS のシークレットキーの作成</a> を参照のこと． シークレットキーを発行したら， <a href="#aws_cli_install">AWS CLI のインストール</a> を参照し，コマンドラインの設定を行う．</p>
<p>手順をここに短く要約すると，一つ目の方法は <code>AWS_ACCESS_KEY_ID</code> などの環境変数を設定するやり方である． もう一つの方法は， <code>~/.aws/credentials</code> に認証情報を保存しておく方式である． シークレットキーの設定は AWS CLI/CDK を使用するうえで共通のステップになるので，しっかりと理解しておくように．</p>
<h3 id="ssh-鍵を生成" tabindex="-1">SSH 鍵を生成 <a class="header-anchor" href="#ssh-鍵を生成" aria-label="Permalink to &quot;SSH 鍵を生成&quot;">&ZeroWidthSpace;</a></h3>
<p>EC2 インスタンスには SSH を使ってログインする． EC2 インスタンスを作成するのに先行して，今回のハンズオンで専用に使う SSH の公開鍵・秘密鍵のペアを準備する必要がある．</p>
<p>次の AWS CLI コマンドにより， <code>HirakeGoma</code> という名前のついた鍵を生成する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">export</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">KEY_NAME=&quot;HirakeGoma&quot;</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ec2</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">create-key-pair</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--key-name</span><span style="color: #ADBAC7"> ${KEY_NAME} </span><span style="color: #6CB6FF">--query</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;KeyMaterial&#39;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--output</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">text</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">&gt;</span><span style="color: #ADBAC7"> ${KEY_NAME}</span><span style="color: #96D0FF">.pem</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">export</span><span style="color: #24292E"> </span><span style="color: #032F62">KEY_NAME=&quot;HirakeGoma&quot;</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">aws</span><span style="color: #24292E"> </span><span style="color: #032F62">ec2</span><span style="color: #24292E"> </span><span style="color: #032F62">create-key-pair</span><span style="color: #24292E"> </span><span style="color: #005CC5">--key-name</span><span style="color: #24292E"> ${KEY_NAME} </span><span style="color: #005CC5">--query</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;KeyMaterial&#39;</span><span style="color: #24292E"> </span><span style="color: #005CC5">--output</span><span style="color: #24292E"> </span><span style="color: #032F62">text</span><span style="color: #24292E"> </span><span style="color: #D73A49">&gt;</span><span style="color: #24292E"> ${KEY_NAME}</span><span style="color: #032F62">.pem</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>このコマンドを実行すると，現在のディレクトリに <code>HirakeGoma.pem</code> というファイルが作成される．これが，サーバーにアクセスするための秘密鍵である． SSH でこの鍵を使うため， <code>~/.ssh/</code> のディレクトリに鍵を移動する． さらに，秘密鍵が書き換えられたり第三者に閲覧されないよう，ファイルのアクセス権限を <code>400</code> に設定する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">mv</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">HirakeGoma.pem</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">~/.ssh/</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">chmod</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">400</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">~/.ssh/HirakeGoma.pem</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">mv</span><span style="color: #24292E"> </span><span style="color: #032F62">HirakeGoma.pem</span><span style="color: #24292E"> </span><span style="color: #032F62">~/.ssh/</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">chmod</span><span style="color: #24292E"> </span><span style="color: #005CC5">400</span><span style="color: #24292E"> </span><span style="color: #032F62">~/.ssh/HirakeGoma.pem</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><h3 id="デプロイを実行" tabindex="-1">デプロイを実行 <a class="header-anchor" href="#デプロイを実行" aria-label="Permalink to &quot;デプロイを実行&quot;">&ZeroWidthSpace;</a></h3>
<p>これまでのステップで， EC2 インスタンスをデプロイするための準備が整った！ 早速，次のコマンドによりアプリケーションを AWS にデプロイしよう． <code>-c key_name=&quot;HirakeGoma&quot;</code> というオプションで，先ほど生成した <code>HirakeGoma</code> という名前の鍵を使うよう指定している．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cdk</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">deploy</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-c</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">key_name=&quot;HirakeGoma&quot;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cdk</span><span style="color: #24292E"> </span><span style="color: #032F62">deploy</span><span style="color: #24292E"> </span><span style="color: #005CC5">-c</span><span style="color: #24292E"> </span><span style="color: #032F62">key_name=&quot;HirakeGoma&quot;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>このコマンドを実行すると， VPC， EC2 などが AWS 上に展開される． そして，コマンドの出力の最後に <a href="#handson_01_cdk_output">figure_title</a> のような出力が得られるはずである． <strong>出力の中で <code>InstancePublicIp</code> に続く数字が，起動したインスタンスのパブリック IP アドレスである．</strong> IP アドレスはデプロイごとにランダムなアドレスが割り当てられる．</p>
<p><img src="./assets/handson-01/cdk_output.png" alt="CDKデプロイ実行後の出力"></p>
<h3 id="ssh-でログイン" tabindex="-1">SSH でログイン <a class="header-anchor" href="#ssh-でログイン" aria-label="Permalink to &quot;SSH でログイン&quot;">&ZeroWidthSpace;</a></h3>
<p>早速，SSH 　で接続してみよう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ssh</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-i</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">~/.ssh/HirakeGoma.pem</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ec2-user@</span><span style="color: #F47067">&lt;</span><span style="color: #96D0FF">IP</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">addres</span><span style="color: #ADBAC7">s</span><span style="color: #F47067">&gt;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">ssh</span><span style="color: #24292E"> </span><span style="color: #005CC5">-i</span><span style="color: #24292E"> </span><span style="color: #032F62">~/.ssh/HirakeGoma.pem</span><span style="color: #24292E"> </span><span style="color: #032F62">ec2-user@</span><span style="color: #D73A49">&lt;</span><span style="color: #032F62">IP</span><span style="color: #24292E"> </span><span style="color: #032F62">addres</span><span style="color: #24292E">s</span><span style="color: #D73A49">&gt;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p><code>-i</code> オプションで，先ほど生成した秘密鍵を指定している． EC2 インスタンスにはデフォルトで <code>ec2-user</code> という名前のユーザーが作られているので，それを使用する． 最後に， <code>&lt;IP address&gt;</code> の部分は自身が作成した EC2 インスタンスの IP アドレスで置き換える (<code>12.345.678.9</code> など）．</p>
<p>ログインに成功すると， <a href="#fig_handson_01_ssh_login">figure_title</a> のような画面が表示される． リモートのサーバーにログインしているので，プロンプトが <code>[ec2-user@ip-10-10-1-217 ~]$</code> のようになっていることを確認しよう．</p>
<p><img src="./assets/handson-01/ssh_login.png" alt="SSH で EC2 インスタンスにログイン"></p>
<p><strong>おめでとう！これで，めでたく AWS 上に EC2 仮想サーバーを起動し，リモートからアクセスできるようになった！</strong></p>
<h3 id="起動した-ec2-インスタンスで遊んでみる" tabindex="-1">起動した EC2 インスタンスで遊んでみる <a class="header-anchor" href="#起動した-ec2-インスタンスで遊んでみる" aria-label="Permalink to &quot;起動した EC2 インスタンスで遊んでみる&quot;">&ZeroWidthSpace;</a></h3>
<p>せっかく新しいインスタンスを起動したので，少し遊んでみよう．</p>
<p>ログインした EC2 インスタンスで，次のコマンドを実行してみよう． CPU の情報を取得することができる．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cat</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">/proc/cpuinfo</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F69D50">processor</span><span style="color: #ADBAC7">       </span><span style="color: #96D0FF">:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0</span></span>
<span class="line"><span style="color: #F69D50">vendor_id</span><span style="color: #ADBAC7">       </span><span style="color: #96D0FF">:</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">GenuineIntel</span></span>
<span class="line"><span style="color: #F69D50">cpu</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">family</span><span style="color: #ADBAC7">      </span><span style="color: #96D0FF">:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">6</span></span>
<span class="line"><span style="color: #F69D50">model</span><span style="color: #ADBAC7">           </span><span style="color: #96D0FF">:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">63</span></span>
<span class="line"><span style="color: #F69D50">model</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">name</span><span style="color: #ADBAC7">      </span><span style="color: #96D0FF">:</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">Intel</span><span style="color: #ADBAC7">(</span><span style="color: #F69D50">R</span><span style="color: #ADBAC7">) </span><span style="color: #96D0FF">Xeon</span><span style="color: #ADBAC7">(</span><span style="color: #F69D50">R</span><span style="color: #ADBAC7">) </span><span style="color: #96D0FF">CPU</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">E5-2676</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">v3</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">@</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">2.40</span><span style="color: #96D0FF">GHz</span></span>
<span class="line"><span style="color: #F69D50">stepping</span><span style="color: #ADBAC7">        </span><span style="color: #96D0FF">:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">2</span></span>
<span class="line"><span style="color: #F69D50">microcode</span><span style="color: #ADBAC7">       </span><span style="color: #96D0FF">:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0x43</span></span>
<span class="line"><span style="color: #F69D50">cpu</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">MHz</span><span style="color: #ADBAC7">         </span><span style="color: #96D0FF">:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">2400.096</span></span>
<span class="line"><span style="color: #F69D50">cache</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">size</span><span style="color: #ADBAC7">      </span><span style="color: #96D0FF">:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">30720</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">KB</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cat</span><span style="color: #24292E"> </span><span style="color: #032F62">/proc/cpuinfo</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6F42C1">processor</span><span style="color: #24292E">       </span><span style="color: #032F62">:</span><span style="color: #24292E"> </span><span style="color: #005CC5">0</span></span>
<span class="line"><span style="color: #6F42C1">vendor_id</span><span style="color: #24292E">       </span><span style="color: #032F62">:</span><span style="color: #24292E"> </span><span style="color: #032F62">GenuineIntel</span></span>
<span class="line"><span style="color: #6F42C1">cpu</span><span style="color: #24292E"> </span><span style="color: #032F62">family</span><span style="color: #24292E">      </span><span style="color: #032F62">:</span><span style="color: #24292E"> </span><span style="color: #005CC5">6</span></span>
<span class="line"><span style="color: #6F42C1">model</span><span style="color: #24292E">           </span><span style="color: #032F62">:</span><span style="color: #24292E"> </span><span style="color: #005CC5">63</span></span>
<span class="line"><span style="color: #6F42C1">model</span><span style="color: #24292E"> </span><span style="color: #032F62">name</span><span style="color: #24292E">      </span><span style="color: #032F62">:</span><span style="color: #24292E"> </span><span style="color: #032F62">Intel</span><span style="color: #24292E">(</span><span style="color: #6F42C1">R</span><span style="color: #24292E">) </span><span style="color: #032F62">Xeon</span><span style="color: #24292E">(</span><span style="color: #6F42C1">R</span><span style="color: #24292E">) </span><span style="color: #032F62">CPU</span><span style="color: #24292E"> </span><span style="color: #032F62">E5-2676</span><span style="color: #24292E"> </span><span style="color: #032F62">v3</span><span style="color: #24292E"> </span><span style="color: #032F62">@</span><span style="color: #24292E"> </span><span style="color: #005CC5">2.40</span><span style="color: #032F62">GHz</span></span>
<span class="line"><span style="color: #6F42C1">stepping</span><span style="color: #24292E">        </span><span style="color: #032F62">:</span><span style="color: #24292E"> </span><span style="color: #005CC5">2</span></span>
<span class="line"><span style="color: #6F42C1">microcode</span><span style="color: #24292E">       </span><span style="color: #032F62">:</span><span style="color: #24292E"> </span><span style="color: #005CC5">0x43</span></span>
<span class="line"><span style="color: #6F42C1">cpu</span><span style="color: #24292E"> </span><span style="color: #032F62">MHz</span><span style="color: #24292E">         </span><span style="color: #032F62">:</span><span style="color: #24292E"> </span><span style="color: #005CC5">2400.096</span></span>
<span class="line"><span style="color: #6F42C1">cache</span><span style="color: #24292E"> </span><span style="color: #032F62">size</span><span style="color: #24292E">      </span><span style="color: #032F62">:</span><span style="color: #24292E"> </span><span style="color: #005CC5">30720</span><span style="color: #24292E"> </span><span style="color: #032F62">KB</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br></div></div><p>次に，実行中のプロセスやメモリの消費を見てみよう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7">  </span><span style="color: #96D0FF">top</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-n</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">1</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F69D50">top</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">-</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">09</span><span style="color: #96D0FF">:29:19</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">up</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">43</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">min,</span><span style="color: #ADBAC7">  </span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">user,</span><span style="color: #ADBAC7">  </span><span style="color: #96D0FF">load</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">average:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0.00</span><span style="color: #96D0FF">,</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0.00</span><span style="color: #96D0FF">,</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0.00</span></span>
<span class="line"><span style="color: #F69D50">Tasks:</span><span style="color: #ADBAC7">  </span><span style="color: #6CB6FF">76</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">total,</span><span style="color: #ADBAC7">   </span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">running,</span><span style="color: #ADBAC7">  </span><span style="color: #6CB6FF">51</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">sleeping,</span><span style="color: #ADBAC7">   </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">stopped,</span><span style="color: #ADBAC7">   </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">zombie</span></span>
<span class="line"><span style="color: #F69D50">Cpu(s</span><span style="color: #ADBAC7">):  0.3%us,  0.3%sy,  0.1%ni, 98.9%id,  0.2%wa,  0.0%hi,  0.0%si,  0.2%st</span></span>
<span class="line"><span style="color: #F69D50">Mem:</span><span style="color: #ADBAC7">   </span><span style="color: #6CB6FF">1009140</span><span style="color: #96D0FF">k</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">total,</span><span style="color: #ADBAC7">   </span><span style="color: #6CB6FF">270760</span><span style="color: #96D0FF">k</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">used,</span><span style="color: #ADBAC7">   </span><span style="color: #6CB6FF">738380</span><span style="color: #96D0FF">k</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">free,</span><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">14340</span><span style="color: #96D0FF">k</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">buffers</span></span>
<span class="line"><span style="color: #F69D50">Swap:</span><span style="color: #ADBAC7">        </span><span style="color: #6CB6FF">0</span><span style="color: #96D0FF">k</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">total,</span><span style="color: #ADBAC7">        </span><span style="color: #6CB6FF">0</span><span style="color: #96D0FF">k</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">used,</span><span style="color: #ADBAC7">        </span><span style="color: #6CB6FF">0</span><span style="color: #96D0FF">k</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">free,</span><span style="color: #ADBAC7">   </span><span style="color: #6CB6FF">185856</span><span style="color: #96D0FF">k</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cached</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #F69D50">PID</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">USER</span><span style="color: #ADBAC7">      </span><span style="color: #96D0FF">PR</span><span style="color: #ADBAC7">  </span><span style="color: #96D0FF">NI</span><span style="color: #ADBAC7">  </span><span style="color: #96D0FF">VIRT</span><span style="color: #ADBAC7">  </span><span style="color: #96D0FF">RES</span><span style="color: #ADBAC7">  </span><span style="color: #96D0FF">SHR</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">S</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">%CPU</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">%MEM</span><span style="color: #ADBAC7">    </span><span style="color: #96D0FF">TIME+</span><span style="color: #ADBAC7">  </span><span style="color: #96D0FF">COMMAND</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">1</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">root</span><span style="color: #ADBAC7">      </span><span style="color: #6CB6FF">20</span><span style="color: #ADBAC7">   </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">19696</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">2596</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">2268</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">S</span><span style="color: #ADBAC7">  </span><span style="color: #6CB6FF">0.0</span><span style="color: #ADBAC7">  </span><span style="color: #6CB6FF">0.3</span><span style="color: #ADBAC7">   </span><span style="color: #6CB6FF">0</span><span style="color: #96D0FF">:01.21</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">init</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">2</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">root</span><span style="color: #ADBAC7">      </span><span style="color: #6CB6FF">20</span><span style="color: #ADBAC7">   </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">     </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">S</span><span style="color: #ADBAC7">  </span><span style="color: #6CB6FF">0.0</span><span style="color: #ADBAC7">  </span><span style="color: #6CB6FF">0.0</span><span style="color: #ADBAC7">   </span><span style="color: #6CB6FF">0</span><span style="color: #96D0FF">:00.00</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">kthreadd</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">3</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">root</span><span style="color: #ADBAC7">      </span><span style="color: #6CB6FF">20</span><span style="color: #ADBAC7">   </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">     </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">I</span><span style="color: #ADBAC7">  </span><span style="color: #6CB6FF">0.0</span><span style="color: #ADBAC7">  </span><span style="color: #6CB6FF">0.0</span><span style="color: #ADBAC7">   </span><span style="color: #6CB6FF">0</span><span style="color: #96D0FF">:00.00</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">kworker/0:0</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E">  </span><span style="color: #032F62">top</span><span style="color: #24292E"> </span><span style="color: #005CC5">-n</span><span style="color: #24292E"> </span><span style="color: #005CC5">1</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6F42C1">top</span><span style="color: #24292E"> </span><span style="color: #032F62">-</span><span style="color: #24292E"> </span><span style="color: #005CC5">09</span><span style="color: #032F62">:29:19</span><span style="color: #24292E"> </span><span style="color: #032F62">up</span><span style="color: #24292E"> </span><span style="color: #005CC5">43</span><span style="color: #24292E"> </span><span style="color: #032F62">min,</span><span style="color: #24292E">  </span><span style="color: #005CC5">1</span><span style="color: #24292E"> </span><span style="color: #032F62">user,</span><span style="color: #24292E">  </span><span style="color: #032F62">load</span><span style="color: #24292E"> </span><span style="color: #032F62">average:</span><span style="color: #24292E"> </span><span style="color: #005CC5">0.00</span><span style="color: #032F62">,</span><span style="color: #24292E"> </span><span style="color: #005CC5">0.00</span><span style="color: #032F62">,</span><span style="color: #24292E"> </span><span style="color: #005CC5">0.00</span></span>
<span class="line"><span style="color: #6F42C1">Tasks:</span><span style="color: #24292E">  </span><span style="color: #005CC5">76</span><span style="color: #24292E"> </span><span style="color: #032F62">total,</span><span style="color: #24292E">   </span><span style="color: #005CC5">1</span><span style="color: #24292E"> </span><span style="color: #032F62">running,</span><span style="color: #24292E">  </span><span style="color: #005CC5">51</span><span style="color: #24292E"> </span><span style="color: #032F62">sleeping,</span><span style="color: #24292E">   </span><span style="color: #005CC5">0</span><span style="color: #24292E"> </span><span style="color: #032F62">stopped,</span><span style="color: #24292E">   </span><span style="color: #005CC5">0</span><span style="color: #24292E"> </span><span style="color: #032F62">zombie</span></span>
<span class="line"><span style="color: #6F42C1">Cpu(s</span><span style="color: #24292E">):  0.3%us,  0.3%sy,  0.1%ni, 98.9%id,  0.2%wa,  0.0%hi,  0.0%si,  0.2%st</span></span>
<span class="line"><span style="color: #6F42C1">Mem:</span><span style="color: #24292E">   </span><span style="color: #005CC5">1009140</span><span style="color: #032F62">k</span><span style="color: #24292E"> </span><span style="color: #032F62">total,</span><span style="color: #24292E">   </span><span style="color: #005CC5">270760</span><span style="color: #032F62">k</span><span style="color: #24292E"> </span><span style="color: #032F62">used,</span><span style="color: #24292E">   </span><span style="color: #005CC5">738380</span><span style="color: #032F62">k</span><span style="color: #24292E"> </span><span style="color: #032F62">free,</span><span style="color: #24292E">    </span><span style="color: #005CC5">14340</span><span style="color: #032F62">k</span><span style="color: #24292E"> </span><span style="color: #032F62">buffers</span></span>
<span class="line"><span style="color: #6F42C1">Swap:</span><span style="color: #24292E">        </span><span style="color: #005CC5">0</span><span style="color: #032F62">k</span><span style="color: #24292E"> </span><span style="color: #032F62">total,</span><span style="color: #24292E">        </span><span style="color: #005CC5">0</span><span style="color: #032F62">k</span><span style="color: #24292E"> </span><span style="color: #032F62">used,</span><span style="color: #24292E">        </span><span style="color: #005CC5">0</span><span style="color: #032F62">k</span><span style="color: #24292E"> </span><span style="color: #032F62">free,</span><span style="color: #24292E">   </span><span style="color: #005CC5">185856</span><span style="color: #032F62">k</span><span style="color: #24292E"> </span><span style="color: #032F62">cached</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">  </span><span style="color: #6F42C1">PID</span><span style="color: #24292E"> </span><span style="color: #032F62">USER</span><span style="color: #24292E">      </span><span style="color: #032F62">PR</span><span style="color: #24292E">  </span><span style="color: #032F62">NI</span><span style="color: #24292E">  </span><span style="color: #032F62">VIRT</span><span style="color: #24292E">  </span><span style="color: #032F62">RES</span><span style="color: #24292E">  </span><span style="color: #032F62">SHR</span><span style="color: #24292E"> </span><span style="color: #032F62">S</span><span style="color: #24292E"> </span><span style="color: #032F62">%CPU</span><span style="color: #24292E"> </span><span style="color: #032F62">%MEM</span><span style="color: #24292E">    </span><span style="color: #032F62">TIME+</span><span style="color: #24292E">  </span><span style="color: #032F62">COMMAND</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #6F42C1">1</span><span style="color: #24292E"> </span><span style="color: #032F62">root</span><span style="color: #24292E">      </span><span style="color: #005CC5">20</span><span style="color: #24292E">   </span><span style="color: #005CC5">0</span><span style="color: #24292E"> </span><span style="color: #005CC5">19696</span><span style="color: #24292E"> </span><span style="color: #005CC5">2596</span><span style="color: #24292E"> </span><span style="color: #005CC5">2268</span><span style="color: #24292E"> </span><span style="color: #032F62">S</span><span style="color: #24292E">  </span><span style="color: #005CC5">0.0</span><span style="color: #24292E">  </span><span style="color: #005CC5">0.3</span><span style="color: #24292E">   </span><span style="color: #005CC5">0</span><span style="color: #032F62">:01.21</span><span style="color: #24292E"> </span><span style="color: #032F62">init</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #6F42C1">2</span><span style="color: #24292E"> </span><span style="color: #032F62">root</span><span style="color: #24292E">      </span><span style="color: #005CC5">20</span><span style="color: #24292E">   </span><span style="color: #005CC5">0</span><span style="color: #24292E">     </span><span style="color: #005CC5">0</span><span style="color: #24292E">    </span><span style="color: #005CC5">0</span><span style="color: #24292E">    </span><span style="color: #005CC5">0</span><span style="color: #24292E"> </span><span style="color: #032F62">S</span><span style="color: #24292E">  </span><span style="color: #005CC5">0.0</span><span style="color: #24292E">  </span><span style="color: #005CC5">0.0</span><span style="color: #24292E">   </span><span style="color: #005CC5">0</span><span style="color: #032F62">:00.00</span><span style="color: #24292E"> </span><span style="color: #032F62">kthreadd</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #6F42C1">3</span><span style="color: #24292E"> </span><span style="color: #032F62">root</span><span style="color: #24292E">      </span><span style="color: #005CC5">20</span><span style="color: #24292E">   </span><span style="color: #005CC5">0</span><span style="color: #24292E">     </span><span style="color: #005CC5">0</span><span style="color: #24292E">    </span><span style="color: #005CC5">0</span><span style="color: #24292E">    </span><span style="color: #005CC5">0</span><span style="color: #24292E"> </span><span style="color: #032F62">I</span><span style="color: #24292E">  </span><span style="color: #005CC5">0.0</span><span style="color: #24292E">  </span><span style="color: #005CC5">0.0</span><span style="color: #24292E">   </span><span style="color: #005CC5">0</span><span style="color: #032F62">:00.00</span><span style="color: #24292E"> </span><span style="color: #032F62">kworker/0:0</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br></div></div><p><code>t2.micro</code> インスタンスなので， 1009140k = 1GB のメモリーがあることがわかる．</p>
<p>今回起動したインスタンスには Python 2 はインストール済みだが， Python 3 は入っていない． Python 3.6 のインストールを行ってみよう． インストールは簡単である．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">sudo</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">yum</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">update</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-y</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">sudo</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">yum</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">install</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-y</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python36</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">sudo</span><span style="color: #24292E"> </span><span style="color: #032F62">yum</span><span style="color: #24292E"> </span><span style="color: #032F62">update</span><span style="color: #24292E"> </span><span style="color: #005CC5">-y</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">sudo</span><span style="color: #24292E"> </span><span style="color: #032F62">yum</span><span style="color: #24292E"> </span><span style="color: #032F62">install</span><span style="color: #24292E"> </span><span style="color: #005CC5">-y</span><span style="color: #24292E"> </span><span style="color: #032F62">python36</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>インストールした Python を起動してみよう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python3</span></span>
<span class="line"><span style="color: #F69D50">Python</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">3.6</span><span style="color: #96D0FF">.10</span><span style="color: #ADBAC7"> (default, </span><span style="color: #96D0FF">Feb</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">10</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">2020</span><span style="color: #96D0FF">,</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">19</span><span style="color: #96D0FF">:55:14</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">[GCC </span><span style="color: #6CB6FF">4.8</span><span style="color: #ADBAC7">.5 </span><span style="color: #6CB6FF">20150623</span><span style="color: #ADBAC7"> (Red Hat </span><span style="color: #6CB6FF">4.8</span><span style="color: #ADBAC7">.5-28)] on linux</span></span>
<span class="line"><span style="color: #F69D50">Type</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;help&quot;,</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;copyright&quot;,</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;credits&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">or</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;license&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">for</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">more</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">information.</span></span>
<span class="line"><span style="color: #ADBAC7">&gt;&gt;&gt;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python3</span></span>
<span class="line"><span style="color: #6F42C1">Python</span><span style="color: #24292E"> </span><span style="color: #005CC5">3.6</span><span style="color: #032F62">.10</span><span style="color: #24292E"> (default, </span><span style="color: #032F62">Feb</span><span style="color: #24292E"> </span><span style="color: #005CC5">10</span><span style="color: #24292E"> </span><span style="color: #005CC5">2020</span><span style="color: #032F62">,</span><span style="color: #24292E"> </span><span style="color: #005CC5">19</span><span style="color: #032F62">:55:14</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">[GCC </span><span style="color: #005CC5">4.8</span><span style="color: #24292E">.5 </span><span style="color: #005CC5">20150623</span><span style="color: #24292E"> (Red Hat </span><span style="color: #005CC5">4.8</span><span style="color: #24292E">.5-28)] on linux</span></span>
<span class="line"><span style="color: #6F42C1">Type</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;help&quot;,</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;copyright&quot;,</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;credits&quot;</span><span style="color: #24292E"> </span><span style="color: #032F62">or</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;license&quot;</span><span style="color: #24292E"> </span><span style="color: #032F62">for</span><span style="color: #24292E"> </span><span style="color: #032F62">more</span><span style="color: #24292E"> </span><span style="color: #032F62">information.</span></span>
<span class="line"><span style="color: #24292E">&gt;&gt;&gt;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br></div></div><p>Python のインタープリタが起動した！ <code>Ctrl + D</code> あるいは <code>exit()</code> と入力することで，インタープリタを閉じることができる．</p>
<p>さて，サーバーでのお遊びはこんなところにしておこう (興味があれば各自いろいろと試してみると良い) ． 次のコマンドでログアウトする．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">exit</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">exit</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><h3 id="aws-コンソールから確認" tabindex="-1">AWS コンソールから確認 <a class="header-anchor" href="#aws-コンソールから確認" aria-label="Permalink to &quot;AWS コンソールから確認&quot;">&ZeroWidthSpace;</a></h3>
<p>これまでは，すべてコマンドラインから EC2 に関連する操作を行ってきた． EC2 インスタンスの状態を確認したり，サーバーをシャットダウンするなどの操作は，AWS コンソールから実行することもできる． 軽くこれを紹介しよう．</p>
<p>まず，ウェブブラウザを開いて AWS コンソールにログインする． ログインしたら， <code>Services</code> から <code>EC2</code> を検索(選択)する． 次に，左のサイドバーの <code>Instances</code> とページをたどる. すると， <a href="#aws_ec2_console">figure_title</a> のような画面が得られるはずである． この画面で，自分のアカウントの管理下にあるインスタンスを確認できる． 同様に，VPC・SG についてもコンソールから確認できる．</p>
<p><img src="./assets/handson-01/ec2_console.png" alt="EC2 コンソール画面"></p>
<p><strong>コンソール右上で，正しいリージョン (今回の場合は ap-northeast-1, Tokyo) が選択されているか，注意する！</strong></p>
<p>前章で CloudFormation について触れたが，今回デプロイしたアプリケーションも，CloudFormation のスタックとして管理されている． <strong>スタック (stack)</strong> とは， AWS リソースの集合のことを指す． 今回の場合は， VPC/EC2/SG などがスタックの中に含まれている． コンソールで <code>CloudFormation</code> のページに行ってみよう (<a href="#aws_cloudformation_console">figure_title</a>)．</p>
<p><img src="./assets/handson-01/cloudformation_console.png" alt="CloudFormation コンソール画面"></p>
<p>&quot;MyFirstEc2&quot; という名前のスタックがあることが確認できる． クリックをして中身を見てみると，EC2, VPC などのリソースがこのスタックに紐付いていることがわかる．</p>
<h3 id="スタックを削除" tabindex="-1">スタックを削除 <a class="header-anchor" href="#スタックを削除" aria-label="Permalink to &quot;スタックを削除&quot;">&ZeroWidthSpace;</a></h3>
<p>これにて，第一回のハンズオンで説明すべき事柄はすべて完了した． 最後に，使わなくなったスタックを削除しよう． スタックの削除には，二つの方法がある．</p>
<p>一つ目の方法は，前節の Cloudformation のコンソール画面で， &quot;Delete&quot; ボタンを押すことである (<a href="#cloudformation_delete">figure_title</a>)． すると，スタックの状態が <code>&quot;DELETE_IN_PROGRESS&quot;</code> に変わり，削除が完了すると CloudFormation のスタックの一覧から消える．</p>
<p><img src="./assets/handson-01/cloudformation_delete.png" alt="CloudFormationコンソール画面から，スタックを削除"></p>
<p>二つ目の方法は，コマンドラインから行う方法である． 先ほど，デプロイを行ったコマンドラインに戻ろう． そうしたら，次のコマンドを実行する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cdk</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">destroy</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cdk</span><span style="color: #24292E"> </span><span style="color: #032F62">destroy</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>このコマンドを実行すると，スタックの削除が始まる． 削除した後は，VPC, EC2 など，すべて跡形もなく消え去っていることを自身で確かめよう． CloudFormation を用いることで関連するすべての AWS リソースを一度に管理・削除することができるので，大変便利である．</p>
<p><strong>スタックの削除は各自で必ず行うこと！</strong> 行わなかった場合， EC2 インスタンスの料金が発生し続けることになる！</p>
<p>また，本ハンズオンのために作成した SSH 鍵ペアも不要なので，削除しておく． まず， EC2 側に登録してある公開鍵を削除する． これも，コンソールおよびコマンドラインの二つの方法で実行できる．</p>
<p>コンソールから実行するには， <code>EC2</code> の画面に行き，左のサイドバーの <code>Key Pairs</code> を選択する． 鍵の一覧が表示されるので， <code>HirakeGoma</code> とある鍵にチェックを入れ，画面右上の <code>Actions</code> から， <code>Delete</code> を実行する (<a href="#delete_ec2_key_pair">figure_title</a>)．</p>
<p><img src="./assets/handson-01/ec2_keypair_console.png" alt="EC2でSSH鍵ペアを削除"></p>
<p>コマンドラインから実行するには，次のコマンドを使う．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ec2</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">delete-key-pair</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--key-name</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;HirakeGoma&quot;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">aws</span><span style="color: #24292E"> </span><span style="color: #032F62">ec2</span><span style="color: #24292E"> </span><span style="color: #032F62">delete-key-pair</span><span style="color: #24292E"> </span><span style="color: #005CC5">--key-name</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;HirakeGoma&quot;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>最後に，ローカルのコンピュータから鍵を削除する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">rm</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-f</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">~/.ssh/HirakeGoma.pem</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">rm</span><span style="color: #24292E"> </span><span style="color: #005CC5">-f</span><span style="color: #24292E"> </span><span style="color: #032F62">~/.ssh/HirakeGoma.pem</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>これで，クラウドの片付けもすべて終了だ．</p>
<p>なお，頻繁に EC2 インスタンスを起動したりする場合は，いちいち SSH 鍵を削除する必要はない．</p>
<h2 id="小括" tabindex="-1">小括 <a class="header-anchor" href="#小括" aria-label="Permalink to &quot;小括&quot;">&ZeroWidthSpace;</a></h2>
<p>ここまでが，本書の第一部の内容である． 盛りだくさんの内容であったが，ついてこれたであろうか？</p>
<p><a href="#chap_cloud_basics">クラウド概論</a> では，クラウドの定義と用語の説明を行ったあと，なぜクラウドを使うのか，という点を議論した． 続いて <a href="#sec_aws_general_introduction">AWS 入門</a> では，クラウドを学ぶ具体的なプラットフォームとして AWS を取り上げ， AWS を使用するにあたり最低限必要な知識と用語の説明を行った． さらに， <a href="#sec_first_ec2">Hands-on #1: 初めての EC2 インスタンスを起動する</a> のハンズオンでは AWS CLI と AWS CDK を使って，自身のプライベートなサーバーを AWS 上に立ち上げる演習を行った．</p>
<p>これらを通じて，いかに簡単に (たった数行のコマンドで！) 仮想サーバーを立ち上げたり，削除したりすることができるか，体験できただろう． 筆者は，<a href="#chap_cloud_basics">クラウド概論</a> でクラウドの最も重要な側面はダイナミックに計算リソースを拡大・縮小できることである，と述べた． この言葉の意味が，ハンズオンを通じてより明らかになっただろうか？ ここで学んだ技術を少し応用するだけで，自分のウェブページをホストする仮想サーバーを作成したり，大量のコアを搭載した EC2 インスタンスを用意して科学計算を実行するなど，いろいろなアプリケーションが実現できる．</p>
<p>次章からは，今回学んだクラウドの技術を基に，より現実に即した問題を解くことを体験してもらう． お楽しみに！</p>
<h1 id="クラウドで行う科学計算・機械学習" tabindex="-1">クラウドで行う科学計算・機械学習 <a class="header-anchor" href="#クラウドで行う科学計算・機械学習" aria-label="Permalink to &quot;クラウドで行う科学計算・機械学習&quot;">&ZeroWidthSpace;</a></h1>
<p>計算機が発達した現代では，計算機によるシミュレーションやビッグデータの解析は，科学・エンジニアリングの研究の主要な柱である． これらの大規模な計算を実行するには，クラウドは最適である． 本章から始まる第二部では，どのようにしてクラウド上で科学計算を実行するのかを，ハンズオンとともに体験してもらう． 科学計算の具体的な題材として，今回は機械学習(深層学習)を取り上げる．</p>
<p>なお，本書では <a href="https://pytorch.org/" target="_blank" rel="noreferrer">PyTorch</a> ライブラリを使って深層学習のアルゴリズムを実装するが，深層学習および PyTorch の知識は不要である． 講義ではなぜ・どうやって深層学習をクラウドで実行するかに主眼を置いているので，実行するプログラムの詳細には立ち入らない． 将来，自分で深層学習を使う機会が来たときに，詳しく学んでもらいたい．</p>
<h2 id="なぜ機械学習をクラウドで行うのか" tabindex="-1">なぜ機械学習をクラウドで行うのか？ <a class="header-anchor" href="#なぜ機械学習をクラウドで行うのか" aria-label="Permalink to &quot;なぜ機械学習をクラウドで行うのか？&quot;">&ZeroWidthSpace;</a></h2>
<p>2010 年頃に始まった第三次 AI ブームのおかげで，学術研究だけでなく社会・ビジネスの文脈でも機械学習に高い関心が寄せられている． とくに，<strong>深層学習 (ディープラーニング)</strong> とよばれる多層のレイヤーからなるニューラルネットワークを用いたアルゴリズムは，画像認識や自然言語処理などの分野で圧倒的に高い性能を実現し，革命をもたらしている．</p>
<p>深層学習の特徴は，なんといってもそのパラメータの多さである． 層が深くなるほど，層間のニューロンを結ぶ重みパラメータの数が増大していく． たとえば，最新の言語モデルである <a href="https://arxiv.org/abs/2005.14165" target="_blank" rel="noreferrer">GPT-3</a> には<strong>1750 億個</strong>ものパラメータが含まれている． このような膨大なパラメータを有することで，深層学習は高い表現力と汎化性能を実現しているのである．</p>
<p>GPT-3 に限らず，最近の SOTA (State-of-the-art) の性能を達成するニューラルネットワークでは，百万から億のオーダーのパラメータを内包することは頻繁になってきている． そのような巨大なニューラルネットを訓練 (最適化) させるのは，当然のことながら膨大な計算コストがかかる． 結果として，ひとつの計算機では丸一日以上の時間がかかる場合も珍しくない． 深層学習の発展の速度は目覚ましく，研究・ビジネス両方の観点からも，いかにスループットよくニューラルネットワークの最適化を行えるかが鍵となってくる． そのような問題を解決するのにとても有効な手段が，クラウドである！ <a href="#sec_first_ec2">Hands-on #1: 初めての EC2 インスタンスを起動する</a> でその片鱗を見たように，クラウドを使用することでゼロから数千に至るまでの数のインスタンスを動的に起動し，並列に計算を実行することができる． さらに，深層学習を加速させる目的で，深層学習の演算に専用設計された計算チップ (GPU など) がある． クラウドを利用すると，そのような専用計算チップも無尽蔵に利用することができる． 事実，先述した GPT-3 の学習も，詳細は明かされていないが，Microsoft 社のクラウドを使って行われたと報告されている．</p>
<h2 id="gpu-による深層学習の高速化" tabindex="-1">GPU による深層学習の高速化 <a class="header-anchor" href="#gpu-による深層学習の高速化" aria-label="Permalink to &quot;GPU による深層学習の高速化&quot;">&ZeroWidthSpace;</a></h2>
<p>深層学習の計算で欠かすことのできない技術として， <strong>GPU (Graphics Processing Unit)</strong> について少し説明する．</p>
<p>GPU は，その名のとおり，元々はコンピュータグラフィックスを出力するための専用計算チップである． CPU (Central Processing Unit) に対し，グラフィックスの演算に特化した設計がなされている． 身近なところでは， XBox や PS5 などのゲームコンソールなどに搭載されているし，ハイエンドなノート型・デスクトップ型計算機にも搭載されていることがある． コンピュータグラフィックスでは，スクリーンにアレイ状に並んだ数百万個の画素をビデオレート (30 fps) 以上で処理する必要がある． そのため，GPU はコアあたりの演算能力は比較的小さいかわりに，チップあたり数百から数千のコアを搭載しており (<a href="#gpu_architecture">figure_title</a>)，スクリーンの画素を並列的に処理することで，リアルタイムでの描画を実現している．</p>
<p><img src="./assets/gpu_architecture.jpg" alt="GPUのアーキテクチャ．GPUには数百から数千の独立した計算コアが搭載されている． (画像出典: https://devblogs.nvidia.com/nvidia-turing-architecture-in-depth/)"></p>
<p>このように，コンピュータグラフィクスの目的で生まれた GPU だが，2010 年前後から，その高い並列計算能力をグラフィックス以外の計算 (科学計算など) に用いるという流れ (<strong>General-purpose computing on GPU; GPGPU</strong>) が生まれた． GPU のコアは，その設計から，行列の計算など，単純かつ規則的な演算が得意であり，そのような演算に対しては数個程度のコアしかもたない CPU に比べて圧倒的に高い計算速度を実現することができる． 現在では GPGPU は分子動力学や気象シミュレーション，そして機械学習など多くの分野で使われている．</p>
<p>ディープラーニングで最も頻繁に起こる演算が，ニューロンの出力を次の層のニューロンに伝える<strong>畳み込み (Convolution)</strong> 演算である (<a href="#fig:convolution">figure_title</a>)． 畳み込み演算は，まさに GPU が得意とする演算であり， CPU ではなく GPU を用いることで学習を飛躍的に (最大で数百倍程度) 加速させることができる．</p>
<p><img src="./assets/cnn.png" alt="ニューラルネットワークにおける畳み込み演算．"></p>
<p>このように GPU は機械学習の計算で欠かせないものであるが，なかなか高価である． たとえば，科学計算・機械学習に専用設計された NVIDIA 社の Tesla V100 というチップは，一台で約百万円の価格が設定されている． 機械学習を始めるのに，いきなり百万円の投資はなかなか大きい． だが，クラウドを使えば，初期コスト０で GPU を使用することができる．</p>
<p>機械学習を行うのに， V100 が必ずしも必要というわけではない． むしろ，研究者などでしばしば行われるのは，コンピュータゲームに使われるグラフィックス用の GPU を買ってきて (NVIDIA GeForce シリーズなど)，開発のときはをそれを用いる，というアプローチである． グラフィックス用のいわゆる&quot;コンシューマ GPU&quot;は，市場の需要が大きいおかげで，10 万円前後の価格で購入することができる． V100 と比べると，コンシューマ GPU はコアの数が少なかったり，メモリーが小さかったりなどで劣る点があるが， それらを除いては計算能力にとくに制限があるわけではなく，開発の段階では十分な性能である場合がほとんどである． プログラムができあがって，ビッグデータの解析や，モデルをさらに大きくしたいときなどに，クラウドは有効だろう．</p>
<p>クラウドで GPU を使うには， GPU が搭載された EC2 インスタンスタイプ (<code>P3</code>, <code>P2</code>, <code>G3</code>, <code>G4</code> など) を選択しなければならない． <a href="#table_gpu_instances">table_title</a> に，代表的な GPU 搭載のインスタンスタイプを挙げる (執筆時点での情報)．</p>
<table style="width:100%;"><caption>GPUを搭載したEC2インスタンスタイプ</caption><colgroup><col style="width: 14%" /><col style="width: 14%" /><col style="width: 14%" /><col style="width: 14%" /><col style="width: 14%" /><col style="width: 14%" /><col style="width: 14%" /></colgroup><thead><tr class="header"><th>Instance</th><th>GPUs</th><th>GPU model</th><th>GPU Mem (GiB)</th><th>vCPU</th><th>Mem (GiB)</th><th>Price per hour ($)</th></tr></thead><tbody><tr class="odd"><td><p>p3.2xlarge</p></td><td><p>1</p></td><td><p>NVIDIA V100</p></td><td><p>16</p></td><td><p>8</p></td><td><p>61</p></td><td><p>3.06</p></td></tr><tr class="even"><td><p>p3n.16xlarge</p></td><td><p>8</p></td><td><p>NVIDIA V100</p></td><td><p>128</p></td><td><p>64</p></td><td><p>488</p></td><td><p>24.48</p></td></tr><tr class="odd"><td><p>p2.xlarge</p></td><td><p>1</p></td><td><p>NVIDIA K80</p></td><td><p>12</p></td><td><p>4</p></td><td><p>61</p></td><td><p>0.9</p></td></tr><tr class="even"><td><p>g4dn.xlarge</p></td><td><p>1</p></td><td><p>NVIDIA T4</p></td><td><p>16</p></td><td><p>4</p></td><td><p>16</p></td><td><p>0.526</p></td></tr></tbody></table>
<p><a href="#table_gpu_instances">table_title</a> からわかるとおり， CPU のみのインスタンスと比べると少し高い価格設定になっている． また，古い世代の GPU (V100 に対しての K80) はより安価な価格で提供されている． 1 インスタンスあたりの GPU の搭載数は 1 台から最大で 8 台まで選択することが可能である．</p>
<p>GPU を搭載した一番安いインスタンスタイプは， <code>g4dn.xlarge</code> であり，これには廉価かつ省エネルギー設計の NVIDIA T4 が搭載されている． 後のハンズオンでは，このインスタンスを使用して，ディープラーニングの計算を行ってみる．</p>
<p><a href="#table_gpu_instances">table_title</a> の価格は <code>us-east-1</code> のものである． リージョンによって多少価格設定が異なる．</p>
<p>V100 を一台搭載した <code>p3.2xlarge</code> の利用料金は一時間あたり $3.06 である． V100 が約百万円で売られていることを考えると，約 3000 時間 (= 124 日間)，通算で計算を行った場合に，クラウドを使うよりも V100 を自分で買ったほうがお得になる，という計算になる (実際には，自前で V100 を用意する場合は， V100 だけでなく， CPU やネットワーク機器，電気使用料も必要なので，百万円よりもさらにコストがかかる)．</p>
<p>GPT-3 で使われた計算リソースの詳細は論文でも明かされていないのだが， <a href="https://lambdalabs.com/blog/demystifying-gpt-3/" target="_blank" rel="noreferrer">Lambda 社のブログ</a>で興味深い考察が行われている (Lambda 社は機械学習に特化したクラウドサービスを提供している)．</p>
<p>記事によると，1750 億のパラメータを訓練するには，一台の GPU (NVIDIA V100) を用いた場合，342 年の月日と 460 万ドルのクラウド利用料が必要となる，とのことである． GPT-3 のチームは，複数の GPU に処理を分散することで現実的な時間のうちに訓練を完了させたのであろうが，このレベルのモデルになってくるとクラウド技術の限界を攻めないと達成できないことは確かである．</p>
<p>深層学習を詳しく勉強したい人には以下の参考書を推薦したい． 深層学習の基礎的な概念や理論は普遍的であるが，この分野は日進月歩なので，常に最新の情報を取り入れることを忘れずに．</p>
<ul>
<li>
<p><a href="https://www.deeplearningbook.org/" target="_blank" rel="noreferrer">Deep Learning (Ian Goodfellow, Yoshua Bengio and Aaron Courville)</a> 出版されてから数年が経つが，深層学習の理論的な側面を学びたいならばおすすめの入門書． ウェブで無料で読むことができる． 日本語版も出版されている． 実装についてはほとんど触れられていないので，理論家向けの本．</p>
</li>
<li>
<p><a href="https://www.oreilly.co.jp/books/9784873117584/" target="_blank" rel="noreferrer">ゼロから作る Deep Learning (斎藤 康毅)</a> 合計三冊からなるシリーズ． 理論と実装がバランスよく説明されていて，深層学習の入門書の決定版．</p>
</li>
<li>
<p><a href="https://d2l.ai/" target="_blank" rel="noreferrer">Dive into Deep Learning (Aston Zhang, Zachary C. Lipton, Mu Li, and Alexander J. Smola)</a> 深層学習の基礎から最新のアルゴリズムまでを，実装を通して学んでいくスタイルの本． ウェブで無料で読むことができる，1000 ページ越えの超大作． これを読破することができれば，深層学習の実装で困ることはないだろう．</p>
</li>
</ul>
<h1 id="hands-on-2-aws-でディープラーニングを実践" tabindex="-1">Hands-on #2: AWS でディープラーニングを実践 <a class="header-anchor" href="#hands-on-2-aws-でディープラーニングを実践" aria-label="Permalink to &quot;Hands-on \#2: AWS でディープラーニングを実践&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="準備-1" tabindex="-1">準備 <a class="header-anchor" href="#準備-1" aria-label="Permalink to &quot;準備&quot;">&ZeroWidthSpace;</a></h2>
<p>ハンズオン第二回では， GPU を搭載した EC2 インスタンスを起動し，深層学習モデルの学習と推論を実行する演習を行う．</p>
<p>ハンズオンのソースコードは GitHub の <a href="https://github.com/andatoshiki/toshiki-notebooktree/main/handson/mnist" target="_blank" rel="noreferrer">handson/mnist</a> に置いてある．</p>
<p>本ハンズオンの実行には，第一回ハンズオンで説明した準備 (<a href="#handson_01_prep">準備</a>) が整っていることを前提とする． それ以外に必要な準備はない．</p>
<p>初期状態の AWS アカウントでは， GPU 搭載の G タイプのインスタンスの起動上限が 0 になっていることがある． これを確認するには， AWS コンソールから EC2 の画面を開き，左のメニューから <code>Limits</code> を選択する． その中の <code>Running On-Demand All G instances</code> という数字が G インスタンスの起動上限を表している．</p>
<p>もし，これが 0 になっていた場合は， AWS の自動申請フォームから上限緩和のリクエストを送る必要がある． 詳しくは <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-resource-limits.html" target="_blank" rel="noreferrer">公式ドキュメンテーション &quot;Amazon EC2 service quotas&quot;</a> を参照のこと．</p>
<p>このハンズオンは， <code>g4dn.xlarge</code> タイプの EC2 インスタンスを使うので，東京 (<code>ap-northeast-1</code>) リージョンでは 0.71 $/hour のコストが発生する．</p>
<p>AWS Educate Starter Account を使用している読者へ: 執筆時点においては， Starter Account には GPU 搭載型インスタンスを起動できないという制限が設けられている． したがって， Starter Account のユーザーはこのハンズオンを実行することはできない． 興味のある読者は，制限のない一般アカウントを自分自身で取得する必要があることに注意．</p>
<h2 id="アプリケーションの説明-1" tabindex="-1">アプリケーションの説明 <a class="header-anchor" href="#アプリケーションの説明-1" aria-label="Permalink to &quot;アプリケーションの説明&quot;">&ZeroWidthSpace;</a></h2>
<p>このハンズオンで作成するアプリケーションの概要を <a href="#handson_02_architecture">figure_title</a> に示す．</p>
<p><img src="./assets/handson-jupyter/handson-02-architecture.png" alt="ハンズオン#2で作製するアプリケーションのアーキテクチャ"></p>
<p>図の多くの部分が，第一回ハンズオンで作成したアプリケーションと共通していることに気がつくだろう． 少しの変更で，簡単にディープラーニングを走らせる環境を構築することができるのである！主な変更点は次の３点である．</p>
<ul>
<li>
<p>GPU を搭載した <code>g4dn.xlarge</code> インスタンスタイプを使用</p>
</li>
<li>
<p>ディープラーニングに使うプログラムがあらかじめインストールされた DLAMI (後述) を使用</p>
</li>
<li>
<p>SSH にポートフォワーディングのオプションつけてサーバーに接続し，サーバーで起動している Jupyter Notebook (後述) を使ってプログラムを書いたり実行したりする</p>
</li>
</ul>
<p>ハンズオンで使用するプログラムのコードをみてみよう <a href="https://github.com/andatoshiki/toshiki-notebooktree/main/handson/mnist/app.py" target="_blank" rel="noreferrer">handson/mnist/app.py</a>)． コードは第一回目とほとんど共通である．変更点のみ解説を行う．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">class</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50">Ec2ForDl</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">core</span><span style="color: #ADBAC7">.</span><span style="color: #6CB6FF">Stack</span><span style="color: #ADBAC7">):</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">def</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">__init__</span><span style="color: #ADBAC7">(self, scope: core.App, name: </span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">, key_name: </span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">, </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">kwargs) -&gt; </span><span style="color: #6CB6FF">None</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #6CB6FF">super</span><span style="color: #ADBAC7">().</span><span style="color: #6CB6FF">__init__</span><span style="color: #ADBAC7">(scope, name, </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">kwargs)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        vpc </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ec2.Vpc(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;Ec2ForDl-Vpc&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">max_azs</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">cidr</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;10.10.0.0/23&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">subnet_configuration</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">[</span></span>
<span class="line"><span style="color: #ADBAC7">                ec2.SubnetConfiguration(</span></span>
<span class="line"><span style="color: #ADBAC7">                    </span><span style="color: #F69D50">name</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;public&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                    </span><span style="color: #F69D50">subnet_type</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.SubnetType.</span><span style="color: #6CB6FF">PUBLIC</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                )</span></span>
<span class="line"><span style="color: #ADBAC7">            ],</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">nat_gateways</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        sg </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ec2.SecurityGroup(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;Ec2ForDl-Sg&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">vpc</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">vpc,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">allow_all_outbound</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">True</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"><span style="color: #ADBAC7">        sg.add_ingress_rule(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">peer</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.Peer.any_ipv4(),</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">connection</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.Port.tcp(</span><span style="color: #6CB6FF">22</span><span style="color: #ADBAC7">),</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        host </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ec2.Instance(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;Ec2ForDl-Instance&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">instance_type</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.InstanceType(</span><span style="color: #96D0FF">&quot;g4dn.xlarge&quot;</span><span style="color: #ADBAC7">), </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">machine_image</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.MachineImage.generic_linux({</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #96D0FF">&quot;us-east-1&quot;</span><span style="color: #ADBAC7">: </span><span style="color: #96D0FF">&quot;ami-060f07284bb6f9faf&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #96D0FF">&quot;ap-northeast-1&quot;</span><span style="color: #ADBAC7">: </span><span style="color: #96D0FF">&quot;ami-09c0c16fc46a29ed9&quot;</span></span>
<span class="line"><span style="color: #ADBAC7">            }), </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">vpc</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">vpc,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">vpc_subnets</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.SubnetSelection(</span><span style="color: #F69D50">subnet_type</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.SubnetType.</span><span style="color: #6CB6FF">PUBLIC</span><span style="color: #ADBAC7">),</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">security_group</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">sg,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">key_name</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">key_name</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">class</span><span style="color: #24292E"> </span><span style="color: #6F42C1">Ec2ForDl</span><span style="color: #24292E">(</span><span style="color: #6F42C1">core</span><span style="color: #24292E">.</span><span style="color: #6F42C1">Stack</span><span style="color: #24292E">):</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">def</span><span style="color: #24292E"> </span><span style="color: #005CC5">__init__</span><span style="color: #24292E">(self, scope: core.App, name: </span><span style="color: #005CC5">str</span><span style="color: #24292E">, key_name: </span><span style="color: #005CC5">str</span><span style="color: #24292E">, </span><span style="color: #D73A49">**</span><span style="color: #24292E">kwargs) -&gt; </span><span style="color: #005CC5">None</span><span style="color: #24292E">:</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #005CC5">super</span><span style="color: #24292E">().</span><span style="color: #005CC5">__init__</span><span style="color: #24292E">(scope, name, </span><span style="color: #D73A49">**</span><span style="color: #24292E">kwargs)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        vpc </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ec2.Vpc(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;Ec2ForDl-Vpc&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">max_azs</span><span style="color: #D73A49">=</span><span style="color: #005CC5">1</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">cidr</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;10.10.0.0/23&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">subnet_configuration</span><span style="color: #D73A49">=</span><span style="color: #24292E">[</span></span>
<span class="line"><span style="color: #24292E">                ec2.SubnetConfiguration(</span></span>
<span class="line"><span style="color: #24292E">                    </span><span style="color: #E36209">name</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;public&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                    </span><span style="color: #E36209">subnet_type</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.SubnetType.</span><span style="color: #005CC5">PUBLIC</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                )</span></span>
<span class="line"><span style="color: #24292E">            ],</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">nat_gateways</span><span style="color: #D73A49">=</span><span style="color: #005CC5">0</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        sg </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ec2.SecurityGroup(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;Ec2ForDl-Sg&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">vpc</span><span style="color: #D73A49">=</span><span style="color: #24292E">vpc,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">allow_all_outbound</span><span style="color: #D73A49">=</span><span style="color: #005CC5">True</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"><span style="color: #24292E">        sg.add_ingress_rule(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">peer</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.Peer.any_ipv4(),</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">connection</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.Port.tcp(</span><span style="color: #005CC5">22</span><span style="color: #24292E">),</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        host </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ec2.Instance(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;Ec2ForDl-Instance&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">instance_type</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.InstanceType(</span><span style="color: #032F62">&quot;g4dn.xlarge&quot;</span><span style="color: #24292E">), </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">machine_image</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.MachineImage.generic_linux({</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #032F62">&quot;us-east-1&quot;</span><span style="color: #24292E">: </span><span style="color: #032F62">&quot;ami-060f07284bb6f9faf&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #032F62">&quot;ap-northeast-1&quot;</span><span style="color: #24292E">: </span><span style="color: #032F62">&quot;ami-09c0c16fc46a29ed9&quot;</span></span>
<span class="line"><span style="color: #24292E">            }), </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">vpc</span><span style="color: #D73A49">=</span><span style="color: #24292E">vpc,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">vpc_subnets</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.SubnetSelection(</span><span style="color: #E36209">subnet_type</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.SubnetType.</span><span style="color: #005CC5">PUBLIC</span><span style="color: #24292E">),</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">security_group</span><span style="color: #D73A49">=</span><span style="color: #24292E">sg,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">key_name</span><span style="color: #D73A49">=</span><span style="color: #24292E">key_name</span></span>
<span class="line"><span style="color: #24292E">        )</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br><span class="line-number">36</span><br><span class="line-number">37</span><br><span class="line-number">38</span><br><span class="line-number">39</span><br><span class="line-number">40</span><br></div></div><ul>
<li>
<p>ここで， <code>g4dn.xlarge</code> インスタンスタイプを選択している (第一回では， CPU のみの <code>t2.micro</code> だった)． <code>g4dn.xlarge</code> のインスタンスタイプは， <a href="#sec_scientific_computing">クラウドで行う科学計算・機械学習</a> ですでに触れた通り， <code>NVIDIA T4</code> と呼ばれる廉価版モデルの GPU を搭載したインスタンスである． CPU は 4 core, メインメモリーは 16GB が割り当てあられている．</p>
</li>
<li>
<p>ここでは，Deep Learning 用の諸々のソフトウェアがプリンストールされた AMI (<a href="https://docs.aws.amazon.com/dlami/latest/devguide/what-is-dlami.html" target="_blank" rel="noreferrer">Deep Learning Amazon Machine Image; DLAMI</a>) を選択している (第一回では，Amazon Linux という AMI を使用していた)． 使用する AMI の ID は リージョンごとに指定する必要があり，ここでは <code>us-east-1</code> と <code>ap-northeast-1</code> でそれぞれ定義している．</p>
</li>
</ul>
<p>DLAMI という新しい概念が出てきたので，説明しよう．</p>
<p>AMI が <code>us-east-1</code> と <code>ap-northeast-1</code> でしか定義されていないので，提供されているコードはこの二つのリージョンのみでデプロイ可能である． もしほかのリージョンを利用したい場合は， AMI の ID を自身で検索し，コードに書き込む必要がある．</p>
<h3 id="dlami-deep-learning-amazon-machine-image" tabindex="-1">DLAMI (Deep Learning Amazon Machine Image) <a class="header-anchor" href="#dlami-deep-learning-amazon-machine-image" aria-label="Permalink to &quot;DLAMI (Deep Learning Amazon Machine Image)&quot;">&ZeroWidthSpace;</a></h3>
<p><strong>AMI (Amazon Machine Image)</strong> とは，大まかには OS (Operating System) に相当する概念である． 当然のことながら， OS がなければコンピュータはなにもできないので，EC2 インスタンスを起動するときには必ずなにかの OS を&quot;インストール&quot;する必要がある． EC2 が起動したときにロードされる OS に相当するものが， AMI である． AMI には，たとえば <a href="https://ubuntu.com/" target="_blank" rel="noreferrer">Ubuntu</a> などの Linux 系 OS に加えて，Windows Server を選択することもできる． また， EC2 での使用に最適化された <a href="https://aws.amazon.com/amazon-linux-ami/" target="_blank" rel="noreferrer">Amazon Linux</a> という AMI も提供されている．</p>
<p>しかしながら， AMI を単なる OS と理解するのは過剰な単純化である． AMI には，ベースとなる (空っぽの) OS を選択することもできるが，それに加えて，各種のプログラムがインストール済みの AMI も定義することができる． 必要なプログラムがインストールされている AMI を見つけることができれば，自身でインストールを行ったり環境設定したりする手間が大幅に省ける． 具体例を挙げると，ハンズオン第一回では EC2 インスタンスに Python 3.6 をインストールする例を示したが，そのような操作をインスタンスが起動するたびに行うのは手間である！</p>
<p>AMI は， AWS 公式のものに加えて，サードパーティから提供されているものもある． また，自分自身の AMI を作って登録することも可能である (<a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/creating-an-ami-instance-store.html" target="_blank" rel="noreferrer">参考</a>)． AMI は EC2 のコンソールから検索することが可能である． あるいは，AWS CLI を使って，次のコマンドでリストを取得することができる (<a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/finding-an-ami.html" target="_blank" rel="noreferrer">参考</a>)．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ec2</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">describe-images</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--owners</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">amazon</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">aws</span><span style="color: #24292E"> </span><span style="color: #032F62">ec2</span><span style="color: #24292E"> </span><span style="color: #032F62">describe-images</span><span style="color: #24292E"> </span><span style="color: #005CC5">--owners</span><span style="color: #24292E"> </span><span style="color: #032F62">amazon</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>ディープラーニングで頻繁に使われるプログラムがあらかじめインストールしてある AMI が， <a href="https://docs.aws.amazon.com/dlami/latest/devguide/what-is-dlami.html" target="_blank" rel="noreferrer">DLAMI (Deep Learning AMI)</a> である． DLAMI には <code>TensorFlow</code>, <code>PyTorch</code> などの人気の高いディープラーニングのフレームワーク・ライブラリがすでにインストールされているため， EC2 インスタンスを起動してすぐさまディープラーニングの計算を実行できる．</p>
<p>本ハンズオンでは， Amazon Linux 2 をベースにした DLAMI を使用する (AMI ID = ami-09c0c16fc46a29ed9．この AMI は ap-northeast-1 でしか使用できない点に注意)． AWS CLI を使って，この AMI の詳細情報を取得してみよう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ec2</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">describe-images</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--owners</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">amazon</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--image-ids</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;ami-09c0c16fc46a29ed9&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--region</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ap-northeast-1</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">aws</span><span style="color: #24292E"> </span><span style="color: #032F62">ec2</span><span style="color: #24292E"> </span><span style="color: #032F62">describe-images</span><span style="color: #24292E"> </span><span style="color: #005CC5">--owners</span><span style="color: #24292E"> </span><span style="color: #032F62">amazon</span><span style="color: #24292E"> </span><span style="color: #005CC5">--image-ids</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;ami-09c0c16fc46a29ed9&quot;</span><span style="color: #24292E"> </span><span style="color: #005CC5">--region</span><span style="color: #24292E"> </span><span style="color: #032F62">ap-northeast-1</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p><img src="./assets/handson-jupyter/ami-info.png" alt="AMI ID = ami-09c0c16fc46a29ed9 の詳細情報"></p>
<p><a href="#handson_02_ami-info">figure_title</a> のような出力が得られるはずである．得られた出力から，この DLAMI には PyTorch のバージョン 1.4.0 と 1.5.0 がインストールされていることがわかる． この DLAMI を使って，早速ディープラーニングの計算を実行してみよう．</p>
<p>DLAMI には具体的には何がインストールされているのだろうか？ 興味のある読者のために，簡単な解説をしよう (参考: <a href="https://docs.aws.amazon.com/dlami/latest/devguide/what-is-dlami.html" target="_blank" rel="noreferrer">公式ドキュメンテーション &quot;What Is the AWS Deep Learning AMI?&quot;</a>)．</p>
<p>最も low-level なレイヤーとしては， GPU ドライバー がインストールされている． GPU ドライバーなしには OS は GPU とコマンドのやり取りをすることができない． 次のレイヤーが <a href="https://developer.nvidia.com/about-cuda" target="_blank" rel="noreferrer">CUDA</a> と <a href="https://developer.nvidia.com/cudnn" target="_blank" rel="noreferrer">cuDNN</a> である． CUDA は， NVIDIA 社が開発した， GPU 上で汎用コンピューティングを行うための言語であり， C++ 言語を拡張したシンタックスを備える． cuDNN は CUDA で書かれたディープラーニングのライブラリであり，n 次元の畳み込みなどの演算が実装されている． ここまでが， &quot;Base&quot; とよばれるタイプの DLAMI の中身である．</p>
<p>これに加えて， &quot;Conda&quot; とよばれるタイプには， &quot;Base&quot; のプログラム基盤の上に， <code>TensorFlow</code> や <code>PyTorch</code> などのライブラリがインストールされている． さらに， <a href="https://docs.conda.io/projects/conda/en/latest/index.html" target="_blank" rel="noreferrer">Anaconda</a> による仮想環境を使うことによって， <code>TensorFlow</code> の環境・ <code>PyTorch</code> の環境・ <code>MxNet</code> の環境など，フレームワークを簡単に切り替えることができる (これについては，後のハンズオンで触れる)． また， Jupyter Notebook もインストール済みである．</p>
<h2 id="スタックのデプロイ" tabindex="-1">スタックのデプロイ <a class="header-anchor" href="#スタックのデプロイ" aria-label="Permalink to &quot;スタックのデプロイ&quot;">&ZeroWidthSpace;</a></h2>
<p>スタックの中身が理解できたところで，早速スタックをデプロイしてみよう．</p>
<p>デプロイの手順は，ハンズオン 1 とほとんど共通である． ここでは，コマンドのみ列挙する (<code>#</code> で始まる行はコメントである)． それぞれのコマンドの意味を忘れてしまった場合は，ハンズオン 1 に戻って復習していただきたい． シークレットキーの設定も忘れずに (<a href="#aws_cli_install">AWS CLI のインストール</a>)．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390"># プロジェクトのディレクトリに移動</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cd</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">handson/mnist</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># venv を作成し，依存ライブラリのインストールを行う</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python3</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-m</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">venv</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.env</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">source</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.env/bin/activate</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">pip</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">install</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-r</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">requirements.txt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># SSH鍵を生成</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">export</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">KEY_NAME=&quot;HirakeGoma&quot;</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ec2</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">create-key-pair</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--key-name</span><span style="color: #ADBAC7"> ${KEY_NAME} </span><span style="color: #6CB6FF">--query</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;KeyMaterial&#39;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--output</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">text</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">&gt;</span><span style="color: #ADBAC7"> ${KEY_NAME}</span><span style="color: #96D0FF">.pem</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">mv</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">HirakeGoma.pem</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">~/.ssh/</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">chmod</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">400</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">~/.ssh/HirakeGoma.pem</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># デプロイを実行</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cdk</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">deploy</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-c</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">key_name=&quot;HirakeGoma&quot;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D"># プロジェクトのディレクトリに移動</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cd</span><span style="color: #24292E"> </span><span style="color: #032F62">handson/mnist</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># venv を作成し，依存ライブラリのインストールを行う</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python3</span><span style="color: #24292E"> </span><span style="color: #005CC5">-m</span><span style="color: #24292E"> </span><span style="color: #032F62">venv</span><span style="color: #24292E"> </span><span style="color: #032F62">.env</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">source</span><span style="color: #24292E"> </span><span style="color: #032F62">.env/bin/activate</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">pip</span><span style="color: #24292E"> </span><span style="color: #032F62">install</span><span style="color: #24292E"> </span><span style="color: #005CC5">-r</span><span style="color: #24292E"> </span><span style="color: #032F62">requirements.txt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># SSH鍵を生成</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">export</span><span style="color: #24292E"> </span><span style="color: #032F62">KEY_NAME=&quot;HirakeGoma&quot;</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">aws</span><span style="color: #24292E"> </span><span style="color: #032F62">ec2</span><span style="color: #24292E"> </span><span style="color: #032F62">create-key-pair</span><span style="color: #24292E"> </span><span style="color: #005CC5">--key-name</span><span style="color: #24292E"> ${KEY_NAME} </span><span style="color: #005CC5">--query</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;KeyMaterial&#39;</span><span style="color: #24292E"> </span><span style="color: #005CC5">--output</span><span style="color: #24292E"> </span><span style="color: #032F62">text</span><span style="color: #24292E"> </span><span style="color: #D73A49">&gt;</span><span style="color: #24292E"> ${KEY_NAME}</span><span style="color: #032F62">.pem</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">mv</span><span style="color: #24292E"> </span><span style="color: #032F62">HirakeGoma.pem</span><span style="color: #24292E"> </span><span style="color: #032F62">~/.ssh/</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">chmod</span><span style="color: #24292E"> </span><span style="color: #005CC5">400</span><span style="color: #24292E"> </span><span style="color: #032F62">~/.ssh/HirakeGoma.pem</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># デプロイを実行</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cdk</span><span style="color: #24292E"> </span><span style="color: #032F62">deploy</span><span style="color: #24292E"> </span><span style="color: #005CC5">-c</span><span style="color: #24292E"> </span><span style="color: #032F62">key_name=&quot;HirakeGoma&quot;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br></div></div><p>ハンズオン 1 で作成した SSH 鍵の削除を行わなかった場合は， SSH 鍵を改めて作成する必要はない． 逆に言うと，同じ名前の SSH がすでに存在する場合は，鍵生成のコマンドはエラーを出力する．</p>
<p>デプロイのコマンドが無事に実行されれば， <a href="#handson_02_cdk_output">figure_title</a> のような出力が得られるはずである．AWS により割り振られた IP アドレス (<code>InstancePublicIp</code> に続く文字列) をメモしておこう．</p>
<p><img src="./assets/handson-jupyter/cdk_output.png" alt="CDKデプロイ実行後の出力"></p>
<h2 id="ログイン" tabindex="-1">ログイン <a class="header-anchor" href="#ログイン" aria-label="Permalink to &quot;ログイン&quot;">&ZeroWidthSpace;</a></h2>
<p>早速，デプロイしたインスタンスに SSH でログインしてみよう． ここでは，この後で使う Jupyter Notebook に接続するため，<strong>ポートフォワーディング (port forwarding)</strong> のオプション (<code>-L</code>) をつけてログインする．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ssh</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-i</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">~/.ssh/HirakeGoma.pem</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-L</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">localhost:8931:localhost:8888</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ec2-user@</span><span style="color: #F47067">&lt;</span><span style="color: #96D0FF">IP</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">addres</span><span style="color: #ADBAC7">s</span><span style="color: #F47067">&gt;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">ssh</span><span style="color: #24292E"> </span><span style="color: #005CC5">-i</span><span style="color: #24292E"> </span><span style="color: #032F62">~/.ssh/HirakeGoma.pem</span><span style="color: #24292E"> </span><span style="color: #005CC5">-L</span><span style="color: #24292E"> </span><span style="color: #032F62">localhost:8931:localhost:8888</span><span style="color: #24292E"> </span><span style="color: #032F62">ec2-user@</span><span style="color: #D73A49">&lt;</span><span style="color: #032F62">IP</span><span style="color: #24292E"> </span><span style="color: #032F62">addres</span><span style="color: #24292E">s</span><span style="color: #D73A49">&gt;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>ポートフォワーディングとは，クライアントマシンの特定のアドレスへの接続を， SSH の暗号化された通信を介して，リモートマシンの特定のアドレスへ転送する，という意味である． このコマンドの <code>-L localhost:8931:localhost:8888</code> は，自分のローカルマシンの <code>localhost:8931</code> へのアクセスを，リモートサーバーの <code>localhost:8888</code> のアドレスに転送せよ，という意味である (<code>:</code> につづく数字は TCP/IP ポートの番号を意味している)． リモートサーバーのポート 8888 には，後述する Jupyter Notebook が起動している． したがって，ローカルマシンの <code>localhost:8931</code> にアクセスすることで，リモートサーバーの Jupyter Notebook にアクセスすることができるのである (<a href="#fig:ssh_port_forwarding">figure_title</a>)． このような SSH による接続方式を<strong>トンネル接続</strong>とよぶ．</p>
<p><img src="./assets/ssh_port_forwarding.png" alt="SSH のポートフォワーディングによる Jupyter Notebook へのアクセス"></p>
<p>ポートフォワーディングのオプションで，ポートの番号 (<code>:8931</code>, <code>:8888</code> など) には 1 から 65535 までの任意の整数を指定できる． しかし，たとえば ポート 22 (SSH) やポート 80 (HTTP) など，いくつかすでに使われているポート番号もあることに注意する． また， Jupyter Notebook はデフォルトではポート 8888 番を使用する． したがって，リモート側のポート番号は，8888 を使うのがよい．</p>
<p>SSH ログインコマンドの <code>&lt;IP address&gt;</code> 部分は自身のインスタンスの IP アドレスを代入することを忘れずに．</p>
<p><strong>本書の提供している Docker を使ってデプロイを実行した人へ</strong></p>
<p>SSH によるログインは， <strong>Docker の外</strong> (すなわちクライアントマシン本体) から行わなければならない． なぜなら，Jupyter を開くウェブブラウザは Docker の外にあるからである．</p>
<p>その際，秘密鍵を Docker の外にもってこなければならない． 手っ取り早い方法は， <code>cat ~/.ssh/HirakeGoma</code> と打って，出力結果をコピーしてホストマシンのファイルに書き込む方法である． あるいは <code>-v</code> オプションをつけて，ファイルシステムをマウントしてもよい (詳しくは <a href="https://docs.docker.com/storage/volumes/" target="_blank" rel="noreferrer">Docker 公式ドキュメンテーション &quot;Use volumes&quot;</a> を参照)．</p>
<p>SSH によるログインができたら，早速， GPU の状態を確認してみよう． 次のコマンドを実行する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">nvidia-smi</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">nvidia-smi</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p><a href="#handson_02_nvidia-smi">figure_title</a> のような出力が得られるはずである． 出力を見ると， Tesla T4 型の GPU が 1 台搭載されていることが確認できる． その他，GPU Driver や CUDA のバージョン， GPU の負荷・メモリー使用率などの情報を確認することができる．</p>
<p><img src="./assets/handson-jupyter/nvidia-smi.png" alt="nvidia-smi の出力"></p>
<h2 id="jupyter-notebook-の起動" tabindex="-1">Jupyter Notebook の起動 <a class="header-anchor" href="#jupyter-notebook-の起動" aria-label="Permalink to &quot;Jupyter Notebook の起動&quot;">&ZeroWidthSpace;</a></h2>
<p><a href="https://jupyter.org/" target="_blank" rel="noreferrer">Jupyter Notebook</a> とは，インタラクティブに Python のプログラムを書いたり実行したりするためのツールである． Jupyter は GUI としてウェブブラウザを介してアクセスする形式をとっており，まるでノートを書くように，プロットやテーブルのデータも美しく表示することができる (<a href="#handson_02_welcome_jupyter">figure_title</a>)． Python に慣れている読者は，きっと一度は使ったことがあるだろう．</p>
<p><img src="./assets/handson-jupyter/welcome_to_jupyter.png" alt="Jupyter Notebook の画面"></p>
<p>このハンズオンでは， Jupyter Notebook を使ってディープラーニングのプログラムをインタラクティブに実行していく． DLAMI には既に Jupyter がインストールされているので，特段の設定なしに使い始めることができる．</p>
<p>早速， Jupyter を起動しよう． SSH でログインした先の EC2 インスタンスで，次のコマンドを実行すればよい．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cd</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">~</span><span style="color: #ADBAC7"> </span><span style="color: #768390"># go to home directory</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">jupyter</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">notebook</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cd</span><span style="color: #24292E"> </span><span style="color: #032F62">~</span><span style="color: #24292E"> </span><span style="color: #6A737D"># go to home directory</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">jupyter</span><span style="color: #24292E"> </span><span style="color: #032F62">notebook</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>このコマンドを実行すると， <a href="#handson_02_jupyter_launch">figure_title</a> のような出力が確認できるだろう． この出力から，Jupyter のサーバーが EC2 インスタンスの <code>localhost:8888</code> というアドレスに起動していることがわかる． また， <code>localhost:8888</code> に続く <code>?token=XXXX</code> は，アクセスに使うための一時的なトークンである．</p>
<p><img src="./assets/handson-jupyter/jupyter_launch.png" alt="Jupyter Notebook サーバーを起動"></p>
<p>Jupyter Notebook を初回に起動するときは，起動に数分程度の時間がかかることがある． ほかの動作も起動直後は遅く，いくつかプログラムを走らせていくうちに俊敏に反応するようになってくる． これは， AWS の GPU 搭載型仮想マシンの運用方法に起因する現象だと考えられる．</p>
<p>先ほど，ポートフォワーディングのオプションをつけて SSH 接続をしているので， Jupyter の起動している <code>localhost:8888</code> には，ローカルマシンの <code>localhost:8931</code> からアクセスすることができる． したがって，ローカルマシンから Jupyter にアクセスするには，ウェブブラウザ (Chrome, FireFox など)から次のアドレスにアクセスすれば良い．</p>
<p><a href="http://localhost:8931/?token=XXXX&amp;lt;/programlisting&amp;gt" target="_blank" rel="noreferrer">http://localhost:8931/?token=XXXX&amp;lt;/programlisting&amp;gt</a>;</p>
<p><code>?token=XXXX</code> の部分は，上で Jupyter を起動したときに発行されたトークンの値に置き換える．</p>
<p>上のアドレスにアクセスすると， Jupyter のホーム画面が起動するはずである (<a href="#handson_02_jupyter_home">figure_title</a>)． これで， Jupyter の準備が整った！</p>
<p><img src="./assets/handson-jupyter/jupyter_home.png" alt="Jupyter ホーム画面"></p>
<p>Jupyter Notebook の使い方 (超簡易版)</p>
<ul>
<li>
<p><code>Shift</code> + <code>Enter</code>: セルを実行</p>
</li>
<li>
<p><code>Esc</code>: <strong>Command mode</strong> に遷移</p>
</li>
<li>
<p>メニューバーの &quot;+&quot; ボタン または Command mode で <code>A</code> ⇒ セルを追加</p>
</li>
<li>
<p>メニューバーの &quot;ハサミ&quot; ボタン または Command mode で <code>X</code> ⇒ セルを削除</p>
</li>
</ul>
<p>ショートカットの一覧などは <a href="https://towardsdatascience.com/jypyter-notebook-shortcuts-bf0101a98330" target="_blank" rel="noreferrer">Ventsislav Yordanov 氏によるブログ</a> が参考になる．</p>
<h2 id="pytorch-はじめの一歩" tabindex="-1">PyTorch はじめの一歩 <a class="header-anchor" href="#pytorch-はじめの一歩" aria-label="Permalink to &quot;PyTorch はじめの一歩&quot;">&ZeroWidthSpace;</a></h2>
<p><a href="https://pytorch.org/" target="_blank" rel="noreferrer">PyTorch</a> は Facebook AI Research LAB (FAIR) が中心となって開発を進めている，オープンソースのディープラーニングのライブラリである． PyTorch は 有名な例で言えば Tesla 社の自動運転プロジェクトなどで使用されており，執筆時点において最も人気の高いディープラーニングライブラリの一つである． 本ハンズオンでは， PyTorch を使ってディープラーニングの実践を行う．</p>
<p>PyTorch の歴史のお話</p>
<p>Facebook は PyTorch のほかに Caffe2 とよばれるディープラーニングのフレームワークを開発していた (初代 Caffe は UC Berkley の博士課程学生だった Yangqing Jia によって創られた)． Caffe2 は 2018 年に PyTorch プロジェクトに合併された．</p>
<p>また，2019 年 12 月，日本の Preferred Networks 社が開発していた <a href="https://chainer.org/" target="_blank" rel="noreferrer">Chainer</a> も開発を終了し，PyTorch の開発チームと協業していくことが発表された (詳しくは <a href="https://chainer.org/announcement/2019/12/05/released-v7-ja.html" target="_blank" rel="noreferrer">プレスリリース</a> を参照)． PyTorch には，開発統合前から Chainer からインスパイアされた API がいくつもあり， Chainer の DNA は今も PyTorch に引き継がれているのである…!</p>
<p>本格的なディープラーニングの計算に移る前に， PyTorch ライブラリを使って， GPU で計算を行うとはどういうものか，その入り口に触れてみよう．</p>
<p>まずは，新しいノートブックを作成する． Jupyter のホーム画面の右上の &quot;New&quot; を押し，&quot;conda_pytorch_p36&quot; という環境を選択したうえで，新規ノートブックを作成する (<a href="#handson_02_jupyeter_new">figure_title</a>)． &quot;conda_pytorch_p36&quot; の仮想環境には， PyTorch がインストール済みである．</p>
<p><img src="./assets/handson-jupyter/jupyter_new.png" alt="新規ノートブックの作成． &quot;conda_pytorch_p36&quot; の環境を選択する．"></p>
<p>ここでは，次のようなプログラムを書いて，実行していく． (<a href="#handson_02_jupyeter_pytorch">figure_title</a>)．</p>
<p><img src="./assets/handson-jupyter/jupyter_pytorch.png" alt="PyTorch始めの一歩"></p>
<p>まずは， PyTorch をインポートする．さらに， GPU が使える環境にあるか，確認する．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> torch</span></span>
<span class="line"><span style="color: #6CB6FF">print</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;Is CUDA ready?&quot;</span><span style="color: #ADBAC7">, torch.cuda.is_available())</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> torch</span></span>
<span class="line"><span style="color: #005CC5">print</span><span style="color: #24292E">(</span><span style="color: #032F62">&quot;Is CUDA ready?&quot;</span><span style="color: #24292E">, torch.cuda.is_available())</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>出力:</p>
<p>Is CUDA ready? True&lt;/programlisting&gt;</p>
<p>次に，3x3 のランダムな行列を <strong>CPU</strong> 上に作ってみよう．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">x </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> torch.rand(</span><span style="color: #6CB6FF">3</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">3</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #6CB6FF">print</span><span style="color: #ADBAC7">(x)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">x </span><span style="color: #D73A49">=</span><span style="color: #24292E"> torch.rand(</span><span style="color: #005CC5">3</span><span style="color: #24292E">,</span><span style="color: #005CC5">3</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #005CC5">print</span><span style="color: #24292E">(x)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>出力:</p>
<p>tensor([[0.6896, 0.2428, 0.3269], [0.0533, 0.3594, 0.9499], [0.9764, 0.5881, 0.0203]])&lt;/programlisting&gt;</p>
<p>次に，行列を <strong>GPU</strong> 上に作成する．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">y </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> torch.ones_like(x, </span><span style="color: #F69D50">device</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;cuda&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">x </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> x.to(</span><span style="color: #96D0FF">&quot;cuda&quot;</span><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">y </span><span style="color: #D73A49">=</span><span style="color: #24292E"> torch.ones_like(x, </span><span style="color: #E36209">device</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;cuda&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">x </span><span style="color: #D73A49">=</span><span style="color: #24292E"> x.to(</span><span style="color: #032F62">&quot;cuda&quot;</span><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>そして，行列 <code>x</code> と <code>y</code> の加算を，<strong>GPU 上で実行する</strong>．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">z </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> x </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> y</span></span>
<span class="line"><span style="color: #6CB6FF">print</span><span style="color: #ADBAC7">(z)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">z </span><span style="color: #D73A49">=</span><span style="color: #24292E"> x </span><span style="color: #D73A49">+</span><span style="color: #24292E"> y</span></span>
<span class="line"><span style="color: #005CC5">print</span><span style="color: #24292E">(z)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>出力:</p>
<p>tensor([[1.6896, 1.2428, 1.3269], [1.0533, 1.3594, 1.9499], [1.9764, 1.5881, 1.0203]], device='cuda:0')&lt;/programlisting&gt;</p>
<p>最後に， GPU 上にある行列を， CPU に戻す．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">z </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> z.to(</span><span style="color: #96D0FF">&quot;cpu&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #6CB6FF">print</span><span style="color: #ADBAC7">(z)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">z </span><span style="color: #D73A49">=</span><span style="color: #24292E"> z.to(</span><span style="color: #032F62">&quot;cpu&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #005CC5">print</span><span style="color: #24292E">(z)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>出力:</p>
<p>tensor([[1.6896, 1.2428, 1.3269], [1.0533, 1.3594, 1.9499], [1.9764, 1.5881, 1.0203]])&lt;/programlisting&gt;</p>
<p>以上の例は， GPU を使った計算の初歩の初歩であるが，雰囲気はつかめただろうか？ CPU と GPU で明示的にデータを交換するのが肝である． この例はたった 3x3 の行列の足し算なので， GPU を使う意味はまったくないが，これが数千，数万のサイズの行列になったとき， GPU は格段の威力を発揮する．</p>
<p>完成した Jupyter Notebook は <a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/mnist/pytorch/pytorch_get_started.ipynb" target="_blank" rel="noreferrer">/handson/mnist/pytorch/pytorch_get_started.ipynb</a> にある． Jupyter の画面右上の &quot;Upload&quot; からこのファイルをアップロードして，コードを走らせることが可能である．</p>
<p>しなしながら，勉強のときにはコードはすべて自分の手で打つことが，記憶に残りやすくより効果的である，というのが筆者の意見である．</p>
<p>実際にベンチマークを取ることで GPU と CPU の速度を比較をしてみよう． 実行時間を計測するツールとして， Jupyter の提供する <a href="https://ipython.readthedocs.io/en/stable/interactive/magics.html" target="_blank" rel="noreferrer">%time</a> マジックコマンドを利用する．</p>
<p>まずは CPU を使用して，10000x10000 の行列の行列積を計算した場合の速度を測ってみよう． 先ほどのノートブックの続きに，次のコードを実行する．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">s </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">10000</span></span>
<span class="line"><span style="color: #ADBAC7">device </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;cpu&quot;</span></span>
<span class="line"><span style="color: #ADBAC7">x </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> torch.rand(s, s, </span><span style="color: #F69D50">device</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">device, </span><span style="color: #F69D50">dtype</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">torch.float32)</span></span>
<span class="line"><span style="color: #ADBAC7">y </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> torch.rand(s, s, </span><span style="color: #F69D50">device</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">device, </span><span style="color: #F69D50">dtype</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">torch.float32)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F47067">%</span><span style="color: #ADBAC7">time z </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> torch.matmul(x,y)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">s </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #005CC5">10000</span></span>
<span class="line"><span style="color: #24292E">device </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;cpu&quot;</span></span>
<span class="line"><span style="color: #24292E">x </span><span style="color: #D73A49">=</span><span style="color: #24292E"> torch.rand(s, s, </span><span style="color: #E36209">device</span><span style="color: #D73A49">=</span><span style="color: #24292E">device, </span><span style="color: #E36209">dtype</span><span style="color: #D73A49">=</span><span style="color: #24292E">torch.float32)</span></span>
<span class="line"><span style="color: #24292E">y </span><span style="color: #D73A49">=</span><span style="color: #24292E"> torch.rand(s, s, </span><span style="color: #E36209">device</span><span style="color: #D73A49">=</span><span style="color: #24292E">device, </span><span style="color: #E36209">dtype</span><span style="color: #D73A49">=</span><span style="color: #24292E">torch.float32)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D73A49">%</span><span style="color: #24292E">time z </span><span style="color: #D73A49">=</span><span style="color: #24292E"> torch.matmul(x,y)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br></div></div><p>出力は以下のようなものが得られるだろう． これは，行列積の計算に実時間で 5.8 秒かかったことを意味する (実行のたびに計測される時間はばらつくことに留意)．</p>
<p>CPU times: user 11.5 s, sys: 140 ms, total: 11.6 s Wall time: 5.8 s&lt;/programlisting&gt;</p>
<p>次に， GPU を使用して，同じ演算を行った場合の速度を計測しよう．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">s </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">10000</span></span>
<span class="line"><span style="color: #ADBAC7">device </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;cuda&quot;</span></span>
<span class="line"><span style="color: #ADBAC7">x </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> torch.rand(s, s, </span><span style="color: #F69D50">device</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">device, </span><span style="color: #F69D50">dtype</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">torch.float32)</span></span>
<span class="line"><span style="color: #ADBAC7">y </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> torch.rand(s, s, </span><span style="color: #F69D50">device</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">device, </span><span style="color: #F69D50">dtype</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">torch.float32)</span></span>
<span class="line"><span style="color: #ADBAC7">torch.cuda.synchronize()</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F47067">%</span><span style="color: #ADBAC7">time z </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> torch.matmul(x,y); torch.cuda.synchronize()</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">s </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #005CC5">10000</span></span>
<span class="line"><span style="color: #24292E">device </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;cuda&quot;</span></span>
<span class="line"><span style="color: #24292E">x </span><span style="color: #D73A49">=</span><span style="color: #24292E"> torch.rand(s, s, </span><span style="color: #E36209">device</span><span style="color: #D73A49">=</span><span style="color: #24292E">device, </span><span style="color: #E36209">dtype</span><span style="color: #D73A49">=</span><span style="color: #24292E">torch.float32)</span></span>
<span class="line"><span style="color: #24292E">y </span><span style="color: #D73A49">=</span><span style="color: #24292E"> torch.rand(s, s, </span><span style="color: #E36209">device</span><span style="color: #D73A49">=</span><span style="color: #24292E">device, </span><span style="color: #E36209">dtype</span><span style="color: #D73A49">=</span><span style="color: #24292E">torch.float32)</span></span>
<span class="line"><span style="color: #24292E">torch.cuda.synchronize()</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D73A49">%</span><span style="color: #24292E">time z </span><span style="color: #D73A49">=</span><span style="color: #24292E"> torch.matmul(x,y); torch.cuda.synchronize()</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br></div></div><p>出力は以下のようなものになるだろう． GPU では 553 ミリ秒 で計算を終えることができた！</p>
<p>CPU times: user 334 ms, sys: 220 ms, total: 554 ms Wall time: 553 ms&lt;/programlisting&gt;</p>
<p>PyTorch において， GPU での演算は asynchronous (非同期) で実行される． その理由で，上のベンチマークコードでは， <code>torch.cuda.synchronize()</code> というステートメントを埋め込んである．</p>
<p>このベンチマークでは， <code>dtype=torch.float32</code> と指定することで，32bit の浮動小数点型を用いている． ディープラーニングの学習および推論の計算には，32bit 型，場合によっては 16bit 型が使われるのが一般的である． これの主な理由として，教師データやミニバッチに起因するノイズが，浮動小数点の精度よりも大きいことがあげられる． 32bit/16bit を採用することで，メモリー消費を抑えたり，計算速度の向上が達成できる．</p>
<p>上記のベンチマークから，GPU を用いることで，<strong>約 10 倍のスピードアップ</strong>を実現することができた． スピードアップの性能は，演算の種類や行列のサイズに依存する． 行列積は，そのなかでも最も速度向上が見込まれる演算の一つである．</p>
<h2 id="実践ディープラーニング-mnist-手書き数字認識タスク" tabindex="-1">実践ディープラーニング! MNIST 手書き数字認識タスク <a class="header-anchor" href="#実践ディープラーニング-mnist-手書き数字認識タスク" aria-label="Permalink to &quot;実践ディープラーニング! MNIST 手書き数字認識タスク&quot;">&ZeroWidthSpace;</a></h2>
<p>ここまで，AWS 上でディープラーニングの計算をするための概念や前提知識をながながと説明してきたが，ついにここからディープラーニングの計算を実際に走らせてみる．</p>
<p>ここでは，機械学習のタスクで最も初歩的かつ有名な <strong>MNIST データセットを使った数字認識</strong>を扱う (<a href="#handson_02_mnist_examples">figure_title</a>)． これは，0 から 9 までの手書きの数字の画像が与えられ，その数字が何の数字なのかを当てる，というシンプルなタスクである．</p>
<p><img src="./assets/handson-jupyter/mnist_examples.png" alt="MNIST 手書き数字データセット"></p>
<p>今回は， MNIST 文字認識タスクを，<strong>畳み込みニューラルネットワーク (Convolutional Neural Network; CNN)</strong> を使って解く． ソースコードは <a href="https://github.com/tomomano/learn-aws-by-coding-source-code/tree/main/handson/mnist/pytorch" target="_blank" rel="noreferrer">/handson/minist/pytorch/</a> にある <code>mnist.ipynb</code> と <code>simple_mnist.py</code> である． なお，このプログラムは， <a href="https://github.com/pytorch/examples/tree/master/mnist" target="_blank" rel="noreferrer">PyTorch の公式 Example Project 集</a> を参考に，多少の改変を行ったものである．</p>
<p>まずは，カスタムのクラスや関数が定義された <code>simple_mnist.py</code> をアップロードしよう (<a href="#handson_02_jupyter_upload">figure_title</a>)． 画面右上の &quot;Upload&quot; ボタンをクリックし，ファイルを選択することでアップロードができる． この Python プログラムの中に，CNN のモデルや，学習の各イテレーションにおけるパラメータの更新などが記述されている． 今回はこの中身を説明することはしないが，興味のある読者は自身でソースコードを読んでみるとよい．</p>
<p><img src="./assets/handson-jupyter/jupyter_upload.png" alt=" をアップロード"></p>
<p><code>simple_mnist.py</code> をアップロードできたら，次に新しい notebook を作成しよう． &quot;conda_pytorch_p36&quot; の環境を選択することを忘れずに．</p>
<p>新しいノートブックが起動したら，まずは必要なライブラリをインポートしよう．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> torch</span></span>
<span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> torch.optim </span><span style="color: #F47067">as</span><span style="color: #ADBAC7"> optim</span></span>
<span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> torchvision</span></span>
<span class="line"><span style="color: #F47067">from</span><span style="color: #ADBAC7"> torchvision </span><span style="color: #F47067">import</span><span style="color: #ADBAC7"> datasets, transforms</span></span>
<span class="line"><span style="color: #F47067">from</span><span style="color: #ADBAC7"> matplotlib </span><span style="color: #F47067">import</span><span style="color: #ADBAC7"> pyplot </span><span style="color: #F47067">as</span><span style="color: #ADBAC7"> plt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># custom functions and classes</span></span>
<span class="line"><span style="color: #F47067">from</span><span style="color: #ADBAC7"> simple_mnist </span><span style="color: #F47067">import</span><span style="color: #ADBAC7"> Model, train, evaluate</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> torch</span></span>
<span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> torch.optim </span><span style="color: #D73A49">as</span><span style="color: #24292E"> optim</span></span>
<span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> torchvision</span></span>
<span class="line"><span style="color: #D73A49">from</span><span style="color: #24292E"> torchvision </span><span style="color: #D73A49">import</span><span style="color: #24292E"> datasets, transforms</span></span>
<span class="line"><span style="color: #D73A49">from</span><span style="color: #24292E"> matplotlib </span><span style="color: #D73A49">import</span><span style="color: #24292E"> pyplot </span><span style="color: #D73A49">as</span><span style="color: #24292E"> plt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># custom functions and classes</span></span>
<span class="line"><span style="color: #D73A49">from</span><span style="color: #24292E"> simple_mnist </span><span style="color: #D73A49">import</span><span style="color: #24292E"> Model, train, evaluate</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br></div></div><p><a href="https://pytorch.org/docs/stable/torchvision/index.html" target="_blank" rel="noreferrer">torchvision</a> パッケージには，MNIST データセットをロードするなどの便利な関数が含まれている． また，今回のハンズオンで使うカスタムのクラス・関数 (<code>Model</code>, <code>train</code>, <code>evaluate</code>) のインポートを行っている．</p>
<p>次に，MNIST テストデータをダウンロードしよう． 同時に，画像データの輝度の正規化も行っている．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">transf </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> transforms.Compose([transforms.ToTensor(),</span></span>
<span class="line"><span style="color: #ADBAC7">                             transforms.Normalize((</span><span style="color: #6CB6FF">0.1307</span><span style="color: #ADBAC7">,), (</span><span style="color: #6CB6FF">0.3081</span><span style="color: #ADBAC7">,))])</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">trainset </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> datasets.MNIST(</span><span style="color: #F69D50">root</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&#39;./data&#39;</span><span style="color: #ADBAC7">, </span><span style="color: #F69D50">train</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">True</span><span style="color: #ADBAC7">, </span><span style="color: #F69D50">download</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">True</span><span style="color: #ADBAC7">, </span><span style="color: #F69D50">transform</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">transf)</span></span>
<span class="line"><span style="color: #ADBAC7">trainloader </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> torch.utils.data.DataLoader(trainset, </span><span style="color: #F69D50">batch_size</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">64</span><span style="color: #ADBAC7">, </span><span style="color: #F69D50">shuffle</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">True</span><span style="color: #ADBAC7">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">testset </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> datasets.MNIST(</span><span style="color: #F69D50">root</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&#39;./data&#39;</span><span style="color: #ADBAC7">, </span><span style="color: #F69D50">train</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">False</span><span style="color: #ADBAC7">, </span><span style="color: #F69D50">download</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">True</span><span style="color: #ADBAC7">, </span><span style="color: #F69D50">transform</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">transf)</span></span>
<span class="line"><span style="color: #ADBAC7">testloader </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> torch.utils.data.DataLoader(testset, </span><span style="color: #F69D50">batch_size</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">1000</span><span style="color: #ADBAC7">, </span><span style="color: #F69D50">shuffle</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">True</span><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">transf </span><span style="color: #D73A49">=</span><span style="color: #24292E"> transforms.Compose([transforms.ToTensor(),</span></span>
<span class="line"><span style="color: #24292E">                             transforms.Normalize((</span><span style="color: #005CC5">0.1307</span><span style="color: #24292E">,), (</span><span style="color: #005CC5">0.3081</span><span style="color: #24292E">,))])</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">trainset </span><span style="color: #D73A49">=</span><span style="color: #24292E"> datasets.MNIST(</span><span style="color: #E36209">root</span><span style="color: #D73A49">=</span><span style="color: #032F62">&#39;./data&#39;</span><span style="color: #24292E">, </span><span style="color: #E36209">train</span><span style="color: #D73A49">=</span><span style="color: #005CC5">True</span><span style="color: #24292E">, </span><span style="color: #E36209">download</span><span style="color: #D73A49">=</span><span style="color: #005CC5">True</span><span style="color: #24292E">, </span><span style="color: #E36209">transform</span><span style="color: #D73A49">=</span><span style="color: #24292E">transf)</span></span>
<span class="line"><span style="color: #24292E">trainloader </span><span style="color: #D73A49">=</span><span style="color: #24292E"> torch.utils.data.DataLoader(trainset, </span><span style="color: #E36209">batch_size</span><span style="color: #D73A49">=</span><span style="color: #005CC5">64</span><span style="color: #24292E">, </span><span style="color: #E36209">shuffle</span><span style="color: #D73A49">=</span><span style="color: #005CC5">True</span><span style="color: #24292E">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">testset </span><span style="color: #D73A49">=</span><span style="color: #24292E"> datasets.MNIST(</span><span style="color: #E36209">root</span><span style="color: #D73A49">=</span><span style="color: #032F62">&#39;./data&#39;</span><span style="color: #24292E">, </span><span style="color: #E36209">train</span><span style="color: #D73A49">=</span><span style="color: #005CC5">False</span><span style="color: #24292E">, </span><span style="color: #E36209">download</span><span style="color: #D73A49">=</span><span style="color: #005CC5">True</span><span style="color: #24292E">, </span><span style="color: #E36209">transform</span><span style="color: #D73A49">=</span><span style="color: #24292E">transf)</span></span>
<span class="line"><span style="color: #24292E">testloader </span><span style="color: #D73A49">=</span><span style="color: #24292E"> torch.utils.data.DataLoader(testset, </span><span style="color: #E36209">batch_size</span><span style="color: #D73A49">=</span><span style="color: #005CC5">1000</span><span style="color: #24292E">, </span><span style="color: #E36209">shuffle</span><span style="color: #D73A49">=</span><span style="color: #005CC5">True</span><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br></div></div><p>今回扱う MNIST データは 28x28 ピクセルの正方形の画像(モノクロ)と，それぞれのラベル(0 - 9 の数字)の組で構成されている． いくつかのデータを抽出して，可視化してみよう． <a href="#handson_02_mnist_ground_truth">figure_title</a> のような出力が得られるはずである．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">examples </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">iter</span><span style="color: #ADBAC7">(testloader)</span></span>
<span class="line"><span style="color: #ADBAC7">example_data, example_targets </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> examples.next()</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6CB6FF">print</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;Example data size:&quot;</span><span style="color: #ADBAC7">, example_data.shape)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">fig </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> plt.figure(</span><span style="color: #F69D50">figsize</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">10</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">4</span><span style="color: #ADBAC7">))</span></span>
<span class="line"><span style="color: #F47067">for</span><span style="color: #ADBAC7"> i </span><span style="color: #F47067">in</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">range</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">10</span><span style="color: #ADBAC7">):</span></span>
<span class="line"><span style="color: #ADBAC7">    plt.subplot(</span><span style="color: #6CB6FF">2</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">5</span><span style="color: #ADBAC7">,i</span><span style="color: #F47067">+</span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">    plt.tight_layout()</span></span>
<span class="line"><span style="color: #ADBAC7">    plt.imshow(example_data[i][</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">], </span><span style="color: #F69D50">cmap</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&#39;gray&#39;</span><span style="color: #ADBAC7">, </span><span style="color: #F69D50">interpolation</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&#39;none&#39;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">    plt.title(</span><span style="color: #96D0FF">&quot;Ground Truth: </span><span style="color: #F47067">{}</span><span style="color: #96D0FF">&quot;</span><span style="color: #ADBAC7">.format(example_targets[i]))</span></span>
<span class="line"><span style="color: #ADBAC7">    plt.xticks([])</span></span>
<span class="line"><span style="color: #ADBAC7">    plt.yticks([])</span></span>
<span class="line"><span style="color: #ADBAC7">plt.show()</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">examples </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #005CC5">iter</span><span style="color: #24292E">(testloader)</span></span>
<span class="line"><span style="color: #24292E">example_data, example_targets </span><span style="color: #D73A49">=</span><span style="color: #24292E"> examples.next()</span></span>
<span class="line"></span>
<span class="line"><span style="color: #005CC5">print</span><span style="color: #24292E">(</span><span style="color: #032F62">&quot;Example data size:&quot;</span><span style="color: #24292E">, example_data.shape)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">fig </span><span style="color: #D73A49">=</span><span style="color: #24292E"> plt.figure(</span><span style="color: #E36209">figsize</span><span style="color: #D73A49">=</span><span style="color: #24292E">(</span><span style="color: #005CC5">10</span><span style="color: #24292E">,</span><span style="color: #005CC5">4</span><span style="color: #24292E">))</span></span>
<span class="line"><span style="color: #D73A49">for</span><span style="color: #24292E"> i </span><span style="color: #D73A49">in</span><span style="color: #24292E"> </span><span style="color: #005CC5">range</span><span style="color: #24292E">(</span><span style="color: #005CC5">10</span><span style="color: #24292E">):</span></span>
<span class="line"><span style="color: #24292E">    plt.subplot(</span><span style="color: #005CC5">2</span><span style="color: #24292E">,</span><span style="color: #005CC5">5</span><span style="color: #24292E">,i</span><span style="color: #D73A49">+</span><span style="color: #005CC5">1</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">    plt.tight_layout()</span></span>
<span class="line"><span style="color: #24292E">    plt.imshow(example_data[i][</span><span style="color: #005CC5">0</span><span style="color: #24292E">], </span><span style="color: #E36209">cmap</span><span style="color: #D73A49">=</span><span style="color: #032F62">&#39;gray&#39;</span><span style="color: #24292E">, </span><span style="color: #E36209">interpolation</span><span style="color: #D73A49">=</span><span style="color: #032F62">&#39;none&#39;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">    plt.title(</span><span style="color: #032F62">&quot;Ground Truth: </span><span style="color: #005CC5">{}</span><span style="color: #032F62">&quot;</span><span style="color: #24292E">.format(example_targets[i]))</span></span>
<span class="line"><span style="color: #24292E">    plt.xticks([])</span></span>
<span class="line"><span style="color: #24292E">    plt.yticks([])</span></span>
<span class="line"><span style="color: #24292E">plt.show()</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br></div></div><p><img src="./assets/handson-jupyter/mnist_ground_truth.png" alt="MNIST の手書き数字画像とその教師ラベル"></p>
<p>次に， CNN のモデルを定義する．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">model </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> Model()</span></span>
<span class="line"><span style="color: #ADBAC7">model.to(</span><span style="color: #96D0FF">&quot;cuda&quot;</span><span style="color: #ADBAC7">) </span><span style="color: #768390"># load to GPU</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">model </span><span style="color: #D73A49">=</span><span style="color: #24292E"> Model()</span></span>
<span class="line"><span style="color: #24292E">model.to(</span><span style="color: #032F62">&quot;cuda&quot;</span><span style="color: #24292E">) </span><span style="color: #6A737D"># load to GPU</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>今回使う <code>Model</code> は <code>simple_mnist.py</code> の中で定義されている． このモデルは，<a href="#handson_02_cnn_architecture">figure_title</a> に示したような，２層の畳み込み層と 2 層の全結合層からなるネットワークである． 出力層 (output layer) には Softmax 関数を使用し，損失関数 (Loss function) には 負の対数尤度関数 (Negative log likelyhood; NLL) を使用している．</p>
<p><img src="./assets/handson-jupyter/cnn_architecture.png" alt="本ハンズオンで使用するニューラルネットの構造．"></p>
<p>続いて， CNN のパラメータを更新する最適化アルゴリズムを定義する． ここでは， <strong>確率的勾配降下法 (Stochastic Gradient Descent; SGD)</strong> を使用している．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">optimizer </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> optim.SGD(model.parameters(), </span><span style="color: #F69D50">lr</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">0.01</span><span style="color: #ADBAC7">, </span><span style="color: #F69D50">momentum</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">0.5</span><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">optimizer </span><span style="color: #D73A49">=</span><span style="color: #24292E"> optim.SGD(model.parameters(), </span><span style="color: #E36209">lr</span><span style="color: #D73A49">=</span><span style="color: #005CC5">0.01</span><span style="color: #24292E">, </span><span style="color: #E36209">momentum</span><span style="color: #D73A49">=</span><span style="color: #005CC5">0.5</span><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>これで，準備が整った． CNN の学習ループを開始しよう!</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">train_losses </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> []</span></span>
<span class="line"><span style="color: #F47067">for</span><span style="color: #ADBAC7"> epoch </span><span style="color: #F47067">in</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">range</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">5</span><span style="color: #ADBAC7">):</span></span>
<span class="line"><span style="color: #ADBAC7">    losses </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> train(model, trainloader, optimizer, epoch)</span></span>
<span class="line"><span style="color: #ADBAC7">    train_losses </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> train_losses </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> losses</span></span>
<span class="line"><span style="color: #ADBAC7">    test_loss, test_accuracy </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> evaluate(model, testloader)</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">print</span><span style="color: #ADBAC7">(</span><span style="color: #F47067">f</span><span style="color: #96D0FF">&quot;</span><span style="color: #F47067">\n</span><span style="color: #96D0FF">Test set: Average loss: </span><span style="color: #F47067">{</span><span style="color: #ADBAC7">test_loss</span><span style="color: #F47067">:.4f}</span><span style="color: #96D0FF">, Accuracy: </span><span style="color: #F47067">{</span><span style="color: #ADBAC7">test_accuracy</span><span style="color: #F47067">:.1f}</span><span style="color: #96D0FF">%</span><span style="color: #F47067">\n</span><span style="color: #96D0FF">&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">plt.figure(</span><span style="color: #F69D50">figsize</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">7</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">5</span><span style="color: #ADBAC7">))</span></span>
<span class="line"><span style="color: #ADBAC7">plt.plot(train_losses)</span></span>
<span class="line"><span style="color: #ADBAC7">plt.xlabel(</span><span style="color: #96D0FF">&quot;Iterations&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">plt.ylabel(</span><span style="color: #96D0FF">&quot;Train loss&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">plt.show()</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">train_losses </span><span style="color: #D73A49">=</span><span style="color: #24292E"> []</span></span>
<span class="line"><span style="color: #D73A49">for</span><span style="color: #24292E"> epoch </span><span style="color: #D73A49">in</span><span style="color: #24292E"> </span><span style="color: #005CC5">range</span><span style="color: #24292E">(</span><span style="color: #005CC5">5</span><span style="color: #24292E">):</span></span>
<span class="line"><span style="color: #24292E">    losses </span><span style="color: #D73A49">=</span><span style="color: #24292E"> train(model, trainloader, optimizer, epoch)</span></span>
<span class="line"><span style="color: #24292E">    train_losses </span><span style="color: #D73A49">=</span><span style="color: #24292E"> train_losses </span><span style="color: #D73A49">+</span><span style="color: #24292E"> losses</span></span>
<span class="line"><span style="color: #24292E">    test_loss, test_accuracy </span><span style="color: #D73A49">=</span><span style="color: #24292E"> evaluate(model, testloader)</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">print</span><span style="color: #24292E">(</span><span style="color: #D73A49">f</span><span style="color: #032F62">&quot;</span><span style="color: #005CC5">\n</span><span style="color: #032F62">Test set: Average loss: </span><span style="color: #005CC5">{</span><span style="color: #24292E">test_loss</span><span style="color: #D73A49">:.4f</span><span style="color: #005CC5">}</span><span style="color: #032F62">, Accuracy: </span><span style="color: #005CC5">{</span><span style="color: #24292E">test_accuracy</span><span style="color: #D73A49">:.1f</span><span style="color: #005CC5">}</span><span style="color: #032F62">%</span><span style="color: #005CC5">\n</span><span style="color: #032F62">&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">plt.figure(</span><span style="color: #E36209">figsize</span><span style="color: #D73A49">=</span><span style="color: #24292E">(</span><span style="color: #005CC5">7</span><span style="color: #24292E">,</span><span style="color: #005CC5">5</span><span style="color: #24292E">))</span></span>
<span class="line"><span style="color: #24292E">plt.plot(train_losses)</span></span>
<span class="line"><span style="color: #24292E">plt.xlabel(</span><span style="color: #032F62">&quot;Iterations&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">plt.ylabel(</span><span style="color: #032F62">&quot;Train loss&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">plt.show()</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br></div></div><p>ここでは 5 エポック分の学習を行っている． GPU を使えば，これくらいの計算であれば 1 分程度で完了するだろう．</p>
<p>出力として， <a href="#handson_02_train_loss">figure_title</a> のようなプロットが得られるはずである． イテレーションを重ねるにつれて，損失関数 (Loss function) の値が減少している (=精度が向上している) ことがわかる．</p>
<p><img src="./assets/handson-jupyter/train_loss.png" alt="学習の進行に対する Train loss の変化"></p>
<p>出力にはテキスト形式で各エポック終了後のテストデータに対する精度も表示されている． 最終的には 98% 以上の極めて高い精度を実現できていることが確認できるだろう (<a href="#handson_02_mnist_final_score">figure_title</a>)．</p>
<p><img src="./assets/handson-jupyter/mnist_final_score.png" alt="学習したCNNのテストデータに対するスコア (5エポック後)"></p>
<p>学習した CNN の推論結果を可視化してみよう． 次のコードを実行することで， <a href="#handson_02_mnist_mnist_prediction">figure_title</a> のような出力が得られるだろう． この図で，下段右から二番目は，&quot;1&quot;に近い見た目をしているが，きちんと&quot;9&quot;と推論できている． なかなか賢い CNN を作り出すことができたようだ！</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">model.eval()</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F47067">with</span><span style="color: #ADBAC7"> torch.no_grad():</span></span>
<span class="line"><span style="color: #ADBAC7">    output </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> model(example_data.to(</span><span style="color: #96D0FF">&quot;cuda&quot;</span><span style="color: #ADBAC7">))</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">fig </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> plt.figure(</span><span style="color: #F69D50">figsize</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">10</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">4</span><span style="color: #ADBAC7">))</span></span>
<span class="line"><span style="color: #F47067">for</span><span style="color: #ADBAC7"> i </span><span style="color: #F47067">in</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">range</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">10</span><span style="color: #ADBAC7">):</span></span>
<span class="line"><span style="color: #ADBAC7">    plt.subplot(</span><span style="color: #6CB6FF">2</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">5</span><span style="color: #ADBAC7">,i</span><span style="color: #F47067">+</span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">    plt.tight_layout()</span></span>
<span class="line"><span style="color: #ADBAC7">    plt.imshow(example_data[i][</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">], </span><span style="color: #F69D50">cmap</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&#39;gray&#39;</span><span style="color: #ADBAC7">, </span><span style="color: #F69D50">interpolation</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&#39;none&#39;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">    plt.title(</span><span style="color: #96D0FF">&quot;Prediction: </span><span style="color: #F47067">{}</span><span style="color: #96D0FF">&quot;</span><span style="color: #ADBAC7">.format(output.data.max(</span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">, </span><span style="color: #F69D50">keepdim</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">True</span><span style="color: #ADBAC7">)[</span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">][i].item()))</span></span>
<span class="line"><span style="color: #ADBAC7">    plt.xticks([])</span></span>
<span class="line"><span style="color: #ADBAC7">    plt.yticks([])</span></span>
<span class="line"><span style="color: #ADBAC7">plt.show()</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">model.eval()</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D73A49">with</span><span style="color: #24292E"> torch.no_grad():</span></span>
<span class="line"><span style="color: #24292E">    output </span><span style="color: #D73A49">=</span><span style="color: #24292E"> model(example_data.to(</span><span style="color: #032F62">&quot;cuda&quot;</span><span style="color: #24292E">))</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">fig </span><span style="color: #D73A49">=</span><span style="color: #24292E"> plt.figure(</span><span style="color: #E36209">figsize</span><span style="color: #D73A49">=</span><span style="color: #24292E">(</span><span style="color: #005CC5">10</span><span style="color: #24292E">,</span><span style="color: #005CC5">4</span><span style="color: #24292E">))</span></span>
<span class="line"><span style="color: #D73A49">for</span><span style="color: #24292E"> i </span><span style="color: #D73A49">in</span><span style="color: #24292E"> </span><span style="color: #005CC5">range</span><span style="color: #24292E">(</span><span style="color: #005CC5">10</span><span style="color: #24292E">):</span></span>
<span class="line"><span style="color: #24292E">    plt.subplot(</span><span style="color: #005CC5">2</span><span style="color: #24292E">,</span><span style="color: #005CC5">5</span><span style="color: #24292E">,i</span><span style="color: #D73A49">+</span><span style="color: #005CC5">1</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">    plt.tight_layout()</span></span>
<span class="line"><span style="color: #24292E">    plt.imshow(example_data[i][</span><span style="color: #005CC5">0</span><span style="color: #24292E">], </span><span style="color: #E36209">cmap</span><span style="color: #D73A49">=</span><span style="color: #032F62">&#39;gray&#39;</span><span style="color: #24292E">, </span><span style="color: #E36209">interpolation</span><span style="color: #D73A49">=</span><span style="color: #032F62">&#39;none&#39;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">    plt.title(</span><span style="color: #032F62">&quot;Prediction: </span><span style="color: #005CC5">{}</span><span style="color: #032F62">&quot;</span><span style="color: #24292E">.format(output.data.max(</span><span style="color: #005CC5">1</span><span style="color: #24292E">, </span><span style="color: #E36209">keepdim</span><span style="color: #D73A49">=</span><span style="color: #005CC5">True</span><span style="color: #24292E">)[</span><span style="color: #005CC5">1</span><span style="color: #24292E">][i].item()))</span></span>
<span class="line"><span style="color: #24292E">    plt.xticks([])</span></span>
<span class="line"><span style="color: #24292E">    plt.yticks([])</span></span>
<span class="line"><span style="color: #24292E">plt.show()</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br></div></div><p><img src="./assets/handson-jupyter/mnist_prediction.png" alt="学習した CNN による，MNIST画像の推論結果"></p>
<p>最後に，学習したニューラルネットワークのパラメータを <code>mnist_cnn.pt</code> というファイル名で保存しておこう． これで，将来いつでも今回学習したモデルを再現し，別の実験に使用することができる．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">torch.save(model.state_dict(), </span><span style="color: #96D0FF">&quot;mnist_cnn.pt&quot;</span><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">torch.save(model.state_dict(), </span><span style="color: #032F62">&quot;mnist_cnn.pt&quot;</span><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>以上が， AWS クラウドの仮想サーバーを立ち上げ，最初のディープラーニングの計算を行う一連の流れである． MNIST 文字認識のタスクを行うニューラルネットを，クラウド上の GPU を使って高速に学習させ，現実的な問題を一つ解くことができたのである． 興味のある読者は，今回のハンズオンを雛形に，自分の所望の計算を走らせてみるとよいだろう．</p>
<h2 id="スタックの削除" tabindex="-1">スタックの削除 <a class="header-anchor" href="#スタックの削除" aria-label="Permalink to &quot;スタックの削除&quot;">&ZeroWidthSpace;</a></h2>
<p>これにて，ハンズオン第二回の内容はすべて説明した． クラウドの利用料金を最小化するため，使い終わった EC2 インスタンスはすぐさま削除しよう．</p>
<p>ハンズオン第一回と同様に， AWS の CloudFormation コンソールか， AWS CLI により削除を実行する (詳細は <a href="#handson_01_delete_stack">スタックを削除</a> 参照)．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cdk</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">destroy</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cdk</span><span style="color: #24292E"> </span><span style="color: #032F62">destroy</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p><strong>スタックの削除は各自で必ず行うこと！</strong> 行わなかった場合，EC2 インスタンスの料金が発生し続けることになる！ <code>g4dn.xlarge</code> は $0.71 / hour の料金設定なので，一日起動しつづけると約$17 の請求が発生することになる！</p>
<p><strong>AWS のバジェットアラート</strong></p>
<p>AWS の初心者が (あるいは経験者も) しばしば陥る失敗が，インスタンスの停止忘れなどで無駄なリソースがクラウドで放置されてしまい，巨大な額の請求が届く，というミスだ． 特に，開発を行っている間はこのような事態は起こりうるものだと思って，備えておかなければならない． このような事態を未然に防ぐため， AWS Budgets という機能が無料で提供されている． AWS Budgets を利用することで，月の利用金額がある閾値を超えた場合にユーザーにメールが送信される，などのアラートを設定することができる． 詳細な手順は <a href="https://aws.amazon.com/blogs/aws-cost-management/getting-started-with-aws-budgets/" target="_blank" rel="noreferrer">AWS の公式ブログ &quot;Getting Started with AWS Budgets&quot;</a> を参照のこと． 本書の読者も，ぜひこのタイミングでアラートを設定しておくことを推奨する．</p>
<h1 id="docker-入門" tabindex="-1">Docker 入門 <a class="header-anchor" href="#docker-入門" aria-label="Permalink to &quot;Docker 入門&quot;">&ZeroWidthSpace;</a></h1>
<p>ここまでの章で扱ってきたハンズオンでは，<strong>単一のサーバー</strong>を立ち上げ，それに SSH でログインをして，コマンドを叩くことで計算を行ってきた． いわば，<em>パーソナルコンピュータの延長</em>のような形でクラウドを使ってきたわけである． このような，インターネットのどこからでもアクセスできるパーソナルコンピュータとしてのクラウドという使い方も，もちろん便利であるし，いろいろな応用の可能性がある． しかし，これだけではクラウドの本当の価値は十分に発揮されていないと言うべきだろう． <a href="#chap_cloud_basics">クラウド概論</a> で述べたように，現代的なクラウドの一番の強みは自由に計算機の規模を拡大できることにある． すなわち，<strong>多数のサーバーを同時に起動し，複数のジョブを分散並列的に実行させることで大量のデータを処理してこそ，クラウドの本領が発揮される</strong>のである．</p>
<p>本章からはじまる 3 章分 (<a href="#sec_docker_introduction">Docker 入門</a>, <a href="#sec_fargate_qabot">Hands-on #3: AWS で自動質問回答ボットを走らせる</a>, <a href="#sec_aws_batch">Hands-on #4: AWS Batch を使って機械学習のハイパーパラメータサーチを並列化する</a>) を使って，クラウドを利用することでどのように大規模な計算システムを構築しビッグデータの解析に立ち向かうのか，その片鱗をお見せしたい． とくに，前章で扱った深層学習をどのようにビッグデータに適用していくかという点に焦点を絞って議論していきたい． そのための前準備として，本章では <a href="https://www.docker.com/" target="_blank" rel="noreferrer">Docker</a> とよばれる計算機環境の仮想化ソフトウェアを紹介する (<a href="#fig:docker_logo">figure_title</a>)． 現代のクラウドは Docker なしには成り立たないといっても過言ではないだろう． クラウドに限らず，ローカルで行う計算処理にも Docker は大変便利である． AWS からは少し話が離れるが，しっかりと理解して前に進んでもらいたい．</p>
<h2 id="機械学習の大規模化" tabindex="-1">機械学習の大規模化 <a class="header-anchor" href="#機械学習の大規模化" aria-label="Permalink to &quot;機械学習の大規模化&quot;">&ZeroWidthSpace;</a></h2>
<p>先ほどから&quot;計算システムの大規模化&quot;と繰り返し唱えているが，それは具体的にはどのようなものを指しているのか？ ここでは大規模データを処理するための計算機システムを，機械学習を例にとって見てみよう．</p>
<p><a href="#sec_scientific_computing">クラウドで行う科学計算・機械学習</a> で紹介した <a href="https://github.com/openai/gpt-3" target="_blank" rel="noreferrer">GPT-3</a> のような，超巨大な数のパラメータを有する深層学習モデルを学習させたいとしよう． そのような計算を行いたい場合，一つのサーバーでは計算力が到底足りない． したがって，典型的には <a href="#big_dnn_training">figure_title</a> に示すような計算システムの設計がなされる． すなわち，大量の教師データを小さなチャンクとして複数のマシンに分散し，並列的にニューラルネットのパラメータを最適化していくという構造である．</p>
<p><img src="./assets/big_dnn_training.png" alt="複数の計算機を使った大規模な深層学習モデルの訓練"></p>
<p>あるいは，学習済みのモデルを大量のデータに適用し，解析を行いたいとしよう． たとえば， SNS のプラットフォームで大量の画像が与えられて，それぞれの写真に何が写っているのかをラベルづけする，などのアプリケーションを想定できる． そのような場合は， <a href="#big_dnn_inference">figure_title</a> のようなアーキテクチャが考えられるだろう． すなわち，大量のデータを複数のマシンで分割し，それぞれのマシンで推論の計算を行うというような構造である．</p>
<p><img src="./assets/big_dnn_inference.png" alt="複数の計算機による深層学習モデルを使った推論計算"></p>
<p>このような複数の計算機を同時に走らせるようなアプリケーションをクラウド上で実現するには，どのようにすればよいのだろうか？</p>
<p>重要なポイントとして， <a href="#big_dnn_training">figure_title</a> や <a href="#big_dnn_inference">figure_title</a> で起動している複数のマシンは，<strong>基本的に全く同一の OS・計算環境を有している</strong>点である． ここで，個人のコンピュータで行うようなインストールの操作を，各マシンで行うこともできるが，それは大変な手間であるし，メンテナンスも面倒だろう． すなわち，大規模な計算システムを構築するには，<strong>簡単に計算環境を複製できるような仕組み</strong>が必要であるということがわかる．</p>
<p>そのような目的を実現するために使われるのが， <a href="https://www.docker.com/" target="_blank" rel="noreferrer">Docker</a> とよばれるソフトウェアである．</p>
<h2 id="docker-とは" tabindex="-1">Docker とは <a class="header-anchor" href="#docker-とは" aria-label="Permalink to &quot;Docker とは&quot;">&ZeroWidthSpace;</a></h2>
<p><img src="./assets/docker_log.png" alt="Docker のアイコン"></p>
<p>Docker とは， <strong>コンテナ (Container)</strong> とよばれる仮想環境下で，ホスト OS とは独立した別の計算環境を走らせるためのソフトウェアである． Docker を使うことで， OS を含めたすべてのプログラムをコンパクトにパッケージングすることが可能になる (パッケージされた一つの計算環境のことを **イメージ (Image)**とよぶ)． Docker を使うことで，クラウドのサーバー上に瞬時に計算環境を複製することが可能になり， <a href="#big_dnn_inference">figure_title</a> で見たような複数の計算機を同時に走らせるためのシステムが実現できる．</p>
<p>Docker は 2013 年に Solomon Hykes らを中心に開発され，それ以降爆発的に普及し，クラウドコンピューティングだけでなく，機械学習・科学計算の文脈などでも欠かすことのできないソフトウェアとなった． Docker はエンタープライズ向けの製品を除き無料で使用することができ，コアの部分は <a href="https://github.com/moby/moby" target="_blank" rel="noreferrer">オープンソースプロジェクト</a> として公開されている． Docker は Linux, Windows, Mac いずれの OS でも提供されている． 概念としては， Docker は仮想マシン (Virtual machine; VM) にとても近い． ここでは， VM との対比をしながら，Docker とはなにかを簡単に説明しよう．</p>
<p>仮想マシン (VM) とは，ホストとなるマシンの上に，仮想化された OS を走らせる技術である (<a href="#docker_vs_vm">figure_title</a>)． VM には <strong>ハイパーバイザー (Hypervisor)</strong> とよばれるレイヤーが存在する． Hypervisor はまず，物理的な計算機リソース (CPU, RAM, network など) を分割し，仮想化する． たとえば， ホストマシンに物理的な CPU が 4 コアあるとして，ハイパーバイザーはそれを (2,2) 個の組に仮想的に分割することができる． VM 上で起動する OS には，ハイパーバイザーによって仮想化されたハードウェアが割り当てられる． VM 上で起動する OS は基本的に完全に独立であり，たとえば OS-A は OS-B に割り当てられた CPU やメモリー領域にアクセスすることはできない (これを isolation とよぶ)． VM を作成するための有名なソフトウェアとしては， <a href="https://www.vmware.com/" target="_blank" rel="noreferrer">VMware</a>， <a href="https://www.virtualbox.org/" target="_blank" rel="noreferrer">VirtualBox</a>， <a href="https://xenproject.org/" target="_blank" rel="noreferrer">Xen</a> などがある． また，これまで触ってきた EC2 も，基本的に VM 技術を使うことで所望のスペックをもった仮想マシンがユーザーに提示される．</p>
<p>Docker も， VM と同様に，仮想化された OS をホストの OS 上に走らせるための技術である． VM に対し， Docker ではハードウェアレベルの仮想化は行われておらず，すべての<strong>仮想化はソフトウェアレベルで実現されている</strong> (<a href="#docker_vs_vm">figure_title</a>)． Docker で走る仮想 OS は，<strong>多くの部分をホストの OS に依存しており，結果として非常にコンパクトである</strong>． その結果， Docker で仮想 OS を起動するために要する時間は， VM に比べて圧倒的に早い． また， パッケージ化された環境 (=イメージ) のサイズも完全な OS に比べ圧倒的に小さくなるので，ネットワークを通じたやり取りが非常に高速化される点も重要である 加えて， VM のいくつかの実装では，メタル (仮想化マシンに対して，物理的なハードウェア上で直接起動する場合のこと) と比べ，ハイパーバイザーレイヤーでのオーバーヘッドなどにより性能が低下することが知られているが， Docker ではメタルとほぼ同様の性能を引き出すことができるとされている．</p>
<p>その他， VM との相違点などはたくさんあるのだが，ここではこれ以上詳細には立ち入らない． 大事なのは， <strong>Docker とはとてもコンパクトかつハイパフォーマンスな仮想計算環境を作るツールである</strong>，という点である． その手軽さゆえに，2013 年の登場以降，クラウドシステムでの利用が急速に増加し，現代のクラウドでは欠くことのできない中心的な技術になっている．</p>
<p><img src="./assets/docker_vs_vm.png" alt="Docker (左) と VM (右) の比較 (画像出典: https://www.docker.com/blog/containers-replacing-virtual-machines/)"></p>
<p>職業的プログラマーにとっての&quot;三種の神器&quot;とはなんだろうか？ 多様な意見があると思うが，筆者は <strong>Git</strong>, <strong>Vim</strong> そして <strong>Docker</strong> を挙げたい．</p>
<p>Git は多くの読者がご存じの通り，コードの変更を追跡するためのシステムである． Linux の作成者である Linus Torvalds によって 2005 年に誕生した． チームでの開発を進める際には欠かせないツールだ．</p>
<p>Vim は 1991 年から 30 年以上の間プログラマーたちに愛されてきたテキストエディターである． <a href="https://insights.stackoverflow.com/survey/2019#technology-development-environments-and-tools-all-respondents" target="_blank" rel="noreferrer">Stackoverflow が行った 2019 年のアンケート</a> によると，開発環境の部門で 5 位の人気を獲得している． たくさんのショートカットと様々なカスタム設定が提供されているので，初見の人にはなかなかハードルが高いが，一度マスターすれば他のモダンなエディターや統合開発環境に負けない，あるいはそれ以上の開発体験を実現することができる．</p>
<p>これらの十年以上の歴史あるツールに並んで，第三番目の三種の神器として挙げたいのが Docker だ． Docker はプログラマーの開発のワークフローを一変させた． たとえば，プロジェクトごとに Docker イメージを作成することで，どの OS・コンピュータ でも全く同じ計算環境で開発・テストを実行することができるようになった． また， <a href="https://en.wikipedia.org/wiki/DevOps" target="_blank" rel="noreferrer">DevOps</a> や <a href="https://en.wikipedia.org/wiki/Continuous_integration" target="_blank" rel="noreferrer">CI</a> / <a href="https://en.wikipedia.org/wiki/Continuous_delivery" target="_blank" rel="noreferrer">CD</a> (Continuous Integration / Continuous Deployment) といった最近の開発ワークフローも Docker のようなコンテナ技術の存在に立脚している． さらにはサーバーレスコンピューティング (<a href="#sec_serverless">Serverless architecture</a>) といった概念も，コンテナ技術の生んだ大きな技術革新といえる．</p>
<p>あなたにとっての三種の神器はなんだろうか？ また，これからの未来ではどんな新しいツールが三種の神器としてプログラマーのワークフローを革新していくだろうか？</p>
<h2 id="docker-チュートリアル" tabindex="-1">Docker チュートリアル <a class="header-anchor" href="#docker-チュートリアル" aria-label="Permalink to &quot;Docker チュートリアル&quot;">&ZeroWidthSpace;</a></h2>
<p>Docker とはなにかを理解するためには，実際に触って動かしてみるのが一番有効な手立てである． ここでは， Docker の簡単なチュートリアルを行っていく．</p>
<p>Docker のインストールについては， <a href="#sec:install_docker">Docker のインストール</a> および <a href="https://docs.docker.com/engine/install/" target="_blank" rel="noreferrer">公式のドキュメンテーション</a> を参照してもらいたい． Docker のインストールが完了している前提で，以下は話を進めるものとする．</p>
<h3 id="docker-用語集" tabindex="-1">Docker 用語集 <a class="header-anchor" href="#docker-用語集" aria-label="Permalink to &quot;Docker 用語集&quot;">&ZeroWidthSpace;</a></h3>
<p>Docker を使い始めるに当たり，最初に主要な用語を解説しよう． 次のパラグラフで太字で強調された用語を頭に入れた上で，続くチュートリアルに取り組んでいただきたい．</p>
<p>Docker を起動する際の大まかなステップを示したのが <a href="#fig:docker_image_container">figure_title</a> である． パッケージされた一つの計算環境のことを **イメージ (Image)**とよぶ． イメージは， Docker Hub などのリポジトリで配布されているものをダウンロードするか，自分でカスタムのイメージを作成することも可能である． イメージを作成するための”レシピ”を記述したファイルが <strong>Dockerfile</strong> である． Dockerfile からイメージを作成する操作を <strong>build</strong> とよぶ． イメージがホストマシンのメモリにロードされ，起動状態にある計算環境のことを <strong>コンテナ (Container)</strong> とよぶ． Container を起動するために使用されるコマンドが <strong>run</strong> である．</p>
<p><img src="./assets/docker_image_container.png" alt="Image と Container"></p>
<h3 id="イメージをダウンロード" tabindex="-1">イメージをダウンロード <a class="header-anchor" href="#イメージをダウンロード" aria-label="Permalink to &quot;イメージをダウンロード&quot;">&ZeroWidthSpace;</a></h3>
<p>パッケージ化された Docker の仮想環境 (= <strong>イメージ (Image)</strong>) は， <a href="https://hub.docker.com/" target="_blank" rel="noreferrer">Docker Hub</a> からダウンロードできる． Docker Hub には，個人や企業・団体が作成した Docker イメージが集められており， GitHub などと同じ感覚で，オープンな形で公開されている．</p>
<p>たとえば， Ubuntu のイメージは <a href="https://hub.docker.com/_/ubuntu" target="_blank" rel="noreferrer">Ubuntu の公式リポジトリ</a> で公開されており， <code>pull</code> コマンドを使うことでローカルにダウンロードすることができる．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">docker</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">pull</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ubuntu:18.04</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">docker</span><span style="color: #24292E"> </span><span style="color: #032F62">pull</span><span style="color: #24292E"> </span><span style="color: #032F62">ubuntu:18.04</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>ここで，イメージ名の <code>:</code> (コロン) 以降に続く文字列を <strong>タグ (tag)</strong> と呼び，主にバージョンを指定するなどの目的で使われる．</p>
<p><code>pull</code> コマンドはデフォルトでは Docker Hub でイメージを検索し，ダウンロードを行う． Docker イメージを公開するためのデータベース (レジストリ (registry) とよぶ) は Docker Hub だけではなく，たとえば GitLab や GitHub は独自のレジストリ機能を提供しているし，個人のサーバーでレジストリを立ち上げることも可能である． Docker Hub 以外のレジストリから pull するには， <code>myregistry.local:5000/testing/test-image</code> のように，イメージ名の先頭につける形でレジストリのアドレス (さらにオプションとしてポート番号) を指定する．</p>
<h3 id="コンテナを起動" tabindex="-1">コンテナを起動 <a class="header-anchor" href="#コンテナを起動" aria-label="Permalink to &quot;コンテナを起動&quot;">&ZeroWidthSpace;</a></h3>
<p>Pull してきたイメージを起動するには， <code>run</code> コマンドを使う．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">docker</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">run</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-it</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ubuntu:18.04</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">docker</span><span style="color: #24292E"> </span><span style="color: #032F62">run</span><span style="color: #24292E"> </span><span style="color: #005CC5">-it</span><span style="color: #24292E"> </span><span style="color: #032F62">ubuntu:18.04</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>ここで， <code>-it</code> とは，インタラクティブな shell のセッションを開始するために必要なオプションである．</p>
<p>このコマンドを実行すると，仮想化された Ubuntu が起動され，コマンドラインからコマンドが打ち込めるようになる (<a href="#docker_shell">figure_title</a>)． このように起動状態にある計算環境 (ランタイム) のことを <strong>Container (コンテナ)</strong> とよぶ．</p>
<p><img src="./assets/docker_shell.png" alt="Docker を使って ubuntu:18.04 イメージを起動"></p>
<p>ここで使用した <code>ubuntu:18.04</code> のイメージは，空の Ubuntu OS だが，すでにプログラムがインストール済みのものもある． これは， <a href="#sec_jupyter_and_deep_learning">Hands-on #2: AWS でディープラーニングを実践</a> でみた DLAMI と概念として似ている． たとえば， PyTorch がインストール済みのイメージは <a href="https://hub.docker.com/r/pytorch/pytorch" target="_blank" rel="noreferrer">PyTorch 公式の Docker Hub リポジトリ</a> で公開されている．</p>
<p>これを起動してみよう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">docker</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">run</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-it</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">pytorch/pytorch</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">docker</span><span style="color: #24292E"> </span><span style="color: #032F62">run</span><span style="color: #24292E"> </span><span style="color: #005CC5">-it</span><span style="color: #24292E"> </span><span style="color: #032F62">pytorch/pytorch</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p><code>docker run</code> を実行したとき，ローカルに該当するイメージが見つからない場合は，自動的に Docker Hub からダウンロードされる．</p>
<p>pytorch のコンテナが起動したら， Python のシェルを立ち上げて， pytorch をインポートしてみよう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python3</span></span>
<span class="line"><span style="color: #F69D50">Python</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">3.7</span><span style="color: #96D0FF">.7</span><span style="color: #ADBAC7"> (default, </span><span style="color: #96D0FF">May</span><span style="color: #ADBAC7">  </span><span style="color: #6CB6FF">7</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">2020</span><span style="color: #96D0FF">,</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">21</span><span style="color: #96D0FF">:25:33</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">[GCC </span><span style="color: #6CB6FF">7.3</span><span style="color: #ADBAC7">.0] :: Anaconda, Inc. on linux</span></span>
<span class="line"><span style="color: #F69D50">Type</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;help&quot;,</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;copyright&quot;,</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;credits&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">or</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;license&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">for</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">more</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">information.</span></span>
<span class="line"><span style="color: #ADBAC7">&gt;&gt;&gt; </span><span style="color: #F69D50">import</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">torch</span></span>
<span class="line"><span style="color: #ADBAC7">&gt;&gt;&gt; </span><span style="color: #DCBDFB">torch.cuda.is_available</span><span style="color: #ADBAC7">()</span></span>
<span class="line"><span style="color: #ADBAC7">False</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python3</span></span>
<span class="line"><span style="color: #6F42C1">Python</span><span style="color: #24292E"> </span><span style="color: #005CC5">3.7</span><span style="color: #032F62">.7</span><span style="color: #24292E"> (default, </span><span style="color: #032F62">May</span><span style="color: #24292E">  </span><span style="color: #005CC5">7</span><span style="color: #24292E"> </span><span style="color: #005CC5">2020</span><span style="color: #032F62">,</span><span style="color: #24292E"> </span><span style="color: #005CC5">21</span><span style="color: #032F62">:25:33</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">[GCC </span><span style="color: #005CC5">7.3</span><span style="color: #24292E">.0] :: Anaconda, Inc. on linux</span></span>
<span class="line"><span style="color: #6F42C1">Type</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;help&quot;,</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;copyright&quot;,</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;credits&quot;</span><span style="color: #24292E"> </span><span style="color: #032F62">or</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;license&quot;</span><span style="color: #24292E"> </span><span style="color: #032F62">for</span><span style="color: #24292E"> </span><span style="color: #032F62">more</span><span style="color: #24292E"> </span><span style="color: #032F62">information.</span></span>
<span class="line"><span style="color: #24292E">&gt;&gt;&gt; </span><span style="color: #6F42C1">import</span><span style="color: #24292E"> </span><span style="color: #032F62">torch</span></span>
<span class="line"><span style="color: #24292E">&gt;&gt;&gt; </span><span style="color: #6F42C1">torch.cuda.is_available</span><span style="color: #24292E">()</span></span>
<span class="line"><span style="color: #24292E">False</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br></div></div><p>このように， Docker を使うことで簡単に特定の OS・プログラムの入った計算環境を再現することが可能になる．</p>
<h3 id="自分だけのイメージを作る" tabindex="-1">自分だけのイメージを作る <a class="header-anchor" href="#自分だけのイメージを作る" aria-label="Permalink to &quot;自分だけのイメージを作る&quot;">&ZeroWidthSpace;</a></h3>
<p>自分の使うソフトウェア・ライブラリがインストールされた，自分だけのイメージを作ることも可能である．</p>
<p>たとえば， <a href="https://hub.docker.com/repository/docker/tomomano/labc" target="_blank" rel="noreferrer">本書のハンズオン実行用に提供している docker イメージ</a> には， Python, Node.js, AWS CLI, AWS CDK などのソフトウェアがインストール済みであり，ダウンロードしてくるだけですぐにハンズオンのプログラムが実行できるようになっている．</p>
<p>カスタムの docker イメージを作るには， <code>Dockerfile</code> という名前のついたファイルを用意し，その中にどんなプログラムをインストールするかなどを記述していく．</p>
<p>具体例として，本書で提供している Docker イメージのレシピを見てみよう (<a href="https://github.com/andatoshiki/toshiki-notebookblob/main/docker/Dockerfile" target="_blank" rel="noreferrer">docker/Dockerfile</a>)．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #6CB6FF">FROM</span><span style="color: #ADBAC7"> node:</span><span style="color: #6CB6FF">12</span></span>
<span class="line"><span style="color: #6CB6FF">LABEL</span><span style="color: #ADBAC7"> maintainer</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;Tomoyuki Mano&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6CB6FF">RUN</span><span style="color: #ADBAC7"> apt</span><span style="color: #F47067">-</span><span style="color: #ADBAC7">get update \</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #FF938A; font-style: italic">&amp;&amp;</span><span style="color: #ADBAC7"> apt</span><span style="color: #F47067">-</span><span style="color: #ADBAC7">get install nano</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #6CB6FF">RUN</span><span style="color: #ADBAC7"> cd </span><span style="color: #F47067">/</span><span style="color: #ADBAC7">opt \</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #FF938A; font-style: italic">&amp;&amp;</span><span style="color: #ADBAC7"> curl </span><span style="color: #F47067">-</span><span style="color: #ADBAC7">q </span><span style="color: #96D0FF">&quot;https://www.python.org/ftp/python/3.7.6/Python-3.7.6.tgz&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">-</span><span style="color: #ADBAC7">o Python</span><span style="color: #F47067">-</span><span style="color: #6CB6FF">3.7</span><span style="color: #ADBAC7">.6.tgz \</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #FF938A; font-style: italic">&amp;&amp;</span><span style="color: #ADBAC7"> tar </span><span style="color: #F47067">-</span><span style="color: #ADBAC7">xzf Python</span><span style="color: #F47067">-</span><span style="color: #6CB6FF">3.7</span><span style="color: #ADBAC7">.6.tgz \</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #FF938A; font-style: italic">&amp;&amp;</span><span style="color: #ADBAC7"> cd Python</span><span style="color: #F47067">-</span><span style="color: #6CB6FF">3.7</span><span style="color: #ADBAC7">.6 \</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #FF938A; font-style: italic">&amp;&amp;</span><span style="color: #ADBAC7"> .</span><span style="color: #F47067">/</span><span style="color: #ADBAC7">configure </span><span style="color: #FF938A; font-style: italic">--</span><span style="color: #ADBAC7">enable</span><span style="color: #F47067">-</span><span style="color: #ADBAC7">optimizations \</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #FF938A; font-style: italic">&amp;&amp;</span><span style="color: #ADBAC7"> make install</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6CB6FF">RUN</span><span style="color: #ADBAC7"> cd </span><span style="color: #F47067">/</span><span style="color: #ADBAC7">opt \</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #FF938A; font-style: italic">&amp;&amp;</span><span style="color: #ADBAC7"> curl </span><span style="color: #96D0FF">&quot;https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">-</span><span style="color: #ADBAC7">o </span><span style="color: #96D0FF">&quot;awscliv2.zip&quot;</span><span style="color: #ADBAC7"> \</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #FF938A; font-style: italic">&amp;&amp;</span><span style="color: #ADBAC7"> unzip awscliv2.zip \</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #FF938A; font-style: italic">&amp;&amp;</span><span style="color: #ADBAC7"> .</span><span style="color: #F47067">/</span><span style="color: #ADBAC7">aws</span><span style="color: #F47067">/</span><span style="color: #ADBAC7">install</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #6CB6FF">RUN</span><span style="color: #ADBAC7"> npm install </span><span style="color: #F47067">-</span><span style="color: #ADBAC7">g aws</span><span style="color: #F47067">-</span><span style="color: #ADBAC7">cdk</span><span style="color: #F47067">@</span><span style="color: #6CB6FF">1.100</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># clean up unnecessary files</span></span>
<span class="line"><span style="color: #6CB6FF">RUN</span><span style="color: #ADBAC7"> rm </span><span style="color: #F47067">-</span><span style="color: #ADBAC7">rf </span><span style="color: #F47067">/</span><span style="color: #ADBAC7">opt</span><span style="color: #F47067">/*</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># copy hands-on source code in /root/</span></span>
<span class="line"><span style="color: #6CB6FF">COPY</span><span style="color: #ADBAC7"> handson</span><span style="color: #F47067">/</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">/</span><span style="color: #ADBAC7">root</span><span style="color: #F47067">/</span><span style="color: #ADBAC7">handson</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #005CC5">FROM</span><span style="color: #24292E"> node:</span><span style="color: #005CC5">12</span></span>
<span class="line"><span style="color: #005CC5">LABEL</span><span style="color: #24292E"> maintainer</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;Tomoyuki Mano&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #005CC5">RUN</span><span style="color: #24292E"> apt</span><span style="color: #D73A49">-</span><span style="color: #24292E">get update \</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #B31D28; font-style: italic">&amp;&amp;</span><span style="color: #24292E"> apt</span><span style="color: #D73A49">-</span><span style="color: #24292E">get install nano</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #005CC5">RUN</span><span style="color: #24292E"> cd </span><span style="color: #D73A49">/</span><span style="color: #24292E">opt \</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #B31D28; font-style: italic">&amp;&amp;</span><span style="color: #24292E"> curl </span><span style="color: #D73A49">-</span><span style="color: #24292E">q </span><span style="color: #032F62">&quot;https://www.python.org/ftp/python/3.7.6/Python-3.7.6.tgz&quot;</span><span style="color: #24292E"> </span><span style="color: #D73A49">-</span><span style="color: #24292E">o Python</span><span style="color: #D73A49">-</span><span style="color: #005CC5">3.7</span><span style="color: #24292E">.6.tgz \</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #B31D28; font-style: italic">&amp;&amp;</span><span style="color: #24292E"> tar </span><span style="color: #D73A49">-</span><span style="color: #24292E">xzf Python</span><span style="color: #D73A49">-</span><span style="color: #005CC5">3.7</span><span style="color: #24292E">.6.tgz \</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #B31D28; font-style: italic">&amp;&amp;</span><span style="color: #24292E"> cd Python</span><span style="color: #D73A49">-</span><span style="color: #005CC5">3.7</span><span style="color: #24292E">.6 \</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #B31D28; font-style: italic">&amp;&amp;</span><span style="color: #24292E"> .</span><span style="color: #D73A49">/</span><span style="color: #24292E">configure </span><span style="color: #B31D28; font-style: italic">--</span><span style="color: #24292E">enable</span><span style="color: #D73A49">-</span><span style="color: #24292E">optimizations \</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #B31D28; font-style: italic">&amp;&amp;</span><span style="color: #24292E"> make install</span></span>
<span class="line"></span>
<span class="line"><span style="color: #005CC5">RUN</span><span style="color: #24292E"> cd </span><span style="color: #D73A49">/</span><span style="color: #24292E">opt \</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #B31D28; font-style: italic">&amp;&amp;</span><span style="color: #24292E"> curl </span><span style="color: #032F62">&quot;https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip&quot;</span><span style="color: #24292E"> </span><span style="color: #D73A49">-</span><span style="color: #24292E">o </span><span style="color: #032F62">&quot;awscliv2.zip&quot;</span><span style="color: #24292E"> \</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #B31D28; font-style: italic">&amp;&amp;</span><span style="color: #24292E"> unzip awscliv2.zip \</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #B31D28; font-style: italic">&amp;&amp;</span><span style="color: #24292E"> .</span><span style="color: #D73A49">/</span><span style="color: #24292E">aws</span><span style="color: #D73A49">/</span><span style="color: #24292E">install</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #005CC5">RUN</span><span style="color: #24292E"> npm install </span><span style="color: #D73A49">-</span><span style="color: #24292E">g aws</span><span style="color: #D73A49">-</span><span style="color: #24292E">cdk</span><span style="color: #D73A49">@</span><span style="color: #005CC5">1.100</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># clean up unnecessary files</span></span>
<span class="line"><span style="color: #005CC5">RUN</span><span style="color: #24292E"> rm </span><span style="color: #D73A49">-</span><span style="color: #24292E">rf </span><span style="color: #D73A49">/</span><span style="color: #24292E">opt</span><span style="color: #D73A49">/*</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># copy hands-on source code in /root/</span></span>
<span class="line"><span style="color: #005CC5">COPY</span><span style="color: #24292E"> handson</span><span style="color: #D73A49">/</span><span style="color: #24292E"> </span><span style="color: #D73A49">/</span><span style="color: #24292E">root</span><span style="color: #D73A49">/</span><span style="color: #24292E">handson</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br></div></div><p><code>Dockerfile</code> の中身の説明は詳しくは行わないが，たとえば上のコードで &lt;1&gt; で示したところは， Python 3.7 のインストールを実行している． また， &lt;2&gt; で示したところは， AWS CDK のインストールを行っていることがわかるだろう． このように，リアルな OS で行うのと同じ流れでインストールのコマンドを逐一記述していくことで，自分だけの Docker イメージを作成することができる． 一度イメージを作成すれば，それを配布することで，他者も同一の計算環境を簡単に再構成することができる．</p>
<p>&quot;ぼくの環境ではそのプログラム走ったのにな…&quot; というのは，プログラミング初心者ではよく耳にする会話だが， Docker を使いこなせばそのような心配とは無縁である． そのような意味で，クラウド以外の場面でも， Docker の有用性・汎用性は極めて高い．</p>
<p>コンテナを用いた仮想計算環境ツールとして Docker を紹介したが， ほかに選択肢はないのか？ よくぞ聞いてくれた！ Docker の登場以降，複数のコンテナベースの仮想環境ツールが開発されてきた． いずれのツールも，概念や API については Docker と共通するものが多いが，Docker にはない独自の特徴を提供している． ここではその中でも有名ないくつかを紹介しよう．</p>
<p><a href="https://github.com/hpcng/singularity" target="_blank" rel="noreferrer">Singularity</a> は科学計算や HPC (High Performance Computing) の分野で人気の高いコンテナプラットフォームである． Singularity では大学・研究機関の HPC クラスターでの運用に適したような設計が施されている． たとえば， Docker は基本的には root 権限で実行されるのに対し， Singularity はユーザー権限 (コマンドを実行したユーザー自身) でプログラムが実行される． root 権限での実行は Web サーバーのように個人・企業がある特定のサービスのために運用するサーバーでは問題ないが，多数のユーザーが多様な目的で計算を実行する HPC クラスターでは問題となる． また，Singularity は独自のイメージの作成方法・エコシステムをもっているが， Docker イメージを Singularity のイメージに変換し実行する機能も有している．</p>
<p><a href="https://github.com/containers/podman" target="_blank" rel="noreferrer">podman</a> は Red Hat 社によって開発されたもう一つのコンテナプラットフォームである． podman は基本的に Docker と同一のコマンドを採用しているが，実装は Red Hat によってスクラッチから行われた． podman では， Singularity と同様にユーザー権限でのプログラムの実行を可能であり，クラウドおよび HPC の両方の環境に対応するコンテナプラットフォームを目指して作られた． また，その名前にあるとおり pod とよばれる独自の概念が導入されている．</p>
<p>著者の個人的な意見としては，現時点では Docker をマスターしておけば当面は困ることはないと考えるが，興味のある読者はぜひこれらのツールも試してみてはいかがだろうか？</p>
<h2 id="elastic-container-service-ecs" tabindex="-1">Elastic Container Service (ECS) <a class="header-anchor" href="#elastic-container-service-ecs" aria-label="Permalink to &quot;Elastic Container Service (ECS)&quot;">&ZeroWidthSpace;</a></h2>
<p><img src="./assets/aws_logos/ECS.png" alt="ECS のアイコン"></p>
<p>ここまでに説明してきたように， Docker を使うことで仮想計算環境を簡単に複製・起動することが可能になる． 本章の最後の話題として， AWS 上で Docker を使った計算システムを構築する方法を解説しよう．</p>
<p><strong>Elastic Container Service (ECS)</strong> とは， Docker を使った計算機クラスターを AWS 上に作成するためのツールである (<a href="#fig:logo_ecs">figure_title</a>)． ECS を使用することで， Docker にパッケージされたアプリケーションを計算機クラスターに投入したり，計算機クラスターのインスタンスを追加・削除する操作 (=スケーリング) を行うことができる．</p>
<p>ECS の概要を示したのが <a href="#ecs_overview">figure_title</a> である． ECS は，<strong>タスク (Task)</strong> と呼ばれる単位で管理された計算ジョブを受け付ける． システムにタスクが投入されると，ECS は最初にタスクで指定された Docker イメージを外部レジストリからダウンロードしてくる． 外部レジストリとしては， Docker Hub や AWS 独自の Docker レジストリである <strong>ECR (Elastic Container Registry)</strong> を指定することができる．</p>
<p>ECS の次の重要な役割はタスクの配置である． あらかじめ定義されたクラスター内で，計算負荷が小さい仮想インスタンスを選び出し，そこに Docker イメージを配置することで指定された計算タスクが開始される． &quot;計算負荷が小さい仮想インスタンスを選び出す&quot; と言ったが，具体的にどのような戦略・ポリシーでこの選択を行うかは，ユーザーの指定したパラメータに従う．</p>
<p>また，クラスターのスケーリングも ECS における重要な概念である． スケーリングとは，クラスター内のインスタンスの計算負荷をモニタリングし，計算負荷に応じてインスタンスの起動・停止を行う操作を指す． クラスター全体の計算負荷が指定された閾値 (たとえば 80%の稼働率) を超えていた場合，新たな仮想インスタンスをクラスター内に立ち上げる操作を scale-out (スケールアウト) とよび， 負荷が減った場合に不要なインスタンスを停止する操作を scale-in (スケールイン) とよぶ． クラスターのスケーリングは， ECS がほかの AWS のサービスと連携することで実現される． 具体的には， EC2 の <strong>Auto scaling group (ASG)</strong> や <strong>Fargate</strong> の２つの選択肢が多くの場合選択される． <strong>ASG</strong> については <a href="#sec_aws_batch">Hands-on #4: AWS Batch を使って機械学習のハイパーパラメータサーチを並列化する</a>, Fargate については <a href="#sec_fargate_qabot">Hands-on #3: AWS で自動質問回答ボットを走らせる</a> でより詳細に解説する．</p>
<p>これら一連のタスクの管理を， ECS は自動でやってくれる． クラスターのスケーリングやタスクの配置に関してのパラメータを一度指定してしまえば，ユーザーは (ほとんどなにも考えずに) 大量のタスクを投入することができる． クラスターのスケーリングによってタスクの量にちょうど十分なだけのインスタンスが起動し，タスクが完了した後は不要なインスタンスはすべて停止される．</p>
<p>さて，ここまで説明的な話が続いてしまったが，次章からは早速 Docker と AWS を使って大規模な並列計算システムを構築していこう！</p>
<p><img src="./assets/ecs.png" alt="ECS の概要"></p>
<h1 id="hands-on-3-aws-で自動質問回答ボットを走らせる" tabindex="-1">Hands-on #3: AWS で自動質問回答ボットを走らせる <a class="header-anchor" href="#hands-on-3-aws-で自動質問回答ボットを走らせる" aria-label="Permalink to &quot;Hands-on \#3: AWS で自動質問回答ボットを走らせる&quot;">&ZeroWidthSpace;</a></h1>
<p>ハンズオン第三回では， Docker と ECS を駆使した機械学習アプリケーションを実装しよう． 具体的には，深層学習による自然言語処理を行うことで，クライアントから与えられた文章題に対して回答を生成する，自動 Question &amp; Answering ボットを作成しよう． ECS を利用することで，ジョブの数によって動的にインスタンスの数を制御し，並列にタスクを実行するようなシステムを構築しよう．</p>
<p>通常の機械学習のワークフローでは，モデルの訓練 ⇒ 推論 (データへの適用) が基本的な流れである． しかしながら， GPU 搭載型の EC2 クラスターを使ったモデルの訓練はやや難易度が高いため，次章 (<a href="#sec_aws_batch">Hands-on #4: AWS Batch を使って機械学習のハイパーパラメータサーチを並列化する</a>) で取り扱う． 本章は，クラウド上でのクラスターの構築・タスクの管理などの概念に慣れるため，よりシンプルな実装で実現できる Fargate クラスターを用いた推論計算の並列化を紹介する．</p>
<h2 id="fargate" tabindex="-1">Fargate <a class="header-anchor" href="#fargate" aria-label="Permalink to &quot;Fargate&quot;">&ZeroWidthSpace;</a></h2>
<p>ハンズオンに入っていく前に， <strong>Fargate</strong> という AWS の機能を知っておく必要がある (<a href="#fig:fargate_logo">figure_title</a>)．</p>
<p><img src="./assets/aws_logos/Fargate.png" alt="Fargate のアイコン"></p>
<p>ECS の概要を示した <a href="#ecs_overview">figure_title</a> をもう一度見てみよう． この図で， ECS の管理下にあるクラスターが示されているが，このクラスターの中で計算を行う実体としては二つの選択肢がある． <strong>EC2 あるいは Fargate</strong> のいずれかである． EC2 を用いた場合は，先の章 (<a href="#sec_first_ec2">Hands-on #1: 初めての EC2 インスタンスを起動する</a>, <a href="#sec_jupyter_and_deep_learning">Hands-on #2: AWS でディープラーニングを実践</a>) で説明したような流れでインスタンスが起動し，計算が実行される． しかし， EC2 を用いた計算機クラスターの作成・管理は技術的な難易度がやや高いので，次章 (<a href="#sec_aws_batch">Hands-on #4: AWS Batch を使って機械学習のハイパーパラメータサーチを並列化する</a>) で説明することにする．</p>
<p>Fargate とは， <strong>ECS での利用に特化</strong>して設計された，<strong>コンテナを使用した計算タスク</strong>を走らせるための仕組みである． 計算を走らせるという点では EC2 と役割は似ているが， Fargate は EC2 インスタンスのような物理的実体はもたない． 物理的実体をもたないというのは，たとえば SSH でログインすることは基本的に想定されていないし，なにかのソフトウェアをインストールしたりなどの概念も存在しない． Fargate ではすべての計算は Docker コンテナを介して行われる． すなわち， Fargate を利用するには，ユーザーは最初に所望の Docker イメージを指定しておき， Fargate は <code>docker run</code> のコマンドを使用することで計算タスクを実行する． Fargate を用いる利点は， Fargate を ECS のクラスターに指定すると，スケーリングなどの操作が簡単な設定・プログラムで構築できる点である．</p>
<p>Fargate では， EC2 と同様に CPU とメモリーのサイズを必要な分だけ指定できる． 執筆時点では， CPU は 0.25 - 4 コア， RAM は 0.5 - 30 GB の間で選択することができる (詳しくは <a href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/AWS_Fargate.html" target="_blank" rel="noreferrer">公式ドキュメンテーション &quot;Amazon ECS on AWS Fargate&quot;</a> 参照)． クラスターのスケーリングが容易な分， Fargate では EC2 ほど大きな CPU コア・ RAM 容量を単一インスタンスに付与することができず，また GPU を利用することもできない．</p>
<p>以上が Fargate の概要であったが，くどくど言葉で説明してもなかなかピンとこないだろう． ここからは実際に手を動かしながら， ECS と Fargate を使った並列タスクの処理の仕方を学んでいこう．</p>
<p>厳密には， ECS に付与するクラスターには EC2 と Fargate のハイブリッドを使用することも可能である．</p>
<h2 id="準備-2" tabindex="-1">準備 <a class="header-anchor" href="#準備-2" aria-label="Permalink to &quot;準備&quot;">&ZeroWidthSpace;</a></h2>
<p>ハンズオンのソースコードは GitHub の <a href="https://github.com/andatoshiki/toshiki-notebooktree/main/handson/qa-bot" target="_blank" rel="noreferrer">handson/qa-bot</a> にある．</p>
<p>本ハンズオンの実行には，第一回ハンズオンで説明した準備 (<a href="#handson_01_prep">準備</a>) が整っていることを前提とする． また， Docker が自身のローカルマシンにインストール済みであることも必要である．</p>
<p>このハンズオンでは 1CPU/4GB RAM の Fargate インスタンスを使用する． 計算の実行には 0.025 $/hour のコストが発生することに注意．</p>
<h2 id="transformer-を用いた-question-answering-プログラム" tabindex="-1">Transformer を用いた question-answering プログラム <a class="header-anchor" href="#transformer-を用いた-question-answering-プログラム" aria-label="Permalink to &quot;Transformer を用いた question-answering プログラム&quot;">&ZeroWidthSpace;</a></h2>
<p>このハンズオンで開発する，自動質問回答システムをより具体的に定義しよう． 次のような文脈 (context) と質問 (question) が与えられた状況を想定する．</p>
<div class="language-txt vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">txt</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #adbac7">context: Albert Einstein (14 March 1879 – 18 April 1955) was a German-born theoretical physicist who developed the theory of relativity, one of the two pillars of modern physics (alongside quantum mechanics). His work is also known for its influence on the philosophy of science. He is best known to the general public for his mass–energy equivalence formula E = mc2, which has been dubbed \&quot;the world&#39;s most famous equation\&quot;. He received the 1921 Nobel Prize in Physics \&quot;for his services to theoretical physics, and especially for his discovery of the law of the photoelectric effect\&quot;, a pivotal step in the development of quantum theory.</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">question: In what year did Einstein win the Nobel prize?</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292e">context: Albert Einstein (14 March 1879 – 18 April 1955) was a German-born theoretical physicist who developed the theory of relativity, one of the two pillars of modern physics (alongside quantum mechanics). His work is also known for its influence on the philosophy of science. He is best known to the general public for his mass–energy equivalence formula E = mc2, which has been dubbed \&quot;the world&#39;s most famous equation\&quot;. He received the 1921 Nobel Prize in Physics \&quot;for his services to theoretical physics, and especially for his discovery of the law of the photoelectric effect\&quot;, a pivotal step in the development of quantum theory.</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">question: In what year did Einstein win the Nobel prize?</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><p>今回作成する自動回答システムは，このような問題に対して， context に含まれる文字列から正解となる言葉を見つけ出すものとする． 上の問題では，次のような回答を返すべきである．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">answer:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">1921</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">answer:</span><span style="color: #24292E"> </span><span style="color: #005CC5">1921</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>人間にとっては，このような文章を理解することは容易であるが，コンピュータにそれを解かせるのは難しいことは容易に想像ができるだろう． しかし，近年の深層学習を使った自然言語処理の進歩は著しく，上で示したような例題などは極めて高い正答率で回答できるモデルを作ることができる．</p>
<p>今回は， <a href="https://github.com/huggingface/transformers" target="_blank" rel="noreferrer">huggingface/transformers</a> で公開されている学習済みの言語モデルを利用することで，上で定義した問題を解く Q&amp;A ボットを作る． この Q&amp;A ボットは <a href="https://en.wikipedia.org/wiki/Transformer_(machine_learning_model)" target="_blank" rel="noreferrer">Transformer</a> とよばれるモデルを使った自然言語処理に支えられえている (<a href="#transformer_architecture">figure_title</a>)． このプログラムを， Docker にパッケージしたものが <a href="https://hub.docker.com/repository/docker/tomomano/qabot" target="_blank" rel="noreferrer">著者の Docker Hub リポジトリ</a> に用意してある． クラウドの設計に入る前に，まずはこのプログラムを単体で動かしてみよう．</p>
<p><img src="./assets/transformer.png" alt="Transformer モデルアーキテクチャ (画像出典: Vaswani+ 2017)"></p>
<p>なお，今回は学習済みのモデルを用いているので，私達が行うのは与えられた入力をモデルに投入して予測を行う (推論) のみである． 推論の演算は， CPU だけでも十分高速に行うことができるので，コストの削減と，実装をシンプルにする目的で，このハンズオンでは GPU は利用しない． 一般的に， ニューラルネットは学習のほうが圧倒的に計算コストが大きく，そのような場合に GPU はより威力を発揮する．</p>
<p>次のコマンドで，今回使う Docker image を ローカルにダウンロード (pull) してこよう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">docker</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">pull</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">tomomano/qabot:latest</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">docker</span><span style="color: #24292E"> </span><span style="color: #032F62">pull</span><span style="color: #24292E"> </span><span style="color: #032F62">tomomano/qabot:latest</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>pull できたら，早速この Docker に質問を投げかけてみよう． まずは context と question をコマンドラインの変数として定義する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">context=&quot;Albert Einstein (14 March 1879 – 18 April 1955) was a German-born theoretical physicist who developed the theory of relativity, one of the two pillars of modern physics (alongside quantum mechanics). His work is also known for its influence on the philosophy of science. He is best known to the general public for his mass–energy equivalence formula E = mc2, which has been dubbed the world&#39;s most famous equation. He received the 1921 Nobel Prize in Physics for his services to theoretical physics, and especially for his discovery of the law of the photoelectric effect, a pivotal step in the development of quantum theory.&quot;</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">question=&quot;In what year did Einstein win the Nobel prize ?&quot;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">context=&quot;Albert Einstein (14 March 1879 – 18 April 1955) was a German-born theoretical physicist who developed the theory of relativity, one of the two pillars of modern physics (alongside quantum mechanics). His work is also known for its influence on the philosophy of science. He is best known to the general public for his mass–energy equivalence formula E = mc2, which has been dubbed the world&#39;s most famous equation. He received the 1921 Nobel Prize in Physics for his services to theoretical physics, and especially for his discovery of the law of the photoelectric effect, a pivotal step in the development of quantum theory.&quot;</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">question=&quot;In what year did Einstein win the Nobel prize ?&quot;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>そうしたら，次のコマンドによってコンテナを実行する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">docker</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">run</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">tomomano/qabot</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;${</span><span style="color: #ADBAC7">context</span><span style="color: #96D0FF">}&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;${</span><span style="color: #ADBAC7">question</span><span style="color: #96D0FF">}&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">foo</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--no_save</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">docker</span><span style="color: #24292E"> </span><span style="color: #032F62">run</span><span style="color: #24292E"> </span><span style="color: #032F62">tomomano/qabot</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;${</span><span style="color: #24292E">context</span><span style="color: #032F62">}&quot;</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;${</span><span style="color: #24292E">question</span><span style="color: #032F62">}&quot;</span><span style="color: #24292E"> </span><span style="color: #032F62">foo</span><span style="color: #24292E"> </span><span style="color: #005CC5">--no_save</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>今回用意した Docker image は，第一引数に context となる文字列を，第二引数に question に相当する文字列を受けつける． 第三引数，第四引数については，クラウドに展開するときの実装上の都合なので，いまは気にしなくてよい．</p>
<p>このコマンドを実行すると，次のような出力が得られるはずである．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">{</span><span style="color: #F69D50">&#39;score&#39;</span><span style="color: #6CB6FF">:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0.9881729286683587</span><span style="color: #96D0FF">,</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;start&#39;:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">437</span><span style="color: #96D0FF">,</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;end&#39;:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">441</span><span style="color: #96D0FF">,</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;answer&#39;:</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;1921&#39;}</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">{</span><span style="color: #6F42C1">&#39;score&#39;</span><span style="color: #005CC5">:</span><span style="color: #24292E"> </span><span style="color: #005CC5">0.9881729286683587</span><span style="color: #032F62">,</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;start&#39;:</span><span style="color: #24292E"> </span><span style="color: #005CC5">437</span><span style="color: #032F62">,</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;end&#39;:</span><span style="color: #24292E"> </span><span style="color: #005CC5">441</span><span style="color: #032F62">,</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;answer&#39;:</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;1921&#39;}</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>&quot;score&quot; は正解の自信度を表す数字で， [0,1] の範囲で与えられる． &quot;start&quot;, &quot;end&quot; は， context 中の何文字目が正解に相当するかを示しており， &quot;answer&quot; が正解と予測された文字列である． 1921 年という，正しい答えが返ってきていることに注目してほしい．</p>
<p>もう少し難しい質問を投げかけてみよう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">question=&quot;Why did Einstein win the Nobel prize ?&quot;</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">docker</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">run</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">tomomano/qabot</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;${</span><span style="color: #ADBAC7">context</span><span style="color: #96D0FF">}&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;${</span><span style="color: #ADBAC7">question</span><span style="color: #96D0FF">}&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">foo</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--no_save</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">question=&quot;Why did Einstein win the Nobel prize ?&quot;</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">docker</span><span style="color: #24292E"> </span><span style="color: #032F62">run</span><span style="color: #24292E"> </span><span style="color: #032F62">tomomano/qabot</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;${</span><span style="color: #24292E">context</span><span style="color: #032F62">}&quot;</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;${</span><span style="color: #24292E">question</span><span style="color: #032F62">}&quot;</span><span style="color: #24292E"> </span><span style="color: #032F62">foo</span><span style="color: #24292E"> </span><span style="color: #005CC5">--no_save</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>出力：</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">{</span><span style="color: #F69D50">&#39;score&#39;</span><span style="color: #6CB6FF">:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0.5235594527494207</span><span style="color: #96D0FF">,</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;start&#39;:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">470</span><span style="color: #96D0FF">,</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;end&#39;:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">506</span><span style="color: #96D0FF">,</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;answer&#39;:</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;his services to theoretical physics,&#39;}</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">{</span><span style="color: #6F42C1">&#39;score&#39;</span><span style="color: #005CC5">:</span><span style="color: #24292E"> </span><span style="color: #005CC5">0.5235594527494207</span><span style="color: #032F62">,</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;start&#39;:</span><span style="color: #24292E"> </span><span style="color: #005CC5">470</span><span style="color: #032F62">,</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;end&#39;:</span><span style="color: #24292E"> </span><span style="color: #005CC5">506</span><span style="color: #032F62">,</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;answer&#39;:</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;his services to theoretical physics,&#39;}</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>今度は， score が 0.52 と，少し自信がないようだが，それでも正しい答えにたどりつけていることがわかる．</p>
<p>このように， 深層学習に支えられた言語モデルを用いることで，実用にも役に立ちそうな Q&amp;A ボットを実現できていることがわかる． 以降では，このプログラムをクラウドに展開することで，大量の質問に自動で対応できるようなシステムを設計していく．</p>
<p>今回使用する Question &amp; Answering システムには， DistilBERT という Transformer を基にした言語モデルが用いられている． 興味のある読者は， <a href="https://arxiv.org/abs/1910.01108" target="_blank" rel="noreferrer">原著論文</a> を参照してもらいたい． また， huggingface/transformers による DistilBert の実装のドキュメンテーションは <a href="https://huggingface.co/transformers/model_doc/distilbert.html" target="_blank" rel="noreferrer">公式ドキュメンテーション</a> を参照のこと．</p>
<p>今回提供する Q-A ボットの Docker のソースコードは <a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/qa-bot/docker/Dockerfile" target="_blank" rel="noreferrer">https://github.com/andatoshiki/toshiki-notebookblob/main/handson/qa-bot/docker/Dockerfile</a> にある．</p>
<h2 id="アプリケーションの説明-2" tabindex="-1">アプリケーションの説明 <a class="header-anchor" href="#アプリケーションの説明-2" aria-label="Permalink to &quot;アプリケーションの説明&quot;">&ZeroWidthSpace;</a></h2>
<p>このハンズオンで作成するアプリケーションの概要を <a href="#handson_03_architecture">figure_title</a> に示す．</p>
<p><img src="./assets/handson-03/handson-03-architecture.png" alt="アプリケーションのアーキテクチャ"></p>
<p>簡単にまとめると，以下のような設計である．</p>
<ul>
<li>
<p>クライアントは，質問を AWS 上のアプリケーションに送信する．</p>
</li>
<li>
<p>質問のタスクは ECS によって処理される．</p>
</li>
<li>
<p>ECS は， Docker Hub から，イメージをダウンロードする．</p>
</li>
<li>
<p>次に，ECS はクラスター内に新たな Fargate インスタンスを立ち上げ，ダウンロードされた Docker イメージをこの新規インスタンスに配置する．</p>
<ul>
<li>このとき，一つの質問に対し一つの Fargate インスタンスを立ち上げることで，複数の質問を並列的に処理できるようにする．</li>
</ul>
</li>
<li>
<p>ジョブが実行される．</p>
</li>
<li>
<p>ジョブの実行結果 (質問への回答) は， データベース (DynamoDB) に書き込まれる．</p>
</li>
<li>
<p>最後に，クライアントは DynamoDB から質問への回答を読み取る．</p>
</li>
</ul>
<p>それでは，プログラムのソースコードを見てみよう (<a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/qa-bot/app.py" target="_blank" rel="noreferrer">handson/qa-bot/app.py</a>)．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">class</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">EcsClusterQaBot</span><span style="color: #ADBAC7">(</span><span style="color: #F69D50">core.Stack</span><span style="color: #ADBAC7">)</span><span style="color: #96D0FF">:</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">def</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">__init__</span><span style="color: #ADBAC7">(</span><span style="color: #F69D50">self,</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">scope:</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">core.App,</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">name:</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">str,</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">**</span><span style="color: #96D0FF">kwargs</span><span style="color: #ADBAC7">) -</span><span style="color: #F47067">&gt;</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">None:</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #DCBDFB">super</span><span style="color: #ADBAC7">().__init__(</span><span style="color: #F69D50">scope,</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">name,</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">**</span><span style="color: #96D0FF">kwargs</span><span style="color: #ADBAC7">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390"># dynamoDB table to store questions and answers</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #F69D50">table</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">dynamodb.Table</span><span style="color: #ADBAC7">(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">self,</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;EcsClusterQaBot-Table&quot;,</span></span>
<span class="line"><span style="color: #ADBAC7">            partition_key</span><span style="color: #F47067">=</span><span style="color: #96D0FF">dynamodb.Attribute</span><span style="color: #ADBAC7">(</span></span>
<span class="line"><span style="color: #ADBAC7">                name</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;item_id&quot;,</span><span style="color: #ADBAC7"> type</span><span style="color: #F47067">=</span><span style="color: #96D0FF">dynamodb.AttributeType.STRING</span></span>
<span class="line"><span style="color: #ADBAC7">            )</span><span style="color: #96D0FF">,</span></span>
<span class="line"><span style="color: #ADBAC7">            billing_mode</span><span style="color: #F47067">=</span><span style="color: #96D0FF">dynamodb.BillingMode.PAY_PER_REQUEST,</span></span>
<span class="line"><span style="color: #ADBAC7">            removal_policy</span><span style="color: #F47067">=</span><span style="color: #96D0FF">core.RemovalPolicy.DESTROY</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #F69D50">vpc</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ec2.Vpc</span><span style="color: #ADBAC7">(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">self,</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;EcsClusterQaBot-Vpc&quot;,</span></span>
<span class="line"><span style="color: #ADBAC7">            max_azs</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">1</span><span style="color: #96D0FF">,</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #F69D50">cluster</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ecs.Cluster</span><span style="color: #ADBAC7">(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">self,</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;EcsClusterQaBot-Cluster&quot;,</span></span>
<span class="line"><span style="color: #ADBAC7">            vpc</span><span style="color: #F47067">=</span><span style="color: #96D0FF">vpc,</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #F69D50">taskdef</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ecs.FargateTaskDefinition</span><span style="color: #ADBAC7">(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">self,</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;EcsClusterQaBot-TaskDef&quot;,</span></span>
<span class="line"><span style="color: #ADBAC7">            cpu</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">1024</span><span style="color: #96D0FF">,</span><span style="color: #ADBAC7"> </span><span style="color: #768390"># 1 CPU</span></span>
<span class="line"><span style="color: #ADBAC7">            memory_limit_mib</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">4096</span><span style="color: #96D0FF">,</span><span style="color: #ADBAC7"> </span><span style="color: #768390"># 4GB RAM</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390"># grant permissions</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #F69D50">table.grant_read_write_data(taskdef.task_role</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #F69D50">taskdef.add_to_task_role_policy(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">iam.PolicyStatement(</span></span>
<span class="line"><span style="color: #ADBAC7">                effect</span><span style="color: #F47067">=</span><span style="color: #96D0FF">iam.Effect.ALLOW,</span></span>
<span class="line"><span style="color: #ADBAC7">                resources</span><span style="color: #F47067">=</span><span style="color: #96D0FF">[&quot;*&quot;],</span></span>
<span class="line"><span style="color: #ADBAC7">                actions</span><span style="color: #F47067">=</span><span style="color: #96D0FF">[&quot;ssm:GetParameter&quot;]</span></span>
<span class="line"><span style="color: #ADBAC7">            )</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #F69D50">container</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">taskdef.add_container</span><span style="color: #ADBAC7">(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">&quot;EcsClusterQaBot-Container&quot;</span><span style="color: #F69D50">,</span></span>
<span class="line"><span style="color: #ADBAC7">            image</span><span style="color: #F47067">=</span><span style="color: #96D0FF">ecs.ContainerImage.from_registry</span><span style="color: #ADBAC7">(</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">&quot;tomomano/qabot:latest&quot;</span></span>
<span class="line"><span style="color: #ADBAC7">            )</span><span style="color: #96D0FF">,</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">class</span><span style="color: #24292E"> </span><span style="color: #032F62">EcsClusterQaBot</span><span style="color: #24292E">(</span><span style="color: #6F42C1">core.Stack</span><span style="color: #24292E">)</span><span style="color: #032F62">:</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #6F42C1">def</span><span style="color: #24292E"> </span><span style="color: #032F62">__init__</span><span style="color: #24292E">(</span><span style="color: #6F42C1">self,</span><span style="color: #24292E"> </span><span style="color: #032F62">scope:</span><span style="color: #24292E"> </span><span style="color: #032F62">core.App,</span><span style="color: #24292E"> </span><span style="color: #032F62">name:</span><span style="color: #24292E"> </span><span style="color: #032F62">str,</span><span style="color: #24292E"> </span><span style="color: #005CC5">**</span><span style="color: #032F62">kwargs</span><span style="color: #24292E">) -</span><span style="color: #D73A49">&gt;</span><span style="color: #24292E"> </span><span style="color: #032F62">None:</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6F42C1">super</span><span style="color: #24292E">().__init__(</span><span style="color: #6F42C1">scope,</span><span style="color: #24292E"> </span><span style="color: #032F62">name,</span><span style="color: #24292E"> </span><span style="color: #005CC5">**</span><span style="color: #032F62">kwargs</span><span style="color: #24292E">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D"># dynamoDB table to store questions and answers</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6F42C1">table</span><span style="color: #24292E"> </span><span style="color: #032F62">=</span><span style="color: #24292E"> </span><span style="color: #032F62">dynamodb.Table</span><span style="color: #24292E">(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #6F42C1">self,</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;EcsClusterQaBot-Table&quot;,</span></span>
<span class="line"><span style="color: #24292E">            partition_key</span><span style="color: #D73A49">=</span><span style="color: #032F62">dynamodb.Attribute</span><span style="color: #24292E">(</span></span>
<span class="line"><span style="color: #24292E">                name</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;item_id&quot;,</span><span style="color: #24292E"> type</span><span style="color: #D73A49">=</span><span style="color: #032F62">dynamodb.AttributeType.STRING</span></span>
<span class="line"><span style="color: #24292E">            )</span><span style="color: #032F62">,</span></span>
<span class="line"><span style="color: #24292E">            billing_mode</span><span style="color: #D73A49">=</span><span style="color: #032F62">dynamodb.BillingMode.PAY_PER_REQUEST,</span></span>
<span class="line"><span style="color: #24292E">            removal_policy</span><span style="color: #D73A49">=</span><span style="color: #032F62">core.RemovalPolicy.DESTROY</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6F42C1">vpc</span><span style="color: #24292E"> </span><span style="color: #032F62">=</span><span style="color: #24292E"> </span><span style="color: #032F62">ec2.Vpc</span><span style="color: #24292E">(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #6F42C1">self,</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;EcsClusterQaBot-Vpc&quot;,</span></span>
<span class="line"><span style="color: #24292E">            max_azs</span><span style="color: #D73A49">=</span><span style="color: #005CC5">1</span><span style="color: #032F62">,</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6F42C1">cluster</span><span style="color: #24292E"> </span><span style="color: #032F62">=</span><span style="color: #24292E"> </span><span style="color: #032F62">ecs.Cluster</span><span style="color: #24292E">(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #6F42C1">self,</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;EcsClusterQaBot-Cluster&quot;,</span></span>
<span class="line"><span style="color: #24292E">            vpc</span><span style="color: #D73A49">=</span><span style="color: #032F62">vpc,</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6F42C1">taskdef</span><span style="color: #24292E"> </span><span style="color: #032F62">=</span><span style="color: #24292E"> </span><span style="color: #032F62">ecs.FargateTaskDefinition</span><span style="color: #24292E">(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #6F42C1">self,</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;EcsClusterQaBot-TaskDef&quot;,</span></span>
<span class="line"><span style="color: #24292E">            cpu</span><span style="color: #D73A49">=</span><span style="color: #005CC5">1024</span><span style="color: #032F62">,</span><span style="color: #24292E"> </span><span style="color: #6A737D"># 1 CPU</span></span>
<span class="line"><span style="color: #24292E">            memory_limit_mib</span><span style="color: #D73A49">=</span><span style="color: #005CC5">4096</span><span style="color: #032F62">,</span><span style="color: #24292E"> </span><span style="color: #6A737D"># 4GB RAM</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D"># grant permissions</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6F42C1">table.grant_read_write_data(taskdef.task_role</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6F42C1">taskdef.add_to_task_role_policy(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #6F42C1">iam.PolicyStatement(</span></span>
<span class="line"><span style="color: #24292E">                effect</span><span style="color: #D73A49">=</span><span style="color: #032F62">iam.Effect.ALLOW,</span></span>
<span class="line"><span style="color: #24292E">                resources</span><span style="color: #D73A49">=</span><span style="color: #032F62">[&quot;*&quot;],</span></span>
<span class="line"><span style="color: #24292E">                actions</span><span style="color: #D73A49">=</span><span style="color: #032F62">[&quot;ssm:GetParameter&quot;]</span></span>
<span class="line"><span style="color: #24292E">            )</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6F42C1">container</span><span style="color: #24292E"> </span><span style="color: #032F62">=</span><span style="color: #24292E"> </span><span style="color: #032F62">taskdef.add_container</span><span style="color: #24292E">(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #6F42C1">&quot;EcsClusterQaBot-Container&quot;</span><span style="color: #6F42C1">,</span></span>
<span class="line"><span style="color: #24292E">            image</span><span style="color: #D73A49">=</span><span style="color: #032F62">ecs.ContainerImage.from_registry</span><span style="color: #24292E">(</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #6F42C1">&quot;tomomano/qabot:latest&quot;</span></span>
<span class="line"><span style="color: #24292E">            )</span><span style="color: #032F62">,</span></span>
<span class="line"><span style="color: #24292E">        )</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br><span class="line-number">36</span><br><span class="line-number">37</span><br><span class="line-number">38</span><br><span class="line-number">39</span><br><span class="line-number">40</span><br><span class="line-number">41</span><br><span class="line-number">42</span><br><span class="line-number">43</span><br><span class="line-number">44</span><br><span class="line-number">45</span><br><span class="line-number">46</span><br><span class="line-number">47</span><br><span class="line-number">48</span><br><span class="line-number">49</span><br><span class="line-number">50</span><br><span class="line-number">51</span><br><span class="line-number">52</span><br></div></div><ul>
<li>
<p>ここでは，回答の結果を書き込むためのデータベースを用意している． DynamoDB については，サーバーレスアーキテクチャの章で扱うので，今は気にしなくてよい．</p>
</li>
<li>
<p>ここでは，ハンズオン #1, #2 で行ったのと同様に， VPC を定義している．</p>
</li>
<li>
<p>ここで， ECS のクラスター (cluster) を定義している． クラスターとは，仮想サーバーのプールのことであり，クラスターの中に複数の仮想インスタンスを配置する．</p>
</li>
<li>
<p>ここで，実行するタスクを定義している (task definition)．</p>
</li>
<li>
<p>ここで， タスクの実行で使用する Docker イメージを定義している．</p>
</li>
</ul>
<h3 id="ecs-と-fargate" tabindex="-1">ECS と Fargate <a class="header-anchor" href="#ecs-と-fargate" aria-label="Permalink to &quot;ECS と Fargate&quot;">&ZeroWidthSpace;</a></h3>
<p>ECS と Fargate の部分について，コードをくわしく見てみよう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">cluster</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ecs.Cluster</span><span style="color: #ADBAC7">(</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">self,</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;EcsClusterQaBot-Cluster&quot;,</span></span>
<span class="line"><span style="color: #ADBAC7">    vpc</span><span style="color: #F47067">=</span><span style="color: #96D0FF">vpc,</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F69D50">taskdef</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ecs.FargateTaskDefinition</span><span style="color: #ADBAC7">(</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">self,</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;EcsClusterQaBot-TaskDef&quot;,</span></span>
<span class="line"><span style="color: #ADBAC7">    cpu</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">1024</span><span style="color: #96D0FF">,</span><span style="color: #ADBAC7"> </span><span style="color: #768390"># 1 CPU</span></span>
<span class="line"><span style="color: #ADBAC7">    memory_limit_mib</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">4096</span><span style="color: #96D0FF">,</span><span style="color: #ADBAC7"> </span><span style="color: #768390"># 4GB RAM</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F69D50">container</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">taskdef.add_container</span><span style="color: #ADBAC7">(</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">&quot;EcsClusterQaBot-Container&quot;</span><span style="color: #F69D50">,</span></span>
<span class="line"><span style="color: #ADBAC7">    image</span><span style="color: #F47067">=</span><span style="color: #96D0FF">ecs.ContainerImage.from_registry</span><span style="color: #ADBAC7">(</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #F69D50">&quot;tomomano/qabot:latest&quot;</span></span>
<span class="line"><span style="color: #ADBAC7">    )</span><span style="color: #96D0FF">,</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">cluster</span><span style="color: #24292E"> </span><span style="color: #032F62">=</span><span style="color: #24292E"> </span><span style="color: #032F62">ecs.Cluster</span><span style="color: #24292E">(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #6F42C1">self,</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;EcsClusterQaBot-Cluster&quot;,</span></span>
<span class="line"><span style="color: #24292E">    vpc</span><span style="color: #D73A49">=</span><span style="color: #032F62">vpc,</span></span>
<span class="line"><span style="color: #24292E">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6F42C1">taskdef</span><span style="color: #24292E"> </span><span style="color: #032F62">=</span><span style="color: #24292E"> </span><span style="color: #032F62">ecs.FargateTaskDefinition</span><span style="color: #24292E">(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #6F42C1">self,</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;EcsClusterQaBot-TaskDef&quot;,</span></span>
<span class="line"><span style="color: #24292E">    cpu</span><span style="color: #D73A49">=</span><span style="color: #005CC5">1024</span><span style="color: #032F62">,</span><span style="color: #24292E"> </span><span style="color: #6A737D"># 1 CPU</span></span>
<span class="line"><span style="color: #24292E">    memory_limit_mib</span><span style="color: #D73A49">=</span><span style="color: #005CC5">4096</span><span style="color: #032F62">,</span><span style="color: #24292E"> </span><span style="color: #6A737D"># 4GB RAM</span></span>
<span class="line"><span style="color: #24292E">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6F42C1">container</span><span style="color: #24292E"> </span><span style="color: #032F62">=</span><span style="color: #24292E"> </span><span style="color: #032F62">taskdef.add_container</span><span style="color: #24292E">(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #6F42C1">&quot;EcsClusterQaBot-Container&quot;</span><span style="color: #6F42C1">,</span></span>
<span class="line"><span style="color: #24292E">    image</span><span style="color: #D73A49">=</span><span style="color: #032F62">ecs.ContainerImage.from_registry</span><span style="color: #24292E">(</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6F42C1">&quot;tomomano/qabot:latest&quot;</span></span>
<span class="line"><span style="color: #24292E">    )</span><span style="color: #032F62">,</span></span>
<span class="line"><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br></div></div><p><code>cluster =</code> の箇所で，空の ECS クラスターを定義している．</p>
<p>次に， <code>taskdef=ecs.FargateTaskDefinition</code> の箇所で， Fargate インスタンスを使ったタスクを定義しており，とくにここでは 1 CPU, 4GB RAM というマシンスペックを指定している． また，このようにして定義されたタスクは，デフォルトで 1 タスクにつき 1 インスタンスが使用される．</p>
<p>最後に， <code>container =</code> の箇所で，タスクの実行で使用する Docker image を定義している． ここでは， Docker Hub に置いてある image をダウンロードしてくるよう指定している．</p>
<p>このようにわずか数行のコードであるが，これだけで前述したような，タスクのスケジューリングなどが自動で実行される．</p>
<p>このコードで <code>cpu=1024</code> と指定されているのに注目してほしい． これは CPU ユニットと呼ばれる数で， 以下の換算表に従って仮想 CPU (virtual CPU; vCPU) が割り当てられる． 1024 が 1 CPU に相当する． 0.25 や 0.5 vCPU などの数字は，それぞれ実効的に 1/4, 1/2 の CPU 時間が割り当てられることを意味する． また， CPU ユニットによって使用できるメモリー量も変わってくる． たとえば， 1024 CPU ユニットを選択した場合は， 2 から 8 GB の範囲でのみメモリー量を指定することができる． 最新の情報は <a href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/AWS_Fargate.html" target="_blank" rel="noreferrer">公式ドキュメンテーション &quot;Amazon ECS on AWS Fargate&quot;</a> を参照のこと．</p>
<table><caption>CPU　ユニットと 指定可能なメモリー量の換算表</caption><colgroup><col style="width: 50%" /><col style="width: 50%" /></colgroup><tbody><tr class="odd"><td><p>CPU ユニット</p></td><td><p>メモリーの値</p></td></tr><tr class="even"><td><p>256 (.25 vCPU)</p></td><td><p>0.5 GB, 1 GB, 2 GB</p></td></tr><tr class="odd"><td><p>512 (.5 vCPU)</p></td><td><p>1 GB, 2 GB, 3 GB, 4 GB</p></td></tr><tr class="even"><td><p>1024 (1 vCPU)</p></td><td><p>2 GB, 3 GB, 4 GB, 5 GB, 6 GB, 7 GB, 8 GB</p></td></tr><tr class="odd"><td><p>2048 (2 vCPU)</p></td><td><p>Between 4 GB and 16 GB in 1-GB increments</p></td></tr><tr class="even"><td><p>4096 (4 vCPU)</p></td><td><p>Between 8 GB and 30 GB in 1-GB increments</p></td></tr></tbody></table>
<h2 id="スタックのデプロイ-1" tabindex="-1">スタックのデプロイ <a class="header-anchor" href="#スタックのデプロイ-1" aria-label="Permalink to &quot;スタックのデプロイ&quot;">&ZeroWidthSpace;</a></h2>
<p>スタックの中身が理解できたところで，早速スタックをデプロイしてみよう．</p>
<p>デプロイの手順は，これまでのハンズオンとほとんど共通である． SSH によるログインの必要がないので，むしろ単純なくらいである． ここでは，コマンドのみ列挙する (<code>#</code> で始まる行はコメントである)． それぞれの意味を忘れてしまった場合は，ハンズオン 1, 2 に戻って復習していただきたい． シークレットキーの設定も忘れずに (<a href="#aws_cli_install">AWS CLI のインストール</a>)．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390"># プロジェクトのディレクトリに移動</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cd</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">handson/qa-bot</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># venv を作成し，依存ライブラリのインストールを行う</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python3</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-m</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">venv</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.env</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">source</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.env/bin/activate</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">pip</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">install</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-r</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">requirements.txt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># デプロイを実行</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cdk</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">deploy</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D"># プロジェクトのディレクトリに移動</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cd</span><span style="color: #24292E"> </span><span style="color: #032F62">handson/qa-bot</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># venv を作成し，依存ライブラリのインストールを行う</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python3</span><span style="color: #24292E"> </span><span style="color: #005CC5">-m</span><span style="color: #24292E"> </span><span style="color: #032F62">venv</span><span style="color: #24292E"> </span><span style="color: #032F62">.env</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">source</span><span style="color: #24292E"> </span><span style="color: #032F62">.env/bin/activate</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">pip</span><span style="color: #24292E"> </span><span style="color: #032F62">install</span><span style="color: #24292E"> </span><span style="color: #005CC5">-r</span><span style="color: #24292E"> </span><span style="color: #032F62">requirements.txt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># デプロイを実行</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cdk</span><span style="color: #24292E"> </span><span style="color: #032F62">deploy</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br></div></div><p>デプロイのコマンドが無事に実行されれば， <a href="#handson_03_cdk_output">figure_title</a> のような出力が得られるはずである．</p>
<p><img src="./assets/handson-03/cdk_output.png" alt="CDKデプロイ実行後の出力"></p>
<p>AWS コンソールにログインして，デプロイされたスタックの中身を確認してみよう． コンソールから，ECS のページに行くと <a href="#handson_03_ecs_console">figure_title</a> のような画面が表示されるはずである． <code>EcsClusterQaBot-XXXX</code> という名前ついたクラスターを見つけよう．</p>
<p>Cluster というのが，先ほど説明したとおり，複数の仮想インスタンスを束ねる一つの単位である． <a href="#handson_03_ecs_console">figure_title</a> で， FARGATE という文字の下に <code>0 Running tasks</code>, <code>0 Pending tasks</code> と表示されていることを確認しよう． この時点では一つもタスクが走っていないので，数字はすべて 0 になっている．</p>
<p><img src="./assets/handson-03/ecs_console.png" alt="ECS コンソール画面"></p>
<p>続いて，この画面の左のメニューバーから <code>Task Definitions</code> という項目を見つけ，クリックしよう． 移動した先のページで <code>EcsClusterQaBotEcsClusterQaBotTaskDefXXXX</code> という項目が見つかるので，開く． 開いた先のページをスクロールすると <a href="#handson_03_ecs_task_definition">figure_title</a> に示したような情報が見つかるだろう． 使用する CPU ・メモリーの量や， Docker container の実行に関する設定などが，この Task Definition の画面から確認することができる．</p>
<p><img src="./assets/handson-03/ecs_task_definition.png" alt="Task definition の確認"></p>
<h2 id="タスクの実行" tabindex="-1">タスクの実行 <a class="header-anchor" href="#タスクの実行" aria-label="Permalink to &quot;タスクの実行&quot;">&ZeroWidthSpace;</a></h2>
<p>それでは，質問をデプロイしたクラウドに提出してみよう．</p>
<p>ECS にタスクを投入するのはやや複雑なので，タスクの投入を簡単にするプログラム (<code>run_task.py</code>) を用意した (<a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/qa-bot/run_task.py" target="_blank" rel="noreferrer">handson/qa-bot/run_task.py</a>)．</p>
<p>次のようなコマンドで，ECS クラスターに新しい質問を投入することができる．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">run_task.py</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ask</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;A giant peach was flowing in the river. She picked it up and brought it home. Later, a healthy baby was born from the peach. She named the baby Momotaro.&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;What is the name of the baby?&quot;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python</span><span style="color: #24292E"> </span><span style="color: #032F62">run_task.py</span><span style="color: #24292E"> </span><span style="color: #032F62">ask</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;A giant peach was flowing in the river. She picked it up and brought it home. Later, a healthy baby was born from the peach. She named the baby Momotaro.&quot;</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;What is the name of the baby?&quot;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p><code>run_task.py</code> を実行するには， コマンドラインで AWS の認証情報が設定されていることが前提である．</p>
<p>&quot;ask&quot; の引数に続き，文脈 (context) と質問 (question) を引数として渡している．</p>
<p>このコマンドを実行すると， &quot;Waiting for the task to finish…&quot; と出力が表示され，回答を得るまでしばらく待たされる． この間， AWS では ECS がタスクを受理し，新しい Fargate のインスタンスを起動し， Docker イメージをそのインスタンスに配置する，という一連の処理がなされている． AWS コンソールから，この一連の様子をモニタリングしてみよう．</p>
<p>先ほどの ECS コンソール画面にもどり，クラスターの名前をクリックすることで，クラスターの詳細画面を開く． 次に， &quot;Tasks&quot; という名前のタブがあるので，それを開く (<a href="#ecs_task_monitoring">figure_title</a>)． すると，実行中のタスクの一覧が表示されるだろう．</p>
<p><img src="./assets/handson-03/ecs_task_monitoring.png" alt="ECS のタスクの実行状況をモニタリング"></p>
<p><a href="#ecs_task_monitoring">figure_title</a> で見て取れるように， &quot;Last status = Pending&quot; となっていることから，この時点では，タスクを実行する準備をしている段階である，ということがわかる． Fargate のインスタンスを起動し， Docker image を配置するまでおよそ 1-2 分の時間がかかる．</p>
<p>しばらく待つうちに， Status が &quot;RUNNING&quot; に遷移し，計算が始まる． 計算が終わると， Status は &quot;STOPPED&quot; に遷移し， ECS によって Fargate インスタンスは自動的にシャットダウンされる．</p>
<p><a href="#ecs_task_monitoring">figure_title</a> の画面から， &quot;Task&quot; の列にあるタスク ID クリックすることで，タスクの詳細画面を開いてみよう (<a href="#ecs_task_detail">figure_title</a>)． &quot;Last status&quot;, &quot;Platform version&quot; など，タスクの情報が表示されている． また， &quot;Logs&quot; のタブを開くことで，コンテナの吐き出した実行ログを閲覧することができる．</p>
<p><img src="./assets/handson-03/ecs_task_detail.png" alt="質問タスクの実行結果"></p>
<p>さて， <code>run_task.py</code> を実行したコマンドラインに戻ってきてみると， <a href="#ask_question_output">figure_title</a> のような出力が得られているはずである． &quot;Momotaro&quot; という正しい回答が返ってきている！</p>
<p><img src="./assets/handson-03/ask_question_output.png" alt="質問タスクの実行結果"></p>
<h2 id="タスクの同時実行" tabindex="-1">タスクの同時実行 <a class="header-anchor" href="#タスクの同時実行" aria-label="Permalink to &quot;タスクの同時実行&quot;">&ZeroWidthSpace;</a></h2>
<p>さて，先ほどはたった一つの質問を投入したわけだが，今回設計したアプリケーションは， ECS と Fargate を使うことで同時にたくさんの質問を処理することができる． 実際に，たくさんの質問を一度に投入してみよう． <code>run_task.py</code> に <code>ask_many</code> というオプションを付けることで，複数の質問を一度に送信できる． 質問の内容は <a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/qa-bot/problems.json" target="_blank" rel="noreferrer">handson/qa-bot/problems.json</a> に定義されている．</p>
<p>次のようなコマンドを実行しよう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">run_task.py</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ask_many</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python</span><span style="color: #24292E"> </span><span style="color: #032F62">run_task.py</span><span style="color: #24292E"> </span><span style="color: #032F62">ask_many</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>このコマンドを実行した後で，先ほどの ECS コンソールに行き，タスクの一覧を見てみよう (<a href="#ecs_many_tasks">figure_title</a>)． 複数の Fargate インスタンスが起動され，タスクが並列に実行されているのがわかる．</p>
<p><img src="./assets/handson-03/ecs_many_tasks.png" alt="複数の質問タスクを同時に投入する"></p>
<p>すべてのタスクのステータスが &quot;STOPPED&quot; になったことを確認した上で，質問への回答を取得しよう． それには，次のコマンドを実行する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">run_task.py</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">list_answers</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python</span><span style="color: #24292E"> </span><span style="color: #032F62">run_task.py</span><span style="color: #24292E"> </span><span style="color: #032F62">list_answers</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>結果として， <a href="#ask_many_output">figure_title</a> のような出力が得られるだろう． 複雑な文章問題に対し，高い正答率で回答できていることがわかるだろう．</p>
<p><img src="./assets/handson-03/ask_many_output.png" alt=" の実行結果"></p>
<p>おめでとう！ ここまでついてこれた読者はとても初歩的ながらも，深層学習による言語モデルを使って自動で質問への回答を生成するシステムを創り上げることができた！ それも，数百の質問にも同時に対応できるような，とても高いスケーラビリティーをもったシステムである！ 今回は GUI (Graphical User Interface) を用意することはしなかったが，このシステムに簡単な GUI を追加すればなかなか立派なウェブサービスとして運用できるだろう．</p>
<p><code>run_task.py</code> で質問を投入し続けると，回答を記録しているデータベースにどんどんエントリーが溜まっていく． これらのエントリーをすべて消去するには，次のコマンドを使う．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">run_task.py</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">clear</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python</span><span style="color: #24292E"> </span><span style="color: #032F62">run_task.py</span><span style="color: #24292E"> </span><span style="color: #032F62">clear</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><h2 id="スタックの削除-1" tabindex="-1">スタックの削除 <a class="header-anchor" href="#スタックの削除-1" aria-label="Permalink to &quot;スタックの削除&quot;">&ZeroWidthSpace;</a></h2>
<p>これにて，今回のハンズオンは終了である． 最後にスタックを削除しよう．</p>
<p>スタックを削除するには，前回までと同様に， AWS コンソールにログインし CloudFormation の画面から DELETE ボタンをクリックするか，コマンドラインからコマンドを実行する． コマンドラインから行う場合は，次のコマンドを使用する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cdk</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">destroy</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cdk</span><span style="color: #24292E"> </span><span style="color: #032F62">destroy</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><h1 id="hands-on-4-aws-batch-を使って機械学習のハイパーパラメータサーチを並列化する" tabindex="-1">Hands-on #4: AWS Batch を使って機械学習のハイパーパラメータサーチを並列化する <a class="header-anchor" href="#hands-on-4-aws-batch-を使って機械学習のハイパーパラメータサーチを並列化する" aria-label="Permalink to &quot;Hands-on \#4: AWS Batch を使って機械学習のハイパーパラメータサーチを並列化する&quot;">&ZeroWidthSpace;</a></h1>
<p>ハンズオン第三回では， ECS と Fargate を使って自動質問回答システムを構築した． シンプルながらも，複数の質問が送られた場合には並列にジョブが実行され，ユーザーに答えが返されるシステムを作ることができた． ここでは，すでに学習済みの言語モデルを用いてアプリケーションを構築した． しかし，一般的に言って，機械学習のワークフローでは自分で作ったモデルを訓練することが最初のステップにあるはずである． そこで，ハンズオン第四回では，クラウドを用いて機械学習の訓練を並列化・高速化することを考える．</p>
<p>本ハンズオンでは深層学習におけるハイパーパラメータ最適化を取り上げる． ハイパーパラメータとは，勾配降下法によって最適化されるニューラルネットのパラメータの外にあるパラメータのことであり，具体的にはモデルの層の幅・深さなどネットワークのアーキテクチャに関わるもの，学習率やモメンタムなどパラメータの更新則に関わるものなどが含まる． 深層学習においてハイパーパラメータの調整はとても重要なタスクである． しかしながら，ハイパーパラメータを調整するには，少しずつ条件を変えながら何度もニューラルネットを学習させる必要があり，多くの計算時間がかかる． 研究・開発においては，スループットよくたくさんのモデルの可能性を探索することが生産性を決める重要なファクターであり，ハイパーパラメータ探索を高速に解くという問題は極めて関心が高い． 本ハンズオンでは，クラウドの強力な計算リソースを利用して並列的にニューラルネットの訓練を実行することで，この問題を解く方法を学んでいこう．</p>
<h2 id="auto-scaling-groups-asg" tabindex="-1">Auto scaling groups (ASG) <a class="header-anchor" href="#auto-scaling-groups-asg" aria-label="Permalink to &quot;Auto scaling groups (ASG)&quot;">&ZeroWidthSpace;</a></h2>
<p>ハンズオンに入っていく前に， <strong>Auto scaling groups (ASG)</strong> とよばれる EC2 の概念を知っておく必要がある．</p>
<p>ECS の概要を示した <a href="#ecs_overview">figure_title</a> を振り返って見てほしい． 前章 (<a href="#sec_fargate_qabot">Hands-on #3: AWS で自動質問回答ボットを走らせる</a>) でも説明したが， ECS のクラスターで計算を担う実体としては EC2 と Fargate を指定することができる． Fargate については前章で記述した． Fargate を用いると，自在にスケールする計算環境をとても簡単な設定で構築することができた． しかし， GPU を利用することができないなど，いくつかの制約があった． EC2 を使用した計算環境を指定することで，プログラミングの複雑度は増すが， GPU やその他のより高度かつ複雑な設定を伴ったクラスターを構築することができる．</p>
<p>EC2 クラスターには <strong>ASG</strong> と呼ばれるサービスが配置される． ASG は複数の EC2 インスタンスをロジカルな単位でグループ化することでクラスターを構成する． ASG はクラスター内に新しいインスタンスを起動する，あるいは不要になったインスタンスを停止するなどのスケーリングを担う． ASG で重要な概念として， <strong>desired capacity</strong>, <strong>minimum capacity</strong>, <strong>maximum capacity</strong> というパラメータがある． minimum capacity， maximum capacity は，それぞれクラスター内に配置できるインスタンスの数の最小値・最大値を指定するパラメータである． 前者は，クラスターに負荷がかかっていない場合でもアイドリング状態にあるインスタンスを維持することで，急に負荷が増大した時などのバッファーとして作用することができる． 後者は，負荷が急に増えたときに，過剰な数のインスタンスが起動する事態を防ぎ，経済的なコストの上限を定める役割を果たす．</p>
<p>desired capacity が，その時々でシステムが要求するインスタンスの数を指定する． desired capacity は，例えば 24 時間のリズムに合わせてインスタンスの数を増減させる (昼は多く夜は少なくなど) などの決まったスケジュールに基づいた設定を適用することができる． あるいはクラスター全体にかかっている負荷に応じて， desired capacity を動的に制御することも可能である． どのような基準でクラスターのスケーリングを行うかを定めるルールのことを，<strong>スケーリングポリシー</strong>とよぶ． たとえば，クラスター全体の稼働率 (負荷) を常に 80% に維持する，などのスケーリングポリシーが想定できる． この場合，クラスター全体の負荷が 80%を下回ったときにはクラスターからインスタンスが削除され，80%を超える (あるいは超えると予測される) 場合はインスタンスを追加する，という操作が ASG によって自動的に行われる．</p>
<p>上記のようなパラメータを検討し，ユーザーは ASG を作成する． ASG を作成したのち， ECS との連携をプログラムしてあげることで， ECS を介して ASG による EC2 クラスターにタスクを投入することが可能になる．</p>
<h2 id="aws-batch" tabindex="-1">AWS Batch <a class="header-anchor" href="#aws-batch" aria-label="Permalink to &quot;AWS Batch&quot;">&ZeroWidthSpace;</a></h2>
<p><img src="./assets/aws_logos/Batch.png" alt="AWS Batch のアイコン"></p>
<p>先に説明したように， ECS と ASG を組み合わせることで，所望の計算クラスターを構築することが可能である． しかしながら， ECS と ASG にはかなり込み入った設定が必要であり，初心者にとっても経験者にとってもなかなか面倒なプログラミングが要求される． そこで， ECS と ASG によるクラスターの設計を自動化してくれるサービスが提供されている． それが <strong>AWS Batch</strong> である．</p>
<p>AWS Batch はその名のとおりバッチ (Batch) 化されたジョブ (入力データだけが異なる独立した演算が繰り返し実行されること) を想定している． 多くの科学計算や機械学習がバッチ計算に当てはまる． たとえば，初期値のパラメータを変えて複数のシミュレーションを走らせる，といったケースだ． AWS Batch を用いることの利点は，クラスターのスケーリングやジョブの割り振りはすべて自動で実行され， ユーザーはクラウドの舞台裏の詳細を気にすることなく，大量のジョブを投入できるシステムが手に入る点である． が，知識として背後では ECS/ASG/EC2 の三つ巴が協調して動作しているという点は知っておいてほしい．</p>
<p>AWS Batch では，ジョブの投入・管理をスムーズに行うため，次のような概念が定義されている (<a href="#fig_batch_concept">figure_title</a>)． まず， <strong>ジョブ (Job)</strong> というのが，AWS Batch によって実行される一つの計算の単位である． <strong>Job definitions</strong> とはジョブの内容を定義するものであり，これには実行されるべき Docker のイメージのアドレスや，割り当てる CPU・RAM の容量，環境変数などの設定が含まれる． Job definition に基づいて個々のジョブが実行される． ジョブが実行されると，ジョブは <strong>Job queues</strong> に入る． Job queues とは，実行待ち状態にあるジョブの列のことであり，時間的に最も先頭に投入されたジョブが最初に実行される． また，複数の queue を配置し， queue ごとに priority (優先度) を設定することが可能であり， priority の高い queue に溜まったジョブが優先的に実行される (筆者はこれをディズニーランドの&quot;ファストパス&quot;を連想して捉えている)． <strong>Compute environment</strong> とは，先述したクラスターとほぼ同義の概念であり，計算が実行される場所 (EC2 や Fargate からなるクラスター) を指す． Compute environment には，使用する EC2 のインスタンスタイプや同時に起動するインスタンス数の上限などの簡易なスケーリングポリシーが指定されている． Job queues は Compute environment の空き状況を監視しており， それに応じてジョブを Compute environment に投下する．</p>
<p>以上が AWS Batch を使用するうえで理解しておかなければならない概念であるが，くどくど言葉で説明してもなかなかピンとこないだろう． ここからは，実際に自分で手を動かしながら学んでいこう．</p>
<p><img src="./assets/aws_batch/batch_concepts.png" alt="AWS Batch の主要な概念"></p>
<p><strong>EC2 or Fargate?</strong></p>
<p>ECS でクラスターを構成する際，計算を実行する場として EC2 と Fargate の二つの選択肢があることを説明した． それぞれ長所と短所を抱えているのだが，どのような場合にどちらを使うべきだろうか？ それを検討するため，まずは <a href="#tab:ec2_vs_fargate">table_title</a> を見てみよう． これは EC2 と Fargate の特徴をまとめたものである． 説明の都合上，大幅な粗視化が行われている点は留意していただきたい．</p>
<table><caption>EC2 vs Fargate</caption><colgroup><col style="width: 33%" /><col style="width: 33%" /><col style="width: 33%" /></colgroup><thead><tr class="header"><th></th><th>EC2</th><th>Fargate</th></tr></thead><tbody><tr class="odd"><td><p>Compute capacity</p></td><td><p>Medium to large</p></td><td><p>Small to medium</p></td></tr><tr class="even"><td><p>GPU</p></td><td><p>Yes</p></td><td><p>No</p></td></tr><tr class="odd"><td><p>Launch speed</p></td><td><p>Slow</p></td><td><p>Fast</p></td></tr><tr class="even"><td><p>Task placement flexibility</p></td><td><p>Low</p></td><td><p>High</p></td></tr><tr class="odd"><td><p>Programming complexity</p></td><td><p>High</p></td><td><p>Low</p></td></tr></tbody></table>
<p>これまでに見てきたように， EC2 は最大の CPU 数・メモリーサイズが大きかったり， GPU を利用できたりするなど，単一のインスタンスでの計算能力は高い． 対して， Fargate は単一インスタンスの最大 CPU 数は 4 コアが上限である． その一方で，インスタンスの起動に要する時間は Fargate のほうが圧倒的に早く，より俊敏にクラスターのスケーリングを行うことができる． また，タスクをクラスターに投入する際のフレキシビリティも Fargate のほうが高い． フレキシビリティというのは，例えば一つのインスタンスで 2 つ以上のコンテナを走らせる，などの状況である． 単位 CPU あたりで処理されるタスクの数を最大化する際には，このような設計がしばしば採用される． プログラミングの複雑さという観点からは， Fargate のほうが一般的にシンプルな実装になる．</p>
<p>このように， EC2 と Fargate は互いに相補的な特性を有しており，アプリケーションによって最適な計算環境は検討される必要がある． また，EC2 と Fargate を両方用いたハイブリッドクラスターというのも定義可能であり，そのような選択肢もしばしば用いられる．</p>
<h2 id="準備-3" tabindex="-1">準備 <a class="header-anchor" href="#準備-3" aria-label="Permalink to &quot;準備&quot;">&ZeroWidthSpace;</a></h2>
<p>ハンズオンのソースコードは GitHub の <a href="https://github.com/andatoshiki/toshiki-notebooktree/main/handson/aws-batch" target="_blank" rel="noreferrer">handson/aws-batch</a> にある．</p>
<p>本ハンズオンの実行には，第一回ハンズオンで説明した準備 (<a href="#handson_01_prep">準備</a>) が整っていることを前提とする． また， Docker が自身のローカルマシンにインストール済みであることも必要である．</p>
<p>このハンズオンは， <code>g4dn.xlarge</code> タイプの EC2 インスタンスを使うので，アメリカ東部 (<code>us-east-1</code>) リージョンでは 0.526 $/hour のコストが発生する． 東京 (<code>ap-northeast-1</code>) を選択した場合は 0.71 $/hour のコストが発生する．</p>
<p><a href="#sec:jupyter_and_deep_learning_setup">準備</a> でも注意したが，このハンズオンを始める前に G タイプインスタンスの起動上限を AWS コンソールの EC2 管理画面から確認しよう． もし上限が 0 になっていた場合は，上限緩和の申請を行う必要がある． <a href="#sec:aws_batch_code">アプリケーションの説明</a> にも関連した情報を記載しているので，併せて参照されたい．</p>
<h2 id="mnist-手書き文字認識-再訪" tabindex="-1">MNIST 手書き文字認識 (再訪) <a class="header-anchor" href="#mnist-手書き文字認識-再訪" aria-label="Permalink to &quot;MNIST 手書き文字認識 (再訪)&quot;">&ZeroWidthSpace;</a></h2>
<p>今回のハンズオンでは，機械学習のハイパーパラメータ調整を取り上げると冒頭で述べた． その最もシンプルな例題として， <a href="#sec_mnist_using_jupyter">実践ディープラーニング! MNIST 手書き数字認識タスク</a> で扱った MNIST 手書き文字認識の問題を再度取り上げよう． <a href="#sec_mnist_using_jupyter">実践ディープラーニング! MNIST 手書き数字認識タスク</a> では，適当にチョイスしたハイパーパラメータを用いてモデルの訓練を行った． ここで使用したプログラムのハイパーパラメータとしては，確率的勾配降下法 (SGD) における学習率やモメンタムが含まれる． コードでいうと，次の行が該当する．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">optimizer </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> optim.SGD(model.parameters(), </span><span style="color: #F69D50">lr</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">0.01</span><span style="color: #ADBAC7">, </span><span style="color: #F69D50">momentum</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">0.5</span><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">optimizer </span><span style="color: #D73A49">=</span><span style="color: #24292E"> optim.SGD(model.parameters(), </span><span style="color: #E36209">lr</span><span style="color: #D73A49">=</span><span style="color: #005CC5">0.01</span><span style="color: #24292E">, </span><span style="color: #E36209">momentum</span><span style="color: #D73A49">=</span><span style="color: #005CC5">0.5</span><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>ここで使用された 学習率 (<code>lr=0.01</code>) やモメンタム (<code>momentum=0.5</code>) は恣意的に選択された値であり，これがベストな数値であるのかはわからない． たまたまこのチョイスが最適であるかもしれないし，もっと高い精度を出すハイパーパラメータの組が存在するかもしれない． この問題に答えるため，ハイパーパラメータサーチを行おう． 今回は，最もシンプルなアプローチとして，<strong>グリッドサーチ</strong>によるハイパーパラメータサーチを行おう．</p>
<p>機械学習のハイパーパラメータの最適化には大きく３つのアプローチが挙げられる． グリッドサーチ，ランダムサーチ，そしてベイズ最適化による方法である．</p>
<p>グリッドサーチとは，ハイパーパラメータの組をある範囲の中で可能な組み合わせをすべて計算し，最適なパラメータの組を見出す方法である． 最もシンプルかつ確実な方法であるが，すべての組み合わせの可能性を愚直に計算するので計算コストが大きい．</p>
<p>ランダムサーチ法とは，ハイパーパラメータの組をある範囲の中でランダムに抽出し，大量に試行されたランダムな組の中から最適なパラメータの組を見出す方法である． すべての可能性を網羅的に探索できるわけではないが，調整すべきパラメータの数が多数ある場合に，グリッドサーチよりも効率的に広い探索空間をカバーすることができる．</p>
<p>ベイズ最適化を用いた方法では，過去の探索結果から次にどの組み合わせを探索すべきかという指標を計算し，次に探索するパラメータを決定する． これにより，理論的にはグリッドサーチやランダムサーチ法よりも少ない試行回数で最適なパラメータにたどり着くことができる．</p>
<p>並列化の観点でいうと，グリッドサーチとランダムサーチは各ハイパーパラメータの組の計算は独立に実行することができるため並列化が容易である． このように独立したジョブとして分割・並列化可能な問題を Embarrassingly parallel な問題とよぶ (直訳すると&quot;恥ずかしいほど並列化可能な問題&quot;，ということになる)． Embarrassingly parallel な問題はクラウドの強力な計算リソースを用いることで，非常なシンプルな実装で解くことができる． この章ではこのようなタイプの並列計算を取り上げる．</p>
<p>一方，ベイズ最適化による方法は，過去の結果をもとに次の探索が決定されるので，並列化はそれほど単純ではない． 最近では <a href="https://optuna.org/" target="_blank" rel="noreferrer">optuna</a> などのハイパーパラメータ探索のためのライブラリが発達しており，ベイズ最適化の数理的な処理を自動で実行してくれるので便利である． これらのライブラリを使うと，もし一台のコンピュータ (ノード) の中に複数の GPU が存在する場合は，並列に計算を実行することができる． しかしながら，一台のノードにとどまらず，複数のノードをまたいだ並列化は，高度なプログラミングテクニックが必要とされるだけでなく，ノード間の接続様式などクラウドのアーキテクチャにも深く依存するものである． 本書ではここまで高度なクラウドの使用方法には立ち入らない．</p>
<p>まずは，本ハンズオンで使用する Docker イメージをローカルで実行してみよう．</p>
<p>Docker イメージのソースコードは <a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/aws-batch/docker" target="_blank" rel="noreferrer">handson/aws-batch/docker</a> にある． 基本的に <a href="#sec_mnist_using_jupyter">実践ディープラーニング! MNIST 手書き数字認識タスク</a> のハンズオンを元にし，本ハンズオン専用の軽微な変更が施してある． 興味のある読者はソースコードも含めて読んでいただきたい．</p>
<p>練習として，この Docker イメージを手元でビルドするところからはじめてみよう． <code>Dockerfile</code> が保存されているディレクトリに移動し， <code>mymnist</code> という名前 (Tag) をつけてビルドを実行する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cd</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">handson/aws-batch/docker</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">docker</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">build</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-t</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">mymnist</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cd</span><span style="color: #24292E"> </span><span style="color: #032F62">handson/aws-batch/docker</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">docker</span><span style="color: #24292E"> </span><span style="color: #032F62">build</span><span style="color: #24292E"> </span><span style="color: #005CC5">-t</span><span style="color: #24292E"> </span><span style="color: #032F62">mymnist</span><span style="color: #24292E"> </span><span style="color: #032F62">.</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p><code>docker build</code> でエラーが出たときは次の可能性を疑ってほしい． ビルドの中で， MNIST の画像データセットを <a href="http://yann.lecun.com/exdb/mnist/" target="_blank" rel="noreferrer">http://yann.lecun.com/exdb/mnist/</a> からダウンロードするのだが，ダウンロード先のサーバーがしばしばダウンしている． 世界中の機械学習ユーザーがアクセスするので，これはしばしば発生するようである． サーバーがダウンしているとビルドも失敗してしまう． エラーメッセージにそれらしい文言が含まれていたら，この可能性を疑おう．</p>
<p>手元でビルドするかわりに， Docker Hub から pull することも可能である． その場合は次のコマンドを実行する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">docker</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">pull</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">tomomano/mymnist:latest</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">docker</span><span style="color: #24292E"> </span><span style="color: #032F62">pull</span><span style="color: #24292E"> </span><span style="color: #032F62">tomomano/mymnist:latest</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>イメージの準備ができたら，次のコマンドでコンテナを起動し， MNIST の学習を実行する．．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">docker</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">run</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">mymnist</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--lr</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0.1</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--momentum</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0.5</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--epochs</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">10</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">docker</span><span style="color: #24292E"> </span><span style="color: #032F62">run</span><span style="color: #24292E"> </span><span style="color: #032F62">mymnist</span><span style="color: #24292E"> </span><span style="color: #005CC5">--lr</span><span style="color: #24292E"> </span><span style="color: #005CC5">0.1</span><span style="color: #24292E"> </span><span style="color: #005CC5">--momentum</span><span style="color: #24292E"> </span><span style="color: #005CC5">0.5</span><span style="color: #24292E"> </span><span style="color: #005CC5">--epochs</span><span style="color: #24292E"> </span><span style="color: #005CC5">10</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>このコマンドを実行すると，指定したハイパーパラメータ (<code>--lr</code> で与えられる学習率と <code>--momentum</code> で与えられるモメンタム) を使ってニューラルネットの最適化が始まる． 学習を行う最大のエポック数は <code>--epochs</code> パラメータで指定する． <a href="#sec_jupyter_and_deep_learning">Hands-on #2: AWS でディープラーニングを実践</a> のハンズオンで見たような， Loss の低下がコマンドライン上に出力されるだろう (<a href="#fig_mnist_log_output">figure_title</a>)．</p>
<p><img src="./assets/aws_batch/mnist_log_output.png" alt="Docker を実行した際の出力"></p>
<p>上に示したコマンドを使うと，計算は CPU を使って実行される． もし，ローカルの計算機に GPU が備わっており， <a href="https://github.com/NVIDIA/nvidia-docker" target="_blank" rel="noreferrer">nvidia-docker</a> の設定が済んでいるならば， 次のコマンドにより GPU を使って計算を実行できる．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">docker</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">run</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--gpus</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">all</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">mymnist</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--lr</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0.1</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--momentum</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0.5</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--epochs</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">10</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">docker</span><span style="color: #24292E"> </span><span style="color: #032F62">run</span><span style="color: #24292E"> </span><span style="color: #005CC5">--gpus</span><span style="color: #24292E"> </span><span style="color: #032F62">all</span><span style="color: #24292E"> </span><span style="color: #032F62">mymnist</span><span style="color: #24292E"> </span><span style="color: #005CC5">--lr</span><span style="color: #24292E"> </span><span style="color: #005CC5">0.1</span><span style="color: #24292E"> </span><span style="color: #005CC5">--momentum</span><span style="color: #24292E"> </span><span style="color: #005CC5">0.5</span><span style="color: #24292E"> </span><span style="color: #005CC5">--epochs</span><span style="color: #24292E"> </span><span style="color: #005CC5">10</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>このコマンドでは，<code>--gpus all</code> というパラメータが加わった．</p>
<p>CPU/GPU どちらで実行した場合でも，エポックを重ねるにつれて訓練データ (Train データ) の Loss は単調に減少していくのが見て取れるだろう． 一方，<strong>検証データ (Validation データ) の Loss および Accuracy は，ある程度まで減少した後，それ以上性能が向上しない</strong>ことに気がつくだろう． これを実際にプロットしてみると <a href="#fig_loss_epoch_profile">figure_title</a> のようになるはずである．</p>
<p><img src="./assets/aws_batch/loss_epoch_profile.png" alt="(左) Train/Validation データそれぞれの Loss のエポックごとの変化． (右) Validation データの Accuracy のエポックごとの変化"></p>
<p>これは<strong>オーバーフィッティング</strong>とよばれる現象で，ニューラルネットが訓練データに過度に最適化され，訓練データの外のデータに対しての精度 (汎化性能) が向上していないことを示している． このような場合の対処法として， <strong>Early stopping</strong> とよばれるテクニックが知られている． Early stopping とは，検証データの Loss を追跡し，それが減少から増加に転じるエポックで学習をうち止め，そのエポックでのウェイトパラメータを採用する，というものである． 本ハンズオンでも， Early stopping によって訓練の終了を判断し，モデルの性能評価を行っていく．</p>
<p>MNIST 手書き文字データセットでは，訓練データとして 60,000 枚，テストデータとして 10,000 枚の画像が与えられている． 本ハンズオンで使用するコードでは，訓練データのうち 80% の 48,000 枚を訓練データとして使用し，残り 20% の 12,000 枚を検証データとして用いている． 詳しくはソースコードを参照のこと．</p>
<h2 id="アプリケーションの説明-3" tabindex="-1">アプリケーションの説明 <a class="header-anchor" href="#アプリケーションの説明-3" aria-label="Permalink to &quot;アプリケーションの説明&quot;">&ZeroWidthSpace;</a></h2>
<p>このハンズオンで作成するアプリケーションの概要を <a href="#fig_batch_architecture">figure_title</a> に示す．</p>
<p><img src="./assets/aws_batch/architecture.png" alt="アプリケーションのアーキテクチャ"></p>
<p>簡単にまとめると，次のような設計である．</p>
<ul>
<li>
<p>クライアントは，あるハイパーパラメータの組を指定して Batch にジョブを提出する</p>
</li>
<li>
<p>Batch はジョブを受け取ると， EC2 からなるクラスターで計算を実行する</p>
</li>
<li>
<p>クラスター内では <code>g4dn.xlarge</code> インスタンスが起動する</p>
</li>
<li>
<p>Docker イメージは， AWS 内に用意された ECR (Elastic Container Registry) から取得される</p>
</li>
<li>
<p>複数のジョブが投下された場合は，その数だけのインスタンスが起動し並列に実行される</p>
</li>
<li>
<p>各ジョブによる計算の結果は S3 に保存される</p>
</li>
<li>
<p>最後にクライアントは S3 から結果をダウンロードし，最適なハイパーパラメータの組を決定する</p>
</li>
</ul>
<p>それでは，プログラムのソースコードを見てみよう (<a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/aws-batch/app.py" target="_blank" rel="noreferrer">handson/aws-batch/app.py</a>)．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">class</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50">SimpleBatch</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">core</span><span style="color: #ADBAC7">.</span><span style="color: #6CB6FF">Stack</span><span style="color: #ADBAC7">):</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">def</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">__init__</span><span style="color: #ADBAC7">(self, scope: core.App, name: </span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">, </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">kwargs) -&gt; </span><span style="color: #6CB6FF">None</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #6CB6FF">super</span><span style="color: #ADBAC7">().</span><span style="color: #6CB6FF">__init__</span><span style="color: #ADBAC7">(scope, name, </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">kwargs)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        bucket </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> s3.Bucket(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;bucket&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">removal_policy</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">core.RemovalPolicy.</span><span style="color: #6CB6FF">DESTROY</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">auto_delete_objects</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">True</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        vpc </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ec2.Vpc(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;vpc&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #768390"># other parameters...</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        managed_env </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> batch.ComputeEnvironment(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;managed-env&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">compute_resources</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">batch.ComputeResources(</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">vpc</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">vpc,</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">allocation_strategy</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">batch.AllocationStrategy.</span><span style="color: #6CB6FF">BEST_FIT</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">desiredv_cpus</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">maxv_cpus</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">64</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">minv_cpus</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">instance_types</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">[</span></span>
<span class="line"><span style="color: #ADBAC7">                    ec2.InstanceType(</span><span style="color: #96D0FF">&quot;g4dn.xlarge&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">                ],</span></span>
<span class="line"><span style="color: #ADBAC7">            ),</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">managed</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">True</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">compute_environment_name</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">.stack_name </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;compute-env&quot;</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        job_queue </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> batch.JobQueue(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;job-queue&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">compute_environments</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">[</span></span>
<span class="line"><span style="color: #ADBAC7">                batch.JobQueueComputeEnvironment(</span></span>
<span class="line"><span style="color: #ADBAC7">                    </span><span style="color: #F69D50">compute_environment</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">managed_env,</span></span>
<span class="line"><span style="color: #ADBAC7">                    </span><span style="color: #F69D50">order</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">100</span></span>
<span class="line"><span style="color: #ADBAC7">                )</span></span>
<span class="line"><span style="color: #ADBAC7">            ],</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">job_queue_name</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">.stack_name </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;job-queue&quot;</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        job_role </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> iam.Role(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;job-role&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">assumed_by</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">iam.CompositePrincipal(</span></span>
<span class="line"><span style="color: #ADBAC7">                iam.ServicePrincipal(</span><span style="color: #96D0FF">&quot;ecs-tasks.amazonaws.com&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">            )</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390"># allow read and write access to S3 bucket</span></span>
<span class="line"><span style="color: #ADBAC7">        bucket.grant_read_write(job_role)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        repo </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ecr.Repository(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;repository&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">removal_policy</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">core.RemovalPolicy.</span><span style="color: #6CB6FF">DESTROY</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        job_def </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> batch.JobDefinition(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;job-definition&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">container</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">batch.JobDefinitionContainer(</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">image</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ecs.ContainerImage.from_ecr_repository(repo),</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">command</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">[</span><span style="color: #96D0FF">&quot;python3&quot;</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;main.py&quot;</span><span style="color: #ADBAC7">],</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">vcpus</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">4</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">gpu_count</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">memory_limit_mib</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">12000</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">job_role</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">job_role,</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">environment</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">{</span></span>
<span class="line"><span style="color: #ADBAC7">                    </span><span style="color: #96D0FF">&quot;BUCKET_NAME&quot;</span><span style="color: #ADBAC7">: bucket.bucket_name</span></span>
<span class="line"><span style="color: #ADBAC7">                }</span></span>
<span class="line"><span style="color: #ADBAC7">            ),</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">job_definition_name</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">.stack_name </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;job-definition&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">timeout</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">core.Duration.hours(</span><span style="color: #6CB6FF">2</span><span style="color: #ADBAC7">),</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">class</span><span style="color: #24292E"> </span><span style="color: #6F42C1">SimpleBatch</span><span style="color: #24292E">(</span><span style="color: #6F42C1">core</span><span style="color: #24292E">.</span><span style="color: #6F42C1">Stack</span><span style="color: #24292E">):</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">def</span><span style="color: #24292E"> </span><span style="color: #005CC5">__init__</span><span style="color: #24292E">(self, scope: core.App, name: </span><span style="color: #005CC5">str</span><span style="color: #24292E">, </span><span style="color: #D73A49">**</span><span style="color: #24292E">kwargs) -&gt; </span><span style="color: #005CC5">None</span><span style="color: #24292E">:</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #005CC5">super</span><span style="color: #24292E">().</span><span style="color: #005CC5">__init__</span><span style="color: #24292E">(scope, name, </span><span style="color: #D73A49">**</span><span style="color: #24292E">kwargs)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        bucket </span><span style="color: #D73A49">=</span><span style="color: #24292E"> s3.Bucket(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;bucket&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">removal_policy</span><span style="color: #D73A49">=</span><span style="color: #24292E">core.RemovalPolicy.</span><span style="color: #005CC5">DESTROY</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">auto_delete_objects</span><span style="color: #D73A49">=</span><span style="color: #005CC5">True</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        vpc </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ec2.Vpc(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;vpc&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #6A737D"># other parameters...</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        managed_env </span><span style="color: #D73A49">=</span><span style="color: #24292E"> batch.ComputeEnvironment(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;managed-env&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">compute_resources</span><span style="color: #D73A49">=</span><span style="color: #24292E">batch.ComputeResources(</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">vpc</span><span style="color: #D73A49">=</span><span style="color: #24292E">vpc,</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">allocation_strategy</span><span style="color: #D73A49">=</span><span style="color: #24292E">batch.AllocationStrategy.</span><span style="color: #005CC5">BEST_FIT</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">desiredv_cpus</span><span style="color: #D73A49">=</span><span style="color: #005CC5">0</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">maxv_cpus</span><span style="color: #D73A49">=</span><span style="color: #005CC5">64</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">minv_cpus</span><span style="color: #D73A49">=</span><span style="color: #005CC5">0</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">instance_types</span><span style="color: #D73A49">=</span><span style="color: #24292E">[</span></span>
<span class="line"><span style="color: #24292E">                    ec2.InstanceType(</span><span style="color: #032F62">&quot;g4dn.xlarge&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">                ],</span></span>
<span class="line"><span style="color: #24292E">            ),</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">managed</span><span style="color: #D73A49">=</span><span style="color: #005CC5">True</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">compute_environment_name</span><span style="color: #D73A49">=</span><span style="color: #005CC5">self</span><span style="color: #24292E">.stack_name </span><span style="color: #D73A49">+</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;compute-env&quot;</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        job_queue </span><span style="color: #D73A49">=</span><span style="color: #24292E"> batch.JobQueue(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;job-queue&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">compute_environments</span><span style="color: #D73A49">=</span><span style="color: #24292E">[</span></span>
<span class="line"><span style="color: #24292E">                batch.JobQueueComputeEnvironment(</span></span>
<span class="line"><span style="color: #24292E">                    </span><span style="color: #E36209">compute_environment</span><span style="color: #D73A49">=</span><span style="color: #24292E">managed_env,</span></span>
<span class="line"><span style="color: #24292E">                    </span><span style="color: #E36209">order</span><span style="color: #D73A49">=</span><span style="color: #005CC5">100</span></span>
<span class="line"><span style="color: #24292E">                )</span></span>
<span class="line"><span style="color: #24292E">            ],</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">job_queue_name</span><span style="color: #D73A49">=</span><span style="color: #005CC5">self</span><span style="color: #24292E">.stack_name </span><span style="color: #D73A49">+</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;job-queue&quot;</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        job_role </span><span style="color: #D73A49">=</span><span style="color: #24292E"> iam.Role(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;job-role&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">assumed_by</span><span style="color: #D73A49">=</span><span style="color: #24292E">iam.CompositePrincipal(</span></span>
<span class="line"><span style="color: #24292E">                iam.ServicePrincipal(</span><span style="color: #032F62">&quot;ecs-tasks.amazonaws.com&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">            )</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D"># allow read and write access to S3 bucket</span></span>
<span class="line"><span style="color: #24292E">        bucket.grant_read_write(job_role)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        repo </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ecr.Repository(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;repository&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">removal_policy</span><span style="color: #D73A49">=</span><span style="color: #24292E">core.RemovalPolicy.</span><span style="color: #005CC5">DESTROY</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        job_def </span><span style="color: #D73A49">=</span><span style="color: #24292E"> batch.JobDefinition(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;job-definition&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">container</span><span style="color: #D73A49">=</span><span style="color: #24292E">batch.JobDefinitionContainer(</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">image</span><span style="color: #D73A49">=</span><span style="color: #24292E">ecs.ContainerImage.from_ecr_repository(repo),</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">command</span><span style="color: #D73A49">=</span><span style="color: #24292E">[</span><span style="color: #032F62">&quot;python3&quot;</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;main.py&quot;</span><span style="color: #24292E">],</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">vcpus</span><span style="color: #D73A49">=</span><span style="color: #005CC5">4</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">gpu_count</span><span style="color: #D73A49">=</span><span style="color: #005CC5">1</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">memory_limit_mib</span><span style="color: #D73A49">=</span><span style="color: #005CC5">12000</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">job_role</span><span style="color: #D73A49">=</span><span style="color: #24292E">job_role,</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">environment</span><span style="color: #D73A49">=</span><span style="color: #24292E">{</span></span>
<span class="line"><span style="color: #24292E">                    </span><span style="color: #032F62">&quot;BUCKET_NAME&quot;</span><span style="color: #24292E">: bucket.bucket_name</span></span>
<span class="line"><span style="color: #24292E">                }</span></span>
<span class="line"><span style="color: #24292E">            ),</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">job_definition_name</span><span style="color: #D73A49">=</span><span style="color: #005CC5">self</span><span style="color: #24292E">.stack_name </span><span style="color: #D73A49">+</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;job-definition&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">timeout</span><span style="color: #D73A49">=</span><span style="color: #24292E">core.Duration.hours(</span><span style="color: #005CC5">2</span><span style="color: #24292E">),</span></span>
<span class="line"><span style="color: #24292E">        )</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br><span class="line-number">36</span><br><span class="line-number">37</span><br><span class="line-number">38</span><br><span class="line-number">39</span><br><span class="line-number">40</span><br><span class="line-number">41</span><br><span class="line-number">42</span><br><span class="line-number">43</span><br><span class="line-number">44</span><br><span class="line-number">45</span><br><span class="line-number">46</span><br><span class="line-number">47</span><br><span class="line-number">48</span><br><span class="line-number">49</span><br><span class="line-number">50</span><br><span class="line-number">51</span><br><span class="line-number">52</span><br><span class="line-number">53</span><br><span class="line-number">54</span><br><span class="line-number">55</span><br><span class="line-number">56</span><br><span class="line-number">57</span><br><span class="line-number">58</span><br><span class="line-number">59</span><br><span class="line-number">60</span><br><span class="line-number">61</span><br><span class="line-number">62</span><br><span class="line-number">63</span><br><span class="line-number">64</span><br><span class="line-number">65</span><br><span class="line-number">66</span><br><span class="line-number">67</span><br><span class="line-number">68</span><br><span class="line-number">69</span><br><span class="line-number">70</span><br><span class="line-number">71</span><br><span class="line-number">72</span><br><span class="line-number">73</span><br><span class="line-number">74</span><br><span class="line-number">75</span><br><span class="line-number">76</span><br><span class="line-number">77</span><br><span class="line-number">78</span><br><span class="line-number">79</span><br></div></div><ul>
<li>
<p>で，計算結果を保存するための S3 バケットを用意している</p>
</li>
<li>
<p>で， Compute environment を定義している． ここでは <code>g4dn.xlarge</code> のインスタンスタイプを使用するとし，最大の vCPU 使用数は 64 と指定している． また，最小の vCPU は 0 である． 今回は，負荷がかかっていないときにアイドリング状態にあるインスタンスを用意する利点は全くないので，ここは 0 にするのが望ましい．</p>
</li>
<li>
<p>で， &lt;2&gt; で作成した Compute environment と紐付いた Job queue を定義している．</p>
</li>
<li>
<p>で，ジョブが計算結果を S3 に書き込むことができるよう， IAM ロールを定義している． (IAM とはリソースがもつ権限を管理する仕組みである．詳しくは <a href="#sec:bashoutter_iam">AWS における権限の管理 (IAM)</a> を参照)</p>
</li>
<li>
<p>では， Docker image を配置するための ECR を定義している．</p>
</li>
<li>
<p>で Job definition を作成している． ここでは，4 vCPU， 12000 MB (=12GB) の RAM を使用するように指定している． また，今後必要となる環境変数 (<code>BUCKET_NAME</code>) を設定している． さらに， &lt;4&gt; で作った IAM を付与している．</p>
</li>
</ul>
<p><code>g4dn.xlarge</code> は 1 台あたり 4 vCPU が割り当てられている． このプログラムでは Compute environment の maximum vCPUs を 64 と指定しているので，最大で 16 台のインスタンスが同時に起動することになる． ここで maxium vCPUs を 64 に限定しているのは，なんらかのミスで意図せぬジョブを大量にクラスターに投入してしまった事態で，高額の AWS 利用料金が発生するのを防ぐためである． もし，自分のアプリケーションで必要と判断したならば自己責任において 64 よりも大きな数を設定して構わない．</p>
<p>ここで注意が一点ある． AWS では各アカウントごとに EC2 で起動できるインスタンスの上限が設定されている． この上限は AWS コンソールにログインし， EC2 コンソールの左側メニューバーの <code>Limits</code> をクリックすることで確認できる (<a href="#fig_ec2_limits">figure_title</a>)． <code>g4dn.xlarge</code> (EC2 の区分でいうと G ファミリーに属する) の制限を確認するには， <code>Running On-Demand All G instances</code> という名前の項目を見る． ここにある数字が， AWS によって課されたアカウントの上限であり，この上限を超えたインスタンスを起動することはできない． もし，自分の用途に対して上限が低すぎる場合は，上限の緩和申請を行うことができる． 詳しくは <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-resource-limits.html" target="_blank" rel="noreferrer">公式ドキュメンテーション &quot;Amazon EC2 service quotas&quot;</a> を参照のこと．</p>
<p><img src="./assets/aws_batch/ec2_limits.png" alt="EC2コンソールから各種の上限を確認する"></p>
<h2 id="スタックのデプロイ-2" tabindex="-1">スタックのデプロイ <a class="header-anchor" href="#スタックのデプロイ-2" aria-label="Permalink to &quot;スタックのデプロイ&quot;">&ZeroWidthSpace;</a></h2>
<p>スタックの中身が理解できたところで，早速スタックをデプロイしてみよう．</p>
<p>デプロイの手順は，これまでのハンズオンとほとんど共通である． ここでは，コマンドのみ列挙する (# で始まる行はコメントである)． シークレットキーの設定も忘れずに (<a href="#aws_cli_install">AWS CLI のインストール</a>)．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390"># プロジェクトのディレクトリに移動</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cd</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">handson/aws-batch</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># venv を作成し，依存ライブラリのインストールを行う</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python3</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-m</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">venv</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.env</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">source</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.env/bin/activate</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">pip</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">install</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-r</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">requirements.txt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># デプロイを実行</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cdk</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">deploy</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D"># プロジェクトのディレクトリに移動</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cd</span><span style="color: #24292E"> </span><span style="color: #032F62">handson/aws-batch</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># venv を作成し，依存ライブラリのインストールを行う</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python3</span><span style="color: #24292E"> </span><span style="color: #005CC5">-m</span><span style="color: #24292E"> </span><span style="color: #032F62">venv</span><span style="color: #24292E"> </span><span style="color: #032F62">.env</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">source</span><span style="color: #24292E"> </span><span style="color: #032F62">.env/bin/activate</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">pip</span><span style="color: #24292E"> </span><span style="color: #032F62">install</span><span style="color: #24292E"> </span><span style="color: #005CC5">-r</span><span style="color: #24292E"> </span><span style="color: #032F62">requirements.txt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># デプロイを実行</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cdk</span><span style="color: #24292E"> </span><span style="color: #032F62">deploy</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br></div></div><p>デプロイのコマンドが無事に実行されたことが確認できたら，AWS コンソールにログインして，デプロイされたスタックを確認してみよう． コンソールの検索バーで <code>batch</code> と入力し， AWS Batch の管理画面を開く (<a href="#fig_batch_console">figure_title</a>)．</p>
<p><img src="./assets/aws_batch/batch_console.png" alt="AWS Batch のコンソール画面 (ダッシュボード)"></p>
<p>まず目を向けてほしいのが，画面の一番下にある Compute environment overview の中の <code>SimpleBatchcompute-env</code> という名前の項目だ． Compute environment とは，先ほど述べたとおり，計算が実行される環境 (クラスターと読み替えてもよい) である． プログラムで指定したとおり， <code>g4dn.xlarge</code> が実際に使用されるインスタンスタイプとして表示されている． また， <code>Minimum vCPUs</code> が 0，<code>Maximum vCPUs</code> が 64 と設定されていることも見て取れる． 加えて，この時点では一つもジョブが走っていないので， <code>Desired vCPUs</code> は 0 になっている． より詳細な Compute environment の情報を閲覧したい場合は，名前をクリックすることで詳細画面が開く．</p>
<p>次に，Job queue overview にある <code>SimpleBatch-queue</code> という項目に注目してほしい． ここでは実行待ちのジョブ・実行中のジョブ・実行が完了したジョブを一覧で確認することができる． <code>PENDING</code>, <code>RUNNING</code>, <code>SUCCEEDED</code>, <code>FAILED</code> などのカラムがあることが確認できる．ジョブが進行するにつれて，ジョブの状態がこのカラムにしたがって遷移していく． 後でジョブを実際にサブミットしたときに戻ってこよう．</p>
<p>最後に，今回作成した Job definition を確認しよう． 左側のメニューから　<code>Job definitions</code> を選択し，次の画面で <code>SimpleBatchjob-definition</code> という項目を見つけて開く． ここから Job definition の詳細を閲覧することができる (<a href="#fig:batch_job_definition">figure_title</a>)． 中でも重要な情報としては，　<code>vCPUs</code>, <code>Memory</code>, <code>GPU</code> がそれぞれ Docker に割り当てられる vCPU・メモリー・ GPU の量を規定している． また， <code>Image</code> と書いてあるところに，ジョブで使用される Docker イメージが指定されている． ここでは， ECR のレポジトリを参照している． 現時点ではこの ECR は空である． 次のステップとして，この ECR にイメージを配置する作業を行おう．</p>
<p><img src="./assets/aws_batch/batch_job_definition.png" alt="AWS Batch から Job definition を確認"></p>
<h2 id="docker-image-を-ecr-に配置する" tabindex="-1">Docker image を ECR に配置する <a class="header-anchor" href="#docker-image-を-ecr-に配置する" aria-label="Permalink to &quot;Docker image を ECR に配置する&quot;">&ZeroWidthSpace;</a></h2>
<p>さて， Batch がジョブを実行するには，どこか指定された場所から Docker イメージをダウンロード (pull) してくる必要がある． 前回のハンズオン (<a href="#sec_fargate_qabot">Hands-on #3: AWS で自動質問回答ボットを走らせる</a>) では，公開設定にしてある Docker Hub からイメージを pull してきた． 今回のハンズオンでは， AWS から提供されているレジストリである <strong>ECR (Elastic Container Registry)</strong> に image を配置するという設計を採用する． ECR を利用する利点は，自分だけがアクセスすることのできるプライベートなイメージの置き場所を用意できる点である． Batch は ECR からイメージを pull してくることで，タスクを実行する (<a href="#fig_batch_architecture">figure_title</a>)．</p>
<p>スタックのソースコードでいうと，次の箇所が ECR を定義している．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">repo </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ecr.Repository(</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;repository&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">removal_policy</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">core.RemovalPolicy.</span><span style="color: #6CB6FF">DESTROY</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">job_def </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> batch.JobDefinition(</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;job-definition&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">container</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">batch.JobDefinitionContainer(</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #F69D50">image</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ecs.ContainerImage.from_ecr_repository(repo), </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #6CB6FF">...</span></span>
<span class="line"><span style="color: #ADBAC7">    ),</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">...</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">repo </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ecr.Repository(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;repository&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">removal_policy</span><span style="color: #D73A49">=</span><span style="color: #24292E">core.RemovalPolicy.</span><span style="color: #005CC5">DESTROY</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">job_def </span><span style="color: #D73A49">=</span><span style="color: #24292E"> batch.JobDefinition(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;job-definition&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">container</span><span style="color: #D73A49">=</span><span style="color: #24292E">batch.JobDefinitionContainer(</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #E36209">image</span><span style="color: #D73A49">=</span><span style="color: #24292E">ecs.ContainerImage.from_ecr_repository(repo), </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #005CC5">...</span></span>
<span class="line"><span style="color: #24292E">    ),</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">...</span></span>
<span class="line"><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br></div></div><ul>
<li>
<p>で，新規の ECR を作成している．</p>
</li>
<li>
<p>で Job definition を定義する中で，イメージを &lt;1&gt; で作った ECR から取得するように指定している． これと同時に， Job definition には ECR へのアクセス権限が IAM を通じて自動的に付与される．</p>
</li>
</ul>
<p>さて，スタックをデプロイした時点では， ECR は空っぽである． ここに自分のアプリケーションで使う Docker イメージを push してあげる必要がある．</p>
<p>そのために，まずは AWS コンソールから ECR の画面を開こう (検索バーに <code>Elastic Container Registry</code> と入力すると出てくる)． <code>Private</code> というタブを選択すると， <code>simplebatch-repositoryXXXXXX</code> という名前のレポジトリが見つかるだろう (<a href="#fig_ecr_console1">figure_title</a>)．</p>
<p><img src="./assets/aws_batch/ecr_console1.png" alt="ECR のコンソール画面"></p>
<p>次に，このレポジトリの名前をクリックするとレポジトリの詳細画面に遷移する． そうしたら，画面右上にある <code>View push commands</code> というボタンをクリックする． すると <a href="#fig_ecr_push_command">figure_title</a> のようなポップアップ画面が立ち上がる．</p>
<p><img src="./assets/aws_batch/ecr_push_command.png" alt="ECR への push コマンド"></p>
<p>このポップアップ画面で表示されている四つのコマンドを順番に実行していくことで，手元の Docker イメージを ECR に push することができる． <strong>push を実行する前に， AWS の認証情報が設定されている</strong>ことを確認しよう． そのうえで，ハンズオンのソースコードの中にある <strong><code>docker/</code> という名前のディレクトリに移動</strong>する． そうしたら，ポップアップ画面で表示されたコマンドを上から順に実行していく．</p>
<p>ポップアップで表示されるコマンドの 2 つめを見てみると <code>docker build -t XXXXX .</code> となっている． 最後の <code>.</code> が重要で，これは <em>現在のディレクトリにある Dockerfile を使ってイメージをビルドせよ</em> という意味である． このような理由で， <code>Dockerfile</code> が置いてあるディレクトリに移動する必要がある．</p>
<p>四つ目のコマンドは，数 GB あるイメージを ECR にアップロードするので少し時間がかかるかもしれないが，これが完了するとめでたくイメージが ECR に配置されたことになる． もう一度 ECR のコンソールを見てみると，確かにイメージが配置されていることが確認できる (<a href="#fig_ecr_console2">figure_title</a>)． これで，AWS Batch を使ってジョブを実行させるための最後の準備が完了した．</p>
<p><img src="./assets/aws_batch/ecr_console2.png" alt="ECR へ image の配置が完了した"></p>
<h2 id="単一のジョブを実行する" tabindex="-1">単一のジョブを実行する <a class="header-anchor" href="#単一のジョブを実行する" aria-label="Permalink to &quot;単一のジョブを実行する&quot;">&ZeroWidthSpace;</a></h2>
<p>さて，ここからは実際に AWS Batch にジョブを投入する方法を見ていこう．</p>
<p>ハンズオンのディレクトリの <code>notebook/</code> というディレクトリの中に， <a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/aws-batch/notebook/run_single.ipynb" target="_blank" rel="noreferrer">run_single.ipynb</a> というファイルが見つかるはずである (<code>.ipynb</code> は Jupyter notebook のファイル形式)． これを Jupyter notebook から開こう．</p>
<p>今回のハンズオンでは， <code>venv</code> による仮想環境の中に Jupyter notebook もインストール済みである． なので，ローカルマシンから以下のコマンドで Jupyter notebook を立ち上げる．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390"># .env の仮想環境にいることを確認</span></span>
<span class="line"><span style="color: #ADBAC7">(</span><span style="color: #F69D50">.env</span><span style="color: #ADBAC7">) $ cd notebook</span></span>
<span class="line"><span style="color: #ADBAC7">(</span><span style="color: #F69D50">.env</span><span style="color: #ADBAC7">) $ jupyter notebook</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D"># .env の仮想環境にいることを確認</span></span>
<span class="line"><span style="color: #24292E">(</span><span style="color: #6F42C1">.env</span><span style="color: #24292E">) $ cd notebook</span></span>
<span class="line"><span style="color: #24292E">(</span><span style="color: #6F42C1">.env</span><span style="color: #24292E">) $ jupyter notebook</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><p>Jupyter notebook が起動したら， <code>run_single.ipynb</code> を開く．</p>
<p>最初の [1], [2], [3] 番のセルは，ジョブをサブミットするための関数 (<code>submit_job()</code>) を定義している．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390"># [1]</span></span>
<span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> boto3</span></span>
<span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> argparse</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># [2]</span></span>
<span class="line"><span style="color: #768390"># AWS 認証ヘルパー ...省略...</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># [3]</span></span>
<span class="line"><span style="color: #F47067">def</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">submit_job</span><span style="color: #ADBAC7">(lr:</span><span style="color: #6CB6FF">float</span><span style="color: #ADBAC7">, momentum:</span><span style="color: #6CB6FF">float</span><span style="color: #ADBAC7">, epochs:</span><span style="color: #6CB6FF">int</span><span style="color: #ADBAC7">, profile_name</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;default&quot;</span><span style="color: #ADBAC7">):</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> profile_name </span><span style="color: #F47067">is</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">None</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">        session </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> boto3.Session()</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">else</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">        session </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> boto3.Session(</span><span style="color: #F69D50">profile_name</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">profile_name)</span></span>
<span class="line"><span style="color: #ADBAC7">    client </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> session.client(</span><span style="color: #96D0FF">&quot;batch&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    title </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;lr&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">(lr).replace(</span><span style="color: #96D0FF">&quot;.&quot;</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;&quot;</span><span style="color: #ADBAC7">) </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;_m&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">(momentum).replace(</span><span style="color: #96D0FF">&quot;.&quot;</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">    resp </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> client.submit_job(</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #F69D50">jobName</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">title,</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #F69D50">jobQueue</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;SimpleBatchjob-queue&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #F69D50">jobDefinition</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;SimpleBatchjob-definition&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #F69D50">containerOverrides</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">{</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #96D0FF">&quot;command&quot;</span><span style="color: #ADBAC7">: [</span><span style="color: #96D0FF">&quot;--lr&quot;</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">(lr),</span></span>
<span class="line"><span style="color: #ADBAC7">                        </span><span style="color: #96D0FF">&quot;--momentum&quot;</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">(momentum),</span></span>
<span class="line"><span style="color: #ADBAC7">                        </span><span style="color: #96D0FF">&quot;--epochs&quot;</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">(epochs),</span></span>
<span class="line"><span style="color: #ADBAC7">                        </span><span style="color: #96D0FF">&quot;--uploadS3&quot;</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;true&quot;</span><span style="color: #ADBAC7">]</span></span>
<span class="line"><span style="color: #ADBAC7">        }</span></span>
<span class="line"><span style="color: #ADBAC7">    )</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">print</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;Job submitted!&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">print</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;job name&quot;</span><span style="color: #ADBAC7">, resp[</span><span style="color: #96D0FF">&quot;jobName&quot;</span><span style="color: #ADBAC7">], </span><span style="color: #96D0FF">&quot;job ID&quot;</span><span style="color: #ADBAC7">, resp[</span><span style="color: #96D0FF">&quot;jobId&quot;</span><span style="color: #ADBAC7">])</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D"># [1]</span></span>
<span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> boto3</span></span>
<span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> argparse</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># [2]</span></span>
<span class="line"><span style="color: #6A737D"># AWS 認証ヘルパー ...省略...</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># [3]</span></span>
<span class="line"><span style="color: #D73A49">def</span><span style="color: #24292E"> </span><span style="color: #6F42C1">submit_job</span><span style="color: #24292E">(lr:</span><span style="color: #005CC5">float</span><span style="color: #24292E">, momentum:</span><span style="color: #005CC5">float</span><span style="color: #24292E">, epochs:</span><span style="color: #005CC5">int</span><span style="color: #24292E">, profile_name</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;default&quot;</span><span style="color: #24292E">):</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">if</span><span style="color: #24292E"> profile_name </span><span style="color: #D73A49">is</span><span style="color: #24292E"> </span><span style="color: #005CC5">None</span><span style="color: #24292E">:</span></span>
<span class="line"><span style="color: #24292E">        session </span><span style="color: #D73A49">=</span><span style="color: #24292E"> boto3.Session()</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">else</span><span style="color: #24292E">:</span></span>
<span class="line"><span style="color: #24292E">        session </span><span style="color: #D73A49">=</span><span style="color: #24292E"> boto3.Session(</span><span style="color: #E36209">profile_name</span><span style="color: #D73A49">=</span><span style="color: #24292E">profile_name)</span></span>
<span class="line"><span style="color: #24292E">    client </span><span style="color: #D73A49">=</span><span style="color: #24292E"> session.client(</span><span style="color: #032F62">&quot;batch&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">    title </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;lr&quot;</span><span style="color: #24292E"> </span><span style="color: #D73A49">+</span><span style="color: #24292E"> </span><span style="color: #005CC5">str</span><span style="color: #24292E">(lr).replace(</span><span style="color: #032F62">&quot;.&quot;</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;&quot;</span><span style="color: #24292E">) </span><span style="color: #D73A49">+</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;_m&quot;</span><span style="color: #24292E"> </span><span style="color: #D73A49">+</span><span style="color: #24292E"> </span><span style="color: #005CC5">str</span><span style="color: #24292E">(momentum).replace(</span><span style="color: #032F62">&quot;.&quot;</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">    resp </span><span style="color: #D73A49">=</span><span style="color: #24292E"> client.submit_job(</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #E36209">jobName</span><span style="color: #D73A49">=</span><span style="color: #24292E">title,</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #E36209">jobQueue</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;SimpleBatchjob-queue&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #E36209">jobDefinition</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;SimpleBatchjob-definition&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #E36209">containerOverrides</span><span style="color: #D73A49">=</span><span style="color: #24292E">{</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #032F62">&quot;command&quot;</span><span style="color: #24292E">: [</span><span style="color: #032F62">&quot;--lr&quot;</span><span style="color: #24292E">, </span><span style="color: #005CC5">str</span><span style="color: #24292E">(lr),</span></span>
<span class="line"><span style="color: #24292E">                        </span><span style="color: #032F62">&quot;--momentum&quot;</span><span style="color: #24292E">, </span><span style="color: #005CC5">str</span><span style="color: #24292E">(momentum),</span></span>
<span class="line"><span style="color: #24292E">                        </span><span style="color: #032F62">&quot;--epochs&quot;</span><span style="color: #24292E">, </span><span style="color: #005CC5">str</span><span style="color: #24292E">(epochs),</span></span>
<span class="line"><span style="color: #24292E">                        </span><span style="color: #032F62">&quot;--uploadS3&quot;</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;true&quot;</span><span style="color: #24292E">]</span></span>
<span class="line"><span style="color: #24292E">        }</span></span>
<span class="line"><span style="color: #24292E">    )</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">print</span><span style="color: #24292E">(</span><span style="color: #032F62">&quot;Job submitted!&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">print</span><span style="color: #24292E">(</span><span style="color: #032F62">&quot;job name&quot;</span><span style="color: #24292E">, resp[</span><span style="color: #032F62">&quot;jobName&quot;</span><span style="color: #24292E">], </span><span style="color: #032F62">&quot;job ID&quot;</span><span style="color: #24292E">, resp[</span><span style="color: #032F62">&quot;jobId&quot;</span><span style="color: #24292E">])</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br></div></div><p><code>submit_job()</code> 関数について簡単に説明しよう． <a href="#sec_run_mnist_docker_local">MNIST 手書き文字認識 (再訪)</a> で， MNIST の Docker をローカルで実行したとき，次のようなコマンドを使用した．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">docker</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">run</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-it</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">mymnist</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--lr</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0.1</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--momentum</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0.5</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--epochs</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">10</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">docker</span><span style="color: #24292E"> </span><span style="color: #032F62">run</span><span style="color: #24292E"> </span><span style="color: #005CC5">-it</span><span style="color: #24292E"> </span><span style="color: #032F62">mymnist</span><span style="color: #24292E"> </span><span style="color: #005CC5">--lr</span><span style="color: #24292E"> </span><span style="color: #005CC5">0.1</span><span style="color: #24292E"> </span><span style="color: #005CC5">--momentum</span><span style="color: #24292E"> </span><span style="color: #005CC5">0.5</span><span style="color: #24292E"> </span><span style="color: #005CC5">--epochs</span><span style="color: #24292E"> </span><span style="color: #005CC5">10</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>ここで， <code>--lr 0.1 --momentum 0.5 --epochs 10</code> の部分が，コンテナに渡されるコマンドである．</p>
<p>AWS Batch でジョブを実行する際も，<code>ContainerOverrides</code> の <code>command</code> というパラメータを使用することで，コンテナに渡されるコマンドを指定することができる． コードでは以下の部分が該当する．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">containerOverrides</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">{</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #96D0FF">&quot;command&quot;</span><span style="color: #ADBAC7">: [</span><span style="color: #96D0FF">&quot;--lr&quot;</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">(lr),</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #96D0FF">&quot;--momentum&quot;</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">(momentum),</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #96D0FF">&quot;--epochs&quot;</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">(epochs),</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #96D0FF">&quot;--uploadS3&quot;</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;true&quot;</span><span style="color: #ADBAC7">]</span></span>
<span class="line"><span style="color: #ADBAC7">}</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">containerOverrides</span><span style="color: #D73A49">=</span><span style="color: #24292E">{</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #032F62">&quot;command&quot;</span><span style="color: #24292E">: [</span><span style="color: #032F62">&quot;--lr&quot;</span><span style="color: #24292E">, </span><span style="color: #005CC5">str</span><span style="color: #24292E">(lr),</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #032F62">&quot;--momentum&quot;</span><span style="color: #24292E">, </span><span style="color: #005CC5">str</span><span style="color: #24292E">(momentum),</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #032F62">&quot;--epochs&quot;</span><span style="color: #24292E">, </span><span style="color: #005CC5">str</span><span style="color: #24292E">(epochs),</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #032F62">&quot;--uploadS3&quot;</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;true&quot;</span><span style="color: #24292E">]</span></span>
<span class="line"><span style="color: #24292E">}</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br></div></div><p>続いて， [4] 番のセルに移ろう． ここでは，上記の <code>submit_job()</code> 関数を用いて， 学習率 = 0.01, モメンタム=0.1, エポック数=100 を指定したジョブを投入する．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390"># [4]</span></span>
<span class="line"><span style="color: #ADBAC7">submit_job(</span><span style="color: #6CB6FF">0.01</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">0.1</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">100</span><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D"># [4]</span></span>
<span class="line"><span style="color: #24292E">submit_job(</span><span style="color: #005CC5">0.01</span><span style="color: #24292E">, </span><span style="color: #005CC5">0.1</span><span style="color: #24292E">, </span><span style="color: #005CC5">100</span><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>AWS の認証情報は， Jupyter Notebook の内部から再度定義する必要がある． これを手助けするため， Notebook の [2] 番のセル (デフォルトではすべてコメントアウトされている) を用意した． これを使うにはコメントアウトを解除すればよい． このセルを実行すると， AWS の認証情報を入力する対話的なプロンプトが表示される． プロンプトに従って aws secret key などを入力することで， (Jupyter のセッションに固有な) 環境変数に AWS の認証情報が記録される．</p>
<p>もう一つの認証方法として， <code>submit_job()</code> 関数に <code>profile_name</code> というパラメータを用意した． もし <code>~/.aws/credentials</code> に認証情報が書き込まれているのならば (詳しくは <a href="#aws_cli_install">AWS CLI のインストール</a>)， <code>profile_name</code> に使用したいプロファイルの名前を渡すだけで， 認証を行うことができる． 慣れている読者は後者のほうが便利であると感じるだろう．</p>
<p>[4] 番のセルを実行したら，ジョブが実際に投入されたかどうかを AWS コンソールから確認してみよう． AWS Batch の管理コンソールを開くと， <a href="#fig_batch_running_job">figure_title</a> のような画面が表示されるだろう．</p>
<p><img src="./assets/aws_batch/batch_running_job.png" alt="AWS Batch でジョブが実行されている様子"></p>
<p><a href="#fig_batch_running_job">figure_title</a> で赤で囲った箇所に注目してほしい． 一つのジョブが投入されると，それは <code>SUBMITTED</code> という状態を経て <code>RUNNABLE</code> という状態に遷移する． <code>RUNNABLE</code> とは， ジョブを実行するためのインスタンスが Compute environment に不足しているため，新たなインスタンスが起動されるのを待っている状態に相当する． インスタンスの準備が整うと，ジョブの状態は <code>STARTING</code> を経て <code>RUNNING</code> に至る．</p>
<p>次に，ジョブのステータスが <code>RUNNING</code> のときの Compute environment の <code>Desired vCPU</code> を見てみよう (<a href="#fig_batch_running_job">figure_title</a> で紫で囲った箇所)． ここで 4 と表示されているのは， <code>g4dn.xlarge</code> インスタンス一つ分の vCPU の数である． ジョブの投入に応じて，それを実行するのに最低限必要な EC2 インスタンスが起動されたことが確認できる (興味のある人は， EC2 コンソールも同時に覗いてみるとよい)．</p>
<p>しばらく経つと，ジョブの状態は <code>RUNNING</code> から <code>SUCCEEDED</code> (あるいは何らかの理由でエラーが発生したときには <code>FAILED</code>) に遷移する． 今回のハンズオンで使っている MNIST の学習はだいたい 10 分くらいで完了するはずである． ジョブの状態が <code>SUCCEEDED</code> になるまで見届けよう．</p>
<p>ジョブが完了すると，学習の結果 (エポックごとの Loss と Accuracy を記録した CSV ファイル) は S3 に保存される． AWS コンソールからこれを確認しよう．</p>
<p>S3 のコンソールに行くと <code>simplebatch-bucketXXXX</code> (XXXX の部分はユーザーによって異なる) という名前のバケットが見つかるはずである． これをクリックして中身を見てみると， <code>metrics_lr0.0100_m0.1000.csv</code> という名前の CSV があることが確認できるだろう (<a href="#fig_s3_saved_file">figure_title</a>)． これが， 学習率 = 0.01, モメンタム = 0.1 として学習を行ったときの結果である．</p>
<p><img src="./assets/aws_batch/s3_saved_file.png" alt="ジョブの実行結果は S3 に保存される"></p>
<p>さて，ここで <code>run_single.ipynb</code> に戻ってこよう． [5] から [7] 番のセルでは，学習結果の CSV ファイルのダウンロードを行っている．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390"># [5]</span></span>
<span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> pandas </span><span style="color: #F47067">as</span><span style="color: #ADBAC7"> pd</span></span>
<span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> io</span></span>
<span class="line"><span style="color: #F47067">from</span><span style="color: #ADBAC7"> matplotlib </span><span style="color: #F47067">import</span><span style="color: #ADBAC7"> pyplot </span><span style="color: #F47067">as</span><span style="color: #ADBAC7"> plt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># [6]</span></span>
<span class="line"><span style="color: #F47067">def</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">read_table_from_s3</span><span style="color: #ADBAC7">(bucket_name, key, profile_name</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">None</span><span style="color: #ADBAC7">):</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> profile_name </span><span style="color: #F47067">is</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">None</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">        session </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> boto3.Session()</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">else</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">        session </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> boto3.Session(</span><span style="color: #F69D50">profile_name</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">profile_name)</span></span>
<span class="line"><span style="color: #ADBAC7">    s3 </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> session.resource(</span><span style="color: #96D0FF">&quot;s3&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">    bucket </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> s3.Bucket(bucket_name)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    obj </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> bucket.Object(key).get().get(</span><span style="color: #96D0FF">&quot;Body&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">    df </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> pd.read_csv(obj)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">return</span><span style="color: #ADBAC7"> df</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># [7]</span></span>
<span class="line"><span style="color: #ADBAC7">bucket_name </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;simplebatch-bucket43879c71-mbqaltx441fu&quot;</span></span>
<span class="line"><span style="color: #ADBAC7">df </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> read_table_from_s3(</span></span>
<span class="line"><span style="color: #ADBAC7">    bucket_name,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #96D0FF">&quot;metrics_lr0.0100_m0.1000.csv&quot;</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D"># [5]</span></span>
<span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> pandas </span><span style="color: #D73A49">as</span><span style="color: #24292E"> pd</span></span>
<span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> io</span></span>
<span class="line"><span style="color: #D73A49">from</span><span style="color: #24292E"> matplotlib </span><span style="color: #D73A49">import</span><span style="color: #24292E"> pyplot </span><span style="color: #D73A49">as</span><span style="color: #24292E"> plt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># [6]</span></span>
<span class="line"><span style="color: #D73A49">def</span><span style="color: #24292E"> </span><span style="color: #6F42C1">read_table_from_s3</span><span style="color: #24292E">(bucket_name, key, profile_name</span><span style="color: #D73A49">=</span><span style="color: #005CC5">None</span><span style="color: #24292E">):</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">if</span><span style="color: #24292E"> profile_name </span><span style="color: #D73A49">is</span><span style="color: #24292E"> </span><span style="color: #005CC5">None</span><span style="color: #24292E">:</span></span>
<span class="line"><span style="color: #24292E">        session </span><span style="color: #D73A49">=</span><span style="color: #24292E"> boto3.Session()</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">else</span><span style="color: #24292E">:</span></span>
<span class="line"><span style="color: #24292E">        session </span><span style="color: #D73A49">=</span><span style="color: #24292E"> boto3.Session(</span><span style="color: #E36209">profile_name</span><span style="color: #D73A49">=</span><span style="color: #24292E">profile_name)</span></span>
<span class="line"><span style="color: #24292E">    s3 </span><span style="color: #D73A49">=</span><span style="color: #24292E"> session.resource(</span><span style="color: #032F62">&quot;s3&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">    bucket </span><span style="color: #D73A49">=</span><span style="color: #24292E"> s3.Bucket(bucket_name)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">    obj </span><span style="color: #D73A49">=</span><span style="color: #24292E"> bucket.Object(key).get().get(</span><span style="color: #032F62">&quot;Body&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">    df </span><span style="color: #D73A49">=</span><span style="color: #24292E"> pd.read_csv(obj)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">return</span><span style="color: #24292E"> df</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># [7]</span></span>
<span class="line"><span style="color: #24292E">bucket_name </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;simplebatch-bucket43879c71-mbqaltx441fu&quot;</span></span>
<span class="line"><span style="color: #24292E">df </span><span style="color: #D73A49">=</span><span style="color: #24292E"> read_table_from_s3(</span></span>
<span class="line"><span style="color: #24292E">    bucket_name,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #032F62">&quot;metrics_lr0.0100_m0.1000.csv&quot;</span></span>
<span class="line"><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br></div></div><p>[6] で S3 から CSV データをダウンロードし， pandas の <code>DataFrame</code> オブジェクトとしてロードする関数を定義している． [7] を実行する際， <code>bucket_name</code> という変数の値を，<strong>自分自身のバケットの名前に置き換える</strong>ことに注意しよう (先ほど S3 コンソールから確認した <code>simplebatch-bucketXXXX</code> のことである)．</p>
<p>続いて， [9] 番のセルで， CSV のデータをプロットしている (<a href="#fig_loss_epoch_profile2">figure_title</a>)． ローカルで実行したときと同じように， AWS Batch を用いて MNIST モデルを訓練することに成功した！</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390"># [9]</span></span>
<span class="line"><span style="color: #ADBAC7">fig, (ax1, ax2) </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> plt.subplots(</span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">2</span><span style="color: #ADBAC7">, </span><span style="color: #F69D50">figsize</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">9</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">4</span><span style="color: #ADBAC7">))</span></span>
<span class="line"><span style="color: #ADBAC7">x </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> [i </span><span style="color: #F47067">for</span><span style="color: #ADBAC7"> i </span><span style="color: #F47067">in</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">range</span><span style="color: #ADBAC7">(df.shape[</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">])]</span></span>
<span class="line"><span style="color: #ADBAC7">ax1.plot(x, df[</span><span style="color: #96D0FF">&quot;train_loss&quot;</span><span style="color: #ADBAC7">], </span><span style="color: #F69D50">label</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;Train&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">ax1.plot(x, df[</span><span style="color: #96D0FF">&quot;val_loss&quot;</span><span style="color: #ADBAC7">], </span><span style="color: #F69D50">label</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;Val&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">ax2.plot(x, df[</span><span style="color: #96D0FF">&quot;val_accuracy&quot;</span><span style="color: #ADBAC7">])</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">ax1.set_xlabel(</span><span style="color: #96D0FF">&quot;Epochs&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">ax1.set_ylabel(</span><span style="color: #96D0FF">&quot;Loss&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">ax1.legend()</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">ax2.set_xlabel(</span><span style="color: #96D0FF">&quot;Epochs&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">ax2.set_ylabel(</span><span style="color: #96D0FF">&quot;Accuracy&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6CB6FF">print</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;Best loss:&quot;</span><span style="color: #ADBAC7">, df[</span><span style="color: #96D0FF">&quot;val_loss&quot;</span><span style="color: #ADBAC7">].min())</span></span>
<span class="line"><span style="color: #6CB6FF">print</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;Best loss epoch:&quot;</span><span style="color: #ADBAC7">, df[</span><span style="color: #96D0FF">&quot;val_loss&quot;</span><span style="color: #ADBAC7">].argmin())</span></span>
<span class="line"><span style="color: #6CB6FF">print</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;Best accuracy:&quot;</span><span style="color: #ADBAC7">, df[</span><span style="color: #96D0FF">&quot;val_accuracy&quot;</span><span style="color: #ADBAC7">].max())</span></span>
<span class="line"><span style="color: #6CB6FF">print</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;Best accuracy epoch:&quot;</span><span style="color: #ADBAC7">, df[</span><span style="color: #96D0FF">&quot;val_accuracy&quot;</span><span style="color: #ADBAC7">].argmax())</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D"># [9]</span></span>
<span class="line"><span style="color: #24292E">fig, (ax1, ax2) </span><span style="color: #D73A49">=</span><span style="color: #24292E"> plt.subplots(</span><span style="color: #005CC5">1</span><span style="color: #24292E">,</span><span style="color: #005CC5">2</span><span style="color: #24292E">, </span><span style="color: #E36209">figsize</span><span style="color: #D73A49">=</span><span style="color: #24292E">(</span><span style="color: #005CC5">9</span><span style="color: #24292E">,</span><span style="color: #005CC5">4</span><span style="color: #24292E">))</span></span>
<span class="line"><span style="color: #24292E">x </span><span style="color: #D73A49">=</span><span style="color: #24292E"> [i </span><span style="color: #D73A49">for</span><span style="color: #24292E"> i </span><span style="color: #D73A49">in</span><span style="color: #24292E"> </span><span style="color: #005CC5">range</span><span style="color: #24292E">(df.shape[</span><span style="color: #005CC5">0</span><span style="color: #24292E">])]</span></span>
<span class="line"><span style="color: #24292E">ax1.plot(x, df[</span><span style="color: #032F62">&quot;train_loss&quot;</span><span style="color: #24292E">], </span><span style="color: #E36209">label</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;Train&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">ax1.plot(x, df[</span><span style="color: #032F62">&quot;val_loss&quot;</span><span style="color: #24292E">], </span><span style="color: #E36209">label</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;Val&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">ax2.plot(x, df[</span><span style="color: #032F62">&quot;val_accuracy&quot;</span><span style="color: #24292E">])</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">ax1.set_xlabel(</span><span style="color: #032F62">&quot;Epochs&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">ax1.set_ylabel(</span><span style="color: #032F62">&quot;Loss&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">ax1.legend()</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">ax2.set_xlabel(</span><span style="color: #032F62">&quot;Epochs&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">ax2.set_ylabel(</span><span style="color: #032F62">&quot;Accuracy&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #005CC5">print</span><span style="color: #24292E">(</span><span style="color: #032F62">&quot;Best loss:&quot;</span><span style="color: #24292E">, df[</span><span style="color: #032F62">&quot;val_loss&quot;</span><span style="color: #24292E">].min())</span></span>
<span class="line"><span style="color: #005CC5">print</span><span style="color: #24292E">(</span><span style="color: #032F62">&quot;Best loss epoch:&quot;</span><span style="color: #24292E">, df[</span><span style="color: #032F62">&quot;val_loss&quot;</span><span style="color: #24292E">].argmin())</span></span>
<span class="line"><span style="color: #005CC5">print</span><span style="color: #24292E">(</span><span style="color: #032F62">&quot;Best accuracy:&quot;</span><span style="color: #24292E">, df[</span><span style="color: #032F62">&quot;val_accuracy&quot;</span><span style="color: #24292E">].max())</span></span>
<span class="line"><span style="color: #005CC5">print</span><span style="color: #24292E">(</span><span style="color: #032F62">&quot;Best accuracy epoch:&quot;</span><span style="color: #24292E">, df[</span><span style="color: #032F62">&quot;val_accuracy&quot;</span><span style="color: #24292E">].argmax())</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br></div></div><p><img src="./assets/aws_batch/loss_epoch_profile2.png" alt="AWS Batch で行った MNIST モデルの学習の結果"></p>
<h2 id="並列に複数の-job-を実行する" tabindex="-1">並列に複数の Job を実行する <a class="header-anchor" href="#並列に複数の-job-を実行する" aria-label="Permalink to &quot;並列に複数の Job を実行する&quot;">&ZeroWidthSpace;</a></h2>
<p>さて，ここからが最後の仕上げである． ここまでのハンズオンで構築した AWS Batch のシステムを使って，ハイパーパラメータサーチを実際に行おう．</p>
<p>先ほど実行した <code>run_single.ipynb</code> と同じディレクトリにある <code>run_sweep.ipynb</code> を開く．</p>
<p>セル [1], [2], [3] は <code>run_single.ipynb</code> と同一である．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390"># [1]</span></span>
<span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> boto3</span></span>
<span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> argparse</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># [2]</span></span>
<span class="line"><span style="color: #768390"># AWS 認証ヘルパー ...省略...</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># [3]</span></span>
<span class="line"><span style="color: #F47067">def</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">submit_job</span><span style="color: #ADBAC7">(lr:</span><span style="color: #6CB6FF">float</span><span style="color: #ADBAC7">, momentum:</span><span style="color: #6CB6FF">float</span><span style="color: #ADBAC7">, epochs:</span><span style="color: #6CB6FF">int</span><span style="color: #ADBAC7">, profile_name</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">None</span><span style="color: #ADBAC7">):</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #768390"># ...省略...</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D"># [1]</span></span>
<span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> boto3</span></span>
<span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> argparse</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># [2]</span></span>
<span class="line"><span style="color: #6A737D"># AWS 認証ヘルパー ...省略...</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># [3]</span></span>
<span class="line"><span style="color: #D73A49">def</span><span style="color: #24292E"> </span><span style="color: #6F42C1">submit_job</span><span style="color: #24292E">(lr:</span><span style="color: #005CC5">float</span><span style="color: #24292E">, momentum:</span><span style="color: #005CC5">float</span><span style="color: #24292E">, epochs:</span><span style="color: #005CC5">int</span><span style="color: #24292E">, profile_name</span><span style="color: #D73A49">=</span><span style="color: #005CC5">None</span><span style="color: #24292E">):</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #6A737D"># ...省略...</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br></div></div><p>セル [4] の for ループを使って，グリッド状にハイパーパラメータの組み合わせを用意し， batch にジョブを投入している． ここでは 3x3=9 個のジョブを作成した．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390"># [4]</span></span>
<span class="line"><span style="color: #F47067">for</span><span style="color: #ADBAC7"> lr </span><span style="color: #F47067">in</span><span style="color: #ADBAC7"> [</span><span style="color: #6CB6FF">0.1</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">0.01</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">0.001</span><span style="color: #ADBAC7">]:</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">for</span><span style="color: #ADBAC7"> m </span><span style="color: #F47067">in</span><span style="color: #ADBAC7"> [</span><span style="color: #6CB6FF">0.5</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">0.1</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">0.05</span><span style="color: #ADBAC7">]:</span></span>
<span class="line"><span style="color: #ADBAC7">        submit_job(lr, m, </span><span style="color: #6CB6FF">100</span><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D"># [4]</span></span>
<span class="line"><span style="color: #D73A49">for</span><span style="color: #24292E"> lr </span><span style="color: #D73A49">in</span><span style="color: #24292E"> [</span><span style="color: #005CC5">0.1</span><span style="color: #24292E">, </span><span style="color: #005CC5">0.01</span><span style="color: #24292E">, </span><span style="color: #005CC5">0.001</span><span style="color: #24292E">]:</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">for</span><span style="color: #24292E"> m </span><span style="color: #D73A49">in</span><span style="color: #24292E"> [</span><span style="color: #005CC5">0.5</span><span style="color: #24292E">, </span><span style="color: #005CC5">0.1</span><span style="color: #24292E">, </span><span style="color: #005CC5">0.05</span><span style="color: #24292E">]:</span></span>
<span class="line"><span style="color: #24292E">        submit_job(lr, m, </span><span style="color: #005CC5">100</span><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br></div></div><p>セル [4] を実行したら， Batch のコンソールを開こう． 先ほどと同様に，ジョブのステータスは <code>SUBMITTED</code> &gt; <code>RUNNABLE</code> &gt; <code>STARTING</code> &gt; <code>RUNNING</code> と移り変わっていくことがわかるだろう． 最終的に 9 個のジョブがすべて <code>RUNNING</code> の状態になることを確認しよう (<a href="#fig_batch_many_parallel_jobs">figure_title</a>)． また，このとき Compute environment の <code>Desired vCPUs</code> は 4x9=36 となっていることを確認しよう (<a href="#fig_batch_many_parallel_jobs">figure_title</a>)．</p>
<p><img src="./assets/aws_batch/batch_many_parallel_jobs.png" alt="複数のジョブを同時投入したときの Batch コンソール"></p>
<p>次に，Batch のコンソールの左側のメニューから <code>Jobs</code> をクリックしてみよう． ここでは，実行中のジョブの一覧が確認することができる (<a href="#fig_batch_parallel_job_list">figure_title</a>)． ジョブのステータスでフィルタリングをすることも可能である． 9 個のジョブがどれも <code>RUNNING</code> 状態にあることが確認できるだろう．</p>
<p><img src="./assets/aws_batch/batch_parallel_job_list.png" alt="複数のジョブを同時投入したときの Job 一覧"></p>
<p>今度は EC2 コンソールを見てみよう． 左のメニューから <code>Instances</code> を選択すると， <a href="#fig_ec2_instances_list">figure_title</a> に示すような起動中のインスタンスの一覧が表示される． <code>g4dn.xlarge</code> が 9 台稼働しているのが確認できる． Batch がジョブの投下に合わせて必要な数のインスタンスを起動してくれたのだ！</p>
<p><img src="./assets/aws_batch/ec2_instances_list.png" alt="複数のジョブを同時投入したときの EC2 インスタンスの一覧"></p>
<p>ここまで確認できたら，それぞれの Job が終了するまでしばらく待とう (だいたい 10-15 分くらいで終わる)． すべてのジョブが終了すると，ダッシュボードの <code>SUCCEEDED</code> が 9 となっているはずだ． また， Compute environment の <code>Desired vCPUs</code> も 0 に落ちていることを確認しよう． 最後に EC2 コンソールに行って，すべての g4dn インスタンスが停止していることを確認しよう．</p>
<p>以上から， AWS Batch を使うことで，<strong>ジョブの投入に応じて自動的に EC2 インスタンスが起動され，ジョブの完了とともに，ただちにインスタンスの停止が行われる</strong>一連の挙動を観察することができた． 一つのジョブの完了におよそ 10 分の時間がかかるので，9 個のハイパーパラメータの組を逐次的に計算していた場合は 90 分の時間を要することになる． AWS Batch を使ってこれらの計算を並列に実行することで，ジョブ一個分の計算時間 (=10 分) ですべての計算を終えることができた！</p>
<p>さて，再び <code>run_sweep.ipynb</code> に戻ってこよう． [5] 以降のセルでは，グリッドサーチの結果を可視化している．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390"># [5]</span></span>
<span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> pandas </span><span style="color: #F47067">as</span><span style="color: #ADBAC7"> pd</span></span>
<span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> numpy </span><span style="color: #F47067">as</span><span style="color: #ADBAC7"> np</span></span>
<span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> io</span></span>
<span class="line"><span style="color: #F47067">from</span><span style="color: #ADBAC7"> matplotlib </span><span style="color: #F47067">import</span><span style="color: #ADBAC7"> pyplot </span><span style="color: #F47067">as</span><span style="color: #ADBAC7"> plt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># [6]</span></span>
<span class="line"><span style="color: #F47067">def</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">read_table_from_s3</span><span style="color: #ADBAC7">(bucket_name, key, profile_name</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">None</span><span style="color: #ADBAC7">):</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> profile_name </span><span style="color: #F47067">is</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">None</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">        session </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> boto3.Session()</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">else</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">        session </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> boto3.Session(</span><span style="color: #F69D50">profile_name</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">profile_name)</span></span>
<span class="line"><span style="color: #ADBAC7">    s3 </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> session.resource(</span><span style="color: #96D0FF">&quot;s3&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">    bucket </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> s3.Bucket(bucket_name)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    obj </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> bucket.Object(key).get().get(</span><span style="color: #96D0FF">&quot;Body&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">    df </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> pd.read_csv(obj)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">return</span><span style="color: #ADBAC7"> df</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># [7]</span></span>
<span class="line"><span style="color: #ADBAC7">grid </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> np.zeros((</span><span style="color: #6CB6FF">3</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">3</span><span style="color: #ADBAC7">))</span></span>
<span class="line"><span style="color: #F47067">for</span><span style="color: #ADBAC7"> (i, lr) </span><span style="color: #F47067">in</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">enumerate</span><span style="color: #ADBAC7">([</span><span style="color: #6CB6FF">0.1</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">0.01</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">0.001</span><span style="color: #ADBAC7">]):</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">for</span><span style="color: #ADBAC7"> (j, m) </span><span style="color: #F47067">in</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">enumerate</span><span style="color: #ADBAC7">([</span><span style="color: #6CB6FF">0.5</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">0.1</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">0.05</span><span style="color: #ADBAC7">]):</span></span>
<span class="line"><span style="color: #ADBAC7">        key </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">f</span><span style="color: #96D0FF">&quot;metrics_lr</span><span style="color: #F47067">{</span><span style="color: #ADBAC7">lr</span><span style="color: #F47067">:0.4f}</span><span style="color: #96D0FF">_m</span><span style="color: #F47067">{</span><span style="color: #ADBAC7">m</span><span style="color: #F47067">:0.4f}</span><span style="color: #96D0FF">.csv&quot;</span></span>
<span class="line"><span style="color: #ADBAC7">        df </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> read_table_from_s3(</span><span style="color: #96D0FF">&quot;simplebatch-bucket43879c71-mbqaltx441fu&quot;</span><span style="color: #ADBAC7">, key)</span></span>
<span class="line"><span style="color: #ADBAC7">        grid[i,j] </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> df[</span><span style="color: #96D0FF">&quot;val_accuracy&quot;</span><span style="color: #ADBAC7">].max()</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># [8]</span></span>
<span class="line"><span style="color: #ADBAC7">fig, ax </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> plt.subplots(</span><span style="color: #F69D50">figsize</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">6</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">6</span><span style="color: #ADBAC7">))</span></span>
<span class="line"><span style="color: #ADBAC7">ax.set_aspect(</span><span style="color: #96D0FF">&#39;equal&#39;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">c </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ax.pcolor(grid, </span><span style="color: #F69D50">edgecolors</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&#39;w&#39;</span><span style="color: #ADBAC7">, </span><span style="color: #F69D50">linewidths</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">2</span><span style="color: #ADBAC7">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F47067">for</span><span style="color: #ADBAC7"> i </span><span style="color: #F47067">in</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">range</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">3</span><span style="color: #ADBAC7">):</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">for</span><span style="color: #ADBAC7"> j </span><span style="color: #F47067">in</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">range</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">3</span><span style="color: #ADBAC7">):</span></span>
<span class="line"><span style="color: #ADBAC7">        text </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ax.text(j</span><span style="color: #F47067">+</span><span style="color: #6CB6FF">0.5</span><span style="color: #ADBAC7">, i</span><span style="color: #F47067">+</span><span style="color: #6CB6FF">0.5</span><span style="color: #ADBAC7">, </span><span style="color: #F47067">f</span><span style="color: #96D0FF">&quot;</span><span style="color: #F47067">{</span><span style="color: #ADBAC7">grid[i, j]</span><span style="color: #F47067">:0.1f}</span><span style="color: #96D0FF">&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                       </span><span style="color: #F69D50">ha</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;center&quot;</span><span style="color: #ADBAC7">, </span><span style="color: #F69D50">va</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;center&quot;</span><span style="color: #ADBAC7">, </span><span style="color: #F69D50">color</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;w&quot;</span><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D"># [5]</span></span>
<span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> pandas </span><span style="color: #D73A49">as</span><span style="color: #24292E"> pd</span></span>
<span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> numpy </span><span style="color: #D73A49">as</span><span style="color: #24292E"> np</span></span>
<span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> io</span></span>
<span class="line"><span style="color: #D73A49">from</span><span style="color: #24292E"> matplotlib </span><span style="color: #D73A49">import</span><span style="color: #24292E"> pyplot </span><span style="color: #D73A49">as</span><span style="color: #24292E"> plt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># [6]</span></span>
<span class="line"><span style="color: #D73A49">def</span><span style="color: #24292E"> </span><span style="color: #6F42C1">read_table_from_s3</span><span style="color: #24292E">(bucket_name, key, profile_name</span><span style="color: #D73A49">=</span><span style="color: #005CC5">None</span><span style="color: #24292E">):</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">if</span><span style="color: #24292E"> profile_name </span><span style="color: #D73A49">is</span><span style="color: #24292E"> </span><span style="color: #005CC5">None</span><span style="color: #24292E">:</span></span>
<span class="line"><span style="color: #24292E">        session </span><span style="color: #D73A49">=</span><span style="color: #24292E"> boto3.Session()</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">else</span><span style="color: #24292E">:</span></span>
<span class="line"><span style="color: #24292E">        session </span><span style="color: #D73A49">=</span><span style="color: #24292E"> boto3.Session(</span><span style="color: #E36209">profile_name</span><span style="color: #D73A49">=</span><span style="color: #24292E">profile_name)</span></span>
<span class="line"><span style="color: #24292E">    s3 </span><span style="color: #D73A49">=</span><span style="color: #24292E"> session.resource(</span><span style="color: #032F62">&quot;s3&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">    bucket </span><span style="color: #D73A49">=</span><span style="color: #24292E"> s3.Bucket(bucket_name)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">    obj </span><span style="color: #D73A49">=</span><span style="color: #24292E"> bucket.Object(key).get().get(</span><span style="color: #032F62">&quot;Body&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">    df </span><span style="color: #D73A49">=</span><span style="color: #24292E"> pd.read_csv(obj)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">return</span><span style="color: #24292E"> df</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># [7]</span></span>
<span class="line"><span style="color: #24292E">grid </span><span style="color: #D73A49">=</span><span style="color: #24292E"> np.zeros((</span><span style="color: #005CC5">3</span><span style="color: #24292E">,</span><span style="color: #005CC5">3</span><span style="color: #24292E">))</span></span>
<span class="line"><span style="color: #D73A49">for</span><span style="color: #24292E"> (i, lr) </span><span style="color: #D73A49">in</span><span style="color: #24292E"> </span><span style="color: #005CC5">enumerate</span><span style="color: #24292E">([</span><span style="color: #005CC5">0.1</span><span style="color: #24292E">, </span><span style="color: #005CC5">0.01</span><span style="color: #24292E">, </span><span style="color: #005CC5">0.001</span><span style="color: #24292E">]):</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">for</span><span style="color: #24292E"> (j, m) </span><span style="color: #D73A49">in</span><span style="color: #24292E"> </span><span style="color: #005CC5">enumerate</span><span style="color: #24292E">([</span><span style="color: #005CC5">0.5</span><span style="color: #24292E">, </span><span style="color: #005CC5">0.1</span><span style="color: #24292E">, </span><span style="color: #005CC5">0.05</span><span style="color: #24292E">]):</span></span>
<span class="line"><span style="color: #24292E">        key </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #D73A49">f</span><span style="color: #032F62">&quot;metrics_lr</span><span style="color: #005CC5">{</span><span style="color: #24292E">lr</span><span style="color: #D73A49">:0.4f</span><span style="color: #005CC5">}</span><span style="color: #032F62">_m</span><span style="color: #005CC5">{</span><span style="color: #24292E">m</span><span style="color: #D73A49">:0.4f</span><span style="color: #005CC5">}</span><span style="color: #032F62">.csv&quot;</span></span>
<span class="line"><span style="color: #24292E">        df </span><span style="color: #D73A49">=</span><span style="color: #24292E"> read_table_from_s3(</span><span style="color: #032F62">&quot;simplebatch-bucket43879c71-mbqaltx441fu&quot;</span><span style="color: #24292E">, key)</span></span>
<span class="line"><span style="color: #24292E">        grid[i,j] </span><span style="color: #D73A49">=</span><span style="color: #24292E"> df[</span><span style="color: #032F62">&quot;val_accuracy&quot;</span><span style="color: #24292E">].max()</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># [8]</span></span>
<span class="line"><span style="color: #24292E">fig, ax </span><span style="color: #D73A49">=</span><span style="color: #24292E"> plt.subplots(</span><span style="color: #E36209">figsize</span><span style="color: #D73A49">=</span><span style="color: #24292E">(</span><span style="color: #005CC5">6</span><span style="color: #24292E">,</span><span style="color: #005CC5">6</span><span style="color: #24292E">))</span></span>
<span class="line"><span style="color: #24292E">ax.set_aspect(</span><span style="color: #032F62">&#39;equal&#39;</span><span style="color: #24292E">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">c </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ax.pcolor(grid, </span><span style="color: #E36209">edgecolors</span><span style="color: #D73A49">=</span><span style="color: #032F62">&#39;w&#39;</span><span style="color: #24292E">, </span><span style="color: #E36209">linewidths</span><span style="color: #D73A49">=</span><span style="color: #005CC5">2</span><span style="color: #24292E">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D73A49">for</span><span style="color: #24292E"> i </span><span style="color: #D73A49">in</span><span style="color: #24292E"> </span><span style="color: #005CC5">range</span><span style="color: #24292E">(</span><span style="color: #005CC5">3</span><span style="color: #24292E">):</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">for</span><span style="color: #24292E"> j </span><span style="color: #D73A49">in</span><span style="color: #24292E"> </span><span style="color: #005CC5">range</span><span style="color: #24292E">(</span><span style="color: #005CC5">3</span><span style="color: #24292E">):</span></span>
<span class="line"><span style="color: #24292E">        text </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ax.text(j</span><span style="color: #D73A49">+</span><span style="color: #005CC5">0.5</span><span style="color: #24292E">, i</span><span style="color: #D73A49">+</span><span style="color: #005CC5">0.5</span><span style="color: #24292E">, </span><span style="color: #D73A49">f</span><span style="color: #032F62">&quot;</span><span style="color: #005CC5">{</span><span style="color: #24292E">grid[i, j]</span><span style="color: #D73A49">:0.1f</span><span style="color: #005CC5">}</span><span style="color: #032F62">&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                       </span><span style="color: #E36209">ha</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;center&quot;</span><span style="color: #24292E">, </span><span style="color: #E36209">va</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;center&quot;</span><span style="color: #24292E">, </span><span style="color: #E36209">color</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;w&quot;</span><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br><span class="line-number">36</span><br><span class="line-number">37</span><br><span class="line-number">38</span><br></div></div><p>最終的に出力されるプロットが <a href="#fig_grid_search_result">figure_title</a> である．</p>
<p><img src="./assets/aws_batch/grid_search_result.png" alt="ハイパーパラメータのグリッドサーチの結果"></p>
<p>このプロットから，差は僅かであるが，学習率が 0.1 のときに精度は最大となることがわかる． また，学習率 0.1 のときはモメンタムを変えても大きな差は生じないことが見て取れる．</p>
<p>今回のパラメータサーチは勉強用に極めて単純化されたものである点は承知いただきたい．</p>
<p>たとえば，今回は学習率が 0.1 が最も良いとされたが，それは訓練のエポックを 100 に限定しているからかもしれない． 学習率が低いとその分訓練に必要なエポック数も多くなる． 訓練のエポック数をもっと増やせばまた違った結果が観察される可能性はある．</p>
<p>また，今回は MNIST の訓練データ 60,000 枚のうち， 48,000 枚を訓練データ，残り 12,000 枚を検証データとして用いた． この分割は乱数を固定してランダムに行ったが，もしこの分割によるデータのバイアスを気にするならば， k 個の異なる学習・検証データの分割をあらかじめ用意して，複数回モデルの評価を行う (<strong>k-fold cross-validation</strong>) 方法も，より精緻なアプローチとして考えられる．</p>
<p>以上のようにして， CNN を用いた MNIST 分類モデルのハイパーパラメータの最適化の一連の流れを体験した． AWS Batch を利用することで，比較的少ないプログラミングで，動的に EC2 クラスターを制御し，並列にジョブを処理するシステムが構築できた． ここまで EC2 を使いこなすことができれば，多くの問題を自力で解くことが可能になるだろう！</p>
<h2 id="スタックの削除-2" tabindex="-1">スタックの削除 <a class="header-anchor" href="#スタックの削除-2" aria-label="Permalink to &quot;スタックの削除&quot;">&ZeroWidthSpace;</a></h2>
<p>これにて，本ハンズオンは終了である．最後にスタックを削除しよう． 今回のスタックを削除するにあたり，ECR に配置された Docker のイメージは手動で削除されなければならない (これをしないと， <code>cdk destroy</code> を実行したときにエラーになってしまう． これは CloudFormation の仕様なので従うしかない)．</p>
<p>ECR の Docker image を削除するには， ECR のコンソールに行き，イメージが配置されたレポジトリを開く． そして，画面右上の <code>DELETE</code> ボタンを押して削除する (<a href="#fig_delete_ecr">figure_title</a>)．</p>
<p><img src="./assets/aws_batch/delete_ecr.png" alt="ECR から Docker image を削除する"></p>
<p>あるいは， AWS CLI から同様の操作を行うには，以下のコマンドを用いる (<code>XXXX</code> は自分の ECR レポジトリ名に置き換える)．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ecr</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">batch-delete-image</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--repository-name</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">XXXX</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--image-ids</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">imageTag=latest</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">aws</span><span style="color: #24292E"> </span><span style="color: #032F62">ecr</span><span style="color: #24292E"> </span><span style="color: #032F62">batch-delete-image</span><span style="color: #24292E"> </span><span style="color: #005CC5">--repository-name</span><span style="color: #24292E"> </span><span style="color: #032F62">XXXX</span><span style="color: #24292E"> </span><span style="color: #005CC5">--image-ids</span><span style="color: #24292E"> </span><span style="color: #032F62">imageTag=latest</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>image の削除が完了したうえで，次のコマンドでスタックを削除する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cdk</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">destroy</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cdk</span><span style="color: #24292E"> </span><span style="color: #032F62">destroy</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>(#sec:batch_development_and_debug) === クラウドを用いた機械学習アプリケーションの開発とデバッグ</p>
<p>本章で紹介したハンズオンでは， AWS Batch を使用することでニューラルネットの学習を複数並列に実行し，高速化を実現した． 本章の最後の話題として，クラウドを用いた機械学習アプリケーションの開発とデバッグの方法について述べよう．</p>
<p>ローカルに GPU を搭載した強力なマシンがなく，クラウドを利用する予算が確保されているのであれば， <a href="#fig:cloud_development">figure_title</a> のような開発のスキームが理想的であると考える． 最初の段階では， <a href="#sec_jupyter_and_deep_learning">Hands-on #2: AWS でディープラーニングを実践</a> で見たような方法で， GPU 搭載型の EC2 インスタンスを作成し， Jupyter Notebook などのインタラクティブな環境で様々なモデルを試し実験を行う． Jupyter である程度アプリケーションが完成してきたタイミングで，作成したアプリケーションを Docker イメージにパッケージングする． そして， EC2 上で <code>docker run</code> を行い，作成したイメージがバグなく動作するか確認を行う． その次に，ハイパーパラメータの最適化などのチューニングを， <a href="#sec_aws_batch">Hands-on #4: AWS Batch を使って機械学習のハイパーパラメータサーチを並列化する</a> のハンズオンで学んだ AWS Batch などの計算システムを利用して行う． よい深層学習モデルが完成したら，仕上げに大規模データへの推論処理を行うシステムを <a href="#sec_fargate_qabot">Hands-on #3: AWS で自動質問回答ボットを走らせる</a> を参考に構築する．</p>
<p>実際，本書ではこの流れに沿って演習を進めてきた． MNIST タスクを解くモデルを，最初 Jupyter Notebook を使用して実験し，そのコードをほとんどそのまま Docker にパッケージし， AWS Batch を用いてハイパーパラメータサーチを行った． このサイクルを繰り返すことで，クラウドを最大限に活用した機械学習アプリケーションの開発を進めることができる．</p>
<p><img src="./assets/aws_batch/cloud_development.png" alt="クラウドを活用した機械学習アプリケーションの開発フロー"></p>
<h2 id="小括-1" tabindex="-1">小括 <a class="header-anchor" href="#小括-1" aria-label="Permalink to &quot;小括&quot;">&ZeroWidthSpace;</a></h2>
<p>ここまでが，本書第二部の内容である． 第一部に引き続き盛りだくさんの内容であったが，ついてこれたであろうか？</p>
<p>第二部ではまず最初に，深層学習の計算をクラウドで実行するため， GPU 搭載型の EC2 インスタンスの起動について解説した． さらに，ハンズオンでは，クラウドに起動した仮想サーバーを使って MNIST 文字認識タスクを解くニューラルネットを訓練した (<a href="#sec_jupyter_and_deep_learning">Hands-on #2: AWS でディープラーニングを実践</a>)．</p>
<p>また，より大規模な機械学習アプリケーションを作るための手段として， Docker と ECS によるクラスターの初歩を説明した (<a href="#sec_docker_introduction">Docker 入門</a>)． その応用として，英語で与えられた文章問題への回答を自動で生成するボットをクラウドに展開した (<a href="#sec_fargate_qabot">Hands-on #3: AWS で自動質問回答ボットを走らせる</a>)． タスクの投入に応じて動的に計算リソースが作成・削除される様子を実際に体験できただろう．</p>
<p>さらに， <a href="#sec_aws_batch">Hands-on #4: AWS Batch を使って機械学習のハイパーパラメータサーチを並列化する</a> では AWS Batch を用いてニューラルネットの学習を並列に実行する方法を紹介した． ここで紹介した方法は，ミニマムであるが，計算機システムを大規模化していくためのエッセンスが網羅されている． これらのハンズオン体験から，クラウド技術を応用してどのように現実世界の問題を解いていくのか，なんとなくイメージが伝わっただろうか？</p>
<p>本書の第三部では，さらにレベルアップし，サーバーレスアーキテクチャという最新のクラウドの設計手法について解説する． その応用として，ハンズオンでは簡単な SNS サービスをゼロから実装する． 引き続きクラウドの最先端の世界を楽しんでいこう！</p>
<h1 id="web-サービスの作り方" tabindex="-1">Web サービスの作り方 <a class="header-anchor" href="#web-サービスの作り方" aria-label="Permalink to &quot;Web サービスの作り方&quot;">&ZeroWidthSpace;</a></h1>
<p>ここからが，本書第三部の内容になる． これまでのセクションでは，仮想サーバーをクラウド上に起動し，そこで計算を走らせる方法について解説をしてきた． EC2, ECS, Fargate, Batch などを利用して，動的にスケールするクラスターを構成し，並列にタスクを実行するクラウドシステムを実装してきた． 振り返ると，これまで紹介してきた内容は，<strong>自分自身が行いたい計算をクラウドを駆使することで実現する</strong>，という用途にフォーカスしていたことに気がつくだろう． 一方で，<strong>広く一般の人々に使ってもらえるような計算サービス・データベース</strong>を提供する，というのもクラウドの重要な役割として挙げられる．</p>
<p>本章から始まる第三部では，前回までとは少し方向性を変え，どのようにしてクラウド上にアプリケーションを展開し，広く一般の人に使ってもらうか，という点を講義したいと思う． これを通じて，どのようにして世の中のウェブサービスができ上がっているのかを知り，さらにどうやって自分でそのようなアプリケーションをゼロから構築するのか，という点を学んでもらう． その過程で，サーバーレスアーキテクチャという最新のクラウド設計手法を解説する．</p>
<p>その前準備として，本章ではどのようにしてウェブサービスが出来上がっているのか，その背後にある技術の概要を解説する． 用語の解説が中心となるが，後のハンズオンを実装するために必須の知識であるので，理解して前に進むよう心がけよう．</p>
<h2 id="ウェブサービスの仕組み-—-twitter-を例に" tabindex="-1">ウェブサービスの仕組み  — Twitter を例に <a class="header-anchor" href="#ウェブサービスの仕組み-—-twitter-を例に" aria-label="Permalink to &quot;ウェブサービスの仕組み  — Twitter を例に&quot;">&ZeroWidthSpace;</a></h2>
<p>あなたがパソコンやスマートフォンから Twitter, Facebook, YouTube などのウェブサービスにアクセスしたとき，実際にどのようなことが行われ，コンテンツが提示されているのだろうか？</p>
<p>HTTP を通じたサーバーとクライアントのデータのやり取りは，すでに知っている読者も多いだろうし，逆にすべて解説しようとすると紙面が足りないので，ここではエッセンスの説明のみにとどめる． 以降では <a href="https://twitter.com" target="_blank" rel="noreferrer">Twitter</a> を具体例として，背後にあるサーバーとクライアントの間の通信を概説しよう． 概念図としては <a href="#fig:web_server">figure_title</a> のような通信がクライアントとサーバーの間で行われていることになる．</p>
<p><img src="./assets/web_server.png" alt="クライアントと Web サーバーの通信の概念図"></p>
<p>前提として，クライアントとサーバーの通信は <strong>HTTP (Hypertext Transfer Protocol)</strong> を使って行われる． また，最近では，暗号化された HTTP である <strong>HTTPS (HTTPS (Hypertext Transfer Protocol Secure))</strong> を用いることがスタンダードになってきている． 第一のステップとして，クライアントは HTTP(S) 通信によってサーバーから静的なコンテンツを取得する． 静的なコンテンツとは， <strong>HTML (Hyptertext Markup Language)</strong> で記述されたウェブページの文書本体， <strong>CSS (Cascading Style Sheets)</strong> で記述されたページのデザインやレイアウトファイル，そして <strong>JavaScript (JS)</strong> で記述されたページの動的な挙動を定義したプログラム，が含まれる． Twitter を含む現代的なウェブアプリケーションの設計では，この静的なファイル群はページの”枠”を定義するだけで，中身となるコンテンツ (例: ツイートの一覧) は別途 <strong>API (Application Programming Interface)</strong> によって取得されなければならない． そこで，クライアントは先のステップで取得された JavaScript で定義されたプログラムに従って，サーバーに API を送信し，ツイートや画像データを取得する． この際，テキストデータのやり取りには <strong>JSON (JavaScript Object Notation)</strong> というフォーマットが用いられることが多い． 画像や動画などのコンテンツも同様に API により取得される． このようにして取得されたテキストや画像が，HTML の文書に埋め込まれることで，最終的にユーザーに提示されるページが完成するのである． また，新しいツイートを投稿するときにも，クライアントから API を通じてサーバーのデータベースにデータが書き込まれる．</p>
<h2 id="rest-api" tabindex="-1">REST API <a class="header-anchor" href="#rest-api" aria-label="Permalink to &quot;REST API&quot;">&ZeroWidthSpace;</a></h2>
<p>API (Application Programming Interface) とはこれまで何度も出てきた言葉であるが，ここではよりフォーマルな定義付けを行う． API とはあるソフトウェア・アプリケーションが，外部のソフトウェアに対してコマンドやデータをやり取りするための媒介の一般的総称である． とくに，ウェブサービスの文脈では，サーバーが外界に対して提示しているコマンドの一覧のことを意味する． クライアントは，提示されている API から適切なコマンドを使うことによって，所望のデータを取得したり，あるいはサーバーにデータを送信したりする．</p>
<p>とくに，ウェブの文脈では <strong>REST (Representational State Transfer)</strong> とよばれる設計思想に基づいた API が現在では最も一般的に使われている． REST の設計指針に従った API のことを <strong>REST API</strong> あるいは <strong>RESTful API</strong> とよんだりする．</p>
<p>REST API は， <a href="#rest_api">figure_title</a> に示したような <strong>Method</strong> と <strong>URI (Universal Resource Identifier)</strong> の組からなる．</p>
<p><img src="./assets/rest_api.png" alt="REST API"></p>
<p>Method (メソッド) とは，どのような操作を行いたいかを抽象的に表す，<strong>&quot;動詞&quot;</strong> として捉えることができる． メソッドには HTTP 規格で定義された 9 個の動詞 (verb) を使用することができる． この中でも， <code>GET</code>, <code>POST</code>, <code>PUT</code>, <code>PATCH</code>, <code>DELETE</code> の 5 個が最も頻繁に使用される (<a href="#tab:rest_api_methods">table_title</a>)． この 5 つのメソッドによる操作を総称して <strong>CRUD</strong> (create, read, update, and delete) とよぶ．</p>
<table><caption>REST API Methods</caption><colgroup><col style="width: 25%" /><col style="width: 75%" /></colgroup><thead><tr class="header"><th>メソッド</th><th>意図される動作</th></tr></thead><tbody><tr class="odd"><td><p>GET</p></td><td><p>要素を取得する</p></td></tr><tr class="even"><td><p>POST</p></td><td><p>新しい要素を作成する</p></td></tr><tr class="odd"><td><p>PUT</p></td><td><p>既存の要素を新しい要素と置き換える</p></td></tr><tr class="even"><td><p>PATCH</p></td><td><p>既存の要素の一部を更新する</p></td></tr><tr class="odd"><td><p>DELETE</p></td><td><p>要素を削除する</p></td></tr></tbody></table>
<p>一方， URI は操作が行われる対象，すなわち <strong>&quot;目的語&quot;</strong> を表す． ウェブの文脈では操作が行われる対象のことをしばしば <strong>リソース</strong> とよぶ． URI は多くの場合 http または https から始まるウェブサーバーのアドレスから始まり， / (スラッシュ) 以降に所望のリソースのパスが指定される． <a href="#rest_api">figure_title</a> の例で言えば， <code>https://api.twitter.com</code> というアドレスの <code>/1.1/status/home_timeline</code> というリソースを取得 (GET) せよ，という意味になる (なお，ここで <code>1.1</code> という数字は API のバージョンを示している)． この API リクエストによって，ユーザーのホームのタイムラインのツイートの一覧が取得される．</p>
<p>REST API のメソッドには， <a href="#tab:rest_api_methods">table_title</a> で挙げたもの以外に， HTTP プロトコルで定義されているほかのメソッド (OPTIONS, TRACE など) を用いることもできるが，あまり一般的ではない．</p>
<p>また，これらのメソッドだけでは動詞として表現しきれないこともあるが， URI の名前でより意味を明確にすることもある． メソッドの使い方も，要素を削除する際は必ず <code>DELETE</code> を使わなければならない，という決まりもなく，たとえば， Twitter API でツイートを消す API は <code>POST statuses/destroy/:id</code> で定義されている． 最終的には，各ウェブサービスが公開している API ドキュメンテーションを読んで，それぞれの API がどんな操作をするのかを調べる必要がある．</p>
<p>REST の概念は 2000 年代初頭に確立され，今日の API 設計のスタンダードとなった． 一方で，ウェブのテクノロジーが進歩するにつれて，新たな API の設計アプローチの需要も高まっている． 近年とくに人気を集めているのが， <a href="https://graphql.org/" target="_blank" rel="noreferrer">GraphQL</a> と呼ばれる API の設計方法である． GraphQL は Facebook 社によって最初に作られ，現在は GraghQL Foundation によって維持と更新がされている． GraphQL を使用すると，クライアントは REST と比較してより柔軟性の高いデータのクエリを行うことができるなど，いくつかの利点がある． キーワードだけでも知っておくと，今後役に立つだろう．</p>
<h2 id="twitter-api" tabindex="-1">Twitter API <a class="header-anchor" href="#twitter-api" aria-label="Permalink to &quot;Twitter API&quot;">&ZeroWidthSpace;</a></h2>
<p>もう少し具体的にウェブサービスの API を体験する目的で，ここでは Twitter の API を見てみよう． Twitter が提供している API の一覧は <a href="https://developer.twitter.com/en/docs/api-reference-index" target="_blank" rel="noreferrer">Twitter の Developer Documentation</a> で見ることができる． いくつかの代表的な API を <a href="#tab_twitter_api">table_title</a> にまとめた．</p>
<table><caption>Twitter API</caption><colgroup><col style="width: 50%" /><col style="width: 50%" /></colgroup><thead><tr class="header"><th>エンドポイント</th><th>動作</th></tr></thead><tbody><tr class="odd"><td><p><code>GET statuses/home_timeline</code></p></td><td><p>ホームのタイムラインのツイートの一覧を取得する．</p></td></tr><tr class="even"><td><p><code>GET statuses/show/:id</code></p></td><td><p><code>:id</code> で指定されたツイートの詳細情報を取得する．</p></td></tr><tr class="odd"><td><p><code>GET search</code></p></td><td><p>ツイートの検索を実行する．</p></td></tr><tr class="even"><td><p><code>POST statuses/update</code></p></td><td><p>新しいツイートを投稿する．</p></td></tr><tr class="odd"><td><p><code>POST media/upload</code></p></td><td><p>画像をアップロードする</p></td></tr><tr class="even"><td><p><code>POST statuses/destroy/:id</code></p></td><td><p><code>:id</code> で指定されたツイートを削除する．</p></td></tr><tr class="odd"><td><p><code>POST statuses/retweet/:id</code></p></td><td><p><code>:id</code> で指定されたツイートをリツイートする．</p></td></tr><tr class="even"><td><p><code>POST statuses/unretweet/:id</code></p></td><td><p><code>:id</code> で指定されたツイートのリツイートを取り消す．</p></td></tr><tr class="odd"><td><p><code>POST favorites/create</code></p></td><td><p>選択したツイートを"いいね"する．</p></td></tr><tr class="even"><td><p><code>POST favorites/destroy</code></p></td><td><p>選択したツイートを"いいね"を取り消す．</p></td></tr></tbody></table>
<p>この API リストをもとに， Twitter のアプリまたはウェブサイトを開いたときに起こるクライアントとサーバーの通信をシミュレートしてみよう．</p>
<p>ユーザーが Twitter を開くと，まず最初に <code>GET statuses/home_timeline</code> の API リクエストによって，ユーザーのホームのタイムラインのツイートのリストが取得される． 個々のツイートは JSON 形式のデータになっており， <code>id</code>, <code>text</code>, <code>user</code>, <code>coordinates</code>, <code>entities</code> などの属性を含む． <code>id</code> はツイートに固有な ID を表し， <code>text</code> はツイートの本文を含んでいる． <code>user</code> はツイートを投稿したユーザーの名前やプロフィール画像の URL などを含んだ JSON データになっている． <code>coordinates</code> にはツイートが発信された地理的な座標が記録されている． また， <code>entities</code> にはツイートに関連するメディアファイル (画像など) のリンクなどの情報が埋め込まれている． <code>GET statuses/home_timeline</code> からは直近のツイートのリスト (リストが長すぎる場合は途中で切られたもの) が取得される． もしツイートの ID を知っている場合は <code>GET statuses/show/:id</code> を呼ぶことによって， <code>:id</code> パラメータで指定された特定のツイートを取得することができる．</p>
<p>ツイートの検索を行うためには <code>GET search</code> API を使用する． この API には，ツイートに含まれる単語や，ハッシュタグ，ツイートの発信された日時や場所など，様々なクエリの条件を渡すことができる． API からは， <code>GET statuses/home_timeline</code> などと同様， JSON 形式のツイートのデータが返される．</p>
<p>ユーザーが新しいツイートを投稿するには <code>POST statuses/update</code> のエンドポイントを利用する． <code>POST statuses/update</code> には，ツイートの文章や，リプライの場合はリプライ先のツイートの ID などのデータを送信する． また，ツイートに画像データを添付したい場合は， <code>POST media/upload</code> を併せて使用する． ツイートの削除を行うには， <code>POST statuses/destroy/:id</code> を用いる．</p>
<p>そのほか，頻繁に行われる操作としては， <code>POST statuses/retweet/:id</code> と <code>POST statuses/unretweet/:id</code> がある． これらは， <code>:id</code> で指定されるツイートに対して，それぞれリツイートを実行あるいは取り消すための API である． また， <code>POST favorites/create</code>，<code>POST favorites/destroy</code> を使用することによって，選択されたツイートに&quot;いいね&quot;を追加したり，取り消したりする操作を行う．</p>
<p>このような一連の操作が， Twitter のアプリの背後では行われている． また，自分自身でボットを作成したい場合は，これらの API を適切に組み合わせ，カスタムのプログラムを書くことで実現される．</p>
<p>このように， API はあらゆるウェブサービスを作るうえで一番基礎となる要素である． 次からの章では本章で紹介した用語が何度も出てくるので，頭の片隅に置いたうえで読み進めていただきたい．</p>
<h1 id="serverless-architecture" tabindex="-1">Serverless architecture <a class="header-anchor" href="#serverless-architecture" aria-label="Permalink to &quot;Serverless architecture&quot;">&ZeroWidthSpace;</a></h1>
<p>サーバーレスアーキテクチャ (Serverless architecture) あるいは サーバーレスコンピューティング (Serverless computing) とは，従来とは全く異なるアプローチに基づくクラウドシステムの設計方法である． 歴史的には， AWS が 2014 年に発表した <a href="https://aws.amazon.com/lambda/" target="_blank" rel="noreferrer">Lamba</a> がサーバーレスアーキテクチャの先駆けとされている． その後， Google や Microsoft などのクラウドプラットフォームも同様の機能の提供を開始している． サーバーレスアーキテクチャの利点は，スケーラブルなクラウドシステムを安価かつ簡易に作成できる点であり，近年いたるところで導入が進んでいる．</p>
<p>Serverless とは，文字どおりの意味としてはサーバーなしで計算をするということになるが，それは一体どういう意味だろうか？ サーバーレスについて説明するためには，まずは従来的な， &quot;serverful&quot; とよばれるようなシステムについて解説しなければならない．</p>
<h2 id="serverful-クラウド-従来型" tabindex="-1">Serverful クラウド (従来型) <a class="header-anchor" href="#serverful-クラウド-従来型" aria-label="Permalink to &quot;Serverful クラウド (従来型)&quot;">&ZeroWidthSpace;</a></h2>
<p>従来的なクラウドシステムのスケッチを <a href="#serverful">figure_title</a> に示す． クライアントから送信されたリクエストは，最初に API サーバーに送られる． API サーバーでは，リクエストの内容に応じてタスクが実行される． タスクには，API サーバーだけで完結できるものもあるが，多くの場合，データベースの読み書きが必要である． データベースには，データベース専用の独立したサーバーマシンが用いられることが一般的である． また，画像や動画などの容量の大きいデータは，また別のストレージサーバーに保存されることが多い． これらの API サーバー，データベースサーバー，ストレージサーバーはそれぞれ独立したサーバーマシンであり， AWS の言葉では EC2 による仮想インスタンスを想定してもらったらよい．</p>
<p>多くのウェブサービスでは，多数のクライアントからのリクエストを処理するため，複数のサーバーマシンがクラウド内で起動し，負荷を分散するような設計がなされている． クライアントから来たリクエストを計算容量に余裕のあるサーバーに振り分けるような操作を <strong>Load balancing</strong> とよび，そのような操作を担当するマシンのことを <strong>Load balancer</strong> という．</p>
<p>計算負荷を分散する目的で多数のインスタンスを起動するのはよいのだが，計算負荷が小さすぎてアイドリング状態にあるようではコストと電力の無駄遣いである． したがって，すべてのサーバーが常に目標とする計算負荷を維持するよう，計算の負荷に応じてクラスター内の仮想サーバーの数を動的に増減させるような仕組みが必要である． そのような仕組みを<strong>クラスターのスケーリング</strong>とよび，負荷の増大に応答して新しい仮想インスタンスをクラスターに追加する操作を <strong>scale-out</strong>，負荷の減少に応答してインスタンスをシャットダウンする操作を <strong>scale-in</strong> とよぶ． クラスターのスケーリングは， API サーバーではもちろんのこと，データベースサーバー・ストレージサーバーでも必要になる． ストレージサーバーでは，例えば頻繁にアクセスされるデータはキャッシュ領域に保存したり，データのコピーを複数作るなどのスケーリングが行われる． データベースサーバーも同様に，頻繁にアクセスされるデータのアクセスがパンクしてしまわないよう，分散的な処理が必要となる． このように，<strong>クラウドシステム内すべての箇所で，負荷が均一になるような調整が必要であり，開発者は多くの時間をそのチューニングに費やさなければならない．</strong> また，サービスの利用者の数などに応じてスケーリングの設定は常に見直される必要があり，継続的な開発が要求される．</p>
<p>さらに問題を複雑にするのは，API サーバーで処理されるべきタスクが，非一様な点である． 非一様であるとは，たとえばタスク A は 3000 ミリ秒の実行時間と 512MB のメモリーを消費し，別のタスク B は 1000 ミリ秒の実行時間と 128MB のメモリーを消費する，というような状況を指している． 一つのサーバーマシンが計算負荷が異なる複数のタスクを処理する場合，クラスターのスケーリングはより複雑になる． この状況をシンプルにするために，１サーバーで実行するタスクは１種類に限る，という設計も可能であるが，そうするとで生まれる弊害も多い (ほとんど使われないタスクに対してもサーバー一台をまるまる割り当てなければならない = ほとんどアイドリング状態になってしまう，など)．</p>
<p><img src="./assets/serverful.png" alt="Serverful なクラウドシステム"></p>
<h2 id="serverless-クラウドへ" tabindex="-1">Serverless クラウドへ <a class="header-anchor" href="#serverless-クラウドへ" aria-label="Permalink to &quot;Serverless クラウドへ&quot;">&ZeroWidthSpace;</a></h2>
<p><a href="#chap_serverful_cloud">Serverful クラウド (従来型)</a> で議論したように，クラスターのスケーリングはクラウドシステムの経済的効率とシステムの安定性を最大化するために必須の作業である． それを反映して，多くの開発者の時間が投資されてきた．</p>
<p>クラスターのスケーリングはすべての開発者が何度も繰り返し行ってきた作業であり，いくつかの側面をテンプレート化し，共通化することができたならば開発のコストを大幅に削減できるだろう． それを実現するには，根本的なレベルからクラウドシステムの設計を考え直す必要がある． <strong>スケーリングを前提</strong>として考えることで，もっと<strong>シンプルで見通しがよいクラウドシステムの設計の仕組みはないだろうか</strong>？ そのような動機が，サーバーレスアーキテクチャが誕生する背後にあった．</p>
<p>従来の serverful なシステムでの最大の問題点は，<strong>サーバーをまるまる占有してしまう</strong>という点にある． すなわち， EC2 インスタンスを起動したとき，そのインスタンスは起動したユーザーだけが使えるものであり，<strong>計算のリソース (CPU や RAM) が独占的に割り当てられた状態</strong>になる． 固定した計算資源の割り当てがされてしまっているので，<strong>インスタンスの計算負荷が 0%であろうが 100%であろうが，均一の使用料金が起動時間に比例</strong>して発生する．</p>
<p>サーバーレスアーキテクチャは，このような <strong>独占的に割り当てられた計算リソースというものを完全に廃止する</strong>ことを出発点とする． サーバーレスアーキテクチャでは，計算のリソースは，クラウドプロバイダーがすべて管理する． クライアントは，仮想インスタンスを一台まるごと借りるのではなく，計算のタスクの需要が生まれる毎に，<strong>実行したいプログラム・コマンドをクラウドに提出する</strong>． クラウドプロバイダーは，自身のもつ巨大な計算リソースから空きを探し，提出されたプログラムを実行し，実行結果をクライアントに返す． 言い換えると，計算リソースのスケーリングやアロケーションなどはクラウドプロバイダーが一手に引き受け，ユーザーはジョブをサブミットすることに注力する，という枠組みである． これを図示すると， <a href="#serverless">figure_title</a> のようになる．</p>
<p><img src="./assets/serverless.png" alt="従来のクラウドと Serverless クラウドの比較"></p>
<p>サーバーレスクラウドでは，スケーリングはすべてクラウドプロバイダーが引き受けるので，スケーラビリティーが保証されている． クライアントが同時に大量のタスクを送信した場合でも，クラウドプロバイダー側の独自の仕組みによってすべてのタスクが遅延なく実行される． また，サーバーレスクラウドを利用することで，<strong>クラウドのコストは実際に使用した計算の総量 (稼働時間) で決定される</strong>ことになる． これは，計算の実行総量に関わらずインスタンスの起動時間で料金が決定されていた従来のシステムと比べて大きな違いである．</p>
<p>サーバーレスクラウドは，従来のクラウドとは根本から異なったアプローチなので，コードの書き方やシステムの設計が大きく異なる． サーバーレスクラウドを開発・運用するには，サーバーレス固有の概念や用語に精通している必要がある． 以降では，実際にクラウドを動かしながら，サーバーレスをより具体的に体験していこう．</p>
<p>従来型の(仮想インスタンスをたくさん起動するような)クラウドシステムは，<strong>賃貸</strong>と似ているかもしれない． 部屋を借りるというのは，その部屋でどれだけの時間を過ごそうが，月々の家賃は一定である． 同様に，仮想サーバーも，それがどれほどの計算を行っているかに関わらず，一定の料金が時間ごとに発生する．</p>
<p>一方で，サーバーレスクラウドは，<strong>電気・水道・ガス料金</strong> と似ている． こちらは，実際に使用した量に比例して料金が決定されている． サーバーレスクラウドも，実際に計算を行った総時間で料金が決まる仕組みになっている．</p>
<h2 id="サーバーレスクラウドを構成するコンポーネント" tabindex="-1">サーバーレスクラウドを構成するコンポーネント <a class="header-anchor" href="#サーバーレスクラウドを構成するコンポーネント" aria-label="Permalink to &quot;サーバーレスクラウドを構成するコンポーネント&quot;">&ZeroWidthSpace;</a></h2>
<p>サーバーレスアーキテクチャの概要がわかってきたところで，ここでは AWS においてサーバーレスクラウドを構成する様々なコンポーネントを紹介していこう． 特に， <strong>Lambda</strong>, <strong>S3</strong>, <strong>DynamoDB</strong> を取り上げ，解説する (<a href="#fig:serverless_logos">figure_title</a>)． サーバーレスクラウドは，これらのコンポーネントを統合することで一つのシステムが出来上がる． ここでは， Lambda，S3，DynamoDB を利用する際に押さえておかなければならない知識を一通り説明しきる都合上，具体的なイメージがわきにくいかもしれない． が，続く <a href="#sec_intro_serverless">Hands-on #5: サーバーレス入門</a> でそれぞれについてハンズオン形式で演習を行うので，そこでさらに理解を深めれば大丈夫である．</p>
<p><img src="./assets/serverless_logos.png" alt="Lambda, S3, DynamoDB のアイコン"></p>
<h3 id="lambda" tabindex="-1">Lambda <a class="header-anchor" href="#lambda" aria-label="Permalink to &quot;Lambda&quot;">&ZeroWidthSpace;</a></h3>
<p>AWS でサーバーレスコンピューティングの中心を担うのが， <a href="https://aws.amazon.com/lambda/" target="_blank" rel="noreferrer">Lambda</a> である． Lambda の使い方を <a href="#lambda_workflow">figure_title</a> に図示している． Lambda の仕組みはシンプルで，まずユーザーは実行したいプログラムのコードを事前に登録しておく． プログラムは， Python, Node.js, Ruby などの主要な言語がサポートされている． Lambda に登録されたひとつひとつのプログラムを関数 (Function) とよぶ． そして，関数を実行したいときに，invoke コマンドを Lambda に送信する． Lambda では， invoke のリクエストを受け取るとただちに (数ミリセカンドから数百ミリセカンド程度の時間で) プログラムの実行を開始する． そして，実行結果をクライアントやその他の計算機に返す．</p>
<p><img src="./assets/lambda_workflow.png" alt="AWS Lambda"></p>
<p>このように，Lambda では占有された仮想インスタンスは存在せず，実行を待っているプログラムだけがある状態である． invoke のリクエストに応じて，プログラムが AWS の巨大な計算機プールのどこかに配置され，実行される． 同時に複数のリクエストが来た場合でも， AWS はそれらを実行するための計算リソースを割り当て，並列的に処理を行ってくれる． 原理上は，<strong>数千から数万のリクエストが同時に来たとしても， Lambda はそれらを同時に実行することができる</strong>． このような，占有された仮想サーバーの存在なしに，動的に関数を実行するサービスのことを総称して <strong>FaaS (Function as a Service)</strong> とよぶ．</p>
<p>Lambda ではそれぞれの関数につき， 128MB から 10240MB のメモリーを使用することができる (執筆時点の仕様)． また，実効的な CPU のパワーはメモリーの量に比例する形で割り当てられる． すなわち，タスクに割り当てたメモリーの量が多ければ多いほど，より多くの CPU リソースが割り当てられることになる (しかし， RAM と CPU パワーの具体的な換算表は AWS からは公開されていない)． 実行時間は 100 ミリ秒の単位で記録され，実行時間に比例して料金が決定される． <a href="#lambda_pricing">table_title</a> は Lambda の利用料金表である (執筆時点で <code>ap-north-east1</code> リージョンを選択した場合)．</p>
<table><caption>Lambda の料金表</caption><colgroup><col style="width: 50%" /><col style="width: 50%" /></colgroup><thead><tr class="header"><th>Memory (MB)</th><th>Price per 100ms</th></tr></thead><tbody><tr class="odd"><td><p>128</p></td><td><p>$0.0000002083</p></td></tr><tr class="even"><td><p>512</p></td><td><p>$0.0000008333</p></td></tr><tr class="odd"><td><p>1024</p></td><td><p>$0.0000016667</p></td></tr><tr class="even"><td><p>3008</p></td><td><p>$0.0000048958</p></td></tr></tbody></table>
<p>実行時間に比例する料金に追加して，リクエストを送信するごとに発生する料金が設定されている． これは，百万回のリクエストにつき $0.2 である． たとえば， 128MB のメモリーを使用する関数を，それぞれ 200 ミリ秒，合計で 100 万回実行した場合， 0.0000002083 * 2 * 10^6 + 0.2 = $0.6 の料金となる． ウェブサーバーのデータベースの更新など簡単な計算であれば，200 ミリ秒程度で実行できる関数も多いことから，100 万回データベースの更新を行ったとしても，たった $0.6 しかコストが発生しないことになる． また，コードが実行されず待機状態になっている場合は，発生する料金は 0 である． このように，実際に意味のある処理が行われた時間にのみ，料金が発生する仕組みになっている．</p>
<p>Lambda は比較的短時間で完了する，反復性の高いタスクの実行に向いている． データベースの読み書きはその典型的な例であるが，そのほかにも，画像のサイズをトリミングしたり，サーバーサイドで定期的に実行されるメンテナンス処理などの利用が考えられる． また，複数の Lambda をリレー式に繋げることも可能で，シンプルな処理を組み合わせることで複雑なロジックを表現することができる．</p>
<p>上述の Lambda の料金計算は，説明のためコストに寄与する要素をいくつか省いている点は承知いただきたい． 例えば， DynamoDB の読み書きに関する料金や，ネットワークの通信にかかわるコストが考慮されていない．</p>
<h3 id="サーバーレスストレージ-s3" tabindex="-1">サーバーレスストレージ: S3 <a class="header-anchor" href="#サーバーレスストレージ-s3" aria-label="Permalink to &quot;サーバーレスストレージ: S3&quot;">&ZeroWidthSpace;</a></h3>
<p>サーバーレスの概念は，ストレージにも拡張されている．</p>
<p>従来的なストレージ (ファイルシステム) では，必ずホストとなるマシンと OS が存在しなければならない． したがって，それほどパワーは必要ないまでも，ある程度の CPU リソースを割かなければならない． また，従来的なファイルシステムでは，データ領域のサイズは最初にディスクを初期化するときに決めなければならず，後から容量を増加させることはしばしば困難である (ZFS などのファイルシステムを使えばある程度は自由にファイルシステムのサイズを変更することは可能である)． よって，従来的なクラウドでは，ストレージを借りる際にはあらかじめディスクのサイズを指定せねばならず，ディスクの中身が空であろうと満杯であろうと，同じ利用料金が発生することになる (<a href="#fig:s3_vs_filesystem">figure_title</a>)．</p>
<p><a href="https://aws.amazon.com/s3/" target="_blank" rel="noreferrer">Simple Storage Service (S3)</a> は，サーバーレスなストレージシステムを提供する (<a href="#fig:s3_vs_filesystem">figure_title</a>)． S3 は従来的なストレージシステムと異なり， OS に&quot;マウントする”という概念はない． 基本的に API を通じてデータの読み書きの操作が行われる． また，データの冗長化や暗号化，バックアップの作成など，通常ならば OS と CPU が介在しなければならない操作も， API を通じて行うことができる． S3 では事前に決められたディスク領域のサイズはなく，データを入れれば入れた分だけ，保存領域は拡大していく (仕様上はペタバイトスケールのデータを保存することが可能である)． ストレージにかかる料金は，保存してあるデータの総容量で決定される．</p>
<p><img src="./assets/s3_vs_filesystem.png" alt="S3 と従来的なファイルシステムの比較"></p>
<p>S3 を利用する際に，料金に関わってくる主要な事項をまとめたのが <a href="#tab:s3_pricing">table_title</a> である (<code>us-east-1</code> リージョンのもの． 説明のため主要な事項のみ取り出している． 詳細は <a href="https://aws.amazon.com/s3/pricing/?nc=sn&amp;loc=4" target="_blank" rel="noreferrer">公式ドキュメンテーション &quot;Amazon S3 pricing&quot;</a> を参照)．</p>
<table><caption>S3 の利用料金</caption><colgroup><col style="width: 50%" /><col style="width: 50%" /></colgroup><thead><tr class="header"><th>項目</th><th>料金</th></tr></thead><tbody><tr class="odd"><td><p>Data storage (First 50TB)</p></td><td><p>$0.023 per GB per month</p></td></tr><tr class="even"><td><p>PUT, COPY, POST, LIST requests (per 1,000 requests)</p></td><td><p>$0.005</p></td></tr><tr class="odd"><td><p>GET, SELECT, and all other requests (per 1,000 requests)</p></td><td><p>$0.0004</p></td></tr><tr class="even"><td><p>Data Transfer IN To Amazon S3 From Internet</p></td><td><p>$0</p></td></tr><tr class="odd"><td><p>Data Transfer OUT From Amazon S3 To Internet</p></td><td><p>$0.09 per GB</p></td></tr></tbody></table>
<p>第一に，データの保存には $0.025 per GB のコストが月ごとに発生する． したがって，1000GB のデータを S3 に一ヵ月保存した場合， $25 の料金が発生することになる． また，<code>PUT</code>, <code>COPY</code>, <code>POST</code> などのリクエスト (=データを書き込む操作) に対しては，データ容量に関係なく，1000 回ごとに $0.005 のコストが発生する． <code>GET</code>, <code>SELECT</code> などのリクエスト (=データを読み込む操作) に対しては，1000 回ごとに $0.0004 のコストが発生する． また， S3 はデータを外に取り出す際の通信にもコストが生じる． 執筆時点では，S3 からインターネットを通じて外部にデータを転送 (data-out) すると $0.09 per GB のコストが発生する． データをインターネットを通じて S3 に入れる (data-in) 通信は無料で行える． また， AWS の 同じ Region 内のサービス (Lambda や EC2 など) にデータを転送するのは無料である． AWS のリージョンをまたいだデータの転送にはコストが発生する． いずれにせよ，サーバーレスの概念に則り，すべての料金が従量課金制で決定される設定になっている．</p>
<h3 id="サーバーレスデータベース-dynamodb" tabindex="-1">サーバーレスデータベース: DynamoDB <a class="header-anchor" href="#サーバーレスデータベース-dynamodb" aria-label="Permalink to &quot;サーバーレスデータベース: DynamoDB&quot;">&ZeroWidthSpace;</a></h3>
<p>サーバーレスの概念は，データベースにも適用することができる．</p>
<p>ここでいうデータベースとは， Web サービスなどにおけるユーザーや商品の情報を記録しておくための保存領域のことを指している． 従来的に有名なデータベースとしては <a href="https://www.mysql.com/" target="_blank" rel="noreferrer">MySQL</a>, <a href="https://www.postgresql.org/" target="_blank" rel="noreferrer">PostgreSQL</a>, <a href="https://www.mongodb.com/" target="_blank" rel="noreferrer">MongoDB</a> などが挙げられる． データベースと普通のストレージの違いは，データの検索機能にある． 普通のストレージではデータは単純にディスクに書き込まれるだけだが， データベースでは検索がより効率的になるようなデータの配置がされたり， 頻繁にアクセスされるデータはメモリーにキャッシュされるなどの機能が備わっている． これにより，巨大なデータの中から，興味のある要素を高速に取得することができる．</p>
<p>このような検索機能を実現するには，当然 CPU の存在が必須である． したがって，従来的なデータベースを構築する際は，ストレージ領域に加えて，たくさんの CPU コアを搭載したマシンが用いられることが多い． また，データベースが巨大な場合は複数マシンにまたがった分散型のシステムが設計される． 分散型システムの場合は， <a href="#chap_serverful_cloud">Serverful クラウド (従来型)</a> で議論したようにデータベースへのアクセス負荷に応じて適切なスケーリングがなされる必要がある．</p>
<p><a href="https://aws.amazon.com/dynamodb/" target="_blank" rel="noreferrer">DynamoDB</a> は， AWS が提供しているサーバーレスな分散型データベースである． サーバーレスであるので，占有されたデータベース用仮想インスタンスは存在せず， API を通じてデータの書き込み・読み出し・検索などの操作を行う． S3 と同様に，データ保存領域の上限は定められておらず，データを入れれば入れた分だけ，保存領域は拡大していく． また，データベースへの負荷が増減したときのスケーリングは， DynamoDB が自動で行うので，ユーザーは心配する必要はない．</p>
<p>DynamoDB での利用料金の計算はやや複雑なのだが， &quot;On-demand Capacity&quot; というモードで使用した場合の料金に関わってくる主要な事項をまとめたのが <a href="#tab:dynamodb_pricing">table_title</a> である (<code>us-east-1</code> リージョンのもの． 詳細は <a href="https://aws.amazon.com/dynamodb/pricing/on-demand/" target="_blank" rel="noreferrer">公式ドキュメンテーション &quot;Pricing for On-Demand Capacity&quot;</a> を参照)．</p>
<table><caption>DynamoDB の利用料金</caption><colgroup><col style="width: 50%" /><col style="width: 50%" /></colgroup><thead><tr class="header"><th>項目</th><th>料金</th></tr></thead><tbody><tr class="odd"><td><p>Write request units</p></td><td><p>$1.25 per million write request units</p></td></tr><tr class="even"><td><p>Read request units</p></td><td><p>$0.25 per million read request units</p></td></tr><tr class="odd"><td><p>Data storage</p></td><td><p>$0.25 per GB-month</p></td></tr></tbody></table>
<p>DynamoDB ではデータの書き込み操作の単位を write request unit とよび，データの読み込み操作の単位を read request unit とよぶ． 基本的に， 1kB 以下のデータを一度書き込むと 1 write request unit を消費し，4kB 以下のデータを一度読み込むと 1 read request unit を消費する (詳しくは <a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.ReadWriteCapacityMode.html" target="_blank" rel="noreferrer">公式ドキュメンテーション &quot;Read/Write Capacity Mode&quot;</a> を参照のこと)． write request units は 100 万回ごとに $1.25, read request units は 100 万回ごとに $0.25 のコストが設定されている． また，保存されたデータ容量に対して $0.25 per GB のコストが月ごとに発生する． DynamoDB は高速な検索機能などを備えたデータベースであるので， GB あたりのストレージコストは S3 に比べ 10 倍程度高い． DynamoDB のデータの転送に関わるコストは，同じリージョン内ならば data-in，data-out ともに $0 である． リージョンをまたいだ通信には別途コストが発生する．</p>
<h3 id="その他のサーバーレスクラウドの構成要素" tabindex="-1">その他のサーバーレスクラウドの構成要素 <a class="header-anchor" href="#その他のサーバーレスクラウドの構成要素" aria-label="Permalink to &quot;その他のサーバーレスクラウドの構成要素&quot;">&ZeroWidthSpace;</a></h3>
<p>以上で紹介した Lambda, S3, DynamoDB がサーバーレスクラウドの中で最も使用する頻度が高いサービスになる． その他のサーバーレスクラウドの構成要素を以下に列挙する． いくつかについては，今後のハンズオンを行う中で改めて解説を行う．</p>
<ul>
<li>
<p><a href="https://aws.amazon.com/api-gateway/" target="_blank" rel="noreferrer">API Gateway</a>: API を構築する際のルーティングを担う． <a href="#sec_bashoutter">Hands-on #6: Bashoutter</a> で取り上げる．</p>
</li>
<li>
<p><a href="https://aws.amazon.com/fargate/" target="_blank" rel="noreferrer">Fargate</a>: <a href="#sec_fargate_qabot">Hands-on #3: AWS で自動質問回答ボットを走らせる</a> で触れた Fargate も，サーバーレスクラウドの要素の一部である． Lambda との違いは，Lambda よりも大容量のメモリーや CPU を要するような計算などを行うことができる点が挙げられる．</p>
</li>
<li>
<p><a href="https://aws.amazon.com/sns/" target="_blank" rel="noreferrer">Simple Notification Service (SNS)</a>: サーバーレスのサービス間でイベントをやり取りするためのサービス．</p>
</li>
<li>
<p><a href="https://aws.amazon.com/step-functions/" target="_blank" rel="noreferrer">Step Functions</a>: サーバーレスのサービス間のオーケストレーションを担う．</p>
</li>
</ul>
<p><strong>サーバーレスアーキテクチャは万能か？</strong></p>
<p>この問いへの答えは，筆者は NO であると考える．</p>
<p>ここまで，サーバーレスの利点を強調して説明をしてきたが，まだまだ新しい技術なだけに，欠点，あるいはサーバーフルなシステムに劣る点は数多くある．</p>
<p>大きな欠点を一つあげるとすれば，サーバーレスのシステムは各クラウドプラットフォームに固有なものなので，特定のプラットフォームでしか運用できないシステムになってしまう点であろう． AWS で作成したサーバーレスのシステムを， Google のクラウドに移植するには，かなり大掛かりなプログラムの書き換えが必要になる． 一方， serverful なシステムであれば，プラットフォーム間のマイグレーションは比較的簡単に行うことができる． クラウドプロバイダーとしては，自社のシステムへの依存度を強めることで，顧客を離さないようにするという狙いがあるのだろう…</p>
<p>その他，サーバーレスコンピューティングの欠点や今後の課題などは，次の論文で詳しく議論されている． 興味のある読者はぜひ読んでいただきたい．</p>
<ul>
<li><a href="https://arxiv.org/abs/1812.03651" target="_blank" rel="noreferrer">Hellerstein et al., &quot;Serverless Computing: One Step Forward, Two Steps Back&quot; arXiv (2018)</a></li>
</ul>
<h1 id="hands-on-5-サーバーレス入門" tabindex="-1">Hands-on #5: サーバーレス入門 <a class="header-anchor" href="#hands-on-5-サーバーレス入門" aria-label="Permalink to &quot;Hands-on \#5: サーバーレス入門&quot;">&ZeroWidthSpace;</a></h1>
<p>前章ではサーバーレスアーキテクチャの概要の説明を行った． 本章では，ハンズオン形式でサーバーレスクラウドを実際に動かしながら，具体的な使用方法を学んでいこう． 今回のハンズオンでは Lambda, S3, DynamoDB の三つのサーバーレスクラウドの構成要素に触れていく． それぞれについて，短いチュートリアルを用意してある．</p>
<h2 id="lambda-ハンズオン" tabindex="-1">Lambda ハンズオン <a class="header-anchor" href="#lambda-ハンズオン" aria-label="Permalink to &quot;Lambda ハンズオン&quot;">&ZeroWidthSpace;</a></h2>
<p>まずは， Lambda を実際に動かしてみよう． ハンズオンのソースコードは GitHub の <a href="https://github.com/andatoshiki/toshiki-notebooktree/main/handson/serverless/lambda" target="_blank" rel="noreferrer">handson/serverless/lambda</a> に置いてある．</p>
<p>このハンズオンで使用するアプリケーションのスケッチを <a href="#fig:lambda_deploy">figure_title</a> に示す． STEP 1 では，AWS CDK を使用して Python で書かれたコードを Lambda に登録する． 続いて STEP 2 では， Invoke API を使用して，同時にいくつもの Lambda を起動し，並列な計算を行う． Lambda のワークフローを体験する目的で最小限の設定である．</p>
<p><img src="./assets/handson-serverless/lambda_deploy.png" alt="Lambda チュートリアルの概要"></p>
<p>このハンズオンは，基本的に <a href="https://aws.amazon.com/free/?all-free-tier.sort-by=item.additionalFields.SortRank&amp;all-free-tier.sort-order=asc" target="_blank" rel="noreferrer">AWS Lambda の無料枠</a> の範囲内で実行することができる．</p>
<p><a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/serverless/lambda/app.py" target="_blank" rel="noreferrer">app.py</a> にデプロイするプログラムが書かれている． 中身を見てみよう．</p>
<div class="language-py vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">py</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #6CB6FF">FUNC</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;&quot;&quot;</span></span>
<span class="line"><span style="color: #96D0FF">import time</span></span>
<span class="line"><span style="color: #96D0FF">from random import choice, randint</span></span>
<span class="line"><span style="color: #96D0FF">def handler(event, context):</span></span>
<span class="line"><span style="color: #96D0FF">    time.sleep(randint(2,5))</span></span>
<span class="line"><span style="color: #96D0FF">    sushi = [&quot;salmon&quot;, &quot;tuna&quot;, &quot;squid&quot;]</span></span>
<span class="line"><span style="color: #96D0FF">    message = &quot;Welcome to Cloud Sushi. Your order is &quot; + choice(sushi)</span></span>
<span class="line"><span style="color: #96D0FF">    print(message)</span></span>
<span class="line"><span style="color: #96D0FF">    return message</span></span>
<span class="line"><span style="color: #96D0FF">&quot;&quot;&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F47067">class</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50">SimpleLambda</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">core</span><span style="color: #ADBAC7">.</span><span style="color: #6CB6FF">Stack</span><span style="color: #ADBAC7">):</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">def</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">__init__</span><span style="color: #ADBAC7">(self, scope: core.App, name: </span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">, </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">kwargs) -&gt; </span><span style="color: #6CB6FF">None</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #6CB6FF">super</span><span style="color: #ADBAC7">().</span><span style="color: #6CB6FF">__init__</span><span style="color: #ADBAC7">(scope, name, </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">kwargs)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        handler </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> _lambda.Function(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&#39;LambdaHandler&#39;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">runtime</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">_lambda.Runtime.</span><span style="color: #6CB6FF">PYTHON_3_7</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">code</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">_lambda.Code.from_inline(</span><span style="color: #6CB6FF">FUNC</span><span style="color: #ADBAC7">),</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">handler</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;index.handler&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">memory_size</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">128</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">timeout</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">core.Duration.seconds(</span><span style="color: #6CB6FF">10</span><span style="color: #ADBAC7">),</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">dead_letter_queue_enabled</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">True</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #005CC5">FUNC</span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;&quot;&quot;</span></span>
<span class="line"><span style="color: #032F62">import time</span></span>
<span class="line"><span style="color: #032F62">from random import choice, randint</span></span>
<span class="line"><span style="color: #032F62">def handler(event, context):</span></span>
<span class="line"><span style="color: #032F62">    time.sleep(randint(2,5))</span></span>
<span class="line"><span style="color: #032F62">    sushi = [&quot;salmon&quot;, &quot;tuna&quot;, &quot;squid&quot;]</span></span>
<span class="line"><span style="color: #032F62">    message = &quot;Welcome to Cloud Sushi. Your order is &quot; + choice(sushi)</span></span>
<span class="line"><span style="color: #032F62">    print(message)</span></span>
<span class="line"><span style="color: #032F62">    return message</span></span>
<span class="line"><span style="color: #032F62">&quot;&quot;&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D73A49">class</span><span style="color: #24292E"> </span><span style="color: #6F42C1">SimpleLambda</span><span style="color: #24292E">(</span><span style="color: #6F42C1">core</span><span style="color: #24292E">.</span><span style="color: #6F42C1">Stack</span><span style="color: #24292E">):</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">def</span><span style="color: #24292E"> </span><span style="color: #005CC5">__init__</span><span style="color: #24292E">(self, scope: core.App, name: </span><span style="color: #005CC5">str</span><span style="color: #24292E">, </span><span style="color: #D73A49">**</span><span style="color: #24292E">kwargs) -&gt; </span><span style="color: #005CC5">None</span><span style="color: #24292E">:</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #005CC5">super</span><span style="color: #24292E">().</span><span style="color: #005CC5">__init__</span><span style="color: #24292E">(scope, name, </span><span style="color: #D73A49">**</span><span style="color: #24292E">kwargs)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        handler </span><span style="color: #D73A49">=</span><span style="color: #24292E"> _lambda.Function(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&#39;LambdaHandler&#39;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">runtime</span><span style="color: #D73A49">=</span><span style="color: #24292E">_lambda.Runtime.</span><span style="color: #005CC5">PYTHON_3_7</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">code</span><span style="color: #D73A49">=</span><span style="color: #24292E">_lambda.Code.from_inline(</span><span style="color: #005CC5">FUNC</span><span style="color: #24292E">),</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">handler</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;index.handler&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">memory_size</span><span style="color: #D73A49">=</span><span style="color: #005CC5">128</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">timeout</span><span style="color: #D73A49">=</span><span style="color: #24292E">core.Duration.seconds(</span><span style="color: #005CC5">10</span><span style="color: #24292E">),</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">dead_letter_queue_enabled</span><span style="color: #D73A49">=</span><span style="color: #005CC5">True</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        )</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br></div></div><ul>
<li>
<p>ここで， Lambda で実行されるべき関数を定義している． これは非常に単純な関数で，2-5 秒のランダムな時間スリープした後，[&quot;salmon&quot;, &quot;tuna&quot;, &quot;squid&quot;] のいずれかの文字列をランダムに選択し， &quot;Welcome to Cloud Sushi. Your order is XXXX&quot; (XXXX は選ばれた寿司のネタ) というメッセージをリターンする．</p>
</li>
<li>
<p>次に， Lambda に &lt;1&gt; で書いた関数を配置している． パラメータの意味は，文字どおりの意味なので難しくはないが，以下に解説する．</p>
<ul>
<li>
<p><code>runtime=_lambda.Runtime.PYTHON_3_7</code>: ここでは， Python3.7 を使って上記で定義された関数を実行せよ，と指定している． Python3.7 のほかに， Node.js, Java, Ruby, Go などの言語を指定することが可能である．</p>
</li>
<li>
<p><code>code=_lambda.Code.from_inline(FUNC)</code>: 実行されるべき関数が書かれたコードを指定する． ここでは， <code>FUNC=...</code> で定義した文字列を渡しているが，文字列以外にもファイルのパスを渡すことも可能である．</p>
</li>
<li>
<p><code>handler=&quot;index.handler&quot;</code>: これは，コードの中にいくつかのサブ関数が含まれているときに，メインとサブを区別するためのパラメータである． <code>handler</code> という名前の関数をメイン関数として実行せよ，という意味である．</p>
</li>
<li>
<p><code>memory_size=128</code>: メモリーは 128MB を最大で使用することを指定している．</p>
</li>
<li>
<p><code>timeout=core.Duration.seconds(10)</code> タイムアウト時間を 10 秒に設定している． 10 秒以内に関数の実行が終了しなかった場合，エラーが返される．</p>
</li>
<li>
<p><code>dead_letter_queue_enabled=True</code>: アドバンストな設定なので説明は省略する．</p>
</li>
</ul>
</li>
</ul>
<p>上記のプログラムを実行することで， Lambda 関数がクラウド上に作成される． 早速デプロイしてみよう．</p>
<h3 id="デプロイ" tabindex="-1">デプロイ <a class="header-anchor" href="#デプロイ" aria-label="Permalink to &quot;デプロイ&quot;">&ZeroWidthSpace;</a></h3>
<p>デプロイの手順は，これまでのハンズオンとほとんど共通である． ここでは，コマンドのみ列挙する (<code>#</code> で始まる行はコメントである)． それぞれの意味を忘れてしまった場合は，ハンズオン 1, 2 に戻って復習していただきたい． シークレットキーの設定も忘れずに (<a href="#aws_cli_install">AWS CLI のインストール</a>)．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390"># プロジェクトのディレクトリに移動</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cd</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">handson/serverless/lambda</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># venv を作成し，依存ライブラリのインストールを行う</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python3</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-m</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">venv</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.env</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">source</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.env/bin/activate</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">pip</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">install</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-r</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">requirements.txt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># デプロイを実行</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cdk</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">deploy</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D"># プロジェクトのディレクトリに移動</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cd</span><span style="color: #24292E"> </span><span style="color: #032F62">handson/serverless/lambda</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># venv を作成し，依存ライブラリのインストールを行う</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python3</span><span style="color: #24292E"> </span><span style="color: #005CC5">-m</span><span style="color: #24292E"> </span><span style="color: #032F62">venv</span><span style="color: #24292E"> </span><span style="color: #032F62">.env</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">source</span><span style="color: #24292E"> </span><span style="color: #032F62">.env/bin/activate</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">pip</span><span style="color: #24292E"> </span><span style="color: #032F62">install</span><span style="color: #24292E"> </span><span style="color: #005CC5">-r</span><span style="color: #24292E"> </span><span style="color: #032F62">requirements.txt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># デプロイを実行</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cdk</span><span style="color: #24292E"> </span><span style="color: #032F62">deploy</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br></div></div><p>デプロイのコマンドが無事に実行されれば， <a href="#handson_04_lambda_cdk_output">figure_title</a> のような出力が得られるはずである． ここで表示されている <code>SimpleLambda.FunctionName = XXXX</code> の XXXX の文字列は後で使うのでメモしておこう．</p>
<p><img src="./assets/handson-serverless/handson_04_lambda_cdk_output.png" alt="CDKデプロイ実行後の出力"></p>
<p>AWS コンソールにログインして，デプロイされたスタックを確認してみよう． コンソールから，Lambda のページに行くと <a href="#handson_04_lambda_console_func_list">figure_title</a> のような画面から Lambda の関数の一覧が確認できる．</p>
<p><img src="./assets/handson-serverless/lambda_console_func_list.png" alt="Lambda コンソール - 関数の一覧"></p>
<p>今回のアプリケーションで作成したのが <code>SimpleLambda</code> で始まるランダムな名前のついた関数だ． 関数の名前をクリックして，詳細を見てみる． すると <a href="#handson_04_lambda_console_func_detail">figure_title</a> のような画面が表示されるはずだ． 先ほどプログラムの中で定義した Python の関数がエディターから確認できる． さらに下の方にスクロールすると，関数の各種設定も確認できる．</p>
<p><img src="./assets/handson-serverless/lambda_console_func_detail.png" alt="Lambda コンソール - 関数の詳細"></p>
<p>Lambda で実行されるコードは， Lambda のコンソール画面 (<a href="#handson_04_lambda_console_func_detail">figure_title</a>) のエディターで編集することもできる． デバッグをするときなどは，こちらを直接いじる方が早い場合もある． その場合は， CDK のコードに行った編集を反映させなおすことを忘れずに．</p>
<h3 id="lambda-関数の実行" tabindex="-1">Lambda 関数の実行 <a class="header-anchor" href="#lambda-関数の実行" aria-label="Permalink to &quot;Lambda 関数の実行&quot;">&ZeroWidthSpace;</a></h3>
<p>それでは，作成した Lambda 関数を実行 (invoke) してみよう． AWS の API を使うことで，関数の実行をスタートすることができる． 今回は， <a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/serverless/lambda/invoke_one.py" target="_blank" rel="noreferrer">handson/serverless/lambda/invoke_one.py</a> に関数を実行するための簡単なプログラムを提供している． 興味のある読者はコードを読んでもらいたい．</p>
<p>以下のコマンドで，Lambda の関数を実行する． コマンドの <code>XXXX</code> の部分は，先ほどデプロイしたときに <code>SimpleLambda.FunctionName = XXXX</code> で得られた XXXX の文字列で置換する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">invoke_one.py</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">XXXX</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python</span><span style="color: #24292E"> </span><span style="color: #032F62">invoke_one.py</span><span style="color: #24292E"> </span><span style="color: #032F62">XXXX</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>すると， <code>&quot;Welcome to Cloud Sushi. Your order is salmon&quot;</code> という出力が得られるはずだ． とてもシンプルではあるが，クラウド上で先ほどの関数が走り，乱数が生成されたうえで，ランダムな寿司ネタが選択されて出力が返されている． このコマンドを何度か打ってみて，実行ごとに異なる寿司ネタが返されることを確認しよう．</p>
<p>さて，このコマンドは，一度につき一回の関数を実行したわけであるが， Lambda の本領は一度に大量のタスクを同時に実行できる点である． そこで，今度は一度に 100 個のタスクを同時に送信してみよう． <a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/serverless/lambda/invoke_many.py" target="_blank" rel="noreferrer">handson/serverless/lambda/invoke_many.py</a> のスクリプトを使用する．</p>
<p>次のコマンドを実行しよう． XXXX の部分は前述と同様に置き換える． 第二引数の <code>100</code> は 100 個のタスクを投入せよ，という意味である．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">invoke_many.py</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">XXXX</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">100</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python</span><span style="color: #24292E"> </span><span style="color: #032F62">invoke_many.py</span><span style="color: #24292E"> </span><span style="color: #032F62">XXXX</span><span style="color: #24292E"> </span><span style="color: #005CC5">100</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>すると次のような出力が得られるはずだ．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #6CB6FF">....................................................................................................</span></span>
<span class="line"><span style="color: #F69D50">Submitted</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">100</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">tasks</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">to</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">Lambda!</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #005CC5">....................................................................................................</span></span>
<span class="line"><span style="color: #6F42C1">Submitted</span><span style="color: #24292E"> </span><span style="color: #005CC5">100</span><span style="color: #24292E"> </span><span style="color: #032F62">tasks</span><span style="color: #24292E"> </span><span style="color: #032F62">to</span><span style="color: #24292E"> </span><span style="color: #032F62">Lambda!</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>実際に，100 個のタスクが同時に実行されていることを確認しよう． <a href="#handson_04_lambda_console_func_detail">figure_title</a> の画面に戻り， &quot;Monitoring&quot; というタブがあるので，それをクリックする． すると， <a href="#handson_04_lambda_console_monitoring">figure_title</a> のようなグラフが表示されるだろう．</p>
<p><img src="./assets/handson-serverless/lambda_console_monitoring.png" alt="Lambda コンソール - 関数の実行のモニタリング"></p>
<p><a href="#handson_04_lambda_console_monitoring">figure_title</a> のグラフの更新には数分かかることがあるので，なにも表示されない場合は少し待つ．</p>
<p><a href="#handson_04_lambda_console_monitoring">figure_title</a> で &quot;Invocations&quot; が関数が何度実行されたかを意味している． たしかに 100 回実行されていることがわかる． さらに， &quot;Concurrent executions&quot; は何個のタスクが同時に行われたかを示している． ここでは 96 となっていることから，96 個のタスクが並列的に実行されたことを意味している (これが 100 とならないのは，タスクの開始のコマンドが送られたのが完全には同タイミングではないことに起因する)．</p>
<p>このように，非常にシンプルではあるが， Lambda を使うことで，同時並列的に処理を実行することのできるクラウドシステムを簡単に作ることができた．</p>
<p>もしこのようなことを従来的な serverful なクラウドで行おうとした場合，クラスターのスケーリングなど多くのコードを書くことに加えて，いろいろなパラメータを調節する必要がある．</p>
<p>興味がある人は，一気に 1000 個などのジョブを投入してみるとよい． Lambda はそのような大量のリクエストにも対応できることが確認できるだろう． が，あまりやりすぎると Lambda の無料利用枠を超えて料金が発生してしまうので注意．</p>
<h3 id="スタックの削除-3" tabindex="-1">スタックの削除 <a class="header-anchor" href="#スタックの削除-3" aria-label="Permalink to &quot;スタックの削除&quot;">&ZeroWidthSpace;</a></h3>
<p>最後にスタックを削除しよう． スタックを削除するには，次のコマンドを実行すればよい．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cdk</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">destroy</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cdk</span><span style="color: #24292E"> </span><span style="color: #032F62">destroy</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><h2 id="dynamodb-ハンズオン" tabindex="-1">DynamoDB ハンズオン <a class="header-anchor" href="#dynamodb-ハンズオン" aria-label="Permalink to &quot;DynamoDB ハンズオン&quot;">&ZeroWidthSpace;</a></h2>
<p>続いて， DynamoDB の簡単なチュートリアルをやってみよう． ハンズオンのソースコードは GitHub の <a href="https://github.com/andatoshiki/toshiki-notebooktree/main/handson/serverless/dynamodb" target="_blank" rel="noreferrer">/handson/serverless/dynamodb</a> に置いてある．</p>
<p>このハンズオンで使用するアプリケーションのスケッチを <a href="#fig:dynamodb_deploy">figure_title</a> に示す． STEP 1 では，AWS CDK を使用して DynamoDB のテーブルを初期化し，デプロイする． 続いて STEP 2 では， API を使用してデータベースのデータの書き込み・読み出し・削除などの操作を練習する．</p>
<p><img src="./assets/handson-serverless/dynamodb_deploy.png" alt="DynamoDB チュートリアルの概要"></p>
<p>このハンズオンは，基本的に <a href="https://aws.amazon.com/free/?all-free-tier.sort-by=item.additionalFields.SortRank&amp;all-free-tier.sort-order=asc" target="_blank" rel="noreferrer">AWS DynamoDB の無料枠</a> の範囲内で実行できる．</p>
<p><a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/serverless/dynamodb/app.py" target="_blank" rel="noreferrer">handson/serverless/dynamodb/app.py</a> にデプロイするプログラムが書かれている． 中身を見てみよう．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">class</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50">SimpleDynamoDb</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">core</span><span style="color: #ADBAC7">.</span><span style="color: #6CB6FF">Stack</span><span style="color: #ADBAC7">):</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">def</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">__init__</span><span style="color: #ADBAC7">(self, scope: core.App, name: </span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">, </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">kwargs) -&gt; </span><span style="color: #6CB6FF">None</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #6CB6FF">super</span><span style="color: #ADBAC7">().</span><span style="color: #6CB6FF">__init__</span><span style="color: #ADBAC7">(scope, name, </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">kwargs)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        table </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ddb.Table(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;SimpleTable&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">partition_key</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ddb.Attribute(</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">name</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;item_id&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">type</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ddb.AttributeType.</span><span style="color: #6CB6FF">STRING</span></span>
<span class="line"><span style="color: #ADBAC7">            ),</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">billing_mode</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ddb.BillingMode.</span><span style="color: #6CB6FF">PAY_PER_REQUEST</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">removal_policy</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">core.RemovalPolicy.</span><span style="color: #6CB6FF">DESTROY</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">class</span><span style="color: #24292E"> </span><span style="color: #6F42C1">SimpleDynamoDb</span><span style="color: #24292E">(</span><span style="color: #6F42C1">core</span><span style="color: #24292E">.</span><span style="color: #6F42C1">Stack</span><span style="color: #24292E">):</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">def</span><span style="color: #24292E"> </span><span style="color: #005CC5">__init__</span><span style="color: #24292E">(self, scope: core.App, name: </span><span style="color: #005CC5">str</span><span style="color: #24292E">, </span><span style="color: #D73A49">**</span><span style="color: #24292E">kwargs) -&gt; </span><span style="color: #005CC5">None</span><span style="color: #24292E">:</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #005CC5">super</span><span style="color: #24292E">().</span><span style="color: #005CC5">__init__</span><span style="color: #24292E">(scope, name, </span><span style="color: #D73A49">**</span><span style="color: #24292E">kwargs)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        table </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ddb.Table(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;SimpleTable&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">partition_key</span><span style="color: #D73A49">=</span><span style="color: #24292E">ddb.Attribute(</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">name</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;item_id&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">type</span><span style="color: #D73A49">=</span><span style="color: #24292E">ddb.AttributeType.</span><span style="color: #005CC5">STRING</span></span>
<span class="line"><span style="color: #24292E">            ),</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">billing_mode</span><span style="color: #D73A49">=</span><span style="color: #24292E">ddb.BillingMode.</span><span style="color: #005CC5">PAY_PER_REQUEST</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">removal_policy</span><span style="color: #D73A49">=</span><span style="color: #24292E">core.RemovalPolicy.</span><span style="color: #005CC5">DESTROY</span></span>
<span class="line"><span style="color: #24292E">        )</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br></div></div><p>このコードで，最低限の設定がなされた空の DynamoDB テーブルが作成される． それぞれのパラメータの意味を簡単に解説しよう．</p>
<ul>
<li>
<p><code>partition_key</code>: すべての DynamoDB テーブルには Partition key が定義されていなければならない． Partition key とは，テーブル内の要素 (レコード) ごとに存在する固有の ID のことである． 同一の Partition key をもった要素がテーブルの中に二つ以上存在することはできない (注: Sort Key を使用している場合は除く．詳しくは <a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.CoreComponents.html" target="_blank" rel="noreferrer">公式ドキュメンテーション &quot;Core Components of Amazon DynamoDB&quot;</a> 参照)． また， Partition key が定義されていない要素はテーブルの中に存在することはできない． ここでは， Partition key に <code>item_id</code> という名前をつけている．</p>
</li>
<li>
<p><code>billing_mode</code>: <code>ddb.BillingMode.PAY_PER_REQUEST</code> を指定することで， <a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.ReadWriteCapacityMode.html#HowItWorks.OnDemand" target="_blank" rel="noreferrer">On-demand Capacity Mode</a> の DynamoDB が作成される． ほかに <code>PROVISIONED</code> というモードがあるが，これはかなり高度なケースを除いて使用しないだろう．</p>
</li>
<li>
<p><code>removal_policy</code>: CloudFormation のスタックが消去されたときに， DynamoDB も一緒に消去されるかどうかを指定する． このコードでは <code>DESTROY</code> を選んでいるので，すべて消去される． ほかのオプションを選択すると，スタックを消去しても DynamoDB のバックアップを残す，などの動作を定義することができる．</p>
</li>
</ul>
<h3 id="デプロイ-1" tabindex="-1">デプロイ <a class="header-anchor" href="#デプロイ-1" aria-label="Permalink to &quot;デプロイ&quot;">&ZeroWidthSpace;</a></h3>
<p>デプロイの手順は，これまでのハンズオンとほとんど共通である． ここでは，コマンドのみ列挙する (<code>#</code> で始まる行はコメントである)． シークレットキーの設定も忘れずに (<a href="#aws_cli_install">AWS CLI のインストール</a>)．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390"># プロジェクトのディレクトリに移動</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cd</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">handson/serverless/dynamodb</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># venv を作成し，依存ライブラリのインストールを行う</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python3</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-m</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">venv</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.env</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">source</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.env/bin/activate</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">pip</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">install</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-r</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">requirements.txt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># デプロイを実行</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cdk</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">deploy</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D"># プロジェクトのディレクトリに移動</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cd</span><span style="color: #24292E"> </span><span style="color: #032F62">handson/serverless/dynamodb</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># venv を作成し，依存ライブラリのインストールを行う</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python3</span><span style="color: #24292E"> </span><span style="color: #005CC5">-m</span><span style="color: #24292E"> </span><span style="color: #032F62">venv</span><span style="color: #24292E"> </span><span style="color: #032F62">.env</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">source</span><span style="color: #24292E"> </span><span style="color: #032F62">.env/bin/activate</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">pip</span><span style="color: #24292E"> </span><span style="color: #032F62">install</span><span style="color: #24292E"> </span><span style="color: #005CC5">-r</span><span style="color: #24292E"> </span><span style="color: #032F62">requirements.txt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># デプロイを実行</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cdk</span><span style="color: #24292E"> </span><span style="color: #032F62">deploy</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br></div></div><p>デプロイのコマンドが無事に実行されれば， <a href="#handson_04_dynamodb_cdk_output">figure_title</a> のような出力が得られるはずである． ここで表示されている <code>SimpleDynamoDb.TableName = XXXX</code> の XXXX の文字列は後で使うのでメモしておこう．</p>
<p><img src="./assets/handson-serverless/handson_04_dynamodb_cdk_output.png" alt="CDKデプロイ実行後の出力"></p>
<p>AWS コンソールにログインして，デプロイされたスタックを確認してみよう． コンソールから， DynamoDB のページに行き，左のメニューバーから &quot;Tables&quot; を選択する． すると， <a href="#handson_04_dynamodb_table_list">figure_title</a> のような画面からテーブルの一覧が確認できる．</p>
<p><img src="./assets/handson-serverless/dynamodb_table_list.png" alt="DynamoDB のコンソール (テーブルの一覧)"></p>
<p>今回のアプリケーションで作成したのが <code>SimpleDynamoDb</code> で始まるランダムな名前のついたテーブルだ． テーブルの名前をクリックして，詳細を見てみる． すると <a href="#handson_04_dynamodb_table_detail">figure_title</a> のような画面が表示されるはずだ． &quot;Items&quot; のタブをクリックすると，テーブルの中のレコードを確認できる． 現時点ではなにもデータを書き込んでいないので，空である．</p>
<p><img src="./assets/handson-serverless/dynamodb_table_detail.png" alt="DynamoDB のコンソール (テーブルの詳細画面)"></p>
<h3 id="データの読み書き" tabindex="-1">データの読み書き <a class="header-anchor" href="#データの読み書き" aria-label="Permalink to &quot;データの読み書き&quot;">&ZeroWidthSpace;</a></h3>
<p>それでは， <a href="#sec:serverless_dynamodb_deploy">デプロイ</a> で作ったテーブルを使ってデータの読み書きを実践してみよう． ここでは Python と <a href="https://boto3.amazonaws.com/v1/documentation/api/latest/index.html" target="_blank" rel="noreferrer">boto3</a> ライブラリを用いた方法を紹介する．</p>
<p>まずは，テーブルに新しい要素を追加してみよう． ハンズオンのディレクトリにある <a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/serverless/dynamodb/simple_write.py" target="_blank" rel="noreferrer">simple_write.py</a> を開いてみよう． 中には次のような関数が書かれている．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> boto3</span></span>
<span class="line"><span style="color: #F47067">from</span><span style="color: #ADBAC7"> uuid </span><span style="color: #F47067">import</span><span style="color: #ADBAC7"> uuid4</span></span>
<span class="line"><span style="color: #ADBAC7">ddb </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> boto3.resource(</span><span style="color: #96D0FF">&#39;dynamodb&#39;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F47067">def</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">write_item</span><span style="color: #ADBAC7">(table_name):</span></span>
<span class="line"><span style="color: #ADBAC7">    table </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ddb.Table(table_name)</span></span>
<span class="line"><span style="color: #ADBAC7">    table.put_item(</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">Item</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">{</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #96D0FF">&#39;item_id&#39;</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">(uuid4()),</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #96D0FF">&#39;first_name&#39;</span><span style="color: #ADBAC7">: </span><span style="color: #96D0FF">&#39;John&#39;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #96D0FF">&#39;last_name&#39;</span><span style="color: #ADBAC7">: </span><span style="color: #96D0FF">&#39;Doe&#39;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #96D0FF">&#39;age&#39;</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">25</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        }</span></span>
<span class="line"><span style="color: #ADBAC7">    )</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> boto3</span></span>
<span class="line"><span style="color: #D73A49">from</span><span style="color: #24292E"> uuid </span><span style="color: #D73A49">import</span><span style="color: #24292E"> uuid4</span></span>
<span class="line"><span style="color: #24292E">ddb </span><span style="color: #D73A49">=</span><span style="color: #24292E"> boto3.resource(</span><span style="color: #032F62">&#39;dynamodb&#39;</span><span style="color: #24292E">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D73A49">def</span><span style="color: #24292E"> </span><span style="color: #6F42C1">write_item</span><span style="color: #24292E">(table_name):</span></span>
<span class="line"><span style="color: #24292E">    table </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ddb.Table(table_name)</span></span>
<span class="line"><span style="color: #24292E">    table.put_item(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">Item</span><span style="color: #D73A49">=</span><span style="color: #24292E">{</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #032F62">&#39;item_id&#39;</span><span style="color: #24292E">: </span><span style="color: #005CC5">str</span><span style="color: #24292E">(uuid4()),</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #032F62">&#39;first_name&#39;</span><span style="color: #24292E">: </span><span style="color: #032F62">&#39;John&#39;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #032F62">&#39;last_name&#39;</span><span style="color: #24292E">: </span><span style="color: #032F62">&#39;Doe&#39;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #032F62">&#39;age&#39;</span><span style="color: #24292E">: </span><span style="color: #005CC5">25</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        }</span></span>
<span class="line"><span style="color: #24292E">    )</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br></div></div><p>コードを上から読んでいくと，まず最初に boto3 ライブラリをインポートし， <code>dynamodb</code> のリソースを呼び出している． <code>write_item()</code> 関数は， DynamoDB のテーブルの名前 (上で見た SimpleDynamoDb-XXXX) を引数として受け取る． そして， <code>put_item()</code> メソッドを呼ぶことで，新しいアイテムを DB に書き込んでいる． アイテムには <code>item_id</code>, <code>first_name</code>, <code>last_name</code>, <code>age</code> の 4 つの属性が定義されている． ここで， <code>item_id</code> は先ほど説明した Partition key に相当しており， <a href="https://en.wikipedia.org/wiki/Universally_unique_identifier" target="_blank" rel="noreferrer">UUID4</a> を用いたランダムな文字列を割り当てている．</p>
<p>では， <code>simple_write.py</code> を実行してみよう． &quot;XXXX&quot; の部分を自分がデプロイしたテーブルの名前 (<code>SimpleDynamoDb</code> で始まる文字列) に置き換えたうえで，次のコマンドを実行する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">simple_write.py</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">XXXX</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python</span><span style="color: #24292E"> </span><span style="color: #032F62">simple_write.py</span><span style="color: #24292E"> </span><span style="color: #032F62">XXXX</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>新しい要素が正しく書き込めたか， AWS コンソールから確認してみよう． <a href="#handson_04_dynamodb_table_detail">figure_title</a> と同じ手順で，テーブルの中身の要素の一覧を表示する． すると <a href="#fig:dynamodb_table_new_item">figure_title</a> のように，期待通り新しい要素が見つかるだろう．</p>
<p><img src="./assets/handson-serverless/dynamodb_table_new_item.png" alt="DynamoDB に新しい要素が追加されたことを確認"></p>
<p>boto3 を使ってテーブルから要素を読みだすことも可能である． ハンズオンのディレクトリにある <a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/serverless/dynamodb/simple_read.py" target="_blank" rel="noreferrer">simple_read.py</a> を見てみよう．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> boto3</span></span>
<span class="line"><span style="color: #ADBAC7">ddb </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> boto3.resource(</span><span style="color: #96D0FF">&#39;dynamodb&#39;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F47067">def</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">scan_table</span><span style="color: #ADBAC7">(table_name):</span></span>
<span class="line"><span style="color: #ADBAC7">    table </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ddb.Table(table_name)</span></span>
<span class="line"><span style="color: #ADBAC7">    items </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> table.scan().get(</span><span style="color: #96D0FF">&quot;Items&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">print</span><span style="color: #ADBAC7">(items)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> boto3</span></span>
<span class="line"><span style="color: #24292E">ddb </span><span style="color: #D73A49">=</span><span style="color: #24292E"> boto3.resource(</span><span style="color: #032F62">&#39;dynamodb&#39;</span><span style="color: #24292E">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D73A49">def</span><span style="color: #24292E"> </span><span style="color: #6F42C1">scan_table</span><span style="color: #24292E">(table_name):</span></span>
<span class="line"><span style="color: #24292E">    table </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ddb.Table(table_name)</span></span>
<span class="line"><span style="color: #24292E">    items </span><span style="color: #D73A49">=</span><span style="color: #24292E"> table.scan().get(</span><span style="color: #032F62">&quot;Items&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">print</span><span style="color: #24292E">(items)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br></div></div><p><code>table.scan().get(&quot;Items&quot;)</code> によって，テーブルの中にあるすべての要素を読みだしている．</p>
<p>次のコマンドで，このスクリプトを実行してみよう (&quot;XXXX&quot; の部分を正しく置き換えることを忘れずに）．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">simple_read.py</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">XXXX</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python</span><span style="color: #24292E"> </span><span style="color: #032F62">simple_read.py</span><span style="color: #24292E"> </span><span style="color: #032F62">XXXX</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>先ほど書き込んだ要素が出力されることを確認しよう．</p>
<h3 id="大量のデータの読み書き" tabindex="-1">大量のデータの読み書き <a class="header-anchor" href="#大量のデータの読み書き" aria-label="Permalink to &quot;大量のデータの読み書き&quot;">&ZeroWidthSpace;</a></h3>
<p>DynamoDB の利点は，最初に述べたとおり，負荷に応じて自在にその処理能力を拡大できる点である．</p>
<p>そこで，ここでは一度に大量のデータを書き込む場合をシミュレートしてみよう． <a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/serverless/dynamodb/batch_rw.py" target="_blank" rel="noreferrer">batch_rw.py</a> に，一度に大量の書き込みを実行するためのプログラムが書いてある．</p>
<p>次のコマンドを実行してみよう (XXXX は自分のテーブルの名前に置き換える)．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">batch_rw.py</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">XXXX</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">write</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">1000</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python</span><span style="color: #24292E"> </span><span style="color: #032F62">batch_rw.py</span><span style="color: #24292E"> </span><span style="color: #032F62">XXXX</span><span style="color: #24292E"> </span><span style="color: #032F62">write</span><span style="color: #24292E"> </span><span style="color: #005CC5">1000</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>このコマンドを実行することで，ランダムなデータが 1000 個データベースに書き込まれる．</p>
<p>さらに，データベースの検索をかけてみよう． 今回書き込んだデータには <code>age</code> という属性に 1 から 50 のランダムな整数が割り当てられている． <code>age</code> が 2 以下であるような要素だけを検索し拾ってくるには，次のコマンドを実行すればよい．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">batch_rw.py</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">XXXX</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">search_under_age</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">2</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python</span><span style="color: #24292E"> </span><span style="color: #032F62">batch_rw.py</span><span style="color: #24292E"> </span><span style="color: #032F62">XXXX</span><span style="color: #24292E"> </span><span style="color: #032F62">search_under_age</span><span style="color: #24292E"> </span><span style="color: #005CC5">2</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>上の 2 つのコマンドを何回か繰り返し実行してみて，データベースに負荷をかけてみよう． とくに大きな遅延なく結果が返ってくることが確認できるだろう．</p>
<h3 id="スタックの削除-4" tabindex="-1">スタックの削除 <a class="header-anchor" href="#スタックの削除-4" aria-label="Permalink to &quot;スタックの削除&quot;">&ZeroWidthSpace;</a></h3>
<p>DynamoDB で十分に遊ぶことができたら，忘れずにスタックを削除しよう．</p>
<p>これまでのハンズオンと同様，スタックを削除するには，次のコマンドを実行すればよい．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cdk</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">destroy</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cdk</span><span style="color: #24292E"> </span><span style="color: #032F62">destroy</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><h2 id="s3-ハンズオン" tabindex="-1">S3 ハンズオン <a class="header-anchor" href="#s3-ハンズオン" aria-label="Permalink to &quot;S3 ハンズオン&quot;">&ZeroWidthSpace;</a></h2>
<p>最後に， S3 の簡単なチュートリアルを紹介する． ハンズオンのソースコードは GitHub の <a href="https://github.com/andatoshiki/toshiki-notebooktree/main/handson/serverless/s3" target="_blank" rel="noreferrer">handson/serverless/s3</a> に置いてある．</p>
<p><a href="#fig:s3_deploy">figure_title</a> が今回提供する S3 チュートリアルの概要である． STEP 1 として， AWS CDK を用いて S3 に新しい空のバケット (Bucket) を作成する． 続いて STEP 2 では，データのアップロード・ダウンロードの方法を解説する．</p>
<p><img src="./assets/handson-serverless/s3_deploy.png" alt="S3 チュートリアルの概要"></p>
<p>このハンズオンは，基本的に <a href="https://aws.amazon.com/free/?all-free-tier.sort-by=item.additionalFields.SortRank&amp;all-free-tier.sort-order=asc" target="_blank" rel="noreferrer">S3 の無料枠</a> の範囲内で実行することができる．</p>
<p><a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/serverless/s3/app.py" target="_blank" rel="noreferrer">app.py</a> にデプロイするプログラムが書かれている． 中身を見てみよう．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">class</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50">SimpleS3</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">core</span><span style="color: #ADBAC7">.</span><span style="color: #6CB6FF">Stack</span><span style="color: #ADBAC7">):</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">def</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">__init__</span><span style="color: #ADBAC7">(self, scope: core.App, name: </span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">, </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">kwargs) -&gt; </span><span style="color: #6CB6FF">None</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #6CB6FF">super</span><span style="color: #ADBAC7">().</span><span style="color: #6CB6FF">__init__</span><span style="color: #ADBAC7">(scope, name, </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">kwargs)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390"># S3 bucket to store data</span></span>
<span class="line"><span style="color: #ADBAC7">        bucket </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> s3.Bucket(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;bucket&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">removal_policy</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">core.RemovalPolicy.</span><span style="color: #6CB6FF">DESTROY</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">auto_delete_objects</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">True</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">class</span><span style="color: #24292E"> </span><span style="color: #6F42C1">SimpleS3</span><span style="color: #24292E">(</span><span style="color: #6F42C1">core</span><span style="color: #24292E">.</span><span style="color: #6F42C1">Stack</span><span style="color: #24292E">):</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">def</span><span style="color: #24292E"> </span><span style="color: #005CC5">__init__</span><span style="color: #24292E">(self, scope: core.App, name: </span><span style="color: #005CC5">str</span><span style="color: #24292E">, </span><span style="color: #D73A49">**</span><span style="color: #24292E">kwargs) -&gt; </span><span style="color: #005CC5">None</span><span style="color: #24292E">:</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #005CC5">super</span><span style="color: #24292E">().</span><span style="color: #005CC5">__init__</span><span style="color: #24292E">(scope, name, </span><span style="color: #D73A49">**</span><span style="color: #24292E">kwargs)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D"># S3 bucket to store data</span></span>
<span class="line"><span style="color: #24292E">        bucket </span><span style="color: #D73A49">=</span><span style="color: #24292E"> s3.Bucket(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;bucket&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">removal_policy</span><span style="color: #D73A49">=</span><span style="color: #24292E">core.RemovalPolicy.</span><span style="color: #005CC5">DESTROY</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">auto_delete_objects</span><span style="color: #D73A49">=</span><span style="color: #005CC5">True</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        )</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br></div></div><p><code>s3.Bucket()</code> を呼ぶことによって空のバケットが新規に作成される． 上記のコードだと，バケットの名前は自動生成される． もし，自分の指定した名前を与えたい場合は， <code>bucket_name</code> というパラメータを指定すればよい． その際， バケットの名前はユニークでなければならない (i.e. AWS のデプロイが行われるリージョン内で名前の重複がない) 点に注意しよう． もし，同じ名前のバケットが既に存在する場合はエラーが返ってくる．</p>
<p>デフォルトでは， CloudFormation スタックが削除されたとき， S3 バケットとその中に保存されたファイルは削除されない． これは，大切なデータを誤って消してしまうことを防止するための安全策である． <code>cdk destroy</code> を実行したときにバケットも含めてすべて削除されるようにするには， <code>removal_policy=core.RemovalPolicy.DESTROY, auto_delete_objects=True</code> とパラメータを設定する． 結果もよく理解したうえで，自分の用途にあった適切なパラメータを設定しよう．</p>
<h3 id="デプロイ-2" tabindex="-1">デプロイ <a class="header-anchor" href="#デプロイ-2" aria-label="Permalink to &quot;デプロイ&quot;">&ZeroWidthSpace;</a></h3>
<p>デプロイの手順は，これまでのハンズオンとほとんど共通である． ここでは，コマンドのみ列挙する (<code>#</code> で始まる行はコメントである)． シークレットキーの設定も忘れずに (<a href="#aws_cli_install">AWS CLI のインストール</a>)．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390"># プロジェクトのディレクトリに移動</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cd</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">handson/serverless/s3</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># venv を作成し，依存ライブラリのインストールを行う</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python3</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-m</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">venv</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.env</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">source</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.env/bin/activate</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">pip</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">install</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-r</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">requirements.txt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># デプロイを実行</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cdk</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">deploy</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D"># プロジェクトのディレクトリに移動</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cd</span><span style="color: #24292E"> </span><span style="color: #032F62">handson/serverless/s3</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># venv を作成し，依存ライブラリのインストールを行う</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python3</span><span style="color: #24292E"> </span><span style="color: #005CC5">-m</span><span style="color: #24292E"> </span><span style="color: #032F62">venv</span><span style="color: #24292E"> </span><span style="color: #032F62">.env</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">source</span><span style="color: #24292E"> </span><span style="color: #032F62">.env/bin/activate</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">pip</span><span style="color: #24292E"> </span><span style="color: #032F62">install</span><span style="color: #24292E"> </span><span style="color: #005CC5">-r</span><span style="color: #24292E"> </span><span style="color: #032F62">requirements.txt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># デプロイを実行</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cdk</span><span style="color: #24292E"> </span><span style="color: #032F62">deploy</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br></div></div><p>デプロイを実行すると， <a href="#fig:s3_deploy_output">figure_title</a> のような出力が得られるはずである． ここで表示されている <code>SimpleS3.BucketName = XXXX</code> が，新しく作られたバケットの名前である (今回提供しているコードを使うとランダムな名前がバケットに割り当てられる）． これはあとで使うのでメモしておこう．</p>
<p><img src="./assets/handson-serverless/s3_deploy_output.png" alt="デプロイ実行後の出力"></p>
<h3 id="データの読み書き-1" tabindex="-1">データの読み書き <a class="header-anchor" href="#データの読み書き-1" aria-label="Permalink to &quot;データの読み書き&quot;">&ZeroWidthSpace;</a></h3>
<p>スタックのデプロイが完了したら，早速バケットにデータをアップロードしてみよう．</p>
<p>まずは，以下のコマンドを実行して， <code>tmp.txt</code> という仮のファイルを生成する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">echo</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;Hello world!&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">&gt;&gt;</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">tmp.txt</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">echo</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;Hello world!&quot;</span><span style="color: #24292E"> </span><span style="color: #D73A49">&gt;&gt;</span><span style="color: #24292E"> </span><span style="color: #032F62">tmp.txt</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>ハンズオンのディレクトリにある <a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/serverless/s3/simple_s3.py" target="_blank" rel="noreferrer">simple_s3.py</a> に <a href="https://boto3.amazonaws.com/v1/documentation/api/latest/index.html" target="_blank" rel="noreferrer">boto3</a> ライブラリを使用した S3 のファイルのアップロード・ダウンロードのスクリプトが書いてある． <code>simple_s3.py</code> を使って，上で作成した <code>tmp.txt</code> を以下のコマンドによりバケットにアップロードする． <code>XXXX</code> のところは，自分自身のバケットの名前で置き換えること．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">simple_s3.py</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">XXXX</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">upload</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">tmp.txt</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python</span><span style="color: #24292E"> </span><span style="color: #032F62">simple_s3.py</span><span style="color: #24292E"> </span><span style="color: #032F62">XXXX</span><span style="color: #24292E"> </span><span style="color: #032F62">upload</span><span style="color: #24292E"> </span><span style="color: #032F62">tmp.txt</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p><code>simple_s3.py</code> のアップロードを担当している部分を以下に抜粋する．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">def</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">upload_file</span><span style="color: #ADBAC7">(bucket_name, filename, key</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">None</span><span style="color: #ADBAC7">):</span></span>
<span class="line"><span style="color: #ADBAC7">    bucket </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> s3.Bucket(bucket_name)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> key </span><span style="color: #F47067">is</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">None</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">        key </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> os.path.basename(filename)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    bucket.upload_file(filename, key)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">def</span><span style="color: #24292E"> </span><span style="color: #6F42C1">upload_file</span><span style="color: #24292E">(bucket_name, filename, key</span><span style="color: #D73A49">=</span><span style="color: #005CC5">None</span><span style="color: #24292E">):</span></span>
<span class="line"><span style="color: #24292E">    bucket </span><span style="color: #D73A49">=</span><span style="color: #24292E"> s3.Bucket(bucket_name)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">if</span><span style="color: #24292E"> key </span><span style="color: #D73A49">is</span><span style="color: #24292E"> </span><span style="color: #005CC5">None</span><span style="color: #24292E">:</span></span>
<span class="line"><span style="color: #24292E">        key </span><span style="color: #D73A49">=</span><span style="color: #24292E"> os.path.basename(filename)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">    bucket.upload_file(filename, key)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br></div></div><p><code>bucket = s3.Bucket(bucket_name)</code> の行で <code>Bucket()</code> オブジェクトを呼び出している． そして， <code>upload_file()</code> メソッドを呼ぶことでファイルのアップロードを実行している．</p>
<p>S3 においてファイルの識別子として使われるのが <strong>Key</strong> である． これは，従来的なファイルシステムにおけるパス (Path) と相同な概念で，それぞれのファイルに固有な Key が割り当てられる必要がある． Key という呼び方は， S3 が <a href="https://en.wikipedia.org/wiki/Object_storage" target="_blank" rel="noreferrer">Object storage</a> と呼ばれるシステムに立脚していることに由来する． <code>--key</code> のオプションを追加して <code>simple_s3.py</code> を実行することで， Key を指定してアップロードを実行することができる．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">simple_s3.py</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">XXXX</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">upload</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">tmp.txt</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--key</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">a/b/tmp.txt</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python</span><span style="color: #24292E"> </span><span style="color: #032F62">simple_s3.py</span><span style="color: #24292E"> </span><span style="color: #032F62">XXXX</span><span style="color: #24292E"> </span><span style="color: #032F62">upload</span><span style="color: #24292E"> </span><span style="color: #032F62">tmp.txt</span><span style="color: #24292E"> </span><span style="color: #005CC5">--key</span><span style="color: #24292E"> </span><span style="color: #032F62">a/b/tmp.txt</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>ここではアップロードされたファイルに <code>a/b/tmp.txt</code> という Key を割り当てている．</p>
<p>ここまでコマンドを実行し終えたところで，一度 AWS コンソールに行き S3 の中身を確認してみよう． S3 のコンソールに行くと，バケットの一覧が見つかるはずである． その中から， <code>simples3-bucket</code> から始まるランダムな名前のついたバケットを探し，クリックする． するとバケットの中に含まれるファイルの一覧が表示される (<a href="#fig:s3_bucket_filelist">figure_title</a>)．</p>
<p><img src="./assets/handson-serverless/s3_bucket_filelist.png" alt="S3 バケットの中のファイル一覧"></p>
<p>ここで実行した 2 つのコマンドによって， <code>tmp.txt</code> というファイルと， <code>a/b/tmp.txt</code> というファイルが見つかることに注目しよう． 従来的なファイルシステムと似た体験を提供するため， S3 では Key が <strong>&quot;/&quot; (スラッシュ)</strong> によって区切られていた場合，<strong>ツリー状の階層構造</strong>によってファイルを管理することができる．</p>
<p>オブジェクトストレージには本来ディレクトリという概念はない． 上で紹介した &quot;/&quot; による階層づけはあくまでユーザー体験向上の目的のお化粧的な機能である．</p>
<p>次に，バケットからファイルのダウンロードを実行してみよう． <code>simple_s3.py</code> を使って，以下のコマンドを実行すればよい． <code>XXXX</code> のところは，自分自身のバケットの名前で置き換えること．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">simple_s3.py</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">XXXX</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">download</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">tmp.txt</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python</span><span style="color: #24292E"> </span><span style="color: #032F62">simple_s3.py</span><span style="color: #24292E"> </span><span style="color: #032F62">XXXX</span><span style="color: #24292E"> </span><span style="color: #032F62">download</span><span style="color: #24292E"> </span><span style="color: #032F62">tmp.txt</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p><code>simple_s3.py</code> のダウンロードを担当している部分を以下に抜粋する．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">def</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">download_file</span><span style="color: #ADBAC7">(bucket_name, key, filename</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">None</span><span style="color: #ADBAC7">):</span></span>
<span class="line"><span style="color: #ADBAC7">    bucket </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> s3.Bucket(bucket_name)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> filename </span><span style="color: #F47067">is</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">None</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">        filename </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> os.path.basename(key)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    bucket.download_file(key, filename)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">def</span><span style="color: #24292E"> </span><span style="color: #6F42C1">download_file</span><span style="color: #24292E">(bucket_name, key, filename</span><span style="color: #D73A49">=</span><span style="color: #005CC5">None</span><span style="color: #24292E">):</span></span>
<span class="line"><span style="color: #24292E">    bucket </span><span style="color: #D73A49">=</span><span style="color: #24292E"> s3.Bucket(bucket_name)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">if</span><span style="color: #24292E"> filename </span><span style="color: #D73A49">is</span><span style="color: #24292E"> </span><span style="color: #005CC5">None</span><span style="color: #24292E">:</span></span>
<span class="line"><span style="color: #24292E">        filename </span><span style="color: #D73A49">=</span><span style="color: #24292E"> os.path.basename(key)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">    bucket.download_file(key, filename)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br></div></div><p>S3 からのダウンロードはシンプルで， <code>download_file()</code> メソッドを使って，ダウンロードしたい対象の Key を指定すればよい． ローカルのコンピュータでの保存先のパスを 2 個目の引数として渡している．</p>
<h3 id="スタックの削除-5" tabindex="-1">スタックの削除 <a class="header-anchor" href="#スタックの削除-5" aria-label="Permalink to &quot;スタックの削除&quot;">&ZeroWidthSpace;</a></h3>
<p>以上のハンズオンで， S3 の一番基本的な使い方を紹介した． ここまでのハンズオンが理解できたら，忘れずにスタックを削除しよう． これまでのハンズオンと同様，スタックを削除するには，次のコマンドを実行すればよい．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cdk</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">destroy</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cdk</span><span style="color: #24292E"> </span><span style="color: #032F62">destroy</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><h1 id="hands-on-6-bashoutter" tabindex="-1">Hands-on #6: Bashoutter <a class="header-anchor" href="#hands-on-6-bashoutter" aria-label="Permalink to &quot;Hands-on \#6: Bashoutter&quot;">&ZeroWidthSpace;</a></h1>
<p>さて，最後のハンズオンとなる第六回では，これまで学んできたサーバーレスクラウドの技術を使って，簡単なウェブサービスを作ってみよう． 具体的には，人々が自分の作った俳句を投稿する SNS サービス (<strong>Bashoutter</strong> と名付ける) を作成してみよう． Lambda, DynamoDB, S3 などの技術をすべて盛り込み，シンプルながらもサーバーレスの利点を生かしたスケーラブルな SNS アプリが誕生する． 最終的には， <a href="#handson_05_bashoutter">figure_title</a> のような，ミニマルではあるがとても現代風な SNS サイトが完成する！</p>
<p><img src="./assets/handson-bashoutter/bashoutter.png" alt="ハンズオン#6で作製する SNS アプリケーション &quot;Bashoutter&quot;"></p>
<h2 id="準備-4" tabindex="-1">準備 <a class="header-anchor" href="#準備-4" aria-label="Permalink to &quot;準備&quot;">&ZeroWidthSpace;</a></h2>
<p>ハンズオンのソースコードは GitHub の <a href="https://github.com/andatoshiki/toshiki-notebooktree/main/handson/bashoutter" target="_blank" rel="noreferrer">handson/bashoutter</a> に置いてある．</p>
<p>本ハンズオンの実行には，第一回ハンズオンで説明した準備 (<a href="#handson_01_prep">準備</a>) が整っていることを前提とする． それ以外に必要な準備はない．</p>
<p>このハンズオンは，基本的に <a href="https://aws.amazon.com/free/?all-free-tier.sort-by=item.additionalFields.SortRank&amp;all-free-tier.sort-order=asc" target="_blank" rel="noreferrer">AWS の無料枠</a> の範囲内で実行できる．</p>
<h2 id="アプリケーションの説明-4" tabindex="-1">アプリケーションの説明 <a class="header-anchor" href="#アプリケーションの説明-4" aria-label="Permalink to &quot;アプリケーションの説明&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="api" tabindex="-1">API <a class="header-anchor" href="#api" aria-label="Permalink to &quot;API&quot;">&ZeroWidthSpace;</a></h3>
<p>今回のアプリケーションでは，人々からの俳句の投稿を受け付けたり，投稿された俳句の一覧を取得する，といった機能を実装したい． この機能を実現するための最小限の設計として， <a href="#tab_handson_05_api">table_title</a> に示すような四つの REST API を今回は実装する． 俳句を投稿する，閲覧する，削除するという基本的なデータ操作を行うための API が完備されている． また， <code>PATCH /haiku/{item_id}</code> は， <code>{item_id}</code> で指定された俳句に”いいね”をするために使用する．</p>
<table><caption>Bashoutter API</caption><colgroup><col style="width: 50%" /><col style="width: 50%" /></colgroup><tbody><tr class="odd"><td><p><code>GET /haiku</code></p></td><td><p>俳句の一覧を取得する</p></td></tr><tr class="even"><td><p><code>POST /haiku</code></p></td><td><p>新しい俳句を投稿する</p></td></tr><tr class="odd"><td><p><code>PATCH /haiku/{item_id}</code></p></td><td><p><code>{item_id}</code> で指定された俳句にお気に入り票を一つ入れる</p></td></tr><tr class="even"><td><p><code>DELETE /haiku/{item_id}</code></p></td><td><p><code>{item_id}</code> で指定された俳句を削除する</p></td></tr></tbody></table>
<p>それぞれの API のパラメータおよび返り値の詳細は，ハンズオンのソースコードの中の <a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/bashoutter/specs/swagger.yml" target="_blank" rel="noreferrer">swagger.yml</a> に定義してある．</p>
<p><strong>Open API Specification</strong> (OAS; 少し前は Swagger Specification とよばれていた) は， REST API のための記述フォーマットである． OAS に従って API の仕様が記述されていると，簡単にドキュメンテーションを生成したり，クライアントアプリケーションを自動生成することができる． <a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/bashoutter/specs/swagger.yml" target="_blank" rel="noreferrer">今回用意した API 仕様</a> も， OAS に従って書いてある． 詳しくは <a href="https://swagger.io/docs/specification/about/" target="_blank" rel="noreferrer">Swagger の公式ドキュメンテーション</a> などを参照．</p>
<h3 id="アプリケーションアーキテクチャ" tabindex="-1">アプリケーションアーキテクチャ <a class="header-anchor" href="#アプリケーションアーキテクチャ" aria-label="Permalink to &quot;アプリケーションアーキテクチャ&quot;">&ZeroWidthSpace;</a></h3>
<p>このハンズオンで作成するアプリケーションの概要を <a href="#handson_05_architecture">figure_title</a> に示す．</p>
<p><img src="./assets/handson-bashoutter/handson-05-architecture.png" alt="ハンズオン#5で作製するアプリケーションのアーキテクチャ"></p>
<p>簡単にまとめると，次のような設計である．</p>
<ul>
<li>
<p>クライアントからの API リクエストは， <strong>API Gateway</strong> (後述)にまず送信され， API の URI で指定された Lambda 関数へ転送される．</p>
</li>
<li>
<p>それぞれの API のパス (リソース) ごとに独立した Lambda を用意する．</p>
</li>
<li>
<p>俳句の情報 (作者，本文，投稿日時など) を記録するためのデータベース (DynamoDB) を用意する．</p>
</li>
<li>
<p>各 Lambda 関数には， DynamoDB へのアクセス権を付与する．</p>
</li>
<li>
<p>最後に，ウェブブラウザからコンテンツを表示できるよう， ウェブページの静的コンテンツを配信するための S3 バケットを用意する．クライアントはこの S3 バケットにアクセスすることで HTML/CSS/JS などのコンテンツを取得する．</p>
</li>
</ul>
<p>それでは，プログラムのソースコードを見てみよう (<a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/bashoutter/app.py" target="_blank" rel="noreferrer">handson/bashoutter/app.py</a>)．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">class</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50">Bashoutter</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">core</span><span style="color: #ADBAC7">.</span><span style="color: #6CB6FF">Stack</span><span style="color: #ADBAC7">):</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">def</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">__init__</span><span style="color: #ADBAC7">(self, scope: core.App, name: </span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">, </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">kwargs) -&gt; </span><span style="color: #6CB6FF">None</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #6CB6FF">super</span><span style="color: #ADBAC7">().</span><span style="color: #6CB6FF">__init__</span><span style="color: #ADBAC7">(scope, name, </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">kwargs)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390"># dynamoDB table to store haiku</span></span>
<span class="line"><span style="color: #ADBAC7">        table </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ddb.Table(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;Bashoutter-Table&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">partition_key</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ddb.Attribute(</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">name</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;item_id&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">type</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ddb.AttributeType.</span><span style="color: #6CB6FF">STRING</span></span>
<span class="line"><span style="color: #ADBAC7">            ),</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">billing_mode</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ddb.BillingMode.</span><span style="color: #6CB6FF">PAY_PER_REQUEST</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">removal_policy</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">core.RemovalPolicy.</span><span style="color: #6CB6FF">DESTROY</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        bucket </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> s3.Bucket(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;Bashoutter-Bucket&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">website_index_document</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;index.html&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">public_read_access</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">True</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">removal_policy</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">core.RemovalPolicy.</span><span style="color: #6CB6FF">DESTROY</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        common_params </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> {</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #96D0FF">&quot;runtime&quot;</span><span style="color: #ADBAC7">: _lambda.Runtime.</span><span style="color: #6CB6FF">PYTHON_3_7</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #96D0FF">&quot;environment&quot;</span><span style="color: #ADBAC7">: {</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #96D0FF">&quot;TABLE_NAME&quot;</span><span style="color: #ADBAC7">: table.table_name</span></span>
<span class="line"><span style="color: #ADBAC7">            }</span></span>
<span class="line"><span style="color: #ADBAC7">        }</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390"># define Lambda functions</span></span>
<span class="line"><span style="color: #ADBAC7">        get_haiku_lambda </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> _lambda.Function(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;GetHaiku&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">code</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">_lambda.Code.from_asset(</span><span style="color: #96D0FF">&quot;api&quot;</span><span style="color: #ADBAC7">),</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">handler</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;api.get_haiku&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">memory_size</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">512</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">common_params,</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"><span style="color: #ADBAC7">        post_haiku_lambda </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> _lambda.Function(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;PostHaiku&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">code</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">_lambda.Code.from_asset(</span><span style="color: #96D0FF">&quot;api&quot;</span><span style="color: #ADBAC7">),</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">handler</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;api.post_haiku&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">common_params,</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"><span style="color: #ADBAC7">        patch_haiku_lambda </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> _lambda.Function(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;PatchHaiku&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">code</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">_lambda.Code.from_asset(</span><span style="color: #96D0FF">&quot;api&quot;</span><span style="color: #ADBAC7">),</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">handler</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;api.patch_haiku&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">common_params,</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"><span style="color: #ADBAC7">        delete_haiku_lambda </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> _lambda.Function(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;DeleteHaiku&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">code</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">_lambda.Code.from_asset(</span><span style="color: #96D0FF">&quot;api&quot;</span><span style="color: #ADBAC7">),</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">handler</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;api.delete_haiku&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">common_params,</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390"># grant permissions</span></span>
<span class="line"><span style="color: #ADBAC7">        table.grant_read_data(get_haiku_lambda)</span></span>
<span class="line"><span style="color: #ADBAC7">        table.grant_read_write_data(post_haiku_lambda)</span></span>
<span class="line"><span style="color: #ADBAC7">        table.grant_read_write_data(patch_haiku_lambda)</span></span>
<span class="line"><span style="color: #ADBAC7">        table.grant_read_write_data(delete_haiku_lambda)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390"># define API Gateway</span></span>
<span class="line"><span style="color: #ADBAC7">        api </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> apigw.RestApi(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;BashoutterApi&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">default_cors_preflight_options</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">apigw.CorsOptions(</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">allow_origins</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">apigw.Cors.</span><span style="color: #6CB6FF">ALL_ORIGINS</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">allow_methods</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">apigw.Cors.</span><span style="color: #6CB6FF">ALL_METHODS</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            )</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        haiku </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> api.root.add_resource(</span><span style="color: #96D0FF">&quot;haiku&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">        haiku.add_method(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #96D0FF">&quot;GET&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            apigw.LambdaIntegration(get_haiku_lambda)</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"><span style="color: #ADBAC7">        haiku.add_method(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #96D0FF">&quot;POST&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            apigw.LambdaIntegration(post_haiku_lambda)</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        haiku_item_id </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> haiku.add_resource(</span><span style="color: #96D0FF">&quot;</span><span style="color: #F47067">{item_id}</span><span style="color: #96D0FF">&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">        haiku_item_id.add_method(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #96D0FF">&quot;PATCH&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            apigw.LambdaIntegration(patch_haiku_lambda)</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"><span style="color: #ADBAC7">        haiku_item_id.add_method(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #96D0FF">&quot;DELETE&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            apigw.LambdaIntegration(delete_haiku_lambda)</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">class</span><span style="color: #24292E"> </span><span style="color: #6F42C1">Bashoutter</span><span style="color: #24292E">(</span><span style="color: #6F42C1">core</span><span style="color: #24292E">.</span><span style="color: #6F42C1">Stack</span><span style="color: #24292E">):</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">def</span><span style="color: #24292E"> </span><span style="color: #005CC5">__init__</span><span style="color: #24292E">(self, scope: core.App, name: </span><span style="color: #005CC5">str</span><span style="color: #24292E">, </span><span style="color: #D73A49">**</span><span style="color: #24292E">kwargs) -&gt; </span><span style="color: #005CC5">None</span><span style="color: #24292E">:</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #005CC5">super</span><span style="color: #24292E">().</span><span style="color: #005CC5">__init__</span><span style="color: #24292E">(scope, name, </span><span style="color: #D73A49">**</span><span style="color: #24292E">kwargs)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D"># dynamoDB table to store haiku</span></span>
<span class="line"><span style="color: #24292E">        table </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ddb.Table(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;Bashoutter-Table&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">partition_key</span><span style="color: #D73A49">=</span><span style="color: #24292E">ddb.Attribute(</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">name</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;item_id&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">type</span><span style="color: #D73A49">=</span><span style="color: #24292E">ddb.AttributeType.</span><span style="color: #005CC5">STRING</span></span>
<span class="line"><span style="color: #24292E">            ),</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">billing_mode</span><span style="color: #D73A49">=</span><span style="color: #24292E">ddb.BillingMode.</span><span style="color: #005CC5">PAY_PER_REQUEST</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">removal_policy</span><span style="color: #D73A49">=</span><span style="color: #24292E">core.RemovalPolicy.</span><span style="color: #005CC5">DESTROY</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        bucket </span><span style="color: #D73A49">=</span><span style="color: #24292E"> s3.Bucket(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;Bashoutter-Bucket&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">website_index_document</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;index.html&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">public_read_access</span><span style="color: #D73A49">=</span><span style="color: #005CC5">True</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">removal_policy</span><span style="color: #D73A49">=</span><span style="color: #24292E">core.RemovalPolicy.</span><span style="color: #005CC5">DESTROY</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        common_params </span><span style="color: #D73A49">=</span><span style="color: #24292E"> {</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #032F62">&quot;runtime&quot;</span><span style="color: #24292E">: _lambda.Runtime.</span><span style="color: #005CC5">PYTHON_3_7</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #032F62">&quot;environment&quot;</span><span style="color: #24292E">: {</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #032F62">&quot;TABLE_NAME&quot;</span><span style="color: #24292E">: table.table_name</span></span>
<span class="line"><span style="color: #24292E">            }</span></span>
<span class="line"><span style="color: #24292E">        }</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D"># define Lambda functions</span></span>
<span class="line"><span style="color: #24292E">        get_haiku_lambda </span><span style="color: #D73A49">=</span><span style="color: #24292E"> _lambda.Function(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;GetHaiku&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">code</span><span style="color: #D73A49">=</span><span style="color: #24292E">_lambda.Code.from_asset(</span><span style="color: #032F62">&quot;api&quot;</span><span style="color: #24292E">),</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">handler</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;api.get_haiku&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">memory_size</span><span style="color: #D73A49">=</span><span style="color: #005CC5">512</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #D73A49">**</span><span style="color: #24292E">common_params,</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"><span style="color: #24292E">        post_haiku_lambda </span><span style="color: #D73A49">=</span><span style="color: #24292E"> _lambda.Function(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;PostHaiku&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">code</span><span style="color: #D73A49">=</span><span style="color: #24292E">_lambda.Code.from_asset(</span><span style="color: #032F62">&quot;api&quot;</span><span style="color: #24292E">),</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">handler</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;api.post_haiku&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #D73A49">**</span><span style="color: #24292E">common_params,</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"><span style="color: #24292E">        patch_haiku_lambda </span><span style="color: #D73A49">=</span><span style="color: #24292E"> _lambda.Function(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;PatchHaiku&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">code</span><span style="color: #D73A49">=</span><span style="color: #24292E">_lambda.Code.from_asset(</span><span style="color: #032F62">&quot;api&quot;</span><span style="color: #24292E">),</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">handler</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;api.patch_haiku&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #D73A49">**</span><span style="color: #24292E">common_params,</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"><span style="color: #24292E">        delete_haiku_lambda </span><span style="color: #D73A49">=</span><span style="color: #24292E"> _lambda.Function(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;DeleteHaiku&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">code</span><span style="color: #D73A49">=</span><span style="color: #24292E">_lambda.Code.from_asset(</span><span style="color: #032F62">&quot;api&quot;</span><span style="color: #24292E">),</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">handler</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;api.delete_haiku&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #D73A49">**</span><span style="color: #24292E">common_params,</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D"># grant permissions</span></span>
<span class="line"><span style="color: #24292E">        table.grant_read_data(get_haiku_lambda)</span></span>
<span class="line"><span style="color: #24292E">        table.grant_read_write_data(post_haiku_lambda)</span></span>
<span class="line"><span style="color: #24292E">        table.grant_read_write_data(patch_haiku_lambda)</span></span>
<span class="line"><span style="color: #24292E">        table.grant_read_write_data(delete_haiku_lambda)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D"># define API Gateway</span></span>
<span class="line"><span style="color: #24292E">        api </span><span style="color: #D73A49">=</span><span style="color: #24292E"> apigw.RestApi(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;BashoutterApi&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">default_cors_preflight_options</span><span style="color: #D73A49">=</span><span style="color: #24292E">apigw.CorsOptions(</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">allow_origins</span><span style="color: #D73A49">=</span><span style="color: #24292E">apigw.Cors.</span><span style="color: #005CC5">ALL_ORIGINS</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">allow_methods</span><span style="color: #D73A49">=</span><span style="color: #24292E">apigw.Cors.</span><span style="color: #005CC5">ALL_METHODS</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            )</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        haiku </span><span style="color: #D73A49">=</span><span style="color: #24292E"> api.root.add_resource(</span><span style="color: #032F62">&quot;haiku&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">        haiku.add_method(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #032F62">&quot;GET&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            apigw.LambdaIntegration(get_haiku_lambda)</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"><span style="color: #24292E">        haiku.add_method(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #032F62">&quot;POST&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            apigw.LambdaIntegration(post_haiku_lambda)</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        haiku_item_id </span><span style="color: #D73A49">=</span><span style="color: #24292E"> haiku.add_resource(</span><span style="color: #032F62">&quot;</span><span style="color: #005CC5">{item_id}</span><span style="color: #032F62">&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">        haiku_item_id.add_method(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #032F62">&quot;PATCH&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            apigw.LambdaIntegration(patch_haiku_lambda)</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"><span style="color: #24292E">        haiku_item_id.add_method(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #032F62">&quot;DELETE&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            apigw.LambdaIntegration(delete_haiku_lambda)</span></span>
<span class="line"><span style="color: #24292E">        )</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br><span class="line-number">36</span><br><span class="line-number">37</span><br><span class="line-number">38</span><br><span class="line-number">39</span><br><span class="line-number">40</span><br><span class="line-number">41</span><br><span class="line-number">42</span><br><span class="line-number">43</span><br><span class="line-number">44</span><br><span class="line-number">45</span><br><span class="line-number">46</span><br><span class="line-number">47</span><br><span class="line-number">48</span><br><span class="line-number">49</span><br><span class="line-number">50</span><br><span class="line-number">51</span><br><span class="line-number">52</span><br><span class="line-number">53</span><br><span class="line-number">54</span><br><span class="line-number">55</span><br><span class="line-number">56</span><br><span class="line-number">57</span><br><span class="line-number">58</span><br><span class="line-number">59</span><br><span class="line-number">60</span><br><span class="line-number">61</span><br><span class="line-number">62</span><br><span class="line-number">63</span><br><span class="line-number">64</span><br><span class="line-number">65</span><br><span class="line-number">66</span><br><span class="line-number">67</span><br><span class="line-number">68</span><br><span class="line-number">69</span><br><span class="line-number">70</span><br><span class="line-number">71</span><br><span class="line-number">72</span><br><span class="line-number">73</span><br><span class="line-number">74</span><br><span class="line-number">75</span><br><span class="line-number">76</span><br><span class="line-number">77</span><br><span class="line-number">78</span><br><span class="line-number">79</span><br><span class="line-number">80</span><br><span class="line-number">81</span><br><span class="line-number">82</span><br><span class="line-number">83</span><br><span class="line-number">84</span><br><span class="line-number">85</span><br><span class="line-number">86</span><br><span class="line-number">87</span><br><span class="line-number">88</span><br><span class="line-number">89</span><br><span class="line-number">90</span><br><span class="line-number">91</span><br><span class="line-number">92</span><br><span class="line-number">93</span><br><span class="line-number">94</span><br><span class="line-number">95</span><br><span class="line-number">96</span><br></div></div><ul>
<li>
<p>ここで，俳句の情報を記録しておくための DynamoDB テーブルを定義している．</p>
</li>
<li>
<p>静的コンテンツを配信するための S3 バケットを用意している．</p>
</li>
<li>
<p>それぞれの API で実行される Lambda 関数を定義している． 関数は Python3.7 で書かれており，コードは <a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/bashoutter/api/api.py" target="_blank" rel="noreferrer">handson/bashoutter/api/api.py</a> にある．</p>
</li>
<li>
<p>&lt;3&gt; で定義された Lambda 関数に対し，データベースへの読み書きのアクセス権限を付与している．</p>
</li>
<li>
<p>ここで，API Gateway により，各 API パスとそこで実行されるべき Lambda 関数を紐付けている．</p>
</li>
</ul>
<p>それぞれの項目について，もう少し詳しく説明しよう．</p>
<h3 id="public-access-mode-の-s3-バケット" tabindex="-1">Public access mode の S3 バケット <a class="header-anchor" href="#public-access-mode-の-s3-バケット" aria-label="Permalink to &quot;Public access mode の S3 バケット&quot;">&ZeroWidthSpace;</a></h3>
<p>S3 のバケットを作成しているコードを見てみよう．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">bucket </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> s3.Bucket(</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;Bashoutter-Bucket&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">website_index_document</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;index.html&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">public_read_access</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">True</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">removal_policy</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">core.RemovalPolicy.</span><span style="color: #6CB6FF">DESTROY</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">bucket </span><span style="color: #D73A49">=</span><span style="color: #24292E"> s3.Bucket(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;Bashoutter-Bucket&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">website_index_document</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;index.html&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">public_read_access</span><span style="color: #D73A49">=</span><span style="color: #005CC5">True</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">removal_policy</span><span style="color: #D73A49">=</span><span style="color: #24292E">core.RemovalPolicy.</span><span style="color: #005CC5">DESTROY</span></span>
<span class="line"><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br></div></div><p>ここで注目してほしいのは <code>public_read_access=True</code> の部分だ． 前章で， S3 について説明を行ったときには触れなかったが， S3 には <strong>Public access mode</strong> という機能がある． Public access mode をオンにしておくと，バケットの中のファイルは認証なしで (i.e. インターネット上の誰でも) 閲覧できるようになる． この設定は，一般公開されているウェブサイトの静的なコンテンツを置いておくのに最適であり，多くのサーバーレスによるウェブサービスでこのような設計が行われる． public access mode を設定しておくと， <code>http://XXXX.s3-website-ap-northeast-1.amazonaws.com/</code> のような固有の URL がバケットに対して付与される． そして，クライアントがこの URL にアクセスをすると，バケットの中にある <code>index.html</code> がクライアントに返され，ページがロードされる (どのファイルが返されるかは， <code>website_index_document=&quot;index.html&quot;</code> の部分で設定している．)</p>
<p>なお，この時点ではバケットは空である． HTML/CSS/JS など静的コンテンツの配置は，デプロイを行った後ほどのステップで行う．</p>
<p>より本格的なウェブページを運用する際には， public access mode の S3 バケットに， <a href="https://aws.amazon.com/cloudfront/" target="_blank" rel="noreferrer">CloudFront</a> という機能を追加することが一般的である． CloudFront により，　<strong>Content Delivery Nework (CDN)</strong> や暗号化された HTTPS 通信を設定することができる． CloudFront についての詳細は <a href="https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Introduction.html" target="_blank" rel="noreferrer">公式ドキュメンテーション &quot;What is Amazon CloudFront?&quot;</a> などを参照いただきたい．</p>
<p>今回のハンズオンでは説明の簡略化のため CloudFront の設定を行わなかったが，興味のある読者は次のリンクのプログラムが参考になるだろう．</p>
<ul>
<li><a href="https://github.com/aws-samples/aws-cdk-examples/tree/master/typescript/static-site" target="_blank" rel="noreferrer">https://github.com/aws-samples/aws-cdk-examples/tree/master/typescript/static-site</a></li>
</ul>
<p>今回の S3 バケットには， AWS によって付与されたランダムな URL がついている． これを． <code>example.com</code> のような自分のドメインでホストしたければ， AWS によって付与された URL を自分のドメインの DNS レコードに追加すればよい．</p>
<h3 id="api-のハンドラ関数" tabindex="-1">API のハンドラ関数 <a class="header-anchor" href="#api-のハンドラ関数" aria-label="Permalink to &quot;API のハンドラ関数&quot;">&ZeroWidthSpace;</a></h3>
<p>API リクエストが来たときに，リクエストされた処理を行う関数のことをハンドラ (handler) 関数とよぶ． <code>GET /haiku</code> の API に対してのハンドラ関数を Lambda で定義している部分を見てみよう．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">get_haiku_lambda </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> _lambda.Function(</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;GetHaiku&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">code</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">_lambda.Code.from_asset(</span><span style="color: #96D0FF">&quot;api&quot;</span><span style="color: #ADBAC7">),</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">handler</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;api.get_haiku&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">memory_size</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">512</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">common_params</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">get_haiku_lambda </span><span style="color: #D73A49">=</span><span style="color: #24292E"> _lambda.Function(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;GetHaiku&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">code</span><span style="color: #D73A49">=</span><span style="color: #24292E">_lambda.Code.from_asset(</span><span style="color: #032F62">&quot;api&quot;</span><span style="color: #24292E">),</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">handler</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;api.get_haiku&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">memory_size</span><span style="color: #D73A49">=</span><span style="color: #005CC5">512</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">**</span><span style="color: #24292E">common_params</span></span>
<span class="line"><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br></div></div><p>簡単なところから見ていくと， <code>memory_size=512</code> の箇所でメモリーの使用量を 512MB に指定している． また， <code>code=_lambda.Code.from_asset(&quot;api&quot;)</code> によって外部のディレクトリ (<code>api/</code>) を参照せよと指定しており， <code>handler=&quot;api.get_haiku&quot;</code> のところで <code>api.py</code> というファイルの <code>get_haiku()</code> という関数をハンドラ関数として実行せよ，と定義している．</p>
<p>次に，ハンドラ関数として使用されている <code>get_haiku()</code> のコードを見てみよう (<a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/bashoutter/api/api.py" target="_blank" rel="noreferrer">handson/bashoutter/api/api.py</a>)．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">ddb </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> boto3.resource(</span><span style="color: #96D0FF">&quot;dynamodb&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">table </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ddb.Table(os.environ[</span><span style="color: #96D0FF">&quot;TABLE_NAME&quot;</span><span style="color: #ADBAC7">])</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F47067">def</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">get_haiku</span><span style="color: #ADBAC7">(event, context):</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #96D0FF">&quot;&quot;&quot;</span></span>
<span class="line"><span style="color: #96D0FF">    handler for GET /haiku</span></span>
<span class="line"><span style="color: #96D0FF">    &quot;&quot;&quot;</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">try</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">        response </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> table.scan()</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        status_code </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">200</span></span>
<span class="line"><span style="color: #ADBAC7">        resp </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> response.get(</span><span style="color: #96D0FF">&quot;Items&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">except</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">Exception</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">as</span><span style="color: #ADBAC7"> e:</span></span>
<span class="line"><span style="color: #ADBAC7">        status_code </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">500</span></span>
<span class="line"><span style="color: #ADBAC7">        resp </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> {</span><span style="color: #96D0FF">&quot;description&quot;</span><span style="color: #ADBAC7">: </span><span style="color: #F47067">f</span><span style="color: #96D0FF">&quot;Internal server error. </span><span style="color: #F47067">{</span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">(e)</span><span style="color: #F47067">}</span><span style="color: #96D0FF">&quot;</span><span style="color: #ADBAC7">}</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">return</span><span style="color: #ADBAC7"> {</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #96D0FF">&quot;statusCode&quot;</span><span style="color: #ADBAC7">: status_code,</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #96D0FF">&quot;headers&quot;</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">HEADERS</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #96D0FF">&quot;body&quot;</span><span style="color: #ADBAC7">: json.dumps(resp, </span><span style="color: #F69D50">cls</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">DecimalEncoder)</span></span>
<span class="line"><span style="color: #ADBAC7">    }</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">ddb </span><span style="color: #D73A49">=</span><span style="color: #24292E"> boto3.resource(</span><span style="color: #032F62">&quot;dynamodb&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">table </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ddb.Table(os.environ[</span><span style="color: #032F62">&quot;TABLE_NAME&quot;</span><span style="color: #24292E">])</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D73A49">def</span><span style="color: #24292E"> </span><span style="color: #6F42C1">get_haiku</span><span style="color: #24292E">(event, context):</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #032F62">&quot;&quot;&quot;</span></span>
<span class="line"><span style="color: #032F62">    handler for GET /haiku</span></span>
<span class="line"><span style="color: #032F62">    &quot;&quot;&quot;</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">try</span><span style="color: #24292E">:</span></span>
<span class="line"><span style="color: #24292E">        response </span><span style="color: #D73A49">=</span><span style="color: #24292E"> table.scan()</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        status_code </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #005CC5">200</span></span>
<span class="line"><span style="color: #24292E">        resp </span><span style="color: #D73A49">=</span><span style="color: #24292E"> response.get(</span><span style="color: #032F62">&quot;Items&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">except</span><span style="color: #24292E"> </span><span style="color: #005CC5">Exception</span><span style="color: #24292E"> </span><span style="color: #D73A49">as</span><span style="color: #24292E"> e:</span></span>
<span class="line"><span style="color: #24292E">        status_code </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #005CC5">500</span></span>
<span class="line"><span style="color: #24292E">        resp </span><span style="color: #D73A49">=</span><span style="color: #24292E"> {</span><span style="color: #032F62">&quot;description&quot;</span><span style="color: #24292E">: </span><span style="color: #D73A49">f</span><span style="color: #032F62">&quot;Internal server error. </span><span style="color: #005CC5">{str</span><span style="color: #24292E">(e)</span><span style="color: #005CC5">}</span><span style="color: #032F62">&quot;</span><span style="color: #24292E">}</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">return</span><span style="color: #24292E"> {</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #032F62">&quot;statusCode&quot;</span><span style="color: #24292E">: status_code,</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #032F62">&quot;headers&quot;</span><span style="color: #24292E">: </span><span style="color: #005CC5">HEADERS</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #032F62">&quot;body&quot;</span><span style="color: #24292E">: json.dumps(resp, </span><span style="color: #E36209">cls</span><span style="color: #D73A49">=</span><span style="color: #24292E">DecimalEncoder)</span></span>
<span class="line"><span style="color: #24292E">    }</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br></div></div><p><code>response = table.scan()</code> で，俳句の格納された DynamoDB テーブルから，すべての要素を取り出している． もしなにもエラーが起きなければステータスコード 200 が返され，もしなにかエラーが起こればステータスコード 500 が返されるようになっている．</p>
<p>上記のような操作を，ほかの API についても繰り返すことで，すべての API のハンドラ関数が定義されている．</p>
<p><code>GET /haiku</code> のハンドラ関数で， <code>response = table.scan()</code> という部分があるが，実はこれは最善の書き方ではない． DynamoDB の <code>scan()</code> メソッドは，最大で 1MB までのデータしか返さない． データベースのサイズが大きく， 1MB 以上のデータがある場合には，再帰的に <code>scan()</code> メソッドをよぶ必要がある． 詳しくは <a href="https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/dynamodb.html#DynamoDB.Table.scan" target="_blank" rel="noreferrer">boto3 ドキュメンテーション</a> を参照．</p>
<h3 id="aws-における権限の管理-iam" tabindex="-1">AWS における権限の管理 (IAM) <a class="header-anchor" href="#aws-における権限の管理-iam" aria-label="Permalink to &quot;AWS における権限の管理 (IAM)&quot;">&ZeroWidthSpace;</a></h3>
<p>以下の部分のコードに注目してほしい．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">table.grant_read_data(get_haiku_lambda)</span></span>
<span class="line"><span style="color: #ADBAC7">table.grant_read_write_data(post_haiku_lambda)</span></span>
<span class="line"><span style="color: #ADBAC7">table.grant_read_write_data(patch_haiku_lambda)</span></span>
<span class="line"><span style="color: #ADBAC7">table.grant_read_write_data(delete_haiku_lambda)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">table.grant_read_data(get_haiku_lambda)</span></span>
<span class="line"><span style="color: #24292E">table.grant_read_write_data(post_haiku_lambda)</span></span>
<span class="line"><span style="color: #24292E">table.grant_read_write_data(patch_haiku_lambda)</span></span>
<span class="line"><span style="color: #24292E">table.grant_read_write_data(delete_haiku_lambda)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br></div></div><p>これまでは説明の簡略化のためにあえて触れてこなかったが， AWS には <a href="https://aws.amazon.com/iam/" target="_blank" rel="noreferrer">IAM (Identity and Access Management)</a> という重要な概念がある． IAM は基本的に，あるリソースがほかのリソースに対してどのような権限をもっているか，を規定するものである． Lambda は，デフォルトの状態ではほかのリソースにアクセスする権限をなにも有していない． したがって， Lambda 関数が DynamoDB のデータを読み書きするためには，それを許可するような IAM が Lambda 関数に付与されていなければならない．</p>
<p>CDK による <code>dynamodb.Table</code> オブジェクトには <code>grant_read_write_data()</code> という便利なメソッドが備わっており，アクセスを許可したい Lambda 関数を引数としてこのメソッドを呼ぶことで，データベースへの読み書きを許可する IAM を付与することができる． 同様に，CDK の <code>s3.Bucket</code> オブジェクトにも <code>grant_read_write()</code> というメソッドが備わっており，これによってバケットへの読み書きを許可することができる． このメソッドは，実は <a href="#sec_aws_batch">Hands-on #4: AWS Batch を使って機械学習のハイパーパラメータサーチを並列化する</a> で AWS Batch によるクラスターを構成した際に使用した． 興味のある読者は振り返ってコードを確認してみよう．</p>
<p>各リソースに付与する IAM は，<strong>必要最低限の権限を与えるにとどめる</strong>というのが基本方針である． これにより，セキュリティを向上させるだけでなく，意図していないプログラムからのデータベースへの読み書きを防止するという点で，バグを未然に防ぐことができる．</p>
<p>そのような理由により，このコードでは <code>GET</code> のハンドラー関数に対しては <code>grant_read_data()</code> によって， read 権限のみを付与している．</p>
<h3 id="api-gateway" tabindex="-1">API Gateway <a class="header-anchor" href="#api-gateway" aria-label="Permalink to &quot;API Gateway&quot;">&ZeroWidthSpace;</a></h3>
<p><a href="https://aws.amazon.com/api-gateway/" target="_blank" rel="noreferrer">API Gateway</a> とは， API の&quot;入り口&quot;として，API のリクエストパスに従って Lambda や EC2 などに接続を行うという機能を担う (<a href="#fig:bashoutter_api_gateway">figure_title</a>)． Lambda や EC2 によって行われた処理の結果は，再び API Gateway を経由してクライアントに返される． このように，クライアントとバックエンドサーバーの間に立ち， API のリソースパスに応じて接続先を振り分けるようなサーバーを<strong>ルーター</strong>，あるいは<strong>リバースプロキシ</strong>とよんだりする． 従来的には，ルーターにはそれ専用の仮想サーバーが置かれることが一般的であった． しかし， API Gateway はサーバーレスなルーターとして，固定されたサーバーを配置することなく， API のリクエストが来たときのみ起動し，API のルーティングを実行する． サーバーレスであることの当然の帰結として，アクセスの件数が増大したときにはそれにルーティングの処理能力を自動で増やす機能も備わっている．</p>
<p><img src="./assets/handson-bashoutter/api_gateway.png" alt="API Gateway"></p>
<p>API Gateway を配置することで，大量 (1 秒間に数千から数万件) の API リクエストに対応することのできるシステムを容易に構築することができる． API Gateway の料金は <a href="#tab_handson_05_apigateway_price">table_title</a> のように設定されている． また，無料利用枠により，月ごとに 100 万件までのリクエストは 0 円で利用できる．</p>
<table><caption>API Gateway の利用料金設定 (<a href="https://aws.amazon.com/api-gateway/pricing/">参照</a>)</caption><colgroup><col style="width: 50%" /><col style="width: 50%" /></colgroup><thead><tr class="header"><th>Number of Requests (per month)</th><th>Price (per million)</th></tr></thead><tbody><tr class="odd"><td><p>First 333 million</p></td><td><p>$4.25</p></td></tr><tr class="even"><td><p>Next 667 million</p></td><td><p>$3.53</p></td></tr><tr class="odd"><td><p>Next 19 billion</p></td><td><p>$3.00</p></td></tr><tr class="even"><td><p>Over 20 billion</p></td><td><p>$1.91</p></td></tr></tbody></table>
<p>ソースコードの該当箇所を見てみよう．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">api </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> apigw.RestApi(</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;BashoutterApi&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">default_cors_preflight_options</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">apigw.CorsOptions(</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #F69D50">allow_origins</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">apigw.Cors.</span><span style="color: #6CB6FF">ALL_ORIGINS</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #F69D50">allow_methods</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">apigw.Cors.</span><span style="color: #6CB6FF">ALL_METHODS</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    )</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">haiku </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> api.root.add_resource(</span><span style="color: #96D0FF">&quot;haiku&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">haiku.add_method(</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #96D0FF">&quot;GET&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    apigw.LambdaIntegration(get_haiku_lambda)</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">haiku.add_method(</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #96D0FF">&quot;POST&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    apigw.LambdaIntegration(post_haiku_lambda)</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">haiku_item_id </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> haiku.add_resource(</span><span style="color: #96D0FF">&quot;</span><span style="color: #F47067">{item_id}</span><span style="color: #96D0FF">&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">haiku_item_id.add_method(</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #96D0FF">&quot;PATCH&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    apigw.LambdaIntegration(patch_haiku_lambda)</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">haiku_item_id.add_method(</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #96D0FF">&quot;DELETE&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    apigw.LambdaIntegration(delete_haiku_lambda)</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">api </span><span style="color: #D73A49">=</span><span style="color: #24292E"> apigw.RestApi(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;BashoutterApi&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">default_cors_preflight_options</span><span style="color: #D73A49">=</span><span style="color: #24292E">apigw.CorsOptions(</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #E36209">allow_origins</span><span style="color: #D73A49">=</span><span style="color: #24292E">apigw.Cors.</span><span style="color: #005CC5">ALL_ORIGINS</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #E36209">allow_methods</span><span style="color: #D73A49">=</span><span style="color: #24292E">apigw.Cors.</span><span style="color: #005CC5">ALL_METHODS</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    )</span></span>
<span class="line"><span style="color: #24292E">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">haiku </span><span style="color: #D73A49">=</span><span style="color: #24292E"> api.root.add_resource(</span><span style="color: #032F62">&quot;haiku&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">haiku.add_method(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #032F62">&quot;GET&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    apigw.LambdaIntegration(get_haiku_lambda)</span></span>
<span class="line"><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">haiku.add_method(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #032F62">&quot;POST&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    apigw.LambdaIntegration(post_haiku_lambda)</span></span>
<span class="line"><span style="color: #24292E">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">haiku_item_id </span><span style="color: #D73A49">=</span><span style="color: #24292E"> haiku.add_resource(</span><span style="color: #032F62">&quot;</span><span style="color: #005CC5">{item_id}</span><span style="color: #032F62">&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">haiku_item_id.add_method(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #032F62">&quot;PATCH&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    apigw.LambdaIntegration(patch_haiku_lambda)</span></span>
<span class="line"><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">haiku_item_id.add_method(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #032F62">&quot;DELETE&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    apigw.LambdaIntegration(delete_haiku_lambda)</span></span>
<span class="line"><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br></div></div><ul>
<li>
<p>最初に， <code>api = apigw.RestApi()</code> により，空の API Gateway を作成している．</p>
</li>
<li>
<p>次に， <code>api.root.add_resource()</code> のメソッドを呼ぶことで， <code>/haiku</code> という API パスを追加している．</p>
</li>
<li>
<p>続いて， <code>add_method()</code> を呼ぶことで， <code>GET</code>, <code>POST</code> のメソッドを <code>/haiku</code> のパスに定義している．</p>
</li>
<li>
<p>さらに， <code>haiku.add_resource(&quot;{item_id}&quot;)</code> により， <code>/haiku/{item_id}</code> という API パスを追加している．</p>
</li>
<li>
<p>最後に， <code>add_method()</code> を呼ぶことにより， <code>PATCH</code>, <code>DELETE</code> のメソッドを <code>/haiku/{item_id}</code> のパスに定義している．</p>
</li>
</ul>
<p>このように， API Gateway の使い方は非常にシンプルで，逐次的に API パスとそこで実行されるメソッド・Lambda を記述していくだけでよい．</p>
<p>このプログラムで 新規 API を作成すると， ランダムな URL がその API のエンドポイントとして割り当てられる． これを． <code>api.example.com</code> のような自分のドメインでホストしたければ， AWS によって付与された URL を自分のドメインの DNS レコードに追加すればよい．</p>
<p>API Gateway で新規 API を作成したとき， <code>default_cors_preflight_options=</code> というパラメータで <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS" target="_blank" rel="noreferrer">Cross Origin Resource Sharing (CORS)</a> の設定を行っている． これは，ブラウザで走る Web アプリケーションと API を接続するときに必要な設定である．</p>
<h2 id="アプリケーションのデプロイ" tabindex="-1">アプリケーションのデプロイ <a class="header-anchor" href="#アプリケーションのデプロイ" aria-label="Permalink to &quot;アプリケーションのデプロイ&quot;">&ZeroWidthSpace;</a></h2>
<p>アプリケーションの中身が理解できたところで，早速デプロイを行ってみよう． デプロイの手順は，これまでのハンズオンとほとんど共通である． ここでは，コマンドのみ列挙する (<code>#</code> で始まる行はコメントである)． シークレットキーの設定も忘れずに (<a href="#aws_cli_install">AWS CLI のインストール</a>)．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390"># プロジェクトのディレクトリに移動</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cd</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">intro-aws/handson/bashoutter</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># venv を作成し，依存ライブラリのインストールを行う</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python3</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-m</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">venv</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.env</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">source</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.env/bin/activate</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">pip</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">install</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-r</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">requirements.txt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># デプロイを実行</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cdk</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">deploy</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D"># プロジェクトのディレクトリに移動</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cd</span><span style="color: #24292E"> </span><span style="color: #032F62">intro-aws/handson/bashoutter</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># venv を作成し，依存ライブラリのインストールを行う</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python3</span><span style="color: #24292E"> </span><span style="color: #005CC5">-m</span><span style="color: #24292E"> </span><span style="color: #032F62">venv</span><span style="color: #24292E"> </span><span style="color: #032F62">.env</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">source</span><span style="color: #24292E"> </span><span style="color: #032F62">.env/bin/activate</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">pip</span><span style="color: #24292E"> </span><span style="color: #032F62">install</span><span style="color: #24292E"> </span><span style="color: #005CC5">-r</span><span style="color: #24292E"> </span><span style="color: #032F62">requirements.txt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># デプロイを実行</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cdk</span><span style="color: #24292E"> </span><span style="color: #032F62">deploy</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br></div></div><p>デプロイのコマンドが無事に実行されれば， <a href="#handson_05_cdk_output">figure_title</a> のような出力が得られるはずである． ここで表示されている <code>Bashoutter.BashoutterApiEndpoint = XXXX</code>, <code>Bashoutter.BucketUrl = YYYY</code> の二つ文字列はあとで使うのでメモしておこう．</p>
<p><img src="./assets/handson-bashoutter/cdk_output.png" alt="CDKデプロイ実行後の出力"></p>
<p>AWS コンソールにログインして，デプロイされたスタックを確認してみよう． まずは，コンソールから API Gateway のページに行く． すると， <a href="#handson_05_apigw_console_list">figure_title</a> のような画面が表示され，デプロイ済みの API エンドポイントの一覧が確認できる．</p>
<p><img src="./assets/handson-bashoutter/apigw_console_list.png" alt="API Gateway コンソール画面 (1)"></p>
<p>今回デプロイした &quot;BashoutterApi&quot; という名前の API をクリックすることで <a href="#handson_05_apigw_console_detail">figure_title</a> のような画面に遷移し，詳細情報を閲覧できる． <code>GET /haiku</code>, <code>POST /haiku</code> などが定義されていることが確認できる．</p>
<p>それぞれのメソッドをクリックすると，そのメソッドの詳細情報を確認できる． API Gateway は，前述したルーティングの機能だけでなく，認証機能などを追加することも可能である． このハンズオンではとくにこれらの機能は使用しないが， &quot;Method Request&quot; と書いてある項目などがそれに相当する． 次に， <a href="#handson_05_apigw_console_detail">figure_title</a> で画面右端の赤色で囲った部分に，この API で呼ばれる Lambda 関数が指定されていることに注目しよう． 関数名をクリックと，該当する Lambda のコンソールに遷移し，関数の中身を閲覧することが可能である．</p>
<p><img src="./assets/handson-bashoutter/apigw_console_detail.png" alt="API Gateway コンソール画面 (2)"></p>
<p>次に， S3 のコンソール画面に移ってみよう． <code>bashouter-</code> で始まるランダムな名前のバケットが見つかるはずである (<a href="#handson_05_s3_console">figure_title</a>)．</p>
<p><img src="./assets/handson-bashoutter/s3_console.png" alt="S3 コンソール画面"></p>
<p>バケットの名前をクリックすることで，バケットの中身を確認してみよう． <code>index.html</code> のほか， <code>css/</code>, <code>js/</code> などのディレクトリがあるのが確認できるだろう (<a href="#handson_05_s3_contents">figure_title</a>)． これらが，ウェブページの&quot;枠&quot;を定義している静的コンテンツである．</p>
<p><img src="./assets/handson-bashoutter/s3_contents.png" alt="S3 バケットの中身"></p>
<h2 id="api-リクエストを送信する" tabindex="-1">API リクエストを送信する <a class="header-anchor" href="#api-リクエストを送信する" aria-label="Permalink to &quot;API リクエストを送信する&quot;">&ZeroWidthSpace;</a></h2>
<p>それでは，デプロイしたアプリケーションに対し，実際に API リクエストを送信してみよう． まずはコマンドラインから API を送信する演習を行おう． S3 に配置した GUI は一旦おいておく．</p>
<p>ここではコマンドラインから HTTP API リクエストを送信するためのシンプルな HTTP クライアントである <a href="https://httpie.org/" target="_blank" rel="noreferrer">HTTPie</a> を使ってみよう． HTTPie は，スタックをデプロイするときに Python 仮想環境 (venv) を作成したとき，一緒にインストールされている． 念のためインストールがうまくいっているか確認するには，仮想環境を立ち上げたあとコマンドラインに <code>http</code> と打ってみる． ヘルプのメッセージが出力されたら準備 OK である．</p>
<p>まず，先ほどデプロイを実行したときに得られた API のエンドポイントの URL (<code>Bashoutter.BashoutterApiEndpoint = XXXX</code> で得られた <code>XXXX</code> の文字列) をコマンドラインの変数に設定しておく．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">export</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ENDPOINT_URL=XXXX</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">export</span><span style="color: #24292E"> </span><span style="color: #032F62">ENDPOINT_URL=XXXX</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>次に，俳句の一覧を取得するため， <code>GET /haiku</code> の API を送信してみよう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">http</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">GET</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;${</span><span style="color: #ADBAC7">ENDPOINT_URL</span><span style="color: #96D0FF">}/haiku&quot;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">http</span><span style="color: #24292E"> </span><span style="color: #032F62">GET</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;${</span><span style="color: #24292E">ENDPOINT_URL</span><span style="color: #032F62">}/haiku&quot;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>現時点では，まだだれも俳句を投稿していないので，空の配列 (<code>[]</code>) が返ってくる．</p>
<p>それでは次に， <code>POST /haiku</code> を使って俳句を投稿してみよう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">http</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">POST</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;${</span><span style="color: #ADBAC7">ENDPOINT_URL</span><span style="color: #96D0FF">}/haiku&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">\</span></span>
<span class="line"><span style="color: #ADBAC7">username=</span><span style="color: #96D0FF">&quot;松尾芭蕉&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">\</span></span>
<span class="line"><span style="color: #ADBAC7">first=</span><span style="color: #96D0FF">&quot;閑さや&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">\</span></span>
<span class="line"><span style="color: #ADBAC7">second=</span><span style="color: #96D0FF">&quot;岩にしみ入る&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">\</span></span>
<span class="line"><span style="color: #ADBAC7">third=</span><span style="color: #96D0FF">&quot;蝉の声&quot;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">http</span><span style="color: #24292E"> </span><span style="color: #032F62">POST</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;${</span><span style="color: #24292E">ENDPOINT_URL</span><span style="color: #032F62">}/haiku&quot;</span><span style="color: #24292E"> </span><span style="color: #005CC5">\</span></span>
<span class="line"><span style="color: #24292E">username=</span><span style="color: #032F62">&quot;松尾芭蕉&quot;</span><span style="color: #24292E"> </span><span style="color: #005CC5">\</span></span>
<span class="line"><span style="color: #24292E">first=</span><span style="color: #032F62">&quot;閑さや&quot;</span><span style="color: #24292E"> </span><span style="color: #005CC5">\</span></span>
<span class="line"><span style="color: #24292E">second=</span><span style="color: #032F62">&quot;岩にしみ入る&quot;</span><span style="color: #24292E"> </span><span style="color: #005CC5">\</span></span>
<span class="line"><span style="color: #24292E">third=</span><span style="color: #032F62">&quot;蝉の声&quot;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br></div></div><p>次のような出力が得られるだろう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">HTTP/1.1</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">201</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">Created</span></span>
<span class="line"><span style="color: #F69D50">Connection:</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">keep-alive</span></span>
<span class="line"><span style="color: #F69D50">Content-Length:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">49</span></span>
<span class="line"><span style="color: #F69D50">Content-Type:</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">application/json</span></span>
<span class="line"><span style="color: #6CB6FF">....</span></span>
<span class="line"><span style="color: #ADBAC7">{</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">&quot;description&quot;</span><span style="color: #6CB6FF">:</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;Successfully added a new haiku&quot;</span></span>
<span class="line"><span style="color: #ADBAC7">}</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">HTTP/1.1</span><span style="color: #24292E"> </span><span style="color: #005CC5">201</span><span style="color: #24292E"> </span><span style="color: #032F62">Created</span></span>
<span class="line"><span style="color: #6F42C1">Connection:</span><span style="color: #24292E"> </span><span style="color: #032F62">keep-alive</span></span>
<span class="line"><span style="color: #6F42C1">Content-Length:</span><span style="color: #24292E"> </span><span style="color: #005CC5">49</span></span>
<span class="line"><span style="color: #6F42C1">Content-Type:</span><span style="color: #24292E"> </span><span style="color: #032F62">application/json</span></span>
<span class="line"><span style="color: #005CC5">....</span></span>
<span class="line"><span style="color: #24292E">{</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #6F42C1">&quot;description&quot;</span><span style="color: #005CC5">:</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;Successfully added a new haiku&quot;</span></span>
<span class="line"><span style="color: #24292E">}</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br></div></div><p>新しい俳句を投稿することに成功したようである． 本当に俳句が追加されたか，再び GET リクエストを呼ぶことで確認してみよう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">http</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">GET</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;${</span><span style="color: #ADBAC7">ENDPOINT_URL</span><span style="color: #96D0FF">}/haiku&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F69D50">HTTP/1.1</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">200</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">OK</span></span>
<span class="line"><span style="color: #F69D50">Connection:</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">keep-alive</span></span>
<span class="line"><span style="color: #F69D50">Content-Length:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">258</span></span>
<span class="line"><span style="color: #F69D50">Content-Type:</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">application/json</span></span>
<span class="line"><span style="color: #6CB6FF">...</span></span>
<span class="line"><span style="color: #ADBAC7">[</span></span>
<span class="line"><span style="color: #ADBAC7">    {</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #96D0FF">&quot;created_at&quot;</span><span style="color: #ADBAC7">: </span><span style="color: #96D0FF">&quot;2020-07-06T02:46:04+00:00&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #96D0FF">&quot;first&quot;</span><span style="color: #ADBAC7">: </span><span style="color: #96D0FF">&quot;閑さや&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #96D0FF">&quot;item_id&quot;</span><span style="color: #ADBAC7">: </span><span style="color: #96D0FF">&quot;7e91c5e4d7ad47909e0ac14c8bbab05b&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #96D0FF">&quot;likes&quot;</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">0.0</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #96D0FF">&quot;second&quot;</span><span style="color: #ADBAC7">: </span><span style="color: #96D0FF">&quot;岩にしみ入る&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #96D0FF">&quot;third&quot;</span><span style="color: #ADBAC7">: </span><span style="color: #96D0FF">&quot;蝉の声&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #96D0FF">&quot;username&quot;</span><span style="color: #ADBAC7">: </span><span style="color: #96D0FF">&quot;松尾芭蕉&quot;</span></span>
<span class="line"><span style="color: #ADBAC7">    }</span></span>
<span class="line"><span style="color: #ADBAC7">]</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">http</span><span style="color: #24292E"> </span><span style="color: #032F62">GET</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;${</span><span style="color: #24292E">ENDPOINT_URL</span><span style="color: #032F62">}/haiku&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6F42C1">HTTP/1.1</span><span style="color: #24292E"> </span><span style="color: #005CC5">200</span><span style="color: #24292E"> </span><span style="color: #032F62">OK</span></span>
<span class="line"><span style="color: #6F42C1">Connection:</span><span style="color: #24292E"> </span><span style="color: #032F62">keep-alive</span></span>
<span class="line"><span style="color: #6F42C1">Content-Length:</span><span style="color: #24292E"> </span><span style="color: #005CC5">258</span></span>
<span class="line"><span style="color: #6F42C1">Content-Type:</span><span style="color: #24292E"> </span><span style="color: #032F62">application/json</span></span>
<span class="line"><span style="color: #005CC5">...</span></span>
<span class="line"><span style="color: #24292E">[</span></span>
<span class="line"><span style="color: #24292E">    {</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #032F62">&quot;created_at&quot;</span><span style="color: #24292E">: </span><span style="color: #032F62">&quot;2020-07-06T02:46:04+00:00&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #032F62">&quot;first&quot;</span><span style="color: #24292E">: </span><span style="color: #032F62">&quot;閑さや&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #032F62">&quot;item_id&quot;</span><span style="color: #24292E">: </span><span style="color: #032F62">&quot;7e91c5e4d7ad47909e0ac14c8bbab05b&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #032F62">&quot;likes&quot;</span><span style="color: #24292E">: </span><span style="color: #005CC5">0.0</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #032F62">&quot;second&quot;</span><span style="color: #24292E">: </span><span style="color: #032F62">&quot;岩にしみ入る&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #032F62">&quot;third&quot;</span><span style="color: #24292E">: </span><span style="color: #032F62">&quot;蝉の声&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #032F62">&quot;username&quot;</span><span style="color: #24292E">: </span><span style="color: #032F62">&quot;松尾芭蕉&quot;</span></span>
<span class="line"><span style="color: #24292E">    }</span></span>
<span class="line"><span style="color: #24292E">]</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br></div></div><p>素晴らしい！</p>
<p>次に， <code>PATCH /haiku/{item_id}</code> を呼ぶことでこの俳句にいいねを追加してみよう． 一つ前のコマンドで取得した俳句の <code>item_id</code> を，次のコマンドの <code>XXXX</code> に代入した上で実行しよう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">http</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">PATCH</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;${</span><span style="color: #ADBAC7">ENDPOINT_URL</span><span style="color: #96D0FF">}/haiku/XXXX&quot;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">http</span><span style="color: #24292E"> </span><span style="color: #032F62">PATCH</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;${</span><span style="color: #24292E">ENDPOINT_URL</span><span style="color: #032F62">}/haiku/XXXX&quot;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p><code>{&quot;description&quot;: &quot;OK&quot;}</code> という出力が得られるはずである． 再び GET リクエストを送ることで，いいね (<code>likes</code>) が 1 増えたことを確認しよう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">http</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">GET</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;${</span><span style="color: #ADBAC7">ENDPOINT_URL</span><span style="color: #96D0FF">}/haiku&quot;</span></span>
<span class="line"><span style="color: #6CB6FF">...</span></span>
<span class="line"><span style="color: #ADBAC7">[</span></span>
<span class="line"><span style="color: #ADBAC7">    {</span></span>
<span class="line"><span style="color: #ADBAC7">        ...</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #96D0FF">&quot;likes&quot;</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">1.0</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        ...</span></span>
<span class="line"><span style="color: #ADBAC7">    }</span></span>
<span class="line"><span style="color: #ADBAC7">]</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">http</span><span style="color: #24292E"> </span><span style="color: #032F62">GET</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;${</span><span style="color: #24292E">ENDPOINT_URL</span><span style="color: #032F62">}/haiku&quot;</span></span>
<span class="line"><span style="color: #005CC5">...</span></span>
<span class="line"><span style="color: #24292E">[</span></span>
<span class="line"><span style="color: #24292E">    {</span></span>
<span class="line"><span style="color: #24292E">        ...</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #032F62">&quot;likes&quot;</span><span style="color: #24292E">: </span><span style="color: #005CC5">1.0</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        ...</span></span>
<span class="line"><span style="color: #24292E">    }</span></span>
<span class="line"><span style="color: #24292E">]</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br></div></div><p>最後に， DELETE リクエストを送ることで俳句をデータベースから削除しよう． <code>XXXX</code> は <code>item_id</code> の値で置き換えたうえで次のコマンドを実行する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">http</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">DELETE</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;${</span><span style="color: #ADBAC7">ENDPOINT_URL</span><span style="color: #96D0FF">}/haiku/XXXX&quot;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">http</span><span style="color: #24292E"> </span><span style="color: #032F62">DELETE</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;${</span><span style="color: #24292E">ENDPOINT_URL</span><span style="color: #032F62">}/haiku/XXXX&quot;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>再び GET リクエストを送ることで，返り値が空 (<code>[]</code>) になっていることを確認しよう．</p>
<p>これで，俳句の投稿・取得・削除そしていいねの追加，といった基本的な API がきちんと動作していることが確認できた．</p>
<h2 id="大量の-api-リクエストをシミュレートする" tabindex="-1">大量の API リクエストをシミュレートする <a class="header-anchor" href="#大量の-api-リクエストをシミュレートする" aria-label="Permalink to &quot;大量の API リクエストをシミュレートする&quot;">&ZeroWidthSpace;</a></h2>
<p>さて，前節ではマニュアルで一つずつ俳句を投稿した． 多数のユーザーがいるような SNS では，1 秒間に数千件以上の投稿がされている． 今回はサーバーレスアーキテクチャを採用したことで，そのような瞬間的な大量アクセスにも容易に対応できるようなシステムが自動的に構築されている． このポイントを実証するため，ここでは大量の API が送信された状況をシミュレートしてみよう．</p>
<p><a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/bashoutter/client.py" target="_blank" rel="noreferrer">handson/bashoutter/client.py</a> に，大量の API リクエストをシミュレートするためのプログラムが書かれている． このプログラムを使用すると， <code>POST /haiku</code> の API リクエストを指定された回数だけ実行することができる．</p>
<p>テストとして， API を 300 回実行してみよう． 次のコマンドを実行する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">client.py</span><span style="color: #ADBAC7"> $ENDPOINT_URL </span><span style="color: #96D0FF">post_many</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">300</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python</span><span style="color: #24292E"> </span><span style="color: #032F62">client.py</span><span style="color: #24292E"> $ENDPOINT_URL </span><span style="color: #032F62">post_many</span><span style="color: #24292E"> </span><span style="color: #005CC5">300</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>数秒のうちに実行が完了するだろう． これがもし，単一のサーバーからなる API だったとしたら，このような大量のリクエストの処理にはもっと時間がかかっただろう． 最悪の場合には，サーバーダウンにもつながっていたかもしれない． したがって，今回作成したサーバーレスアプリケーションは，とてもシンプルながらも 1 秒間に数百件の処理を行えるような，スケーラブルなクラウドシステムであることがわかる． サーバーレスでクラウドを設計することの利点を垣間見ることができただろうか？</p>
<p>先述のコマンドにより大量の俳句を投稿するとデータベースに無駄なデータがどんどん溜まってしまう． データベースを完全に空にするには，次のコマンドを使用する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">client.py</span><span style="color: #ADBAC7"> $ENDPOINT_URL </span><span style="color: #96D0FF">clear_database</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python</span><span style="color: #24292E"> </span><span style="color: #032F62">client.py</span><span style="color: #24292E"> $ENDPOINT_URL </span><span style="color: #032F62">clear_database</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><h2 id="bashoutter-gui-を動かしてみる" tabindex="-1">Bashoutter GUI を動かしてみる <a class="header-anchor" href="#bashoutter-gui-を動かしてみる" aria-label="Permalink to &quot;Bashoutter GUI を動かしてみる&quot;">&ZeroWidthSpace;</a></h2>
<p>前節ではコマンドラインから API を送信する演習を行った． ウェブアプリケーションでは，これと同じことがウェブブラウザの背後で行われ，ページのコンテンツが表示されている (<a href="#fig:web_server">figure_title</a> 参照)． 最後に， API が GUI と統合されるとどうなるのか，見てみよう．</p>
<p>CDK のコードで， Public access mode の S3 バケットを作成したことを思い出してほしい． 最初のステップとして，ここにウェブサイトのコンテンツをアップロードしよう． ハンズオンのソースコードの中に <code>gui/dist</code> というフォルダが見つかるはずである． ここにはビルド済みのウェブサイトの静的コンテンツ (HTML/CSS/JavaScript) が入っている． AWS CLI のコマンドを使うことでこれらのファイルを S3 にアップロードしよう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">s3</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cp</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--recursive</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">./gui/dist</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">s3://</span><span style="color: #F47067">&lt;</span><span style="color: #96D0FF">BUCKET_NAM</span><span style="color: #ADBAC7">E</span><span style="color: #F47067">&gt;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">aws</span><span style="color: #24292E"> </span><span style="color: #032F62">s3</span><span style="color: #24292E"> </span><span style="color: #032F62">cp</span><span style="color: #24292E"> </span><span style="color: #005CC5">--recursive</span><span style="color: #24292E"> </span><span style="color: #032F62">./gui/dist</span><span style="color: #24292E"> </span><span style="color: #032F62">s3://</span><span style="color: #D73A49">&lt;</span><span style="color: #032F62">BUCKET_NAM</span><span style="color: #24292E">E</span><span style="color: #D73A49">&gt;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>コマンドを実行する際は， Bashoutter ハンズオンのディレクトリから行うこと (<code>./gui/dist</code> に注目)，そして <code>&lt;BUCKET_NAME&gt;</code> にはデプロイした自身のバケットの名前が入る点に注意． 念のため，AWS コンソールにログインし，バケットにファイルがアップロードされている点を確認しておこう．</p>
<p>なお，今回は GUI の説明はとくに行わないが， Bashoutter のウェブサイトは <a href="https://vuejs.org/" target="_blank" rel="noreferrer">Vue.js</a> と <a href="https://vuetifyjs.com/" target="_blank" rel="noreferrer">Vuetify</a> という UI フレームワークを使って作成した． Vue を使うことで， Single page application (SPA) の技術でウェブサイトの画面がレンダリングされる． ソースコードは <a href="https://github.com/andatoshiki/toshiki-notebooktree/main/handson/bashoutter/gui" target="_blank" rel="noreferrer">handson/bashoutter/gui</a> のディレクトリの中にあるので，興味のある読者は確認してみるとよい．</p>
<p>アップトードが完了したところで，続いてデプロイを実行したときにコマンドラインの出力を見直してみよう． <code>Bashoutter.BucketUrl=</code> で与えられた URL が見つかるはずである (<a href="#handson_05_cdk_output">figure_title</a>)． これは，先述したとおり， Public access mode の S3 バケットの URL である．</p>
<p>ウェブブラウザを開き，アドレスバーに S3 の URL を入力しへアクセスしてみよう． すると， <a href="#handson_05_bashoutter_2">figure_title</a> のようなページが表示されるはずである．</p>
<p><img src="./assets/handson-bashoutter/bashoutter_2.png" alt="&quot;Bashoutter&quot; の GUI 画面"></p>
<p>ページが表示されたら，一番上の &quot;API Endpoint URL&quot; と書いてあるテキストボックスに，今回デプロイした <strong>API Gateway の URL を入力</strong>する (今回のアプリケーションでは，API Gateway の URL はランダムに割り当てられるのでこのような GUI の仕様になっている)． そうしたら，画面の &quot;REFRESH&quot; と書いてあるボタンを押してみよう． データベースに俳句が登録済みであれば，俳句の一覧が表示されるはずである． 各俳句の左下にあるハートのアイコンをクリックすることで， &quot;like&quot; の票を入れることができる．</p>
<p>新しい俳句を投稿するには，五七五と投稿者の名前を入力して， &quot;POST&quot; を押す． &quot;POST&quot; を押した後は，再び &quot;REFRESH&quot; ボタンを押すことで最新の俳句のリストをデータベースから取得する．</p>
<h2 id="アプリケーションの削除" tabindex="-1">アプリケーションの削除 <a class="header-anchor" href="#アプリケーションの削除" aria-label="Permalink to &quot;アプリケーションの削除&quot;">&ZeroWidthSpace;</a></h2>
<p>これで， Bashoutter プロジェクトが完成した！ この SNS は，インターネットを通じて世界のどこからでもアクセスできる状態にある． また， <a href="#simulating_many_apis">大量の API リクエストをシミュレートする</a> で見たように，大量のユーザーの同時アクセスによる負荷がかかっても，柔軟にスケールが行われ遅延なく処理を行うことができる． 極めて簡素ながらも，立派なウェブサービスとしてのスペックは満たしているのである！</p>
<p>Bashoutter アプリを存分に楽しむことができたら，最後に忘れずにスタックを削除しよう．</p>
<p>コマンドラインからスタックの削除を実行するには，次のコマンドを使う．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cdk</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">destroy</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cdk</span><span style="color: #24292E"> </span><span style="color: #032F62">destroy</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>CDK のバージョンによっては S3 のバケットが空でないと， <code>cdk destroy</code> がエラーを出力する場合がある． この場合はスタックを削除する前に， S3 バケットの中身をすべて削除しなければならない．</p>
<p>コンソールから実行するには， S3 コンソールに行き，バケットの中身を開いたうえで，すべてのファイルを選択し， &quot;Actions&quot; → &quot;Delete&quot; を実行すればよいい．</p>
<p>コマンドラインから実行するには， 次のコマンドを使う． &lt;BUCKET NAME&gt; のところは，自分の バケットの名前 (&quot;<code>BashoutterBucketXXXX</code>&quot; というパターンの名前がついているはずである) に置き換えることを忘れずに．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">s3</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">rm</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">&lt;</span><span style="color: #96D0FF">BUCKET</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">NAM</span><span style="color: #ADBAC7">E</span><span style="color: #F47067">&gt;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--recursive</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">aws</span><span style="color: #24292E"> </span><span style="color: #032F62">s3</span><span style="color: #24292E"> </span><span style="color: #032F62">rm</span><span style="color: #24292E"> </span><span style="color: #D73A49">&lt;</span><span style="color: #032F62">BUCKET</span><span style="color: #24292E"> </span><span style="color: #032F62">NAM</span><span style="color: #24292E">E</span><span style="color: #D73A49">&gt;</span><span style="color: #24292E"> </span><span style="color: #005CC5">--recursive</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><h2 id="小括-2" tabindex="-1">小括 <a class="header-anchor" href="#小括-2" aria-label="Permalink to &quot;小括&quot;">&ZeroWidthSpace;</a></h2>
<p>ここまでが，本書第三部の内容であった．</p>
<p>第三部では，クラウドの応用として，一般の人に使ってもらうようなウェブアプリケーション・データベースをどのようにして作るのか，という点に焦点を当てて，説明を行った． その中で，従来的なクラウドシステムの設計と，ここ数年の最新の設計方法であるサーバーレスアーキテクチャについて解説した． <a href="#sec_intro_serverless">Hands-on #5: サーバーレス入門</a> では， AWS でのサーバーレスの実践として， Lambda, S3, DynamoDB のハンズオンを行った． 最後に， <a href="#sec_bashoutter">Hands-on #6: Bashoutter</a> では，これらの技術を統合することで，完全サーバーレスなウェブアプリケーション &quot;Bashoutter&quot; を作成した．</p>
<p>これらの演習を通じて，世の中のウェブサービスがどのようにしてでき上がっているのか，少し理解が深まっただろうか？ また，そのようなウェブアプリケーションを自分が作りたいと思ったとき，今回のハンズオンがその出発点となることができたならば幸いである．</p>
<h1 id="まとめ" tabindex="-1">まとめ <a class="header-anchor" href="#まとめ" aria-label="Permalink to &quot;まとめ&quot;">&ZeroWidthSpace;</a></h1>
<h1 id="appendix-環境構築" tabindex="-1">Appendix: 環境構築 <a class="header-anchor" href="#appendix-環境構築" aria-label="Permalink to &quot;Appendix: 環境構築&quot;">&ZeroWidthSpace;</a></h1>
<p>本書を読み進めるにあたって，ハンズオンのプログラムを実行するための環境を自分のローカルマシンにセットアップしなければならない． ここでは， AWS やコマンドラインの初心者を想定して，本章で必要なソフトウェアやライブラリのインストールなどを簡単に解説する． 以下に簡単な目次を示そう． 既に環境構築が済んでいる場合は適宜読み飛ばしていただき，関係のある箇所のみ目を通せば良い．</p>
<ul>
<li>
<p>AWS アカウントの取得 (<a href="#sec:create_aws_account">AWS アカウントの取得</a>)</p>
</li>
<li>
<p>AWS シークレットキーの作成 (<a href="#aws_secrets">AWS のシークレットキーの作成</a>)</p>
</li>
<li>
<p>AWS CLI のインストール (<a href="#aws_cli_install">AWS CLI のインストール</a>)</p>
</li>
<li>
<p>AWS CDK のインストール (<a href="#aws_cdk_install">AWS CDK のインストール</a>)</p>
</li>
<li>
<p>WSL のインストール (<a href="#sec:install_wsl">WSL のインストール</a>)</p>
</li>
<li>
<p>Docker のインストール (<a href="#sec:install_docker">Docker のインストール</a>)</p>
</li>
<li>
<p>Python venv クイックガイド (<a href="#venv_quick_guide">Python クイックガイド</a>)</p>
</li>
<li>
<p>ハンズオン実行用の Docker image の使い方 (<a href="#sec_handson_docker">ハンズオン実行用の Docker image の使い方</a>)</p>
</li>
</ul>
<p>使用する OS は Linux/Mac/Windows のどれを用いても構わない． Windows のユーザーは， Windows Subsytem for Linux (WSL) を使用することを想定している (<a href="#sec:install_wsl">WSL のインストール</a>)．</p>
<p>また，本書のハンズオンを実行するための <a href="https://hub.docker.com/repository/docker/tomomano/labc" target="_blank" rel="noreferrer">Docker イメージ</a> を提供している． これを用いると， AWS CLI/CDK や Python の設定などをスキップできるので， Docker の使用方法を知っている読者には便利だろう．</p>
<h2 id="aws-アカウントの取得" tabindex="-1">AWS アカウントの取得 <a class="header-anchor" href="#aws-アカウントの取得" aria-label="Permalink to &quot;AWS アカウントの取得&quot;">&ZeroWidthSpace;</a></h2>
<p>本書で提供するハンズオンを実際に自分で試すには，読者自身で AWS のアカウントの作成をする必要がある． 詳しいアカウントの作成の手順は <a href="https://aws.amazon.com/jp/register-flow/" target="_blank" rel="noreferrer">公式のドキュメンテーション</a> に書かれているので，そちらも参照していただきたい． 以下の手順に従ってアカウントの作成を行う．</p>
<p>まず，ウェブブラウザから <a href="https://aws.amazon.com/console/" target="_blank" rel="noreferrer">AWS コンソール</a> にアクセスし，右上の <code>Create an AWS Account</code> をクリックする (<a href="#fig:aws-signup-1">figure_title</a> で実線で囲った部分)．</p>
<p><img src="./assets/signup-1.png" alt="サインアップ (1): AWS コンソールにアクセス"></p>
<p>次に，遷移した先のページでメールアドレスとパスワードなどの登録を行う (<a href="#fig:aws-signup-3">figure_title</a>)．</p>
<p><img src="./assets/signup-3.png" alt="サインアップ (2): メールアドレス・パスワードなどの登録．"></p>
<p>続いて，住所や電話番号などを訊かれるので，すべて入力しよう (<a href="#fig:aws-signup-4">figure_title</a>)．</p>
<p><img src="./assets/signup-4.png" alt="サインアップ (3): 住所・電話番号の入力"></p>
<p>次に，クレジットカードの情報の登録を求められる (<a href="#fig:aws-signup-5">figure_title</a>)． 個人で AWS を利用する場合は，利用料金の請求はクレジットカードを経由して行われる． クレジットカードの登録なしには AWS を使い始めることはできないことに注意．</p>
<p><img src="./assets/signup-5.png" alt="サインアップ (4): クレジットカードの登録"></p>
<p>次の画面では，携帯電話の SMS またはボイスメッセージを利用した本人確認が求められる (<a href="#fig:aws-signup-6">figure_title</a>)． 希望の認証方法を選択し，自分の携帯電話番号を入力しよう．</p>
<p><img src="./assets/signup-6.png" alt="サインアップ (5): 携帯電話による本人確認"></p>
<p>無事に本人確認が完了すると，最後にサポートプランの選択を求められる (<a href="#fig:aws-signup-8">figure_title</a>)． 無料の Basic support を選択しておけば問題ない．</p>
<p><img src="./assets/signup-8.png" alt="サインアップ (6): サポートプランの選択"></p>
<p>以上のステップにより，アカウントの作成が完了する (<a href="#fig:aws-signup-9">figure_title</a>)． 早速ログインをして， AWS コンソールにアクセスできるか確認しておこう．</p>
<p><img src="./assets/signup-9.png" alt="サインアップ (7): アカウントの作成が完了した"></p>
<h2 id="aws-のシークレットキーの作成" tabindex="-1">AWS のシークレットキーの作成 <a class="header-anchor" href="#aws-のシークレットキーの作成" aria-label="Permalink to &quot;AWS のシークレットキーの作成&quot;">&ZeroWidthSpace;</a></h2>
<p>AWS シークレットキーとは， AWS CLI や AWS CDK から AWS の API を操作するときに，ユーザー認証を行うための鍵のことである． AWS CLI/CDK を使うには，最初にシークレットキーを発行する必要がある． AWS シークレットキーの詳細は <a href="https://docs.aws.amazon.com/general/latest/gr/aws-sec-cred-types.html" target="_blank" rel="noreferrer">公式ドキュメンテーション &quot;Understanding and getting your AWS credentials&quot;</a> を参照．</p>
<ol>
<li>
<p>AWS コンソールにログインする．</p>
</li>
<li>
<p>画面右上のアカウント名をクリックし，表示されるプルダウンメニューから &quot;My Security Credentials&quot; を選択 (<a href="#fig:aws_secret_key_1">figure_title</a>)</p>
</li>
<li>
<p>&quot;Access keys for CLI, SDK, &amp; API access&quot; の下にある &quot;Create accesss key&quot; のボタンをクリックする (<a href="#fig:aws_secret_key_2">figure_title</a>)</p>
</li>
<li>
<p>表示された Access key ID, Secret access key を記録しておく (画面を閉じると二度と表示されない)．</p>
</li>
<li>
<p>鍵を忘れてしまった場合などは，同じ手順で再発行が可能である．</p>
</li>
<li>
<p>発行したシークレットキーは， <code>~/.aws/credentials</code> のファイルに書き込むか，環境変数に設定するなどして使う (詳しくは <a href="#aws_cli_install">AWS CLI のインストール</a>)．</p>
</li>
</ol>
<p><img src="./assets/aws_secret_key_1.png" alt="AWS シークレットキーの発行1"></p>
<p><img src="./assets/aws_secret_key_2.png" alt="AWS シークレットキーの発行2"></p>
<p><strong>AWS Educate Starter Account</strong> を用いている場合は，次の手順でシークレットキーを確認する．</p>
<ul>
<li>
<p>AWS Educate のコンソール画面から， <code>vocareum</code> のコンソールに移動する (<a href="#fig:vocareum_console">figure_title</a>)．</p>
</li>
<li>
<p><code>Account Details</code> をクリックし，続いて <code>AWS CLI: Show</code> をクリックする．</p>
</li>
<li>
<p><code>aws_access_key_id</code>, <code>aws_secret_access_key</code>, <code>aws_session_token</code> が表示される (<a href="#fig:vocareum_secret">figure_title</a>)． ここで表示された内容を <code>~/.aws/credentials</code> にコピーする (<a href="#aws_cli_install">AWS CLI のインストール</a> 参照)． <code>aws_session_token</code> の箇所も漏らさずコピーすること．</p>
</li>
<li>
<p>続いて， <code>~/.aws/config</code> というファイルを用意し，次の内容を書き込む． 現時点では AWS Starter Account は <code>us-east-1</code> リージョンでしか利用できないためである．</p>
<p>[default]
region = us-east-1
output = json</p>
</li>
<li>
<p>上記の説明ではプロファイル名が <code>default</code> となっていたが，これは自分の好きな名前に変更してもよい． <code>default</code> 以外の名前を使用する場合は，コマンドを実行するときにプロファイル名を指定する必要がある (詳しくは <a href="#aws_cli_install">AWS CLI のインストール</a>)．</p>
</li>
</ul>
<p><img src="./assets/vocareum_console.png" alt="vocareum コンソール"></p>
<p><img src="./assets/vocareum_secret.png" alt="vocareum から AWS シークレットキーの発行"></p>
<h2 id="aws-cli-のインストール" tabindex="-1">AWS CLI のインストール <a class="header-anchor" href="#aws-cli-のインストール" aria-label="Permalink to &quot;AWS CLI のインストール&quot;">&ZeroWidthSpace;</a></h2>
<p>読者のために，執筆時点におけるインストールの手順 (Linux 向け) を簡単に記述する． 将来のバージョンでは変更される可能性があるので，常に <a href="https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html" target="_blank" rel="noreferrer">公式のドキュメンテーション</a> で最新の情報をチェックすることを忘れずに．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">curl</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-o</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;awscliv2.zip&quot;</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">unzip</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">awscliv2.zip</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">sudo</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">./aws/install</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">curl</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip&quot;</span><span style="color: #24292E"> </span><span style="color: #005CC5">-o</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;awscliv2.zip&quot;</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">unzip</span><span style="color: #24292E"> </span><span style="color: #032F62">awscliv2.zip</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">sudo</span><span style="color: #24292E"> </span><span style="color: #032F62">./aws/install</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><p>インストールできたか確認するため，次のコマンドを打ってバージョン情報が出力されることを確認する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--version</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">aws</span><span style="color: #24292E"> </span><span style="color: #005CC5">--version</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>インストールができたら，次のコマンドにより初期設定を行う (<a href="https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html" target="_blank" rel="noreferrer">参照</a>)．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">configure</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">aws</span><span style="color: #24292E"> </span><span style="color: #032F62">configure</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>コマンドを実行すると， <code>AWS Access Key ID</code>, <code>AWS Secret Access Key</code> を入力するよう指示される． シークレットキーの発行については <a href="#aws_secrets">AWS のシークレットキーの作成</a> を参照． コマンドは加えて，<code>Default region name</code> を訊いてくる． ここには自分の好きな地域 (例えば <code>ap-northeast-1</code> =東京リージョン) を指定すればよい． 最後の <code>Default output format</code> は <code>json</code> としておくとよい．</p>
<p>このコマンドを完了すると， <code>~/.aws/credentials</code> と <code>~/.aws/config</code>　という名前のファイルが生成されているはずである． 念のため， <code>cat</code> コマンドを使って中身を確認してみるとよい．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cat</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">~/.aws/credentials</span></span>
<span class="line"><span style="color: #ADBAC7">[default]</span></span>
<span class="line"><span style="color: #F69D50">aws_access_key_id</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">XXXXXXXXXXXXXXXXXX</span></span>
<span class="line"><span style="color: #F69D50">aws_secret_access_key</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">YYYYYYYYYYYYYYYYYYY</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cat</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">~/.aws/config</span></span>
<span class="line"><span style="color: #ADBAC7">[profile default]</span></span>
<span class="line"><span style="color: #F69D50">region</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ap-northeast-1</span></span>
<span class="line"><span style="color: #F69D50">output</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">json</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cat</span><span style="color: #24292E"> </span><span style="color: #032F62">~/.aws/credentials</span></span>
<span class="line"><span style="color: #24292E">[default]</span></span>
<span class="line"><span style="color: #6F42C1">aws_access_key_id</span><span style="color: #24292E"> </span><span style="color: #032F62">=</span><span style="color: #24292E"> </span><span style="color: #032F62">XXXXXXXXXXXXXXXXXX</span></span>
<span class="line"><span style="color: #6F42C1">aws_secret_access_key</span><span style="color: #24292E"> </span><span style="color: #032F62">=</span><span style="color: #24292E"> </span><span style="color: #032F62">YYYYYYYYYYYYYYYYYYY</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cat</span><span style="color: #24292E"> </span><span style="color: #032F62">~/.aws/config</span></span>
<span class="line"><span style="color: #24292E">[profile default]</span></span>
<span class="line"><span style="color: #6F42C1">region</span><span style="color: #24292E"> </span><span style="color: #032F62">=</span><span style="color: #24292E"> </span><span style="color: #032F62">ap-northeast-1</span></span>
<span class="line"><span style="color: #6F42C1">output</span><span style="color: #24292E"> </span><span style="color: #032F62">=</span><span style="color: #24292E"> </span><span style="color: #032F62">json</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br></div></div><p><code>~/.aws/credentials</code> には認証鍵の情報が， <code>~/.aws/config</code> には AWS CLI の設定が記録されている．</p>
<p>デフォルトでは， <code>[default]</code> という名前でプロファイルが保存される． いくつかのプロファイルを使い分けたければ， default の例に従って，たとえば <code>[myprofile]</code> などという名前でプロファイルを追加すればよい．</p>
<p>AWS CLI でコマンドを打つときに，プロファイルを使い分けるには，</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">s3</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ls</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--profile</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">myprofile</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">aws</span><span style="color: #24292E"> </span><span style="color: #032F62">s3</span><span style="color: #24292E"> </span><span style="color: #032F62">ls</span><span style="color: #24292E"> </span><span style="color: #005CC5">--profile</span><span style="color: #24292E"> </span><span style="color: #032F62">myprofile</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>のように， <code>--profile</code> というオプションをつけてコマンドを実行する．</p>
<p>いちいち <code>--profile</code> オプションをつけるのが面倒だと感じる場合は， <code>AWS_PROFILE</code> という環境変数を設定するとよい．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">export</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">AWS_PROFILE=myprofile</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">export</span><span style="color: #24292E"> </span><span style="color: #032F62">AWS_PROFILE=myprofile</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>あるいは，認証情報などを環境変数に設定するテクニックもある．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">export</span><span style="color: #ADBAC7"> AWS_ACCESS_KEY_ID</span><span style="color: #F47067">=</span><span style="color: #96D0FF">XXXXXX</span></span>
<span class="line"><span style="color: #F47067">export</span><span style="color: #ADBAC7"> AWS_SECRET_ACCESS_KEY</span><span style="color: #F47067">=</span><span style="color: #96D0FF">YYYYYY</span></span>
<span class="line"><span style="color: #F47067">export</span><span style="color: #ADBAC7"> AWS_DEFAULT_REGION</span><span style="color: #F47067">=</span><span style="color: #96D0FF">ap-northeast-1</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">export</span><span style="color: #24292E"> AWS_ACCESS_KEY_ID</span><span style="color: #D73A49">=</span><span style="color: #032F62">XXXXXX</span></span>
<span class="line"><span style="color: #D73A49">export</span><span style="color: #24292E"> AWS_SECRET_ACCESS_KEY</span><span style="color: #D73A49">=</span><span style="color: #032F62">YYYYYY</span></span>
<span class="line"><span style="color: #D73A49">export</span><span style="color: #24292E"> AWS_DEFAULT_REGION</span><span style="color: #D73A49">=</span><span style="color: #032F62">ap-northeast-1</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><p>これらの環境変数は， <code>~/.aws/credentials</code> よりも高い優先度をもつので，環境変数が設定されていればそちらの情報が使用される (<a href="https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html" target="_blank" rel="noreferrer">参照</a>)．</p>
<p><strong>AWS Educate Starter Account</strong> は <code>us-east-1</code> のリージョンのみ利用可能である (執筆時点での情報)． よって， AWS Educate Starter Account を使用している場合は， default region を <code>us-east-1</code> に設定する必要がある．</p>
<h2 id="aws-cdk-のインストール" tabindex="-1">AWS CDK のインストール <a class="header-anchor" href="#aws-cdk-のインストール" aria-label="Permalink to &quot;AWS CDK のインストール&quot;">&ZeroWidthSpace;</a></h2>
<p>読者のために，執筆時点におけるインストールの手順 (Linux 向け) を簡単に記述する． 将来のバージョンでは変更される可能性があるので，常に <a href="https://docs.aws.amazon.com/cdk/latest/guide/getting_started.html" target="_blank" rel="noreferrer">公式のドキュメンテーション</a> で最新の情報をチェックすることを忘れずに．</p>
<p>Node.js がインストールされていれば，基本的に次のコマンドを実行すればよい．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">sudo</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">npm</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">install</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-g</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws-cdk</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">sudo</span><span style="color: #24292E"> </span><span style="color: #032F62">npm</span><span style="color: #24292E"> </span><span style="color: #032F62">install</span><span style="color: #24292E"> </span><span style="color: #005CC5">-g</span><span style="color: #24292E"> </span><span style="color: #032F62">aws-cdk</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>本書のハンズオンは AWS CDK version 1.100.0 で開発した． CDK は開発途上のライブラリなので，将来的に API が変更される可能性がある． API の変更によりエラーが生じた場合は， version 1.100.0 を使用することを推奨する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">npm</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">install</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-g</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws-cdk@1.100</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">npm</span><span style="color: #24292E"> </span><span style="color: #032F62">install</span><span style="color: #24292E"> </span><span style="color: #005CC5">-g</span><span style="color: #24292E"> </span><span style="color: #032F62">aws-cdk@1.100</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>インストールできたか確認するため，次のコマンドを打って正しくバージョンが表示されることを確認する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cdk</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--version</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cdk</span><span style="color: #24292E"> </span><span style="color: #005CC5">--version</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>インストールができたら，次のコマンドにより AWS 側の初期設定を行う． これは一度実行すれば OK．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cdk</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">bootstrap</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cdk</span><span style="color: #24292E"> </span><span style="color: #032F62">bootstrap</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p><code>cdk bootstrap</code> を実行するときは，AWS の認証情報とリージョンが正しく設定されていることを確認する． デフォルトでは <code>~/.aws/config</code> にあるデフォルトのプロファイルが使用される． デフォルト以外のプロファイルを用いるときは <a href="#aws_cli_install">AWS CLI のインストール</a> で紹介したテクニックを使って切り替える．</p>
<p>AWS CDK の認証情報の設定は AWS CLI と基本的に同じである．詳しくは <a href="#aws_cli_install">AWS CLI のインストール</a> を参照．</p>
<h2 id="wsl-のインストール" tabindex="-1">WSL のインストール <a class="header-anchor" href="#wsl-のインストール" aria-label="Permalink to &quot;WSL のインストール&quot;">&ZeroWidthSpace;</a></h2>
<p>本書のハンズオンではコマンドラインから AWS CLI のコマンドを実行したり， Python で書かれたプログラムを実行する． コマンドは基本的に UNIX のターミナルを想定して書かれている． Linux や Mac のユーザーは OS に標準搭載されているターミナルを用いれば良い． Windows を利用している読者は， <a href="https://docs.microsoft.com/en-us/windows/wsl/" target="_blank" rel="noreferrer">Windows Subsystem for Linux (WSL)</a> を利用することで，仮想の Linux 環境を構築することを推奨する． <a href="https://www.cygwin.com/" target="_blank" rel="noreferrer">Cygwin</a> などの Linux 環境をエミュレートするほかのツールでも構わないが，本書のプログラムは WSL でのみ動作確認を行っている．</p>
<p>WSL とは， Windows の OS 上で Linux の仮想環境を起動するための， Microsoft 社が公式で提供しているソフトウェアである． Ubuntu など希望の Linux distribution が選択でき，基本的にすべての Linux 向けに作られたプログラム・ソフトウェアを使用することができる．</p>
<p>執筆時点では <a href="https://docs.microsoft.com/en-us/windows/wsl/compare-versions#whats-new-in-wsl-2" target="_blank" rel="noreferrer">WSL 2</a> が最新版として提供されているので，以下では WSL 2 のインストール手順を簡単に説明する． 細かな詳細などは， <a href="https://docs.microsoft.com/en-us/windows/wsl/install-win10" target="_blank" rel="noreferrer">公式ドキュメンテーション</a> を参照のこと．</p>
<p>前提として，使用される OS は Windows 10 (Pro または Home エディション) でなければならない． さらに，使用している Windows 10 のバージョンが WSL に対応するバージョンであるかを確認する． X64 のシステムでは Version 1903, Build 18362 以上でなければならない． バージョンが対応していない場合は、 Windows のアップデートを行う．</p>
<p>まず最初に， Administrator 権限で PowerShell を起動する (<a href="#fig:powershell">figure_title</a>)． 左下の Windows メニューの検索バーに <code>powershell</code> と入力すると， PowerShell のプログラムが見つかるはずである， これを右クリックし、 <code>Run as administrator</code> を選択し起動する．</p>
<p><img src="./assets/wsl/powershell.png" alt="管理者権限での PowerShell の起動"></p>
<p>PowerShell が起動したら、次のコマンドを実行する．</p>
<div class="language-powershell vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">powershell</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #6CB6FF">dism.exe</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">/</span><span style="color: #ADBAC7">online </span><span style="color: #F47067">/</span><span style="color: #6CB6FF">enable-feature</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">/</span><span style="color: #ADBAC7">featurename:Microsoft</span><span style="color: #F47067">-</span><span style="color: #ADBAC7">Windows</span><span style="color: #F47067">-</span><span style="color: #ADBAC7">Subsystem</span><span style="color: #F47067">-</span><span style="color: #ADBAC7">Linux </span><span style="color: #F47067">/</span><span style="color: #ADBAC7">all </span><span style="color: #F47067">/</span><span style="color: #ADBAC7">norestart</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #005CC5">dism.exe</span><span style="color: #24292E"> </span><span style="color: #D73A49">/</span><span style="color: #24292E">online </span><span style="color: #D73A49">/</span><span style="color: #005CC5">enable-feature</span><span style="color: #24292E"> </span><span style="color: #D73A49">/</span><span style="color: #24292E">featurename:Microsoft</span><span style="color: #D73A49">-</span><span style="color: #24292E">Windows</span><span style="color: #D73A49">-</span><span style="color: #24292E">Subsystem</span><span style="color: #D73A49">-</span><span style="color: #24292E">Linux </span><span style="color: #D73A49">/</span><span style="color: #24292E">all </span><span style="color: #D73A49">/</span><span style="color: #24292E">norestart</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>実行して、“The operation completed successfully.” と出力されるのを確認する． これで WSL が enable される．</p>
<p>次に，先ほどと同じ Administrator 権限で開いた PowerShell で次のコマンドを実行する。</p>
<div class="language-powersh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">powersh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #adbac7">dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292e">dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>実行して， “The operation completed successfully.” と出力されるのを確認する． これが確認出来たら、一度コンピュータを再起動する．</p>
<p>続いて， Linux kernel update package を次のリンクからダウンロードする． <a href="https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi" target="_blank" rel="noreferrer">https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi</a></p>
<p>ダウンロードしたファイルをダブルクリックして実行する． ダイアログに従ってインストールを完了させる．</p>
<p>そうしたら，再び PowerShell を開き次のコマンドを実行する。</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">wsl</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--set-default-version</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">2</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">wsl</span><span style="color: #24292E"> </span><span style="color: #005CC5">--set-default-version</span><span style="color: #24292E"> </span><span style="color: #005CC5">2</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>最後に、自分の好みの Linux distribution をインストールする． ここでは Ubuntu 20.04 をインストールしよう．</p>
<p>Microsoft store のアプリを起動し，検索バーに <code>Ubuntu</code> と入力する． Ubuntu 20.04 LTS という項目が見つかるはずなので，それを開き， “Get” ボタンをクリックする (<a href="#fig:microsoft_store">figure_title</a>)． しばらく待つと， Ubuntu 20.04 のインストールが完了する．</p>
<p><img src="./assets/wsl/microsoft_store.png" alt="Microsoft store から Ubuntu 20.04 をインストール"></p>
<p>Ubuntu 20.04 を初回に起動すると，初期設定が自動で開始され，数分待つことになる． 初期設定が終わると，ユーザー名・パスワードを設定するようプロンプトが出るので，プロンプトに従い入力する．</p>
<p>これで WSL2 のインストールが完了した． 早速 WSL2 を起動してみよう． 左下の Windows メニューの検索バーに <code>Ubuntu</code> と入力すると， Ubuntu 20.04 のプログラムが見つかるはずである (<a href="#fig:ubuntu">figure_title</a>)． クリックして起動しよう．</p>
<p><img src="./assets/wsl/ubuntu2004.png" alt="Ubuntu 20.04 の起動"></p>
<p>すると，ターミナルの黒い画面が立ち上がるだろう (<a href="#fig:wsl_window">figure_title</a>)． <code>ls</code>, <code>top</code> などのコマンドを打ってみて， WSL がきちんと動作していることを確認しよう．</p>
<p><img src="./assets/wsl/wsl_window.png" alt="WSL の起動画面"></p>
<p>オプションとして， <a href="https://docs.microsoft.com/en-us/windows/terminal/get-started" target="_blank" rel="noreferrer">Windows Terminal</a> というマイクロソフトから提供されているツールを使うと，より快適に WSL を使用することができる． 興味のある読者はこちらのインストールも推奨する．</p>
<h2 id="docker-のインストール" tabindex="-1">Docker のインストール <a class="header-anchor" href="#docker-のインストール" aria-label="Permalink to &quot;Docker のインストール&quot;">&ZeroWidthSpace;</a></h2>
<p>Docker のインストールの方法は OS によって異なる．</p>
<p>Mac ユーザーは， Docker Desktop をインストールする． インストールの方法は， <a href="https://docs.docker.com/docker-for-mac/install/" target="_blank" rel="noreferrer">Docker のウェブサイト</a> から， Mac 版の Docker Desktop をダウンロードし，ダウンロードされたファイルをダブルクリックし， <code>Applications</code> のフォルダにドラッグするだけで良い． 詳細は <a href="https://docs.docker.com/docker-for-mac/install/" target="_blank" rel="noreferrer">公式ドキュメンテーション</a> を参照のこと．</p>
<p>Windows のユーザーは，Docker Desktop をインストールする． その際， WSL 2 が事前にインストールされていなければならない． 詳細は <a href="https://docs.docker.com/desktop/windows/install/" target="_blank" rel="noreferrer">公式ドキュメンテーション</a> を参照のこと． Docker Desktop をインストールすると， WSL からも <code>docker</code> コマンドが使用できるようになる．</p>
<p>Linux ユーザー (特に Ubuntu ユーザー) については，インストールの方法はいくつかのアプローチがある． <a href="https://docs.docker.com/engine/install/ubuntu/" target="_blank" rel="noreferrer">公式ドキュメンテーション</a> にいくつかのインストールの方法が示されているので，詳しい情報はそちらを参照いただきたい．</p>
<p>最も簡単な方法は， Docker が公式で提供しているインストールスクリプトを用いる方法である． この場合，次のコマンドを実行することで Docker がインストールされる．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">curl</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-fsSL</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">https://get.docker.com</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-o</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">get-docker.sh</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">sudo</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">sh</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">get-docker.sh</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">curl</span><span style="color: #24292E"> </span><span style="color: #005CC5">-fsSL</span><span style="color: #24292E"> </span><span style="color: #032F62">https://get.docker.com</span><span style="color: #24292E"> </span><span style="color: #005CC5">-o</span><span style="color: #24292E"> </span><span style="color: #032F62">get-docker.sh</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">sudo</span><span style="color: #24292E"> </span><span style="color: #032F62">sh</span><span style="color: #24292E"> </span><span style="color: #032F62">get-docker.sh</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>デフォルトのインストールでは， root ユーザーのみが <code>docker</code> コマンドを使用できる設定になっている． 従って，コマンドには毎回 <code>sudo</code> を付け加える必要がある． これが面倒だと感じる場合は，次のステップにより，使用するユーザーを <code>docker</code> というグループに追加する (詳細は <a href="https://docs.docker.com/engine/install/linux-postinstall/#manage-docker-as-a-non-root-user" target="_blank" rel="noreferrer">公式ドキュメンテーション &quot;Post-installation steps for Linux&quot;</a> を参照)．</p>
<p>まず最初に， <code>docker</code> という名前にグループを追加する． インストールによっては，既に <code>docker</code> グループが作られている場合もある．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">sudo</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">groupadd</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">docker</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">sudo</span><span style="color: #24292E"> </span><span style="color: #032F62">groupadd</span><span style="color: #24292E"> </span><span style="color: #032F62">docker</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>次に，現在使用しているユーザーを <code>docker</code> グループに加える．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">sudo</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">usermod</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-aG</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">docker</span><span style="color: #ADBAC7"> $USER</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">sudo</span><span style="color: #24292E"> </span><span style="color: #032F62">usermod</span><span style="color: #24292E"> </span><span style="color: #005CC5">-aG</span><span style="color: #24292E"> </span><span style="color: #032F62">docker</span><span style="color: #24292E"> $USER</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>ここまでできたら，一度ログアウトし，再度ログインする． これによって，グループの変更がターミナルのセッションに反映される．</p>
<p>設定が正しくできているかを確認するため，次のコマンドを実行してみる．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">docker</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">run</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">hello-world</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">docker</span><span style="color: #24292E"> </span><span style="color: #032F62">run</span><span style="color: #24292E"> </span><span style="color: #032F62">hello-world</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p><code>sudo</code> なしでコンテナが実行できたならば，設定は完了である．</p>
<h2 id="python-venv-クイックガイド" tabindex="-1">Python <code>venv</code> クイックガイド <a class="header-anchor" href="#python-venv-クイックガイド" aria-label="Permalink to &quot;Python `venv` クイックガイド&quot;">&ZeroWidthSpace;</a></h2>
<p>他人からもらったプログラムで， numpy や scipy のバージョンが違う！などの理由で，プログラムが動かない，という経験をしたことがある人は多いのではないだろうか． もし，自分の計算機の中に一つしか Python 環境がないとすると，プロジェクトを切り替えるごとに正しいバージョンをインストールし直さなければならず，これは大変な手間である．</p>
<p>コードのシェアをよりスムーズにするためには，ライブラリのバージョンはプロジェクトごとに管理されるべきである． それを可能にするのが Python 仮想環境とよばれるツールであり， <a href="https://docs.python.org/3/tutorial/venv.html" target="_blank" rel="noreferrer">venv</a>, <a href="https://github.com/pyenv/pyenv" target="_blank" rel="noreferrer">pyenv</a>, <a href="https://docs.conda.io/en/latest/" target="_blank" rel="noreferrer">conda</a> などがよく使われる．</p>
<p>そのなかでも， <code>venv</code> は Python に標準搭載されているのでとても便利である． <code>pyenv</code> や <code>conda</code> は，別途インストールの必要があるが，それぞれの長所もある．</p>
<p><code>venv</code> を使って仮想環境を作成するには，</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-m</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">venv</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.env</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python</span><span style="color: #24292E"> </span><span style="color: #005CC5">-m</span><span style="color: #24292E"> </span><span style="color: #032F62">venv</span><span style="color: #24292E"> </span><span style="color: #032F62">.env</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>と実行する． これにより <code>.env/</code> というディレクトリが作られ，このディレクトリに依存するライブラリが保存されることになる．</p>
<p>この新たな仮想環境を起動するには</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">source</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.env/bin/activate</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">source</span><span style="color: #24292E"> </span><span style="color: #032F62">.env/bin/activate</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>と実行する．</p>
<p>シェルのプロンプトに <code>(.env)</code> という文字が追加されていることを確認しよう (<a href="#fig_venv_prompt">figure_title</a>)． これが， &quot;いまあなたは venv の中にいますよ&quot; というしるしになる．</p>
<p><img src="./assets/venv_shell.png" alt="venv を起動したときのプロンプト"></p>
<p>仮想環境を起動すると，それ以降実行する <code>pip</code> コマンドは， <code>.env/</code> 以下にインストールされる．このようにして，プロジェクトごとに使うライブラリのバージョンを切り分けることができる．</p>
<p>Python では <code>requirements.txt</code> というファイルに依存ライブラリを記述するのが一般的な慣例である．他人からもらったプログラムに， <code>requirements.txt</code> が定義されていれば，</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">pip</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">install</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-r</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">requirements.txt</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">pip</span><span style="color: #24292E"> </span><span style="color: #032F62">install</span><span style="color: #24292E"> </span><span style="color: #005CC5">-r</span><span style="color: #24292E"> </span><span style="color: #032F62">requirements.txt</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>と実行することで，必要なライブラリをインストールし，瞬時に Python 環境を再現することができる．</p>
<p>venv による仮想環境を保存するディレクトリの名前は任意に選べることができるが， <code>.env</code> という名前を用いるのが一般的である．</p>
<h2 id="ハンズオン実行用の-docker-image-の使い方" tabindex="-1">ハンズオン実行用の Docker image の使い方 <a class="header-anchor" href="#ハンズオン実行用の-docker-image-の使い方" aria-label="Permalink to &quot;ハンズオン実行用の Docker image の使い方&quot;">&ZeroWidthSpace;</a></h2>
<p>ハンズオンを実行するために必要な， Node.js, Python, AWS CDK などがインストールされた Docker image を用意した． これを使用することで，自分のローカルマシンに諸々をインストールする必要なく，すぐにハンズオンのコードが実行できる．</p>
<p>ハンズオンのいくつかのコマンドは Docker の外 = ローカルマシンのリアル環境で実行されなければならない． それらについてはハンズオンの該当箇所に注意書きとして記してある．</p>
<p>Docker イメージは <a href="https://hub.docker.com/repository/docker/tomomano/labc" target="_blank" rel="noreferrer">Docker Hub</a> においてある． Docker イメージのビルドファイルは GitHub の <a href="https://github.com/tomomano/learn-aws-by-coding-source-code/blob/main/docker/Dockerfile" target="_blank" rel="noreferrer">docker/Dockerfile</a> にある．</p>
<p>次のコマンドでコンテナを起動する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">docker</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">run</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-it</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">tomomano/labc:latest</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">docker</span><span style="color: #24292E"> </span><span style="color: #032F62">run</span><span style="color: #24292E"> </span><span style="color: #005CC5">-it</span><span style="color: #24292E"> </span><span style="color: #032F62">tomomano/labc:latest</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>初回にコマンドを実行したときのみ，イメージが Docker Hub からダウンロード (pull) される． 二回目以降はローカルにダウンロードされたイメージが使用される．</p>
<p>コンテナが起動すると，次のようなインタラクティブシェルが表示されるはずである (起動時に <code>-it</code> のオプションをつけたのがポイントである)．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">root@aws-handson:~/programlisting</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">root@aws-handson:~/programlisting</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>この状態で <code>ls</code> コマンドを打つと， <code>handson/</code> というディレクトリがあるはずである． ここに <code>cd</code> する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cd</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">handson</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cd</span><span style="color: #24292E"> </span><span style="color: #032F62">handson</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>すると，各ハンズオンごとのディレクトリが見つかるはずである．</p>
<p>あとは，ハンズオンごとにディレクトリを移動し，ハンズオンごとの virtualenv を作成し，スタックのデプロイを行えばよい (<a href="#sec_handson_ec2_run">プログラムを実行する</a> など参照)． ハンズオンごとに使用する依存ライブラリが異なるので，それぞれのハンズオンごとに virtualenv を作成するという設計になっている．</p>
<p>AWS の認証情報を設定することも忘れずに． <a href="#aws_cli_install">AWS CLI のインストール</a> で記述したように， <code>AWS_ACCESS_KEY_ID</code> などの環境変数を設定するのが簡単な方法である． あるいは，<strong>ローカルマシンの</strong> <code>~/.aws/credentials</code> に認証情報が書き込まれているなら，このディレクトリをコンテナに<strong>マウント</strong>することで，同じ認証ファイルをコンテナ内部から参照することが可能である． この選択肢を取る場合は，次のコマンドでコンテナを起動する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">docker</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">run</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-it</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-v</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">~/.aws:/root/.aws:ro</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">tomomano/labc:latest</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">docker</span><span style="color: #24292E"> </span><span style="color: #032F62">run</span><span style="color: #24292E"> </span><span style="color: #005CC5">-it</span><span style="color: #24292E"> </span><span style="color: #005CC5">-v</span><span style="color: #24292E"> </span><span style="color: #032F62">~/.aws:/root/.aws:ro</span><span style="color: #24292E"> </span><span style="color: #032F62">tomomano/labc:latest</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>これにより，ローカルマシンの <code>~/.aws</code> をコンテナの <code>/root/.aws</code> にマウントすることができる． 最後の <code>:ro</code> は read-only を意味する． 大切な認証ファイルが誤って書き換えられてしまわないように， read-only のフラグをつけることをおすすめする．</p>
<p><code>/root/</code> がコンテナ環境におけるホームディレクトリである． ここで紹介した認証ファイルをマウントするテクニックは， SSH 鍵をコンテナに渡すときなどにも使える．</p>
<h1 id="ライセンス" tabindex="-1">ライセンス <a class="header-anchor" href="#ライセンス" aria-label="Permalink to &quot;ライセンス&quot;">&ZeroWidthSpace;</a></h1>
<p>本教科書およびハンズオンのソースコードは <a href="https://creativecommons.org/licenses/by-nc-nd/4.0/" target="_blank" rel="noreferrer">CC BY-NC-ND 4.0</a> に従うライセンスで公開しています．</p>
<p>教育など非商用の目的での本教科書の使用や再配布は自由に行うことが可能です． 商用目的で本書の全体またはその一部を無断で転載する行為は，これを固く禁じます．</p>
]]></description>
            <content:encoded><![CDATA[<h1 id="はじめに" tabindex="-1">はじめに! <a class="header-anchor" href="#はじめに" aria-label="Permalink to &quot;はじめに!&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="本書の目的・内容" tabindex="-1">本書の目的・内容 <a class="header-anchor" href="#本書の目的・内容" aria-label="Permalink to &quot;本書の目的・内容&quot;">&ZeroWidthSpace;</a></h2>
<p>本書は，東京大学計数工学科で 2021 年度 S1/S2 タームに開講されている&quot;システム情報工学特論&quot;の講義資料として作成された．</p>
<p>本書の目的は，クラウドの初心者を対象とし，クラウドの基礎的な知識・概念を解説する． また， Amazon Web Services (以下， AWS) の提供するクラウド環境を実例として，具体的なクラウドの利用方法をハンズオンを通して学ぶ．</p>
<p>とくに，科学・エンジニアリングの学生を対象として，研究などの目的でクラウドを利用するための実践的な手順を紹介する． 知識・理論の説明は最小限に留め，実践を行う中で必要な概念の解説を行う予定である． 読者が今後，研究などでクラウドを利用する際の，足がかりとなれば本書の目的は十分達成されたことになる．</p>
<p>本書は以下のような三部構成になっている．</p>
<table><caption>本書の構成</caption><colgroup><col style="width: 20%" /><col style="width: 40%" /><col style="width: 40%" /></colgroup><thead><tr class="header"><th></th><th>テーマ</th><th>ハンズオン</th></tr></thead><tbody><tr class="odd"><td><p>第一部 (1章-4章)</p></td><td><p>クラウドの基礎</p></td><td><ul><li><p>AWSに自分のサーバーを立ち上げる</p></li></ul></td></tr><tr class="even"><td><p>第二部 (5章-9章)</p></td><td><p>クラウドを活用した機械学習</p></td><td><ul><li><p>AWS と Jupyter を使って始めるディープラーニング</p></li><li><p>スケーラブルな自動質問回答ボットを作る</p></li><li><p>並列化されたハイパーパラメータサーチの実装</p></li></ul></td></tr><tr class="odd"><td><p>第三部 (10章-13章)</p></td><td><p>サーバーレスアーキテクチャ入門</p></td><td><ul><li><p>Lambda, DynamoDB, S3 の演習</p></li><li><p>俳句を投稿する SNS "Bashoutter" を作る</p></li></ul></td></tr></tbody></table>
<p>第一部は，クラウドの基礎となる概念・知識を解説する． セキュリティやネットワークなど，クラウドを利用する上で最低限おさえなければいけないポイントを説明する． ハンズオンでは，はじめての仮想サーバーを AWS に立ち上げる演習を行う．</p>
<p>第二部では，クラウド上で科学計算 (とくに機械学習) を走らせるための入門となる知識・技術を解説する． あわせて， <a href="https://www.docker.com/" target="_blank" rel="noreferrer">Docker</a> とよばれる仮想計算環境の使用方法を紹介する． 一つ目のハンズオンでは， AWS のクラウドで Jupyter Notebook を起動し簡単な機械学習の計算を走らせる課題を実践する． 二つ目のハンズオンでは，深層学習を用いた自然言語処理により，質問に自動で回答を生成するボットを作成する． 最後に，複数台の GPU インスタンスからなるクラスターを起動し，並列に深層学習のハイパーパラメータサーチを行う方法を紹介する．</p>
<p>第三部では，サーバーレスアーキテクチャとよばれる最新のクラウドのアーキテクチャを紹介する． これは，サーバーの処理能力を負荷に応じてより柔軟に拡大・縮小するための概念であり，それ以前 (Serverful としばしばよばれる) と質的に異なる設計思想をクラウドに導入するものである． ハンズオンでは，サーバーレスクラウドの主要なコンポーネントである Lambda, DynamoDB, S3 の演習を提供する． さらに，サーバーレスの技術を使用して簡単な SNS をクラウド上に作成する．</p>
<p>これらの豊富なハンズオンにより， AWS 上にクラウドシステムを開発するための知識と技術が身につくはずである． いずれのハンズオンも，実用性を重視したものになっており，これらをベースにカスタマイズを施すことで様々な応用が可能である．</p>
<h2 id="本書のフィロソフィー" tabindex="-1">本書のフィロソフィー <a class="header-anchor" href="#本書のフィロソフィー" aria-label="Permalink to &quot;本書のフィロソフィー&quot;">&ZeroWidthSpace;</a></h2>
<p>本書のフィロソフィーを一言で表すなら， <strong>&quot;ロケットで宇宙まで飛んでいって一度地球を眺めてみよう！&quot;</strong> である．</p>
<p>どういうことか？</p>
<p>ここでいう&quot;地球&quot;とは，クラウドコンピューティングの全体像のことである． 言うまでもなく，クラウドという技術は非常に広範かつ複雑な概念で，幾多の情報技術・ハードウェア・アルゴリズムが精緻に組み合わさってできた総体である． そして，今日では科学研究から日常のインフラ設備に至るまで，我々の社会の多くの部分がクラウド技術によって支えられている．</p>
<p>ここでいう&quot;ロケット&quot;とはこの講義のことである． この講義では，ロケットに乗って宇宙まで飛び立ち，地球(クラウド)の全体を自身の目で眺めてもらう． その際，ロケットの成り立ちや仕組み (背後にある要素技術やプログラムのソースコード) を深くは問わない． 将来，自分が研究などの目的でクラウドを利用することになった際に，改めて学んでもらえば良い． 本書の目的はむしろ，クラウドの最先端に実際に触れ，そこからどんな景色が見えるか(どんな応用が可能か)を実感してもらうことである．</p>
<p>そのような理由で，本書はクラウドの基礎から応用まで幅広いテーマを取り扱う． 第一部はクラウドの基礎から始め，第二部では一気にレベルアップし機械学習(深層学習)をクラウドで実行する手法を解説する． さらに第三部では，サーバーレス・アーキテクチャというここ数年のうちに確立した全く新しいクラウドの設計について解説する． それぞれで本一冊分以上の内容に相当するものであるが，本書はあえてこれらを一冊にまとめ連続的に俯瞰するという野心的な意図をもって執筆された．</p>
<p>決して楽な搭乗体験ではないかもしれないが，このロケットにしがみついてきてもらえれば，とてもエキサイティングな景色が見られることを約束したい．</p>
<p><img src="./assets/earth_from_earth.jpg" alt="宇宙からみた地球 (Image from NASA https://www.nasa.gov/image-feature/planet-of-clouds)"></p>
<h2 id="aws-アカウント" tabindex="-1">AWS アカウント <a class="header-anchor" href="#aws-アカウント" aria-label="Permalink to &quot;AWS アカウント&quot;">&ZeroWidthSpace;</a></h2>
<p>本書では，ハンズオン形式で AWS のクラウドを実際に動かす演習を提供する． 自分でハンズオンを実行してみたい読者は，各自で AWS のアカウントの作成をしていただく． AWS のアカウントの作成の仕方は巻末付録 (<a href="#sec:create_aws_account">AWS アカウントの取得</a>) に簡単に記載したので，必要に応じて参照していただきたい．</p>
<p>AWS にはいくつかの機能に対して無料利用枠が設定されており，いくつかのハンズオンは無料の範囲内で実行できる． 一方，ほかのハンズオン (とくに機械学習を扱うもの) では数ドル程度のコストが発生する． ハンズオンごとに発生するおおよそのコストについて記述があるので，注意をしながらハンズオンに取り組んでいただきたい．</p>
<p>また，大学などの教育機関における講義で AWS を使用する際は， <a href="https://aws.amazon.com/education/awseducate/" target="_blank" rel="noreferrer">AWS Educate</a> というプログラムを利用することも可能である． これは，講義の担当者が申請を行うことで，受講する学生に対し AWS クレジットが提供されるというプログラムである． AWS Educate を利用することで金銭的な負担なしに AWS を体験することができる． また，講義を経由せず個人でも AWS Educate に参加することも可能である． AWS Educate からは様々な学習教材が提供されているので，ぜひ活用してもらいたい．</p>
<h2 id="環境構築" tabindex="-1">環境構築 <a class="header-anchor" href="#環境構築" aria-label="Permalink to &quot;環境構築&quot;">&ZeroWidthSpace;</a></h2>
<p>本書では， AWS 上にクラウドアプリケーションを展開するハンズオンを実施する． そこで紹介するプログラムを実行するためには，以下の計算機環境が必要である． インストールの方法については，巻末付録 (<a href="#sec:appendix_settingup">Appendix: 環境構築</a>) に記してある． 必要に応じて参照し，環境構築を各自実施していただきたい．</p>
<ul>
<li>
<p><strong>UNIX 系コンソール</strong>: ハンズオンで紹介するコマンドを実行したり， SSH でサーバーにアクセスするため， UNIX 系のコンソール環境が必要である． Mac または Linux のユーザーは， OS に標準搭載のコンソール(ターミナルとも呼ばれる)を使用すればよい． Windows のユーザーは， <a href="https://docs.microsoft.com/en-us/windows/wsl/about" target="_blank" rel="noreferrer">Windows Subsystem for Linux (WSL)</a> を使い， Linux の仮想環境のインストールを推奨する (<a href="#sec:install_wsl">WSL のインストール</a> 参照)．</p>
</li>
<li>
<p><strong>Docker</strong>: 本書では Docker とよばれる仮想計算環境の利用方法を解説する． インストール手順については <a href="#sec:install_docker">Docker のインストール</a> を参照のこと．</p>
</li>
<li>
<p><strong>Python</strong>: Version 3.6 以上をインストールする． とくに，ハンズオンでは <code>venv</code> モジュールを使用する． <code>venv</code> の使い方は <a href="#venv_quick_guide">Python クイックガイド</a> 参照のこと．</p>
</li>
<li>
<p><strong>Node.js</strong>: version 12.0 以上 をインストールする．</p>
</li>
<li>
<p><strong>AWS CLI</strong>: <a href="https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html" target="_blank" rel="noreferrer">Version 2</a> をインストールする． インストール手順については <a href="#aws_cli_install">AWS CLI のインストール</a> 参照のこと．</p>
</li>
<li>
<p><strong>AWS CDK</strong>: Version 1.100 以上をインストールする． Version 2 以降には未対応である． インストール手順については <a href="#aws_cdk_install">AWS CDK のインストール</a> 参照のこと．</p>
</li>
<li>
<p><strong>AWS 認証鍵の設定</strong>: AWS API をコマンドラインから呼ぶには，認証鍵 (secret key) が設定されている必要がある． 認証鍵の設定については <a href="#aws_cli_install">AWS CLI のインストール</a> 参照のこと．</p>
</li>
</ul>
<h3 id="ハンズオン実行用の-docker-image" tabindex="-1">ハンズオン実行用の Docker Image <a class="header-anchor" href="#ハンズオン実行用の-docker-image" aria-label="Permalink to &quot;ハンズオン実行用の Docker Image&quot;">&ZeroWidthSpace;</a></h3>
<p>Python, Node.js, AWS CDK など，ハンズオンのプログラムを実行するために必要なプログラム/ライブラリがインストール済みの Docker image を用意した． また，ハンズオンのソースコードもクローン済みである． Docker の使い方を知っている読者は，これを使えば，諸々のインストールをする必要なく，すぐにハンズオンのプログラムを実行できる．</p>
<p>次のコマンドで起動する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">docker</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">run</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-it</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">tomomano/labc</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">docker</span><span style="color: #24292E"> </span><span style="color: #032F62">run</span><span style="color: #24292E"> </span><span style="color: #005CC5">-it</span><span style="color: #24292E"> </span><span style="color: #032F62">tomomano/labc</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>この Docker image の使い方や詳細は <a href="#sec_handson_docker">ハンズオン実行用の Docker image の使い方</a> に記載している．</p>
<h2 id="前提知識" tabindex="-1">前提知識 <a class="header-anchor" href="#前提知識" aria-label="Permalink to &quot;前提知識&quot;">&ZeroWidthSpace;</a></h2>
<p>本書を読むにあたり，要求する前提知識は大学初等程度の計算機科学の知識 (OS，プログラミングなど)のみである． それ以上の前提知識はとくに仮定しない． クラウドの利用経験もゼロで問題ない． が，以下の事前知識があるとよりスムーズに理解をすることができるだろう．</p>
<ul>
<li>
<p><strong>Python の基本的な理解</strong>: 本書では Python を使ってプログラムの作成を行う． 使用するライブラリは十分抽象化されており，関数の名前を見ただけで意味が明瞭なものがほとんどであるので， Python に詳しくなくても心配する必要はない．</p>
</li>
<li>
<p><strong>Linux コマンドラインの基礎的な理解</strong>: クラウドを利用する際，クラウド上に立ち上がるサーバーは基本的に Linux である． Linux のコマンドラインについて知識があると，トラブルシュートなどが容易になる． 筆者のおすすめの参考書は <a href="http://linuxcommand.org/tlcl.php" target="_blank" rel="noreferrer">The Linux Command Line by William Shotts</a> である． ウェブで無料で読むことができるので，読んだことのない人はぜひ一読を．</p>
</li>
</ul>
<h2 id="講義に関連する資料" tabindex="-1">講義に関連する資料 <a class="header-anchor" href="#講義に関連する資料" aria-label="Permalink to &quot;講義に関連する資料&quot;">&ZeroWidthSpace;</a></h2>
<p>ハンズオンで使うプログラムや教科書のソースコードは以下のウェブページで公開している．</p>
<p><a href="https://github.com/tomomano/learn-aws-by-coding" target="_blank" rel="noreferrer">https://github.com/tomomano/learn-aws-by-coding</a></p>
<h2 id="本書で使用するノーテーションなど" tabindex="-1">本書で使用するノーテーションなど <a class="header-anchor" href="#本書で使用するノーテーションなど" aria-label="Permalink to &quot;本書で使用するノーテーションなど&quot;">&ZeroWidthSpace;</a></h2>
<ul>
<li>
<p>コードやシェルのコマンドは <code>monospace letter</code> で記述する．</p>
</li>
<li>
<p>シェルに入力するコマンドは，それがシェルコマンドであると明示する目的で，先頭に <code>$</code> がつけてある． <code>$</code> はコマンドをコピー&amp;ペーストするときは除かなければならない． 逆に，コマンドの出力には <code>$</code> はついていない点に留意する．</p>
</li>
</ul>
<p>また，以下のような形式で注意やチップスを提供する．</p>
<p>追加のコメントなどを記す．</p>
<p>発展的な議論やアイディアなどを紹介する．</p>
<p>陥りやすいミスなどの注意事項を述べる．</p>
<p>絶対に犯してはならないミスを指摘する．</p>
<h1 id="クラウド概論" tabindex="-1">クラウド概論 <a class="header-anchor" href="#クラウド概論" aria-label="Permalink to &quot;クラウド概論&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="クラウドとは" tabindex="-1">クラウドとは？ <a class="header-anchor" href="#クラウドとは" aria-label="Permalink to &quot;クラウドとは？&quot;">&ZeroWidthSpace;</a></h2>
<p><img src="./assets/cloud_word_art.png" alt="Cloud"></p>
<p>クラウドとはなにか？ クラウドという言葉は，それ自身がとても広い意味をもつので，厳密な定義付けを行うことは難しい．</p>
<p>学術的な意味でのクラウドの定義づけをするとしたら，NIST(米国・国立標準技術研究所) による <a href="https://csrc.nist.gov/publications/detail/sp/800-145/final" target="_blank" rel="noreferrer">The NIST Definition of Cloud Computing</a> が引用されることが多い． ここに記載されたクラウドの定義・モデルを図示したのが <a href="#fig:nist_cloud_definition">figure_title</a> である．</p>
<p><img src="./assets/nist_cloud_definition.png" alt="The NIST Definition of Cloud Computing"></p>
<p>これによると，クラウドとは以下の要件が満たされたハードウェア/ソフトウェアの総体のことをいう．</p>
<ul>
<li>
<p><strong>On-demand self-service</strong> 利用者のリクエストに応じて計算資源が自動的に割り当てられる．</p>
</li>
<li>
<p><strong>Broad network access</strong> 利用者はネットワークを通じてクラウドにアクセスできる．</p>
</li>
<li>
<p><strong>Resource pooling</strong> クラウドプロバイダーは，所有する計算資源を分割することで複数の利用者に計算資源を割り当てる．</p>
</li>
<li>
<p><strong>Rapid elasticity</strong> 利用者のリクエストに応じて，迅速に計算資源の拡大あるいは縮小を行うことができる．</p>
</li>
<li>
<p><strong>Measured service</strong> 計算資源の利用量を計測・監視することができる．</p>
</li>
</ul>
<p>…と，いわれても抽象的でよくわからないかもしれない．もう少し具体的な話をする．</p>
<p>個人が所有する計算機で， CPU をアップグレードしようと思ったら，物理的に筐体を開け，CPU ソケットを露出させ，新しい CPU に交換する必要があるだろう． あるいは，ストレージがいっぱいになってしまったら，古いディスクを抜き取り，新しいディスクを挿入する必要がある． 計算機の場所を移動させたときには，新しい部屋の LAN ケーブルを差し込まないとネットワークには接続できない．</p>
<p>クラウドでは，これらの操作が<strong>プログラムからのコマンドによって実行できる</strong>． CPU が 1000 個欲しいと思ったならば，そのようにクラウドプロバイダーにリクエストを送れば良い． すると，数分もしないうちに 1000 CPU の計算資源が割り当てられる． ストレージを 1TB から 10TB に拡張しようと思ったならば，そのようにコマンドを送ればよい (これは，Google Drive や Dropbox などのサービスなどで馴染みのある人も多いだろう)． 計算資源を使い終わったら，そのことをプロバイダーに伝えれば，割り当て分はすぐさま削除される． クラウドプロバイダーは，使った計算資源の量を正確にモニタリングしており，その量をもとに利用料金の計算が行われる．</p>
<p>このように，クラウドの本質は物理的なハードウェアの仮想化・抽象化であり，利用者はコマンドを通じて，<strong>まるでソフトウェアの一部かのように，物理的なハードウェアの管理・運用を行うことができる</strong>． もちろん，背後では，データセンターに置かれた膨大な数の計算機が大量の電力を消費しながら稼働している． クラウドプロバイダーはデータセンターの計算資源を上手にやりくりし，ソフトウェアとしてのインターフェースをユーザーに提供することで，このような仮想化・抽象化を達成しているわけである． クラウドプロバイダーの視点からすると，大勢のユーザーに計算機を貸し出し，データセンターの稼働率を常時 100%に近づけることで，利益率の最大化を図っているのである．</p>
<p>著者の言葉で，クラウドの重要な特性を定義するならば，以下のようになる．</p>
<blockquote>
<p>クラウドとは計算機ハードウェアの抽象化である．つまり，物理的なハードウェアをソフトウェアの一部かのように自在に操作・拡大・接続することを可能にする技術である．</p>
</blockquote>
<p>先述の The NIST Definition of Cloud Computing に戻ると，クラウドプロバイダーによるクラウドサービスの形態としては，次の三つが定義されている (<a href="#fig:nist_cloud_definition">figure_title</a>)．</p>
<ul>
<li>
<p>Software as a Service (SaaS): クラウド上で実行されるアプリケーションをサービスとして利用者に提供する形態． 例として， Google Drive や Slack などが挙げられる． 利用者は，背後にあるクラウドのインフラ (ネットワークやサーバーなど) には直接触れず，アプリケーションとして提供されているクラウドサービスを享受する．</p>
</li>
<li>
<p>Platform as a Service (PaaS): 顧客の作成したアプリケーション (多くの場合データベースと API リクエスト処理を行うサーバーのコードから構成される) をデプロイする環境をサービスとして利用者に提供する形態． PaaS では利用者はクラウドのインフラに直接触れることはなく，計算負荷が増減した際のサーバーのスケーリングはクラウドプロバイダーによってなされる． 例としては， Google App Engine や Heroku などがある．</p>
</li>
<li>
<p>Infrastructure as a Service (IaaS): クラウド上の計算インフラストラクチャーを従量課金制で利用者に提供する形態． 利用者は必要なネットワーク・サーバー・ストレージをプロバイダーから借り受け，そこに自身のアプリケーションを展開し運用する． IaaS の例としては AWS EC2 などが挙げられる．</p>
</li>
</ul>
<p>本書が扱うのは，主に IaaS におけるクラウド開発である． すなわち，開発者がクラウドのインフラを直接操作し，所望のネットワーク・サーバー・ストレージなどを一から構成し，そこにアプリケーションを展開するというクラウド開発である． この意味において，クラウドの開発とは<strong>クラウドインフラストラクチャーを定義・展開するプログラムを構築するステップ</strong>と<strong>インフラ上で実際に走るアプリケーションを作成するステップ</strong>の二つに分けることができる． この二つは，プログラマーの技術としてはある程度分業を行うことが可能であるが，最も効率化・最適化されたクラウドシステムを構築するためには両方の理解が必須である． 本書では，前者 (クラウドインフラの記述) に重きを置きつつ，アプリケーションレイヤーの話題も取り扱う． PaaS とは，開発者はアプリケーションレイヤーの開発に注力し，クラウドインフラの部分はクラウドプロバイダーに依存するという概念である． PaaS は，クラウドインフラの開発が不要になることで開発の時間が短縮されるが，細かなインフラの挙動はコントロールできないという限界がある． 本書では PaaS についてはとくに取り扱わない．</p>
<p>SaaS は本書の文脈では開発による&quot;成果物&quot;と捉えられるだろう． すなわち， IaaS を構成するプログラムを作成し展開することによって，一般の人が利用できるようなウェブ上の計算サービスやデータベースを提供することが開発の最終ゴールである． 本書のハンズオンではその実例として，シンプルな SNS の作成 (<a href="#sec_bashoutter">Hands-on #6: Bashoutter</a>) などの演習を提供する．</p>
<p>なお，最近では Function as a Service (FaaS) やサーバーレスコンピューティングなども新たなクラウドのカテゴリとして認知されている． これらの概念については <a href="#sec_intro_serverless">Hands-on #5: サーバーレス入門</a> などの章で詳しく触れていく． 本書を読み進める中で明らかになるように，クラウドの技術は日進月歩である． 本書では実用的・教育的な観点から，従来的なクラウドの設計概念に触れたあと，サーバーレスなどの最新の技術も網羅するので，楽しみにしながら読み進めていただきたい．</p>
<p>最後に，The NIST Definition of Cloud Computing によると，クラウドの運用形態について次のような定義がなされている (<a href="#fig:nist_cloud_definition">figure_title</a>)． 特定の組織・団体・企業の内部のみで使用されるクラウドを，<strong>プライベートクラウド (private cloud)</strong> とよぶ． 例えば，大学や研究機関では，その機関の構成員向けの大規模計算機サーバーが運用されていることが多い． プライベートクラウドは，組織の構成員ならば無料もしくは極めて割安のコストで計算を実行できる． しかし，使用できる計算資源の上限は限られる場合が多く，拡張時の柔軟性に欠ける場合もある．</p>
<p>一方，商用のサービスとして一般の顧客に向けたクラウドのことを，<strong>パブリッククラウド (public cloud)</strong> とよぶ． 有名なパブリッククラウドプラットフォームの例を挙げると， Google 社が提供する <a href="https://cloud.google.com/" target="_blank" rel="noreferrer">Google Cloud Platform (GCP)</a>， Microsoft 社が提供する <a href="https://azure.microsoft.com" target="_blank" rel="noreferrer">Azure</a>， Amazon 社が提供する <a href="https://aws.amazon.com" target="_blank" rel="noreferrer">Amazon Web Services (AWS)</a> などがある． パブリッククラウドを利用する場合は，プロバイダーの設定した利用料金を支払うことになる． その分，巨大なデータセンターを運用する企業の計算資源にアクセスすることができるので，計算のキャパシティは無尽蔵にあるといって過言でない．</p>
<p>第三のクラウドの運用形態として，コミュニティクラウド (community cloud) が挙げられる． これは，例えば政府の省庁・機関など目的・役割を共有する団体・組織が共有して運用するクラウドを指す． 最後に，ハイブリッドクラウド (hybrid cloud) という形態もあり，これはプライベート・パブリック・コミュニティクラウドの二つ以上の組み合わせによって構成されるクラウドのことである． データ保護の観点から，いくつかの機密データやプライバシーに関わる情報はプライベートクラウドに保持し，残りのシステムをパブリッククラウドに依存する，などの形態が想定される．</p>
<p>本書で説明するのは，基本的にパブリッククラウドを使ったクラウド開発である． 特に，Amazon Web Services (AWS) を使用して，具体的な技術と概念を学んでいく． 一方で，サーバーのスケーリングや仮想計算環境などのテクニックはすべてのクラウドに共通な概念であるので，クラウドのプラットフォームが変わろうと一般に通用する知識も同時に身につくはずだ．</p>
<h2 id="なぜクラウドを使うのか" tabindex="-1">なぜクラウドを使うのか？ <a class="header-anchor" href="#なぜクラウドを使うのか" aria-label="Permalink to &quot;なぜクラウドを使うのか？&quot;">&ZeroWidthSpace;</a></h2>
<p>上述のように，クラウドとはプログラムを通じて自由に計算資源を操作することのできる計算環境である． ここでは，リアルなローカル計算環境と比べて，なぜクラウドを使うと良いことがあるのかについて述べたい．</p>
<ol>
<li>
<p><strong>自由にサーバーのサイズをスケールできる</strong></p>
<p>なにか新しいプロジェクトを始めるとき，あらかじめ必要なサーバーのスペックを知るのは難しい． いきなり大きなサーバーを買うのはリスクが高い． 一方で，小さすぎるサーバーでは，後のアップグレードが面倒である． クラウドを利用すれば，プロジェクトを進めながら，必要な分だけの計算資源を確保することができる． 2. <strong>自分でサーバーをメンテナンスする必要がない</strong></p>
<p>悲しいことに，コンピュータとは古くなるものである．最近の技術の進歩の速度からすると，5 年も経てば，もはや当時の最新コンピュータも化石と同じである． 5 年ごとにサーバーを入れ替えるのは相当な手間である． またサーバーの停電や故障など不意の障害への対応も必要である． クラウドでは，そのようなインフラの整備やメンテナンスはプロバイダーが自動でやってくれるので，ユーザーが心配する必要がない． 3. <strong>初期コスト 0</strong></p>
<p>自前の計算環境とクラウドの，経済的なコストのイメージを示したのが <a href="#cloud_economic_curve">figure_title</a> である． クラウドを利用する場合の初期コストは基本的に 0 である． その後，使った利用量に応じてコストが増大していく． 一方，自前の計算環境では，大きな初期コストが生じる． その分，初期投資後のコストの増加は，電気利用料やサーバー維持費などに留まるため，クラウドを利用した場合よりも傾きは小さくなる． 自前の計算機では，ある一定期間後，サーバーのアップグレードなどによる支出が生じることがある． 一方，クラウドを利用する場合は，そのような非連続なコストの増大は基本的に生じない． クラウドのコストのカーブが，自前計算環境のコストのカーブの下にある範囲においては，クラウドを使うことは経済的なコスト削減につながる．</p>
<p><img src="./assets/cloud_cost.png" alt="クラウドと自前計算機環境の経済的コストの比較"></p>
</li>
</ol>
<p>とくに，**1.**の点は研究の場面では重要であると筆者は感じる． 研究をやっていて，四六時中計算を走らせ続けるという場合は少ない． むしろ，新しいアルゴリズムが完成したとき・新しいデータが届いたとき，集中的・突発的に計算タスクが増大することが多いだろう． そういったときに，フレキシブルに計算力を増強させることができるのは，クラウドを使う大きなメリットである．</p>
<p>ここまでクラウドを使うメリットを述べたが，逆に，デメリットというのも当然存在する．</p>
<ol>
<li>
<p><strong>クラウドは賢く使わないといけない</strong></p>
<p><a href="#cloud_economic_curve">figure_title</a> で示したコストのカーブにあるとおり，使い方によっては自前の計算環境のほうがコスト的に有利な場面は存在しうる． クラウドを利用する際は，使い終わった計算資源はすぐに削除するなど，利用者が賢く管理を行う必要があり，これを怠ると思いもしない額の請求が届く可能性がある． 2. <strong>セキュリティ</strong></p>
<p>クラウドは，インターネットを通じて世界のどこからでもアクセスできる状態にあり，セキュリティ管理を怠ると簡単にハッキングの対象となりうる． ハッキングを受けると，情報流出だけでなく，経済的な損失を被る可能性がある． 3. <strong>ラーニングカーブ</strong></p>
<p>上記のように，コスト・セキュリティなど，クラウドを利用する際に留意しなければならない点は多い． 賢くクラウドを使うには，十分なクラウドの理解が必要であり，そのラーニングカーブを乗り越える必要がある．</p>
</li>
</ol>
<p>Mac/Linux などでコマンドを入力するときに使用する，あの黒い画面のことを Terminal とよんだりする． この言葉の語源をご存知だろうか？</p>
<p><img src="./assets/terminal.png" alt="Terminal"></p>
<p>この言葉の語源は，コンピュータが誕生して間もない頃の時代に遡る． その頃のコンピュータというと，何千何万のという数の真空管が接続された，会議室一個分くらいのサイズのマシンであった． そのような高価でメンテが大変な機材であるから，当然みんなでシェアして使うことが前提となる． ユーザーがコンピュータにアクセスするため，マシンからは何本かのケーブルが伸び，それぞれにキーボードとスクリーンが接続されていた… これを <strong>Terminal</strong> とよんでいたのである． 人々は，代わる代わる Terminal の前に座って，計算機との対話を行っていた.</p>
<p>時代は流れ，Windows や Mac などのいわゆるパーソナルコンピュータの出現により，コンピュータはみんなで共有するものではなく，個人が所有するものになった．</p>
<p>最近のクラウドの台頭は，みんなで大きなコンピュータをシェアするという，最初のコンピュータの使われ方に原点回帰していると捉えることもできる． 一方で，スマートフォンやウェアラブルなどのエッジデバイスの普及も盛んであり，個人が複数の&quot;小さな&quot;コンピュータを所有する，という流れも同時に進行しているのである．</p>
<h1 id="aws-入門" tabindex="-1">AWS 入門 <a class="header-anchor" href="#aws-入門" aria-label="Permalink to &quot;AWS 入門&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="aws-とは" tabindex="-1">AWS とは？ <a class="header-anchor" href="#aws-とは" aria-label="Permalink to &quot;AWS とは？&quot;">&ZeroWidthSpace;</a></h2>
<p>本書では，クラウドの実践を行うプラットフォームとして， AWS を用いる． 実践にあたって，最低限必要な AWS の知識を本章では解説しよう．</p>
<p><a href="https://aws.amazon.com" target="_blank" rel="noreferrer">AWS (Amazon Web Services)</a> は Amazon 社が提供する総合的なクラウドプラットフォームである． AWS は Amazon 社が持つ膨大な計算リソースを貸し出すクラウドサービスとして，2006 年に誕生した． 2021 年では，クラウドプロバイダーとして最大のマーケットシェア (約 32%) を保持している (<a href="https://www.canalys.com/newsroom/global-cloud-market-Q121" target="_blank" rel="noreferrer">参照</a>)． Netflix や Slack をはじめとした多くのウェブ関連のサービスで，一部または全てのサーバーリソースが AWS から提供されているとのことである． よって，知らないうちに AWS の恩恵にあずかっている人も少なくないはずだ．</p>
<p>最大のシェアをもつだけに，機能・サービスの幅広さはほかのクラウドプラットフォームと比べ抜きんでている． また，利用者数が多いことを反映して，公式あるいはサードパーティによる技術紹介記事が数多くウェブ上に存在しているだけでなく，ライブラリのユーザーコミュニティも大きく問題解決が捗るのも魅力の一つだ． 初期のころウェブビジネスを行う企業がユーザーの大半を占めていたが，最近は大学などでの科学研究用途としても頻繁に用いられるようになってきている．</p>
<h2 id="aws-の機能・サービス" tabindex="-1">AWS の機能・サービス <a class="header-anchor" href="#aws-の機能・サービス" aria-label="Permalink to &quot;AWS の機能・サービス&quot;">&ZeroWidthSpace;</a></h2>
<p><a href="#fig_aws_services">figure_title</a> は，執筆時点において AWS で提供されている主要な機能・サービスの一覧である．</p>
<p><img src="./assets/aws_services.png" alt="AWSで提供されている主要なサービス一覧"></p>
<p>計算，ストレージ，データベース，ネットワーク，セキュリティなど，クラウドの構築に必要な様々な要素が<strong>独立したコンポーネント</strong>として提供されている． 基本的に，これらを組み合わせることで一つのクラウドシステムができあがる．</p>
<p>また，機械学習・音声認識・AR/VR など，特定のアプリケーションにパッケージ済みのサービスも提供されている． これらを合計すると全部で 170 個以上のサービスが提供されているとのことである (<a href="https://dev.classmethod.jp/articles/aws-summary-2020/" target="_blank" rel="noreferrer">参照</a>)．</p>
<p>AWS の初心者が陥りがちなのは，<strong>大量のサービスの数に圧倒され，どこから手をつけたらよいのかわからなくなる</strong>，という状況である． たくさんのサービスの中から，どのサービスをどの順番で学んでいったらいいのか，その道筋すら明らかでなく，大きな参入障壁となっていることは間違いない． だが実のところ， AWS の<strong>基本的な構成要素はそのうちの数個</strong>のみに限られる． 基本要素となる機能の使い方を知れば， AWS のおおよそのリソースを使いこなすことが可能になる． ほかの機能の多くは，基本の要素を組み合わせて特定のアプリケーションに特化したパッケージとして AWS が用意したものである． そのポイントを認知することが， AWS の学習の最初のステップである．</p>
<p>ここでは， AWS 上でクラウドシステムを構築するときの基本となる構成要素を列挙する． これらは後のハンズオンで実際にプログラムを書きながら体験する． 現時点では，名前だけでも頭の片隅に記憶してもらえればよい．</p>
<h3 id="計算" tabindex="-1">計算 <a class="header-anchor" href="#計算" aria-label="Permalink to &quot;計算&quot;">&ZeroWidthSpace;</a></h3>
<p><img src="./assets/aws_logos/EC2.png" alt="S3"> <strong>EC2 (Elastic Compute Cloud)</strong> 様々なスペックの仮想マシンを作成し，計算を実行することができる． クラウドの最も基本となる構成要素である． <a href="#sec_first_ec2">Hands-on #1: 初めての EC2 インスタンスを起動する</a>, <a href="#sec_jupyter_and_deep_learning">Hands-on #2: AWS でディープラーニングを実践</a>, <a href="#sec_aws_batch">Hands-on #4: AWS Batch を使って機械学習のハイパーパラメータサーチを並列化する</a> で詳しく触れる．</p>
<p><img src="./assets/aws_logos/Lambda.png" alt="S3"> <strong>Lambda</strong> Function as a Service (FaaS) とよばれる，小さな計算を<strong>サーバーなし</strong>で実行するためのサービス． サーバーレスアーキテクチャの章 (<a href="#sec_serverless">Serverless architecture</a>) で詳しく解説する．</p>
<h3 id="ストレージ" tabindex="-1">ストレージ <a class="header-anchor" href="#ストレージ" aria-label="Permalink to &quot;ストレージ&quot;">&ZeroWidthSpace;</a></h3>
<p><img src="./assets/aws_logos/EBS.png" alt="S3"> <strong>EBS (Elastic Block Store)</strong> EC2 に付与することのできる仮想データドライブ． いわゆる&quot;普通の&quot;(一般的な OS で使われている)ファイルシステムを思い浮かべてくれたらよい．</p>
<p><img src="./assets/aws_logos/S3.png" alt="S3"> <strong>S3 (Simple Storage Service)</strong> Object Storage とよばれる，API を使ってデータの読み書きを行う，いうなれば”クラウド・ネイティブ”なデータの格納システムである． サーバーレスアーキテクチャの章 (<a href="#sec_serverless">Serverless architecture</a>) で詳しく解説する．</p>
<h3 id="データベース" tabindex="-1">データベース <a class="header-anchor" href="#データベース" aria-label="Permalink to &quot;データベース&quot;">&ZeroWidthSpace;</a></h3>
<p><img src="./assets/aws_logos/DynamoDB.png" alt="S3"> <strong>DynamoDB</strong> NoSQL 型のデータベースサービス (知っている人は <code>mongoDB</code> などを思い浮かべたらよい)． サーバーレスアーキテクチャの章 (<a href="#sec_serverless">Serverless architecture</a>) で詳しく解説する．</p>
<h3 id="ネットワーク" tabindex="-1">ネットワーク <a class="header-anchor" href="#ネットワーク" aria-label="Permalink to &quot;ネットワーク&quot;">&ZeroWidthSpace;</a></h3>
<p><img src="./assets/aws_logos/VPC.png" alt="S3"> <strong>VPC(Virtual Private Cloud)</strong> AWS 上に仮想ネットワーク環境を作成し，仮想サーバー間の接続を定義したり，外部からのアクセスなどを管理する． EC2 は VPC の内部に配置されなければならない．</p>
<p><strong>API Gateway</strong> <img src="./assets/aws_logos/APIGateway.png" alt="S3"> API のエンドポイントとバックエンドのサービス (Lambda など) を接続する際に用いる，リバースプロキシとしての役割を担う． <a href="#sec_bashoutter">Hands-on #6: Bashoutter</a> で詳しく解説する．</p>
<h2 id="region-と-availability-zone" tabindex="-1">Region と Availability Zone <a class="header-anchor" href="#region-と-availability-zone" aria-label="Permalink to &quot;Region と Availability Zone&quot;">&ZeroWidthSpace;</a></h2>
<p>AWS を使用する際に知っておかなければならない重要な概念として， <strong>リージョン (Region)</strong> と <strong>Availability Zone (AZ)</strong> がある (<a href="#fig_aws_regions_and_azs">figure_title</a>)． 以下ではこの概念について簡単に記述する．</p>
<p><img src="./assets/aws_region_and_az.png" alt="AWSにおける Region と Availability Zones"></p>
<p><strong>リージョン (Region)</strong> とは，おおまかに言うとデータセンターの所在地のことである． 執筆時点において， AWS は世界の 25 の国と地域でデータセンターを所有している． <a href="#fig_aws_regions">figure_title</a> は執筆時点で利用できるリージョンの世界地図を示している． 日本では東京と大阪にデータセンターがある． 各リージョンには固有の ID がついており，例えば東京は <code>ap-northeast-1</code>, 米国オハイオ州は <code>us-east-2</code>，などと定義されている．</p>
<p><img src="./assets/aws_regions.png" alt="Regions in AWS(出典: https://aws.amazon.com/about-aws/global-infrastructure/)"></p>
<p>AWS コンソールにログインすると，画面右上のメニューバーでリージョンを選択することができる(<a href="#fig_aws_console_regions">figure_title</a>, 赤丸で囲った箇所)． EC2, S3 などの AWS のリソースは，リージョンごとに完全に独立である． したがって，<strong>リソースを新たにデプロイする際，あるいはデプロイ済みのリソースを閲覧する際は，コンソールのリージョンが正しく設定されているか，確認する必要がある</strong>． ウェブビジネスを展開する場合などは，世界の各地にクラウドを展開する必要があるが，個人的な研究用途として用いる場合は，最寄りのリージョン (i.e. 東京) を使えば基本的に問題ない．</p>
<p><img src="./assets/aws_regions2.png" alt="AWSコンソールでリージョンを選択"></p>
<p><code>Avaialibity Zone (AZ)</code> とは，リージョン内で地理的に隔離されたデータセンターのことである． それぞれのリージョンは 2 個以上の AZ を有しており，もし一つの AZ で火災や停電などが起きた場合でも，ほかの AZ がその障害をカバーすることができる． また， AZ 間は高速な AWS 専用ネットワーク回線で結ばれているため， AZ 間のデータ転送は極めて早い． AZ は，ビジネスなどでサーバーダウンが許容されない場合などに注意すべき概念であり，個人的な用途で使う限りにおいてはあまり深く考慮する必要はない．言葉の意味だけ知っておけば十分である．</p>
<p>AWS を使用する際，どこのリージョンを指定するのがよいのだろうか？ インターネットの接続速度の観点からは，地理的に一番近いリージョンを使用するのが一般的によいだろう． 一方， EC2 の利用料などはリージョンごとに価格設定が若干 (10-20%程度) 異なる． したがって，自分が最も頻繁に利用するサービスの価格が最も安く設定されているリージョンを選択する，というのも重要な視点である． また，いくつかのサービスは，特定のリージョンで利用できない場合もある． これらのポイントから総合的に判断して使用するリージョンを決めると良い．</p>
<p>AWS Educate を利用している読者へ</p>
<p>執筆時点において，AWS Educate による Starter Account を使用している場合は <code>us-east-1</code> region のみ利用できる (<a href="https://awseducate-starter-account-services.s3.amazonaws.com/AWS_Educate_Starter_Account_Services_Supported.pdf" target="_blank" rel="noreferrer">参照</a>)．</p>
<ul>
<li><a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-regions-availability-zones.html" target="_blank" rel="noreferrer">AWS documentation &quot;Regions, Availability Zones, and Local Zones&quot;</a></li>
</ul>
<h2 id="aws-でのクラウド開発" tabindex="-1">AWS でのクラウド開発 <a class="header-anchor" href="#aws-でのクラウド開発" aria-label="Permalink to &quot;AWS でのクラウド開発&quot;">&ZeroWidthSpace;</a></h2>
<p>AWS のクラウドの全体像がわかってきたところで，次のトピックとして，どのようにして AWS 上にクラウドの開発を行い，展開していくかについての概略を解説しよう．</p>
<p>AWS のリソースを追加・編集・削除するなどの操作を実行するには，<strong>コンソールを用いる</strong>方法と，<strong>API を用いる方法</strong>の，二つの経路がある．</p>
<h3 id="コンソール画面からリソースを操作する" tabindex="-1">コンソール画面からリソースを操作する <a class="header-anchor" href="#コンソール画面からリソースを操作する" aria-label="Permalink to &quot;コンソール画面からリソースを操作する&quot;">&ZeroWidthSpace;</a></h3>
<p>AWS のアカウントにログインすると，まず最初に表示されるのが<strong>AWS コンソール</strong>である (<a href="#aws_console_window">figure_title</a>)．</p>
<p><img src="./assets/aws_console.png" alt="AWSマネージメントコンソール画面"></p>
<p>コンソールを使うことで， EC2 のインスタンスを立ち上げたり，S3 のデータを追加・削除したり，ログを閲覧したりなど，AWS 上のあらゆるリソースの操作を GUI (Graphical User Interface) を通して実行することができる． <strong>初めて触る機能をポチポチと試したり，デバッグを行うときなどにとても便利である</strong>．</p>
<p>コンソールはさらっと機能を試したり，開発中のクラウドのデバッグをするときには便利なのであるが，実際にクラウドの開発をする場面でこれを直接いじることはあまりない． むしろ，次に紹介する API を使用して，プログラムとしてクラウドのリソースを記述することで開発を行うのが一般的である． そのような理由で，本書では AWS コンソールを使った AWS の使い方はあまり触れない． AWS のドキュメンテーションには，たくさんの <a href="https://aws.amazon.com/getting-started/hands-on/" target="_blank" rel="noreferrer">チュートリアル</a> が用意されており，コンソール画面から様々な操作を行う方法が記述されているので，興味がある読者はそちらを参照されたい．</p>
<h3 id="api-からリソースを操作する" tabindex="-1">API からリソースを操作する <a class="header-anchor" href="#api-からリソースを操作する" aria-label="Permalink to &quot;API からリソースを操作する&quot;">&ZeroWidthSpace;</a></h3>
<p><strong>API (Application Programming Interface)</strong> を使うことで，コマンドを AWS に送信し，クラウドのリソースの操作をすることができる． API とは，端的に言えば AWS が公開しているコマンドの一覧であり，<code>GET</code>, <code>POST</code>, <code>DELETE</code> などの <strong>REST API</strong> から構成されている (REST API については <a href="#sec_rest_api">REST API</a> で簡単に解説する)． が，直接 REST API を入力するのは面倒であるので，その手間を解消するための様々なツールが提供されている．</p>
<p>例えば， <a href="https://docs.aws.amazon.com/cli/latest/index.html" target="_blank" rel="noreferrer">AWS CLI</a> は， UNIX コンソールから AWS API を実行するための CLI (Command Line Interface) である． CLI に加えて，いろいろなプログラミング言語での SDK (Software Development Kit) が提供されている．以下に一例を挙げる．</p>
<ul>
<li>
<p>Python ⇒ <a href="https://boto3.amazonaws.com/v1/documentation/api/latest/index.html" target="_blank" rel="noreferrer">boto3</a></p>
</li>
<li>
<p>Ruby ⇒ <a href="https://aws.amazon.com/sdk-for-ruby/" target="_blank" rel="noreferrer">AWS SDK for Ruby</a></p>
</li>
<li>
<p>Node.js ⇒ <a href="https://aws.amazon.com/sdk-for-node-js/" target="_blank" rel="noreferrer">AWS SDK for Node.js</a></p>
</li>
</ul>
<p>具体的な API の使用例を見てみよう．</p>
<p>S3 に新しい保存領域 (<code>Bucket (バケット)</code> とよばれる) を追加したいとしよう． AWS CLI を使った場合は，次のようなコマンドを打てばよい．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">s3</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">mb</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">s3://my-bucket</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--region</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ap-northeast-1</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">aws</span><span style="color: #24292E"> </span><span style="color: #032F62">s3</span><span style="color: #24292E"> </span><span style="color: #032F62">mb</span><span style="color: #24292E"> </span><span style="color: #032F62">s3://my-bucket</span><span style="color: #24292E"> </span><span style="color: #005CC5">--region</span><span style="color: #24292E"> </span><span style="color: #032F62">ap-northeast-1</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>上記のコマンドは， <code>my-bucket</code> という名前のバケットを， <code>ap-northeast-1</code> のリージョンに作成する．</p>
<p>Python からこれと同じ操作を実行するには， <code>boto3</code> ライブラリを使って，次のようなスクリプトを実行する．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> boto3</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">s3_client </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> boto3.client(</span><span style="color: #96D0FF">&quot;s3&quot;</span><span style="color: #ADBAC7">, </span><span style="color: #F69D50">region_name</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;ap-northeast-1&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">s3_client.create_bucket(</span><span style="color: #F69D50">Bucket</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;my-bucket&quot;</span><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> boto3</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">s3_client </span><span style="color: #D73A49">=</span><span style="color: #24292E"> boto3.client(</span><span style="color: #032F62">&quot;s3&quot;</span><span style="color: #24292E">, </span><span style="color: #E36209">region_name</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;ap-northeast-1&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">s3_client.create_bucket(</span><span style="color: #E36209">Bucket</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;my-bucket&quot;</span><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br></div></div><p>もう一つ例をあげよう．</p>
<p>新しい EC2 のインスタンス(インスタンスとは，起動状態にある仮想サーバーの意味である)を起動するには，次のようなコマンドを打てば良い．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ec2</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">run-instances</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--image-id</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ami-xxxxxxxx</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--count</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--instance-type</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">t2.micro</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--key-name</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">MyKeyPair</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--security-group-ids</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">sg-903004f8</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--subnet-id</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">subnet-6e7f829e</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">aws</span><span style="color: #24292E"> </span><span style="color: #032F62">ec2</span><span style="color: #24292E"> </span><span style="color: #032F62">run-instances</span><span style="color: #24292E"> </span><span style="color: #005CC5">--image-id</span><span style="color: #24292E"> </span><span style="color: #032F62">ami-xxxxxxxx</span><span style="color: #24292E"> </span><span style="color: #005CC5">--count</span><span style="color: #24292E"> </span><span style="color: #005CC5">1</span><span style="color: #24292E"> </span><span style="color: #005CC5">--instance-type</span><span style="color: #24292E"> </span><span style="color: #032F62">t2.micro</span><span style="color: #24292E"> </span><span style="color: #005CC5">--key-name</span><span style="color: #24292E"> </span><span style="color: #032F62">MyKeyPair</span><span style="color: #24292E"> </span><span style="color: #005CC5">--security-group-ids</span><span style="color: #24292E"> </span><span style="color: #032F62">sg-903004f8</span><span style="color: #24292E"> </span><span style="color: #005CC5">--subnet-id</span><span style="color: #24292E"> </span><span style="color: #032F62">subnet-6e7f829e</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>このコマンドにより， <a href="https://aws.amazon.com/ec2/instance-types/t2/" target="_blank" rel="noreferrer">t2.micro</a> というタイプ (1 vCPU, 1.0 GB RAM) のインスタンスが起動する． ここではその他のパラメータの詳細の説明は省略する (ハンズオン (<a href="#sec_first_ec2">Hands-on #1: 初めての EC2 インスタンスを起動する</a>) で詳しく解説する)．</p>
<p>Python から上記と同じ操作を実行するには，以下のようなスクリプトを使う．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> boto3</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">ec2_client </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> boto3.client(</span><span style="color: #96D0FF">&quot;ec2&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">ec2_client.run_instances(</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">ImageId</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;ami-xxxxxxxxx&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">MinCount</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">MaxCount</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">KeyName</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;MyKeyPair&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">InstanceType</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;t2.micro&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">SecurityGroupIds</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">[</span><span style="color: #96D0FF">&quot;sg-903004f8&quot;</span><span style="color: #ADBAC7">],</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">SubnetId</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;subnet-6e7f829e&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> boto3</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">ec2_client </span><span style="color: #D73A49">=</span><span style="color: #24292E"> boto3.client(</span><span style="color: #032F62">&quot;ec2&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">ec2_client.run_instances(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">ImageId</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;ami-xxxxxxxxx&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">MinCount</span><span style="color: #D73A49">=</span><span style="color: #005CC5">1</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">MaxCount</span><span style="color: #D73A49">=</span><span style="color: #005CC5">1</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">KeyName</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;MyKeyPair&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">InstanceType</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;t2.micro&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">SecurityGroupIds</span><span style="color: #D73A49">=</span><span style="color: #24292E">[</span><span style="color: #032F62">&quot;sg-903004f8&quot;</span><span style="color: #24292E">],</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">SubnetId</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;subnet-6e7f829e&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br></div></div><p>以上の例を通じて，API によるクラウドのリソースの操作のイメージがつかめてきただろうか？ コマンド一つで，新しい仮想サーバーを起動したり，データの保存領域を追加したり，任意の操作を実行できるわけである． 基本的に，このようなコマンドを複数組み合わせていくことで，自分の望む CPU・RAM・ネットワーク・ストレージが備わった計算環境を構築することができる． もちろん，逆の操作 (リソースの削除) も API を使って実行できる．</p>
<h3 id="ミニ・ハンズオン-aws-cli-を使ってみよう" tabindex="-1">ミニ・ハンズオン: AWS CLI を使ってみよう <a class="header-anchor" href="#ミニ・ハンズオン-aws-cli-を使ってみよう" aria-label="Permalink to &quot;ミニ・ハンズオン: AWS CLI を使ってみよう&quot;">&ZeroWidthSpace;</a></h3>
<p>ここでは，ミニ・ハンズオンとして，AWS CLI を実際に使ってみる． AWS CLI は先述のとおり， AWS 上の任意のリソースの操作が可能であるが，ここでは一番シンプルな，<strong>S3 を使ったファイルの読み書きを実践する</strong> (EC2 の操作は少し複雑なので，第一回ハンズオンで行う)． <code>aws s3</code> コマンドの詳しい使い方は <a href="https://docs.aws.amazon.com/cli/latest/reference/s3/index.html#cli-aws-s3" target="_blank" rel="noreferrer">公式ドキュメンテーション</a>を参照．</p>
<p>AWS CLI のインストールについては， <a href="#aws_cli_install">AWS CLI のインストール</a> を参照．</p>
<p>以下に紹介するハンズオンは，基本的に <a href="https://aws.amazon.com/free/?all-free-tier.sort-by=item.additionalFields.SortRank&amp;all-free-tier.sort-order=asc" target="_blank" rel="noreferrer">S3 の無料枠</a> の範囲内で実行することができる．</p>
<p>以下のコマンドを実行する前に，AWS の認証情報が正しく設定されていることを確認する． これには <code>~/.aws/credentials</code> のファイルに設定が書き込まれているか，環境変数 (<code>AWS_ACCESS_KEY_ID</code>, <code>AWS_SECRET_ACCESS_KEY</code>, <code>AWS_DEFAULT_REGION</code>) が定義されている必要がある． 詳しくは <a href="#aws_cli_install">AWS CLI のインストール</a> を参照．</p>
<p>まずは，S3 にデータの格納領域 (<code>Bucket</code> とよばれる．一般的な OS での&quot;ドライブ&quot;に相当する) を作成するところから始めよう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">bucketName=&quot;mybucket-$(</span><span style="color: #F69D50">openssl</span><span style="color: #96D0FF"> rand </span><span style="color: #6CB6FF">-hex</span><span style="color: #96D0FF"> </span><span style="color: #6CB6FF">12</span><span style="color: #96D0FF">)&quot;</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">echo</span><span style="color: #ADBAC7"> $bucketName</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">s3</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">mb</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;s3://${</span><span style="color: #ADBAC7">bucketName</span><span style="color: #96D0FF">}&quot;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">bucketName=&quot;mybucket-$(</span><span style="color: #6F42C1">openssl</span><span style="color: #032F62"> rand </span><span style="color: #005CC5">-hex</span><span style="color: #032F62"> </span><span style="color: #005CC5">12</span><span style="color: #032F62">)&quot;</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">echo</span><span style="color: #24292E"> $bucketName</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">aws</span><span style="color: #24292E"> </span><span style="color: #032F62">s3</span><span style="color: #24292E"> </span><span style="color: #032F62">mb</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;s3://${</span><span style="color: #24292E">bucketName</span><span style="color: #032F62">}&quot;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><p>S3 のバケットの名前は， AWS 全体で一意的でなければならないことから，前述のコマンドではランダムな文字列を含んだバケットの名前を生成し，<code>bucketName</code> という変数に格納している． そして， <code>aws s3 mb</code> (<code>mb</code> は make bucket の略) によって，新しいバケットを作成する．</p>
<p>次に，バケットの一覧を取得してみよう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">s3</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ls</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F69D50">2020-06-07</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">23</span><span style="color: #96D0FF">:45:44</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">mybucket-c6f93855550a72b5b66f5efe</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">aws</span><span style="color: #24292E"> </span><span style="color: #032F62">s3</span><span style="color: #24292E"> </span><span style="color: #032F62">ls</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6F42C1">2020-06-07</span><span style="color: #24292E"> </span><span style="color: #005CC5">23</span><span style="color: #032F62">:45:44</span><span style="color: #24292E"> </span><span style="color: #032F62">mybucket-c6f93855550a72b5b66f5efe</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><p>先ほど作成したバケットがリストにあることを確認できる．</p>
<p>本書のノーテーションとして，コマンドラインに入力するコマンドは，それがコマンドであると明示する目的で先頭に <code>$</code> がつけてある． <code>$</code> はコマンドをコピー&amp;ペーストするときは除かなければならない． 逆に，コマンドの出力は <code>$</code> なしで表示されている．</p>
<p>次に，バケットにファイルをアップロードする．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">echo</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;Hello world&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">&gt;</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">hello_world.txt</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">s3</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cp</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">hello_world.txt</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;s3://${</span><span style="color: #ADBAC7">bucketName</span><span style="color: #96D0FF">}/hello_world.txt&quot;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">echo</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;Hello world&quot;</span><span style="color: #24292E"> </span><span style="color: #D73A49">&gt;</span><span style="color: #24292E"> </span><span style="color: #032F62">hello_world.txt</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">aws</span><span style="color: #24292E"> </span><span style="color: #032F62">s3</span><span style="color: #24292E"> </span><span style="color: #032F62">cp</span><span style="color: #24292E"> </span><span style="color: #032F62">hello_world.txt</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;s3://${</span><span style="color: #24292E">bucketName</span><span style="color: #032F62">}/hello_world.txt&quot;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>上では <code>hello_world.txt</code> というダミーのファイルを作成して，それをアップロードした．</p>
<p>それでは，バケットの中にあるファイルの一覧を取得してみる．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">s3</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ls</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;s3://${</span><span style="color: #ADBAC7">bucketName</span><span style="color: #96D0FF">}&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--human-readable</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F69D50">2020-06-07</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">23</span><span style="color: #96D0FF">:54:19</span><span style="color: #ADBAC7">   </span><span style="color: #6CB6FF">13</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">Bytes</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">hello_world.txt</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">aws</span><span style="color: #24292E"> </span><span style="color: #032F62">s3</span><span style="color: #24292E"> </span><span style="color: #032F62">ls</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;s3://${</span><span style="color: #24292E">bucketName</span><span style="color: #032F62">}&quot;</span><span style="color: #24292E"> </span><span style="color: #005CC5">--human-readable</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6F42C1">2020-06-07</span><span style="color: #24292E"> </span><span style="color: #005CC5">23</span><span style="color: #032F62">:54:19</span><span style="color: #24292E">   </span><span style="color: #005CC5">13</span><span style="color: #24292E"> </span><span style="color: #032F62">Bytes</span><span style="color: #24292E"> </span><span style="color: #032F62">hello_world.txt</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><p>先ほどアップロードしたファイルがたしかに存在することがわかる．</p>
<p>最後に，使い終わったバケットを削除する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">s3</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">rb</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;s3://${</span><span style="color: #ADBAC7">bucketName</span><span style="color: #96D0FF">}&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--force</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">aws</span><span style="color: #24292E"> </span><span style="color: #032F62">s3</span><span style="color: #24292E"> </span><span style="color: #032F62">rb</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;s3://${</span><span style="color: #24292E">bucketName</span><span style="color: #032F62">}&quot;</span><span style="color: #24292E"> </span><span style="color: #005CC5">--force</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p><code>rb</code> は remove bucket の略である． デフォルトでは，バケットの中にファイルが存在すると削除できない． 空でないバケットを強制的に削除するには <code>--force</code> のオプションを付ける．</p>
<p>以上のように，AWS CLI を使って S3 バケットに対しての一連の操作を実行できた． EC2 や Lambda, DynamoDB などについても同様に AWS CLI を使ってあらゆる操作を実行できる．</p>
<p><strong>Amazon Resource Name (ARN)</strong></p>
<p>AWS 上のあらゆるリソースには， Amazon Resource Name (ARN) という固有の ID が付与されている． ARN は <code>arn:aws:s3:::my_bucket/</code> のようなフォーマットで記述され，ARN を使用することで，特定の AWS リソース (S3 のバケットや EC2 のインスタンス) を一意的に参照することができる．</p>
<p>S3 バケットや EC2 インスタンスなどには ARN に加えて，人間が読みやすい名前を定義することも可能である． この場合は，ARN または名前のどちらを用いても同じリソースを参照することが可能である．</p>
<h2 id="cloudformation-と-aws-cdk" tabindex="-1">CloudFormation と AWS CDK <a class="header-anchor" href="#cloudformation-と-aws-cdk" aria-label="Permalink to &quot;CloudFormation と AWS CDK&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="cloudformation-による-infrastructure-as-code-iac" tabindex="-1">CloudFormation による Infrastructure as Code (IaC) <a class="header-anchor" href="#cloudformation-による-infrastructure-as-code-iac" aria-label="Permalink to &quot;CloudFormation による Infrastructure as Code (IaC)&quot;">&ZeroWidthSpace;</a></h3>
<p>前節で述べたように，AWS API を使うことでクラウドの<strong>あらゆる</strong>リソースの作成・管理が可能である． よって，原理上は， API のコマンドを組み合わせていくことで，自分の作りたいクラウドを設計することができる．</p>
<p>しかし，ここで実用上考慮しなければならない点が一つある． AWS API には大きく分けて，<strong>リソースを操作する</strong>コマンドと，<strong>タスクを実行する</strong>コマンドがあることである (<a href="#fig_aws_iac">figure_title</a>)．</p>
<p><img src="./assets/iac.png" alt="AWS APIはリソースを操作するコマンドとタスクを実行するコマンドに大きく分けられる．リソースを記述・管理するのに使われるのが， CloudFormation と CDK である．"></p>
<p><strong>リソースを操作する</strong>とは，EC2 のインスタンスを起動したり，S3 のバケットを作成したり，データベースに新たなテーブルを追加する，などの<strong>静的なリソースを準備する</strong> 操作を指す． &quot;ハコ&quot;を作る操作とよんでも良いだろう． このようなコマンドは，<strong>クラウドのデプロイ時にのみ，一度だけ実行されればよい</strong>．</p>
<p><strong>タスクを実行するコマンド</strong> とは， EC2 のインスタンスにジョブを投入したり， S3 のバケットにデータを読み書きするなどの操作を指す． これは， EC2 や S3 などのリソース (&quot;ハコ&quot;) を前提として，その内部で実行されるべき計算を記述するものである． 前者に比べてこちらは<strong>動的な操作</strong>を担当する，と捉えることもできる．</p>
<p>そのような観点から，<strong>インフラを記述するプログラム</strong>と<strong>タスクを実行するプログラム</strong>はある程度分けて管理されるべきである． クラウドの開発は，クラウドの(静的な)リソースを記述するプログラムを作成するステップと，インフラ上で動く動的な操作を行うプログラムを作成するステップの二段階に分けて考えることができる．</p>
<p>AWS での静的リソースを管理するための仕組みが， <a href="https://aws.amazon.com/cloudformation/" target="_blank" rel="noreferrer">CloudFormation</a> である． CloudFormation とは， CloudFormation の文法に従ったテキストファイルを使って，AWS のインフラを記述する仕組みである． CloudFormation を使って，たとえば，EC2 のインスタンスをどれくらいのスペックで，何個起動するか，インスタンス間はどのようなネットワークで結び，どのようなアクセス権限を付与するか，などのリソースの要件を逐次的に記述することができる． 一度 CloudFormation ファイルができ上がれば，それにしたがったクラウドシステムをコマンド一つで AWS 上に展開することができる． また，CloudFormation ファイルを交換することで，全く同一のクラウド環境を他者が簡単に再現することも可能になる． このように，本来は物理的な実体のあるハードウェアを，プログラムによって記述し，管理するという考え方を，**Infrastructure as Code (IaC)**とよぶ．</p>
<p>CloudFormation を記述するには，基本的に <strong>JSON</strong> (JavaScript Object Notation) とよばれるフォーマットを使う． 次のコードは，JSON で記述された CloudFormation ファイルの一例 (抜粋) である．</p>
<div class="language-json vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">json</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #96D0FF">&quot;Resources&quot;</span><span style="color: #ADBAC7"> : {</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #FF938A; font-style: italic">...</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #8DDB8C">&quot;WebServer&quot;</span><span style="color: #ADBAC7">: {</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #8DDB8C">&quot;Type&quot;</span><span style="color: #ADBAC7"> : </span><span style="color: #96D0FF">&quot;AWS::EC2::Instance&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #8DDB8C">&quot;Properties&quot;</span><span style="color: #ADBAC7">: {</span></span>
<span class="line"><span style="color: #ADBAC7">      </span><span style="color: #8DDB8C">&quot;ImageId&quot;</span><span style="color: #ADBAC7"> : { </span><span style="color: #8DDB8C">&quot;Fn::FindInMap&quot;</span><span style="color: #ADBAC7"> : [ </span><span style="color: #96D0FF">&quot;AWSRegionArch2AMI&quot;</span><span style="color: #ADBAC7">, { </span><span style="color: #8DDB8C">&quot;Ref&quot;</span><span style="color: #ADBAC7"> : </span><span style="color: #96D0FF">&quot;AWS::Region&quot;</span><span style="color: #ADBAC7"> },</span></span>
<span class="line"><span style="color: #ADBAC7">                        { </span><span style="color: #8DDB8C">&quot;Fn::FindInMap&quot;</span><span style="color: #ADBAC7"> : [ </span><span style="color: #96D0FF">&quot;AWSInstanceType2Arch&quot;</span><span style="color: #ADBAC7">, { </span><span style="color: #8DDB8C">&quot;Ref&quot;</span><span style="color: #ADBAC7"> : </span><span style="color: #96D0FF">&quot;InstanceType&quot;</span><span style="color: #ADBAC7"> }, </span><span style="color: #96D0FF">&quot;Arch&quot;</span><span style="color: #ADBAC7"> ] } ] },</span></span>
<span class="line"><span style="color: #ADBAC7">      </span><span style="color: #8DDB8C">&quot;InstanceType&quot;</span><span style="color: #ADBAC7">   : { </span><span style="color: #8DDB8C">&quot;Ref&quot;</span><span style="color: #ADBAC7"> : </span><span style="color: #96D0FF">&quot;InstanceType&quot;</span><span style="color: #ADBAC7"> },</span></span>
<span class="line"><span style="color: #ADBAC7">      </span><span style="color: #8DDB8C">&quot;SecurityGroups&quot;</span><span style="color: #ADBAC7"> : [ {</span><span style="color: #8DDB8C">&quot;Ref&quot;</span><span style="color: #ADBAC7"> : </span><span style="color: #96D0FF">&quot;WebServerSecurityGroup&quot;</span><span style="color: #ADBAC7">} ],</span></span>
<span class="line"><span style="color: #ADBAC7">      </span><span style="color: #8DDB8C">&quot;KeyName&quot;</span><span style="color: #ADBAC7">        : { </span><span style="color: #8DDB8C">&quot;Ref&quot;</span><span style="color: #ADBAC7"> : </span><span style="color: #96D0FF">&quot;KeyName&quot;</span><span style="color: #ADBAC7"> },</span></span>
<span class="line"><span style="color: #ADBAC7">      </span><span style="color: #8DDB8C">&quot;UserData&quot;</span><span style="color: #ADBAC7"> : { </span><span style="color: #8DDB8C">&quot;Fn::Base64&quot;</span><span style="color: #ADBAC7"> : { </span><span style="color: #8DDB8C">&quot;Fn::Join&quot;</span><span style="color: #ADBAC7"> : [</span><span style="color: #96D0FF">&quot;&quot;</span><span style="color: #ADBAC7">, [</span></span>
<span class="line"><span style="color: #ADBAC7">                     </span><span style="color: #96D0FF">&quot;#!/bin/bash -xe</span><span style="color: #F47067">\n</span><span style="color: #96D0FF">&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                     </span><span style="color: #96D0FF">&quot;yum update -y aws-cfn-bootstrap</span><span style="color: #F47067">\n</span><span style="color: #96D0FF">&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">                     </span><span style="color: #96D0FF">&quot;/opt/aws/bin/cfn-init -v &quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                     </span><span style="color: #96D0FF">&quot;         --stack &quot;</span><span style="color: #ADBAC7">, { </span><span style="color: #8DDB8C">&quot;Ref&quot;</span><span style="color: #ADBAC7"> : </span><span style="color: #96D0FF">&quot;AWS::StackName&quot;</span><span style="color: #ADBAC7"> },</span></span>
<span class="line"><span style="color: #ADBAC7">                     </span><span style="color: #96D0FF">&quot;         --resource WebServer &quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                     </span><span style="color: #96D0FF">&quot;         --configsets wordpress_install &quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                     </span><span style="color: #96D0FF">&quot;         --region &quot;</span><span style="color: #ADBAC7">, { </span><span style="color: #8DDB8C">&quot;Ref&quot;</span><span style="color: #ADBAC7"> : </span><span style="color: #96D0FF">&quot;AWS::Region&quot;</span><span style="color: #ADBAC7"> }, </span><span style="color: #96D0FF">&quot;</span><span style="color: #F47067">\n</span><span style="color: #96D0FF">&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">                     </span><span style="color: #96D0FF">&quot;/opt/aws/bin/cfn-signal -e $? &quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                     </span><span style="color: #96D0FF">&quot;         --stack &quot;</span><span style="color: #ADBAC7">, { </span><span style="color: #8DDB8C">&quot;Ref&quot;</span><span style="color: #ADBAC7"> : </span><span style="color: #96D0FF">&quot;AWS::StackName&quot;</span><span style="color: #ADBAC7"> },</span></span>
<span class="line"><span style="color: #ADBAC7">                     </span><span style="color: #96D0FF">&quot;         --resource WebServer &quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                     </span><span style="color: #96D0FF">&quot;         --region &quot;</span><span style="color: #ADBAC7">, { </span><span style="color: #8DDB8C">&quot;Ref&quot;</span><span style="color: #ADBAC7"> : </span><span style="color: #96D0FF">&quot;AWS::Region&quot;</span><span style="color: #ADBAC7"> }, </span><span style="color: #96D0FF">&quot;</span><span style="color: #F47067">\n</span><span style="color: #96D0FF">&quot;</span></span>
<span class="line"><span style="color: #ADBAC7">      ]]}}</span></span>
<span class="line"><span style="color: #ADBAC7">    },</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #FF938A; font-style: italic">...</span></span>
<span class="line"><span style="color: #ADBAC7">  },</span></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #FF938A; font-style: italic">...</span></span>
<span class="line"><span style="color: #ADBAC7">},</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #032F62">&quot;Resources&quot;</span><span style="color: #24292E"> : {</span></span>
<span class="line"><span style="color: #24292E">  </span><span style="color: #B31D28; font-style: italic">...</span></span>
<span class="line"><span style="color: #24292E">  </span><span style="color: #005CC5">&quot;WebServer&quot;</span><span style="color: #24292E">: {</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">&quot;Type&quot;</span><span style="color: #24292E"> : </span><span style="color: #032F62">&quot;AWS::EC2::Instance&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">&quot;Properties&quot;</span><span style="color: #24292E">: {</span></span>
<span class="line"><span style="color: #24292E">      </span><span style="color: #005CC5">&quot;ImageId&quot;</span><span style="color: #24292E"> : { </span><span style="color: #005CC5">&quot;Fn::FindInMap&quot;</span><span style="color: #24292E"> : [ </span><span style="color: #032F62">&quot;AWSRegionArch2AMI&quot;</span><span style="color: #24292E">, { </span><span style="color: #005CC5">&quot;Ref&quot;</span><span style="color: #24292E"> : </span><span style="color: #032F62">&quot;AWS::Region&quot;</span><span style="color: #24292E"> },</span></span>
<span class="line"><span style="color: #24292E">                        { </span><span style="color: #005CC5">&quot;Fn::FindInMap&quot;</span><span style="color: #24292E"> : [ </span><span style="color: #032F62">&quot;AWSInstanceType2Arch&quot;</span><span style="color: #24292E">, { </span><span style="color: #005CC5">&quot;Ref&quot;</span><span style="color: #24292E"> : </span><span style="color: #032F62">&quot;InstanceType&quot;</span><span style="color: #24292E"> }, </span><span style="color: #032F62">&quot;Arch&quot;</span><span style="color: #24292E"> ] } ] },</span></span>
<span class="line"><span style="color: #24292E">      </span><span style="color: #005CC5">&quot;InstanceType&quot;</span><span style="color: #24292E">   : { </span><span style="color: #005CC5">&quot;Ref&quot;</span><span style="color: #24292E"> : </span><span style="color: #032F62">&quot;InstanceType&quot;</span><span style="color: #24292E"> },</span></span>
<span class="line"><span style="color: #24292E">      </span><span style="color: #005CC5">&quot;SecurityGroups&quot;</span><span style="color: #24292E"> : [ {</span><span style="color: #005CC5">&quot;Ref&quot;</span><span style="color: #24292E"> : </span><span style="color: #032F62">&quot;WebServerSecurityGroup&quot;</span><span style="color: #24292E">} ],</span></span>
<span class="line"><span style="color: #24292E">      </span><span style="color: #005CC5">&quot;KeyName&quot;</span><span style="color: #24292E">        : { </span><span style="color: #005CC5">&quot;Ref&quot;</span><span style="color: #24292E"> : </span><span style="color: #032F62">&quot;KeyName&quot;</span><span style="color: #24292E"> },</span></span>
<span class="line"><span style="color: #24292E">      </span><span style="color: #005CC5">&quot;UserData&quot;</span><span style="color: #24292E"> : { </span><span style="color: #005CC5">&quot;Fn::Base64&quot;</span><span style="color: #24292E"> : { </span><span style="color: #005CC5">&quot;Fn::Join&quot;</span><span style="color: #24292E"> : [</span><span style="color: #032F62">&quot;&quot;</span><span style="color: #24292E">, [</span></span>
<span class="line"><span style="color: #24292E">                     </span><span style="color: #032F62">&quot;#!/bin/bash -xe</span><span style="color: #005CC5">\n</span><span style="color: #032F62">&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                     </span><span style="color: #032F62">&quot;yum update -y aws-cfn-bootstrap</span><span style="color: #005CC5">\n</span><span style="color: #032F62">&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">                     </span><span style="color: #032F62">&quot;/opt/aws/bin/cfn-init -v &quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                     </span><span style="color: #032F62">&quot;         --stack &quot;</span><span style="color: #24292E">, { </span><span style="color: #005CC5">&quot;Ref&quot;</span><span style="color: #24292E"> : </span><span style="color: #032F62">&quot;AWS::StackName&quot;</span><span style="color: #24292E"> },</span></span>
<span class="line"><span style="color: #24292E">                     </span><span style="color: #032F62">&quot;         --resource WebServer &quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                     </span><span style="color: #032F62">&quot;         --configsets wordpress_install &quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                     </span><span style="color: #032F62">&quot;         --region &quot;</span><span style="color: #24292E">, { </span><span style="color: #005CC5">&quot;Ref&quot;</span><span style="color: #24292E"> : </span><span style="color: #032F62">&quot;AWS::Region&quot;</span><span style="color: #24292E"> }, </span><span style="color: #032F62">&quot;</span><span style="color: #005CC5">\n</span><span style="color: #032F62">&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">                     </span><span style="color: #032F62">&quot;/opt/aws/bin/cfn-signal -e $? &quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                     </span><span style="color: #032F62">&quot;         --stack &quot;</span><span style="color: #24292E">, { </span><span style="color: #005CC5">&quot;Ref&quot;</span><span style="color: #24292E"> : </span><span style="color: #032F62">&quot;AWS::StackName&quot;</span><span style="color: #24292E"> },</span></span>
<span class="line"><span style="color: #24292E">                     </span><span style="color: #032F62">&quot;         --resource WebServer &quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                     </span><span style="color: #032F62">&quot;         --region &quot;</span><span style="color: #24292E">, { </span><span style="color: #005CC5">&quot;Ref&quot;</span><span style="color: #24292E"> : </span><span style="color: #032F62">&quot;AWS::Region&quot;</span><span style="color: #24292E"> }, </span><span style="color: #032F62">&quot;</span><span style="color: #005CC5">\n</span><span style="color: #032F62">&quot;</span></span>
<span class="line"><span style="color: #24292E">      ]]}}</span></span>
<span class="line"><span style="color: #24292E">    },</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #B31D28; font-style: italic">...</span></span>
<span class="line"><span style="color: #24292E">  },</span></span>
<span class="line"><span style="color: #24292E">  </span><span style="color: #B31D28; font-style: italic">...</span></span>
<span class="line"><span style="color: #24292E">},</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br></div></div><p>ここでは， &quot;WebServer&quot; という名前のつけられた EC2 インスタンスを定義している．かなり長大で複雑な記述であるが，これによって所望のスペック・OS をもつ EC2 インスタンスを自動的に生成することが可能になる．</p>
<h3 id="aws-cdk" tabindex="-1">AWS CDK <a class="header-anchor" href="#aws-cdk" aria-label="Permalink to &quot;AWS CDK&quot;">&ZeroWidthSpace;</a></h3>
<p>前節で紹介した CloudFormation は，見てわかるとおり大変記述が複雑であり，またそれのどれか一つにでも誤りがあってはいけない． また，基本的に&quot;テキスト&quot;を書いていくことになるので，プログラミング言語で使うような変数やクラスといった便利な概念が使えない　(厳密には， CloudFormation にも変数に相当するような機能は存在する)． また，記述の多くの部分は繰り返しが多く，自動化できる部分も多い．</p>
<p>そのような悩みを解決してくれるのが， <a href="https://aws.amazon.com/cdk/" target="_blank" rel="noreferrer">AWS Cloud Development Kit (CDK)</a> である． <strong>CDK は Python などのプログラミング言語を使って CloudFormation を自動的に生成してくれるツールである．</strong> CDK は 2019 年にリリースされたばかりの比較的新しいツールで，日々改良が進められている (<a href="https://github.com/aws/aws-cdk/releases" target="_blank" rel="noreferrer">GitHub リポジトリ</a> のリリースを見ればその開発のスピードの速さがわかるだろう)． CDK は TypeScript (JavaScript), Python, Java など複数の言語でサポートされている．</p>
<p>CDK を使うことで，CloudFormation に相当するクラウドリソースの記述を，より親しみのあるプログラミング言語を使って行うことができる． かつ，典型的なリソース操作に関してはパラメータの多くの部分を自動で決定してくれるので，記述しなければならない量もかなり削減される．</p>
<p>以下に Python を使った CDK のコードの一例 (抜粋) を示す．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">from</span><span style="color: #ADBAC7"> aws_cdk </span><span style="color: #F47067">import</span><span style="color: #ADBAC7"> (</span></span>
<span class="line"><span style="color: #ADBAC7">    core,</span></span>
<span class="line"><span style="color: #ADBAC7">    aws_ec2 </span><span style="color: #F47067">as</span><span style="color: #ADBAC7"> ec2,</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F47067">class</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50">MyFirstEc2</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">core</span><span style="color: #ADBAC7">.</span><span style="color: #6CB6FF">Stack</span><span style="color: #ADBAC7">):</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">def</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">__init__</span><span style="color: #ADBAC7">(self, scope, name, </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">kwargs):</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #6CB6FF">super</span><span style="color: #ADBAC7">().</span><span style="color: #6CB6FF">__init__</span><span style="color: #ADBAC7">(scope, name, </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">kwargs)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        vpc </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ec2.Vpc(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">...</span><span style="color: #ADBAC7"> </span><span style="color: #768390"># some parameters</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        sg </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ec2.SecurityGroup(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">...</span><span style="color: #ADBAC7"> </span><span style="color: #768390"># some parameters</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        host </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ec2.Instance(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;MyGreatEc2&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">instance_type</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.InstanceType(</span><span style="color: #96D0FF">&quot;t2.micro&quot;</span><span style="color: #ADBAC7">),</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">machine_image</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.MachineImage.latest_amazon_linux(),</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">vpc</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">vpc,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">...</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">from</span><span style="color: #24292E"> aws_cdk </span><span style="color: #D73A49">import</span><span style="color: #24292E"> (</span></span>
<span class="line"><span style="color: #24292E">    core,</span></span>
<span class="line"><span style="color: #24292E">    aws_ec2 </span><span style="color: #D73A49">as</span><span style="color: #24292E"> ec2,</span></span>
<span class="line"><span style="color: #24292E">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D73A49">class</span><span style="color: #24292E"> </span><span style="color: #6F42C1">MyFirstEc2</span><span style="color: #24292E">(</span><span style="color: #6F42C1">core</span><span style="color: #24292E">.</span><span style="color: #6F42C1">Stack</span><span style="color: #24292E">):</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">def</span><span style="color: #24292E"> </span><span style="color: #005CC5">__init__</span><span style="color: #24292E">(self, scope, name, </span><span style="color: #D73A49">**</span><span style="color: #24292E">kwargs):</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #005CC5">super</span><span style="color: #24292E">().</span><span style="color: #005CC5">__init__</span><span style="color: #24292E">(scope, name, </span><span style="color: #D73A49">**</span><span style="color: #24292E">kwargs)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        vpc </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ec2.Vpc(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">...</span><span style="color: #24292E"> </span><span style="color: #6A737D"># some parameters</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        sg </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ec2.SecurityGroup(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">...</span><span style="color: #24292E"> </span><span style="color: #6A737D"># some parameters</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        host </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ec2.Instance(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;MyGreatEc2&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">instance_type</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.InstanceType(</span><span style="color: #032F62">&quot;t2.micro&quot;</span><span style="color: #24292E">),</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">machine_image</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.MachineImage.latest_amazon_linux(),</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">vpc</span><span style="color: #D73A49">=</span><span style="color: #24292E">vpc,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">...</span></span>
<span class="line"><span style="color: #24292E">        )</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br></div></div><p>このコードは，一つ前に示した JSON を使った CloudFormation と実質的に同じことを記述している． とても煩雑だった CloudFormation ファイルに比べて， CDK と Python を使うことで格段に短く，わかりやすく記述できることができるのがわかるだろう．</p>
<p>本書の主題は，<strong>CDK を使って，コードを書きながら AWS の概念や開発方法を学んでいくことである</strong>． 後の章では CDK を使って様々なハンズオンを実施していく． 早速，最初のハンズオンでは， CDK を使って EC2 インスタンスを作成する方法を学んでいこう．</p>
<ul>
<li><a href="https://github.com/aws-samples/aws-cdk-examples" target="_blank" rel="noreferrer">AWS CDK Examples</a>: CDK を使ったプロジェクトの例が多数紹介されている． ここにある例をテンプレートに自分のアプリケーションの開発を進めるとよい．</li>
</ul>
<h1 id="hands-on-1-初めての-ec2-インスタンスを起動する" tabindex="-1">Hands-on #1: 初めての EC2 インスタンスを起動する <a class="header-anchor" href="#hands-on-1-初めての-ec2-インスタンスを起動する" aria-label="Permalink to &quot;Hands-on \#1: 初めての EC2 インスタンスを起動する&quot;">&ZeroWidthSpace;</a></h1>
<p>ハンズオンの第一回では， CDK を使って EC2 のインスタンス(仮想サーバー)を作成し，SSH でサーバーにログインする，という演習を行う． このハンズオンを終えれば，あなたは自分だけのサーバーを AWS 上に立ち上げ，自由に計算を走らせることができるようになるのである！</p>
<h2 id="準備" tabindex="-1">準備 <a class="header-anchor" href="#準備" aria-label="Permalink to &quot;準備&quot;">&ZeroWidthSpace;</a></h2>
<p>ハンズオンのソースコードは GitHub の <a href="https://github.com/andatoshiki/toshiki-notebooktree/main/handson/ec2-get-started" target="_blank" rel="noreferrer">handson/ec2-get-started</a> に置いてある．</p>
<p>このハンズオンは，基本的に <a href="https://aws.amazon.com/free/?all-free-tier.sort-by=item.additionalFields.SortRank&amp;all-free-tier.sort-order=asc" target="_blank" rel="noreferrer">AWS の無料枠</a> の範囲内で実行することができる．</p>
<p>まずは，ハンズオンを実行するための環境を整える． これらの環境整備は，後のハンズオンでも前提となるものなので確実にミスなく行っていただきたい．</p>
<ul>
<li><strong>AWS Account</strong>: ハンズオンを実行するには個人の AWS アカウントが必要である． AWS アカウントの取得については <a href="#sec:create_aws_account">AWS アカウントの取得</a> を参照のこと．</li>
<li><strong>Python と Node.js</strong>: 本ハンズオンを実行するには，Python (3.6 以上)，Node.js (12.0 以上) がインストールされていなければならない．</li>
<li><strong>AWS CLI</strong>: AWS CLI のインストールについては， <a href="#aws_cli_install">AWS CLI のインストール</a> を参照． ここに記載されている認証鍵の設定も済ませておくこと．</li>
<li><strong>AWS CDK</strong>: AWS CDK のインストールについては， <a href="#aws_cdk_install">AWS CDK のインストール</a> を参照．</li>
<li><strong>ソースコードのダウンロード</strong>: 本ハンズオンで使用するプログラムのソースコードを，以下のコマンドを使って GitHub からダウンロードする．</li>
</ul>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">git</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">clone</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">https://github.com/tomomano/learn-aws-by-coding.git</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">git</span><span style="color: #24292E"> </span><span style="color: #032F62">clone</span><span style="color: #24292E"> </span><span style="color: #032F62">https://github.com/tomomano/learn-aws-by-coding.git</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>あるいは， <code>https://github.com/tomomano/learn-aws-by-coding</code> のページに行って，右上のダウンロードボタンからダウンロードすることもできる．</p>
<p><strong>Docker を使用する場合</strong></p>
<p>Python, Node.js, AWS CDK など，ハンズオンのプログラムを実行するために必要なプログラム/ライブラリがインストール済みの Docker image を用意した． また，ハンズオンのソースコードもパッケージ済みである． Docker の使い方を知っている読者は，これを使えば，諸々のインストールをする必要なく，すぐにハンズオンのプログラムを実行できる．</p>
<p>使用方法については <a href="#sec_handson_docker">ハンズオン実行用の Docker image の使い方</a> を参照のこと．</p>
<h2 id="ssh" tabindex="-1">SSH <a class="header-anchor" href="#ssh" aria-label="Permalink to &quot;SSH&quot;">&ZeroWidthSpace;</a></h2>
<p><strong>SSH (secure shell)</strong> は Unix 系のリモートサーバーに安全にアクセスするためのツールである． 本ハンズオンでは， SSH を使って仮想サーバーにアクセスする． SSH に慣れていない読者のため，簡単な説明をここで行おう．</p>
<p>SSH による通信はすべて暗号化されているので，機密情報をインターネットを介して安全に送受信することができる． 本ハンズオンで，リモートのサーバーにアクセスするための SSH クライアントがローカルマシンにインストールされている必要がある． SSH クライアントは Linux/Mac には標準搭載されている． Windows の場合は WSL をインストールすることで SSH クライアントを利用することを推奨する (<a href="#environments">環境構築</a> を参照)．</p>
<p>SSH コマンドの基本的な使い方を次に示す． <code>&lt;host name&gt;</code> はアクセスする先のサーバーの IP アドレスや DNS によるホストネームが入る． <code>&lt;user name&gt;</code> は接続する先のユーザー名である．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ssh</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">&lt;</span><span style="color: #96D0FF">user</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">nam</span><span style="color: #ADBAC7">e</span><span style="color: #F47067">&gt;</span><span style="color: #96D0FF">@</span><span style="color: #F47067">&lt;</span><span style="color: #96D0FF">host</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">nam</span><span style="color: #ADBAC7">e</span><span style="color: #F47067">&gt;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">ssh</span><span style="color: #24292E"> </span><span style="color: #D73A49">&lt;</span><span style="color: #032F62">user</span><span style="color: #24292E"> </span><span style="color: #032F62">nam</span><span style="color: #24292E">e</span><span style="color: #D73A49">&gt;</span><span style="color: #032F62">@</span><span style="color: #D73A49">&lt;</span><span style="color: #032F62">host</span><span style="color: #24292E"> </span><span style="color: #032F62">nam</span><span style="color: #24292E">e</span><span style="color: #D73A49">&gt;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>SSH は平文のパスワードによる認証を行うこともできるが，より強固なセキュリティを施すため，<strong>公開鍵暗号方式(Public Key Cryptography)による認証</strong>を行うことが強く推奨されており， EC2 はこの方法でしかアクセスを許していない． 公開鍵暗号方式の仕組みについては各自勉強してほしい． 本ハンズオンにおいて大事なことは，<strong>EC2 インスタンスが公開鍵(Public key)を保持し，クライアントとなるコンピュータ(読者自身のコンピュータ)が秘密鍵(Private key)を保持する</strong>，という点である． EC2 のインスタンスには秘密鍵を持ったコンピュータのみがアクセスすることができる．逆に言うと，秘密鍵が漏洩すると第三者もサーバーにアクセスできることになるので，<strong>秘密鍵は絶対に漏洩することのないよう注意して管理する</strong>．</p>
<p>SSH コマンドでは，ログインのために使用する秘密鍵ファイルを <code>-i</code> もしくは <code>--identity_file</code> のオプションで指定することができる． たとえば，次のように使う．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ssh</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-i</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">Ec2SecretKey.pem</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">&lt;</span><span style="color: #96D0FF">user</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">nam</span><span style="color: #ADBAC7">e</span><span style="color: #F47067">&gt;</span><span style="color: #96D0FF">@</span><span style="color: #F47067">&lt;</span><span style="color: #96D0FF">host</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">nam</span><span style="color: #ADBAC7">e</span><span style="color: #F47067">&gt;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">ssh</span><span style="color: #24292E"> </span><span style="color: #005CC5">-i</span><span style="color: #24292E"> </span><span style="color: #032F62">Ec2SecretKey.pem</span><span style="color: #24292E"> </span><span style="color: #D73A49">&lt;</span><span style="color: #032F62">user</span><span style="color: #24292E"> </span><span style="color: #032F62">nam</span><span style="color: #24292E">e</span><span style="color: #D73A49">&gt;</span><span style="color: #032F62">@</span><span style="color: #D73A49">&lt;</span><span style="color: #032F62">host</span><span style="color: #24292E"> </span><span style="color: #032F62">nam</span><span style="color: #24292E">e</span><span style="color: #D73A49">&gt;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><h2 id="アプリケーションの説明" tabindex="-1">アプリケーションの説明 <a class="header-anchor" href="#アプリケーションの説明" aria-label="Permalink to &quot;アプリケーションの説明&quot;">&ZeroWidthSpace;</a></h2>
<p>このハンズオンで作成するアプリケーションの概要を <a href="#handson_01_architecture">figure_title</a> に示す．</p>
<p><img src="./assets/handson-01/app_architecture.png" alt="ハンズオン#1で作製するアプリケーションのアーキテクチャ"></p>
<p>このアプリケーションではまず，<strong>VPC (Virtual Private Cloud)</strong> を使ってプライベートな仮想ネットワーク環境を立ち上げている． その VPC の public subnet の内側に，<strong>EC2 (Elatic Compute Cloud)</strong> の仮想サーバーを配置する． さらに，セキュリティのため， <strong>Security Group</strong> による EC2 インスタンスへのアクセス制限を設定している． このようにして作成された仮想サーバーに，SSH を使ってアクセスし，簡単な計算を行う．</p>
<p><a href="#handson_01_architecture">figure_title</a> のようなアプリケーションを，CDK を使って構築する．</p>
<p>早速ではあるが，今回のハンズオンで使用するプログラムを見てみよう (<a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/ec2-get-started/app.py" target="_blank" rel="noreferrer">handson/ec2-get-started/app.py</a>)．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">class</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50">MyFirstEc2</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">core</span><span style="color: #ADBAC7">.</span><span style="color: #6CB6FF">Stack</span><span style="color: #ADBAC7">):</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">def</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">__init__</span><span style="color: #ADBAC7">(self, scope: core.App, name: </span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">, key_name: </span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">, </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">kwargs) -&gt; </span><span style="color: #6CB6FF">None</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #6CB6FF">super</span><span style="color: #ADBAC7">().</span><span style="color: #6CB6FF">__init__</span><span style="color: #ADBAC7">(scope, name, </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">kwargs)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        vpc </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ec2.Vpc(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;MyFirstEc2-Vpc&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">max_azs</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">cidr</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;10.10.0.0/23&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">subnet_configuration</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">[</span></span>
<span class="line"><span style="color: #ADBAC7">                ec2.SubnetConfiguration(</span></span>
<span class="line"><span style="color: #ADBAC7">                    </span><span style="color: #F69D50">name</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;public&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                    </span><span style="color: #F69D50">subnet_type</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.SubnetType.</span><span style="color: #6CB6FF">PUBLIC</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                )</span></span>
<span class="line"><span style="color: #ADBAC7">            ],</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">nat_gateways</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        sg </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ec2.SecurityGroup(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;MyFirstEc2Vpc-Sg&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">vpc</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">vpc,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">allow_all_outbound</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">True</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"><span style="color: #ADBAC7">        sg.add_ingress_rule(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">peer</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.Peer.any_ipv4(),</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">connection</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.Port.tcp(</span><span style="color: #6CB6FF">22</span><span style="color: #ADBAC7">),</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        host </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ec2.Instance(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;MyFirstEc2Instance&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">instance_type</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.InstanceType(</span><span style="color: #96D0FF">&quot;t2.micro&quot;</span><span style="color: #ADBAC7">),</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">machine_image</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.MachineImage.latest_amazon_linux(),</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">vpc</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">vpc,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">vpc_subnets</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.SubnetSelection(</span><span style="color: #F69D50">subnet_type</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.SubnetType.</span><span style="color: #6CB6FF">PUBLIC</span><span style="color: #ADBAC7">),</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">security_group</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">sg,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">key_name</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">key_name</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">class</span><span style="color: #24292E"> </span><span style="color: #6F42C1">MyFirstEc2</span><span style="color: #24292E">(</span><span style="color: #6F42C1">core</span><span style="color: #24292E">.</span><span style="color: #6F42C1">Stack</span><span style="color: #24292E">):</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">def</span><span style="color: #24292E"> </span><span style="color: #005CC5">__init__</span><span style="color: #24292E">(self, scope: core.App, name: </span><span style="color: #005CC5">str</span><span style="color: #24292E">, key_name: </span><span style="color: #005CC5">str</span><span style="color: #24292E">, </span><span style="color: #D73A49">**</span><span style="color: #24292E">kwargs) -&gt; </span><span style="color: #005CC5">None</span><span style="color: #24292E">:</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #005CC5">super</span><span style="color: #24292E">().</span><span style="color: #005CC5">__init__</span><span style="color: #24292E">(scope, name, </span><span style="color: #D73A49">**</span><span style="color: #24292E">kwargs)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        vpc </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ec2.Vpc(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;MyFirstEc2-Vpc&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">max_azs</span><span style="color: #D73A49">=</span><span style="color: #005CC5">1</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">cidr</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;10.10.0.0/23&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">subnet_configuration</span><span style="color: #D73A49">=</span><span style="color: #24292E">[</span></span>
<span class="line"><span style="color: #24292E">                ec2.SubnetConfiguration(</span></span>
<span class="line"><span style="color: #24292E">                    </span><span style="color: #E36209">name</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;public&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                    </span><span style="color: #E36209">subnet_type</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.SubnetType.</span><span style="color: #005CC5">PUBLIC</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                )</span></span>
<span class="line"><span style="color: #24292E">            ],</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">nat_gateways</span><span style="color: #D73A49">=</span><span style="color: #005CC5">0</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        sg </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ec2.SecurityGroup(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;MyFirstEc2Vpc-Sg&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">vpc</span><span style="color: #D73A49">=</span><span style="color: #24292E">vpc,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">allow_all_outbound</span><span style="color: #D73A49">=</span><span style="color: #005CC5">True</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"><span style="color: #24292E">        sg.add_ingress_rule(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">peer</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.Peer.any_ipv4(),</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">connection</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.Port.tcp(</span><span style="color: #005CC5">22</span><span style="color: #24292E">),</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        host </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ec2.Instance(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;MyFirstEc2Instance&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">instance_type</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.InstanceType(</span><span style="color: #032F62">&quot;t2.micro&quot;</span><span style="color: #24292E">),</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">machine_image</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.MachineImage.latest_amazon_linux(),</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">vpc</span><span style="color: #D73A49">=</span><span style="color: #24292E">vpc,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">vpc_subnets</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.SubnetSelection(</span><span style="color: #E36209">subnet_type</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.SubnetType.</span><span style="color: #005CC5">PUBLIC</span><span style="color: #24292E">),</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">security_group</span><span style="color: #D73A49">=</span><span style="color: #24292E">sg,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">key_name</span><span style="color: #D73A49">=</span><span style="color: #24292E">key_name</span></span>
<span class="line"><span style="color: #24292E">        )</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br><span class="line-number">36</span><br><span class="line-number">37</span><br><span class="line-number">38</span><br><span class="line-number">39</span><br><span class="line-number">40</span><br></div></div><ul>
<li>
<p>まず最初に，VPC を定義する．</p>
</li>
<li>
<p>次に， security group (SG) を定義している． ここでは，任意の IPv4 のアドレスからの，ポート 22 (SSH の接続に使用される)への接続を許可している． それ以外の接続は拒絶される．</p>
</li>
<li>
<p>最後に，上記で作った VPC と SG が付与された EC2 インスタンスを作成している． インスタンスタイプは <code>t2.micro</code> を選択し， <a href="https://aws.amazon.com/amazon-linux-ami/" target="_blank" rel="noreferrer">Amazon Linux</a> を OS として設定している．</p>
</li>
</ul>
<p>それぞれについて，もう少し詳しく説明しよう．</p>
<h3 id="vpc-virtual-private-cloud" tabindex="-1">VPC (Virtual Private Cloud) <a class="header-anchor" href="#vpc-virtual-private-cloud" aria-label="Permalink to &quot;VPC (Virtual Private Cloud)&quot;">&ZeroWidthSpace;</a></h3>
<p><strong>VPC のアイコン.</strong></p>
<p><img src="./assets/aws_logos/VPC.png" alt="VPC"></p>
<p>VPC は AWS 上にプライベートな仮想ネットワーク環境を構築するツールである．高度な計算システムを構築するには，複数のサーバーを連動させて計算を行う必要があるが，そのような場合に互いのアドレスなどを管理する必要があり，そういった目的で VPC は有用である．</p>
<p>本ハンズオンでは，サーバーは一つしか起動しないので，VPC の恩恵はよく分からないかもしれない．しかし，EC2 インスタンスは必ず VPC の中に配置されなければならない，という制約があるので，このハンズオンでもミニマルな VPC を構成している．</p>
<p>興味のある読者のために，VPC のコードについてもう少し詳しく説明しよう．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">vpc </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ec2.Vpc(</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;MyFirstEc2-Vpc&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">max_azs</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">cidr</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;10.10.0.0/23&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">subnet_configuration</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">[</span></span>
<span class="line"><span style="color: #ADBAC7">        ec2.SubnetConfiguration(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">name</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;public&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">subnet_type</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.SubnetType.</span><span style="color: #6CB6FF">PUBLIC</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"><span style="color: #ADBAC7">    ],</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">nat_gateways</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">vpc </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ec2.Vpc(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;MyFirstEc2-Vpc&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">max_azs</span><span style="color: #D73A49">=</span><span style="color: #005CC5">1</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">cidr</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;10.10.0.0/23&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">subnet_configuration</span><span style="color: #D73A49">=</span><span style="color: #24292E">[</span></span>
<span class="line"><span style="color: #24292E">        ec2.SubnetConfiguration(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">name</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;public&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">subnet_type</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.SubnetType.</span><span style="color: #005CC5">PUBLIC</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"><span style="color: #24292E">    ],</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">nat_gateways</span><span style="color: #D73A49">=</span><span style="color: #005CC5">0</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br></div></div><ul>
<li>
<p><code>max_azs=1</code> : このパラメータは，前章で説明した avaialibility zone (AZ) を設定している． このハンズオンでは，特にデータセンターの障害などを気にする必要はないので <code>1</code> にしている．</p>
</li>
<li>
<p><code>cidr=&quot;10.10.0.0/23&quot;</code> : このパラメータは，VPC 内の IPv4 のレンジを指定している． CIDR 記法については， <a href="https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing" target="_blank" rel="noreferrer">Wikipedia</a>などを参照． <code>10.10.0.0/23</code> は <code>10.10.0.0</code> から <code>10.10.1.255</code> までの 512 個の連続したアドレス範囲を指している． つまり，この VPC では最大で 512 個のユニークな IPv4 アドレスが使えることになる． 今回はサーバーは一つなので 512 個は明らかに多すぎるが，VPC はアドレスの数はどれだけ作成しても無料なので，多めに作成した．</p>
</li>
<li>
<p><code>subnet_configuration=...</code> : このパラメータは，VPC にどのようなサブネットを作るか，を決めている． サブネットの種類には <strong>private subnet</strong> と <strong>public subnet</strong> の二種類がある． private subnet は基本的にインターネットとは遮断されたサブネット環境である． インターネットと繋がっていないので，セキュリティは極めて高く， VPC 内のサーバーとのみ通信を行えばよい EC2 インスタンスはここに配置する． Public subnet とはインターネットに繋がったサブネットである． 本ハンズオンで作成するサーバーは，外から SSH でログインを行いたいので， Public subnet 内に配置する． より詳細な記述は <a href="https://docs.aws.amazon.com/vpc/latest/userguide/VPC_Subnets.html#vpc-subnet-basics" target="_blank" rel="noreferrer">公式ドキュメンテーション</a> を参照．</p>
</li>
<li>
<p><code>natgateways=0</code> : これは少し高度な内容なので省略する (興味のある読者は <a href="https://docs.aws.amazon.com/vpc/latest/userguide/vpc-nat-gateway.html" target="_blank" rel="noreferrer">公式ドキュメンテーション</a>を参照)． が，<strong>これを 0 にしておかないと，NAT Gateway の利用料金が発生してしまうので，注意！</strong></p>
</li>
</ul>
<h3 id="security-group" tabindex="-1">Security Group <a class="header-anchor" href="#security-group" aria-label="Permalink to &quot;Security Group&quot;">&ZeroWidthSpace;</a></h3>
<p>Security group (SG) は， EC2 インスタンスに付与することのできる仮想ファイアーウォールである． たとえば，特定の IP アドレスから来た接続を許可・拒絶したり　(インバウンド・トラフィックの制限) ，逆に特定の IP アドレスへのアクセスを禁止したり (アウトバウンド・トラフィックの制限) することができる．</p>
<p>コードの該当部分を見てみよう．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">sg </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ec2.SecurityGroup(</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;MyFirstEc2Vpc-Sg&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">vpc</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">vpc,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">allow_all_outbound</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">True</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">sg.add_ingress_rule(</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">peer</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.Peer.any_ipv4(),</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">connection</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.Port.tcp(</span><span style="color: #6CB6FF">22</span><span style="color: #ADBAC7">),</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">sg </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ec2.SecurityGroup(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;MyFirstEc2Vpc-Sg&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">vpc</span><span style="color: #D73A49">=</span><span style="color: #24292E">vpc,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">allow_all_outbound</span><span style="color: #D73A49">=</span><span style="color: #005CC5">True</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">sg.add_ingress_rule(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">peer</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.Peer.any_ipv4(),</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">connection</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.Port.tcp(</span><span style="color: #005CC5">22</span><span style="color: #24292E">),</span></span>
<span class="line"><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br></div></div><p>本ハンズオンでは， SSH による外部からの接続を許容するため， <code>sg.add_ingress_rule(peer=ec2.Peer.any_ipv4(), connection=ec2.Port.tcp(22))</code> により，すべての IPv4 アドレスからのポート 22 番へのアクセスを許容している． また， SSH で EC2 インスタンスにログインしたのち，インターネットからプログラムなどをダウンロードできるよう， <code>allow_all_outbound=True</code> のパラメータを設定している．</p>
<p>SSH はデフォルトでは 22 番ポートを使用するのが慣例である．</p>
<p>セキュリティ上の観点からは，SSH の接続は自宅や大学・職場など特定の地点からの接続のみを許す方が望ましい．</p>
<h3 id="ec2-elastic-compute-cloud" tabindex="-1">EC2 (Elastic Compute Cloud) <a class="header-anchor" href="#ec2-elastic-compute-cloud" aria-label="Permalink to &quot;EC2 (Elastic Compute Cloud)&quot;">&ZeroWidthSpace;</a></h3>
<p><strong>EC2 のアイコン.</strong></p>
<p><img src="./assets/aws_logos/EC2.png" alt="EC2"></p>
<p>EC2 は AWS 上に仮想サーバーを立ち上げるサービスである． 個々の起動状態にある仮想サーバーのことをインスタンス (instance) とよぶ (しかし，口語的なコミュニケーションにおいては，サーバーとインスタンスという言葉は相互互換的に用いられることが多い)．</p>
<p>EC2 では用途に応じて様々なインスタンスタイプが提供されている． <a href="#ec2_instance_types">table_title</a> に，代表的なインスタンスタイプの例を挙げる (執筆時点での情報)． EC2 のインスタンスタイプのすべてのリストは <a href="https://aws.amazon.com/ec2/instance-types/" target="_blank" rel="noreferrer">公式ドキュメンテーション &quot;Amazon EC2 Instance Types&quot;</a> で見ることができる．</p>
<table><caption>EC2 instance types</caption><colgroup><col style="width: 20%" /><col style="width: 20%" /><col style="width: 20%" /><col style="width: 20%" /><col style="width: 20%" /></colgroup><thead><tr class="header"><th>Instance</th><th>vCPU</th><th>Memory (GiB)</th><th>Network bandwidth (Gbps)</th><th>Price per hour ($)</th></tr></thead><tbody><tr class="odd"><td><p>t2.micro</p></td><td><p>1</p></td><td><p>1</p></td><td><p>-</p></td><td><p>0.0116</p></td></tr><tr class="even"><td><p>t2.small</p></td><td><p>1</p></td><td><p>2</p></td><td><p>-</p></td><td><p>0.023</p></td></tr><tr class="odd"><td><p>t2.medium</p></td><td><p>2</p></td><td><p>4</p></td><td><p>-</p></td><td><p>0.0464</p></td></tr><tr class="even"><td><p>c5.24xlarge</p></td><td><p>96</p></td><td><p>192</p></td><td><p>25</p></td><td><p>4.08</p></td></tr><tr class="odd"><td><p>c5n.18xlarge</p></td><td><p>72</p></td><td><p>192</p></td><td><p>100</p></td><td><p>3.888</p></td></tr><tr class="even"><td><p>x1e.16xlarge</p></td><td><p>64</p></td><td><p>1952</p></td><td><p>10</p></td><td><p>13.344</p></td></tr></tbody></table>
<p><a href="#ec2_instance_types">table_title</a> からわかるように， CPU は 1 コアから 96 コアまで，メモリーは 1GB から 2TB 以上まで，ネットワーク帯域は最大で 100Gbps まで，幅広く選択することができる． また，時間あたりの料金は，CPU・メモリーの占有数にほぼ比例する形で増加する． EC2 はサーバーの起動時間を秒単位で記録しており，<strong>利用料金は使用時間に比例する形で決定される</strong>． 例えば， <code>t2.medium</code> のインスタンスを 10 時間起動した場合，0.0464 * 10 = 0.464 ドルの料金が発生する．</p>
<p>AWS には <a href="https://aws.amazon.com/free/?all-free-tier.sort-by=item.additionalFields.SortRank&amp;all-free-tier.sort-order=asc" target="_blank" rel="noreferrer">無料利用枠</a> というものがあり， <code>t2.micro</code> であれば月に 750 時間までは無料で利用することができる．</p>
<p><a href="#ec2_instance_types">table_title</a> の価格は <code>us-east-1</code> のものである． リージョンによって多少価格設定が異なる．</p>
<p>上記で t2.micro の $0.0116 / hour という金額は， On-demand インスタンスというタイプを選択した場合の価格である． EC2 ではほかに， <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-spot-instances.html" target="_blank" rel="noreferrer">Spot instance</a> とよばれるインスタンスも存在しする． Spot instance は，AWS のデータセンターの負荷が増えた場合，ユーザーのプログラムが実行中であっても AWS の判断により強制シャットダウンされる，という不便さを抱えているのだが，その分大幅に安い料金設定になっている． AWS で一時的に生じた余剰な空き CPU をユーザーに割安で貸し出す，という発想である． 科学計算やウェブサーバーなどの用途でコストを削減する目的で， Spot Instance を活用する事例も多数報告されている．</p>
<p>EC2 インスタンスを定義しているコードの該当部分を見てみよう．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">host </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ec2.Instance(</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;MyFirstEc2Instance&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">instance_type</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.InstanceType(</span><span style="color: #96D0FF">&quot;t2.micro&quot;</span><span style="color: #ADBAC7">),</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">machine_image</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.MachineImage.latest_amazon_linux(),</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">vpc</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">vpc,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">vpc_subnets</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.SubnetSelection(</span><span style="color: #F69D50">subnet_type</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.SubnetType.</span><span style="color: #6CB6FF">PUBLIC</span><span style="color: #ADBAC7">),</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">security_group</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">sg,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">key_name</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">key_name</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">host </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ec2.Instance(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;MyFirstEc2Instance&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">instance_type</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.InstanceType(</span><span style="color: #032F62">&quot;t2.micro&quot;</span><span style="color: #24292E">),</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">machine_image</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.MachineImage.latest_amazon_linux(),</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">vpc</span><span style="color: #D73A49">=</span><span style="color: #24292E">vpc,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">vpc_subnets</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.SubnetSelection(</span><span style="color: #E36209">subnet_type</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.SubnetType.</span><span style="color: #005CC5">PUBLIC</span><span style="color: #24292E">),</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">security_group</span><span style="color: #D73A49">=</span><span style="color: #24292E">sg,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">key_name</span><span style="color: #D73A49">=</span><span style="color: #24292E">key_name</span></span>
<span class="line"><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br></div></div><p>ここでは， <code>t2.micro</code> というインスタンスタイプを選択している． さらに， <code>machine_image</code> として， <a href="https://aws.amazon.com/amazon-linux-ami/" target="_blank" rel="noreferrer">Amazon Linux</a> を選択している (Machine image は OS と似た概念である． Machine image については， <a href="#sec_jupyter_and_deep_learning">Hands-on #2: AWS でディープラーニングを実践</a> でより詳しく触れる)． さらに，上で定義した VPC, SG をこのインスタンスに付与している．</p>
<p>以上が，今回使用するプログラムの簡単な解説であった． ミニマルな形のプログラムではあるが，仮想サーバーを作成するのに必要なステップがおわかりいただけただろうか？</p>
<h2 id="プログラムを実行する" tabindex="-1">プログラムを実行する <a class="header-anchor" href="#プログラムを実行する" aria-label="Permalink to &quot;プログラムを実行する&quot;">&ZeroWidthSpace;</a></h2>
<p>さて，ハンズオンのコードの理解ができたところで，プログラムを実際に実行してみよう．繰り返しになるが， <a href="#handson_01_prep">準備</a> での準備ができていることが前提である．</p>
<h3 id="python-の依存ライブラリのインストール" tabindex="-1">Python の依存ライブラリのインストール <a class="header-anchor" href="#python-の依存ライブラリのインストール" aria-label="Permalink to &quot;Python の依存ライブラリのインストール&quot;">&ZeroWidthSpace;</a></h3>
<p>まずは，Python の依存ライブラリをインストールする．以下では，Python のライブラリを管理するツールとして， <a href="https://docs.python.org/3/library/venv.html" target="_blank" rel="noreferrer">venv</a> を使用する．</p>
<p>まずは， <code>handson/ec2-get-started</code> のディレクトリに移動しよう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cd</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">handson/ec2-get-started</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cd</span><span style="color: #24292E"> </span><span style="color: #032F62">handson/ec2-get-started</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>ディレクトリを移動したら， <code>venv</code> で新しい仮想環境を作成し，インストールを実行する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python3</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-m</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">venv</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.env</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">source</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.env/bin/activate</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">pip</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">install</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-r</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">requirements.txt</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python3</span><span style="color: #24292E"> </span><span style="color: #005CC5">-m</span><span style="color: #24292E"> </span><span style="color: #032F62">venv</span><span style="color: #24292E"> </span><span style="color: #032F62">.env</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">source</span><span style="color: #24292E"> </span><span style="color: #032F62">.env/bin/activate</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">pip</span><span style="color: #24292E"> </span><span style="color: #032F62">install</span><span style="color: #24292E"> </span><span style="color: #005CC5">-r</span><span style="color: #24292E"> </span><span style="color: #032F62">requirements.txt</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><p>これで Python の環境構築は完了だ．</p>
<p><code>venv</code> の簡単な説明は <a href="#venv_quick_guide">Python クイックガイド</a> に記述してある．</p>
<p>環境によっては <code>pip</code> ではなく <code>pip3</code> あるいは <code>python3 -m pip</code> に置き換える必要がある．</p>
<h3 id="aws-のシークレットキーをセットする" tabindex="-1">AWS のシークレットキーをセットする <a class="header-anchor" href="#aws-のシークレットキーをセットする" aria-label="Permalink to &quot;AWS のシークレットキーをセットする&quot;">&ZeroWidthSpace;</a></h3>
<p>AWS CLI および AWS CDK を使うには， AWS のシークレットキーが設定されている必要がある． シークレットキーの発行については <a href="#aws_secrets">AWS のシークレットキーの作成</a> を参照のこと． シークレットキーを発行したら， <a href="#aws_cli_install">AWS CLI のインストール</a> を参照し，コマンドラインの設定を行う．</p>
<p>手順をここに短く要約すると，一つ目の方法は <code>AWS_ACCESS_KEY_ID</code> などの環境変数を設定するやり方である． もう一つの方法は， <code>~/.aws/credentials</code> に認証情報を保存しておく方式である． シークレットキーの設定は AWS CLI/CDK を使用するうえで共通のステップになるので，しっかりと理解しておくように．</p>
<h3 id="ssh-鍵を生成" tabindex="-1">SSH 鍵を生成 <a class="header-anchor" href="#ssh-鍵を生成" aria-label="Permalink to &quot;SSH 鍵を生成&quot;">&ZeroWidthSpace;</a></h3>
<p>EC2 インスタンスには SSH を使ってログインする． EC2 インスタンスを作成するのに先行して，今回のハンズオンで専用に使う SSH の公開鍵・秘密鍵のペアを準備する必要がある．</p>
<p>次の AWS CLI コマンドにより， <code>HirakeGoma</code> という名前のついた鍵を生成する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">export</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">KEY_NAME=&quot;HirakeGoma&quot;</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ec2</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">create-key-pair</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--key-name</span><span style="color: #ADBAC7"> ${KEY_NAME} </span><span style="color: #6CB6FF">--query</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;KeyMaterial&#39;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--output</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">text</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">&gt;</span><span style="color: #ADBAC7"> ${KEY_NAME}</span><span style="color: #96D0FF">.pem</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">export</span><span style="color: #24292E"> </span><span style="color: #032F62">KEY_NAME=&quot;HirakeGoma&quot;</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">aws</span><span style="color: #24292E"> </span><span style="color: #032F62">ec2</span><span style="color: #24292E"> </span><span style="color: #032F62">create-key-pair</span><span style="color: #24292E"> </span><span style="color: #005CC5">--key-name</span><span style="color: #24292E"> ${KEY_NAME} </span><span style="color: #005CC5">--query</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;KeyMaterial&#39;</span><span style="color: #24292E"> </span><span style="color: #005CC5">--output</span><span style="color: #24292E"> </span><span style="color: #032F62">text</span><span style="color: #24292E"> </span><span style="color: #D73A49">&gt;</span><span style="color: #24292E"> ${KEY_NAME}</span><span style="color: #032F62">.pem</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>このコマンドを実行すると，現在のディレクトリに <code>HirakeGoma.pem</code> というファイルが作成される．これが，サーバーにアクセスするための秘密鍵である． SSH でこの鍵を使うため， <code>~/.ssh/</code> のディレクトリに鍵を移動する． さらに，秘密鍵が書き換えられたり第三者に閲覧されないよう，ファイルのアクセス権限を <code>400</code> に設定する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">mv</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">HirakeGoma.pem</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">~/.ssh/</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">chmod</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">400</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">~/.ssh/HirakeGoma.pem</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">mv</span><span style="color: #24292E"> </span><span style="color: #032F62">HirakeGoma.pem</span><span style="color: #24292E"> </span><span style="color: #032F62">~/.ssh/</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">chmod</span><span style="color: #24292E"> </span><span style="color: #005CC5">400</span><span style="color: #24292E"> </span><span style="color: #032F62">~/.ssh/HirakeGoma.pem</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><h3 id="デプロイを実行" tabindex="-1">デプロイを実行 <a class="header-anchor" href="#デプロイを実行" aria-label="Permalink to &quot;デプロイを実行&quot;">&ZeroWidthSpace;</a></h3>
<p>これまでのステップで， EC2 インスタンスをデプロイするための準備が整った！ 早速，次のコマンドによりアプリケーションを AWS にデプロイしよう． <code>-c key_name=&quot;HirakeGoma&quot;</code> というオプションで，先ほど生成した <code>HirakeGoma</code> という名前の鍵を使うよう指定している．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cdk</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">deploy</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-c</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">key_name=&quot;HirakeGoma&quot;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cdk</span><span style="color: #24292E"> </span><span style="color: #032F62">deploy</span><span style="color: #24292E"> </span><span style="color: #005CC5">-c</span><span style="color: #24292E"> </span><span style="color: #032F62">key_name=&quot;HirakeGoma&quot;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>このコマンドを実行すると， VPC， EC2 などが AWS 上に展開される． そして，コマンドの出力の最後に <a href="#handson_01_cdk_output">figure_title</a> のような出力が得られるはずである． <strong>出力の中で <code>InstancePublicIp</code> に続く数字が，起動したインスタンスのパブリック IP アドレスである．</strong> IP アドレスはデプロイごとにランダムなアドレスが割り当てられる．</p>
<p><img src="./assets/handson-01/cdk_output.png" alt="CDKデプロイ実行後の出力"></p>
<h3 id="ssh-でログイン" tabindex="-1">SSH でログイン <a class="header-anchor" href="#ssh-でログイン" aria-label="Permalink to &quot;SSH でログイン&quot;">&ZeroWidthSpace;</a></h3>
<p>早速，SSH 　で接続してみよう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ssh</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-i</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">~/.ssh/HirakeGoma.pem</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ec2-user@</span><span style="color: #F47067">&lt;</span><span style="color: #96D0FF">IP</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">addres</span><span style="color: #ADBAC7">s</span><span style="color: #F47067">&gt;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">ssh</span><span style="color: #24292E"> </span><span style="color: #005CC5">-i</span><span style="color: #24292E"> </span><span style="color: #032F62">~/.ssh/HirakeGoma.pem</span><span style="color: #24292E"> </span><span style="color: #032F62">ec2-user@</span><span style="color: #D73A49">&lt;</span><span style="color: #032F62">IP</span><span style="color: #24292E"> </span><span style="color: #032F62">addres</span><span style="color: #24292E">s</span><span style="color: #D73A49">&gt;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p><code>-i</code> オプションで，先ほど生成した秘密鍵を指定している． EC2 インスタンスにはデフォルトで <code>ec2-user</code> という名前のユーザーが作られているので，それを使用する． 最後に， <code>&lt;IP address&gt;</code> の部分は自身が作成した EC2 インスタンスの IP アドレスで置き換える (<code>12.345.678.9</code> など）．</p>
<p>ログインに成功すると， <a href="#fig_handson_01_ssh_login">figure_title</a> のような画面が表示される． リモートのサーバーにログインしているので，プロンプトが <code>[ec2-user@ip-10-10-1-217 ~]$</code> のようになっていることを確認しよう．</p>
<p><img src="./assets/handson-01/ssh_login.png" alt="SSH で EC2 インスタンスにログイン"></p>
<p><strong>おめでとう！これで，めでたく AWS 上に EC2 仮想サーバーを起動し，リモートからアクセスできるようになった！</strong></p>
<h3 id="起動した-ec2-インスタンスで遊んでみる" tabindex="-1">起動した EC2 インスタンスで遊んでみる <a class="header-anchor" href="#起動した-ec2-インスタンスで遊んでみる" aria-label="Permalink to &quot;起動した EC2 インスタンスで遊んでみる&quot;">&ZeroWidthSpace;</a></h3>
<p>せっかく新しいインスタンスを起動したので，少し遊んでみよう．</p>
<p>ログインした EC2 インスタンスで，次のコマンドを実行してみよう． CPU の情報を取得することができる．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cat</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">/proc/cpuinfo</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F69D50">processor</span><span style="color: #ADBAC7">       </span><span style="color: #96D0FF">:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0</span></span>
<span class="line"><span style="color: #F69D50">vendor_id</span><span style="color: #ADBAC7">       </span><span style="color: #96D0FF">:</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">GenuineIntel</span></span>
<span class="line"><span style="color: #F69D50">cpu</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">family</span><span style="color: #ADBAC7">      </span><span style="color: #96D0FF">:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">6</span></span>
<span class="line"><span style="color: #F69D50">model</span><span style="color: #ADBAC7">           </span><span style="color: #96D0FF">:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">63</span></span>
<span class="line"><span style="color: #F69D50">model</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">name</span><span style="color: #ADBAC7">      </span><span style="color: #96D0FF">:</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">Intel</span><span style="color: #ADBAC7">(</span><span style="color: #F69D50">R</span><span style="color: #ADBAC7">) </span><span style="color: #96D0FF">Xeon</span><span style="color: #ADBAC7">(</span><span style="color: #F69D50">R</span><span style="color: #ADBAC7">) </span><span style="color: #96D0FF">CPU</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">E5-2676</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">v3</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">@</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">2.40</span><span style="color: #96D0FF">GHz</span></span>
<span class="line"><span style="color: #F69D50">stepping</span><span style="color: #ADBAC7">        </span><span style="color: #96D0FF">:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">2</span></span>
<span class="line"><span style="color: #F69D50">microcode</span><span style="color: #ADBAC7">       </span><span style="color: #96D0FF">:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0x43</span></span>
<span class="line"><span style="color: #F69D50">cpu</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">MHz</span><span style="color: #ADBAC7">         </span><span style="color: #96D0FF">:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">2400.096</span></span>
<span class="line"><span style="color: #F69D50">cache</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">size</span><span style="color: #ADBAC7">      </span><span style="color: #96D0FF">:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">30720</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">KB</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cat</span><span style="color: #24292E"> </span><span style="color: #032F62">/proc/cpuinfo</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6F42C1">processor</span><span style="color: #24292E">       </span><span style="color: #032F62">:</span><span style="color: #24292E"> </span><span style="color: #005CC5">0</span></span>
<span class="line"><span style="color: #6F42C1">vendor_id</span><span style="color: #24292E">       </span><span style="color: #032F62">:</span><span style="color: #24292E"> </span><span style="color: #032F62">GenuineIntel</span></span>
<span class="line"><span style="color: #6F42C1">cpu</span><span style="color: #24292E"> </span><span style="color: #032F62">family</span><span style="color: #24292E">      </span><span style="color: #032F62">:</span><span style="color: #24292E"> </span><span style="color: #005CC5">6</span></span>
<span class="line"><span style="color: #6F42C1">model</span><span style="color: #24292E">           </span><span style="color: #032F62">:</span><span style="color: #24292E"> </span><span style="color: #005CC5">63</span></span>
<span class="line"><span style="color: #6F42C1">model</span><span style="color: #24292E"> </span><span style="color: #032F62">name</span><span style="color: #24292E">      </span><span style="color: #032F62">:</span><span style="color: #24292E"> </span><span style="color: #032F62">Intel</span><span style="color: #24292E">(</span><span style="color: #6F42C1">R</span><span style="color: #24292E">) </span><span style="color: #032F62">Xeon</span><span style="color: #24292E">(</span><span style="color: #6F42C1">R</span><span style="color: #24292E">) </span><span style="color: #032F62">CPU</span><span style="color: #24292E"> </span><span style="color: #032F62">E5-2676</span><span style="color: #24292E"> </span><span style="color: #032F62">v3</span><span style="color: #24292E"> </span><span style="color: #032F62">@</span><span style="color: #24292E"> </span><span style="color: #005CC5">2.40</span><span style="color: #032F62">GHz</span></span>
<span class="line"><span style="color: #6F42C1">stepping</span><span style="color: #24292E">        </span><span style="color: #032F62">:</span><span style="color: #24292E"> </span><span style="color: #005CC5">2</span></span>
<span class="line"><span style="color: #6F42C1">microcode</span><span style="color: #24292E">       </span><span style="color: #032F62">:</span><span style="color: #24292E"> </span><span style="color: #005CC5">0x43</span></span>
<span class="line"><span style="color: #6F42C1">cpu</span><span style="color: #24292E"> </span><span style="color: #032F62">MHz</span><span style="color: #24292E">         </span><span style="color: #032F62">:</span><span style="color: #24292E"> </span><span style="color: #005CC5">2400.096</span></span>
<span class="line"><span style="color: #6F42C1">cache</span><span style="color: #24292E"> </span><span style="color: #032F62">size</span><span style="color: #24292E">      </span><span style="color: #032F62">:</span><span style="color: #24292E"> </span><span style="color: #005CC5">30720</span><span style="color: #24292E"> </span><span style="color: #032F62">KB</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br></div></div><p>次に，実行中のプロセスやメモリの消費を見てみよう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7">  </span><span style="color: #96D0FF">top</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-n</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">1</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F69D50">top</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">-</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">09</span><span style="color: #96D0FF">:29:19</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">up</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">43</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">min,</span><span style="color: #ADBAC7">  </span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">user,</span><span style="color: #ADBAC7">  </span><span style="color: #96D0FF">load</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">average:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0.00</span><span style="color: #96D0FF">,</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0.00</span><span style="color: #96D0FF">,</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0.00</span></span>
<span class="line"><span style="color: #F69D50">Tasks:</span><span style="color: #ADBAC7">  </span><span style="color: #6CB6FF">76</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">total,</span><span style="color: #ADBAC7">   </span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">running,</span><span style="color: #ADBAC7">  </span><span style="color: #6CB6FF">51</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">sleeping,</span><span style="color: #ADBAC7">   </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">stopped,</span><span style="color: #ADBAC7">   </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">zombie</span></span>
<span class="line"><span style="color: #F69D50">Cpu(s</span><span style="color: #ADBAC7">):  0.3%us,  0.3%sy,  0.1%ni, 98.9%id,  0.2%wa,  0.0%hi,  0.0%si,  0.2%st</span></span>
<span class="line"><span style="color: #F69D50">Mem:</span><span style="color: #ADBAC7">   </span><span style="color: #6CB6FF">1009140</span><span style="color: #96D0FF">k</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">total,</span><span style="color: #ADBAC7">   </span><span style="color: #6CB6FF">270760</span><span style="color: #96D0FF">k</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">used,</span><span style="color: #ADBAC7">   </span><span style="color: #6CB6FF">738380</span><span style="color: #96D0FF">k</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">free,</span><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">14340</span><span style="color: #96D0FF">k</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">buffers</span></span>
<span class="line"><span style="color: #F69D50">Swap:</span><span style="color: #ADBAC7">        </span><span style="color: #6CB6FF">0</span><span style="color: #96D0FF">k</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">total,</span><span style="color: #ADBAC7">        </span><span style="color: #6CB6FF">0</span><span style="color: #96D0FF">k</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">used,</span><span style="color: #ADBAC7">        </span><span style="color: #6CB6FF">0</span><span style="color: #96D0FF">k</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">free,</span><span style="color: #ADBAC7">   </span><span style="color: #6CB6FF">185856</span><span style="color: #96D0FF">k</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cached</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">  </span><span style="color: #F69D50">PID</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">USER</span><span style="color: #ADBAC7">      </span><span style="color: #96D0FF">PR</span><span style="color: #ADBAC7">  </span><span style="color: #96D0FF">NI</span><span style="color: #ADBAC7">  </span><span style="color: #96D0FF">VIRT</span><span style="color: #ADBAC7">  </span><span style="color: #96D0FF">RES</span><span style="color: #ADBAC7">  </span><span style="color: #96D0FF">SHR</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">S</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">%CPU</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">%MEM</span><span style="color: #ADBAC7">    </span><span style="color: #96D0FF">TIME+</span><span style="color: #ADBAC7">  </span><span style="color: #96D0FF">COMMAND</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">1</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">root</span><span style="color: #ADBAC7">      </span><span style="color: #6CB6FF">20</span><span style="color: #ADBAC7">   </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">19696</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">2596</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">2268</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">S</span><span style="color: #ADBAC7">  </span><span style="color: #6CB6FF">0.0</span><span style="color: #ADBAC7">  </span><span style="color: #6CB6FF">0.3</span><span style="color: #ADBAC7">   </span><span style="color: #6CB6FF">0</span><span style="color: #96D0FF">:01.21</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">init</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">2</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">root</span><span style="color: #ADBAC7">      </span><span style="color: #6CB6FF">20</span><span style="color: #ADBAC7">   </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">     </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">S</span><span style="color: #ADBAC7">  </span><span style="color: #6CB6FF">0.0</span><span style="color: #ADBAC7">  </span><span style="color: #6CB6FF">0.0</span><span style="color: #ADBAC7">   </span><span style="color: #6CB6FF">0</span><span style="color: #96D0FF">:00.00</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">kthreadd</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">3</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">root</span><span style="color: #ADBAC7">      </span><span style="color: #6CB6FF">20</span><span style="color: #ADBAC7">   </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">     </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">I</span><span style="color: #ADBAC7">  </span><span style="color: #6CB6FF">0.0</span><span style="color: #ADBAC7">  </span><span style="color: #6CB6FF">0.0</span><span style="color: #ADBAC7">   </span><span style="color: #6CB6FF">0</span><span style="color: #96D0FF">:00.00</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">kworker/0:0</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E">  </span><span style="color: #032F62">top</span><span style="color: #24292E"> </span><span style="color: #005CC5">-n</span><span style="color: #24292E"> </span><span style="color: #005CC5">1</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6F42C1">top</span><span style="color: #24292E"> </span><span style="color: #032F62">-</span><span style="color: #24292E"> </span><span style="color: #005CC5">09</span><span style="color: #032F62">:29:19</span><span style="color: #24292E"> </span><span style="color: #032F62">up</span><span style="color: #24292E"> </span><span style="color: #005CC5">43</span><span style="color: #24292E"> </span><span style="color: #032F62">min,</span><span style="color: #24292E">  </span><span style="color: #005CC5">1</span><span style="color: #24292E"> </span><span style="color: #032F62">user,</span><span style="color: #24292E">  </span><span style="color: #032F62">load</span><span style="color: #24292E"> </span><span style="color: #032F62">average:</span><span style="color: #24292E"> </span><span style="color: #005CC5">0.00</span><span style="color: #032F62">,</span><span style="color: #24292E"> </span><span style="color: #005CC5">0.00</span><span style="color: #032F62">,</span><span style="color: #24292E"> </span><span style="color: #005CC5">0.00</span></span>
<span class="line"><span style="color: #6F42C1">Tasks:</span><span style="color: #24292E">  </span><span style="color: #005CC5">76</span><span style="color: #24292E"> </span><span style="color: #032F62">total,</span><span style="color: #24292E">   </span><span style="color: #005CC5">1</span><span style="color: #24292E"> </span><span style="color: #032F62">running,</span><span style="color: #24292E">  </span><span style="color: #005CC5">51</span><span style="color: #24292E"> </span><span style="color: #032F62">sleeping,</span><span style="color: #24292E">   </span><span style="color: #005CC5">0</span><span style="color: #24292E"> </span><span style="color: #032F62">stopped,</span><span style="color: #24292E">   </span><span style="color: #005CC5">0</span><span style="color: #24292E"> </span><span style="color: #032F62">zombie</span></span>
<span class="line"><span style="color: #6F42C1">Cpu(s</span><span style="color: #24292E">):  0.3%us,  0.3%sy,  0.1%ni, 98.9%id,  0.2%wa,  0.0%hi,  0.0%si,  0.2%st</span></span>
<span class="line"><span style="color: #6F42C1">Mem:</span><span style="color: #24292E">   </span><span style="color: #005CC5">1009140</span><span style="color: #032F62">k</span><span style="color: #24292E"> </span><span style="color: #032F62">total,</span><span style="color: #24292E">   </span><span style="color: #005CC5">270760</span><span style="color: #032F62">k</span><span style="color: #24292E"> </span><span style="color: #032F62">used,</span><span style="color: #24292E">   </span><span style="color: #005CC5">738380</span><span style="color: #032F62">k</span><span style="color: #24292E"> </span><span style="color: #032F62">free,</span><span style="color: #24292E">    </span><span style="color: #005CC5">14340</span><span style="color: #032F62">k</span><span style="color: #24292E"> </span><span style="color: #032F62">buffers</span></span>
<span class="line"><span style="color: #6F42C1">Swap:</span><span style="color: #24292E">        </span><span style="color: #005CC5">0</span><span style="color: #032F62">k</span><span style="color: #24292E"> </span><span style="color: #032F62">total,</span><span style="color: #24292E">        </span><span style="color: #005CC5">0</span><span style="color: #032F62">k</span><span style="color: #24292E"> </span><span style="color: #032F62">used,</span><span style="color: #24292E">        </span><span style="color: #005CC5">0</span><span style="color: #032F62">k</span><span style="color: #24292E"> </span><span style="color: #032F62">free,</span><span style="color: #24292E">   </span><span style="color: #005CC5">185856</span><span style="color: #032F62">k</span><span style="color: #24292E"> </span><span style="color: #032F62">cached</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">  </span><span style="color: #6F42C1">PID</span><span style="color: #24292E"> </span><span style="color: #032F62">USER</span><span style="color: #24292E">      </span><span style="color: #032F62">PR</span><span style="color: #24292E">  </span><span style="color: #032F62">NI</span><span style="color: #24292E">  </span><span style="color: #032F62">VIRT</span><span style="color: #24292E">  </span><span style="color: #032F62">RES</span><span style="color: #24292E">  </span><span style="color: #032F62">SHR</span><span style="color: #24292E"> </span><span style="color: #032F62">S</span><span style="color: #24292E"> </span><span style="color: #032F62">%CPU</span><span style="color: #24292E"> </span><span style="color: #032F62">%MEM</span><span style="color: #24292E">    </span><span style="color: #032F62">TIME+</span><span style="color: #24292E">  </span><span style="color: #032F62">COMMAND</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #6F42C1">1</span><span style="color: #24292E"> </span><span style="color: #032F62">root</span><span style="color: #24292E">      </span><span style="color: #005CC5">20</span><span style="color: #24292E">   </span><span style="color: #005CC5">0</span><span style="color: #24292E"> </span><span style="color: #005CC5">19696</span><span style="color: #24292E"> </span><span style="color: #005CC5">2596</span><span style="color: #24292E"> </span><span style="color: #005CC5">2268</span><span style="color: #24292E"> </span><span style="color: #032F62">S</span><span style="color: #24292E">  </span><span style="color: #005CC5">0.0</span><span style="color: #24292E">  </span><span style="color: #005CC5">0.3</span><span style="color: #24292E">   </span><span style="color: #005CC5">0</span><span style="color: #032F62">:01.21</span><span style="color: #24292E"> </span><span style="color: #032F62">init</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #6F42C1">2</span><span style="color: #24292E"> </span><span style="color: #032F62">root</span><span style="color: #24292E">      </span><span style="color: #005CC5">20</span><span style="color: #24292E">   </span><span style="color: #005CC5">0</span><span style="color: #24292E">     </span><span style="color: #005CC5">0</span><span style="color: #24292E">    </span><span style="color: #005CC5">0</span><span style="color: #24292E">    </span><span style="color: #005CC5">0</span><span style="color: #24292E"> </span><span style="color: #032F62">S</span><span style="color: #24292E">  </span><span style="color: #005CC5">0.0</span><span style="color: #24292E">  </span><span style="color: #005CC5">0.0</span><span style="color: #24292E">   </span><span style="color: #005CC5">0</span><span style="color: #032F62">:00.00</span><span style="color: #24292E"> </span><span style="color: #032F62">kthreadd</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #6F42C1">3</span><span style="color: #24292E"> </span><span style="color: #032F62">root</span><span style="color: #24292E">      </span><span style="color: #005CC5">20</span><span style="color: #24292E">   </span><span style="color: #005CC5">0</span><span style="color: #24292E">     </span><span style="color: #005CC5">0</span><span style="color: #24292E">    </span><span style="color: #005CC5">0</span><span style="color: #24292E">    </span><span style="color: #005CC5">0</span><span style="color: #24292E"> </span><span style="color: #032F62">I</span><span style="color: #24292E">  </span><span style="color: #005CC5">0.0</span><span style="color: #24292E">  </span><span style="color: #005CC5">0.0</span><span style="color: #24292E">   </span><span style="color: #005CC5">0</span><span style="color: #032F62">:00.00</span><span style="color: #24292E"> </span><span style="color: #032F62">kworker/0:0</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br></div></div><p><code>t2.micro</code> インスタンスなので， 1009140k = 1GB のメモリーがあることがわかる．</p>
<p>今回起動したインスタンスには Python 2 はインストール済みだが， Python 3 は入っていない． Python 3.6 のインストールを行ってみよう． インストールは簡単である．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">sudo</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">yum</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">update</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-y</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">sudo</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">yum</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">install</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-y</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python36</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">sudo</span><span style="color: #24292E"> </span><span style="color: #032F62">yum</span><span style="color: #24292E"> </span><span style="color: #032F62">update</span><span style="color: #24292E"> </span><span style="color: #005CC5">-y</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">sudo</span><span style="color: #24292E"> </span><span style="color: #032F62">yum</span><span style="color: #24292E"> </span><span style="color: #032F62">install</span><span style="color: #24292E"> </span><span style="color: #005CC5">-y</span><span style="color: #24292E"> </span><span style="color: #032F62">python36</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>インストールした Python を起動してみよう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python3</span></span>
<span class="line"><span style="color: #F69D50">Python</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">3.6</span><span style="color: #96D0FF">.10</span><span style="color: #ADBAC7"> (default, </span><span style="color: #96D0FF">Feb</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">10</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">2020</span><span style="color: #96D0FF">,</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">19</span><span style="color: #96D0FF">:55:14</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">[GCC </span><span style="color: #6CB6FF">4.8</span><span style="color: #ADBAC7">.5 </span><span style="color: #6CB6FF">20150623</span><span style="color: #ADBAC7"> (Red Hat </span><span style="color: #6CB6FF">4.8</span><span style="color: #ADBAC7">.5-28)] on linux</span></span>
<span class="line"><span style="color: #F69D50">Type</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;help&quot;,</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;copyright&quot;,</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;credits&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">or</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;license&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">for</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">more</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">information.</span></span>
<span class="line"><span style="color: #ADBAC7">&gt;&gt;&gt;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python3</span></span>
<span class="line"><span style="color: #6F42C1">Python</span><span style="color: #24292E"> </span><span style="color: #005CC5">3.6</span><span style="color: #032F62">.10</span><span style="color: #24292E"> (default, </span><span style="color: #032F62">Feb</span><span style="color: #24292E"> </span><span style="color: #005CC5">10</span><span style="color: #24292E"> </span><span style="color: #005CC5">2020</span><span style="color: #032F62">,</span><span style="color: #24292E"> </span><span style="color: #005CC5">19</span><span style="color: #032F62">:55:14</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">[GCC </span><span style="color: #005CC5">4.8</span><span style="color: #24292E">.5 </span><span style="color: #005CC5">20150623</span><span style="color: #24292E"> (Red Hat </span><span style="color: #005CC5">4.8</span><span style="color: #24292E">.5-28)] on linux</span></span>
<span class="line"><span style="color: #6F42C1">Type</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;help&quot;,</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;copyright&quot;,</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;credits&quot;</span><span style="color: #24292E"> </span><span style="color: #032F62">or</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;license&quot;</span><span style="color: #24292E"> </span><span style="color: #032F62">for</span><span style="color: #24292E"> </span><span style="color: #032F62">more</span><span style="color: #24292E"> </span><span style="color: #032F62">information.</span></span>
<span class="line"><span style="color: #24292E">&gt;&gt;&gt;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br></div></div><p>Python のインタープリタが起動した！ <code>Ctrl + D</code> あるいは <code>exit()</code> と入力することで，インタープリタを閉じることができる．</p>
<p>さて，サーバーでのお遊びはこんなところにしておこう (興味があれば各自いろいろと試してみると良い) ． 次のコマンドでログアウトする．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">exit</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">exit</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><h3 id="aws-コンソールから確認" tabindex="-1">AWS コンソールから確認 <a class="header-anchor" href="#aws-コンソールから確認" aria-label="Permalink to &quot;AWS コンソールから確認&quot;">&ZeroWidthSpace;</a></h3>
<p>これまでは，すべてコマンドラインから EC2 に関連する操作を行ってきた． EC2 インスタンスの状態を確認したり，サーバーをシャットダウンするなどの操作は，AWS コンソールから実行することもできる． 軽くこれを紹介しよう．</p>
<p>まず，ウェブブラウザを開いて AWS コンソールにログインする． ログインしたら， <code>Services</code> から <code>EC2</code> を検索(選択)する． 次に，左のサイドバーの <code>Instances</code> とページをたどる. すると， <a href="#aws_ec2_console">figure_title</a> のような画面が得られるはずである． この画面で，自分のアカウントの管理下にあるインスタンスを確認できる． 同様に，VPC・SG についてもコンソールから確認できる．</p>
<p><img src="./assets/handson-01/ec2_console.png" alt="EC2 コンソール画面"></p>
<p><strong>コンソール右上で，正しいリージョン (今回の場合は ap-northeast-1, Tokyo) が選択されているか，注意する！</strong></p>
<p>前章で CloudFormation について触れたが，今回デプロイしたアプリケーションも，CloudFormation のスタックとして管理されている． <strong>スタック (stack)</strong> とは， AWS リソースの集合のことを指す． 今回の場合は， VPC/EC2/SG などがスタックの中に含まれている． コンソールで <code>CloudFormation</code> のページに行ってみよう (<a href="#aws_cloudformation_console">figure_title</a>)．</p>
<p><img src="./assets/handson-01/cloudformation_console.png" alt="CloudFormation コンソール画面"></p>
<p>&quot;MyFirstEc2&quot; という名前のスタックがあることが確認できる． クリックをして中身を見てみると，EC2, VPC などのリソースがこのスタックに紐付いていることがわかる．</p>
<h3 id="スタックを削除" tabindex="-1">スタックを削除 <a class="header-anchor" href="#スタックを削除" aria-label="Permalink to &quot;スタックを削除&quot;">&ZeroWidthSpace;</a></h3>
<p>これにて，第一回のハンズオンで説明すべき事柄はすべて完了した． 最後に，使わなくなったスタックを削除しよう． スタックの削除には，二つの方法がある．</p>
<p>一つ目の方法は，前節の Cloudformation のコンソール画面で， &quot;Delete&quot; ボタンを押すことである (<a href="#cloudformation_delete">figure_title</a>)． すると，スタックの状態が <code>&quot;DELETE_IN_PROGRESS&quot;</code> に変わり，削除が完了すると CloudFormation のスタックの一覧から消える．</p>
<p><img src="./assets/handson-01/cloudformation_delete.png" alt="CloudFormationコンソール画面から，スタックを削除"></p>
<p>二つ目の方法は，コマンドラインから行う方法である． 先ほど，デプロイを行ったコマンドラインに戻ろう． そうしたら，次のコマンドを実行する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cdk</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">destroy</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cdk</span><span style="color: #24292E"> </span><span style="color: #032F62">destroy</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>このコマンドを実行すると，スタックの削除が始まる． 削除した後は，VPC, EC2 など，すべて跡形もなく消え去っていることを自身で確かめよう． CloudFormation を用いることで関連するすべての AWS リソースを一度に管理・削除することができるので，大変便利である．</p>
<p><strong>スタックの削除は各自で必ず行うこと！</strong> 行わなかった場合， EC2 インスタンスの料金が発生し続けることになる！</p>
<p>また，本ハンズオンのために作成した SSH 鍵ペアも不要なので，削除しておく． まず， EC2 側に登録してある公開鍵を削除する． これも，コンソールおよびコマンドラインの二つの方法で実行できる．</p>
<p>コンソールから実行するには， <code>EC2</code> の画面に行き，左のサイドバーの <code>Key Pairs</code> を選択する． 鍵の一覧が表示されるので， <code>HirakeGoma</code> とある鍵にチェックを入れ，画面右上の <code>Actions</code> から， <code>Delete</code> を実行する (<a href="#delete_ec2_key_pair">figure_title</a>)．</p>
<p><img src="./assets/handson-01/ec2_keypair_console.png" alt="EC2でSSH鍵ペアを削除"></p>
<p>コマンドラインから実行するには，次のコマンドを使う．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ec2</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">delete-key-pair</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--key-name</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;HirakeGoma&quot;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">aws</span><span style="color: #24292E"> </span><span style="color: #032F62">ec2</span><span style="color: #24292E"> </span><span style="color: #032F62">delete-key-pair</span><span style="color: #24292E"> </span><span style="color: #005CC5">--key-name</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;HirakeGoma&quot;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>最後に，ローカルのコンピュータから鍵を削除する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">rm</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-f</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">~/.ssh/HirakeGoma.pem</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">rm</span><span style="color: #24292E"> </span><span style="color: #005CC5">-f</span><span style="color: #24292E"> </span><span style="color: #032F62">~/.ssh/HirakeGoma.pem</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>これで，クラウドの片付けもすべて終了だ．</p>
<p>なお，頻繁に EC2 インスタンスを起動したりする場合は，いちいち SSH 鍵を削除する必要はない．</p>
<h2 id="小括" tabindex="-1">小括 <a class="header-anchor" href="#小括" aria-label="Permalink to &quot;小括&quot;">&ZeroWidthSpace;</a></h2>
<p>ここまでが，本書の第一部の内容である． 盛りだくさんの内容であったが，ついてこれたであろうか？</p>
<p><a href="#chap_cloud_basics">クラウド概論</a> では，クラウドの定義と用語の説明を行ったあと，なぜクラウドを使うのか，という点を議論した． 続いて <a href="#sec_aws_general_introduction">AWS 入門</a> では，クラウドを学ぶ具体的なプラットフォームとして AWS を取り上げ， AWS を使用するにあたり最低限必要な知識と用語の説明を行った． さらに， <a href="#sec_first_ec2">Hands-on #1: 初めての EC2 インスタンスを起動する</a> のハンズオンでは AWS CLI と AWS CDK を使って，自身のプライベートなサーバーを AWS 上に立ち上げる演習を行った．</p>
<p>これらを通じて，いかに簡単に (たった数行のコマンドで！) 仮想サーバーを立ち上げたり，削除したりすることができるか，体験できただろう． 筆者は，<a href="#chap_cloud_basics">クラウド概論</a> でクラウドの最も重要な側面はダイナミックに計算リソースを拡大・縮小できることである，と述べた． この言葉の意味が，ハンズオンを通じてより明らかになっただろうか？ ここで学んだ技術を少し応用するだけで，自分のウェブページをホストする仮想サーバーを作成したり，大量のコアを搭載した EC2 インスタンスを用意して科学計算を実行するなど，いろいろなアプリケーションが実現できる．</p>
<p>次章からは，今回学んだクラウドの技術を基に，より現実に即した問題を解くことを体験してもらう． お楽しみに！</p>
<h1 id="クラウドで行う科学計算・機械学習" tabindex="-1">クラウドで行う科学計算・機械学習 <a class="header-anchor" href="#クラウドで行う科学計算・機械学習" aria-label="Permalink to &quot;クラウドで行う科学計算・機械学習&quot;">&ZeroWidthSpace;</a></h1>
<p>計算機が発達した現代では，計算機によるシミュレーションやビッグデータの解析は，科学・エンジニアリングの研究の主要な柱である． これらの大規模な計算を実行するには，クラウドは最適である． 本章から始まる第二部では，どのようにしてクラウド上で科学計算を実行するのかを，ハンズオンとともに体験してもらう． 科学計算の具体的な題材として，今回は機械学習(深層学習)を取り上げる．</p>
<p>なお，本書では <a href="https://pytorch.org/" target="_blank" rel="noreferrer">PyTorch</a> ライブラリを使って深層学習のアルゴリズムを実装するが，深層学習および PyTorch の知識は不要である． 講義ではなぜ・どうやって深層学習をクラウドで実行するかに主眼を置いているので，実行するプログラムの詳細には立ち入らない． 将来，自分で深層学習を使う機会が来たときに，詳しく学んでもらいたい．</p>
<h2 id="なぜ機械学習をクラウドで行うのか" tabindex="-1">なぜ機械学習をクラウドで行うのか？ <a class="header-anchor" href="#なぜ機械学習をクラウドで行うのか" aria-label="Permalink to &quot;なぜ機械学習をクラウドで行うのか？&quot;">&ZeroWidthSpace;</a></h2>
<p>2010 年頃に始まった第三次 AI ブームのおかげで，学術研究だけでなく社会・ビジネスの文脈でも機械学習に高い関心が寄せられている． とくに，<strong>深層学習 (ディープラーニング)</strong> とよばれる多層のレイヤーからなるニューラルネットワークを用いたアルゴリズムは，画像認識や自然言語処理などの分野で圧倒的に高い性能を実現し，革命をもたらしている．</p>
<p>深層学習の特徴は，なんといってもそのパラメータの多さである． 層が深くなるほど，層間のニューロンを結ぶ重みパラメータの数が増大していく． たとえば，最新の言語モデルである <a href="https://arxiv.org/abs/2005.14165" target="_blank" rel="noreferrer">GPT-3</a> には<strong>1750 億個</strong>ものパラメータが含まれている． このような膨大なパラメータを有することで，深層学習は高い表現力と汎化性能を実現しているのである．</p>
<p>GPT-3 に限らず，最近の SOTA (State-of-the-art) の性能を達成するニューラルネットワークでは，百万から億のオーダーのパラメータを内包することは頻繁になってきている． そのような巨大なニューラルネットを訓練 (最適化) させるのは，当然のことながら膨大な計算コストがかかる． 結果として，ひとつの計算機では丸一日以上の時間がかかる場合も珍しくない． 深層学習の発展の速度は目覚ましく，研究・ビジネス両方の観点からも，いかにスループットよくニューラルネットワークの最適化を行えるかが鍵となってくる． そのような問題を解決するのにとても有効な手段が，クラウドである！ <a href="#sec_first_ec2">Hands-on #1: 初めての EC2 インスタンスを起動する</a> でその片鱗を見たように，クラウドを使用することでゼロから数千に至るまでの数のインスタンスを動的に起動し，並列に計算を実行することができる． さらに，深層学習を加速させる目的で，深層学習の演算に専用設計された計算チップ (GPU など) がある． クラウドを利用すると，そのような専用計算チップも無尽蔵に利用することができる． 事実，先述した GPT-3 の学習も，詳細は明かされていないが，Microsoft 社のクラウドを使って行われたと報告されている．</p>
<h2 id="gpu-による深層学習の高速化" tabindex="-1">GPU による深層学習の高速化 <a class="header-anchor" href="#gpu-による深層学習の高速化" aria-label="Permalink to &quot;GPU による深層学習の高速化&quot;">&ZeroWidthSpace;</a></h2>
<p>深層学習の計算で欠かすことのできない技術として， <strong>GPU (Graphics Processing Unit)</strong> について少し説明する．</p>
<p>GPU は，その名のとおり，元々はコンピュータグラフィックスを出力するための専用計算チップである． CPU (Central Processing Unit) に対し，グラフィックスの演算に特化した設計がなされている． 身近なところでは， XBox や PS5 などのゲームコンソールなどに搭載されているし，ハイエンドなノート型・デスクトップ型計算機にも搭載されていることがある． コンピュータグラフィックスでは，スクリーンにアレイ状に並んだ数百万個の画素をビデオレート (30 fps) 以上で処理する必要がある． そのため，GPU はコアあたりの演算能力は比較的小さいかわりに，チップあたり数百から数千のコアを搭載しており (<a href="#gpu_architecture">figure_title</a>)，スクリーンの画素を並列的に処理することで，リアルタイムでの描画を実現している．</p>
<p><img src="./assets/gpu_architecture.jpg" alt="GPUのアーキテクチャ．GPUには数百から数千の独立した計算コアが搭載されている． (画像出典: https://devblogs.nvidia.com/nvidia-turing-architecture-in-depth/)"></p>
<p>このように，コンピュータグラフィクスの目的で生まれた GPU だが，2010 年前後から，その高い並列計算能力をグラフィックス以外の計算 (科学計算など) に用いるという流れ (<strong>General-purpose computing on GPU; GPGPU</strong>) が生まれた． GPU のコアは，その設計から，行列の計算など，単純かつ規則的な演算が得意であり，そのような演算に対しては数個程度のコアしかもたない CPU に比べて圧倒的に高い計算速度を実現することができる． 現在では GPGPU は分子動力学や気象シミュレーション，そして機械学習など多くの分野で使われている．</p>
<p>ディープラーニングで最も頻繁に起こる演算が，ニューロンの出力を次の層のニューロンに伝える<strong>畳み込み (Convolution)</strong> 演算である (<a href="#fig:convolution">figure_title</a>)． 畳み込み演算は，まさに GPU が得意とする演算であり， CPU ではなく GPU を用いることで学習を飛躍的に (最大で数百倍程度) 加速させることができる．</p>
<p><img src="./assets/cnn.png" alt="ニューラルネットワークにおける畳み込み演算．"></p>
<p>このように GPU は機械学習の計算で欠かせないものであるが，なかなか高価である． たとえば，科学計算・機械学習に専用設計された NVIDIA 社の Tesla V100 というチップは，一台で約百万円の価格が設定されている． 機械学習を始めるのに，いきなり百万円の投資はなかなか大きい． だが，クラウドを使えば，初期コスト０で GPU を使用することができる．</p>
<p>機械学習を行うのに， V100 が必ずしも必要というわけではない． むしろ，研究者などでしばしば行われるのは，コンピュータゲームに使われるグラフィックス用の GPU を買ってきて (NVIDIA GeForce シリーズなど)，開発のときはをそれを用いる，というアプローチである． グラフィックス用のいわゆる&quot;コンシューマ GPU&quot;は，市場の需要が大きいおかげで，10 万円前後の価格で購入することができる． V100 と比べると，コンシューマ GPU はコアの数が少なかったり，メモリーが小さかったりなどで劣る点があるが， それらを除いては計算能力にとくに制限があるわけではなく，開発の段階では十分な性能である場合がほとんどである． プログラムができあがって，ビッグデータの解析や，モデルをさらに大きくしたいときなどに，クラウドは有効だろう．</p>
<p>クラウドで GPU を使うには， GPU が搭載された EC2 インスタンスタイプ (<code>P3</code>, <code>P2</code>, <code>G3</code>, <code>G4</code> など) を選択しなければならない． <a href="#table_gpu_instances">table_title</a> に，代表的な GPU 搭載のインスタンスタイプを挙げる (執筆時点での情報)．</p>
<table style="width:100%;"><caption>GPUを搭載したEC2インスタンスタイプ</caption><colgroup><col style="width: 14%" /><col style="width: 14%" /><col style="width: 14%" /><col style="width: 14%" /><col style="width: 14%" /><col style="width: 14%" /><col style="width: 14%" /></colgroup><thead><tr class="header"><th>Instance</th><th>GPUs</th><th>GPU model</th><th>GPU Mem (GiB)</th><th>vCPU</th><th>Mem (GiB)</th><th>Price per hour ($)</th></tr></thead><tbody><tr class="odd"><td><p>p3.2xlarge</p></td><td><p>1</p></td><td><p>NVIDIA V100</p></td><td><p>16</p></td><td><p>8</p></td><td><p>61</p></td><td><p>3.06</p></td></tr><tr class="even"><td><p>p3n.16xlarge</p></td><td><p>8</p></td><td><p>NVIDIA V100</p></td><td><p>128</p></td><td><p>64</p></td><td><p>488</p></td><td><p>24.48</p></td></tr><tr class="odd"><td><p>p2.xlarge</p></td><td><p>1</p></td><td><p>NVIDIA K80</p></td><td><p>12</p></td><td><p>4</p></td><td><p>61</p></td><td><p>0.9</p></td></tr><tr class="even"><td><p>g4dn.xlarge</p></td><td><p>1</p></td><td><p>NVIDIA T4</p></td><td><p>16</p></td><td><p>4</p></td><td><p>16</p></td><td><p>0.526</p></td></tr></tbody></table>
<p><a href="#table_gpu_instances">table_title</a> からわかるとおり， CPU のみのインスタンスと比べると少し高い価格設定になっている． また，古い世代の GPU (V100 に対しての K80) はより安価な価格で提供されている． 1 インスタンスあたりの GPU の搭載数は 1 台から最大で 8 台まで選択することが可能である．</p>
<p>GPU を搭載した一番安いインスタンスタイプは， <code>g4dn.xlarge</code> であり，これには廉価かつ省エネルギー設計の NVIDIA T4 が搭載されている． 後のハンズオンでは，このインスタンスを使用して，ディープラーニングの計算を行ってみる．</p>
<p><a href="#table_gpu_instances">table_title</a> の価格は <code>us-east-1</code> のものである． リージョンによって多少価格設定が異なる．</p>
<p>V100 を一台搭載した <code>p3.2xlarge</code> の利用料金は一時間あたり $3.06 である． V100 が約百万円で売られていることを考えると，約 3000 時間 (= 124 日間)，通算で計算を行った場合に，クラウドを使うよりも V100 を自分で買ったほうがお得になる，という計算になる (実際には，自前で V100 を用意する場合は， V100 だけでなく， CPU やネットワーク機器，電気使用料も必要なので，百万円よりもさらにコストがかかる)．</p>
<p>GPT-3 で使われた計算リソースの詳細は論文でも明かされていないのだが， <a href="https://lambdalabs.com/blog/demystifying-gpt-3/" target="_blank" rel="noreferrer">Lambda 社のブログ</a>で興味深い考察が行われている (Lambda 社は機械学習に特化したクラウドサービスを提供している)．</p>
<p>記事によると，1750 億のパラメータを訓練するには，一台の GPU (NVIDIA V100) を用いた場合，342 年の月日と 460 万ドルのクラウド利用料が必要となる，とのことである． GPT-3 のチームは，複数の GPU に処理を分散することで現実的な時間のうちに訓練を完了させたのであろうが，このレベルのモデルになってくるとクラウド技術の限界を攻めないと達成できないことは確かである．</p>
<p>深層学習を詳しく勉強したい人には以下の参考書を推薦したい． 深層学習の基礎的な概念や理論は普遍的であるが，この分野は日進月歩なので，常に最新の情報を取り入れることを忘れずに．</p>
<ul>
<li>
<p><a href="https://www.deeplearningbook.org/" target="_blank" rel="noreferrer">Deep Learning (Ian Goodfellow, Yoshua Bengio and Aaron Courville)</a> 出版されてから数年が経つが，深層学習の理論的な側面を学びたいならばおすすめの入門書． ウェブで無料で読むことができる． 日本語版も出版されている． 実装についてはほとんど触れられていないので，理論家向けの本．</p>
</li>
<li>
<p><a href="https://www.oreilly.co.jp/books/9784873117584/" target="_blank" rel="noreferrer">ゼロから作る Deep Learning (斎藤 康毅)</a> 合計三冊からなるシリーズ． 理論と実装がバランスよく説明されていて，深層学習の入門書の決定版．</p>
</li>
<li>
<p><a href="https://d2l.ai/" target="_blank" rel="noreferrer">Dive into Deep Learning (Aston Zhang, Zachary C. Lipton, Mu Li, and Alexander J. Smola)</a> 深層学習の基礎から最新のアルゴリズムまでを，実装を通して学んでいくスタイルの本． ウェブで無料で読むことができる，1000 ページ越えの超大作． これを読破することができれば，深層学習の実装で困ることはないだろう．</p>
</li>
</ul>
<h1 id="hands-on-2-aws-でディープラーニングを実践" tabindex="-1">Hands-on #2: AWS でディープラーニングを実践 <a class="header-anchor" href="#hands-on-2-aws-でディープラーニングを実践" aria-label="Permalink to &quot;Hands-on \#2: AWS でディープラーニングを実践&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="準備-1" tabindex="-1">準備 <a class="header-anchor" href="#準備-1" aria-label="Permalink to &quot;準備&quot;">&ZeroWidthSpace;</a></h2>
<p>ハンズオン第二回では， GPU を搭載した EC2 インスタンスを起動し，深層学習モデルの学習と推論を実行する演習を行う．</p>
<p>ハンズオンのソースコードは GitHub の <a href="https://github.com/andatoshiki/toshiki-notebooktree/main/handson/mnist" target="_blank" rel="noreferrer">handson/mnist</a> に置いてある．</p>
<p>本ハンズオンの実行には，第一回ハンズオンで説明した準備 (<a href="#handson_01_prep">準備</a>) が整っていることを前提とする． それ以外に必要な準備はない．</p>
<p>初期状態の AWS アカウントでは， GPU 搭載の G タイプのインスタンスの起動上限が 0 になっていることがある． これを確認するには， AWS コンソールから EC2 の画面を開き，左のメニューから <code>Limits</code> を選択する． その中の <code>Running On-Demand All G instances</code> という数字が G インスタンスの起動上限を表している．</p>
<p>もし，これが 0 になっていた場合は， AWS の自動申請フォームから上限緩和のリクエストを送る必要がある． 詳しくは <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-resource-limits.html" target="_blank" rel="noreferrer">公式ドキュメンテーション &quot;Amazon EC2 service quotas&quot;</a> を参照のこと．</p>
<p>このハンズオンは， <code>g4dn.xlarge</code> タイプの EC2 インスタンスを使うので，東京 (<code>ap-northeast-1</code>) リージョンでは 0.71 $/hour のコストが発生する．</p>
<p>AWS Educate Starter Account を使用している読者へ: 執筆時点においては， Starter Account には GPU 搭載型インスタンスを起動できないという制限が設けられている． したがって， Starter Account のユーザーはこのハンズオンを実行することはできない． 興味のある読者は，制限のない一般アカウントを自分自身で取得する必要があることに注意．</p>
<h2 id="アプリケーションの説明-1" tabindex="-1">アプリケーションの説明 <a class="header-anchor" href="#アプリケーションの説明-1" aria-label="Permalink to &quot;アプリケーションの説明&quot;">&ZeroWidthSpace;</a></h2>
<p>このハンズオンで作成するアプリケーションの概要を <a href="#handson_02_architecture">figure_title</a> に示す．</p>
<p><img src="./assets/handson-jupyter/handson-02-architecture.png" alt="ハンズオン#2で作製するアプリケーションのアーキテクチャ"></p>
<p>図の多くの部分が，第一回ハンズオンで作成したアプリケーションと共通していることに気がつくだろう． 少しの変更で，簡単にディープラーニングを走らせる環境を構築することができるのである！主な変更点は次の３点である．</p>
<ul>
<li>
<p>GPU を搭載した <code>g4dn.xlarge</code> インスタンスタイプを使用</p>
</li>
<li>
<p>ディープラーニングに使うプログラムがあらかじめインストールされた DLAMI (後述) を使用</p>
</li>
<li>
<p>SSH にポートフォワーディングのオプションつけてサーバーに接続し，サーバーで起動している Jupyter Notebook (後述) を使ってプログラムを書いたり実行したりする</p>
</li>
</ul>
<p>ハンズオンで使用するプログラムのコードをみてみよう <a href="https://github.com/andatoshiki/toshiki-notebooktree/main/handson/mnist/app.py" target="_blank" rel="noreferrer">handson/mnist/app.py</a>)． コードは第一回目とほとんど共通である．変更点のみ解説を行う．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">class</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50">Ec2ForDl</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">core</span><span style="color: #ADBAC7">.</span><span style="color: #6CB6FF">Stack</span><span style="color: #ADBAC7">):</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">def</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">__init__</span><span style="color: #ADBAC7">(self, scope: core.App, name: </span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">, key_name: </span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">, </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">kwargs) -&gt; </span><span style="color: #6CB6FF">None</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #6CB6FF">super</span><span style="color: #ADBAC7">().</span><span style="color: #6CB6FF">__init__</span><span style="color: #ADBAC7">(scope, name, </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">kwargs)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        vpc </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ec2.Vpc(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;Ec2ForDl-Vpc&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">max_azs</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">cidr</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;10.10.0.0/23&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">subnet_configuration</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">[</span></span>
<span class="line"><span style="color: #ADBAC7">                ec2.SubnetConfiguration(</span></span>
<span class="line"><span style="color: #ADBAC7">                    </span><span style="color: #F69D50">name</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;public&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                    </span><span style="color: #F69D50">subnet_type</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.SubnetType.</span><span style="color: #6CB6FF">PUBLIC</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                )</span></span>
<span class="line"><span style="color: #ADBAC7">            ],</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">nat_gateways</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        sg </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ec2.SecurityGroup(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;Ec2ForDl-Sg&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">vpc</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">vpc,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">allow_all_outbound</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">True</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"><span style="color: #ADBAC7">        sg.add_ingress_rule(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">peer</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.Peer.any_ipv4(),</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">connection</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.Port.tcp(</span><span style="color: #6CB6FF">22</span><span style="color: #ADBAC7">),</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        host </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ec2.Instance(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;Ec2ForDl-Instance&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">instance_type</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.InstanceType(</span><span style="color: #96D0FF">&quot;g4dn.xlarge&quot;</span><span style="color: #ADBAC7">), </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">machine_image</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.MachineImage.generic_linux({</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #96D0FF">&quot;us-east-1&quot;</span><span style="color: #ADBAC7">: </span><span style="color: #96D0FF">&quot;ami-060f07284bb6f9faf&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #96D0FF">&quot;ap-northeast-1&quot;</span><span style="color: #ADBAC7">: </span><span style="color: #96D0FF">&quot;ami-09c0c16fc46a29ed9&quot;</span></span>
<span class="line"><span style="color: #ADBAC7">            }), </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">vpc</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">vpc,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">vpc_subnets</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.SubnetSelection(</span><span style="color: #F69D50">subnet_type</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ec2.SubnetType.</span><span style="color: #6CB6FF">PUBLIC</span><span style="color: #ADBAC7">),</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">security_group</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">sg,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">key_name</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">key_name</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">class</span><span style="color: #24292E"> </span><span style="color: #6F42C1">Ec2ForDl</span><span style="color: #24292E">(</span><span style="color: #6F42C1">core</span><span style="color: #24292E">.</span><span style="color: #6F42C1">Stack</span><span style="color: #24292E">):</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">def</span><span style="color: #24292E"> </span><span style="color: #005CC5">__init__</span><span style="color: #24292E">(self, scope: core.App, name: </span><span style="color: #005CC5">str</span><span style="color: #24292E">, key_name: </span><span style="color: #005CC5">str</span><span style="color: #24292E">, </span><span style="color: #D73A49">**</span><span style="color: #24292E">kwargs) -&gt; </span><span style="color: #005CC5">None</span><span style="color: #24292E">:</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #005CC5">super</span><span style="color: #24292E">().</span><span style="color: #005CC5">__init__</span><span style="color: #24292E">(scope, name, </span><span style="color: #D73A49">**</span><span style="color: #24292E">kwargs)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        vpc </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ec2.Vpc(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;Ec2ForDl-Vpc&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">max_azs</span><span style="color: #D73A49">=</span><span style="color: #005CC5">1</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">cidr</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;10.10.0.0/23&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">subnet_configuration</span><span style="color: #D73A49">=</span><span style="color: #24292E">[</span></span>
<span class="line"><span style="color: #24292E">                ec2.SubnetConfiguration(</span></span>
<span class="line"><span style="color: #24292E">                    </span><span style="color: #E36209">name</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;public&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                    </span><span style="color: #E36209">subnet_type</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.SubnetType.</span><span style="color: #005CC5">PUBLIC</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                )</span></span>
<span class="line"><span style="color: #24292E">            ],</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">nat_gateways</span><span style="color: #D73A49">=</span><span style="color: #005CC5">0</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        sg </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ec2.SecurityGroup(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;Ec2ForDl-Sg&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">vpc</span><span style="color: #D73A49">=</span><span style="color: #24292E">vpc,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">allow_all_outbound</span><span style="color: #D73A49">=</span><span style="color: #005CC5">True</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"><span style="color: #24292E">        sg.add_ingress_rule(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">peer</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.Peer.any_ipv4(),</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">connection</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.Port.tcp(</span><span style="color: #005CC5">22</span><span style="color: #24292E">),</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        host </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ec2.Instance(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;Ec2ForDl-Instance&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">instance_type</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.InstanceType(</span><span style="color: #032F62">&quot;g4dn.xlarge&quot;</span><span style="color: #24292E">), </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">machine_image</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.MachineImage.generic_linux({</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #032F62">&quot;us-east-1&quot;</span><span style="color: #24292E">: </span><span style="color: #032F62">&quot;ami-060f07284bb6f9faf&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #032F62">&quot;ap-northeast-1&quot;</span><span style="color: #24292E">: </span><span style="color: #032F62">&quot;ami-09c0c16fc46a29ed9&quot;</span></span>
<span class="line"><span style="color: #24292E">            }), </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">vpc</span><span style="color: #D73A49">=</span><span style="color: #24292E">vpc,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">vpc_subnets</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.SubnetSelection(</span><span style="color: #E36209">subnet_type</span><span style="color: #D73A49">=</span><span style="color: #24292E">ec2.SubnetType.</span><span style="color: #005CC5">PUBLIC</span><span style="color: #24292E">),</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">security_group</span><span style="color: #D73A49">=</span><span style="color: #24292E">sg,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">key_name</span><span style="color: #D73A49">=</span><span style="color: #24292E">key_name</span></span>
<span class="line"><span style="color: #24292E">        )</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br><span class="line-number">36</span><br><span class="line-number">37</span><br><span class="line-number">38</span><br><span class="line-number">39</span><br><span class="line-number">40</span><br></div></div><ul>
<li>
<p>ここで， <code>g4dn.xlarge</code> インスタンスタイプを選択している (第一回では， CPU のみの <code>t2.micro</code> だった)． <code>g4dn.xlarge</code> のインスタンスタイプは， <a href="#sec_scientific_computing">クラウドで行う科学計算・機械学習</a> ですでに触れた通り， <code>NVIDIA T4</code> と呼ばれる廉価版モデルの GPU を搭載したインスタンスである． CPU は 4 core, メインメモリーは 16GB が割り当てあられている．</p>
</li>
<li>
<p>ここでは，Deep Learning 用の諸々のソフトウェアがプリンストールされた AMI (<a href="https://docs.aws.amazon.com/dlami/latest/devguide/what-is-dlami.html" target="_blank" rel="noreferrer">Deep Learning Amazon Machine Image; DLAMI</a>) を選択している (第一回では，Amazon Linux という AMI を使用していた)． 使用する AMI の ID は リージョンごとに指定する必要があり，ここでは <code>us-east-1</code> と <code>ap-northeast-1</code> でそれぞれ定義している．</p>
</li>
</ul>
<p>DLAMI という新しい概念が出てきたので，説明しよう．</p>
<p>AMI が <code>us-east-1</code> と <code>ap-northeast-1</code> でしか定義されていないので，提供されているコードはこの二つのリージョンのみでデプロイ可能である． もしほかのリージョンを利用したい場合は， AMI の ID を自身で検索し，コードに書き込む必要がある．</p>
<h3 id="dlami-deep-learning-amazon-machine-image" tabindex="-1">DLAMI (Deep Learning Amazon Machine Image) <a class="header-anchor" href="#dlami-deep-learning-amazon-machine-image" aria-label="Permalink to &quot;DLAMI (Deep Learning Amazon Machine Image)&quot;">&ZeroWidthSpace;</a></h3>
<p><strong>AMI (Amazon Machine Image)</strong> とは，大まかには OS (Operating System) に相当する概念である． 当然のことながら， OS がなければコンピュータはなにもできないので，EC2 インスタンスを起動するときには必ずなにかの OS を&quot;インストール&quot;する必要がある． EC2 が起動したときにロードされる OS に相当するものが， AMI である． AMI には，たとえば <a href="https://ubuntu.com/" target="_blank" rel="noreferrer">Ubuntu</a> などの Linux 系 OS に加えて，Windows Server を選択することもできる． また， EC2 での使用に最適化された <a href="https://aws.amazon.com/amazon-linux-ami/" target="_blank" rel="noreferrer">Amazon Linux</a> という AMI も提供されている．</p>
<p>しかしながら， AMI を単なる OS と理解するのは過剰な単純化である． AMI には，ベースとなる (空っぽの) OS を選択することもできるが，それに加えて，各種のプログラムがインストール済みの AMI も定義することができる． 必要なプログラムがインストールされている AMI を見つけることができれば，自身でインストールを行ったり環境設定したりする手間が大幅に省ける． 具体例を挙げると，ハンズオン第一回では EC2 インスタンスに Python 3.6 をインストールする例を示したが，そのような操作をインスタンスが起動するたびに行うのは手間である！</p>
<p>AMI は， AWS 公式のものに加えて，サードパーティから提供されているものもある． また，自分自身の AMI を作って登録することも可能である (<a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/creating-an-ami-instance-store.html" target="_blank" rel="noreferrer">参考</a>)． AMI は EC2 のコンソールから検索することが可能である． あるいは，AWS CLI を使って，次のコマンドでリストを取得することができる (<a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/finding-an-ami.html" target="_blank" rel="noreferrer">参考</a>)．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ec2</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">describe-images</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--owners</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">amazon</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">aws</span><span style="color: #24292E"> </span><span style="color: #032F62">ec2</span><span style="color: #24292E"> </span><span style="color: #032F62">describe-images</span><span style="color: #24292E"> </span><span style="color: #005CC5">--owners</span><span style="color: #24292E"> </span><span style="color: #032F62">amazon</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>ディープラーニングで頻繁に使われるプログラムがあらかじめインストールしてある AMI が， <a href="https://docs.aws.amazon.com/dlami/latest/devguide/what-is-dlami.html" target="_blank" rel="noreferrer">DLAMI (Deep Learning AMI)</a> である． DLAMI には <code>TensorFlow</code>, <code>PyTorch</code> などの人気の高いディープラーニングのフレームワーク・ライブラリがすでにインストールされているため， EC2 インスタンスを起動してすぐさまディープラーニングの計算を実行できる．</p>
<p>本ハンズオンでは， Amazon Linux 2 をベースにした DLAMI を使用する (AMI ID = ami-09c0c16fc46a29ed9．この AMI は ap-northeast-1 でしか使用できない点に注意)． AWS CLI を使って，この AMI の詳細情報を取得してみよう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ec2</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">describe-images</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--owners</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">amazon</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--image-ids</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;ami-09c0c16fc46a29ed9&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--region</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ap-northeast-1</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">aws</span><span style="color: #24292E"> </span><span style="color: #032F62">ec2</span><span style="color: #24292E"> </span><span style="color: #032F62">describe-images</span><span style="color: #24292E"> </span><span style="color: #005CC5">--owners</span><span style="color: #24292E"> </span><span style="color: #032F62">amazon</span><span style="color: #24292E"> </span><span style="color: #005CC5">--image-ids</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;ami-09c0c16fc46a29ed9&quot;</span><span style="color: #24292E"> </span><span style="color: #005CC5">--region</span><span style="color: #24292E"> </span><span style="color: #032F62">ap-northeast-1</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p><img src="./assets/handson-jupyter/ami-info.png" alt="AMI ID = ami-09c0c16fc46a29ed9 の詳細情報"></p>
<p><a href="#handson_02_ami-info">figure_title</a> のような出力が得られるはずである．得られた出力から，この DLAMI には PyTorch のバージョン 1.4.0 と 1.5.0 がインストールされていることがわかる． この DLAMI を使って，早速ディープラーニングの計算を実行してみよう．</p>
<p>DLAMI には具体的には何がインストールされているのだろうか？ 興味のある読者のために，簡単な解説をしよう (参考: <a href="https://docs.aws.amazon.com/dlami/latest/devguide/what-is-dlami.html" target="_blank" rel="noreferrer">公式ドキュメンテーション &quot;What Is the AWS Deep Learning AMI?&quot;</a>)．</p>
<p>最も low-level なレイヤーとしては， GPU ドライバー がインストールされている． GPU ドライバーなしには OS は GPU とコマンドのやり取りをすることができない． 次のレイヤーが <a href="https://developer.nvidia.com/about-cuda" target="_blank" rel="noreferrer">CUDA</a> と <a href="https://developer.nvidia.com/cudnn" target="_blank" rel="noreferrer">cuDNN</a> である． CUDA は， NVIDIA 社が開発した， GPU 上で汎用コンピューティングを行うための言語であり， C++ 言語を拡張したシンタックスを備える． cuDNN は CUDA で書かれたディープラーニングのライブラリであり，n 次元の畳み込みなどの演算が実装されている． ここまでが， &quot;Base&quot; とよばれるタイプの DLAMI の中身である．</p>
<p>これに加えて， &quot;Conda&quot; とよばれるタイプには， &quot;Base&quot; のプログラム基盤の上に， <code>TensorFlow</code> や <code>PyTorch</code> などのライブラリがインストールされている． さらに， <a href="https://docs.conda.io/projects/conda/en/latest/index.html" target="_blank" rel="noreferrer">Anaconda</a> による仮想環境を使うことによって， <code>TensorFlow</code> の環境・ <code>PyTorch</code> の環境・ <code>MxNet</code> の環境など，フレームワークを簡単に切り替えることができる (これについては，後のハンズオンで触れる)． また， Jupyter Notebook もインストール済みである．</p>
<h2 id="スタックのデプロイ" tabindex="-1">スタックのデプロイ <a class="header-anchor" href="#スタックのデプロイ" aria-label="Permalink to &quot;スタックのデプロイ&quot;">&ZeroWidthSpace;</a></h2>
<p>スタックの中身が理解できたところで，早速スタックをデプロイしてみよう．</p>
<p>デプロイの手順は，ハンズオン 1 とほとんど共通である． ここでは，コマンドのみ列挙する (<code>#</code> で始まる行はコメントである)． それぞれのコマンドの意味を忘れてしまった場合は，ハンズオン 1 に戻って復習していただきたい． シークレットキーの設定も忘れずに (<a href="#aws_cli_install">AWS CLI のインストール</a>)．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390"># プロジェクトのディレクトリに移動</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cd</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">handson/mnist</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># venv を作成し，依存ライブラリのインストールを行う</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python3</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-m</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">venv</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.env</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">source</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.env/bin/activate</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">pip</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">install</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-r</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">requirements.txt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># SSH鍵を生成</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">export</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">KEY_NAME=&quot;HirakeGoma&quot;</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ec2</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">create-key-pair</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--key-name</span><span style="color: #ADBAC7"> ${KEY_NAME} </span><span style="color: #6CB6FF">--query</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;KeyMaterial&#39;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--output</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">text</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">&gt;</span><span style="color: #ADBAC7"> ${KEY_NAME}</span><span style="color: #96D0FF">.pem</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">mv</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">HirakeGoma.pem</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">~/.ssh/</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">chmod</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">400</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">~/.ssh/HirakeGoma.pem</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># デプロイを実行</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cdk</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">deploy</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-c</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">key_name=&quot;HirakeGoma&quot;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D"># プロジェクトのディレクトリに移動</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cd</span><span style="color: #24292E"> </span><span style="color: #032F62">handson/mnist</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># venv を作成し，依存ライブラリのインストールを行う</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python3</span><span style="color: #24292E"> </span><span style="color: #005CC5">-m</span><span style="color: #24292E"> </span><span style="color: #032F62">venv</span><span style="color: #24292E"> </span><span style="color: #032F62">.env</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">source</span><span style="color: #24292E"> </span><span style="color: #032F62">.env/bin/activate</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">pip</span><span style="color: #24292E"> </span><span style="color: #032F62">install</span><span style="color: #24292E"> </span><span style="color: #005CC5">-r</span><span style="color: #24292E"> </span><span style="color: #032F62">requirements.txt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># SSH鍵を生成</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">export</span><span style="color: #24292E"> </span><span style="color: #032F62">KEY_NAME=&quot;HirakeGoma&quot;</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">aws</span><span style="color: #24292E"> </span><span style="color: #032F62">ec2</span><span style="color: #24292E"> </span><span style="color: #032F62">create-key-pair</span><span style="color: #24292E"> </span><span style="color: #005CC5">--key-name</span><span style="color: #24292E"> ${KEY_NAME} </span><span style="color: #005CC5">--query</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;KeyMaterial&#39;</span><span style="color: #24292E"> </span><span style="color: #005CC5">--output</span><span style="color: #24292E"> </span><span style="color: #032F62">text</span><span style="color: #24292E"> </span><span style="color: #D73A49">&gt;</span><span style="color: #24292E"> ${KEY_NAME}</span><span style="color: #032F62">.pem</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">mv</span><span style="color: #24292E"> </span><span style="color: #032F62">HirakeGoma.pem</span><span style="color: #24292E"> </span><span style="color: #032F62">~/.ssh/</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">chmod</span><span style="color: #24292E"> </span><span style="color: #005CC5">400</span><span style="color: #24292E"> </span><span style="color: #032F62">~/.ssh/HirakeGoma.pem</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># デプロイを実行</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cdk</span><span style="color: #24292E"> </span><span style="color: #032F62">deploy</span><span style="color: #24292E"> </span><span style="color: #005CC5">-c</span><span style="color: #24292E"> </span><span style="color: #032F62">key_name=&quot;HirakeGoma&quot;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br></div></div><p>ハンズオン 1 で作成した SSH 鍵の削除を行わなかった場合は， SSH 鍵を改めて作成する必要はない． 逆に言うと，同じ名前の SSH がすでに存在する場合は，鍵生成のコマンドはエラーを出力する．</p>
<p>デプロイのコマンドが無事に実行されれば， <a href="#handson_02_cdk_output">figure_title</a> のような出力が得られるはずである．AWS により割り振られた IP アドレス (<code>InstancePublicIp</code> に続く文字列) をメモしておこう．</p>
<p><img src="./assets/handson-jupyter/cdk_output.png" alt="CDKデプロイ実行後の出力"></p>
<h2 id="ログイン" tabindex="-1">ログイン <a class="header-anchor" href="#ログイン" aria-label="Permalink to &quot;ログイン&quot;">&ZeroWidthSpace;</a></h2>
<p>早速，デプロイしたインスタンスに SSH でログインしてみよう． ここでは，この後で使う Jupyter Notebook に接続するため，<strong>ポートフォワーディング (port forwarding)</strong> のオプション (<code>-L</code>) をつけてログインする．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ssh</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-i</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">~/.ssh/HirakeGoma.pem</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-L</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">localhost:8931:localhost:8888</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ec2-user@</span><span style="color: #F47067">&lt;</span><span style="color: #96D0FF">IP</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">addres</span><span style="color: #ADBAC7">s</span><span style="color: #F47067">&gt;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">ssh</span><span style="color: #24292E"> </span><span style="color: #005CC5">-i</span><span style="color: #24292E"> </span><span style="color: #032F62">~/.ssh/HirakeGoma.pem</span><span style="color: #24292E"> </span><span style="color: #005CC5">-L</span><span style="color: #24292E"> </span><span style="color: #032F62">localhost:8931:localhost:8888</span><span style="color: #24292E"> </span><span style="color: #032F62">ec2-user@</span><span style="color: #D73A49">&lt;</span><span style="color: #032F62">IP</span><span style="color: #24292E"> </span><span style="color: #032F62">addres</span><span style="color: #24292E">s</span><span style="color: #D73A49">&gt;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>ポートフォワーディングとは，クライアントマシンの特定のアドレスへの接続を， SSH の暗号化された通信を介して，リモートマシンの特定のアドレスへ転送する，という意味である． このコマンドの <code>-L localhost:8931:localhost:8888</code> は，自分のローカルマシンの <code>localhost:8931</code> へのアクセスを，リモートサーバーの <code>localhost:8888</code> のアドレスに転送せよ，という意味である (<code>:</code> につづく数字は TCP/IP ポートの番号を意味している)． リモートサーバーのポート 8888 には，後述する Jupyter Notebook が起動している． したがって，ローカルマシンの <code>localhost:8931</code> にアクセスすることで，リモートサーバーの Jupyter Notebook にアクセスすることができるのである (<a href="#fig:ssh_port_forwarding">figure_title</a>)． このような SSH による接続方式を<strong>トンネル接続</strong>とよぶ．</p>
<p><img src="./assets/ssh_port_forwarding.png" alt="SSH のポートフォワーディングによる Jupyter Notebook へのアクセス"></p>
<p>ポートフォワーディングのオプションで，ポートの番号 (<code>:8931</code>, <code>:8888</code> など) には 1 から 65535 までの任意の整数を指定できる． しかし，たとえば ポート 22 (SSH) やポート 80 (HTTP) など，いくつかすでに使われているポート番号もあることに注意する． また， Jupyter Notebook はデフォルトではポート 8888 番を使用する． したがって，リモート側のポート番号は，8888 を使うのがよい．</p>
<p>SSH ログインコマンドの <code>&lt;IP address&gt;</code> 部分は自身のインスタンスの IP アドレスを代入することを忘れずに．</p>
<p><strong>本書の提供している Docker を使ってデプロイを実行した人へ</strong></p>
<p>SSH によるログインは， <strong>Docker の外</strong> (すなわちクライアントマシン本体) から行わなければならない． なぜなら，Jupyter を開くウェブブラウザは Docker の外にあるからである．</p>
<p>その際，秘密鍵を Docker の外にもってこなければならない． 手っ取り早い方法は， <code>cat ~/.ssh/HirakeGoma</code> と打って，出力結果をコピーしてホストマシンのファイルに書き込む方法である． あるいは <code>-v</code> オプションをつけて，ファイルシステムをマウントしてもよい (詳しくは <a href="https://docs.docker.com/storage/volumes/" target="_blank" rel="noreferrer">Docker 公式ドキュメンテーション &quot;Use volumes&quot;</a> を参照)．</p>
<p>SSH によるログインができたら，早速， GPU の状態を確認してみよう． 次のコマンドを実行する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">nvidia-smi</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">nvidia-smi</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p><a href="#handson_02_nvidia-smi">figure_title</a> のような出力が得られるはずである． 出力を見ると， Tesla T4 型の GPU が 1 台搭載されていることが確認できる． その他，GPU Driver や CUDA のバージョン， GPU の負荷・メモリー使用率などの情報を確認することができる．</p>
<p><img src="./assets/handson-jupyter/nvidia-smi.png" alt="nvidia-smi の出力"></p>
<h2 id="jupyter-notebook-の起動" tabindex="-1">Jupyter Notebook の起動 <a class="header-anchor" href="#jupyter-notebook-の起動" aria-label="Permalink to &quot;Jupyter Notebook の起動&quot;">&ZeroWidthSpace;</a></h2>
<p><a href="https://jupyter.org/" target="_blank" rel="noreferrer">Jupyter Notebook</a> とは，インタラクティブに Python のプログラムを書いたり実行したりするためのツールである． Jupyter は GUI としてウェブブラウザを介してアクセスする形式をとっており，まるでノートを書くように，プロットやテーブルのデータも美しく表示することができる (<a href="#handson_02_welcome_jupyter">figure_title</a>)． Python に慣れている読者は，きっと一度は使ったことがあるだろう．</p>
<p><img src="./assets/handson-jupyter/welcome_to_jupyter.png" alt="Jupyter Notebook の画面"></p>
<p>このハンズオンでは， Jupyter Notebook を使ってディープラーニングのプログラムをインタラクティブに実行していく． DLAMI には既に Jupyter がインストールされているので，特段の設定なしに使い始めることができる．</p>
<p>早速， Jupyter を起動しよう． SSH でログインした先の EC2 インスタンスで，次のコマンドを実行すればよい．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cd</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">~</span><span style="color: #ADBAC7"> </span><span style="color: #768390"># go to home directory</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">jupyter</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">notebook</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cd</span><span style="color: #24292E"> </span><span style="color: #032F62">~</span><span style="color: #24292E"> </span><span style="color: #6A737D"># go to home directory</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">jupyter</span><span style="color: #24292E"> </span><span style="color: #032F62">notebook</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>このコマンドを実行すると， <a href="#handson_02_jupyter_launch">figure_title</a> のような出力が確認できるだろう． この出力から，Jupyter のサーバーが EC2 インスタンスの <code>localhost:8888</code> というアドレスに起動していることがわかる． また， <code>localhost:8888</code> に続く <code>?token=XXXX</code> は，アクセスに使うための一時的なトークンである．</p>
<p><img src="./assets/handson-jupyter/jupyter_launch.png" alt="Jupyter Notebook サーバーを起動"></p>
<p>Jupyter Notebook を初回に起動するときは，起動に数分程度の時間がかかることがある． ほかの動作も起動直後は遅く，いくつかプログラムを走らせていくうちに俊敏に反応するようになってくる． これは， AWS の GPU 搭載型仮想マシンの運用方法に起因する現象だと考えられる．</p>
<p>先ほど，ポートフォワーディングのオプションをつけて SSH 接続をしているので， Jupyter の起動している <code>localhost:8888</code> には，ローカルマシンの <code>localhost:8931</code> からアクセスすることができる． したがって，ローカルマシンから Jupyter にアクセスするには，ウェブブラウザ (Chrome, FireFox など)から次のアドレスにアクセスすれば良い．</p>
<p><a href="http://localhost:8931/?token=XXXX&amp;lt;/programlisting&amp;gt" target="_blank" rel="noreferrer">http://localhost:8931/?token=XXXX&amp;lt;/programlisting&amp;gt</a>;</p>
<p><code>?token=XXXX</code> の部分は，上で Jupyter を起動したときに発行されたトークンの値に置き換える．</p>
<p>上のアドレスにアクセスすると， Jupyter のホーム画面が起動するはずである (<a href="#handson_02_jupyter_home">figure_title</a>)． これで， Jupyter の準備が整った！</p>
<p><img src="./assets/handson-jupyter/jupyter_home.png" alt="Jupyter ホーム画面"></p>
<p>Jupyter Notebook の使い方 (超簡易版)</p>
<ul>
<li>
<p><code>Shift</code> + <code>Enter</code>: セルを実行</p>
</li>
<li>
<p><code>Esc</code>: <strong>Command mode</strong> に遷移</p>
</li>
<li>
<p>メニューバーの &quot;+&quot; ボタン または Command mode で <code>A</code> ⇒ セルを追加</p>
</li>
<li>
<p>メニューバーの &quot;ハサミ&quot; ボタン または Command mode で <code>X</code> ⇒ セルを削除</p>
</li>
</ul>
<p>ショートカットの一覧などは <a href="https://towardsdatascience.com/jypyter-notebook-shortcuts-bf0101a98330" target="_blank" rel="noreferrer">Ventsislav Yordanov 氏によるブログ</a> が参考になる．</p>
<h2 id="pytorch-はじめの一歩" tabindex="-1">PyTorch はじめの一歩 <a class="header-anchor" href="#pytorch-はじめの一歩" aria-label="Permalink to &quot;PyTorch はじめの一歩&quot;">&ZeroWidthSpace;</a></h2>
<p><a href="https://pytorch.org/" target="_blank" rel="noreferrer">PyTorch</a> は Facebook AI Research LAB (FAIR) が中心となって開発を進めている，オープンソースのディープラーニングのライブラリである． PyTorch は 有名な例で言えば Tesla 社の自動運転プロジェクトなどで使用されており，執筆時点において最も人気の高いディープラーニングライブラリの一つである． 本ハンズオンでは， PyTorch を使ってディープラーニングの実践を行う．</p>
<p>PyTorch の歴史のお話</p>
<p>Facebook は PyTorch のほかに Caffe2 とよばれるディープラーニングのフレームワークを開発していた (初代 Caffe は UC Berkley の博士課程学生だった Yangqing Jia によって創られた)． Caffe2 は 2018 年に PyTorch プロジェクトに合併された．</p>
<p>また，2019 年 12 月，日本の Preferred Networks 社が開発していた <a href="https://chainer.org/" target="_blank" rel="noreferrer">Chainer</a> も開発を終了し，PyTorch の開発チームと協業していくことが発表された (詳しくは <a href="https://chainer.org/announcement/2019/12/05/released-v7-ja.html" target="_blank" rel="noreferrer">プレスリリース</a> を参照)． PyTorch には，開発統合前から Chainer からインスパイアされた API がいくつもあり， Chainer の DNA は今も PyTorch に引き継がれているのである…!</p>
<p>本格的なディープラーニングの計算に移る前に， PyTorch ライブラリを使って， GPU で計算を行うとはどういうものか，その入り口に触れてみよう．</p>
<p>まずは，新しいノートブックを作成する． Jupyter のホーム画面の右上の &quot;New&quot; を押し，&quot;conda_pytorch_p36&quot; という環境を選択したうえで，新規ノートブックを作成する (<a href="#handson_02_jupyeter_new">figure_title</a>)． &quot;conda_pytorch_p36&quot; の仮想環境には， PyTorch がインストール済みである．</p>
<p><img src="./assets/handson-jupyter/jupyter_new.png" alt="新規ノートブックの作成． &quot;conda_pytorch_p36&quot; の環境を選択する．"></p>
<p>ここでは，次のようなプログラムを書いて，実行していく． (<a href="#handson_02_jupyeter_pytorch">figure_title</a>)．</p>
<p><img src="./assets/handson-jupyter/jupyter_pytorch.png" alt="PyTorch始めの一歩"></p>
<p>まずは， PyTorch をインポートする．さらに， GPU が使える環境にあるか，確認する．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> torch</span></span>
<span class="line"><span style="color: #6CB6FF">print</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;Is CUDA ready?&quot;</span><span style="color: #ADBAC7">, torch.cuda.is_available())</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> torch</span></span>
<span class="line"><span style="color: #005CC5">print</span><span style="color: #24292E">(</span><span style="color: #032F62">&quot;Is CUDA ready?&quot;</span><span style="color: #24292E">, torch.cuda.is_available())</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>出力:</p>
<p>Is CUDA ready? True&lt;/programlisting&gt;</p>
<p>次に，3x3 のランダムな行列を <strong>CPU</strong> 上に作ってみよう．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">x </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> torch.rand(</span><span style="color: #6CB6FF">3</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">3</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #6CB6FF">print</span><span style="color: #ADBAC7">(x)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">x </span><span style="color: #D73A49">=</span><span style="color: #24292E"> torch.rand(</span><span style="color: #005CC5">3</span><span style="color: #24292E">,</span><span style="color: #005CC5">3</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #005CC5">print</span><span style="color: #24292E">(x)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>出力:</p>
<p>tensor([[0.6896, 0.2428, 0.3269], [0.0533, 0.3594, 0.9499], [0.9764, 0.5881, 0.0203]])&lt;/programlisting&gt;</p>
<p>次に，行列を <strong>GPU</strong> 上に作成する．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">y </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> torch.ones_like(x, </span><span style="color: #F69D50">device</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;cuda&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">x </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> x.to(</span><span style="color: #96D0FF">&quot;cuda&quot;</span><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">y </span><span style="color: #D73A49">=</span><span style="color: #24292E"> torch.ones_like(x, </span><span style="color: #E36209">device</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;cuda&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">x </span><span style="color: #D73A49">=</span><span style="color: #24292E"> x.to(</span><span style="color: #032F62">&quot;cuda&quot;</span><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>そして，行列 <code>x</code> と <code>y</code> の加算を，<strong>GPU 上で実行する</strong>．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">z </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> x </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> y</span></span>
<span class="line"><span style="color: #6CB6FF">print</span><span style="color: #ADBAC7">(z)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">z </span><span style="color: #D73A49">=</span><span style="color: #24292E"> x </span><span style="color: #D73A49">+</span><span style="color: #24292E"> y</span></span>
<span class="line"><span style="color: #005CC5">print</span><span style="color: #24292E">(z)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>出力:</p>
<p>tensor([[1.6896, 1.2428, 1.3269], [1.0533, 1.3594, 1.9499], [1.9764, 1.5881, 1.0203]], device='cuda:0')&lt;/programlisting&gt;</p>
<p>最後に， GPU 上にある行列を， CPU に戻す．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">z </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> z.to(</span><span style="color: #96D0FF">&quot;cpu&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #6CB6FF">print</span><span style="color: #ADBAC7">(z)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">z </span><span style="color: #D73A49">=</span><span style="color: #24292E"> z.to(</span><span style="color: #032F62">&quot;cpu&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #005CC5">print</span><span style="color: #24292E">(z)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>出力:</p>
<p>tensor([[1.6896, 1.2428, 1.3269], [1.0533, 1.3594, 1.9499], [1.9764, 1.5881, 1.0203]])&lt;/programlisting&gt;</p>
<p>以上の例は， GPU を使った計算の初歩の初歩であるが，雰囲気はつかめただろうか？ CPU と GPU で明示的にデータを交換するのが肝である． この例はたった 3x3 の行列の足し算なので， GPU を使う意味はまったくないが，これが数千，数万のサイズの行列になったとき， GPU は格段の威力を発揮する．</p>
<p>完成した Jupyter Notebook は <a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/mnist/pytorch/pytorch_get_started.ipynb" target="_blank" rel="noreferrer">/handson/mnist/pytorch/pytorch_get_started.ipynb</a> にある． Jupyter の画面右上の &quot;Upload&quot; からこのファイルをアップロードして，コードを走らせることが可能である．</p>
<p>しなしながら，勉強のときにはコードはすべて自分の手で打つことが，記憶に残りやすくより効果的である，というのが筆者の意見である．</p>
<p>実際にベンチマークを取ることで GPU と CPU の速度を比較をしてみよう． 実行時間を計測するツールとして， Jupyter の提供する <a href="https://ipython.readthedocs.io/en/stable/interactive/magics.html" target="_blank" rel="noreferrer">%time</a> マジックコマンドを利用する．</p>
<p>まずは CPU を使用して，10000x10000 の行列の行列積を計算した場合の速度を測ってみよう． 先ほどのノートブックの続きに，次のコードを実行する．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">s </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">10000</span></span>
<span class="line"><span style="color: #ADBAC7">device </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;cpu&quot;</span></span>
<span class="line"><span style="color: #ADBAC7">x </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> torch.rand(s, s, </span><span style="color: #F69D50">device</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">device, </span><span style="color: #F69D50">dtype</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">torch.float32)</span></span>
<span class="line"><span style="color: #ADBAC7">y </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> torch.rand(s, s, </span><span style="color: #F69D50">device</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">device, </span><span style="color: #F69D50">dtype</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">torch.float32)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F47067">%</span><span style="color: #ADBAC7">time z </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> torch.matmul(x,y)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">s </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #005CC5">10000</span></span>
<span class="line"><span style="color: #24292E">device </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;cpu&quot;</span></span>
<span class="line"><span style="color: #24292E">x </span><span style="color: #D73A49">=</span><span style="color: #24292E"> torch.rand(s, s, </span><span style="color: #E36209">device</span><span style="color: #D73A49">=</span><span style="color: #24292E">device, </span><span style="color: #E36209">dtype</span><span style="color: #D73A49">=</span><span style="color: #24292E">torch.float32)</span></span>
<span class="line"><span style="color: #24292E">y </span><span style="color: #D73A49">=</span><span style="color: #24292E"> torch.rand(s, s, </span><span style="color: #E36209">device</span><span style="color: #D73A49">=</span><span style="color: #24292E">device, </span><span style="color: #E36209">dtype</span><span style="color: #D73A49">=</span><span style="color: #24292E">torch.float32)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D73A49">%</span><span style="color: #24292E">time z </span><span style="color: #D73A49">=</span><span style="color: #24292E"> torch.matmul(x,y)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br></div></div><p>出力は以下のようなものが得られるだろう． これは，行列積の計算に実時間で 5.8 秒かかったことを意味する (実行のたびに計測される時間はばらつくことに留意)．</p>
<p>CPU times: user 11.5 s, sys: 140 ms, total: 11.6 s Wall time: 5.8 s&lt;/programlisting&gt;</p>
<p>次に， GPU を使用して，同じ演算を行った場合の速度を計測しよう．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">s </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">10000</span></span>
<span class="line"><span style="color: #ADBAC7">device </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;cuda&quot;</span></span>
<span class="line"><span style="color: #ADBAC7">x </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> torch.rand(s, s, </span><span style="color: #F69D50">device</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">device, </span><span style="color: #F69D50">dtype</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">torch.float32)</span></span>
<span class="line"><span style="color: #ADBAC7">y </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> torch.rand(s, s, </span><span style="color: #F69D50">device</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">device, </span><span style="color: #F69D50">dtype</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">torch.float32)</span></span>
<span class="line"><span style="color: #ADBAC7">torch.cuda.synchronize()</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F47067">%</span><span style="color: #ADBAC7">time z </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> torch.matmul(x,y); torch.cuda.synchronize()</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">s </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #005CC5">10000</span></span>
<span class="line"><span style="color: #24292E">device </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;cuda&quot;</span></span>
<span class="line"><span style="color: #24292E">x </span><span style="color: #D73A49">=</span><span style="color: #24292E"> torch.rand(s, s, </span><span style="color: #E36209">device</span><span style="color: #D73A49">=</span><span style="color: #24292E">device, </span><span style="color: #E36209">dtype</span><span style="color: #D73A49">=</span><span style="color: #24292E">torch.float32)</span></span>
<span class="line"><span style="color: #24292E">y </span><span style="color: #D73A49">=</span><span style="color: #24292E"> torch.rand(s, s, </span><span style="color: #E36209">device</span><span style="color: #D73A49">=</span><span style="color: #24292E">device, </span><span style="color: #E36209">dtype</span><span style="color: #D73A49">=</span><span style="color: #24292E">torch.float32)</span></span>
<span class="line"><span style="color: #24292E">torch.cuda.synchronize()</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D73A49">%</span><span style="color: #24292E">time z </span><span style="color: #D73A49">=</span><span style="color: #24292E"> torch.matmul(x,y); torch.cuda.synchronize()</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br></div></div><p>出力は以下のようなものになるだろう． GPU では 553 ミリ秒 で計算を終えることができた！</p>
<p>CPU times: user 334 ms, sys: 220 ms, total: 554 ms Wall time: 553 ms&lt;/programlisting&gt;</p>
<p>PyTorch において， GPU での演算は asynchronous (非同期) で実行される． その理由で，上のベンチマークコードでは， <code>torch.cuda.synchronize()</code> というステートメントを埋め込んである．</p>
<p>このベンチマークでは， <code>dtype=torch.float32</code> と指定することで，32bit の浮動小数点型を用いている． ディープラーニングの学習および推論の計算には，32bit 型，場合によっては 16bit 型が使われるのが一般的である． これの主な理由として，教師データやミニバッチに起因するノイズが，浮動小数点の精度よりも大きいことがあげられる． 32bit/16bit を採用することで，メモリー消費を抑えたり，計算速度の向上が達成できる．</p>
<p>上記のベンチマークから，GPU を用いることで，<strong>約 10 倍のスピードアップ</strong>を実現することができた． スピードアップの性能は，演算の種類や行列のサイズに依存する． 行列積は，そのなかでも最も速度向上が見込まれる演算の一つである．</p>
<h2 id="実践ディープラーニング-mnist-手書き数字認識タスク" tabindex="-1">実践ディープラーニング! MNIST 手書き数字認識タスク <a class="header-anchor" href="#実践ディープラーニング-mnist-手書き数字認識タスク" aria-label="Permalink to &quot;実践ディープラーニング! MNIST 手書き数字認識タスク&quot;">&ZeroWidthSpace;</a></h2>
<p>ここまで，AWS 上でディープラーニングの計算をするための概念や前提知識をながながと説明してきたが，ついにここからディープラーニングの計算を実際に走らせてみる．</p>
<p>ここでは，機械学習のタスクで最も初歩的かつ有名な <strong>MNIST データセットを使った数字認識</strong>を扱う (<a href="#handson_02_mnist_examples">figure_title</a>)． これは，0 から 9 までの手書きの数字の画像が与えられ，その数字が何の数字なのかを当てる，というシンプルなタスクである．</p>
<p><img src="./assets/handson-jupyter/mnist_examples.png" alt="MNIST 手書き数字データセット"></p>
<p>今回は， MNIST 文字認識タスクを，<strong>畳み込みニューラルネットワーク (Convolutional Neural Network; CNN)</strong> を使って解く． ソースコードは <a href="https://github.com/tomomano/learn-aws-by-coding-source-code/tree/main/handson/mnist/pytorch" target="_blank" rel="noreferrer">/handson/minist/pytorch/</a> にある <code>mnist.ipynb</code> と <code>simple_mnist.py</code> である． なお，このプログラムは， <a href="https://github.com/pytorch/examples/tree/master/mnist" target="_blank" rel="noreferrer">PyTorch の公式 Example Project 集</a> を参考に，多少の改変を行ったものである．</p>
<p>まずは，カスタムのクラスや関数が定義された <code>simple_mnist.py</code> をアップロードしよう (<a href="#handson_02_jupyter_upload">figure_title</a>)． 画面右上の &quot;Upload&quot; ボタンをクリックし，ファイルを選択することでアップロードができる． この Python プログラムの中に，CNN のモデルや，学習の各イテレーションにおけるパラメータの更新などが記述されている． 今回はこの中身を説明することはしないが，興味のある読者は自身でソースコードを読んでみるとよい．</p>
<p><img src="./assets/handson-jupyter/jupyter_upload.png" alt=" をアップロード"></p>
<p><code>simple_mnist.py</code> をアップロードできたら，次に新しい notebook を作成しよう． &quot;conda_pytorch_p36&quot; の環境を選択することを忘れずに．</p>
<p>新しいノートブックが起動したら，まずは必要なライブラリをインポートしよう．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> torch</span></span>
<span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> torch.optim </span><span style="color: #F47067">as</span><span style="color: #ADBAC7"> optim</span></span>
<span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> torchvision</span></span>
<span class="line"><span style="color: #F47067">from</span><span style="color: #ADBAC7"> torchvision </span><span style="color: #F47067">import</span><span style="color: #ADBAC7"> datasets, transforms</span></span>
<span class="line"><span style="color: #F47067">from</span><span style="color: #ADBAC7"> matplotlib </span><span style="color: #F47067">import</span><span style="color: #ADBAC7"> pyplot </span><span style="color: #F47067">as</span><span style="color: #ADBAC7"> plt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># custom functions and classes</span></span>
<span class="line"><span style="color: #F47067">from</span><span style="color: #ADBAC7"> simple_mnist </span><span style="color: #F47067">import</span><span style="color: #ADBAC7"> Model, train, evaluate</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> torch</span></span>
<span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> torch.optim </span><span style="color: #D73A49">as</span><span style="color: #24292E"> optim</span></span>
<span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> torchvision</span></span>
<span class="line"><span style="color: #D73A49">from</span><span style="color: #24292E"> torchvision </span><span style="color: #D73A49">import</span><span style="color: #24292E"> datasets, transforms</span></span>
<span class="line"><span style="color: #D73A49">from</span><span style="color: #24292E"> matplotlib </span><span style="color: #D73A49">import</span><span style="color: #24292E"> pyplot </span><span style="color: #D73A49">as</span><span style="color: #24292E"> plt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># custom functions and classes</span></span>
<span class="line"><span style="color: #D73A49">from</span><span style="color: #24292E"> simple_mnist </span><span style="color: #D73A49">import</span><span style="color: #24292E"> Model, train, evaluate</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br></div></div><p><a href="https://pytorch.org/docs/stable/torchvision/index.html" target="_blank" rel="noreferrer">torchvision</a> パッケージには，MNIST データセットをロードするなどの便利な関数が含まれている． また，今回のハンズオンで使うカスタムのクラス・関数 (<code>Model</code>, <code>train</code>, <code>evaluate</code>) のインポートを行っている．</p>
<p>次に，MNIST テストデータをダウンロードしよう． 同時に，画像データの輝度の正規化も行っている．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">transf </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> transforms.Compose([transforms.ToTensor(),</span></span>
<span class="line"><span style="color: #ADBAC7">                             transforms.Normalize((</span><span style="color: #6CB6FF">0.1307</span><span style="color: #ADBAC7">,), (</span><span style="color: #6CB6FF">0.3081</span><span style="color: #ADBAC7">,))])</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">trainset </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> datasets.MNIST(</span><span style="color: #F69D50">root</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&#39;./data&#39;</span><span style="color: #ADBAC7">, </span><span style="color: #F69D50">train</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">True</span><span style="color: #ADBAC7">, </span><span style="color: #F69D50">download</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">True</span><span style="color: #ADBAC7">, </span><span style="color: #F69D50">transform</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">transf)</span></span>
<span class="line"><span style="color: #ADBAC7">trainloader </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> torch.utils.data.DataLoader(trainset, </span><span style="color: #F69D50">batch_size</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">64</span><span style="color: #ADBAC7">, </span><span style="color: #F69D50">shuffle</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">True</span><span style="color: #ADBAC7">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">testset </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> datasets.MNIST(</span><span style="color: #F69D50">root</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&#39;./data&#39;</span><span style="color: #ADBAC7">, </span><span style="color: #F69D50">train</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">False</span><span style="color: #ADBAC7">, </span><span style="color: #F69D50">download</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">True</span><span style="color: #ADBAC7">, </span><span style="color: #F69D50">transform</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">transf)</span></span>
<span class="line"><span style="color: #ADBAC7">testloader </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> torch.utils.data.DataLoader(testset, </span><span style="color: #F69D50">batch_size</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">1000</span><span style="color: #ADBAC7">, </span><span style="color: #F69D50">shuffle</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">True</span><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">transf </span><span style="color: #D73A49">=</span><span style="color: #24292E"> transforms.Compose([transforms.ToTensor(),</span></span>
<span class="line"><span style="color: #24292E">                             transforms.Normalize((</span><span style="color: #005CC5">0.1307</span><span style="color: #24292E">,), (</span><span style="color: #005CC5">0.3081</span><span style="color: #24292E">,))])</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">trainset </span><span style="color: #D73A49">=</span><span style="color: #24292E"> datasets.MNIST(</span><span style="color: #E36209">root</span><span style="color: #D73A49">=</span><span style="color: #032F62">&#39;./data&#39;</span><span style="color: #24292E">, </span><span style="color: #E36209">train</span><span style="color: #D73A49">=</span><span style="color: #005CC5">True</span><span style="color: #24292E">, </span><span style="color: #E36209">download</span><span style="color: #D73A49">=</span><span style="color: #005CC5">True</span><span style="color: #24292E">, </span><span style="color: #E36209">transform</span><span style="color: #D73A49">=</span><span style="color: #24292E">transf)</span></span>
<span class="line"><span style="color: #24292E">trainloader </span><span style="color: #D73A49">=</span><span style="color: #24292E"> torch.utils.data.DataLoader(trainset, </span><span style="color: #E36209">batch_size</span><span style="color: #D73A49">=</span><span style="color: #005CC5">64</span><span style="color: #24292E">, </span><span style="color: #E36209">shuffle</span><span style="color: #D73A49">=</span><span style="color: #005CC5">True</span><span style="color: #24292E">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">testset </span><span style="color: #D73A49">=</span><span style="color: #24292E"> datasets.MNIST(</span><span style="color: #E36209">root</span><span style="color: #D73A49">=</span><span style="color: #032F62">&#39;./data&#39;</span><span style="color: #24292E">, </span><span style="color: #E36209">train</span><span style="color: #D73A49">=</span><span style="color: #005CC5">False</span><span style="color: #24292E">, </span><span style="color: #E36209">download</span><span style="color: #D73A49">=</span><span style="color: #005CC5">True</span><span style="color: #24292E">, </span><span style="color: #E36209">transform</span><span style="color: #D73A49">=</span><span style="color: #24292E">transf)</span></span>
<span class="line"><span style="color: #24292E">testloader </span><span style="color: #D73A49">=</span><span style="color: #24292E"> torch.utils.data.DataLoader(testset, </span><span style="color: #E36209">batch_size</span><span style="color: #D73A49">=</span><span style="color: #005CC5">1000</span><span style="color: #24292E">, </span><span style="color: #E36209">shuffle</span><span style="color: #D73A49">=</span><span style="color: #005CC5">True</span><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br></div></div><p>今回扱う MNIST データは 28x28 ピクセルの正方形の画像(モノクロ)と，それぞれのラベル(0 - 9 の数字)の組で構成されている． いくつかのデータを抽出して，可視化してみよう． <a href="#handson_02_mnist_ground_truth">figure_title</a> のような出力が得られるはずである．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">examples </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">iter</span><span style="color: #ADBAC7">(testloader)</span></span>
<span class="line"><span style="color: #ADBAC7">example_data, example_targets </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> examples.next()</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6CB6FF">print</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;Example data size:&quot;</span><span style="color: #ADBAC7">, example_data.shape)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">fig </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> plt.figure(</span><span style="color: #F69D50">figsize</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">10</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">4</span><span style="color: #ADBAC7">))</span></span>
<span class="line"><span style="color: #F47067">for</span><span style="color: #ADBAC7"> i </span><span style="color: #F47067">in</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">range</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">10</span><span style="color: #ADBAC7">):</span></span>
<span class="line"><span style="color: #ADBAC7">    plt.subplot(</span><span style="color: #6CB6FF">2</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">5</span><span style="color: #ADBAC7">,i</span><span style="color: #F47067">+</span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">    plt.tight_layout()</span></span>
<span class="line"><span style="color: #ADBAC7">    plt.imshow(example_data[i][</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">], </span><span style="color: #F69D50">cmap</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&#39;gray&#39;</span><span style="color: #ADBAC7">, </span><span style="color: #F69D50">interpolation</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&#39;none&#39;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">    plt.title(</span><span style="color: #96D0FF">&quot;Ground Truth: </span><span style="color: #F47067">{}</span><span style="color: #96D0FF">&quot;</span><span style="color: #ADBAC7">.format(example_targets[i]))</span></span>
<span class="line"><span style="color: #ADBAC7">    plt.xticks([])</span></span>
<span class="line"><span style="color: #ADBAC7">    plt.yticks([])</span></span>
<span class="line"><span style="color: #ADBAC7">plt.show()</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">examples </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #005CC5">iter</span><span style="color: #24292E">(testloader)</span></span>
<span class="line"><span style="color: #24292E">example_data, example_targets </span><span style="color: #D73A49">=</span><span style="color: #24292E"> examples.next()</span></span>
<span class="line"></span>
<span class="line"><span style="color: #005CC5">print</span><span style="color: #24292E">(</span><span style="color: #032F62">&quot;Example data size:&quot;</span><span style="color: #24292E">, example_data.shape)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">fig </span><span style="color: #D73A49">=</span><span style="color: #24292E"> plt.figure(</span><span style="color: #E36209">figsize</span><span style="color: #D73A49">=</span><span style="color: #24292E">(</span><span style="color: #005CC5">10</span><span style="color: #24292E">,</span><span style="color: #005CC5">4</span><span style="color: #24292E">))</span></span>
<span class="line"><span style="color: #D73A49">for</span><span style="color: #24292E"> i </span><span style="color: #D73A49">in</span><span style="color: #24292E"> </span><span style="color: #005CC5">range</span><span style="color: #24292E">(</span><span style="color: #005CC5">10</span><span style="color: #24292E">):</span></span>
<span class="line"><span style="color: #24292E">    plt.subplot(</span><span style="color: #005CC5">2</span><span style="color: #24292E">,</span><span style="color: #005CC5">5</span><span style="color: #24292E">,i</span><span style="color: #D73A49">+</span><span style="color: #005CC5">1</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">    plt.tight_layout()</span></span>
<span class="line"><span style="color: #24292E">    plt.imshow(example_data[i][</span><span style="color: #005CC5">0</span><span style="color: #24292E">], </span><span style="color: #E36209">cmap</span><span style="color: #D73A49">=</span><span style="color: #032F62">&#39;gray&#39;</span><span style="color: #24292E">, </span><span style="color: #E36209">interpolation</span><span style="color: #D73A49">=</span><span style="color: #032F62">&#39;none&#39;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">    plt.title(</span><span style="color: #032F62">&quot;Ground Truth: </span><span style="color: #005CC5">{}</span><span style="color: #032F62">&quot;</span><span style="color: #24292E">.format(example_targets[i]))</span></span>
<span class="line"><span style="color: #24292E">    plt.xticks([])</span></span>
<span class="line"><span style="color: #24292E">    plt.yticks([])</span></span>
<span class="line"><span style="color: #24292E">plt.show()</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br></div></div><p><img src="./assets/handson-jupyter/mnist_ground_truth.png" alt="MNIST の手書き数字画像とその教師ラベル"></p>
<p>次に， CNN のモデルを定義する．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">model </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> Model()</span></span>
<span class="line"><span style="color: #ADBAC7">model.to(</span><span style="color: #96D0FF">&quot;cuda&quot;</span><span style="color: #ADBAC7">) </span><span style="color: #768390"># load to GPU</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">model </span><span style="color: #D73A49">=</span><span style="color: #24292E"> Model()</span></span>
<span class="line"><span style="color: #24292E">model.to(</span><span style="color: #032F62">&quot;cuda&quot;</span><span style="color: #24292E">) </span><span style="color: #6A737D"># load to GPU</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>今回使う <code>Model</code> は <code>simple_mnist.py</code> の中で定義されている． このモデルは，<a href="#handson_02_cnn_architecture">figure_title</a> に示したような，２層の畳み込み層と 2 層の全結合層からなるネットワークである． 出力層 (output layer) には Softmax 関数を使用し，損失関数 (Loss function) には 負の対数尤度関数 (Negative log likelyhood; NLL) を使用している．</p>
<p><img src="./assets/handson-jupyter/cnn_architecture.png" alt="本ハンズオンで使用するニューラルネットの構造．"></p>
<p>続いて， CNN のパラメータを更新する最適化アルゴリズムを定義する． ここでは， <strong>確率的勾配降下法 (Stochastic Gradient Descent; SGD)</strong> を使用している．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">optimizer </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> optim.SGD(model.parameters(), </span><span style="color: #F69D50">lr</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">0.01</span><span style="color: #ADBAC7">, </span><span style="color: #F69D50">momentum</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">0.5</span><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">optimizer </span><span style="color: #D73A49">=</span><span style="color: #24292E"> optim.SGD(model.parameters(), </span><span style="color: #E36209">lr</span><span style="color: #D73A49">=</span><span style="color: #005CC5">0.01</span><span style="color: #24292E">, </span><span style="color: #E36209">momentum</span><span style="color: #D73A49">=</span><span style="color: #005CC5">0.5</span><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>これで，準備が整った． CNN の学習ループを開始しよう!</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">train_losses </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> []</span></span>
<span class="line"><span style="color: #F47067">for</span><span style="color: #ADBAC7"> epoch </span><span style="color: #F47067">in</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">range</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">5</span><span style="color: #ADBAC7">):</span></span>
<span class="line"><span style="color: #ADBAC7">    losses </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> train(model, trainloader, optimizer, epoch)</span></span>
<span class="line"><span style="color: #ADBAC7">    train_losses </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> train_losses </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> losses</span></span>
<span class="line"><span style="color: #ADBAC7">    test_loss, test_accuracy </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> evaluate(model, testloader)</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">print</span><span style="color: #ADBAC7">(</span><span style="color: #F47067">f</span><span style="color: #96D0FF">&quot;</span><span style="color: #F47067">\n</span><span style="color: #96D0FF">Test set: Average loss: </span><span style="color: #F47067">{</span><span style="color: #ADBAC7">test_loss</span><span style="color: #F47067">:.4f}</span><span style="color: #96D0FF">, Accuracy: </span><span style="color: #F47067">{</span><span style="color: #ADBAC7">test_accuracy</span><span style="color: #F47067">:.1f}</span><span style="color: #96D0FF">%</span><span style="color: #F47067">\n</span><span style="color: #96D0FF">&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">plt.figure(</span><span style="color: #F69D50">figsize</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">7</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">5</span><span style="color: #ADBAC7">))</span></span>
<span class="line"><span style="color: #ADBAC7">plt.plot(train_losses)</span></span>
<span class="line"><span style="color: #ADBAC7">plt.xlabel(</span><span style="color: #96D0FF">&quot;Iterations&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">plt.ylabel(</span><span style="color: #96D0FF">&quot;Train loss&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">plt.show()</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">train_losses </span><span style="color: #D73A49">=</span><span style="color: #24292E"> []</span></span>
<span class="line"><span style="color: #D73A49">for</span><span style="color: #24292E"> epoch </span><span style="color: #D73A49">in</span><span style="color: #24292E"> </span><span style="color: #005CC5">range</span><span style="color: #24292E">(</span><span style="color: #005CC5">5</span><span style="color: #24292E">):</span></span>
<span class="line"><span style="color: #24292E">    losses </span><span style="color: #D73A49">=</span><span style="color: #24292E"> train(model, trainloader, optimizer, epoch)</span></span>
<span class="line"><span style="color: #24292E">    train_losses </span><span style="color: #D73A49">=</span><span style="color: #24292E"> train_losses </span><span style="color: #D73A49">+</span><span style="color: #24292E"> losses</span></span>
<span class="line"><span style="color: #24292E">    test_loss, test_accuracy </span><span style="color: #D73A49">=</span><span style="color: #24292E"> evaluate(model, testloader)</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">print</span><span style="color: #24292E">(</span><span style="color: #D73A49">f</span><span style="color: #032F62">&quot;</span><span style="color: #005CC5">\n</span><span style="color: #032F62">Test set: Average loss: </span><span style="color: #005CC5">{</span><span style="color: #24292E">test_loss</span><span style="color: #D73A49">:.4f</span><span style="color: #005CC5">}</span><span style="color: #032F62">, Accuracy: </span><span style="color: #005CC5">{</span><span style="color: #24292E">test_accuracy</span><span style="color: #D73A49">:.1f</span><span style="color: #005CC5">}</span><span style="color: #032F62">%</span><span style="color: #005CC5">\n</span><span style="color: #032F62">&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">plt.figure(</span><span style="color: #E36209">figsize</span><span style="color: #D73A49">=</span><span style="color: #24292E">(</span><span style="color: #005CC5">7</span><span style="color: #24292E">,</span><span style="color: #005CC5">5</span><span style="color: #24292E">))</span></span>
<span class="line"><span style="color: #24292E">plt.plot(train_losses)</span></span>
<span class="line"><span style="color: #24292E">plt.xlabel(</span><span style="color: #032F62">&quot;Iterations&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">plt.ylabel(</span><span style="color: #032F62">&quot;Train loss&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">plt.show()</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br></div></div><p>ここでは 5 エポック分の学習を行っている． GPU を使えば，これくらいの計算であれば 1 分程度で完了するだろう．</p>
<p>出力として， <a href="#handson_02_train_loss">figure_title</a> のようなプロットが得られるはずである． イテレーションを重ねるにつれて，損失関数 (Loss function) の値が減少している (=精度が向上している) ことがわかる．</p>
<p><img src="./assets/handson-jupyter/train_loss.png" alt="学習の進行に対する Train loss の変化"></p>
<p>出力にはテキスト形式で各エポック終了後のテストデータに対する精度も表示されている． 最終的には 98% 以上の極めて高い精度を実現できていることが確認できるだろう (<a href="#handson_02_mnist_final_score">figure_title</a>)．</p>
<p><img src="./assets/handson-jupyter/mnist_final_score.png" alt="学習したCNNのテストデータに対するスコア (5エポック後)"></p>
<p>学習した CNN の推論結果を可視化してみよう． 次のコードを実行することで， <a href="#handson_02_mnist_mnist_prediction">figure_title</a> のような出力が得られるだろう． この図で，下段右から二番目は，&quot;1&quot;に近い見た目をしているが，きちんと&quot;9&quot;と推論できている． なかなか賢い CNN を作り出すことができたようだ！</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">model.eval()</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F47067">with</span><span style="color: #ADBAC7"> torch.no_grad():</span></span>
<span class="line"><span style="color: #ADBAC7">    output </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> model(example_data.to(</span><span style="color: #96D0FF">&quot;cuda&quot;</span><span style="color: #ADBAC7">))</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">fig </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> plt.figure(</span><span style="color: #F69D50">figsize</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">10</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">4</span><span style="color: #ADBAC7">))</span></span>
<span class="line"><span style="color: #F47067">for</span><span style="color: #ADBAC7"> i </span><span style="color: #F47067">in</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">range</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">10</span><span style="color: #ADBAC7">):</span></span>
<span class="line"><span style="color: #ADBAC7">    plt.subplot(</span><span style="color: #6CB6FF">2</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">5</span><span style="color: #ADBAC7">,i</span><span style="color: #F47067">+</span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">    plt.tight_layout()</span></span>
<span class="line"><span style="color: #ADBAC7">    plt.imshow(example_data[i][</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">], </span><span style="color: #F69D50">cmap</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&#39;gray&#39;</span><span style="color: #ADBAC7">, </span><span style="color: #F69D50">interpolation</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&#39;none&#39;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">    plt.title(</span><span style="color: #96D0FF">&quot;Prediction: </span><span style="color: #F47067">{}</span><span style="color: #96D0FF">&quot;</span><span style="color: #ADBAC7">.format(output.data.max(</span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">, </span><span style="color: #F69D50">keepdim</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">True</span><span style="color: #ADBAC7">)[</span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">][i].item()))</span></span>
<span class="line"><span style="color: #ADBAC7">    plt.xticks([])</span></span>
<span class="line"><span style="color: #ADBAC7">    plt.yticks([])</span></span>
<span class="line"><span style="color: #ADBAC7">plt.show()</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">model.eval()</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D73A49">with</span><span style="color: #24292E"> torch.no_grad():</span></span>
<span class="line"><span style="color: #24292E">    output </span><span style="color: #D73A49">=</span><span style="color: #24292E"> model(example_data.to(</span><span style="color: #032F62">&quot;cuda&quot;</span><span style="color: #24292E">))</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">fig </span><span style="color: #D73A49">=</span><span style="color: #24292E"> plt.figure(</span><span style="color: #E36209">figsize</span><span style="color: #D73A49">=</span><span style="color: #24292E">(</span><span style="color: #005CC5">10</span><span style="color: #24292E">,</span><span style="color: #005CC5">4</span><span style="color: #24292E">))</span></span>
<span class="line"><span style="color: #D73A49">for</span><span style="color: #24292E"> i </span><span style="color: #D73A49">in</span><span style="color: #24292E"> </span><span style="color: #005CC5">range</span><span style="color: #24292E">(</span><span style="color: #005CC5">10</span><span style="color: #24292E">):</span></span>
<span class="line"><span style="color: #24292E">    plt.subplot(</span><span style="color: #005CC5">2</span><span style="color: #24292E">,</span><span style="color: #005CC5">5</span><span style="color: #24292E">,i</span><span style="color: #D73A49">+</span><span style="color: #005CC5">1</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">    plt.tight_layout()</span></span>
<span class="line"><span style="color: #24292E">    plt.imshow(example_data[i][</span><span style="color: #005CC5">0</span><span style="color: #24292E">], </span><span style="color: #E36209">cmap</span><span style="color: #D73A49">=</span><span style="color: #032F62">&#39;gray&#39;</span><span style="color: #24292E">, </span><span style="color: #E36209">interpolation</span><span style="color: #D73A49">=</span><span style="color: #032F62">&#39;none&#39;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">    plt.title(</span><span style="color: #032F62">&quot;Prediction: </span><span style="color: #005CC5">{}</span><span style="color: #032F62">&quot;</span><span style="color: #24292E">.format(output.data.max(</span><span style="color: #005CC5">1</span><span style="color: #24292E">, </span><span style="color: #E36209">keepdim</span><span style="color: #D73A49">=</span><span style="color: #005CC5">True</span><span style="color: #24292E">)[</span><span style="color: #005CC5">1</span><span style="color: #24292E">][i].item()))</span></span>
<span class="line"><span style="color: #24292E">    plt.xticks([])</span></span>
<span class="line"><span style="color: #24292E">    plt.yticks([])</span></span>
<span class="line"><span style="color: #24292E">plt.show()</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br></div></div><p><img src="./assets/handson-jupyter/mnist_prediction.png" alt="学習した CNN による，MNIST画像の推論結果"></p>
<p>最後に，学習したニューラルネットワークのパラメータを <code>mnist_cnn.pt</code> というファイル名で保存しておこう． これで，将来いつでも今回学習したモデルを再現し，別の実験に使用することができる．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">torch.save(model.state_dict(), </span><span style="color: #96D0FF">&quot;mnist_cnn.pt&quot;</span><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">torch.save(model.state_dict(), </span><span style="color: #032F62">&quot;mnist_cnn.pt&quot;</span><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>以上が， AWS クラウドの仮想サーバーを立ち上げ，最初のディープラーニングの計算を行う一連の流れである． MNIST 文字認識のタスクを行うニューラルネットを，クラウド上の GPU を使って高速に学習させ，現実的な問題を一つ解くことができたのである． 興味のある読者は，今回のハンズオンを雛形に，自分の所望の計算を走らせてみるとよいだろう．</p>
<h2 id="スタックの削除" tabindex="-1">スタックの削除 <a class="header-anchor" href="#スタックの削除" aria-label="Permalink to &quot;スタックの削除&quot;">&ZeroWidthSpace;</a></h2>
<p>これにて，ハンズオン第二回の内容はすべて説明した． クラウドの利用料金を最小化するため，使い終わった EC2 インスタンスはすぐさま削除しよう．</p>
<p>ハンズオン第一回と同様に， AWS の CloudFormation コンソールか， AWS CLI により削除を実行する (詳細は <a href="#handson_01_delete_stack">スタックを削除</a> 参照)．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cdk</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">destroy</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cdk</span><span style="color: #24292E"> </span><span style="color: #032F62">destroy</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p><strong>スタックの削除は各自で必ず行うこと！</strong> 行わなかった場合，EC2 インスタンスの料金が発生し続けることになる！ <code>g4dn.xlarge</code> は $0.71 / hour の料金設定なので，一日起動しつづけると約$17 の請求が発生することになる！</p>
<p><strong>AWS のバジェットアラート</strong></p>
<p>AWS の初心者が (あるいは経験者も) しばしば陥る失敗が，インスタンスの停止忘れなどで無駄なリソースがクラウドで放置されてしまい，巨大な額の請求が届く，というミスだ． 特に，開発を行っている間はこのような事態は起こりうるものだと思って，備えておかなければならない． このような事態を未然に防ぐため， AWS Budgets という機能が無料で提供されている． AWS Budgets を利用することで，月の利用金額がある閾値を超えた場合にユーザーにメールが送信される，などのアラートを設定することができる． 詳細な手順は <a href="https://aws.amazon.com/blogs/aws-cost-management/getting-started-with-aws-budgets/" target="_blank" rel="noreferrer">AWS の公式ブログ &quot;Getting Started with AWS Budgets&quot;</a> を参照のこと． 本書の読者も，ぜひこのタイミングでアラートを設定しておくことを推奨する．</p>
<h1 id="docker-入門" tabindex="-1">Docker 入門 <a class="header-anchor" href="#docker-入門" aria-label="Permalink to &quot;Docker 入門&quot;">&ZeroWidthSpace;</a></h1>
<p>ここまでの章で扱ってきたハンズオンでは，<strong>単一のサーバー</strong>を立ち上げ，それに SSH でログインをして，コマンドを叩くことで計算を行ってきた． いわば，<em>パーソナルコンピュータの延長</em>のような形でクラウドを使ってきたわけである． このような，インターネットのどこからでもアクセスできるパーソナルコンピュータとしてのクラウドという使い方も，もちろん便利であるし，いろいろな応用の可能性がある． しかし，これだけではクラウドの本当の価値は十分に発揮されていないと言うべきだろう． <a href="#chap_cloud_basics">クラウド概論</a> で述べたように，現代的なクラウドの一番の強みは自由に計算機の規模を拡大できることにある． すなわち，<strong>多数のサーバーを同時に起動し，複数のジョブを分散並列的に実行させることで大量のデータを処理してこそ，クラウドの本領が発揮される</strong>のである．</p>
<p>本章からはじまる 3 章分 (<a href="#sec_docker_introduction">Docker 入門</a>, <a href="#sec_fargate_qabot">Hands-on #3: AWS で自動質問回答ボットを走らせる</a>, <a href="#sec_aws_batch">Hands-on #4: AWS Batch を使って機械学習のハイパーパラメータサーチを並列化する</a>) を使って，クラウドを利用することでどのように大規模な計算システムを構築しビッグデータの解析に立ち向かうのか，その片鱗をお見せしたい． とくに，前章で扱った深層学習をどのようにビッグデータに適用していくかという点に焦点を絞って議論していきたい． そのための前準備として，本章では <a href="https://www.docker.com/" target="_blank" rel="noreferrer">Docker</a> とよばれる計算機環境の仮想化ソフトウェアを紹介する (<a href="#fig:docker_logo">figure_title</a>)． 現代のクラウドは Docker なしには成り立たないといっても過言ではないだろう． クラウドに限らず，ローカルで行う計算処理にも Docker は大変便利である． AWS からは少し話が離れるが，しっかりと理解して前に進んでもらいたい．</p>
<h2 id="機械学習の大規模化" tabindex="-1">機械学習の大規模化 <a class="header-anchor" href="#機械学習の大規模化" aria-label="Permalink to &quot;機械学習の大規模化&quot;">&ZeroWidthSpace;</a></h2>
<p>先ほどから&quot;計算システムの大規模化&quot;と繰り返し唱えているが，それは具体的にはどのようなものを指しているのか？ ここでは大規模データを処理するための計算機システムを，機械学習を例にとって見てみよう．</p>
<p><a href="#sec_scientific_computing">クラウドで行う科学計算・機械学習</a> で紹介した <a href="https://github.com/openai/gpt-3" target="_blank" rel="noreferrer">GPT-3</a> のような，超巨大な数のパラメータを有する深層学習モデルを学習させたいとしよう． そのような計算を行いたい場合，一つのサーバーでは計算力が到底足りない． したがって，典型的には <a href="#big_dnn_training">figure_title</a> に示すような計算システムの設計がなされる． すなわち，大量の教師データを小さなチャンクとして複数のマシンに分散し，並列的にニューラルネットのパラメータを最適化していくという構造である．</p>
<p><img src="./assets/big_dnn_training.png" alt="複数の計算機を使った大規模な深層学習モデルの訓練"></p>
<p>あるいは，学習済みのモデルを大量のデータに適用し，解析を行いたいとしよう． たとえば， SNS のプラットフォームで大量の画像が与えられて，それぞれの写真に何が写っているのかをラベルづけする，などのアプリケーションを想定できる． そのような場合は， <a href="#big_dnn_inference">figure_title</a> のようなアーキテクチャが考えられるだろう． すなわち，大量のデータを複数のマシンで分割し，それぞれのマシンで推論の計算を行うというような構造である．</p>
<p><img src="./assets/big_dnn_inference.png" alt="複数の計算機による深層学習モデルを使った推論計算"></p>
<p>このような複数の計算機を同時に走らせるようなアプリケーションをクラウド上で実現するには，どのようにすればよいのだろうか？</p>
<p>重要なポイントとして， <a href="#big_dnn_training">figure_title</a> や <a href="#big_dnn_inference">figure_title</a> で起動している複数のマシンは，<strong>基本的に全く同一の OS・計算環境を有している</strong>点である． ここで，個人のコンピュータで行うようなインストールの操作を，各マシンで行うこともできるが，それは大変な手間であるし，メンテナンスも面倒だろう． すなわち，大規模な計算システムを構築するには，<strong>簡単に計算環境を複製できるような仕組み</strong>が必要であるということがわかる．</p>
<p>そのような目的を実現するために使われるのが， <a href="https://www.docker.com/" target="_blank" rel="noreferrer">Docker</a> とよばれるソフトウェアである．</p>
<h2 id="docker-とは" tabindex="-1">Docker とは <a class="header-anchor" href="#docker-とは" aria-label="Permalink to &quot;Docker とは&quot;">&ZeroWidthSpace;</a></h2>
<p><img src="./assets/docker_log.png" alt="Docker のアイコン"></p>
<p>Docker とは， <strong>コンテナ (Container)</strong> とよばれる仮想環境下で，ホスト OS とは独立した別の計算環境を走らせるためのソフトウェアである． Docker を使うことで， OS を含めたすべてのプログラムをコンパクトにパッケージングすることが可能になる (パッケージされた一つの計算環境のことを **イメージ (Image)**とよぶ)． Docker を使うことで，クラウドのサーバー上に瞬時に計算環境を複製することが可能になり， <a href="#big_dnn_inference">figure_title</a> で見たような複数の計算機を同時に走らせるためのシステムが実現できる．</p>
<p>Docker は 2013 年に Solomon Hykes らを中心に開発され，それ以降爆発的に普及し，クラウドコンピューティングだけでなく，機械学習・科学計算の文脈などでも欠かすことのできないソフトウェアとなった． Docker はエンタープライズ向けの製品を除き無料で使用することができ，コアの部分は <a href="https://github.com/moby/moby" target="_blank" rel="noreferrer">オープンソースプロジェクト</a> として公開されている． Docker は Linux, Windows, Mac いずれの OS でも提供されている． 概念としては， Docker は仮想マシン (Virtual machine; VM) にとても近い． ここでは， VM との対比をしながら，Docker とはなにかを簡単に説明しよう．</p>
<p>仮想マシン (VM) とは，ホストとなるマシンの上に，仮想化された OS を走らせる技術である (<a href="#docker_vs_vm">figure_title</a>)． VM には <strong>ハイパーバイザー (Hypervisor)</strong> とよばれるレイヤーが存在する． Hypervisor はまず，物理的な計算機リソース (CPU, RAM, network など) を分割し，仮想化する． たとえば， ホストマシンに物理的な CPU が 4 コアあるとして，ハイパーバイザーはそれを (2,2) 個の組に仮想的に分割することができる． VM 上で起動する OS には，ハイパーバイザーによって仮想化されたハードウェアが割り当てられる． VM 上で起動する OS は基本的に完全に独立であり，たとえば OS-A は OS-B に割り当てられた CPU やメモリー領域にアクセスすることはできない (これを isolation とよぶ)． VM を作成するための有名なソフトウェアとしては， <a href="https://www.vmware.com/" target="_blank" rel="noreferrer">VMware</a>， <a href="https://www.virtualbox.org/" target="_blank" rel="noreferrer">VirtualBox</a>， <a href="https://xenproject.org/" target="_blank" rel="noreferrer">Xen</a> などがある． また，これまで触ってきた EC2 も，基本的に VM 技術を使うことで所望のスペックをもった仮想マシンがユーザーに提示される．</p>
<p>Docker も， VM と同様に，仮想化された OS をホストの OS 上に走らせるための技術である． VM に対し， Docker ではハードウェアレベルの仮想化は行われておらず，すべての<strong>仮想化はソフトウェアレベルで実現されている</strong> (<a href="#docker_vs_vm">figure_title</a>)． Docker で走る仮想 OS は，<strong>多くの部分をホストの OS に依存しており，結果として非常にコンパクトである</strong>． その結果， Docker で仮想 OS を起動するために要する時間は， VM に比べて圧倒的に早い． また， パッケージ化された環境 (=イメージ) のサイズも完全な OS に比べ圧倒的に小さくなるので，ネットワークを通じたやり取りが非常に高速化される点も重要である 加えて， VM のいくつかの実装では，メタル (仮想化マシンに対して，物理的なハードウェア上で直接起動する場合のこと) と比べ，ハイパーバイザーレイヤーでのオーバーヘッドなどにより性能が低下することが知られているが， Docker ではメタルとほぼ同様の性能を引き出すことができるとされている．</p>
<p>その他， VM との相違点などはたくさんあるのだが，ここではこれ以上詳細には立ち入らない． 大事なのは， <strong>Docker とはとてもコンパクトかつハイパフォーマンスな仮想計算環境を作るツールである</strong>，という点である． その手軽さゆえに，2013 年の登場以降，クラウドシステムでの利用が急速に増加し，現代のクラウドでは欠くことのできない中心的な技術になっている．</p>
<p><img src="./assets/docker_vs_vm.png" alt="Docker (左) と VM (右) の比較 (画像出典: https://www.docker.com/blog/containers-replacing-virtual-machines/)"></p>
<p>職業的プログラマーにとっての&quot;三種の神器&quot;とはなんだろうか？ 多様な意見があると思うが，筆者は <strong>Git</strong>, <strong>Vim</strong> そして <strong>Docker</strong> を挙げたい．</p>
<p>Git は多くの読者がご存じの通り，コードの変更を追跡するためのシステムである． Linux の作成者である Linus Torvalds によって 2005 年に誕生した． チームでの開発を進める際には欠かせないツールだ．</p>
<p>Vim は 1991 年から 30 年以上の間プログラマーたちに愛されてきたテキストエディターである． <a href="https://insights.stackoverflow.com/survey/2019#technology-development-environments-and-tools-all-respondents" target="_blank" rel="noreferrer">Stackoverflow が行った 2019 年のアンケート</a> によると，開発環境の部門で 5 位の人気を獲得している． たくさんのショートカットと様々なカスタム設定が提供されているので，初見の人にはなかなかハードルが高いが，一度マスターすれば他のモダンなエディターや統合開発環境に負けない，あるいはそれ以上の開発体験を実現することができる．</p>
<p>これらの十年以上の歴史あるツールに並んで，第三番目の三種の神器として挙げたいのが Docker だ． Docker はプログラマーの開発のワークフローを一変させた． たとえば，プロジェクトごとに Docker イメージを作成することで，どの OS・コンピュータ でも全く同じ計算環境で開発・テストを実行することができるようになった． また， <a href="https://en.wikipedia.org/wiki/DevOps" target="_blank" rel="noreferrer">DevOps</a> や <a href="https://en.wikipedia.org/wiki/Continuous_integration" target="_blank" rel="noreferrer">CI</a> / <a href="https://en.wikipedia.org/wiki/Continuous_delivery" target="_blank" rel="noreferrer">CD</a> (Continuous Integration / Continuous Deployment) といった最近の開発ワークフローも Docker のようなコンテナ技術の存在に立脚している． さらにはサーバーレスコンピューティング (<a href="#sec_serverless">Serverless architecture</a>) といった概念も，コンテナ技術の生んだ大きな技術革新といえる．</p>
<p>あなたにとっての三種の神器はなんだろうか？ また，これからの未来ではどんな新しいツールが三種の神器としてプログラマーのワークフローを革新していくだろうか？</p>
<h2 id="docker-チュートリアル" tabindex="-1">Docker チュートリアル <a class="header-anchor" href="#docker-チュートリアル" aria-label="Permalink to &quot;Docker チュートリアル&quot;">&ZeroWidthSpace;</a></h2>
<p>Docker とはなにかを理解するためには，実際に触って動かしてみるのが一番有効な手立てである． ここでは， Docker の簡単なチュートリアルを行っていく．</p>
<p>Docker のインストールについては， <a href="#sec:install_docker">Docker のインストール</a> および <a href="https://docs.docker.com/engine/install/" target="_blank" rel="noreferrer">公式のドキュメンテーション</a> を参照してもらいたい． Docker のインストールが完了している前提で，以下は話を進めるものとする．</p>
<h3 id="docker-用語集" tabindex="-1">Docker 用語集 <a class="header-anchor" href="#docker-用語集" aria-label="Permalink to &quot;Docker 用語集&quot;">&ZeroWidthSpace;</a></h3>
<p>Docker を使い始めるに当たり，最初に主要な用語を解説しよう． 次のパラグラフで太字で強調された用語を頭に入れた上で，続くチュートリアルに取り組んでいただきたい．</p>
<p>Docker を起動する際の大まかなステップを示したのが <a href="#fig:docker_image_container">figure_title</a> である． パッケージされた一つの計算環境のことを **イメージ (Image)**とよぶ． イメージは， Docker Hub などのリポジトリで配布されているものをダウンロードするか，自分でカスタムのイメージを作成することも可能である． イメージを作成するための”レシピ”を記述したファイルが <strong>Dockerfile</strong> である． Dockerfile からイメージを作成する操作を <strong>build</strong> とよぶ． イメージがホストマシンのメモリにロードされ，起動状態にある計算環境のことを <strong>コンテナ (Container)</strong> とよぶ． Container を起動するために使用されるコマンドが <strong>run</strong> である．</p>
<p><img src="./assets/docker_image_container.png" alt="Image と Container"></p>
<h3 id="イメージをダウンロード" tabindex="-1">イメージをダウンロード <a class="header-anchor" href="#イメージをダウンロード" aria-label="Permalink to &quot;イメージをダウンロード&quot;">&ZeroWidthSpace;</a></h3>
<p>パッケージ化された Docker の仮想環境 (= <strong>イメージ (Image)</strong>) は， <a href="https://hub.docker.com/" target="_blank" rel="noreferrer">Docker Hub</a> からダウンロードできる． Docker Hub には，個人や企業・団体が作成した Docker イメージが集められており， GitHub などと同じ感覚で，オープンな形で公開されている．</p>
<p>たとえば， Ubuntu のイメージは <a href="https://hub.docker.com/_/ubuntu" target="_blank" rel="noreferrer">Ubuntu の公式リポジトリ</a> で公開されており， <code>pull</code> コマンドを使うことでローカルにダウンロードすることができる．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">docker</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">pull</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ubuntu:18.04</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">docker</span><span style="color: #24292E"> </span><span style="color: #032F62">pull</span><span style="color: #24292E"> </span><span style="color: #032F62">ubuntu:18.04</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>ここで，イメージ名の <code>:</code> (コロン) 以降に続く文字列を <strong>タグ (tag)</strong> と呼び，主にバージョンを指定するなどの目的で使われる．</p>
<p><code>pull</code> コマンドはデフォルトでは Docker Hub でイメージを検索し，ダウンロードを行う． Docker イメージを公開するためのデータベース (レジストリ (registry) とよぶ) は Docker Hub だけではなく，たとえば GitLab や GitHub は独自のレジストリ機能を提供しているし，個人のサーバーでレジストリを立ち上げることも可能である． Docker Hub 以外のレジストリから pull するには， <code>myregistry.local:5000/testing/test-image</code> のように，イメージ名の先頭につける形でレジストリのアドレス (さらにオプションとしてポート番号) を指定する．</p>
<h3 id="コンテナを起動" tabindex="-1">コンテナを起動 <a class="header-anchor" href="#コンテナを起動" aria-label="Permalink to &quot;コンテナを起動&quot;">&ZeroWidthSpace;</a></h3>
<p>Pull してきたイメージを起動するには， <code>run</code> コマンドを使う．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">docker</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">run</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-it</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ubuntu:18.04</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">docker</span><span style="color: #24292E"> </span><span style="color: #032F62">run</span><span style="color: #24292E"> </span><span style="color: #005CC5">-it</span><span style="color: #24292E"> </span><span style="color: #032F62">ubuntu:18.04</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>ここで， <code>-it</code> とは，インタラクティブな shell のセッションを開始するために必要なオプションである．</p>
<p>このコマンドを実行すると，仮想化された Ubuntu が起動され，コマンドラインからコマンドが打ち込めるようになる (<a href="#docker_shell">figure_title</a>)． このように起動状態にある計算環境 (ランタイム) のことを <strong>Container (コンテナ)</strong> とよぶ．</p>
<p><img src="./assets/docker_shell.png" alt="Docker を使って ubuntu:18.04 イメージを起動"></p>
<p>ここで使用した <code>ubuntu:18.04</code> のイメージは，空の Ubuntu OS だが，すでにプログラムがインストール済みのものもある． これは， <a href="#sec_jupyter_and_deep_learning">Hands-on #2: AWS でディープラーニングを実践</a> でみた DLAMI と概念として似ている． たとえば， PyTorch がインストール済みのイメージは <a href="https://hub.docker.com/r/pytorch/pytorch" target="_blank" rel="noreferrer">PyTorch 公式の Docker Hub リポジトリ</a> で公開されている．</p>
<p>これを起動してみよう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">docker</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">run</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-it</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">pytorch/pytorch</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">docker</span><span style="color: #24292E"> </span><span style="color: #032F62">run</span><span style="color: #24292E"> </span><span style="color: #005CC5">-it</span><span style="color: #24292E"> </span><span style="color: #032F62">pytorch/pytorch</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p><code>docker run</code> を実行したとき，ローカルに該当するイメージが見つからない場合は，自動的に Docker Hub からダウンロードされる．</p>
<p>pytorch のコンテナが起動したら， Python のシェルを立ち上げて， pytorch をインポートしてみよう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python3</span></span>
<span class="line"><span style="color: #F69D50">Python</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">3.7</span><span style="color: #96D0FF">.7</span><span style="color: #ADBAC7"> (default, </span><span style="color: #96D0FF">May</span><span style="color: #ADBAC7">  </span><span style="color: #6CB6FF">7</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">2020</span><span style="color: #96D0FF">,</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">21</span><span style="color: #96D0FF">:25:33</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">[GCC </span><span style="color: #6CB6FF">7.3</span><span style="color: #ADBAC7">.0] :: Anaconda, Inc. on linux</span></span>
<span class="line"><span style="color: #F69D50">Type</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;help&quot;,</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;copyright&quot;,</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;credits&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">or</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;license&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">for</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">more</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">information.</span></span>
<span class="line"><span style="color: #ADBAC7">&gt;&gt;&gt; </span><span style="color: #F69D50">import</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">torch</span></span>
<span class="line"><span style="color: #ADBAC7">&gt;&gt;&gt; </span><span style="color: #DCBDFB">torch.cuda.is_available</span><span style="color: #ADBAC7">()</span></span>
<span class="line"><span style="color: #ADBAC7">False</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python3</span></span>
<span class="line"><span style="color: #6F42C1">Python</span><span style="color: #24292E"> </span><span style="color: #005CC5">3.7</span><span style="color: #032F62">.7</span><span style="color: #24292E"> (default, </span><span style="color: #032F62">May</span><span style="color: #24292E">  </span><span style="color: #005CC5">7</span><span style="color: #24292E"> </span><span style="color: #005CC5">2020</span><span style="color: #032F62">,</span><span style="color: #24292E"> </span><span style="color: #005CC5">21</span><span style="color: #032F62">:25:33</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">[GCC </span><span style="color: #005CC5">7.3</span><span style="color: #24292E">.0] :: Anaconda, Inc. on linux</span></span>
<span class="line"><span style="color: #6F42C1">Type</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;help&quot;,</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;copyright&quot;,</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;credits&quot;</span><span style="color: #24292E"> </span><span style="color: #032F62">or</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;license&quot;</span><span style="color: #24292E"> </span><span style="color: #032F62">for</span><span style="color: #24292E"> </span><span style="color: #032F62">more</span><span style="color: #24292E"> </span><span style="color: #032F62">information.</span></span>
<span class="line"><span style="color: #24292E">&gt;&gt;&gt; </span><span style="color: #6F42C1">import</span><span style="color: #24292E"> </span><span style="color: #032F62">torch</span></span>
<span class="line"><span style="color: #24292E">&gt;&gt;&gt; </span><span style="color: #6F42C1">torch.cuda.is_available</span><span style="color: #24292E">()</span></span>
<span class="line"><span style="color: #24292E">False</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br></div></div><p>このように， Docker を使うことで簡単に特定の OS・プログラムの入った計算環境を再現することが可能になる．</p>
<h3 id="自分だけのイメージを作る" tabindex="-1">自分だけのイメージを作る <a class="header-anchor" href="#自分だけのイメージを作る" aria-label="Permalink to &quot;自分だけのイメージを作る&quot;">&ZeroWidthSpace;</a></h3>
<p>自分の使うソフトウェア・ライブラリがインストールされた，自分だけのイメージを作ることも可能である．</p>
<p>たとえば， <a href="https://hub.docker.com/repository/docker/tomomano/labc" target="_blank" rel="noreferrer">本書のハンズオン実行用に提供している docker イメージ</a> には， Python, Node.js, AWS CLI, AWS CDK などのソフトウェアがインストール済みであり，ダウンロードしてくるだけですぐにハンズオンのプログラムが実行できるようになっている．</p>
<p>カスタムの docker イメージを作るには， <code>Dockerfile</code> という名前のついたファイルを用意し，その中にどんなプログラムをインストールするかなどを記述していく．</p>
<p>具体例として，本書で提供している Docker イメージのレシピを見てみよう (<a href="https://github.com/andatoshiki/toshiki-notebookblob/main/docker/Dockerfile" target="_blank" rel="noreferrer">docker/Dockerfile</a>)．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #6CB6FF">FROM</span><span style="color: #ADBAC7"> node:</span><span style="color: #6CB6FF">12</span></span>
<span class="line"><span style="color: #6CB6FF">LABEL</span><span style="color: #ADBAC7"> maintainer</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;Tomoyuki Mano&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6CB6FF">RUN</span><span style="color: #ADBAC7"> apt</span><span style="color: #F47067">-</span><span style="color: #ADBAC7">get update \</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #FF938A; font-style: italic">&amp;&amp;</span><span style="color: #ADBAC7"> apt</span><span style="color: #F47067">-</span><span style="color: #ADBAC7">get install nano</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #6CB6FF">RUN</span><span style="color: #ADBAC7"> cd </span><span style="color: #F47067">/</span><span style="color: #ADBAC7">opt \</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #FF938A; font-style: italic">&amp;&amp;</span><span style="color: #ADBAC7"> curl </span><span style="color: #F47067">-</span><span style="color: #ADBAC7">q </span><span style="color: #96D0FF">&quot;https://www.python.org/ftp/python/3.7.6/Python-3.7.6.tgz&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">-</span><span style="color: #ADBAC7">o Python</span><span style="color: #F47067">-</span><span style="color: #6CB6FF">3.7</span><span style="color: #ADBAC7">.6.tgz \</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #FF938A; font-style: italic">&amp;&amp;</span><span style="color: #ADBAC7"> tar </span><span style="color: #F47067">-</span><span style="color: #ADBAC7">xzf Python</span><span style="color: #F47067">-</span><span style="color: #6CB6FF">3.7</span><span style="color: #ADBAC7">.6.tgz \</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #FF938A; font-style: italic">&amp;&amp;</span><span style="color: #ADBAC7"> cd Python</span><span style="color: #F47067">-</span><span style="color: #6CB6FF">3.7</span><span style="color: #ADBAC7">.6 \</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #FF938A; font-style: italic">&amp;&amp;</span><span style="color: #ADBAC7"> .</span><span style="color: #F47067">/</span><span style="color: #ADBAC7">configure </span><span style="color: #FF938A; font-style: italic">--</span><span style="color: #ADBAC7">enable</span><span style="color: #F47067">-</span><span style="color: #ADBAC7">optimizations \</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #FF938A; font-style: italic">&amp;&amp;</span><span style="color: #ADBAC7"> make install</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6CB6FF">RUN</span><span style="color: #ADBAC7"> cd </span><span style="color: #F47067">/</span><span style="color: #ADBAC7">opt \</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #FF938A; font-style: italic">&amp;&amp;</span><span style="color: #ADBAC7"> curl </span><span style="color: #96D0FF">&quot;https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">-</span><span style="color: #ADBAC7">o </span><span style="color: #96D0FF">&quot;awscliv2.zip&quot;</span><span style="color: #ADBAC7"> \</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #FF938A; font-style: italic">&amp;&amp;</span><span style="color: #ADBAC7"> unzip awscliv2.zip \</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #FF938A; font-style: italic">&amp;&amp;</span><span style="color: #ADBAC7"> .</span><span style="color: #F47067">/</span><span style="color: #ADBAC7">aws</span><span style="color: #F47067">/</span><span style="color: #ADBAC7">install</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #6CB6FF">RUN</span><span style="color: #ADBAC7"> npm install </span><span style="color: #F47067">-</span><span style="color: #ADBAC7">g aws</span><span style="color: #F47067">-</span><span style="color: #ADBAC7">cdk</span><span style="color: #F47067">@</span><span style="color: #6CB6FF">1.100</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># clean up unnecessary files</span></span>
<span class="line"><span style="color: #6CB6FF">RUN</span><span style="color: #ADBAC7"> rm </span><span style="color: #F47067">-</span><span style="color: #ADBAC7">rf </span><span style="color: #F47067">/</span><span style="color: #ADBAC7">opt</span><span style="color: #F47067">/*</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># copy hands-on source code in /root/</span></span>
<span class="line"><span style="color: #6CB6FF">COPY</span><span style="color: #ADBAC7"> handson</span><span style="color: #F47067">/</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">/</span><span style="color: #ADBAC7">root</span><span style="color: #F47067">/</span><span style="color: #ADBAC7">handson</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #005CC5">FROM</span><span style="color: #24292E"> node:</span><span style="color: #005CC5">12</span></span>
<span class="line"><span style="color: #005CC5">LABEL</span><span style="color: #24292E"> maintainer</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;Tomoyuki Mano&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #005CC5">RUN</span><span style="color: #24292E"> apt</span><span style="color: #D73A49">-</span><span style="color: #24292E">get update \</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #B31D28; font-style: italic">&amp;&amp;</span><span style="color: #24292E"> apt</span><span style="color: #D73A49">-</span><span style="color: #24292E">get install nano</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #005CC5">RUN</span><span style="color: #24292E"> cd </span><span style="color: #D73A49">/</span><span style="color: #24292E">opt \</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #B31D28; font-style: italic">&amp;&amp;</span><span style="color: #24292E"> curl </span><span style="color: #D73A49">-</span><span style="color: #24292E">q </span><span style="color: #032F62">&quot;https://www.python.org/ftp/python/3.7.6/Python-3.7.6.tgz&quot;</span><span style="color: #24292E"> </span><span style="color: #D73A49">-</span><span style="color: #24292E">o Python</span><span style="color: #D73A49">-</span><span style="color: #005CC5">3.7</span><span style="color: #24292E">.6.tgz \</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #B31D28; font-style: italic">&amp;&amp;</span><span style="color: #24292E"> tar </span><span style="color: #D73A49">-</span><span style="color: #24292E">xzf Python</span><span style="color: #D73A49">-</span><span style="color: #005CC5">3.7</span><span style="color: #24292E">.6.tgz \</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #B31D28; font-style: italic">&amp;&amp;</span><span style="color: #24292E"> cd Python</span><span style="color: #D73A49">-</span><span style="color: #005CC5">3.7</span><span style="color: #24292E">.6 \</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #B31D28; font-style: italic">&amp;&amp;</span><span style="color: #24292E"> .</span><span style="color: #D73A49">/</span><span style="color: #24292E">configure </span><span style="color: #B31D28; font-style: italic">--</span><span style="color: #24292E">enable</span><span style="color: #D73A49">-</span><span style="color: #24292E">optimizations \</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #B31D28; font-style: italic">&amp;&amp;</span><span style="color: #24292E"> make install</span></span>
<span class="line"></span>
<span class="line"><span style="color: #005CC5">RUN</span><span style="color: #24292E"> cd </span><span style="color: #D73A49">/</span><span style="color: #24292E">opt \</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #B31D28; font-style: italic">&amp;&amp;</span><span style="color: #24292E"> curl </span><span style="color: #032F62">&quot;https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip&quot;</span><span style="color: #24292E"> </span><span style="color: #D73A49">-</span><span style="color: #24292E">o </span><span style="color: #032F62">&quot;awscliv2.zip&quot;</span><span style="color: #24292E"> \</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #B31D28; font-style: italic">&amp;&amp;</span><span style="color: #24292E"> unzip awscliv2.zip \</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #B31D28; font-style: italic">&amp;&amp;</span><span style="color: #24292E"> .</span><span style="color: #D73A49">/</span><span style="color: #24292E">aws</span><span style="color: #D73A49">/</span><span style="color: #24292E">install</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #005CC5">RUN</span><span style="color: #24292E"> npm install </span><span style="color: #D73A49">-</span><span style="color: #24292E">g aws</span><span style="color: #D73A49">-</span><span style="color: #24292E">cdk</span><span style="color: #D73A49">@</span><span style="color: #005CC5">1.100</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># clean up unnecessary files</span></span>
<span class="line"><span style="color: #005CC5">RUN</span><span style="color: #24292E"> rm </span><span style="color: #D73A49">-</span><span style="color: #24292E">rf </span><span style="color: #D73A49">/</span><span style="color: #24292E">opt</span><span style="color: #D73A49">/*</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># copy hands-on source code in /root/</span></span>
<span class="line"><span style="color: #005CC5">COPY</span><span style="color: #24292E"> handson</span><span style="color: #D73A49">/</span><span style="color: #24292E"> </span><span style="color: #D73A49">/</span><span style="color: #24292E">root</span><span style="color: #D73A49">/</span><span style="color: #24292E">handson</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br></div></div><p><code>Dockerfile</code> の中身の説明は詳しくは行わないが，たとえば上のコードで &lt;1&gt; で示したところは， Python 3.7 のインストールを実行している． また， &lt;2&gt; で示したところは， AWS CDK のインストールを行っていることがわかるだろう． このように，リアルな OS で行うのと同じ流れでインストールのコマンドを逐一記述していくことで，自分だけの Docker イメージを作成することができる． 一度イメージを作成すれば，それを配布することで，他者も同一の計算環境を簡単に再構成することができる．</p>
<p>&quot;ぼくの環境ではそのプログラム走ったのにな…&quot; というのは，プログラミング初心者ではよく耳にする会話だが， Docker を使いこなせばそのような心配とは無縁である． そのような意味で，クラウド以外の場面でも， Docker の有用性・汎用性は極めて高い．</p>
<p>コンテナを用いた仮想計算環境ツールとして Docker を紹介したが， ほかに選択肢はないのか？ よくぞ聞いてくれた！ Docker の登場以降，複数のコンテナベースの仮想環境ツールが開発されてきた． いずれのツールも，概念や API については Docker と共通するものが多いが，Docker にはない独自の特徴を提供している． ここではその中でも有名ないくつかを紹介しよう．</p>
<p><a href="https://github.com/hpcng/singularity" target="_blank" rel="noreferrer">Singularity</a> は科学計算や HPC (High Performance Computing) の分野で人気の高いコンテナプラットフォームである． Singularity では大学・研究機関の HPC クラスターでの運用に適したような設計が施されている． たとえば， Docker は基本的には root 権限で実行されるのに対し， Singularity はユーザー権限 (コマンドを実行したユーザー自身) でプログラムが実行される． root 権限での実行は Web サーバーのように個人・企業がある特定のサービスのために運用するサーバーでは問題ないが，多数のユーザーが多様な目的で計算を実行する HPC クラスターでは問題となる． また，Singularity は独自のイメージの作成方法・エコシステムをもっているが， Docker イメージを Singularity のイメージに変換し実行する機能も有している．</p>
<p><a href="https://github.com/containers/podman" target="_blank" rel="noreferrer">podman</a> は Red Hat 社によって開発されたもう一つのコンテナプラットフォームである． podman は基本的に Docker と同一のコマンドを採用しているが，実装は Red Hat によってスクラッチから行われた． podman では， Singularity と同様にユーザー権限でのプログラムの実行を可能であり，クラウドおよび HPC の両方の環境に対応するコンテナプラットフォームを目指して作られた． また，その名前にあるとおり pod とよばれる独自の概念が導入されている．</p>
<p>著者の個人的な意見としては，現時点では Docker をマスターしておけば当面は困ることはないと考えるが，興味のある読者はぜひこれらのツールも試してみてはいかがだろうか？</p>
<h2 id="elastic-container-service-ecs" tabindex="-1">Elastic Container Service (ECS) <a class="header-anchor" href="#elastic-container-service-ecs" aria-label="Permalink to &quot;Elastic Container Service (ECS)&quot;">&ZeroWidthSpace;</a></h2>
<p><img src="./assets/aws_logos/ECS.png" alt="ECS のアイコン"></p>
<p>ここまでに説明してきたように， Docker を使うことで仮想計算環境を簡単に複製・起動することが可能になる． 本章の最後の話題として， AWS 上で Docker を使った計算システムを構築する方法を解説しよう．</p>
<p><strong>Elastic Container Service (ECS)</strong> とは， Docker を使った計算機クラスターを AWS 上に作成するためのツールである (<a href="#fig:logo_ecs">figure_title</a>)． ECS を使用することで， Docker にパッケージされたアプリケーションを計算機クラスターに投入したり，計算機クラスターのインスタンスを追加・削除する操作 (=スケーリング) を行うことができる．</p>
<p>ECS の概要を示したのが <a href="#ecs_overview">figure_title</a> である． ECS は，<strong>タスク (Task)</strong> と呼ばれる単位で管理された計算ジョブを受け付ける． システムにタスクが投入されると，ECS は最初にタスクで指定された Docker イメージを外部レジストリからダウンロードしてくる． 外部レジストリとしては， Docker Hub や AWS 独自の Docker レジストリである <strong>ECR (Elastic Container Registry)</strong> を指定することができる．</p>
<p>ECS の次の重要な役割はタスクの配置である． あらかじめ定義されたクラスター内で，計算負荷が小さい仮想インスタンスを選び出し，そこに Docker イメージを配置することで指定された計算タスクが開始される． &quot;計算負荷が小さい仮想インスタンスを選び出す&quot; と言ったが，具体的にどのような戦略・ポリシーでこの選択を行うかは，ユーザーの指定したパラメータに従う．</p>
<p>また，クラスターのスケーリングも ECS における重要な概念である． スケーリングとは，クラスター内のインスタンスの計算負荷をモニタリングし，計算負荷に応じてインスタンスの起動・停止を行う操作を指す． クラスター全体の計算負荷が指定された閾値 (たとえば 80%の稼働率) を超えていた場合，新たな仮想インスタンスをクラスター内に立ち上げる操作を scale-out (スケールアウト) とよび， 負荷が減った場合に不要なインスタンスを停止する操作を scale-in (スケールイン) とよぶ． クラスターのスケーリングは， ECS がほかの AWS のサービスと連携することで実現される． 具体的には， EC2 の <strong>Auto scaling group (ASG)</strong> や <strong>Fargate</strong> の２つの選択肢が多くの場合選択される． <strong>ASG</strong> については <a href="#sec_aws_batch">Hands-on #4: AWS Batch を使って機械学習のハイパーパラメータサーチを並列化する</a>, Fargate については <a href="#sec_fargate_qabot">Hands-on #3: AWS で自動質問回答ボットを走らせる</a> でより詳細に解説する．</p>
<p>これら一連のタスクの管理を， ECS は自動でやってくれる． クラスターのスケーリングやタスクの配置に関してのパラメータを一度指定してしまえば，ユーザーは (ほとんどなにも考えずに) 大量のタスクを投入することができる． クラスターのスケーリングによってタスクの量にちょうど十分なだけのインスタンスが起動し，タスクが完了した後は不要なインスタンスはすべて停止される．</p>
<p>さて，ここまで説明的な話が続いてしまったが，次章からは早速 Docker と AWS を使って大規模な並列計算システムを構築していこう！</p>
<p><img src="./assets/ecs.png" alt="ECS の概要"></p>
<h1 id="hands-on-3-aws-で自動質問回答ボットを走らせる" tabindex="-1">Hands-on #3: AWS で自動質問回答ボットを走らせる <a class="header-anchor" href="#hands-on-3-aws-で自動質問回答ボットを走らせる" aria-label="Permalink to &quot;Hands-on \#3: AWS で自動質問回答ボットを走らせる&quot;">&ZeroWidthSpace;</a></h1>
<p>ハンズオン第三回では， Docker と ECS を駆使した機械学習アプリケーションを実装しよう． 具体的には，深層学習による自然言語処理を行うことで，クライアントから与えられた文章題に対して回答を生成する，自動 Question &amp; Answering ボットを作成しよう． ECS を利用することで，ジョブの数によって動的にインスタンスの数を制御し，並列にタスクを実行するようなシステムを構築しよう．</p>
<p>通常の機械学習のワークフローでは，モデルの訓練 ⇒ 推論 (データへの適用) が基本的な流れである． しかしながら， GPU 搭載型の EC2 クラスターを使ったモデルの訓練はやや難易度が高いため，次章 (<a href="#sec_aws_batch">Hands-on #4: AWS Batch を使って機械学習のハイパーパラメータサーチを並列化する</a>) で取り扱う． 本章は，クラウド上でのクラスターの構築・タスクの管理などの概念に慣れるため，よりシンプルな実装で実現できる Fargate クラスターを用いた推論計算の並列化を紹介する．</p>
<h2 id="fargate" tabindex="-1">Fargate <a class="header-anchor" href="#fargate" aria-label="Permalink to &quot;Fargate&quot;">&ZeroWidthSpace;</a></h2>
<p>ハンズオンに入っていく前に， <strong>Fargate</strong> という AWS の機能を知っておく必要がある (<a href="#fig:fargate_logo">figure_title</a>)．</p>
<p><img src="./assets/aws_logos/Fargate.png" alt="Fargate のアイコン"></p>
<p>ECS の概要を示した <a href="#ecs_overview">figure_title</a> をもう一度見てみよう． この図で， ECS の管理下にあるクラスターが示されているが，このクラスターの中で計算を行う実体としては二つの選択肢がある． <strong>EC2 あるいは Fargate</strong> のいずれかである． EC2 を用いた場合は，先の章 (<a href="#sec_first_ec2">Hands-on #1: 初めての EC2 インスタンスを起動する</a>, <a href="#sec_jupyter_and_deep_learning">Hands-on #2: AWS でディープラーニングを実践</a>) で説明したような流れでインスタンスが起動し，計算が実行される． しかし， EC2 を用いた計算機クラスターの作成・管理は技術的な難易度がやや高いので，次章 (<a href="#sec_aws_batch">Hands-on #4: AWS Batch を使って機械学習のハイパーパラメータサーチを並列化する</a>) で説明することにする．</p>
<p>Fargate とは， <strong>ECS での利用に特化</strong>して設計された，<strong>コンテナを使用した計算タスク</strong>を走らせるための仕組みである． 計算を走らせるという点では EC2 と役割は似ているが， Fargate は EC2 インスタンスのような物理的実体はもたない． 物理的実体をもたないというのは，たとえば SSH でログインすることは基本的に想定されていないし，なにかのソフトウェアをインストールしたりなどの概念も存在しない． Fargate ではすべての計算は Docker コンテナを介して行われる． すなわち， Fargate を利用するには，ユーザーは最初に所望の Docker イメージを指定しておき， Fargate は <code>docker run</code> のコマンドを使用することで計算タスクを実行する． Fargate を用いる利点は， Fargate を ECS のクラスターに指定すると，スケーリングなどの操作が簡単な設定・プログラムで構築できる点である．</p>
<p>Fargate では， EC2 と同様に CPU とメモリーのサイズを必要な分だけ指定できる． 執筆時点では， CPU は 0.25 - 4 コア， RAM は 0.5 - 30 GB の間で選択することができる (詳しくは <a href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/AWS_Fargate.html" target="_blank" rel="noreferrer">公式ドキュメンテーション &quot;Amazon ECS on AWS Fargate&quot;</a> 参照)． クラスターのスケーリングが容易な分， Fargate では EC2 ほど大きな CPU コア・ RAM 容量を単一インスタンスに付与することができず，また GPU を利用することもできない．</p>
<p>以上が Fargate の概要であったが，くどくど言葉で説明してもなかなかピンとこないだろう． ここからは実際に手を動かしながら， ECS と Fargate を使った並列タスクの処理の仕方を学んでいこう．</p>
<p>厳密には， ECS に付与するクラスターには EC2 と Fargate のハイブリッドを使用することも可能である．</p>
<h2 id="準備-2" tabindex="-1">準備 <a class="header-anchor" href="#準備-2" aria-label="Permalink to &quot;準備&quot;">&ZeroWidthSpace;</a></h2>
<p>ハンズオンのソースコードは GitHub の <a href="https://github.com/andatoshiki/toshiki-notebooktree/main/handson/qa-bot" target="_blank" rel="noreferrer">handson/qa-bot</a> にある．</p>
<p>本ハンズオンの実行には，第一回ハンズオンで説明した準備 (<a href="#handson_01_prep">準備</a>) が整っていることを前提とする． また， Docker が自身のローカルマシンにインストール済みであることも必要である．</p>
<p>このハンズオンでは 1CPU/4GB RAM の Fargate インスタンスを使用する． 計算の実行には 0.025 $/hour のコストが発生することに注意．</p>
<h2 id="transformer-を用いた-question-answering-プログラム" tabindex="-1">Transformer を用いた question-answering プログラム <a class="header-anchor" href="#transformer-を用いた-question-answering-プログラム" aria-label="Permalink to &quot;Transformer を用いた question-answering プログラム&quot;">&ZeroWidthSpace;</a></h2>
<p>このハンズオンで開発する，自動質問回答システムをより具体的に定義しよう． 次のような文脈 (context) と質問 (question) が与えられた状況を想定する．</p>
<div class="language-txt vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">txt</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #adbac7">context: Albert Einstein (14 March 1879 – 18 April 1955) was a German-born theoretical physicist who developed the theory of relativity, one of the two pillars of modern physics (alongside quantum mechanics). His work is also known for its influence on the philosophy of science. He is best known to the general public for his mass–energy equivalence formula E = mc2, which has been dubbed \&quot;the world&#39;s most famous equation\&quot;. He received the 1921 Nobel Prize in Physics \&quot;for his services to theoretical physics, and especially for his discovery of the law of the photoelectric effect\&quot;, a pivotal step in the development of quantum theory.</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">question: In what year did Einstein win the Nobel prize?</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292e">context: Albert Einstein (14 March 1879 – 18 April 1955) was a German-born theoretical physicist who developed the theory of relativity, one of the two pillars of modern physics (alongside quantum mechanics). His work is also known for its influence on the philosophy of science. He is best known to the general public for his mass–energy equivalence formula E = mc2, which has been dubbed \&quot;the world&#39;s most famous equation\&quot;. He received the 1921 Nobel Prize in Physics \&quot;for his services to theoretical physics, and especially for his discovery of the law of the photoelectric effect\&quot;, a pivotal step in the development of quantum theory.</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">question: In what year did Einstein win the Nobel prize?</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><p>今回作成する自動回答システムは，このような問題に対して， context に含まれる文字列から正解となる言葉を見つけ出すものとする． 上の問題では，次のような回答を返すべきである．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">answer:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">1921</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">answer:</span><span style="color: #24292E"> </span><span style="color: #005CC5">1921</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>人間にとっては，このような文章を理解することは容易であるが，コンピュータにそれを解かせるのは難しいことは容易に想像ができるだろう． しかし，近年の深層学習を使った自然言語処理の進歩は著しく，上で示したような例題などは極めて高い正答率で回答できるモデルを作ることができる．</p>
<p>今回は， <a href="https://github.com/huggingface/transformers" target="_blank" rel="noreferrer">huggingface/transformers</a> で公開されている学習済みの言語モデルを利用することで，上で定義した問題を解く Q&amp;A ボットを作る． この Q&amp;A ボットは <a href="https://en.wikipedia.org/wiki/Transformer_(machine_learning_model)" target="_blank" rel="noreferrer">Transformer</a> とよばれるモデルを使った自然言語処理に支えられえている (<a href="#transformer_architecture">figure_title</a>)． このプログラムを， Docker にパッケージしたものが <a href="https://hub.docker.com/repository/docker/tomomano/qabot" target="_blank" rel="noreferrer">著者の Docker Hub リポジトリ</a> に用意してある． クラウドの設計に入る前に，まずはこのプログラムを単体で動かしてみよう．</p>
<p><img src="./assets/transformer.png" alt="Transformer モデルアーキテクチャ (画像出典: Vaswani+ 2017)"></p>
<p>なお，今回は学習済みのモデルを用いているので，私達が行うのは与えられた入力をモデルに投入して予測を行う (推論) のみである． 推論の演算は， CPU だけでも十分高速に行うことができるので，コストの削減と，実装をシンプルにする目的で，このハンズオンでは GPU は利用しない． 一般的に， ニューラルネットは学習のほうが圧倒的に計算コストが大きく，そのような場合に GPU はより威力を発揮する．</p>
<p>次のコマンドで，今回使う Docker image を ローカルにダウンロード (pull) してこよう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">docker</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">pull</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">tomomano/qabot:latest</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">docker</span><span style="color: #24292E"> </span><span style="color: #032F62">pull</span><span style="color: #24292E"> </span><span style="color: #032F62">tomomano/qabot:latest</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>pull できたら，早速この Docker に質問を投げかけてみよう． まずは context と question をコマンドラインの変数として定義する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">context=&quot;Albert Einstein (14 March 1879 – 18 April 1955) was a German-born theoretical physicist who developed the theory of relativity, one of the two pillars of modern physics (alongside quantum mechanics). His work is also known for its influence on the philosophy of science. He is best known to the general public for his mass–energy equivalence formula E = mc2, which has been dubbed the world&#39;s most famous equation. He received the 1921 Nobel Prize in Physics for his services to theoretical physics, and especially for his discovery of the law of the photoelectric effect, a pivotal step in the development of quantum theory.&quot;</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">question=&quot;In what year did Einstein win the Nobel prize ?&quot;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">context=&quot;Albert Einstein (14 March 1879 – 18 April 1955) was a German-born theoretical physicist who developed the theory of relativity, one of the two pillars of modern physics (alongside quantum mechanics). His work is also known for its influence on the philosophy of science. He is best known to the general public for his mass–energy equivalence formula E = mc2, which has been dubbed the world&#39;s most famous equation. He received the 1921 Nobel Prize in Physics for his services to theoretical physics, and especially for his discovery of the law of the photoelectric effect, a pivotal step in the development of quantum theory.&quot;</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">question=&quot;In what year did Einstein win the Nobel prize ?&quot;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>そうしたら，次のコマンドによってコンテナを実行する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">docker</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">run</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">tomomano/qabot</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;${</span><span style="color: #ADBAC7">context</span><span style="color: #96D0FF">}&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;${</span><span style="color: #ADBAC7">question</span><span style="color: #96D0FF">}&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">foo</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--no_save</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">docker</span><span style="color: #24292E"> </span><span style="color: #032F62">run</span><span style="color: #24292E"> </span><span style="color: #032F62">tomomano/qabot</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;${</span><span style="color: #24292E">context</span><span style="color: #032F62">}&quot;</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;${</span><span style="color: #24292E">question</span><span style="color: #032F62">}&quot;</span><span style="color: #24292E"> </span><span style="color: #032F62">foo</span><span style="color: #24292E"> </span><span style="color: #005CC5">--no_save</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>今回用意した Docker image は，第一引数に context となる文字列を，第二引数に question に相当する文字列を受けつける． 第三引数，第四引数については，クラウドに展開するときの実装上の都合なので，いまは気にしなくてよい．</p>
<p>このコマンドを実行すると，次のような出力が得られるはずである．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">{</span><span style="color: #F69D50">&#39;score&#39;</span><span style="color: #6CB6FF">:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0.9881729286683587</span><span style="color: #96D0FF">,</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;start&#39;:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">437</span><span style="color: #96D0FF">,</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;end&#39;:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">441</span><span style="color: #96D0FF">,</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;answer&#39;:</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;1921&#39;}</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">{</span><span style="color: #6F42C1">&#39;score&#39;</span><span style="color: #005CC5">:</span><span style="color: #24292E"> </span><span style="color: #005CC5">0.9881729286683587</span><span style="color: #032F62">,</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;start&#39;:</span><span style="color: #24292E"> </span><span style="color: #005CC5">437</span><span style="color: #032F62">,</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;end&#39;:</span><span style="color: #24292E"> </span><span style="color: #005CC5">441</span><span style="color: #032F62">,</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;answer&#39;:</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;1921&#39;}</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>&quot;score&quot; は正解の自信度を表す数字で， [0,1] の範囲で与えられる． &quot;start&quot;, &quot;end&quot; は， context 中の何文字目が正解に相当するかを示しており， &quot;answer&quot; が正解と予測された文字列である． 1921 年という，正しい答えが返ってきていることに注目してほしい．</p>
<p>もう少し難しい質問を投げかけてみよう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">question=&quot;Why did Einstein win the Nobel prize ?&quot;</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">docker</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">run</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">tomomano/qabot</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;${</span><span style="color: #ADBAC7">context</span><span style="color: #96D0FF">}&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;${</span><span style="color: #ADBAC7">question</span><span style="color: #96D0FF">}&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">foo</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--no_save</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">question=&quot;Why did Einstein win the Nobel prize ?&quot;</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">docker</span><span style="color: #24292E"> </span><span style="color: #032F62">run</span><span style="color: #24292E"> </span><span style="color: #032F62">tomomano/qabot</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;${</span><span style="color: #24292E">context</span><span style="color: #032F62">}&quot;</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;${</span><span style="color: #24292E">question</span><span style="color: #032F62">}&quot;</span><span style="color: #24292E"> </span><span style="color: #032F62">foo</span><span style="color: #24292E"> </span><span style="color: #005CC5">--no_save</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>出力：</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">{</span><span style="color: #F69D50">&#39;score&#39;</span><span style="color: #6CB6FF">:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0.5235594527494207</span><span style="color: #96D0FF">,</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;start&#39;:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">470</span><span style="color: #96D0FF">,</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;end&#39;:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">506</span><span style="color: #96D0FF">,</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;answer&#39;:</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;his services to theoretical physics,&#39;}</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">{</span><span style="color: #6F42C1">&#39;score&#39;</span><span style="color: #005CC5">:</span><span style="color: #24292E"> </span><span style="color: #005CC5">0.5235594527494207</span><span style="color: #032F62">,</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;start&#39;:</span><span style="color: #24292E"> </span><span style="color: #005CC5">470</span><span style="color: #032F62">,</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;end&#39;:</span><span style="color: #24292E"> </span><span style="color: #005CC5">506</span><span style="color: #032F62">,</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;answer&#39;:</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;his services to theoretical physics,&#39;}</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>今度は， score が 0.52 と，少し自信がないようだが，それでも正しい答えにたどりつけていることがわかる．</p>
<p>このように， 深層学習に支えられた言語モデルを用いることで，実用にも役に立ちそうな Q&amp;A ボットを実現できていることがわかる． 以降では，このプログラムをクラウドに展開することで，大量の質問に自動で対応できるようなシステムを設計していく．</p>
<p>今回使用する Question &amp; Answering システムには， DistilBERT という Transformer を基にした言語モデルが用いられている． 興味のある読者は， <a href="https://arxiv.org/abs/1910.01108" target="_blank" rel="noreferrer">原著論文</a> を参照してもらいたい． また， huggingface/transformers による DistilBert の実装のドキュメンテーションは <a href="https://huggingface.co/transformers/model_doc/distilbert.html" target="_blank" rel="noreferrer">公式ドキュメンテーション</a> を参照のこと．</p>
<p>今回提供する Q-A ボットの Docker のソースコードは <a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/qa-bot/docker/Dockerfile" target="_blank" rel="noreferrer">https://github.com/andatoshiki/toshiki-notebookblob/main/handson/qa-bot/docker/Dockerfile</a> にある．</p>
<h2 id="アプリケーションの説明-2" tabindex="-1">アプリケーションの説明 <a class="header-anchor" href="#アプリケーションの説明-2" aria-label="Permalink to &quot;アプリケーションの説明&quot;">&ZeroWidthSpace;</a></h2>
<p>このハンズオンで作成するアプリケーションの概要を <a href="#handson_03_architecture">figure_title</a> に示す．</p>
<p><img src="./assets/handson-03/handson-03-architecture.png" alt="アプリケーションのアーキテクチャ"></p>
<p>簡単にまとめると，以下のような設計である．</p>
<ul>
<li>
<p>クライアントは，質問を AWS 上のアプリケーションに送信する．</p>
</li>
<li>
<p>質問のタスクは ECS によって処理される．</p>
</li>
<li>
<p>ECS は， Docker Hub から，イメージをダウンロードする．</p>
</li>
<li>
<p>次に，ECS はクラスター内に新たな Fargate インスタンスを立ち上げ，ダウンロードされた Docker イメージをこの新規インスタンスに配置する．</p>
<ul>
<li>このとき，一つの質問に対し一つの Fargate インスタンスを立ち上げることで，複数の質問を並列的に処理できるようにする．</li>
</ul>
</li>
<li>
<p>ジョブが実行される．</p>
</li>
<li>
<p>ジョブの実行結果 (質問への回答) は， データベース (DynamoDB) に書き込まれる．</p>
</li>
<li>
<p>最後に，クライアントは DynamoDB から質問への回答を読み取る．</p>
</li>
</ul>
<p>それでは，プログラムのソースコードを見てみよう (<a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/qa-bot/app.py" target="_blank" rel="noreferrer">handson/qa-bot/app.py</a>)．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">class</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">EcsClusterQaBot</span><span style="color: #ADBAC7">(</span><span style="color: #F69D50">core.Stack</span><span style="color: #ADBAC7">)</span><span style="color: #96D0FF">:</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">def</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">__init__</span><span style="color: #ADBAC7">(</span><span style="color: #F69D50">self,</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">scope:</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">core.App,</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">name:</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">str,</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">**</span><span style="color: #96D0FF">kwargs</span><span style="color: #ADBAC7">) -</span><span style="color: #F47067">&gt;</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">None:</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #DCBDFB">super</span><span style="color: #ADBAC7">().__init__(</span><span style="color: #F69D50">scope,</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">name,</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">**</span><span style="color: #96D0FF">kwargs</span><span style="color: #ADBAC7">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390"># dynamoDB table to store questions and answers</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #F69D50">table</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">dynamodb.Table</span><span style="color: #ADBAC7">(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">self,</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;EcsClusterQaBot-Table&quot;,</span></span>
<span class="line"><span style="color: #ADBAC7">            partition_key</span><span style="color: #F47067">=</span><span style="color: #96D0FF">dynamodb.Attribute</span><span style="color: #ADBAC7">(</span></span>
<span class="line"><span style="color: #ADBAC7">                name</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;item_id&quot;,</span><span style="color: #ADBAC7"> type</span><span style="color: #F47067">=</span><span style="color: #96D0FF">dynamodb.AttributeType.STRING</span></span>
<span class="line"><span style="color: #ADBAC7">            )</span><span style="color: #96D0FF">,</span></span>
<span class="line"><span style="color: #ADBAC7">            billing_mode</span><span style="color: #F47067">=</span><span style="color: #96D0FF">dynamodb.BillingMode.PAY_PER_REQUEST,</span></span>
<span class="line"><span style="color: #ADBAC7">            removal_policy</span><span style="color: #F47067">=</span><span style="color: #96D0FF">core.RemovalPolicy.DESTROY</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #F69D50">vpc</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ec2.Vpc</span><span style="color: #ADBAC7">(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">self,</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;EcsClusterQaBot-Vpc&quot;,</span></span>
<span class="line"><span style="color: #ADBAC7">            max_azs</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">1</span><span style="color: #96D0FF">,</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #F69D50">cluster</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ecs.Cluster</span><span style="color: #ADBAC7">(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">self,</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;EcsClusterQaBot-Cluster&quot;,</span></span>
<span class="line"><span style="color: #ADBAC7">            vpc</span><span style="color: #F47067">=</span><span style="color: #96D0FF">vpc,</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #F69D50">taskdef</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ecs.FargateTaskDefinition</span><span style="color: #ADBAC7">(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">self,</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;EcsClusterQaBot-TaskDef&quot;,</span></span>
<span class="line"><span style="color: #ADBAC7">            cpu</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">1024</span><span style="color: #96D0FF">,</span><span style="color: #ADBAC7"> </span><span style="color: #768390"># 1 CPU</span></span>
<span class="line"><span style="color: #ADBAC7">            memory_limit_mib</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">4096</span><span style="color: #96D0FF">,</span><span style="color: #ADBAC7"> </span><span style="color: #768390"># 4GB RAM</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390"># grant permissions</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #F69D50">table.grant_read_write_data(taskdef.task_role</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #F69D50">taskdef.add_to_task_role_policy(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">iam.PolicyStatement(</span></span>
<span class="line"><span style="color: #ADBAC7">                effect</span><span style="color: #F47067">=</span><span style="color: #96D0FF">iam.Effect.ALLOW,</span></span>
<span class="line"><span style="color: #ADBAC7">                resources</span><span style="color: #F47067">=</span><span style="color: #96D0FF">[&quot;*&quot;],</span></span>
<span class="line"><span style="color: #ADBAC7">                actions</span><span style="color: #F47067">=</span><span style="color: #96D0FF">[&quot;ssm:GetParameter&quot;]</span></span>
<span class="line"><span style="color: #ADBAC7">            )</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #F69D50">container</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">taskdef.add_container</span><span style="color: #ADBAC7">(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">&quot;EcsClusterQaBot-Container&quot;</span><span style="color: #F69D50">,</span></span>
<span class="line"><span style="color: #ADBAC7">            image</span><span style="color: #F47067">=</span><span style="color: #96D0FF">ecs.ContainerImage.from_registry</span><span style="color: #ADBAC7">(</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">&quot;tomomano/qabot:latest&quot;</span></span>
<span class="line"><span style="color: #ADBAC7">            )</span><span style="color: #96D0FF">,</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">class</span><span style="color: #24292E"> </span><span style="color: #032F62">EcsClusterQaBot</span><span style="color: #24292E">(</span><span style="color: #6F42C1">core.Stack</span><span style="color: #24292E">)</span><span style="color: #032F62">:</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #6F42C1">def</span><span style="color: #24292E"> </span><span style="color: #032F62">__init__</span><span style="color: #24292E">(</span><span style="color: #6F42C1">self,</span><span style="color: #24292E"> </span><span style="color: #032F62">scope:</span><span style="color: #24292E"> </span><span style="color: #032F62">core.App,</span><span style="color: #24292E"> </span><span style="color: #032F62">name:</span><span style="color: #24292E"> </span><span style="color: #032F62">str,</span><span style="color: #24292E"> </span><span style="color: #005CC5">**</span><span style="color: #032F62">kwargs</span><span style="color: #24292E">) -</span><span style="color: #D73A49">&gt;</span><span style="color: #24292E"> </span><span style="color: #032F62">None:</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6F42C1">super</span><span style="color: #24292E">().__init__(</span><span style="color: #6F42C1">scope,</span><span style="color: #24292E"> </span><span style="color: #032F62">name,</span><span style="color: #24292E"> </span><span style="color: #005CC5">**</span><span style="color: #032F62">kwargs</span><span style="color: #24292E">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D"># dynamoDB table to store questions and answers</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6F42C1">table</span><span style="color: #24292E"> </span><span style="color: #032F62">=</span><span style="color: #24292E"> </span><span style="color: #032F62">dynamodb.Table</span><span style="color: #24292E">(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #6F42C1">self,</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;EcsClusterQaBot-Table&quot;,</span></span>
<span class="line"><span style="color: #24292E">            partition_key</span><span style="color: #D73A49">=</span><span style="color: #032F62">dynamodb.Attribute</span><span style="color: #24292E">(</span></span>
<span class="line"><span style="color: #24292E">                name</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;item_id&quot;,</span><span style="color: #24292E"> type</span><span style="color: #D73A49">=</span><span style="color: #032F62">dynamodb.AttributeType.STRING</span></span>
<span class="line"><span style="color: #24292E">            )</span><span style="color: #032F62">,</span></span>
<span class="line"><span style="color: #24292E">            billing_mode</span><span style="color: #D73A49">=</span><span style="color: #032F62">dynamodb.BillingMode.PAY_PER_REQUEST,</span></span>
<span class="line"><span style="color: #24292E">            removal_policy</span><span style="color: #D73A49">=</span><span style="color: #032F62">core.RemovalPolicy.DESTROY</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6F42C1">vpc</span><span style="color: #24292E"> </span><span style="color: #032F62">=</span><span style="color: #24292E"> </span><span style="color: #032F62">ec2.Vpc</span><span style="color: #24292E">(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #6F42C1">self,</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;EcsClusterQaBot-Vpc&quot;,</span></span>
<span class="line"><span style="color: #24292E">            max_azs</span><span style="color: #D73A49">=</span><span style="color: #005CC5">1</span><span style="color: #032F62">,</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6F42C1">cluster</span><span style="color: #24292E"> </span><span style="color: #032F62">=</span><span style="color: #24292E"> </span><span style="color: #032F62">ecs.Cluster</span><span style="color: #24292E">(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #6F42C1">self,</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;EcsClusterQaBot-Cluster&quot;,</span></span>
<span class="line"><span style="color: #24292E">            vpc</span><span style="color: #D73A49">=</span><span style="color: #032F62">vpc,</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6F42C1">taskdef</span><span style="color: #24292E"> </span><span style="color: #032F62">=</span><span style="color: #24292E"> </span><span style="color: #032F62">ecs.FargateTaskDefinition</span><span style="color: #24292E">(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #6F42C1">self,</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;EcsClusterQaBot-TaskDef&quot;,</span></span>
<span class="line"><span style="color: #24292E">            cpu</span><span style="color: #D73A49">=</span><span style="color: #005CC5">1024</span><span style="color: #032F62">,</span><span style="color: #24292E"> </span><span style="color: #6A737D"># 1 CPU</span></span>
<span class="line"><span style="color: #24292E">            memory_limit_mib</span><span style="color: #D73A49">=</span><span style="color: #005CC5">4096</span><span style="color: #032F62">,</span><span style="color: #24292E"> </span><span style="color: #6A737D"># 4GB RAM</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D"># grant permissions</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6F42C1">table.grant_read_write_data(taskdef.task_role</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6F42C1">taskdef.add_to_task_role_policy(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #6F42C1">iam.PolicyStatement(</span></span>
<span class="line"><span style="color: #24292E">                effect</span><span style="color: #D73A49">=</span><span style="color: #032F62">iam.Effect.ALLOW,</span></span>
<span class="line"><span style="color: #24292E">                resources</span><span style="color: #D73A49">=</span><span style="color: #032F62">[&quot;*&quot;],</span></span>
<span class="line"><span style="color: #24292E">                actions</span><span style="color: #D73A49">=</span><span style="color: #032F62">[&quot;ssm:GetParameter&quot;]</span></span>
<span class="line"><span style="color: #24292E">            )</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6F42C1">container</span><span style="color: #24292E"> </span><span style="color: #032F62">=</span><span style="color: #24292E"> </span><span style="color: #032F62">taskdef.add_container</span><span style="color: #24292E">(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #6F42C1">&quot;EcsClusterQaBot-Container&quot;</span><span style="color: #6F42C1">,</span></span>
<span class="line"><span style="color: #24292E">            image</span><span style="color: #D73A49">=</span><span style="color: #032F62">ecs.ContainerImage.from_registry</span><span style="color: #24292E">(</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #6F42C1">&quot;tomomano/qabot:latest&quot;</span></span>
<span class="line"><span style="color: #24292E">            )</span><span style="color: #032F62">,</span></span>
<span class="line"><span style="color: #24292E">        )</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br><span class="line-number">36</span><br><span class="line-number">37</span><br><span class="line-number">38</span><br><span class="line-number">39</span><br><span class="line-number">40</span><br><span class="line-number">41</span><br><span class="line-number">42</span><br><span class="line-number">43</span><br><span class="line-number">44</span><br><span class="line-number">45</span><br><span class="line-number">46</span><br><span class="line-number">47</span><br><span class="line-number">48</span><br><span class="line-number">49</span><br><span class="line-number">50</span><br><span class="line-number">51</span><br><span class="line-number">52</span><br></div></div><ul>
<li>
<p>ここでは，回答の結果を書き込むためのデータベースを用意している． DynamoDB については，サーバーレスアーキテクチャの章で扱うので，今は気にしなくてよい．</p>
</li>
<li>
<p>ここでは，ハンズオン #1, #2 で行ったのと同様に， VPC を定義している．</p>
</li>
<li>
<p>ここで， ECS のクラスター (cluster) を定義している． クラスターとは，仮想サーバーのプールのことであり，クラスターの中に複数の仮想インスタンスを配置する．</p>
</li>
<li>
<p>ここで，実行するタスクを定義している (task definition)．</p>
</li>
<li>
<p>ここで， タスクの実行で使用する Docker イメージを定義している．</p>
</li>
</ul>
<h3 id="ecs-と-fargate" tabindex="-1">ECS と Fargate <a class="header-anchor" href="#ecs-と-fargate" aria-label="Permalink to &quot;ECS と Fargate&quot;">&ZeroWidthSpace;</a></h3>
<p>ECS と Fargate の部分について，コードをくわしく見てみよう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">cluster</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ecs.Cluster</span><span style="color: #ADBAC7">(</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">self,</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;EcsClusterQaBot-Cluster&quot;,</span></span>
<span class="line"><span style="color: #ADBAC7">    vpc</span><span style="color: #F47067">=</span><span style="color: #96D0FF">vpc,</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F69D50">taskdef</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ecs.FargateTaskDefinition</span><span style="color: #ADBAC7">(</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">self,</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;EcsClusterQaBot-TaskDef&quot;,</span></span>
<span class="line"><span style="color: #ADBAC7">    cpu</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">1024</span><span style="color: #96D0FF">,</span><span style="color: #ADBAC7"> </span><span style="color: #768390"># 1 CPU</span></span>
<span class="line"><span style="color: #ADBAC7">    memory_limit_mib</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">4096</span><span style="color: #96D0FF">,</span><span style="color: #ADBAC7"> </span><span style="color: #768390"># 4GB RAM</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F69D50">container</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">taskdef.add_container</span><span style="color: #ADBAC7">(</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">&quot;EcsClusterQaBot-Container&quot;</span><span style="color: #F69D50">,</span></span>
<span class="line"><span style="color: #ADBAC7">    image</span><span style="color: #F47067">=</span><span style="color: #96D0FF">ecs.ContainerImage.from_registry</span><span style="color: #ADBAC7">(</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #F69D50">&quot;tomomano/qabot:latest&quot;</span></span>
<span class="line"><span style="color: #ADBAC7">    )</span><span style="color: #96D0FF">,</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">cluster</span><span style="color: #24292E"> </span><span style="color: #032F62">=</span><span style="color: #24292E"> </span><span style="color: #032F62">ecs.Cluster</span><span style="color: #24292E">(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #6F42C1">self,</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;EcsClusterQaBot-Cluster&quot;,</span></span>
<span class="line"><span style="color: #24292E">    vpc</span><span style="color: #D73A49">=</span><span style="color: #032F62">vpc,</span></span>
<span class="line"><span style="color: #24292E">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6F42C1">taskdef</span><span style="color: #24292E"> </span><span style="color: #032F62">=</span><span style="color: #24292E"> </span><span style="color: #032F62">ecs.FargateTaskDefinition</span><span style="color: #24292E">(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #6F42C1">self,</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;EcsClusterQaBot-TaskDef&quot;,</span></span>
<span class="line"><span style="color: #24292E">    cpu</span><span style="color: #D73A49">=</span><span style="color: #005CC5">1024</span><span style="color: #032F62">,</span><span style="color: #24292E"> </span><span style="color: #6A737D"># 1 CPU</span></span>
<span class="line"><span style="color: #24292E">    memory_limit_mib</span><span style="color: #D73A49">=</span><span style="color: #005CC5">4096</span><span style="color: #032F62">,</span><span style="color: #24292E"> </span><span style="color: #6A737D"># 4GB RAM</span></span>
<span class="line"><span style="color: #24292E">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6F42C1">container</span><span style="color: #24292E"> </span><span style="color: #032F62">=</span><span style="color: #24292E"> </span><span style="color: #032F62">taskdef.add_container</span><span style="color: #24292E">(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #6F42C1">&quot;EcsClusterQaBot-Container&quot;</span><span style="color: #6F42C1">,</span></span>
<span class="line"><span style="color: #24292E">    image</span><span style="color: #D73A49">=</span><span style="color: #032F62">ecs.ContainerImage.from_registry</span><span style="color: #24292E">(</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6F42C1">&quot;tomomano/qabot:latest&quot;</span></span>
<span class="line"><span style="color: #24292E">    )</span><span style="color: #032F62">,</span></span>
<span class="line"><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br></div></div><p><code>cluster =</code> の箇所で，空の ECS クラスターを定義している．</p>
<p>次に， <code>taskdef=ecs.FargateTaskDefinition</code> の箇所で， Fargate インスタンスを使ったタスクを定義しており，とくにここでは 1 CPU, 4GB RAM というマシンスペックを指定している． また，このようにして定義されたタスクは，デフォルトで 1 タスクにつき 1 インスタンスが使用される．</p>
<p>最後に， <code>container =</code> の箇所で，タスクの実行で使用する Docker image を定義している． ここでは， Docker Hub に置いてある image をダウンロードしてくるよう指定している．</p>
<p>このようにわずか数行のコードであるが，これだけで前述したような，タスクのスケジューリングなどが自動で実行される．</p>
<p>このコードで <code>cpu=1024</code> と指定されているのに注目してほしい． これは CPU ユニットと呼ばれる数で， 以下の換算表に従って仮想 CPU (virtual CPU; vCPU) が割り当てられる． 1024 が 1 CPU に相当する． 0.25 や 0.5 vCPU などの数字は，それぞれ実効的に 1/4, 1/2 の CPU 時間が割り当てられることを意味する． また， CPU ユニットによって使用できるメモリー量も変わってくる． たとえば， 1024 CPU ユニットを選択した場合は， 2 から 8 GB の範囲でのみメモリー量を指定することができる． 最新の情報は <a href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/AWS_Fargate.html" target="_blank" rel="noreferrer">公式ドキュメンテーション &quot;Amazon ECS on AWS Fargate&quot;</a> を参照のこと．</p>
<table><caption>CPU　ユニットと 指定可能なメモリー量の換算表</caption><colgroup><col style="width: 50%" /><col style="width: 50%" /></colgroup><tbody><tr class="odd"><td><p>CPU ユニット</p></td><td><p>メモリーの値</p></td></tr><tr class="even"><td><p>256 (.25 vCPU)</p></td><td><p>0.5 GB, 1 GB, 2 GB</p></td></tr><tr class="odd"><td><p>512 (.5 vCPU)</p></td><td><p>1 GB, 2 GB, 3 GB, 4 GB</p></td></tr><tr class="even"><td><p>1024 (1 vCPU)</p></td><td><p>2 GB, 3 GB, 4 GB, 5 GB, 6 GB, 7 GB, 8 GB</p></td></tr><tr class="odd"><td><p>2048 (2 vCPU)</p></td><td><p>Between 4 GB and 16 GB in 1-GB increments</p></td></tr><tr class="even"><td><p>4096 (4 vCPU)</p></td><td><p>Between 8 GB and 30 GB in 1-GB increments</p></td></tr></tbody></table>
<h2 id="スタックのデプロイ-1" tabindex="-1">スタックのデプロイ <a class="header-anchor" href="#スタックのデプロイ-1" aria-label="Permalink to &quot;スタックのデプロイ&quot;">&ZeroWidthSpace;</a></h2>
<p>スタックの中身が理解できたところで，早速スタックをデプロイしてみよう．</p>
<p>デプロイの手順は，これまでのハンズオンとほとんど共通である． SSH によるログインの必要がないので，むしろ単純なくらいである． ここでは，コマンドのみ列挙する (<code>#</code> で始まる行はコメントである)． それぞれの意味を忘れてしまった場合は，ハンズオン 1, 2 に戻って復習していただきたい． シークレットキーの設定も忘れずに (<a href="#aws_cli_install">AWS CLI のインストール</a>)．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390"># プロジェクトのディレクトリに移動</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cd</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">handson/qa-bot</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># venv を作成し，依存ライブラリのインストールを行う</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python3</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-m</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">venv</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.env</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">source</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.env/bin/activate</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">pip</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">install</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-r</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">requirements.txt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># デプロイを実行</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cdk</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">deploy</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D"># プロジェクトのディレクトリに移動</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cd</span><span style="color: #24292E"> </span><span style="color: #032F62">handson/qa-bot</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># venv を作成し，依存ライブラリのインストールを行う</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python3</span><span style="color: #24292E"> </span><span style="color: #005CC5">-m</span><span style="color: #24292E"> </span><span style="color: #032F62">venv</span><span style="color: #24292E"> </span><span style="color: #032F62">.env</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">source</span><span style="color: #24292E"> </span><span style="color: #032F62">.env/bin/activate</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">pip</span><span style="color: #24292E"> </span><span style="color: #032F62">install</span><span style="color: #24292E"> </span><span style="color: #005CC5">-r</span><span style="color: #24292E"> </span><span style="color: #032F62">requirements.txt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># デプロイを実行</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cdk</span><span style="color: #24292E"> </span><span style="color: #032F62">deploy</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br></div></div><p>デプロイのコマンドが無事に実行されれば， <a href="#handson_03_cdk_output">figure_title</a> のような出力が得られるはずである．</p>
<p><img src="./assets/handson-03/cdk_output.png" alt="CDKデプロイ実行後の出力"></p>
<p>AWS コンソールにログインして，デプロイされたスタックの中身を確認してみよう． コンソールから，ECS のページに行くと <a href="#handson_03_ecs_console">figure_title</a> のような画面が表示されるはずである． <code>EcsClusterQaBot-XXXX</code> という名前ついたクラスターを見つけよう．</p>
<p>Cluster というのが，先ほど説明したとおり，複数の仮想インスタンスを束ねる一つの単位である． <a href="#handson_03_ecs_console">figure_title</a> で， FARGATE という文字の下に <code>0 Running tasks</code>, <code>0 Pending tasks</code> と表示されていることを確認しよう． この時点では一つもタスクが走っていないので，数字はすべて 0 になっている．</p>
<p><img src="./assets/handson-03/ecs_console.png" alt="ECS コンソール画面"></p>
<p>続いて，この画面の左のメニューバーから <code>Task Definitions</code> という項目を見つけ，クリックしよう． 移動した先のページで <code>EcsClusterQaBotEcsClusterQaBotTaskDefXXXX</code> という項目が見つかるので，開く． 開いた先のページをスクロールすると <a href="#handson_03_ecs_task_definition">figure_title</a> に示したような情報が見つかるだろう． 使用する CPU ・メモリーの量や， Docker container の実行に関する設定などが，この Task Definition の画面から確認することができる．</p>
<p><img src="./assets/handson-03/ecs_task_definition.png" alt="Task definition の確認"></p>
<h2 id="タスクの実行" tabindex="-1">タスクの実行 <a class="header-anchor" href="#タスクの実行" aria-label="Permalink to &quot;タスクの実行&quot;">&ZeroWidthSpace;</a></h2>
<p>それでは，質問をデプロイしたクラウドに提出してみよう．</p>
<p>ECS にタスクを投入するのはやや複雑なので，タスクの投入を簡単にするプログラム (<code>run_task.py</code>) を用意した (<a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/qa-bot/run_task.py" target="_blank" rel="noreferrer">handson/qa-bot/run_task.py</a>)．</p>
<p>次のようなコマンドで，ECS クラスターに新しい質問を投入することができる．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">run_task.py</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ask</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;A giant peach was flowing in the river. She picked it up and brought it home. Later, a healthy baby was born from the peach. She named the baby Momotaro.&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;What is the name of the baby?&quot;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python</span><span style="color: #24292E"> </span><span style="color: #032F62">run_task.py</span><span style="color: #24292E"> </span><span style="color: #032F62">ask</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;A giant peach was flowing in the river. She picked it up and brought it home. Later, a healthy baby was born from the peach. She named the baby Momotaro.&quot;</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;What is the name of the baby?&quot;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p><code>run_task.py</code> を実行するには， コマンドラインで AWS の認証情報が設定されていることが前提である．</p>
<p>&quot;ask&quot; の引数に続き，文脈 (context) と質問 (question) を引数として渡している．</p>
<p>このコマンドを実行すると， &quot;Waiting for the task to finish…&quot; と出力が表示され，回答を得るまでしばらく待たされる． この間， AWS では ECS がタスクを受理し，新しい Fargate のインスタンスを起動し， Docker イメージをそのインスタンスに配置する，という一連の処理がなされている． AWS コンソールから，この一連の様子をモニタリングしてみよう．</p>
<p>先ほどの ECS コンソール画面にもどり，クラスターの名前をクリックすることで，クラスターの詳細画面を開く． 次に， &quot;Tasks&quot; という名前のタブがあるので，それを開く (<a href="#ecs_task_monitoring">figure_title</a>)． すると，実行中のタスクの一覧が表示されるだろう．</p>
<p><img src="./assets/handson-03/ecs_task_monitoring.png" alt="ECS のタスクの実行状況をモニタリング"></p>
<p><a href="#ecs_task_monitoring">figure_title</a> で見て取れるように， &quot;Last status = Pending&quot; となっていることから，この時点では，タスクを実行する準備をしている段階である，ということがわかる． Fargate のインスタンスを起動し， Docker image を配置するまでおよそ 1-2 分の時間がかかる．</p>
<p>しばらく待つうちに， Status が &quot;RUNNING&quot; に遷移し，計算が始まる． 計算が終わると， Status は &quot;STOPPED&quot; に遷移し， ECS によって Fargate インスタンスは自動的にシャットダウンされる．</p>
<p><a href="#ecs_task_monitoring">figure_title</a> の画面から， &quot;Task&quot; の列にあるタスク ID クリックすることで，タスクの詳細画面を開いてみよう (<a href="#ecs_task_detail">figure_title</a>)． &quot;Last status&quot;, &quot;Platform version&quot; など，タスクの情報が表示されている． また， &quot;Logs&quot; のタブを開くことで，コンテナの吐き出した実行ログを閲覧することができる．</p>
<p><img src="./assets/handson-03/ecs_task_detail.png" alt="質問タスクの実行結果"></p>
<p>さて， <code>run_task.py</code> を実行したコマンドラインに戻ってきてみると， <a href="#ask_question_output">figure_title</a> のような出力が得られているはずである． &quot;Momotaro&quot; という正しい回答が返ってきている！</p>
<p><img src="./assets/handson-03/ask_question_output.png" alt="質問タスクの実行結果"></p>
<h2 id="タスクの同時実行" tabindex="-1">タスクの同時実行 <a class="header-anchor" href="#タスクの同時実行" aria-label="Permalink to &quot;タスクの同時実行&quot;">&ZeroWidthSpace;</a></h2>
<p>さて，先ほどはたった一つの質問を投入したわけだが，今回設計したアプリケーションは， ECS と Fargate を使うことで同時にたくさんの質問を処理することができる． 実際に，たくさんの質問を一度に投入してみよう． <code>run_task.py</code> に <code>ask_many</code> というオプションを付けることで，複数の質問を一度に送信できる． 質問の内容は <a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/qa-bot/problems.json" target="_blank" rel="noreferrer">handson/qa-bot/problems.json</a> に定義されている．</p>
<p>次のようなコマンドを実行しよう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">run_task.py</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ask_many</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python</span><span style="color: #24292E"> </span><span style="color: #032F62">run_task.py</span><span style="color: #24292E"> </span><span style="color: #032F62">ask_many</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>このコマンドを実行した後で，先ほどの ECS コンソールに行き，タスクの一覧を見てみよう (<a href="#ecs_many_tasks">figure_title</a>)． 複数の Fargate インスタンスが起動され，タスクが並列に実行されているのがわかる．</p>
<p><img src="./assets/handson-03/ecs_many_tasks.png" alt="複数の質問タスクを同時に投入する"></p>
<p>すべてのタスクのステータスが &quot;STOPPED&quot; になったことを確認した上で，質問への回答を取得しよう． それには，次のコマンドを実行する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">run_task.py</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">list_answers</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python</span><span style="color: #24292E"> </span><span style="color: #032F62">run_task.py</span><span style="color: #24292E"> </span><span style="color: #032F62">list_answers</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>結果として， <a href="#ask_many_output">figure_title</a> のような出力が得られるだろう． 複雑な文章問題に対し，高い正答率で回答できていることがわかるだろう．</p>
<p><img src="./assets/handson-03/ask_many_output.png" alt=" の実行結果"></p>
<p>おめでとう！ ここまでついてこれた読者はとても初歩的ながらも，深層学習による言語モデルを使って自動で質問への回答を生成するシステムを創り上げることができた！ それも，数百の質問にも同時に対応できるような，とても高いスケーラビリティーをもったシステムである！ 今回は GUI (Graphical User Interface) を用意することはしなかったが，このシステムに簡単な GUI を追加すればなかなか立派なウェブサービスとして運用できるだろう．</p>
<p><code>run_task.py</code> で質問を投入し続けると，回答を記録しているデータベースにどんどんエントリーが溜まっていく． これらのエントリーをすべて消去するには，次のコマンドを使う．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">run_task.py</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">clear</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python</span><span style="color: #24292E"> </span><span style="color: #032F62">run_task.py</span><span style="color: #24292E"> </span><span style="color: #032F62">clear</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><h2 id="スタックの削除-1" tabindex="-1">スタックの削除 <a class="header-anchor" href="#スタックの削除-1" aria-label="Permalink to &quot;スタックの削除&quot;">&ZeroWidthSpace;</a></h2>
<p>これにて，今回のハンズオンは終了である． 最後にスタックを削除しよう．</p>
<p>スタックを削除するには，前回までと同様に， AWS コンソールにログインし CloudFormation の画面から DELETE ボタンをクリックするか，コマンドラインからコマンドを実行する． コマンドラインから行う場合は，次のコマンドを使用する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cdk</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">destroy</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cdk</span><span style="color: #24292E"> </span><span style="color: #032F62">destroy</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><h1 id="hands-on-4-aws-batch-を使って機械学習のハイパーパラメータサーチを並列化する" tabindex="-1">Hands-on #4: AWS Batch を使って機械学習のハイパーパラメータサーチを並列化する <a class="header-anchor" href="#hands-on-4-aws-batch-を使って機械学習のハイパーパラメータサーチを並列化する" aria-label="Permalink to &quot;Hands-on \#4: AWS Batch を使って機械学習のハイパーパラメータサーチを並列化する&quot;">&ZeroWidthSpace;</a></h1>
<p>ハンズオン第三回では， ECS と Fargate を使って自動質問回答システムを構築した． シンプルながらも，複数の質問が送られた場合には並列にジョブが実行され，ユーザーに答えが返されるシステムを作ることができた． ここでは，すでに学習済みの言語モデルを用いてアプリケーションを構築した． しかし，一般的に言って，機械学習のワークフローでは自分で作ったモデルを訓練することが最初のステップにあるはずである． そこで，ハンズオン第四回では，クラウドを用いて機械学習の訓練を並列化・高速化することを考える．</p>
<p>本ハンズオンでは深層学習におけるハイパーパラメータ最適化を取り上げる． ハイパーパラメータとは，勾配降下法によって最適化されるニューラルネットのパラメータの外にあるパラメータのことであり，具体的にはモデルの層の幅・深さなどネットワークのアーキテクチャに関わるもの，学習率やモメンタムなどパラメータの更新則に関わるものなどが含まる． 深層学習においてハイパーパラメータの調整はとても重要なタスクである． しかしながら，ハイパーパラメータを調整するには，少しずつ条件を変えながら何度もニューラルネットを学習させる必要があり，多くの計算時間がかかる． 研究・開発においては，スループットよくたくさんのモデルの可能性を探索することが生産性を決める重要なファクターであり，ハイパーパラメータ探索を高速に解くという問題は極めて関心が高い． 本ハンズオンでは，クラウドの強力な計算リソースを利用して並列的にニューラルネットの訓練を実行することで，この問題を解く方法を学んでいこう．</p>
<h2 id="auto-scaling-groups-asg" tabindex="-1">Auto scaling groups (ASG) <a class="header-anchor" href="#auto-scaling-groups-asg" aria-label="Permalink to &quot;Auto scaling groups (ASG)&quot;">&ZeroWidthSpace;</a></h2>
<p>ハンズオンに入っていく前に， <strong>Auto scaling groups (ASG)</strong> とよばれる EC2 の概念を知っておく必要がある．</p>
<p>ECS の概要を示した <a href="#ecs_overview">figure_title</a> を振り返って見てほしい． 前章 (<a href="#sec_fargate_qabot">Hands-on #3: AWS で自動質問回答ボットを走らせる</a>) でも説明したが， ECS のクラスターで計算を担う実体としては EC2 と Fargate を指定することができる． Fargate については前章で記述した． Fargate を用いると，自在にスケールする計算環境をとても簡単な設定で構築することができた． しかし， GPU を利用することができないなど，いくつかの制約があった． EC2 を使用した計算環境を指定することで，プログラミングの複雑度は増すが， GPU やその他のより高度かつ複雑な設定を伴ったクラスターを構築することができる．</p>
<p>EC2 クラスターには <strong>ASG</strong> と呼ばれるサービスが配置される． ASG は複数の EC2 インスタンスをロジカルな単位でグループ化することでクラスターを構成する． ASG はクラスター内に新しいインスタンスを起動する，あるいは不要になったインスタンスを停止するなどのスケーリングを担う． ASG で重要な概念として， <strong>desired capacity</strong>, <strong>minimum capacity</strong>, <strong>maximum capacity</strong> というパラメータがある． minimum capacity， maximum capacity は，それぞれクラスター内に配置できるインスタンスの数の最小値・最大値を指定するパラメータである． 前者は，クラスターに負荷がかかっていない場合でもアイドリング状態にあるインスタンスを維持することで，急に負荷が増大した時などのバッファーとして作用することができる． 後者は，負荷が急に増えたときに，過剰な数のインスタンスが起動する事態を防ぎ，経済的なコストの上限を定める役割を果たす．</p>
<p>desired capacity が，その時々でシステムが要求するインスタンスの数を指定する． desired capacity は，例えば 24 時間のリズムに合わせてインスタンスの数を増減させる (昼は多く夜は少なくなど) などの決まったスケジュールに基づいた設定を適用することができる． あるいはクラスター全体にかかっている負荷に応じて， desired capacity を動的に制御することも可能である． どのような基準でクラスターのスケーリングを行うかを定めるルールのことを，<strong>スケーリングポリシー</strong>とよぶ． たとえば，クラスター全体の稼働率 (負荷) を常に 80% に維持する，などのスケーリングポリシーが想定できる． この場合，クラスター全体の負荷が 80%を下回ったときにはクラスターからインスタンスが削除され，80%を超える (あるいは超えると予測される) 場合はインスタンスを追加する，という操作が ASG によって自動的に行われる．</p>
<p>上記のようなパラメータを検討し，ユーザーは ASG を作成する． ASG を作成したのち， ECS との連携をプログラムしてあげることで， ECS を介して ASG による EC2 クラスターにタスクを投入することが可能になる．</p>
<h2 id="aws-batch" tabindex="-1">AWS Batch <a class="header-anchor" href="#aws-batch" aria-label="Permalink to &quot;AWS Batch&quot;">&ZeroWidthSpace;</a></h2>
<p><img src="./assets/aws_logos/Batch.png" alt="AWS Batch のアイコン"></p>
<p>先に説明したように， ECS と ASG を組み合わせることで，所望の計算クラスターを構築することが可能である． しかしながら， ECS と ASG にはかなり込み入った設定が必要であり，初心者にとっても経験者にとってもなかなか面倒なプログラミングが要求される． そこで， ECS と ASG によるクラスターの設計を自動化してくれるサービスが提供されている． それが <strong>AWS Batch</strong> である．</p>
<p>AWS Batch はその名のとおりバッチ (Batch) 化されたジョブ (入力データだけが異なる独立した演算が繰り返し実行されること) を想定している． 多くの科学計算や機械学習がバッチ計算に当てはまる． たとえば，初期値のパラメータを変えて複数のシミュレーションを走らせる，といったケースだ． AWS Batch を用いることの利点は，クラスターのスケーリングやジョブの割り振りはすべて自動で実行され， ユーザーはクラウドの舞台裏の詳細を気にすることなく，大量のジョブを投入できるシステムが手に入る点である． が，知識として背後では ECS/ASG/EC2 の三つ巴が協調して動作しているという点は知っておいてほしい．</p>
<p>AWS Batch では，ジョブの投入・管理をスムーズに行うため，次のような概念が定義されている (<a href="#fig_batch_concept">figure_title</a>)． まず， <strong>ジョブ (Job)</strong> というのが，AWS Batch によって実行される一つの計算の単位である． <strong>Job definitions</strong> とはジョブの内容を定義するものであり，これには実行されるべき Docker のイメージのアドレスや，割り当てる CPU・RAM の容量，環境変数などの設定が含まれる． Job definition に基づいて個々のジョブが実行される． ジョブが実行されると，ジョブは <strong>Job queues</strong> に入る． Job queues とは，実行待ち状態にあるジョブの列のことであり，時間的に最も先頭に投入されたジョブが最初に実行される． また，複数の queue を配置し， queue ごとに priority (優先度) を設定することが可能であり， priority の高い queue に溜まったジョブが優先的に実行される (筆者はこれをディズニーランドの&quot;ファストパス&quot;を連想して捉えている)． <strong>Compute environment</strong> とは，先述したクラスターとほぼ同義の概念であり，計算が実行される場所 (EC2 や Fargate からなるクラスター) を指す． Compute environment には，使用する EC2 のインスタンスタイプや同時に起動するインスタンス数の上限などの簡易なスケーリングポリシーが指定されている． Job queues は Compute environment の空き状況を監視しており， それに応じてジョブを Compute environment に投下する．</p>
<p>以上が AWS Batch を使用するうえで理解しておかなければならない概念であるが，くどくど言葉で説明してもなかなかピンとこないだろう． ここからは，実際に自分で手を動かしながら学んでいこう．</p>
<p><img src="./assets/aws_batch/batch_concepts.png" alt="AWS Batch の主要な概念"></p>
<p><strong>EC2 or Fargate?</strong></p>
<p>ECS でクラスターを構成する際，計算を実行する場として EC2 と Fargate の二つの選択肢があることを説明した． それぞれ長所と短所を抱えているのだが，どのような場合にどちらを使うべきだろうか？ それを検討するため，まずは <a href="#tab:ec2_vs_fargate">table_title</a> を見てみよう． これは EC2 と Fargate の特徴をまとめたものである． 説明の都合上，大幅な粗視化が行われている点は留意していただきたい．</p>
<table><caption>EC2 vs Fargate</caption><colgroup><col style="width: 33%" /><col style="width: 33%" /><col style="width: 33%" /></colgroup><thead><tr class="header"><th></th><th>EC2</th><th>Fargate</th></tr></thead><tbody><tr class="odd"><td><p>Compute capacity</p></td><td><p>Medium to large</p></td><td><p>Small to medium</p></td></tr><tr class="even"><td><p>GPU</p></td><td><p>Yes</p></td><td><p>No</p></td></tr><tr class="odd"><td><p>Launch speed</p></td><td><p>Slow</p></td><td><p>Fast</p></td></tr><tr class="even"><td><p>Task placement flexibility</p></td><td><p>Low</p></td><td><p>High</p></td></tr><tr class="odd"><td><p>Programming complexity</p></td><td><p>High</p></td><td><p>Low</p></td></tr></tbody></table>
<p>これまでに見てきたように， EC2 は最大の CPU 数・メモリーサイズが大きかったり， GPU を利用できたりするなど，単一のインスタンスでの計算能力は高い． 対して， Fargate は単一インスタンスの最大 CPU 数は 4 コアが上限である． その一方で，インスタンスの起動に要する時間は Fargate のほうが圧倒的に早く，より俊敏にクラスターのスケーリングを行うことができる． また，タスクをクラスターに投入する際のフレキシビリティも Fargate のほうが高い． フレキシビリティというのは，例えば一つのインスタンスで 2 つ以上のコンテナを走らせる，などの状況である． 単位 CPU あたりで処理されるタスクの数を最大化する際には，このような設計がしばしば採用される． プログラミングの複雑さという観点からは， Fargate のほうが一般的にシンプルな実装になる．</p>
<p>このように， EC2 と Fargate は互いに相補的な特性を有しており，アプリケーションによって最適な計算環境は検討される必要がある． また，EC2 と Fargate を両方用いたハイブリッドクラスターというのも定義可能であり，そのような選択肢もしばしば用いられる．</p>
<h2 id="準備-3" tabindex="-1">準備 <a class="header-anchor" href="#準備-3" aria-label="Permalink to &quot;準備&quot;">&ZeroWidthSpace;</a></h2>
<p>ハンズオンのソースコードは GitHub の <a href="https://github.com/andatoshiki/toshiki-notebooktree/main/handson/aws-batch" target="_blank" rel="noreferrer">handson/aws-batch</a> にある．</p>
<p>本ハンズオンの実行には，第一回ハンズオンで説明した準備 (<a href="#handson_01_prep">準備</a>) が整っていることを前提とする． また， Docker が自身のローカルマシンにインストール済みであることも必要である．</p>
<p>このハンズオンは， <code>g4dn.xlarge</code> タイプの EC2 インスタンスを使うので，アメリカ東部 (<code>us-east-1</code>) リージョンでは 0.526 $/hour のコストが発生する． 東京 (<code>ap-northeast-1</code>) を選択した場合は 0.71 $/hour のコストが発生する．</p>
<p><a href="#sec:jupyter_and_deep_learning_setup">準備</a> でも注意したが，このハンズオンを始める前に G タイプインスタンスの起動上限を AWS コンソールの EC2 管理画面から確認しよう． もし上限が 0 になっていた場合は，上限緩和の申請を行う必要がある． <a href="#sec:aws_batch_code">アプリケーションの説明</a> にも関連した情報を記載しているので，併せて参照されたい．</p>
<h2 id="mnist-手書き文字認識-再訪" tabindex="-1">MNIST 手書き文字認識 (再訪) <a class="header-anchor" href="#mnist-手書き文字認識-再訪" aria-label="Permalink to &quot;MNIST 手書き文字認識 (再訪)&quot;">&ZeroWidthSpace;</a></h2>
<p>今回のハンズオンでは，機械学習のハイパーパラメータ調整を取り上げると冒頭で述べた． その最もシンプルな例題として， <a href="#sec_mnist_using_jupyter">実践ディープラーニング! MNIST 手書き数字認識タスク</a> で扱った MNIST 手書き文字認識の問題を再度取り上げよう． <a href="#sec_mnist_using_jupyter">実践ディープラーニング! MNIST 手書き数字認識タスク</a> では，適当にチョイスしたハイパーパラメータを用いてモデルの訓練を行った． ここで使用したプログラムのハイパーパラメータとしては，確率的勾配降下法 (SGD) における学習率やモメンタムが含まれる． コードでいうと，次の行が該当する．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">optimizer </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> optim.SGD(model.parameters(), </span><span style="color: #F69D50">lr</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">0.01</span><span style="color: #ADBAC7">, </span><span style="color: #F69D50">momentum</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">0.5</span><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">optimizer </span><span style="color: #D73A49">=</span><span style="color: #24292E"> optim.SGD(model.parameters(), </span><span style="color: #E36209">lr</span><span style="color: #D73A49">=</span><span style="color: #005CC5">0.01</span><span style="color: #24292E">, </span><span style="color: #E36209">momentum</span><span style="color: #D73A49">=</span><span style="color: #005CC5">0.5</span><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>ここで使用された 学習率 (<code>lr=0.01</code>) やモメンタム (<code>momentum=0.5</code>) は恣意的に選択された値であり，これがベストな数値であるのかはわからない． たまたまこのチョイスが最適であるかもしれないし，もっと高い精度を出すハイパーパラメータの組が存在するかもしれない． この問題に答えるため，ハイパーパラメータサーチを行おう． 今回は，最もシンプルなアプローチとして，<strong>グリッドサーチ</strong>によるハイパーパラメータサーチを行おう．</p>
<p>機械学習のハイパーパラメータの最適化には大きく３つのアプローチが挙げられる． グリッドサーチ，ランダムサーチ，そしてベイズ最適化による方法である．</p>
<p>グリッドサーチとは，ハイパーパラメータの組をある範囲の中で可能な組み合わせをすべて計算し，最適なパラメータの組を見出す方法である． 最もシンプルかつ確実な方法であるが，すべての組み合わせの可能性を愚直に計算するので計算コストが大きい．</p>
<p>ランダムサーチ法とは，ハイパーパラメータの組をある範囲の中でランダムに抽出し，大量に試行されたランダムな組の中から最適なパラメータの組を見出す方法である． すべての可能性を網羅的に探索できるわけではないが，調整すべきパラメータの数が多数ある場合に，グリッドサーチよりも効率的に広い探索空間をカバーすることができる．</p>
<p>ベイズ最適化を用いた方法では，過去の探索結果から次にどの組み合わせを探索すべきかという指標を計算し，次に探索するパラメータを決定する． これにより，理論的にはグリッドサーチやランダムサーチ法よりも少ない試行回数で最適なパラメータにたどり着くことができる．</p>
<p>並列化の観点でいうと，グリッドサーチとランダムサーチは各ハイパーパラメータの組の計算は独立に実行することができるため並列化が容易である． このように独立したジョブとして分割・並列化可能な問題を Embarrassingly parallel な問題とよぶ (直訳すると&quot;恥ずかしいほど並列化可能な問題&quot;，ということになる)． Embarrassingly parallel な問題はクラウドの強力な計算リソースを用いることで，非常なシンプルな実装で解くことができる． この章ではこのようなタイプの並列計算を取り上げる．</p>
<p>一方，ベイズ最適化による方法は，過去の結果をもとに次の探索が決定されるので，並列化はそれほど単純ではない． 最近では <a href="https://optuna.org/" target="_blank" rel="noreferrer">optuna</a> などのハイパーパラメータ探索のためのライブラリが発達しており，ベイズ最適化の数理的な処理を自動で実行してくれるので便利である． これらのライブラリを使うと，もし一台のコンピュータ (ノード) の中に複数の GPU が存在する場合は，並列に計算を実行することができる． しかしながら，一台のノードにとどまらず，複数のノードをまたいだ並列化は，高度なプログラミングテクニックが必要とされるだけでなく，ノード間の接続様式などクラウドのアーキテクチャにも深く依存するものである． 本書ではここまで高度なクラウドの使用方法には立ち入らない．</p>
<p>まずは，本ハンズオンで使用する Docker イメージをローカルで実行してみよう．</p>
<p>Docker イメージのソースコードは <a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/aws-batch/docker" target="_blank" rel="noreferrer">handson/aws-batch/docker</a> にある． 基本的に <a href="#sec_mnist_using_jupyter">実践ディープラーニング! MNIST 手書き数字認識タスク</a> のハンズオンを元にし，本ハンズオン専用の軽微な変更が施してある． 興味のある読者はソースコードも含めて読んでいただきたい．</p>
<p>練習として，この Docker イメージを手元でビルドするところからはじめてみよう． <code>Dockerfile</code> が保存されているディレクトリに移動し， <code>mymnist</code> という名前 (Tag) をつけてビルドを実行する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cd</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">handson/aws-batch/docker</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">docker</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">build</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-t</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">mymnist</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cd</span><span style="color: #24292E"> </span><span style="color: #032F62">handson/aws-batch/docker</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">docker</span><span style="color: #24292E"> </span><span style="color: #032F62">build</span><span style="color: #24292E"> </span><span style="color: #005CC5">-t</span><span style="color: #24292E"> </span><span style="color: #032F62">mymnist</span><span style="color: #24292E"> </span><span style="color: #032F62">.</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p><code>docker build</code> でエラーが出たときは次の可能性を疑ってほしい． ビルドの中で， MNIST の画像データセットを <a href="http://yann.lecun.com/exdb/mnist/" target="_blank" rel="noreferrer">http://yann.lecun.com/exdb/mnist/</a> からダウンロードするのだが，ダウンロード先のサーバーがしばしばダウンしている． 世界中の機械学習ユーザーがアクセスするので，これはしばしば発生するようである． サーバーがダウンしているとビルドも失敗してしまう． エラーメッセージにそれらしい文言が含まれていたら，この可能性を疑おう．</p>
<p>手元でビルドするかわりに， Docker Hub から pull することも可能である． その場合は次のコマンドを実行する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">docker</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">pull</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">tomomano/mymnist:latest</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">docker</span><span style="color: #24292E"> </span><span style="color: #032F62">pull</span><span style="color: #24292E"> </span><span style="color: #032F62">tomomano/mymnist:latest</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>イメージの準備ができたら，次のコマンドでコンテナを起動し， MNIST の学習を実行する．．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">docker</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">run</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">mymnist</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--lr</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0.1</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--momentum</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0.5</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--epochs</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">10</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">docker</span><span style="color: #24292E"> </span><span style="color: #032F62">run</span><span style="color: #24292E"> </span><span style="color: #032F62">mymnist</span><span style="color: #24292E"> </span><span style="color: #005CC5">--lr</span><span style="color: #24292E"> </span><span style="color: #005CC5">0.1</span><span style="color: #24292E"> </span><span style="color: #005CC5">--momentum</span><span style="color: #24292E"> </span><span style="color: #005CC5">0.5</span><span style="color: #24292E"> </span><span style="color: #005CC5">--epochs</span><span style="color: #24292E"> </span><span style="color: #005CC5">10</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>このコマンドを実行すると，指定したハイパーパラメータ (<code>--lr</code> で与えられる学習率と <code>--momentum</code> で与えられるモメンタム) を使ってニューラルネットの最適化が始まる． 学習を行う最大のエポック数は <code>--epochs</code> パラメータで指定する． <a href="#sec_jupyter_and_deep_learning">Hands-on #2: AWS でディープラーニングを実践</a> のハンズオンで見たような， Loss の低下がコマンドライン上に出力されるだろう (<a href="#fig_mnist_log_output">figure_title</a>)．</p>
<p><img src="./assets/aws_batch/mnist_log_output.png" alt="Docker を実行した際の出力"></p>
<p>上に示したコマンドを使うと，計算は CPU を使って実行される． もし，ローカルの計算機に GPU が備わっており， <a href="https://github.com/NVIDIA/nvidia-docker" target="_blank" rel="noreferrer">nvidia-docker</a> の設定が済んでいるならば， 次のコマンドにより GPU を使って計算を実行できる．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">docker</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">run</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--gpus</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">all</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">mymnist</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--lr</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0.1</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--momentum</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0.5</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--epochs</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">10</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">docker</span><span style="color: #24292E"> </span><span style="color: #032F62">run</span><span style="color: #24292E"> </span><span style="color: #005CC5">--gpus</span><span style="color: #24292E"> </span><span style="color: #032F62">all</span><span style="color: #24292E"> </span><span style="color: #032F62">mymnist</span><span style="color: #24292E"> </span><span style="color: #005CC5">--lr</span><span style="color: #24292E"> </span><span style="color: #005CC5">0.1</span><span style="color: #24292E"> </span><span style="color: #005CC5">--momentum</span><span style="color: #24292E"> </span><span style="color: #005CC5">0.5</span><span style="color: #24292E"> </span><span style="color: #005CC5">--epochs</span><span style="color: #24292E"> </span><span style="color: #005CC5">10</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>このコマンドでは，<code>--gpus all</code> というパラメータが加わった．</p>
<p>CPU/GPU どちらで実行した場合でも，エポックを重ねるにつれて訓練データ (Train データ) の Loss は単調に減少していくのが見て取れるだろう． 一方，<strong>検証データ (Validation データ) の Loss および Accuracy は，ある程度まで減少した後，それ以上性能が向上しない</strong>ことに気がつくだろう． これを実際にプロットしてみると <a href="#fig_loss_epoch_profile">figure_title</a> のようになるはずである．</p>
<p><img src="./assets/aws_batch/loss_epoch_profile.png" alt="(左) Train/Validation データそれぞれの Loss のエポックごとの変化． (右) Validation データの Accuracy のエポックごとの変化"></p>
<p>これは<strong>オーバーフィッティング</strong>とよばれる現象で，ニューラルネットが訓練データに過度に最適化され，訓練データの外のデータに対しての精度 (汎化性能) が向上していないことを示している． このような場合の対処法として， <strong>Early stopping</strong> とよばれるテクニックが知られている． Early stopping とは，検証データの Loss を追跡し，それが減少から増加に転じるエポックで学習をうち止め，そのエポックでのウェイトパラメータを採用する，というものである． 本ハンズオンでも， Early stopping によって訓練の終了を判断し，モデルの性能評価を行っていく．</p>
<p>MNIST 手書き文字データセットでは，訓練データとして 60,000 枚，テストデータとして 10,000 枚の画像が与えられている． 本ハンズオンで使用するコードでは，訓練データのうち 80% の 48,000 枚を訓練データとして使用し，残り 20% の 12,000 枚を検証データとして用いている． 詳しくはソースコードを参照のこと．</p>
<h2 id="アプリケーションの説明-3" tabindex="-1">アプリケーションの説明 <a class="header-anchor" href="#アプリケーションの説明-3" aria-label="Permalink to &quot;アプリケーションの説明&quot;">&ZeroWidthSpace;</a></h2>
<p>このハンズオンで作成するアプリケーションの概要を <a href="#fig_batch_architecture">figure_title</a> に示す．</p>
<p><img src="./assets/aws_batch/architecture.png" alt="アプリケーションのアーキテクチャ"></p>
<p>簡単にまとめると，次のような設計である．</p>
<ul>
<li>
<p>クライアントは，あるハイパーパラメータの組を指定して Batch にジョブを提出する</p>
</li>
<li>
<p>Batch はジョブを受け取ると， EC2 からなるクラスターで計算を実行する</p>
</li>
<li>
<p>クラスター内では <code>g4dn.xlarge</code> インスタンスが起動する</p>
</li>
<li>
<p>Docker イメージは， AWS 内に用意された ECR (Elastic Container Registry) から取得される</p>
</li>
<li>
<p>複数のジョブが投下された場合は，その数だけのインスタンスが起動し並列に実行される</p>
</li>
<li>
<p>各ジョブによる計算の結果は S3 に保存される</p>
</li>
<li>
<p>最後にクライアントは S3 から結果をダウンロードし，最適なハイパーパラメータの組を決定する</p>
</li>
</ul>
<p>それでは，プログラムのソースコードを見てみよう (<a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/aws-batch/app.py" target="_blank" rel="noreferrer">handson/aws-batch/app.py</a>)．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">class</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50">SimpleBatch</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">core</span><span style="color: #ADBAC7">.</span><span style="color: #6CB6FF">Stack</span><span style="color: #ADBAC7">):</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">def</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">__init__</span><span style="color: #ADBAC7">(self, scope: core.App, name: </span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">, </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">kwargs) -&gt; </span><span style="color: #6CB6FF">None</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #6CB6FF">super</span><span style="color: #ADBAC7">().</span><span style="color: #6CB6FF">__init__</span><span style="color: #ADBAC7">(scope, name, </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">kwargs)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        bucket </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> s3.Bucket(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;bucket&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">removal_policy</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">core.RemovalPolicy.</span><span style="color: #6CB6FF">DESTROY</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">auto_delete_objects</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">True</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        vpc </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ec2.Vpc(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;vpc&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #768390"># other parameters...</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        managed_env </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> batch.ComputeEnvironment(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;managed-env&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">compute_resources</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">batch.ComputeResources(</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">vpc</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">vpc,</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">allocation_strategy</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">batch.AllocationStrategy.</span><span style="color: #6CB6FF">BEST_FIT</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">desiredv_cpus</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">maxv_cpus</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">64</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">minv_cpus</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">instance_types</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">[</span></span>
<span class="line"><span style="color: #ADBAC7">                    ec2.InstanceType(</span><span style="color: #96D0FF">&quot;g4dn.xlarge&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">                ],</span></span>
<span class="line"><span style="color: #ADBAC7">            ),</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">managed</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">True</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">compute_environment_name</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">.stack_name </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;compute-env&quot;</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        job_queue </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> batch.JobQueue(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;job-queue&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">compute_environments</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">[</span></span>
<span class="line"><span style="color: #ADBAC7">                batch.JobQueueComputeEnvironment(</span></span>
<span class="line"><span style="color: #ADBAC7">                    </span><span style="color: #F69D50">compute_environment</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">managed_env,</span></span>
<span class="line"><span style="color: #ADBAC7">                    </span><span style="color: #F69D50">order</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">100</span></span>
<span class="line"><span style="color: #ADBAC7">                )</span></span>
<span class="line"><span style="color: #ADBAC7">            ],</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">job_queue_name</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">.stack_name </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;job-queue&quot;</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        job_role </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> iam.Role(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;job-role&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">assumed_by</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">iam.CompositePrincipal(</span></span>
<span class="line"><span style="color: #ADBAC7">                iam.ServicePrincipal(</span><span style="color: #96D0FF">&quot;ecs-tasks.amazonaws.com&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">            )</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390"># allow read and write access to S3 bucket</span></span>
<span class="line"><span style="color: #ADBAC7">        bucket.grant_read_write(job_role)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        repo </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ecr.Repository(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;repository&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">removal_policy</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">core.RemovalPolicy.</span><span style="color: #6CB6FF">DESTROY</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        job_def </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> batch.JobDefinition(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;job-definition&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">container</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">batch.JobDefinitionContainer(</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">image</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ecs.ContainerImage.from_ecr_repository(repo),</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">command</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">[</span><span style="color: #96D0FF">&quot;python3&quot;</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;main.py&quot;</span><span style="color: #ADBAC7">],</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">vcpus</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">4</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">gpu_count</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">memory_limit_mib</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">12000</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">job_role</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">job_role,</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">environment</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">{</span></span>
<span class="line"><span style="color: #ADBAC7">                    </span><span style="color: #96D0FF">&quot;BUCKET_NAME&quot;</span><span style="color: #ADBAC7">: bucket.bucket_name</span></span>
<span class="line"><span style="color: #ADBAC7">                }</span></span>
<span class="line"><span style="color: #ADBAC7">            ),</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">job_definition_name</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">.stack_name </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;job-definition&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">timeout</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">core.Duration.hours(</span><span style="color: #6CB6FF">2</span><span style="color: #ADBAC7">),</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">class</span><span style="color: #24292E"> </span><span style="color: #6F42C1">SimpleBatch</span><span style="color: #24292E">(</span><span style="color: #6F42C1">core</span><span style="color: #24292E">.</span><span style="color: #6F42C1">Stack</span><span style="color: #24292E">):</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">def</span><span style="color: #24292E"> </span><span style="color: #005CC5">__init__</span><span style="color: #24292E">(self, scope: core.App, name: </span><span style="color: #005CC5">str</span><span style="color: #24292E">, </span><span style="color: #D73A49">**</span><span style="color: #24292E">kwargs) -&gt; </span><span style="color: #005CC5">None</span><span style="color: #24292E">:</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #005CC5">super</span><span style="color: #24292E">().</span><span style="color: #005CC5">__init__</span><span style="color: #24292E">(scope, name, </span><span style="color: #D73A49">**</span><span style="color: #24292E">kwargs)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        bucket </span><span style="color: #D73A49">=</span><span style="color: #24292E"> s3.Bucket(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;bucket&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">removal_policy</span><span style="color: #D73A49">=</span><span style="color: #24292E">core.RemovalPolicy.</span><span style="color: #005CC5">DESTROY</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">auto_delete_objects</span><span style="color: #D73A49">=</span><span style="color: #005CC5">True</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        vpc </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ec2.Vpc(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;vpc&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #6A737D"># other parameters...</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        managed_env </span><span style="color: #D73A49">=</span><span style="color: #24292E"> batch.ComputeEnvironment(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;managed-env&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">compute_resources</span><span style="color: #D73A49">=</span><span style="color: #24292E">batch.ComputeResources(</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">vpc</span><span style="color: #D73A49">=</span><span style="color: #24292E">vpc,</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">allocation_strategy</span><span style="color: #D73A49">=</span><span style="color: #24292E">batch.AllocationStrategy.</span><span style="color: #005CC5">BEST_FIT</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">desiredv_cpus</span><span style="color: #D73A49">=</span><span style="color: #005CC5">0</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">maxv_cpus</span><span style="color: #D73A49">=</span><span style="color: #005CC5">64</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">minv_cpus</span><span style="color: #D73A49">=</span><span style="color: #005CC5">0</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">instance_types</span><span style="color: #D73A49">=</span><span style="color: #24292E">[</span></span>
<span class="line"><span style="color: #24292E">                    ec2.InstanceType(</span><span style="color: #032F62">&quot;g4dn.xlarge&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">                ],</span></span>
<span class="line"><span style="color: #24292E">            ),</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">managed</span><span style="color: #D73A49">=</span><span style="color: #005CC5">True</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">compute_environment_name</span><span style="color: #D73A49">=</span><span style="color: #005CC5">self</span><span style="color: #24292E">.stack_name </span><span style="color: #D73A49">+</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;compute-env&quot;</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        job_queue </span><span style="color: #D73A49">=</span><span style="color: #24292E"> batch.JobQueue(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;job-queue&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">compute_environments</span><span style="color: #D73A49">=</span><span style="color: #24292E">[</span></span>
<span class="line"><span style="color: #24292E">                batch.JobQueueComputeEnvironment(</span></span>
<span class="line"><span style="color: #24292E">                    </span><span style="color: #E36209">compute_environment</span><span style="color: #D73A49">=</span><span style="color: #24292E">managed_env,</span></span>
<span class="line"><span style="color: #24292E">                    </span><span style="color: #E36209">order</span><span style="color: #D73A49">=</span><span style="color: #005CC5">100</span></span>
<span class="line"><span style="color: #24292E">                )</span></span>
<span class="line"><span style="color: #24292E">            ],</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">job_queue_name</span><span style="color: #D73A49">=</span><span style="color: #005CC5">self</span><span style="color: #24292E">.stack_name </span><span style="color: #D73A49">+</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;job-queue&quot;</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        job_role </span><span style="color: #D73A49">=</span><span style="color: #24292E"> iam.Role(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;job-role&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">assumed_by</span><span style="color: #D73A49">=</span><span style="color: #24292E">iam.CompositePrincipal(</span></span>
<span class="line"><span style="color: #24292E">                iam.ServicePrincipal(</span><span style="color: #032F62">&quot;ecs-tasks.amazonaws.com&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">            )</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D"># allow read and write access to S3 bucket</span></span>
<span class="line"><span style="color: #24292E">        bucket.grant_read_write(job_role)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        repo </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ecr.Repository(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;repository&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">removal_policy</span><span style="color: #D73A49">=</span><span style="color: #24292E">core.RemovalPolicy.</span><span style="color: #005CC5">DESTROY</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        job_def </span><span style="color: #D73A49">=</span><span style="color: #24292E"> batch.JobDefinition(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;job-definition&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">container</span><span style="color: #D73A49">=</span><span style="color: #24292E">batch.JobDefinitionContainer(</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">image</span><span style="color: #D73A49">=</span><span style="color: #24292E">ecs.ContainerImage.from_ecr_repository(repo),</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">command</span><span style="color: #D73A49">=</span><span style="color: #24292E">[</span><span style="color: #032F62">&quot;python3&quot;</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;main.py&quot;</span><span style="color: #24292E">],</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">vcpus</span><span style="color: #D73A49">=</span><span style="color: #005CC5">4</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">gpu_count</span><span style="color: #D73A49">=</span><span style="color: #005CC5">1</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">memory_limit_mib</span><span style="color: #D73A49">=</span><span style="color: #005CC5">12000</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">job_role</span><span style="color: #D73A49">=</span><span style="color: #24292E">job_role,</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">environment</span><span style="color: #D73A49">=</span><span style="color: #24292E">{</span></span>
<span class="line"><span style="color: #24292E">                    </span><span style="color: #032F62">&quot;BUCKET_NAME&quot;</span><span style="color: #24292E">: bucket.bucket_name</span></span>
<span class="line"><span style="color: #24292E">                }</span></span>
<span class="line"><span style="color: #24292E">            ),</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">job_definition_name</span><span style="color: #D73A49">=</span><span style="color: #005CC5">self</span><span style="color: #24292E">.stack_name </span><span style="color: #D73A49">+</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;job-definition&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">timeout</span><span style="color: #D73A49">=</span><span style="color: #24292E">core.Duration.hours(</span><span style="color: #005CC5">2</span><span style="color: #24292E">),</span></span>
<span class="line"><span style="color: #24292E">        )</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br><span class="line-number">36</span><br><span class="line-number">37</span><br><span class="line-number">38</span><br><span class="line-number">39</span><br><span class="line-number">40</span><br><span class="line-number">41</span><br><span class="line-number">42</span><br><span class="line-number">43</span><br><span class="line-number">44</span><br><span class="line-number">45</span><br><span class="line-number">46</span><br><span class="line-number">47</span><br><span class="line-number">48</span><br><span class="line-number">49</span><br><span class="line-number">50</span><br><span class="line-number">51</span><br><span class="line-number">52</span><br><span class="line-number">53</span><br><span class="line-number">54</span><br><span class="line-number">55</span><br><span class="line-number">56</span><br><span class="line-number">57</span><br><span class="line-number">58</span><br><span class="line-number">59</span><br><span class="line-number">60</span><br><span class="line-number">61</span><br><span class="line-number">62</span><br><span class="line-number">63</span><br><span class="line-number">64</span><br><span class="line-number">65</span><br><span class="line-number">66</span><br><span class="line-number">67</span><br><span class="line-number">68</span><br><span class="line-number">69</span><br><span class="line-number">70</span><br><span class="line-number">71</span><br><span class="line-number">72</span><br><span class="line-number">73</span><br><span class="line-number">74</span><br><span class="line-number">75</span><br><span class="line-number">76</span><br><span class="line-number">77</span><br><span class="line-number">78</span><br><span class="line-number">79</span><br></div></div><ul>
<li>
<p>で，計算結果を保存するための S3 バケットを用意している</p>
</li>
<li>
<p>で， Compute environment を定義している． ここでは <code>g4dn.xlarge</code> のインスタンスタイプを使用するとし，最大の vCPU 使用数は 64 と指定している． また，最小の vCPU は 0 である． 今回は，負荷がかかっていないときにアイドリング状態にあるインスタンスを用意する利点は全くないので，ここは 0 にするのが望ましい．</p>
</li>
<li>
<p>で， &lt;2&gt; で作成した Compute environment と紐付いた Job queue を定義している．</p>
</li>
<li>
<p>で，ジョブが計算結果を S3 に書き込むことができるよう， IAM ロールを定義している． (IAM とはリソースがもつ権限を管理する仕組みである．詳しくは <a href="#sec:bashoutter_iam">AWS における権限の管理 (IAM)</a> を参照)</p>
</li>
<li>
<p>では， Docker image を配置するための ECR を定義している．</p>
</li>
<li>
<p>で Job definition を作成している． ここでは，4 vCPU， 12000 MB (=12GB) の RAM を使用するように指定している． また，今後必要となる環境変数 (<code>BUCKET_NAME</code>) を設定している． さらに， &lt;4&gt; で作った IAM を付与している．</p>
</li>
</ul>
<p><code>g4dn.xlarge</code> は 1 台あたり 4 vCPU が割り当てられている． このプログラムでは Compute environment の maximum vCPUs を 64 と指定しているので，最大で 16 台のインスタンスが同時に起動することになる． ここで maxium vCPUs を 64 に限定しているのは，なんらかのミスで意図せぬジョブを大量にクラスターに投入してしまった事態で，高額の AWS 利用料金が発生するのを防ぐためである． もし，自分のアプリケーションで必要と判断したならば自己責任において 64 よりも大きな数を設定して構わない．</p>
<p>ここで注意が一点ある． AWS では各アカウントごとに EC2 で起動できるインスタンスの上限が設定されている． この上限は AWS コンソールにログインし， EC2 コンソールの左側メニューバーの <code>Limits</code> をクリックすることで確認できる (<a href="#fig_ec2_limits">figure_title</a>)． <code>g4dn.xlarge</code> (EC2 の区分でいうと G ファミリーに属する) の制限を確認するには， <code>Running On-Demand All G instances</code> という名前の項目を見る． ここにある数字が， AWS によって課されたアカウントの上限であり，この上限を超えたインスタンスを起動することはできない． もし，自分の用途に対して上限が低すぎる場合は，上限の緩和申請を行うことができる． 詳しくは <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-resource-limits.html" target="_blank" rel="noreferrer">公式ドキュメンテーション &quot;Amazon EC2 service quotas&quot;</a> を参照のこと．</p>
<p><img src="./assets/aws_batch/ec2_limits.png" alt="EC2コンソールから各種の上限を確認する"></p>
<h2 id="スタックのデプロイ-2" tabindex="-1">スタックのデプロイ <a class="header-anchor" href="#スタックのデプロイ-2" aria-label="Permalink to &quot;スタックのデプロイ&quot;">&ZeroWidthSpace;</a></h2>
<p>スタックの中身が理解できたところで，早速スタックをデプロイしてみよう．</p>
<p>デプロイの手順は，これまでのハンズオンとほとんど共通である． ここでは，コマンドのみ列挙する (# で始まる行はコメントである)． シークレットキーの設定も忘れずに (<a href="#aws_cli_install">AWS CLI のインストール</a>)．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390"># プロジェクトのディレクトリに移動</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cd</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">handson/aws-batch</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># venv を作成し，依存ライブラリのインストールを行う</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python3</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-m</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">venv</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.env</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">source</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.env/bin/activate</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">pip</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">install</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-r</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">requirements.txt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># デプロイを実行</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cdk</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">deploy</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D"># プロジェクトのディレクトリに移動</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cd</span><span style="color: #24292E"> </span><span style="color: #032F62">handson/aws-batch</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># venv を作成し，依存ライブラリのインストールを行う</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python3</span><span style="color: #24292E"> </span><span style="color: #005CC5">-m</span><span style="color: #24292E"> </span><span style="color: #032F62">venv</span><span style="color: #24292E"> </span><span style="color: #032F62">.env</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">source</span><span style="color: #24292E"> </span><span style="color: #032F62">.env/bin/activate</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">pip</span><span style="color: #24292E"> </span><span style="color: #032F62">install</span><span style="color: #24292E"> </span><span style="color: #005CC5">-r</span><span style="color: #24292E"> </span><span style="color: #032F62">requirements.txt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># デプロイを実行</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cdk</span><span style="color: #24292E"> </span><span style="color: #032F62">deploy</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br></div></div><p>デプロイのコマンドが無事に実行されたことが確認できたら，AWS コンソールにログインして，デプロイされたスタックを確認してみよう． コンソールの検索バーで <code>batch</code> と入力し， AWS Batch の管理画面を開く (<a href="#fig_batch_console">figure_title</a>)．</p>
<p><img src="./assets/aws_batch/batch_console.png" alt="AWS Batch のコンソール画面 (ダッシュボード)"></p>
<p>まず目を向けてほしいのが，画面の一番下にある Compute environment overview の中の <code>SimpleBatchcompute-env</code> という名前の項目だ． Compute environment とは，先ほど述べたとおり，計算が実行される環境 (クラスターと読み替えてもよい) である． プログラムで指定したとおり， <code>g4dn.xlarge</code> が実際に使用されるインスタンスタイプとして表示されている． また， <code>Minimum vCPUs</code> が 0，<code>Maximum vCPUs</code> が 64 と設定されていることも見て取れる． 加えて，この時点では一つもジョブが走っていないので， <code>Desired vCPUs</code> は 0 になっている． より詳細な Compute environment の情報を閲覧したい場合は，名前をクリックすることで詳細画面が開く．</p>
<p>次に，Job queue overview にある <code>SimpleBatch-queue</code> という項目に注目してほしい． ここでは実行待ちのジョブ・実行中のジョブ・実行が完了したジョブを一覧で確認することができる． <code>PENDING</code>, <code>RUNNING</code>, <code>SUCCEEDED</code>, <code>FAILED</code> などのカラムがあることが確認できる．ジョブが進行するにつれて，ジョブの状態がこのカラムにしたがって遷移していく． 後でジョブを実際にサブミットしたときに戻ってこよう．</p>
<p>最後に，今回作成した Job definition を確認しよう． 左側のメニューから　<code>Job definitions</code> を選択し，次の画面で <code>SimpleBatchjob-definition</code> という項目を見つけて開く． ここから Job definition の詳細を閲覧することができる (<a href="#fig:batch_job_definition">figure_title</a>)． 中でも重要な情報としては，　<code>vCPUs</code>, <code>Memory</code>, <code>GPU</code> がそれぞれ Docker に割り当てられる vCPU・メモリー・ GPU の量を規定している． また， <code>Image</code> と書いてあるところに，ジョブで使用される Docker イメージが指定されている． ここでは， ECR のレポジトリを参照している． 現時点ではこの ECR は空である． 次のステップとして，この ECR にイメージを配置する作業を行おう．</p>
<p><img src="./assets/aws_batch/batch_job_definition.png" alt="AWS Batch から Job definition を確認"></p>
<h2 id="docker-image-を-ecr-に配置する" tabindex="-1">Docker image を ECR に配置する <a class="header-anchor" href="#docker-image-を-ecr-に配置する" aria-label="Permalink to &quot;Docker image を ECR に配置する&quot;">&ZeroWidthSpace;</a></h2>
<p>さて， Batch がジョブを実行するには，どこか指定された場所から Docker イメージをダウンロード (pull) してくる必要がある． 前回のハンズオン (<a href="#sec_fargate_qabot">Hands-on #3: AWS で自動質問回答ボットを走らせる</a>) では，公開設定にしてある Docker Hub からイメージを pull してきた． 今回のハンズオンでは， AWS から提供されているレジストリである <strong>ECR (Elastic Container Registry)</strong> に image を配置するという設計を採用する． ECR を利用する利点は，自分だけがアクセスすることのできるプライベートなイメージの置き場所を用意できる点である． Batch は ECR からイメージを pull してくることで，タスクを実行する (<a href="#fig_batch_architecture">figure_title</a>)．</p>
<p>スタックのソースコードでいうと，次の箇所が ECR を定義している．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">repo </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ecr.Repository(</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;repository&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">removal_policy</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">core.RemovalPolicy.</span><span style="color: #6CB6FF">DESTROY</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">job_def </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> batch.JobDefinition(</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;job-definition&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">container</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">batch.JobDefinitionContainer(</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #F69D50">image</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ecs.ContainerImage.from_ecr_repository(repo), </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #6CB6FF">...</span></span>
<span class="line"><span style="color: #ADBAC7">    ),</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">...</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">repo </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ecr.Repository(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;repository&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">removal_policy</span><span style="color: #D73A49">=</span><span style="color: #24292E">core.RemovalPolicy.</span><span style="color: #005CC5">DESTROY</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">job_def </span><span style="color: #D73A49">=</span><span style="color: #24292E"> batch.JobDefinition(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;job-definition&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">container</span><span style="color: #D73A49">=</span><span style="color: #24292E">batch.JobDefinitionContainer(</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #E36209">image</span><span style="color: #D73A49">=</span><span style="color: #24292E">ecs.ContainerImage.from_ecr_repository(repo), </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #005CC5">...</span></span>
<span class="line"><span style="color: #24292E">    ),</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">...</span></span>
<span class="line"><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br></div></div><ul>
<li>
<p>で，新規の ECR を作成している．</p>
</li>
<li>
<p>で Job definition を定義する中で，イメージを &lt;1&gt; で作った ECR から取得するように指定している． これと同時に， Job definition には ECR へのアクセス権限が IAM を通じて自動的に付与される．</p>
</li>
</ul>
<p>さて，スタックをデプロイした時点では， ECR は空っぽである． ここに自分のアプリケーションで使う Docker イメージを push してあげる必要がある．</p>
<p>そのために，まずは AWS コンソールから ECR の画面を開こう (検索バーに <code>Elastic Container Registry</code> と入力すると出てくる)． <code>Private</code> というタブを選択すると， <code>simplebatch-repositoryXXXXXX</code> という名前のレポジトリが見つかるだろう (<a href="#fig_ecr_console1">figure_title</a>)．</p>
<p><img src="./assets/aws_batch/ecr_console1.png" alt="ECR のコンソール画面"></p>
<p>次に，このレポジトリの名前をクリックするとレポジトリの詳細画面に遷移する． そうしたら，画面右上にある <code>View push commands</code> というボタンをクリックする． すると <a href="#fig_ecr_push_command">figure_title</a> のようなポップアップ画面が立ち上がる．</p>
<p><img src="./assets/aws_batch/ecr_push_command.png" alt="ECR への push コマンド"></p>
<p>このポップアップ画面で表示されている四つのコマンドを順番に実行していくことで，手元の Docker イメージを ECR に push することができる． <strong>push を実行する前に， AWS の認証情報が設定されている</strong>ことを確認しよう． そのうえで，ハンズオンのソースコードの中にある <strong><code>docker/</code> という名前のディレクトリに移動</strong>する． そうしたら，ポップアップ画面で表示されたコマンドを上から順に実行していく．</p>
<p>ポップアップで表示されるコマンドの 2 つめを見てみると <code>docker build -t XXXXX .</code> となっている． 最後の <code>.</code> が重要で，これは <em>現在のディレクトリにある Dockerfile を使ってイメージをビルドせよ</em> という意味である． このような理由で， <code>Dockerfile</code> が置いてあるディレクトリに移動する必要がある．</p>
<p>四つ目のコマンドは，数 GB あるイメージを ECR にアップロードするので少し時間がかかるかもしれないが，これが完了するとめでたくイメージが ECR に配置されたことになる． もう一度 ECR のコンソールを見てみると，確かにイメージが配置されていることが確認できる (<a href="#fig_ecr_console2">figure_title</a>)． これで，AWS Batch を使ってジョブを実行させるための最後の準備が完了した．</p>
<p><img src="./assets/aws_batch/ecr_console2.png" alt="ECR へ image の配置が完了した"></p>
<h2 id="単一のジョブを実行する" tabindex="-1">単一のジョブを実行する <a class="header-anchor" href="#単一のジョブを実行する" aria-label="Permalink to &quot;単一のジョブを実行する&quot;">&ZeroWidthSpace;</a></h2>
<p>さて，ここからは実際に AWS Batch にジョブを投入する方法を見ていこう．</p>
<p>ハンズオンのディレクトリの <code>notebook/</code> というディレクトリの中に， <a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/aws-batch/notebook/run_single.ipynb" target="_blank" rel="noreferrer">run_single.ipynb</a> というファイルが見つかるはずである (<code>.ipynb</code> は Jupyter notebook のファイル形式)． これを Jupyter notebook から開こう．</p>
<p>今回のハンズオンでは， <code>venv</code> による仮想環境の中に Jupyter notebook もインストール済みである． なので，ローカルマシンから以下のコマンドで Jupyter notebook を立ち上げる．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390"># .env の仮想環境にいることを確認</span></span>
<span class="line"><span style="color: #ADBAC7">(</span><span style="color: #F69D50">.env</span><span style="color: #ADBAC7">) $ cd notebook</span></span>
<span class="line"><span style="color: #ADBAC7">(</span><span style="color: #F69D50">.env</span><span style="color: #ADBAC7">) $ jupyter notebook</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D"># .env の仮想環境にいることを確認</span></span>
<span class="line"><span style="color: #24292E">(</span><span style="color: #6F42C1">.env</span><span style="color: #24292E">) $ cd notebook</span></span>
<span class="line"><span style="color: #24292E">(</span><span style="color: #6F42C1">.env</span><span style="color: #24292E">) $ jupyter notebook</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><p>Jupyter notebook が起動したら， <code>run_single.ipynb</code> を開く．</p>
<p>最初の [1], [2], [3] 番のセルは，ジョブをサブミットするための関数 (<code>submit_job()</code>) を定義している．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390"># [1]</span></span>
<span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> boto3</span></span>
<span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> argparse</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># [2]</span></span>
<span class="line"><span style="color: #768390"># AWS 認証ヘルパー ...省略...</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># [3]</span></span>
<span class="line"><span style="color: #F47067">def</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">submit_job</span><span style="color: #ADBAC7">(lr:</span><span style="color: #6CB6FF">float</span><span style="color: #ADBAC7">, momentum:</span><span style="color: #6CB6FF">float</span><span style="color: #ADBAC7">, epochs:</span><span style="color: #6CB6FF">int</span><span style="color: #ADBAC7">, profile_name</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;default&quot;</span><span style="color: #ADBAC7">):</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> profile_name </span><span style="color: #F47067">is</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">None</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">        session </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> boto3.Session()</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">else</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">        session </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> boto3.Session(</span><span style="color: #F69D50">profile_name</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">profile_name)</span></span>
<span class="line"><span style="color: #ADBAC7">    client </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> session.client(</span><span style="color: #96D0FF">&quot;batch&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    title </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;lr&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">(lr).replace(</span><span style="color: #96D0FF">&quot;.&quot;</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;&quot;</span><span style="color: #ADBAC7">) </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;_m&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">(momentum).replace(</span><span style="color: #96D0FF">&quot;.&quot;</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">    resp </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> client.submit_job(</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #F69D50">jobName</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">title,</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #F69D50">jobQueue</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;SimpleBatchjob-queue&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #F69D50">jobDefinition</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;SimpleBatchjob-definition&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #F69D50">containerOverrides</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">{</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #96D0FF">&quot;command&quot;</span><span style="color: #ADBAC7">: [</span><span style="color: #96D0FF">&quot;--lr&quot;</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">(lr),</span></span>
<span class="line"><span style="color: #ADBAC7">                        </span><span style="color: #96D0FF">&quot;--momentum&quot;</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">(momentum),</span></span>
<span class="line"><span style="color: #ADBAC7">                        </span><span style="color: #96D0FF">&quot;--epochs&quot;</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">(epochs),</span></span>
<span class="line"><span style="color: #ADBAC7">                        </span><span style="color: #96D0FF">&quot;--uploadS3&quot;</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;true&quot;</span><span style="color: #ADBAC7">]</span></span>
<span class="line"><span style="color: #ADBAC7">        }</span></span>
<span class="line"><span style="color: #ADBAC7">    )</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">print</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;Job submitted!&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">print</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;job name&quot;</span><span style="color: #ADBAC7">, resp[</span><span style="color: #96D0FF">&quot;jobName&quot;</span><span style="color: #ADBAC7">], </span><span style="color: #96D0FF">&quot;job ID&quot;</span><span style="color: #ADBAC7">, resp[</span><span style="color: #96D0FF">&quot;jobId&quot;</span><span style="color: #ADBAC7">])</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D"># [1]</span></span>
<span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> boto3</span></span>
<span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> argparse</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># [2]</span></span>
<span class="line"><span style="color: #6A737D"># AWS 認証ヘルパー ...省略...</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># [3]</span></span>
<span class="line"><span style="color: #D73A49">def</span><span style="color: #24292E"> </span><span style="color: #6F42C1">submit_job</span><span style="color: #24292E">(lr:</span><span style="color: #005CC5">float</span><span style="color: #24292E">, momentum:</span><span style="color: #005CC5">float</span><span style="color: #24292E">, epochs:</span><span style="color: #005CC5">int</span><span style="color: #24292E">, profile_name</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;default&quot;</span><span style="color: #24292E">):</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">if</span><span style="color: #24292E"> profile_name </span><span style="color: #D73A49">is</span><span style="color: #24292E"> </span><span style="color: #005CC5">None</span><span style="color: #24292E">:</span></span>
<span class="line"><span style="color: #24292E">        session </span><span style="color: #D73A49">=</span><span style="color: #24292E"> boto3.Session()</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">else</span><span style="color: #24292E">:</span></span>
<span class="line"><span style="color: #24292E">        session </span><span style="color: #D73A49">=</span><span style="color: #24292E"> boto3.Session(</span><span style="color: #E36209">profile_name</span><span style="color: #D73A49">=</span><span style="color: #24292E">profile_name)</span></span>
<span class="line"><span style="color: #24292E">    client </span><span style="color: #D73A49">=</span><span style="color: #24292E"> session.client(</span><span style="color: #032F62">&quot;batch&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">    title </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;lr&quot;</span><span style="color: #24292E"> </span><span style="color: #D73A49">+</span><span style="color: #24292E"> </span><span style="color: #005CC5">str</span><span style="color: #24292E">(lr).replace(</span><span style="color: #032F62">&quot;.&quot;</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;&quot;</span><span style="color: #24292E">) </span><span style="color: #D73A49">+</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;_m&quot;</span><span style="color: #24292E"> </span><span style="color: #D73A49">+</span><span style="color: #24292E"> </span><span style="color: #005CC5">str</span><span style="color: #24292E">(momentum).replace(</span><span style="color: #032F62">&quot;.&quot;</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">    resp </span><span style="color: #D73A49">=</span><span style="color: #24292E"> client.submit_job(</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #E36209">jobName</span><span style="color: #D73A49">=</span><span style="color: #24292E">title,</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #E36209">jobQueue</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;SimpleBatchjob-queue&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #E36209">jobDefinition</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;SimpleBatchjob-definition&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #E36209">containerOverrides</span><span style="color: #D73A49">=</span><span style="color: #24292E">{</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #032F62">&quot;command&quot;</span><span style="color: #24292E">: [</span><span style="color: #032F62">&quot;--lr&quot;</span><span style="color: #24292E">, </span><span style="color: #005CC5">str</span><span style="color: #24292E">(lr),</span></span>
<span class="line"><span style="color: #24292E">                        </span><span style="color: #032F62">&quot;--momentum&quot;</span><span style="color: #24292E">, </span><span style="color: #005CC5">str</span><span style="color: #24292E">(momentum),</span></span>
<span class="line"><span style="color: #24292E">                        </span><span style="color: #032F62">&quot;--epochs&quot;</span><span style="color: #24292E">, </span><span style="color: #005CC5">str</span><span style="color: #24292E">(epochs),</span></span>
<span class="line"><span style="color: #24292E">                        </span><span style="color: #032F62">&quot;--uploadS3&quot;</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;true&quot;</span><span style="color: #24292E">]</span></span>
<span class="line"><span style="color: #24292E">        }</span></span>
<span class="line"><span style="color: #24292E">    )</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">print</span><span style="color: #24292E">(</span><span style="color: #032F62">&quot;Job submitted!&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">print</span><span style="color: #24292E">(</span><span style="color: #032F62">&quot;job name&quot;</span><span style="color: #24292E">, resp[</span><span style="color: #032F62">&quot;jobName&quot;</span><span style="color: #24292E">], </span><span style="color: #032F62">&quot;job ID&quot;</span><span style="color: #24292E">, resp[</span><span style="color: #032F62">&quot;jobId&quot;</span><span style="color: #24292E">])</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br></div></div><p><code>submit_job()</code> 関数について簡単に説明しよう． <a href="#sec_run_mnist_docker_local">MNIST 手書き文字認識 (再訪)</a> で， MNIST の Docker をローカルで実行したとき，次のようなコマンドを使用した．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">docker</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">run</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-it</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">mymnist</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--lr</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0.1</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--momentum</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">0.5</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--epochs</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">10</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">docker</span><span style="color: #24292E"> </span><span style="color: #032F62">run</span><span style="color: #24292E"> </span><span style="color: #005CC5">-it</span><span style="color: #24292E"> </span><span style="color: #032F62">mymnist</span><span style="color: #24292E"> </span><span style="color: #005CC5">--lr</span><span style="color: #24292E"> </span><span style="color: #005CC5">0.1</span><span style="color: #24292E"> </span><span style="color: #005CC5">--momentum</span><span style="color: #24292E"> </span><span style="color: #005CC5">0.5</span><span style="color: #24292E"> </span><span style="color: #005CC5">--epochs</span><span style="color: #24292E"> </span><span style="color: #005CC5">10</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>ここで， <code>--lr 0.1 --momentum 0.5 --epochs 10</code> の部分が，コンテナに渡されるコマンドである．</p>
<p>AWS Batch でジョブを実行する際も，<code>ContainerOverrides</code> の <code>command</code> というパラメータを使用することで，コンテナに渡されるコマンドを指定することができる． コードでは以下の部分が該当する．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">containerOverrides</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">{</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #96D0FF">&quot;command&quot;</span><span style="color: #ADBAC7">: [</span><span style="color: #96D0FF">&quot;--lr&quot;</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">(lr),</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #96D0FF">&quot;--momentum&quot;</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">(momentum),</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #96D0FF">&quot;--epochs&quot;</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">(epochs),</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #96D0FF">&quot;--uploadS3&quot;</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;true&quot;</span><span style="color: #ADBAC7">]</span></span>
<span class="line"><span style="color: #ADBAC7">}</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">containerOverrides</span><span style="color: #D73A49">=</span><span style="color: #24292E">{</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #032F62">&quot;command&quot;</span><span style="color: #24292E">: [</span><span style="color: #032F62">&quot;--lr&quot;</span><span style="color: #24292E">, </span><span style="color: #005CC5">str</span><span style="color: #24292E">(lr),</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #032F62">&quot;--momentum&quot;</span><span style="color: #24292E">, </span><span style="color: #005CC5">str</span><span style="color: #24292E">(momentum),</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #032F62">&quot;--epochs&quot;</span><span style="color: #24292E">, </span><span style="color: #005CC5">str</span><span style="color: #24292E">(epochs),</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #032F62">&quot;--uploadS3&quot;</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;true&quot;</span><span style="color: #24292E">]</span></span>
<span class="line"><span style="color: #24292E">}</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br></div></div><p>続いて， [4] 番のセルに移ろう． ここでは，上記の <code>submit_job()</code> 関数を用いて， 学習率 = 0.01, モメンタム=0.1, エポック数=100 を指定したジョブを投入する．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390"># [4]</span></span>
<span class="line"><span style="color: #ADBAC7">submit_job(</span><span style="color: #6CB6FF">0.01</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">0.1</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">100</span><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D"># [4]</span></span>
<span class="line"><span style="color: #24292E">submit_job(</span><span style="color: #005CC5">0.01</span><span style="color: #24292E">, </span><span style="color: #005CC5">0.1</span><span style="color: #24292E">, </span><span style="color: #005CC5">100</span><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>AWS の認証情報は， Jupyter Notebook の内部から再度定義する必要がある． これを手助けするため， Notebook の [2] 番のセル (デフォルトではすべてコメントアウトされている) を用意した． これを使うにはコメントアウトを解除すればよい． このセルを実行すると， AWS の認証情報を入力する対話的なプロンプトが表示される． プロンプトに従って aws secret key などを入力することで， (Jupyter のセッションに固有な) 環境変数に AWS の認証情報が記録される．</p>
<p>もう一つの認証方法として， <code>submit_job()</code> 関数に <code>profile_name</code> というパラメータを用意した． もし <code>~/.aws/credentials</code> に認証情報が書き込まれているのならば (詳しくは <a href="#aws_cli_install">AWS CLI のインストール</a>)， <code>profile_name</code> に使用したいプロファイルの名前を渡すだけで， 認証を行うことができる． 慣れている読者は後者のほうが便利であると感じるだろう．</p>
<p>[4] 番のセルを実行したら，ジョブが実際に投入されたかどうかを AWS コンソールから確認してみよう． AWS Batch の管理コンソールを開くと， <a href="#fig_batch_running_job">figure_title</a> のような画面が表示されるだろう．</p>
<p><img src="./assets/aws_batch/batch_running_job.png" alt="AWS Batch でジョブが実行されている様子"></p>
<p><a href="#fig_batch_running_job">figure_title</a> で赤で囲った箇所に注目してほしい． 一つのジョブが投入されると，それは <code>SUBMITTED</code> という状態を経て <code>RUNNABLE</code> という状態に遷移する． <code>RUNNABLE</code> とは， ジョブを実行するためのインスタンスが Compute environment に不足しているため，新たなインスタンスが起動されるのを待っている状態に相当する． インスタンスの準備が整うと，ジョブの状態は <code>STARTING</code> を経て <code>RUNNING</code> に至る．</p>
<p>次に，ジョブのステータスが <code>RUNNING</code> のときの Compute environment の <code>Desired vCPU</code> を見てみよう (<a href="#fig_batch_running_job">figure_title</a> で紫で囲った箇所)． ここで 4 と表示されているのは， <code>g4dn.xlarge</code> インスタンス一つ分の vCPU の数である． ジョブの投入に応じて，それを実行するのに最低限必要な EC2 インスタンスが起動されたことが確認できる (興味のある人は， EC2 コンソールも同時に覗いてみるとよい)．</p>
<p>しばらく経つと，ジョブの状態は <code>RUNNING</code> から <code>SUCCEEDED</code> (あるいは何らかの理由でエラーが発生したときには <code>FAILED</code>) に遷移する． 今回のハンズオンで使っている MNIST の学習はだいたい 10 分くらいで完了するはずである． ジョブの状態が <code>SUCCEEDED</code> になるまで見届けよう．</p>
<p>ジョブが完了すると，学習の結果 (エポックごとの Loss と Accuracy を記録した CSV ファイル) は S3 に保存される． AWS コンソールからこれを確認しよう．</p>
<p>S3 のコンソールに行くと <code>simplebatch-bucketXXXX</code> (XXXX の部分はユーザーによって異なる) という名前のバケットが見つかるはずである． これをクリックして中身を見てみると， <code>metrics_lr0.0100_m0.1000.csv</code> という名前の CSV があることが確認できるだろう (<a href="#fig_s3_saved_file">figure_title</a>)． これが， 学習率 = 0.01, モメンタム = 0.1 として学習を行ったときの結果である．</p>
<p><img src="./assets/aws_batch/s3_saved_file.png" alt="ジョブの実行結果は S3 に保存される"></p>
<p>さて，ここで <code>run_single.ipynb</code> に戻ってこよう． [5] から [7] 番のセルでは，学習結果の CSV ファイルのダウンロードを行っている．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390"># [5]</span></span>
<span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> pandas </span><span style="color: #F47067">as</span><span style="color: #ADBAC7"> pd</span></span>
<span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> io</span></span>
<span class="line"><span style="color: #F47067">from</span><span style="color: #ADBAC7"> matplotlib </span><span style="color: #F47067">import</span><span style="color: #ADBAC7"> pyplot </span><span style="color: #F47067">as</span><span style="color: #ADBAC7"> plt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># [6]</span></span>
<span class="line"><span style="color: #F47067">def</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">read_table_from_s3</span><span style="color: #ADBAC7">(bucket_name, key, profile_name</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">None</span><span style="color: #ADBAC7">):</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> profile_name </span><span style="color: #F47067">is</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">None</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">        session </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> boto3.Session()</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">else</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">        session </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> boto3.Session(</span><span style="color: #F69D50">profile_name</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">profile_name)</span></span>
<span class="line"><span style="color: #ADBAC7">    s3 </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> session.resource(</span><span style="color: #96D0FF">&quot;s3&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">    bucket </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> s3.Bucket(bucket_name)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    obj </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> bucket.Object(key).get().get(</span><span style="color: #96D0FF">&quot;Body&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">    df </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> pd.read_csv(obj)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">return</span><span style="color: #ADBAC7"> df</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># [7]</span></span>
<span class="line"><span style="color: #ADBAC7">bucket_name </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;simplebatch-bucket43879c71-mbqaltx441fu&quot;</span></span>
<span class="line"><span style="color: #ADBAC7">df </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> read_table_from_s3(</span></span>
<span class="line"><span style="color: #ADBAC7">    bucket_name,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #96D0FF">&quot;metrics_lr0.0100_m0.1000.csv&quot;</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D"># [5]</span></span>
<span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> pandas </span><span style="color: #D73A49">as</span><span style="color: #24292E"> pd</span></span>
<span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> io</span></span>
<span class="line"><span style="color: #D73A49">from</span><span style="color: #24292E"> matplotlib </span><span style="color: #D73A49">import</span><span style="color: #24292E"> pyplot </span><span style="color: #D73A49">as</span><span style="color: #24292E"> plt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># [6]</span></span>
<span class="line"><span style="color: #D73A49">def</span><span style="color: #24292E"> </span><span style="color: #6F42C1">read_table_from_s3</span><span style="color: #24292E">(bucket_name, key, profile_name</span><span style="color: #D73A49">=</span><span style="color: #005CC5">None</span><span style="color: #24292E">):</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">if</span><span style="color: #24292E"> profile_name </span><span style="color: #D73A49">is</span><span style="color: #24292E"> </span><span style="color: #005CC5">None</span><span style="color: #24292E">:</span></span>
<span class="line"><span style="color: #24292E">        session </span><span style="color: #D73A49">=</span><span style="color: #24292E"> boto3.Session()</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">else</span><span style="color: #24292E">:</span></span>
<span class="line"><span style="color: #24292E">        session </span><span style="color: #D73A49">=</span><span style="color: #24292E"> boto3.Session(</span><span style="color: #E36209">profile_name</span><span style="color: #D73A49">=</span><span style="color: #24292E">profile_name)</span></span>
<span class="line"><span style="color: #24292E">    s3 </span><span style="color: #D73A49">=</span><span style="color: #24292E"> session.resource(</span><span style="color: #032F62">&quot;s3&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">    bucket </span><span style="color: #D73A49">=</span><span style="color: #24292E"> s3.Bucket(bucket_name)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">    obj </span><span style="color: #D73A49">=</span><span style="color: #24292E"> bucket.Object(key).get().get(</span><span style="color: #032F62">&quot;Body&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">    df </span><span style="color: #D73A49">=</span><span style="color: #24292E"> pd.read_csv(obj)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">return</span><span style="color: #24292E"> df</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># [7]</span></span>
<span class="line"><span style="color: #24292E">bucket_name </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;simplebatch-bucket43879c71-mbqaltx441fu&quot;</span></span>
<span class="line"><span style="color: #24292E">df </span><span style="color: #D73A49">=</span><span style="color: #24292E"> read_table_from_s3(</span></span>
<span class="line"><span style="color: #24292E">    bucket_name,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #032F62">&quot;metrics_lr0.0100_m0.1000.csv&quot;</span></span>
<span class="line"><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br></div></div><p>[6] で S3 から CSV データをダウンロードし， pandas の <code>DataFrame</code> オブジェクトとしてロードする関数を定義している． [7] を実行する際， <code>bucket_name</code> という変数の値を，<strong>自分自身のバケットの名前に置き換える</strong>ことに注意しよう (先ほど S3 コンソールから確認した <code>simplebatch-bucketXXXX</code> のことである)．</p>
<p>続いて， [9] 番のセルで， CSV のデータをプロットしている (<a href="#fig_loss_epoch_profile2">figure_title</a>)． ローカルで実行したときと同じように， AWS Batch を用いて MNIST モデルを訓練することに成功した！</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390"># [9]</span></span>
<span class="line"><span style="color: #ADBAC7">fig, (ax1, ax2) </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> plt.subplots(</span><span style="color: #6CB6FF">1</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">2</span><span style="color: #ADBAC7">, </span><span style="color: #F69D50">figsize</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">9</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">4</span><span style="color: #ADBAC7">))</span></span>
<span class="line"><span style="color: #ADBAC7">x </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> [i </span><span style="color: #F47067">for</span><span style="color: #ADBAC7"> i </span><span style="color: #F47067">in</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">range</span><span style="color: #ADBAC7">(df.shape[</span><span style="color: #6CB6FF">0</span><span style="color: #ADBAC7">])]</span></span>
<span class="line"><span style="color: #ADBAC7">ax1.plot(x, df[</span><span style="color: #96D0FF">&quot;train_loss&quot;</span><span style="color: #ADBAC7">], </span><span style="color: #F69D50">label</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;Train&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">ax1.plot(x, df[</span><span style="color: #96D0FF">&quot;val_loss&quot;</span><span style="color: #ADBAC7">], </span><span style="color: #F69D50">label</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;Val&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">ax2.plot(x, df[</span><span style="color: #96D0FF">&quot;val_accuracy&quot;</span><span style="color: #ADBAC7">])</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">ax1.set_xlabel(</span><span style="color: #96D0FF">&quot;Epochs&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">ax1.set_ylabel(</span><span style="color: #96D0FF">&quot;Loss&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">ax1.legend()</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">ax2.set_xlabel(</span><span style="color: #96D0FF">&quot;Epochs&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">ax2.set_ylabel(</span><span style="color: #96D0FF">&quot;Accuracy&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6CB6FF">print</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;Best loss:&quot;</span><span style="color: #ADBAC7">, df[</span><span style="color: #96D0FF">&quot;val_loss&quot;</span><span style="color: #ADBAC7">].min())</span></span>
<span class="line"><span style="color: #6CB6FF">print</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;Best loss epoch:&quot;</span><span style="color: #ADBAC7">, df[</span><span style="color: #96D0FF">&quot;val_loss&quot;</span><span style="color: #ADBAC7">].argmin())</span></span>
<span class="line"><span style="color: #6CB6FF">print</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;Best accuracy:&quot;</span><span style="color: #ADBAC7">, df[</span><span style="color: #96D0FF">&quot;val_accuracy&quot;</span><span style="color: #ADBAC7">].max())</span></span>
<span class="line"><span style="color: #6CB6FF">print</span><span style="color: #ADBAC7">(</span><span style="color: #96D0FF">&quot;Best accuracy epoch:&quot;</span><span style="color: #ADBAC7">, df[</span><span style="color: #96D0FF">&quot;val_accuracy&quot;</span><span style="color: #ADBAC7">].argmax())</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D"># [9]</span></span>
<span class="line"><span style="color: #24292E">fig, (ax1, ax2) </span><span style="color: #D73A49">=</span><span style="color: #24292E"> plt.subplots(</span><span style="color: #005CC5">1</span><span style="color: #24292E">,</span><span style="color: #005CC5">2</span><span style="color: #24292E">, </span><span style="color: #E36209">figsize</span><span style="color: #D73A49">=</span><span style="color: #24292E">(</span><span style="color: #005CC5">9</span><span style="color: #24292E">,</span><span style="color: #005CC5">4</span><span style="color: #24292E">))</span></span>
<span class="line"><span style="color: #24292E">x </span><span style="color: #D73A49">=</span><span style="color: #24292E"> [i </span><span style="color: #D73A49">for</span><span style="color: #24292E"> i </span><span style="color: #D73A49">in</span><span style="color: #24292E"> </span><span style="color: #005CC5">range</span><span style="color: #24292E">(df.shape[</span><span style="color: #005CC5">0</span><span style="color: #24292E">])]</span></span>
<span class="line"><span style="color: #24292E">ax1.plot(x, df[</span><span style="color: #032F62">&quot;train_loss&quot;</span><span style="color: #24292E">], </span><span style="color: #E36209">label</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;Train&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">ax1.plot(x, df[</span><span style="color: #032F62">&quot;val_loss&quot;</span><span style="color: #24292E">], </span><span style="color: #E36209">label</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;Val&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">ax2.plot(x, df[</span><span style="color: #032F62">&quot;val_accuracy&quot;</span><span style="color: #24292E">])</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">ax1.set_xlabel(</span><span style="color: #032F62">&quot;Epochs&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">ax1.set_ylabel(</span><span style="color: #032F62">&quot;Loss&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">ax1.legend()</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">ax2.set_xlabel(</span><span style="color: #032F62">&quot;Epochs&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">ax2.set_ylabel(</span><span style="color: #032F62">&quot;Accuracy&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #005CC5">print</span><span style="color: #24292E">(</span><span style="color: #032F62">&quot;Best loss:&quot;</span><span style="color: #24292E">, df[</span><span style="color: #032F62">&quot;val_loss&quot;</span><span style="color: #24292E">].min())</span></span>
<span class="line"><span style="color: #005CC5">print</span><span style="color: #24292E">(</span><span style="color: #032F62">&quot;Best loss epoch:&quot;</span><span style="color: #24292E">, df[</span><span style="color: #032F62">&quot;val_loss&quot;</span><span style="color: #24292E">].argmin())</span></span>
<span class="line"><span style="color: #005CC5">print</span><span style="color: #24292E">(</span><span style="color: #032F62">&quot;Best accuracy:&quot;</span><span style="color: #24292E">, df[</span><span style="color: #032F62">&quot;val_accuracy&quot;</span><span style="color: #24292E">].max())</span></span>
<span class="line"><span style="color: #005CC5">print</span><span style="color: #24292E">(</span><span style="color: #032F62">&quot;Best accuracy epoch:&quot;</span><span style="color: #24292E">, df[</span><span style="color: #032F62">&quot;val_accuracy&quot;</span><span style="color: #24292E">].argmax())</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br></div></div><p><img src="./assets/aws_batch/loss_epoch_profile2.png" alt="AWS Batch で行った MNIST モデルの学習の結果"></p>
<h2 id="並列に複数の-job-を実行する" tabindex="-1">並列に複数の Job を実行する <a class="header-anchor" href="#並列に複数の-job-を実行する" aria-label="Permalink to &quot;並列に複数の Job を実行する&quot;">&ZeroWidthSpace;</a></h2>
<p>さて，ここからが最後の仕上げである． ここまでのハンズオンで構築した AWS Batch のシステムを使って，ハイパーパラメータサーチを実際に行おう．</p>
<p>先ほど実行した <code>run_single.ipynb</code> と同じディレクトリにある <code>run_sweep.ipynb</code> を開く．</p>
<p>セル [1], [2], [3] は <code>run_single.ipynb</code> と同一である．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390"># [1]</span></span>
<span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> boto3</span></span>
<span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> argparse</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># [2]</span></span>
<span class="line"><span style="color: #768390"># AWS 認証ヘルパー ...省略...</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># [3]</span></span>
<span class="line"><span style="color: #F47067">def</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">submit_job</span><span style="color: #ADBAC7">(lr:</span><span style="color: #6CB6FF">float</span><span style="color: #ADBAC7">, momentum:</span><span style="color: #6CB6FF">float</span><span style="color: #ADBAC7">, epochs:</span><span style="color: #6CB6FF">int</span><span style="color: #ADBAC7">, profile_name</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">None</span><span style="color: #ADBAC7">):</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #768390"># ...省略...</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D"># [1]</span></span>
<span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> boto3</span></span>
<span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> argparse</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># [2]</span></span>
<span class="line"><span style="color: #6A737D"># AWS 認証ヘルパー ...省略...</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># [3]</span></span>
<span class="line"><span style="color: #D73A49">def</span><span style="color: #24292E"> </span><span style="color: #6F42C1">submit_job</span><span style="color: #24292E">(lr:</span><span style="color: #005CC5">float</span><span style="color: #24292E">, momentum:</span><span style="color: #005CC5">float</span><span style="color: #24292E">, epochs:</span><span style="color: #005CC5">int</span><span style="color: #24292E">, profile_name</span><span style="color: #D73A49">=</span><span style="color: #005CC5">None</span><span style="color: #24292E">):</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #6A737D"># ...省略...</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br></div></div><p>セル [4] の for ループを使って，グリッド状にハイパーパラメータの組み合わせを用意し， batch にジョブを投入している． ここでは 3x3=9 個のジョブを作成した．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390"># [4]</span></span>
<span class="line"><span style="color: #F47067">for</span><span style="color: #ADBAC7"> lr </span><span style="color: #F47067">in</span><span style="color: #ADBAC7"> [</span><span style="color: #6CB6FF">0.1</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">0.01</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">0.001</span><span style="color: #ADBAC7">]:</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">for</span><span style="color: #ADBAC7"> m </span><span style="color: #F47067">in</span><span style="color: #ADBAC7"> [</span><span style="color: #6CB6FF">0.5</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">0.1</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">0.05</span><span style="color: #ADBAC7">]:</span></span>
<span class="line"><span style="color: #ADBAC7">        submit_job(lr, m, </span><span style="color: #6CB6FF">100</span><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D"># [4]</span></span>
<span class="line"><span style="color: #D73A49">for</span><span style="color: #24292E"> lr </span><span style="color: #D73A49">in</span><span style="color: #24292E"> [</span><span style="color: #005CC5">0.1</span><span style="color: #24292E">, </span><span style="color: #005CC5">0.01</span><span style="color: #24292E">, </span><span style="color: #005CC5">0.001</span><span style="color: #24292E">]:</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">for</span><span style="color: #24292E"> m </span><span style="color: #D73A49">in</span><span style="color: #24292E"> [</span><span style="color: #005CC5">0.5</span><span style="color: #24292E">, </span><span style="color: #005CC5">0.1</span><span style="color: #24292E">, </span><span style="color: #005CC5">0.05</span><span style="color: #24292E">]:</span></span>
<span class="line"><span style="color: #24292E">        submit_job(lr, m, </span><span style="color: #005CC5">100</span><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br></div></div><p>セル [4] を実行したら， Batch のコンソールを開こう． 先ほどと同様に，ジョブのステータスは <code>SUBMITTED</code> &gt; <code>RUNNABLE</code> &gt; <code>STARTING</code> &gt; <code>RUNNING</code> と移り変わっていくことがわかるだろう． 最終的に 9 個のジョブがすべて <code>RUNNING</code> の状態になることを確認しよう (<a href="#fig_batch_many_parallel_jobs">figure_title</a>)． また，このとき Compute environment の <code>Desired vCPUs</code> は 4x9=36 となっていることを確認しよう (<a href="#fig_batch_many_parallel_jobs">figure_title</a>)．</p>
<p><img src="./assets/aws_batch/batch_many_parallel_jobs.png" alt="複数のジョブを同時投入したときの Batch コンソール"></p>
<p>次に，Batch のコンソールの左側のメニューから <code>Jobs</code> をクリックしてみよう． ここでは，実行中のジョブの一覧が確認することができる (<a href="#fig_batch_parallel_job_list">figure_title</a>)． ジョブのステータスでフィルタリングをすることも可能である． 9 個のジョブがどれも <code>RUNNING</code> 状態にあることが確認できるだろう．</p>
<p><img src="./assets/aws_batch/batch_parallel_job_list.png" alt="複数のジョブを同時投入したときの Job 一覧"></p>
<p>今度は EC2 コンソールを見てみよう． 左のメニューから <code>Instances</code> を選択すると， <a href="#fig_ec2_instances_list">figure_title</a> に示すような起動中のインスタンスの一覧が表示される． <code>g4dn.xlarge</code> が 9 台稼働しているのが確認できる． Batch がジョブの投下に合わせて必要な数のインスタンスを起動してくれたのだ！</p>
<p><img src="./assets/aws_batch/ec2_instances_list.png" alt="複数のジョブを同時投入したときの EC2 インスタンスの一覧"></p>
<p>ここまで確認できたら，それぞれの Job が終了するまでしばらく待とう (だいたい 10-15 分くらいで終わる)． すべてのジョブが終了すると，ダッシュボードの <code>SUCCEEDED</code> が 9 となっているはずだ． また， Compute environment の <code>Desired vCPUs</code> も 0 に落ちていることを確認しよう． 最後に EC2 コンソールに行って，すべての g4dn インスタンスが停止していることを確認しよう．</p>
<p>以上から， AWS Batch を使うことで，<strong>ジョブの投入に応じて自動的に EC2 インスタンスが起動され，ジョブの完了とともに，ただちにインスタンスの停止が行われる</strong>一連の挙動を観察することができた． 一つのジョブの完了におよそ 10 分の時間がかかるので，9 個のハイパーパラメータの組を逐次的に計算していた場合は 90 分の時間を要することになる． AWS Batch を使ってこれらの計算を並列に実行することで，ジョブ一個分の計算時間 (=10 分) ですべての計算を終えることができた！</p>
<p>さて，再び <code>run_sweep.ipynb</code> に戻ってこよう． [5] 以降のセルでは，グリッドサーチの結果を可視化している．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390"># [5]</span></span>
<span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> pandas </span><span style="color: #F47067">as</span><span style="color: #ADBAC7"> pd</span></span>
<span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> numpy </span><span style="color: #F47067">as</span><span style="color: #ADBAC7"> np</span></span>
<span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> io</span></span>
<span class="line"><span style="color: #F47067">from</span><span style="color: #ADBAC7"> matplotlib </span><span style="color: #F47067">import</span><span style="color: #ADBAC7"> pyplot </span><span style="color: #F47067">as</span><span style="color: #ADBAC7"> plt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># [6]</span></span>
<span class="line"><span style="color: #F47067">def</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">read_table_from_s3</span><span style="color: #ADBAC7">(bucket_name, key, profile_name</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">None</span><span style="color: #ADBAC7">):</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> profile_name </span><span style="color: #F47067">is</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">None</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">        session </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> boto3.Session()</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">else</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">        session </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> boto3.Session(</span><span style="color: #F69D50">profile_name</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">profile_name)</span></span>
<span class="line"><span style="color: #ADBAC7">    s3 </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> session.resource(</span><span style="color: #96D0FF">&quot;s3&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">    bucket </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> s3.Bucket(bucket_name)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    obj </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> bucket.Object(key).get().get(</span><span style="color: #96D0FF">&quot;Body&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">    df </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> pd.read_csv(obj)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">return</span><span style="color: #ADBAC7"> df</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># [7]</span></span>
<span class="line"><span style="color: #ADBAC7">grid </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> np.zeros((</span><span style="color: #6CB6FF">3</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">3</span><span style="color: #ADBAC7">))</span></span>
<span class="line"><span style="color: #F47067">for</span><span style="color: #ADBAC7"> (i, lr) </span><span style="color: #F47067">in</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">enumerate</span><span style="color: #ADBAC7">([</span><span style="color: #6CB6FF">0.1</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">0.01</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">0.001</span><span style="color: #ADBAC7">]):</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">for</span><span style="color: #ADBAC7"> (j, m) </span><span style="color: #F47067">in</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">enumerate</span><span style="color: #ADBAC7">([</span><span style="color: #6CB6FF">0.5</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">0.1</span><span style="color: #ADBAC7">, </span><span style="color: #6CB6FF">0.05</span><span style="color: #ADBAC7">]):</span></span>
<span class="line"><span style="color: #ADBAC7">        key </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">f</span><span style="color: #96D0FF">&quot;metrics_lr</span><span style="color: #F47067">{</span><span style="color: #ADBAC7">lr</span><span style="color: #F47067">:0.4f}</span><span style="color: #96D0FF">_m</span><span style="color: #F47067">{</span><span style="color: #ADBAC7">m</span><span style="color: #F47067">:0.4f}</span><span style="color: #96D0FF">.csv&quot;</span></span>
<span class="line"><span style="color: #ADBAC7">        df </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> read_table_from_s3(</span><span style="color: #96D0FF">&quot;simplebatch-bucket43879c71-mbqaltx441fu&quot;</span><span style="color: #ADBAC7">, key)</span></span>
<span class="line"><span style="color: #ADBAC7">        grid[i,j] </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> df[</span><span style="color: #96D0FF">&quot;val_accuracy&quot;</span><span style="color: #ADBAC7">].max()</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># [8]</span></span>
<span class="line"><span style="color: #ADBAC7">fig, ax </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> plt.subplots(</span><span style="color: #F69D50">figsize</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">6</span><span style="color: #ADBAC7">,</span><span style="color: #6CB6FF">6</span><span style="color: #ADBAC7">))</span></span>
<span class="line"><span style="color: #ADBAC7">ax.set_aspect(</span><span style="color: #96D0FF">&#39;equal&#39;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">c </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ax.pcolor(grid, </span><span style="color: #F69D50">edgecolors</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&#39;w&#39;</span><span style="color: #ADBAC7">, </span><span style="color: #F69D50">linewidths</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">2</span><span style="color: #ADBAC7">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F47067">for</span><span style="color: #ADBAC7"> i </span><span style="color: #F47067">in</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">range</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">3</span><span style="color: #ADBAC7">):</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">for</span><span style="color: #ADBAC7"> j </span><span style="color: #F47067">in</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">range</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">3</span><span style="color: #ADBAC7">):</span></span>
<span class="line"><span style="color: #ADBAC7">        text </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ax.text(j</span><span style="color: #F47067">+</span><span style="color: #6CB6FF">0.5</span><span style="color: #ADBAC7">, i</span><span style="color: #F47067">+</span><span style="color: #6CB6FF">0.5</span><span style="color: #ADBAC7">, </span><span style="color: #F47067">f</span><span style="color: #96D0FF">&quot;</span><span style="color: #F47067">{</span><span style="color: #ADBAC7">grid[i, j]</span><span style="color: #F47067">:0.1f}</span><span style="color: #96D0FF">&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                       </span><span style="color: #F69D50">ha</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;center&quot;</span><span style="color: #ADBAC7">, </span><span style="color: #F69D50">va</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;center&quot;</span><span style="color: #ADBAC7">, </span><span style="color: #F69D50">color</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;w&quot;</span><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D"># [5]</span></span>
<span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> pandas </span><span style="color: #D73A49">as</span><span style="color: #24292E"> pd</span></span>
<span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> numpy </span><span style="color: #D73A49">as</span><span style="color: #24292E"> np</span></span>
<span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> io</span></span>
<span class="line"><span style="color: #D73A49">from</span><span style="color: #24292E"> matplotlib </span><span style="color: #D73A49">import</span><span style="color: #24292E"> pyplot </span><span style="color: #D73A49">as</span><span style="color: #24292E"> plt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># [6]</span></span>
<span class="line"><span style="color: #D73A49">def</span><span style="color: #24292E"> </span><span style="color: #6F42C1">read_table_from_s3</span><span style="color: #24292E">(bucket_name, key, profile_name</span><span style="color: #D73A49">=</span><span style="color: #005CC5">None</span><span style="color: #24292E">):</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">if</span><span style="color: #24292E"> profile_name </span><span style="color: #D73A49">is</span><span style="color: #24292E"> </span><span style="color: #005CC5">None</span><span style="color: #24292E">:</span></span>
<span class="line"><span style="color: #24292E">        session </span><span style="color: #D73A49">=</span><span style="color: #24292E"> boto3.Session()</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">else</span><span style="color: #24292E">:</span></span>
<span class="line"><span style="color: #24292E">        session </span><span style="color: #D73A49">=</span><span style="color: #24292E"> boto3.Session(</span><span style="color: #E36209">profile_name</span><span style="color: #D73A49">=</span><span style="color: #24292E">profile_name)</span></span>
<span class="line"><span style="color: #24292E">    s3 </span><span style="color: #D73A49">=</span><span style="color: #24292E"> session.resource(</span><span style="color: #032F62">&quot;s3&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">    bucket </span><span style="color: #D73A49">=</span><span style="color: #24292E"> s3.Bucket(bucket_name)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">    obj </span><span style="color: #D73A49">=</span><span style="color: #24292E"> bucket.Object(key).get().get(</span><span style="color: #032F62">&quot;Body&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">    df </span><span style="color: #D73A49">=</span><span style="color: #24292E"> pd.read_csv(obj)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">return</span><span style="color: #24292E"> df</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># [7]</span></span>
<span class="line"><span style="color: #24292E">grid </span><span style="color: #D73A49">=</span><span style="color: #24292E"> np.zeros((</span><span style="color: #005CC5">3</span><span style="color: #24292E">,</span><span style="color: #005CC5">3</span><span style="color: #24292E">))</span></span>
<span class="line"><span style="color: #D73A49">for</span><span style="color: #24292E"> (i, lr) </span><span style="color: #D73A49">in</span><span style="color: #24292E"> </span><span style="color: #005CC5">enumerate</span><span style="color: #24292E">([</span><span style="color: #005CC5">0.1</span><span style="color: #24292E">, </span><span style="color: #005CC5">0.01</span><span style="color: #24292E">, </span><span style="color: #005CC5">0.001</span><span style="color: #24292E">]):</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">for</span><span style="color: #24292E"> (j, m) </span><span style="color: #D73A49">in</span><span style="color: #24292E"> </span><span style="color: #005CC5">enumerate</span><span style="color: #24292E">([</span><span style="color: #005CC5">0.5</span><span style="color: #24292E">, </span><span style="color: #005CC5">0.1</span><span style="color: #24292E">, </span><span style="color: #005CC5">0.05</span><span style="color: #24292E">]):</span></span>
<span class="line"><span style="color: #24292E">        key </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #D73A49">f</span><span style="color: #032F62">&quot;metrics_lr</span><span style="color: #005CC5">{</span><span style="color: #24292E">lr</span><span style="color: #D73A49">:0.4f</span><span style="color: #005CC5">}</span><span style="color: #032F62">_m</span><span style="color: #005CC5">{</span><span style="color: #24292E">m</span><span style="color: #D73A49">:0.4f</span><span style="color: #005CC5">}</span><span style="color: #032F62">.csv&quot;</span></span>
<span class="line"><span style="color: #24292E">        df </span><span style="color: #D73A49">=</span><span style="color: #24292E"> read_table_from_s3(</span><span style="color: #032F62">&quot;simplebatch-bucket43879c71-mbqaltx441fu&quot;</span><span style="color: #24292E">, key)</span></span>
<span class="line"><span style="color: #24292E">        grid[i,j] </span><span style="color: #D73A49">=</span><span style="color: #24292E"> df[</span><span style="color: #032F62">&quot;val_accuracy&quot;</span><span style="color: #24292E">].max()</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># [8]</span></span>
<span class="line"><span style="color: #24292E">fig, ax </span><span style="color: #D73A49">=</span><span style="color: #24292E"> plt.subplots(</span><span style="color: #E36209">figsize</span><span style="color: #D73A49">=</span><span style="color: #24292E">(</span><span style="color: #005CC5">6</span><span style="color: #24292E">,</span><span style="color: #005CC5">6</span><span style="color: #24292E">))</span></span>
<span class="line"><span style="color: #24292E">ax.set_aspect(</span><span style="color: #032F62">&#39;equal&#39;</span><span style="color: #24292E">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">c </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ax.pcolor(grid, </span><span style="color: #E36209">edgecolors</span><span style="color: #D73A49">=</span><span style="color: #032F62">&#39;w&#39;</span><span style="color: #24292E">, </span><span style="color: #E36209">linewidths</span><span style="color: #D73A49">=</span><span style="color: #005CC5">2</span><span style="color: #24292E">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D73A49">for</span><span style="color: #24292E"> i </span><span style="color: #D73A49">in</span><span style="color: #24292E"> </span><span style="color: #005CC5">range</span><span style="color: #24292E">(</span><span style="color: #005CC5">3</span><span style="color: #24292E">):</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">for</span><span style="color: #24292E"> j </span><span style="color: #D73A49">in</span><span style="color: #24292E"> </span><span style="color: #005CC5">range</span><span style="color: #24292E">(</span><span style="color: #005CC5">3</span><span style="color: #24292E">):</span></span>
<span class="line"><span style="color: #24292E">        text </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ax.text(j</span><span style="color: #D73A49">+</span><span style="color: #005CC5">0.5</span><span style="color: #24292E">, i</span><span style="color: #D73A49">+</span><span style="color: #005CC5">0.5</span><span style="color: #24292E">, </span><span style="color: #D73A49">f</span><span style="color: #032F62">&quot;</span><span style="color: #005CC5">{</span><span style="color: #24292E">grid[i, j]</span><span style="color: #D73A49">:0.1f</span><span style="color: #005CC5">}</span><span style="color: #032F62">&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                       </span><span style="color: #E36209">ha</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;center&quot;</span><span style="color: #24292E">, </span><span style="color: #E36209">va</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;center&quot;</span><span style="color: #24292E">, </span><span style="color: #E36209">color</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;w&quot;</span><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br><span class="line-number">36</span><br><span class="line-number">37</span><br><span class="line-number">38</span><br></div></div><p>最終的に出力されるプロットが <a href="#fig_grid_search_result">figure_title</a> である．</p>
<p><img src="./assets/aws_batch/grid_search_result.png" alt="ハイパーパラメータのグリッドサーチの結果"></p>
<p>このプロットから，差は僅かであるが，学習率が 0.1 のときに精度は最大となることがわかる． また，学習率 0.1 のときはモメンタムを変えても大きな差は生じないことが見て取れる．</p>
<p>今回のパラメータサーチは勉強用に極めて単純化されたものである点は承知いただきたい．</p>
<p>たとえば，今回は学習率が 0.1 が最も良いとされたが，それは訓練のエポックを 100 に限定しているからかもしれない． 学習率が低いとその分訓練に必要なエポック数も多くなる． 訓練のエポック数をもっと増やせばまた違った結果が観察される可能性はある．</p>
<p>また，今回は MNIST の訓練データ 60,000 枚のうち， 48,000 枚を訓練データ，残り 12,000 枚を検証データとして用いた． この分割は乱数を固定してランダムに行ったが，もしこの分割によるデータのバイアスを気にするならば， k 個の異なる学習・検証データの分割をあらかじめ用意して，複数回モデルの評価を行う (<strong>k-fold cross-validation</strong>) 方法も，より精緻なアプローチとして考えられる．</p>
<p>以上のようにして， CNN を用いた MNIST 分類モデルのハイパーパラメータの最適化の一連の流れを体験した． AWS Batch を利用することで，比較的少ないプログラミングで，動的に EC2 クラスターを制御し，並列にジョブを処理するシステムが構築できた． ここまで EC2 を使いこなすことができれば，多くの問題を自力で解くことが可能になるだろう！</p>
<h2 id="スタックの削除-2" tabindex="-1">スタックの削除 <a class="header-anchor" href="#スタックの削除-2" aria-label="Permalink to &quot;スタックの削除&quot;">&ZeroWidthSpace;</a></h2>
<p>これにて，本ハンズオンは終了である．最後にスタックを削除しよう． 今回のスタックを削除するにあたり，ECR に配置された Docker のイメージは手動で削除されなければならない (これをしないと， <code>cdk destroy</code> を実行したときにエラーになってしまう． これは CloudFormation の仕様なので従うしかない)．</p>
<p>ECR の Docker image を削除するには， ECR のコンソールに行き，イメージが配置されたレポジトリを開く． そして，画面右上の <code>DELETE</code> ボタンを押して削除する (<a href="#fig_delete_ecr">figure_title</a>)．</p>
<p><img src="./assets/aws_batch/delete_ecr.png" alt="ECR から Docker image を削除する"></p>
<p>あるいは， AWS CLI から同様の操作を行うには，以下のコマンドを用いる (<code>XXXX</code> は自分の ECR レポジトリ名に置き換える)．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ecr</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">batch-delete-image</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--repository-name</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">XXXX</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--image-ids</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">imageTag=latest</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">aws</span><span style="color: #24292E"> </span><span style="color: #032F62">ecr</span><span style="color: #24292E"> </span><span style="color: #032F62">batch-delete-image</span><span style="color: #24292E"> </span><span style="color: #005CC5">--repository-name</span><span style="color: #24292E"> </span><span style="color: #032F62">XXXX</span><span style="color: #24292E"> </span><span style="color: #005CC5">--image-ids</span><span style="color: #24292E"> </span><span style="color: #032F62">imageTag=latest</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>image の削除が完了したうえで，次のコマンドでスタックを削除する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cdk</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">destroy</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cdk</span><span style="color: #24292E"> </span><span style="color: #032F62">destroy</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>(#sec:batch_development_and_debug) === クラウドを用いた機械学習アプリケーションの開発とデバッグ</p>
<p>本章で紹介したハンズオンでは， AWS Batch を使用することでニューラルネットの学習を複数並列に実行し，高速化を実現した． 本章の最後の話題として，クラウドを用いた機械学習アプリケーションの開発とデバッグの方法について述べよう．</p>
<p>ローカルに GPU を搭載した強力なマシンがなく，クラウドを利用する予算が確保されているのであれば， <a href="#fig:cloud_development">figure_title</a> のような開発のスキームが理想的であると考える． 最初の段階では， <a href="#sec_jupyter_and_deep_learning">Hands-on #2: AWS でディープラーニングを実践</a> で見たような方法で， GPU 搭載型の EC2 インスタンスを作成し， Jupyter Notebook などのインタラクティブな環境で様々なモデルを試し実験を行う． Jupyter である程度アプリケーションが完成してきたタイミングで，作成したアプリケーションを Docker イメージにパッケージングする． そして， EC2 上で <code>docker run</code> を行い，作成したイメージがバグなく動作するか確認を行う． その次に，ハイパーパラメータの最適化などのチューニングを， <a href="#sec_aws_batch">Hands-on #4: AWS Batch を使って機械学習のハイパーパラメータサーチを並列化する</a> のハンズオンで学んだ AWS Batch などの計算システムを利用して行う． よい深層学習モデルが完成したら，仕上げに大規模データへの推論処理を行うシステムを <a href="#sec_fargate_qabot">Hands-on #3: AWS で自動質問回答ボットを走らせる</a> を参考に構築する．</p>
<p>実際，本書ではこの流れに沿って演習を進めてきた． MNIST タスクを解くモデルを，最初 Jupyter Notebook を使用して実験し，そのコードをほとんどそのまま Docker にパッケージし， AWS Batch を用いてハイパーパラメータサーチを行った． このサイクルを繰り返すことで，クラウドを最大限に活用した機械学習アプリケーションの開発を進めることができる．</p>
<p><img src="./assets/aws_batch/cloud_development.png" alt="クラウドを活用した機械学習アプリケーションの開発フロー"></p>
<h2 id="小括-1" tabindex="-1">小括 <a class="header-anchor" href="#小括-1" aria-label="Permalink to &quot;小括&quot;">&ZeroWidthSpace;</a></h2>
<p>ここまでが，本書第二部の内容である． 第一部に引き続き盛りだくさんの内容であったが，ついてこれたであろうか？</p>
<p>第二部ではまず最初に，深層学習の計算をクラウドで実行するため， GPU 搭載型の EC2 インスタンスの起動について解説した． さらに，ハンズオンでは，クラウドに起動した仮想サーバーを使って MNIST 文字認識タスクを解くニューラルネットを訓練した (<a href="#sec_jupyter_and_deep_learning">Hands-on #2: AWS でディープラーニングを実践</a>)．</p>
<p>また，より大規模な機械学習アプリケーションを作るための手段として， Docker と ECS によるクラスターの初歩を説明した (<a href="#sec_docker_introduction">Docker 入門</a>)． その応用として，英語で与えられた文章問題への回答を自動で生成するボットをクラウドに展開した (<a href="#sec_fargate_qabot">Hands-on #3: AWS で自動質問回答ボットを走らせる</a>)． タスクの投入に応じて動的に計算リソースが作成・削除される様子を実際に体験できただろう．</p>
<p>さらに， <a href="#sec_aws_batch">Hands-on #4: AWS Batch を使って機械学習のハイパーパラメータサーチを並列化する</a> では AWS Batch を用いてニューラルネットの学習を並列に実行する方法を紹介した． ここで紹介した方法は，ミニマムであるが，計算機システムを大規模化していくためのエッセンスが網羅されている． これらのハンズオン体験から，クラウド技術を応用してどのように現実世界の問題を解いていくのか，なんとなくイメージが伝わっただろうか？</p>
<p>本書の第三部では，さらにレベルアップし，サーバーレスアーキテクチャという最新のクラウドの設計手法について解説する． その応用として，ハンズオンでは簡単な SNS サービスをゼロから実装する． 引き続きクラウドの最先端の世界を楽しんでいこう！</p>
<h1 id="web-サービスの作り方" tabindex="-1">Web サービスの作り方 <a class="header-anchor" href="#web-サービスの作り方" aria-label="Permalink to &quot;Web サービスの作り方&quot;">&ZeroWidthSpace;</a></h1>
<p>ここからが，本書第三部の内容になる． これまでのセクションでは，仮想サーバーをクラウド上に起動し，そこで計算を走らせる方法について解説をしてきた． EC2, ECS, Fargate, Batch などを利用して，動的にスケールするクラスターを構成し，並列にタスクを実行するクラウドシステムを実装してきた． 振り返ると，これまで紹介してきた内容は，<strong>自分自身が行いたい計算をクラウドを駆使することで実現する</strong>，という用途にフォーカスしていたことに気がつくだろう． 一方で，<strong>広く一般の人々に使ってもらえるような計算サービス・データベース</strong>を提供する，というのもクラウドの重要な役割として挙げられる．</p>
<p>本章から始まる第三部では，前回までとは少し方向性を変え，どのようにしてクラウド上にアプリケーションを展開し，広く一般の人に使ってもらうか，という点を講義したいと思う． これを通じて，どのようにして世の中のウェブサービスができ上がっているのかを知り，さらにどうやって自分でそのようなアプリケーションをゼロから構築するのか，という点を学んでもらう． その過程で，サーバーレスアーキテクチャという最新のクラウド設計手法を解説する．</p>
<p>その前準備として，本章ではどのようにしてウェブサービスが出来上がっているのか，その背後にある技術の概要を解説する． 用語の解説が中心となるが，後のハンズオンを実装するために必須の知識であるので，理解して前に進むよう心がけよう．</p>
<h2 id="ウェブサービスの仕組み-—-twitter-を例に" tabindex="-1">ウェブサービスの仕組み  — Twitter を例に <a class="header-anchor" href="#ウェブサービスの仕組み-—-twitter-を例に" aria-label="Permalink to &quot;ウェブサービスの仕組み  — Twitter を例に&quot;">&ZeroWidthSpace;</a></h2>
<p>あなたがパソコンやスマートフォンから Twitter, Facebook, YouTube などのウェブサービスにアクセスしたとき，実際にどのようなことが行われ，コンテンツが提示されているのだろうか？</p>
<p>HTTP を通じたサーバーとクライアントのデータのやり取りは，すでに知っている読者も多いだろうし，逆にすべて解説しようとすると紙面が足りないので，ここではエッセンスの説明のみにとどめる． 以降では <a href="https://twitter.com" target="_blank" rel="noreferrer">Twitter</a> を具体例として，背後にあるサーバーとクライアントの間の通信を概説しよう． 概念図としては <a href="#fig:web_server">figure_title</a> のような通信がクライアントとサーバーの間で行われていることになる．</p>
<p><img src="./assets/web_server.png" alt="クライアントと Web サーバーの通信の概念図"></p>
<p>前提として，クライアントとサーバーの通信は <strong>HTTP (Hypertext Transfer Protocol)</strong> を使って行われる． また，最近では，暗号化された HTTP である <strong>HTTPS (HTTPS (Hypertext Transfer Protocol Secure))</strong> を用いることがスタンダードになってきている． 第一のステップとして，クライアントは HTTP(S) 通信によってサーバーから静的なコンテンツを取得する． 静的なコンテンツとは， <strong>HTML (Hyptertext Markup Language)</strong> で記述されたウェブページの文書本体， <strong>CSS (Cascading Style Sheets)</strong> で記述されたページのデザインやレイアウトファイル，そして <strong>JavaScript (JS)</strong> で記述されたページの動的な挙動を定義したプログラム，が含まれる． Twitter を含む現代的なウェブアプリケーションの設計では，この静的なファイル群はページの”枠”を定義するだけで，中身となるコンテンツ (例: ツイートの一覧) は別途 <strong>API (Application Programming Interface)</strong> によって取得されなければならない． そこで，クライアントは先のステップで取得された JavaScript で定義されたプログラムに従って，サーバーに API を送信し，ツイートや画像データを取得する． この際，テキストデータのやり取りには <strong>JSON (JavaScript Object Notation)</strong> というフォーマットが用いられることが多い． 画像や動画などのコンテンツも同様に API により取得される． このようにして取得されたテキストや画像が，HTML の文書に埋め込まれることで，最終的にユーザーに提示されるページが完成するのである． また，新しいツイートを投稿するときにも，クライアントから API を通じてサーバーのデータベースにデータが書き込まれる．</p>
<h2 id="rest-api" tabindex="-1">REST API <a class="header-anchor" href="#rest-api" aria-label="Permalink to &quot;REST API&quot;">&ZeroWidthSpace;</a></h2>
<p>API (Application Programming Interface) とはこれまで何度も出てきた言葉であるが，ここではよりフォーマルな定義付けを行う． API とはあるソフトウェア・アプリケーションが，外部のソフトウェアに対してコマンドやデータをやり取りするための媒介の一般的総称である． とくに，ウェブサービスの文脈では，サーバーが外界に対して提示しているコマンドの一覧のことを意味する． クライアントは，提示されている API から適切なコマンドを使うことによって，所望のデータを取得したり，あるいはサーバーにデータを送信したりする．</p>
<p>とくに，ウェブの文脈では <strong>REST (Representational State Transfer)</strong> とよばれる設計思想に基づいた API が現在では最も一般的に使われている． REST の設計指針に従った API のことを <strong>REST API</strong> あるいは <strong>RESTful API</strong> とよんだりする．</p>
<p>REST API は， <a href="#rest_api">figure_title</a> に示したような <strong>Method</strong> と <strong>URI (Universal Resource Identifier)</strong> の組からなる．</p>
<p><img src="./assets/rest_api.png" alt="REST API"></p>
<p>Method (メソッド) とは，どのような操作を行いたいかを抽象的に表す，<strong>&quot;動詞&quot;</strong> として捉えることができる． メソッドには HTTP 規格で定義された 9 個の動詞 (verb) を使用することができる． この中でも， <code>GET</code>, <code>POST</code>, <code>PUT</code>, <code>PATCH</code>, <code>DELETE</code> の 5 個が最も頻繁に使用される (<a href="#tab:rest_api_methods">table_title</a>)． この 5 つのメソッドによる操作を総称して <strong>CRUD</strong> (create, read, update, and delete) とよぶ．</p>
<table><caption>REST API Methods</caption><colgroup><col style="width: 25%" /><col style="width: 75%" /></colgroup><thead><tr class="header"><th>メソッド</th><th>意図される動作</th></tr></thead><tbody><tr class="odd"><td><p>GET</p></td><td><p>要素を取得する</p></td></tr><tr class="even"><td><p>POST</p></td><td><p>新しい要素を作成する</p></td></tr><tr class="odd"><td><p>PUT</p></td><td><p>既存の要素を新しい要素と置き換える</p></td></tr><tr class="even"><td><p>PATCH</p></td><td><p>既存の要素の一部を更新する</p></td></tr><tr class="odd"><td><p>DELETE</p></td><td><p>要素を削除する</p></td></tr></tbody></table>
<p>一方， URI は操作が行われる対象，すなわち <strong>&quot;目的語&quot;</strong> を表す． ウェブの文脈では操作が行われる対象のことをしばしば <strong>リソース</strong> とよぶ． URI は多くの場合 http または https から始まるウェブサーバーのアドレスから始まり， / (スラッシュ) 以降に所望のリソースのパスが指定される． <a href="#rest_api">figure_title</a> の例で言えば， <code>https://api.twitter.com</code> というアドレスの <code>/1.1/status/home_timeline</code> というリソースを取得 (GET) せよ，という意味になる (なお，ここで <code>1.1</code> という数字は API のバージョンを示している)． この API リクエストによって，ユーザーのホームのタイムラインのツイートの一覧が取得される．</p>
<p>REST API のメソッドには， <a href="#tab:rest_api_methods">table_title</a> で挙げたもの以外に， HTTP プロトコルで定義されているほかのメソッド (OPTIONS, TRACE など) を用いることもできるが，あまり一般的ではない．</p>
<p>また，これらのメソッドだけでは動詞として表現しきれないこともあるが， URI の名前でより意味を明確にすることもある． メソッドの使い方も，要素を削除する際は必ず <code>DELETE</code> を使わなければならない，という決まりもなく，たとえば， Twitter API でツイートを消す API は <code>POST statuses/destroy/:id</code> で定義されている． 最終的には，各ウェブサービスが公開している API ドキュメンテーションを読んで，それぞれの API がどんな操作をするのかを調べる必要がある．</p>
<p>REST の概念は 2000 年代初頭に確立され，今日の API 設計のスタンダードとなった． 一方で，ウェブのテクノロジーが進歩するにつれて，新たな API の設計アプローチの需要も高まっている． 近年とくに人気を集めているのが， <a href="https://graphql.org/" target="_blank" rel="noreferrer">GraphQL</a> と呼ばれる API の設計方法である． GraphQL は Facebook 社によって最初に作られ，現在は GraghQL Foundation によって維持と更新がされている． GraphQL を使用すると，クライアントは REST と比較してより柔軟性の高いデータのクエリを行うことができるなど，いくつかの利点がある． キーワードだけでも知っておくと，今後役に立つだろう．</p>
<h2 id="twitter-api" tabindex="-1">Twitter API <a class="header-anchor" href="#twitter-api" aria-label="Permalink to &quot;Twitter API&quot;">&ZeroWidthSpace;</a></h2>
<p>もう少し具体的にウェブサービスの API を体験する目的で，ここでは Twitter の API を見てみよう． Twitter が提供している API の一覧は <a href="https://developer.twitter.com/en/docs/api-reference-index" target="_blank" rel="noreferrer">Twitter の Developer Documentation</a> で見ることができる． いくつかの代表的な API を <a href="#tab_twitter_api">table_title</a> にまとめた．</p>
<table><caption>Twitter API</caption><colgroup><col style="width: 50%" /><col style="width: 50%" /></colgroup><thead><tr class="header"><th>エンドポイント</th><th>動作</th></tr></thead><tbody><tr class="odd"><td><p><code>GET statuses/home_timeline</code></p></td><td><p>ホームのタイムラインのツイートの一覧を取得する．</p></td></tr><tr class="even"><td><p><code>GET statuses/show/:id</code></p></td><td><p><code>:id</code> で指定されたツイートの詳細情報を取得する．</p></td></tr><tr class="odd"><td><p><code>GET search</code></p></td><td><p>ツイートの検索を実行する．</p></td></tr><tr class="even"><td><p><code>POST statuses/update</code></p></td><td><p>新しいツイートを投稿する．</p></td></tr><tr class="odd"><td><p><code>POST media/upload</code></p></td><td><p>画像をアップロードする</p></td></tr><tr class="even"><td><p><code>POST statuses/destroy/:id</code></p></td><td><p><code>:id</code> で指定されたツイートを削除する．</p></td></tr><tr class="odd"><td><p><code>POST statuses/retweet/:id</code></p></td><td><p><code>:id</code> で指定されたツイートをリツイートする．</p></td></tr><tr class="even"><td><p><code>POST statuses/unretweet/:id</code></p></td><td><p><code>:id</code> で指定されたツイートのリツイートを取り消す．</p></td></tr><tr class="odd"><td><p><code>POST favorites/create</code></p></td><td><p>選択したツイートを"いいね"する．</p></td></tr><tr class="even"><td><p><code>POST favorites/destroy</code></p></td><td><p>選択したツイートを"いいね"を取り消す．</p></td></tr></tbody></table>
<p>この API リストをもとに， Twitter のアプリまたはウェブサイトを開いたときに起こるクライアントとサーバーの通信をシミュレートしてみよう．</p>
<p>ユーザーが Twitter を開くと，まず最初に <code>GET statuses/home_timeline</code> の API リクエストによって，ユーザーのホームのタイムラインのツイートのリストが取得される． 個々のツイートは JSON 形式のデータになっており， <code>id</code>, <code>text</code>, <code>user</code>, <code>coordinates</code>, <code>entities</code> などの属性を含む． <code>id</code> はツイートに固有な ID を表し， <code>text</code> はツイートの本文を含んでいる． <code>user</code> はツイートを投稿したユーザーの名前やプロフィール画像の URL などを含んだ JSON データになっている． <code>coordinates</code> にはツイートが発信された地理的な座標が記録されている． また， <code>entities</code> にはツイートに関連するメディアファイル (画像など) のリンクなどの情報が埋め込まれている． <code>GET statuses/home_timeline</code> からは直近のツイートのリスト (リストが長すぎる場合は途中で切られたもの) が取得される． もしツイートの ID を知っている場合は <code>GET statuses/show/:id</code> を呼ぶことによって， <code>:id</code> パラメータで指定された特定のツイートを取得することができる．</p>
<p>ツイートの検索を行うためには <code>GET search</code> API を使用する． この API には，ツイートに含まれる単語や，ハッシュタグ，ツイートの発信された日時や場所など，様々なクエリの条件を渡すことができる． API からは， <code>GET statuses/home_timeline</code> などと同様， JSON 形式のツイートのデータが返される．</p>
<p>ユーザーが新しいツイートを投稿するには <code>POST statuses/update</code> のエンドポイントを利用する． <code>POST statuses/update</code> には，ツイートの文章や，リプライの場合はリプライ先のツイートの ID などのデータを送信する． また，ツイートに画像データを添付したい場合は， <code>POST media/upload</code> を併せて使用する． ツイートの削除を行うには， <code>POST statuses/destroy/:id</code> を用いる．</p>
<p>そのほか，頻繁に行われる操作としては， <code>POST statuses/retweet/:id</code> と <code>POST statuses/unretweet/:id</code> がある． これらは， <code>:id</code> で指定されるツイートに対して，それぞれリツイートを実行あるいは取り消すための API である． また， <code>POST favorites/create</code>，<code>POST favorites/destroy</code> を使用することによって，選択されたツイートに&quot;いいね&quot;を追加したり，取り消したりする操作を行う．</p>
<p>このような一連の操作が， Twitter のアプリの背後では行われている． また，自分自身でボットを作成したい場合は，これらの API を適切に組み合わせ，カスタムのプログラムを書くことで実現される．</p>
<p>このように， API はあらゆるウェブサービスを作るうえで一番基礎となる要素である． 次からの章では本章で紹介した用語が何度も出てくるので，頭の片隅に置いたうえで読み進めていただきたい．</p>
<h1 id="serverless-architecture" tabindex="-1">Serverless architecture <a class="header-anchor" href="#serverless-architecture" aria-label="Permalink to &quot;Serverless architecture&quot;">&ZeroWidthSpace;</a></h1>
<p>サーバーレスアーキテクチャ (Serverless architecture) あるいは サーバーレスコンピューティング (Serverless computing) とは，従来とは全く異なるアプローチに基づくクラウドシステムの設計方法である． 歴史的には， AWS が 2014 年に発表した <a href="https://aws.amazon.com/lambda/" target="_blank" rel="noreferrer">Lamba</a> がサーバーレスアーキテクチャの先駆けとされている． その後， Google や Microsoft などのクラウドプラットフォームも同様の機能の提供を開始している． サーバーレスアーキテクチャの利点は，スケーラブルなクラウドシステムを安価かつ簡易に作成できる点であり，近年いたるところで導入が進んでいる．</p>
<p>Serverless とは，文字どおりの意味としてはサーバーなしで計算をするということになるが，それは一体どういう意味だろうか？ サーバーレスについて説明するためには，まずは従来的な， &quot;serverful&quot; とよばれるようなシステムについて解説しなければならない．</p>
<h2 id="serverful-クラウド-従来型" tabindex="-1">Serverful クラウド (従来型) <a class="header-anchor" href="#serverful-クラウド-従来型" aria-label="Permalink to &quot;Serverful クラウド (従来型)&quot;">&ZeroWidthSpace;</a></h2>
<p>従来的なクラウドシステムのスケッチを <a href="#serverful">figure_title</a> に示す． クライアントから送信されたリクエストは，最初に API サーバーに送られる． API サーバーでは，リクエストの内容に応じてタスクが実行される． タスクには，API サーバーだけで完結できるものもあるが，多くの場合，データベースの読み書きが必要である． データベースには，データベース専用の独立したサーバーマシンが用いられることが一般的である． また，画像や動画などの容量の大きいデータは，また別のストレージサーバーに保存されることが多い． これらの API サーバー，データベースサーバー，ストレージサーバーはそれぞれ独立したサーバーマシンであり， AWS の言葉では EC2 による仮想インスタンスを想定してもらったらよい．</p>
<p>多くのウェブサービスでは，多数のクライアントからのリクエストを処理するため，複数のサーバーマシンがクラウド内で起動し，負荷を分散するような設計がなされている． クライアントから来たリクエストを計算容量に余裕のあるサーバーに振り分けるような操作を <strong>Load balancing</strong> とよび，そのような操作を担当するマシンのことを <strong>Load balancer</strong> という．</p>
<p>計算負荷を分散する目的で多数のインスタンスを起動するのはよいのだが，計算負荷が小さすぎてアイドリング状態にあるようではコストと電力の無駄遣いである． したがって，すべてのサーバーが常に目標とする計算負荷を維持するよう，計算の負荷に応じてクラスター内の仮想サーバーの数を動的に増減させるような仕組みが必要である． そのような仕組みを<strong>クラスターのスケーリング</strong>とよび，負荷の増大に応答して新しい仮想インスタンスをクラスターに追加する操作を <strong>scale-out</strong>，負荷の減少に応答してインスタンスをシャットダウンする操作を <strong>scale-in</strong> とよぶ． クラスターのスケーリングは， API サーバーではもちろんのこと，データベースサーバー・ストレージサーバーでも必要になる． ストレージサーバーでは，例えば頻繁にアクセスされるデータはキャッシュ領域に保存したり，データのコピーを複数作るなどのスケーリングが行われる． データベースサーバーも同様に，頻繁にアクセスされるデータのアクセスがパンクしてしまわないよう，分散的な処理が必要となる． このように，<strong>クラウドシステム内すべての箇所で，負荷が均一になるような調整が必要であり，開発者は多くの時間をそのチューニングに費やさなければならない．</strong> また，サービスの利用者の数などに応じてスケーリングの設定は常に見直される必要があり，継続的な開発が要求される．</p>
<p>さらに問題を複雑にするのは，API サーバーで処理されるべきタスクが，非一様な点である． 非一様であるとは，たとえばタスク A は 3000 ミリ秒の実行時間と 512MB のメモリーを消費し，別のタスク B は 1000 ミリ秒の実行時間と 128MB のメモリーを消費する，というような状況を指している． 一つのサーバーマシンが計算負荷が異なる複数のタスクを処理する場合，クラスターのスケーリングはより複雑になる． この状況をシンプルにするために，１サーバーで実行するタスクは１種類に限る，という設計も可能であるが，そうするとで生まれる弊害も多い (ほとんど使われないタスクに対してもサーバー一台をまるまる割り当てなければならない = ほとんどアイドリング状態になってしまう，など)．</p>
<p><img src="./assets/serverful.png" alt="Serverful なクラウドシステム"></p>
<h2 id="serverless-クラウドへ" tabindex="-1">Serverless クラウドへ <a class="header-anchor" href="#serverless-クラウドへ" aria-label="Permalink to &quot;Serverless クラウドへ&quot;">&ZeroWidthSpace;</a></h2>
<p><a href="#chap_serverful_cloud">Serverful クラウド (従来型)</a> で議論したように，クラスターのスケーリングはクラウドシステムの経済的効率とシステムの安定性を最大化するために必須の作業である． それを反映して，多くの開発者の時間が投資されてきた．</p>
<p>クラスターのスケーリングはすべての開発者が何度も繰り返し行ってきた作業であり，いくつかの側面をテンプレート化し，共通化することができたならば開発のコストを大幅に削減できるだろう． それを実現するには，根本的なレベルからクラウドシステムの設計を考え直す必要がある． <strong>スケーリングを前提</strong>として考えることで，もっと<strong>シンプルで見通しがよいクラウドシステムの設計の仕組みはないだろうか</strong>？ そのような動機が，サーバーレスアーキテクチャが誕生する背後にあった．</p>
<p>従来の serverful なシステムでの最大の問題点は，<strong>サーバーをまるまる占有してしまう</strong>という点にある． すなわち， EC2 インスタンスを起動したとき，そのインスタンスは起動したユーザーだけが使えるものであり，<strong>計算のリソース (CPU や RAM) が独占的に割り当てられた状態</strong>になる． 固定した計算資源の割り当てがされてしまっているので，<strong>インスタンスの計算負荷が 0%であろうが 100%であろうが，均一の使用料金が起動時間に比例</strong>して発生する．</p>
<p>サーバーレスアーキテクチャは，このような <strong>独占的に割り当てられた計算リソースというものを完全に廃止する</strong>ことを出発点とする． サーバーレスアーキテクチャでは，計算のリソースは，クラウドプロバイダーがすべて管理する． クライアントは，仮想インスタンスを一台まるごと借りるのではなく，計算のタスクの需要が生まれる毎に，<strong>実行したいプログラム・コマンドをクラウドに提出する</strong>． クラウドプロバイダーは，自身のもつ巨大な計算リソースから空きを探し，提出されたプログラムを実行し，実行結果をクライアントに返す． 言い換えると，計算リソースのスケーリングやアロケーションなどはクラウドプロバイダーが一手に引き受け，ユーザーはジョブをサブミットすることに注力する，という枠組みである． これを図示すると， <a href="#serverless">figure_title</a> のようになる．</p>
<p><img src="./assets/serverless.png" alt="従来のクラウドと Serverless クラウドの比較"></p>
<p>サーバーレスクラウドでは，スケーリングはすべてクラウドプロバイダーが引き受けるので，スケーラビリティーが保証されている． クライアントが同時に大量のタスクを送信した場合でも，クラウドプロバイダー側の独自の仕組みによってすべてのタスクが遅延なく実行される． また，サーバーレスクラウドを利用することで，<strong>クラウドのコストは実際に使用した計算の総量 (稼働時間) で決定される</strong>ことになる． これは，計算の実行総量に関わらずインスタンスの起動時間で料金が決定されていた従来のシステムと比べて大きな違いである．</p>
<p>サーバーレスクラウドは，従来のクラウドとは根本から異なったアプローチなので，コードの書き方やシステムの設計が大きく異なる． サーバーレスクラウドを開発・運用するには，サーバーレス固有の概念や用語に精通している必要がある． 以降では，実際にクラウドを動かしながら，サーバーレスをより具体的に体験していこう．</p>
<p>従来型の(仮想インスタンスをたくさん起動するような)クラウドシステムは，<strong>賃貸</strong>と似ているかもしれない． 部屋を借りるというのは，その部屋でどれだけの時間を過ごそうが，月々の家賃は一定である． 同様に，仮想サーバーも，それがどれほどの計算を行っているかに関わらず，一定の料金が時間ごとに発生する．</p>
<p>一方で，サーバーレスクラウドは，<strong>電気・水道・ガス料金</strong> と似ている． こちらは，実際に使用した量に比例して料金が決定されている． サーバーレスクラウドも，実際に計算を行った総時間で料金が決まる仕組みになっている．</p>
<h2 id="サーバーレスクラウドを構成するコンポーネント" tabindex="-1">サーバーレスクラウドを構成するコンポーネント <a class="header-anchor" href="#サーバーレスクラウドを構成するコンポーネント" aria-label="Permalink to &quot;サーバーレスクラウドを構成するコンポーネント&quot;">&ZeroWidthSpace;</a></h2>
<p>サーバーレスアーキテクチャの概要がわかってきたところで，ここでは AWS においてサーバーレスクラウドを構成する様々なコンポーネントを紹介していこう． 特に， <strong>Lambda</strong>, <strong>S3</strong>, <strong>DynamoDB</strong> を取り上げ，解説する (<a href="#fig:serverless_logos">figure_title</a>)． サーバーレスクラウドは，これらのコンポーネントを統合することで一つのシステムが出来上がる． ここでは， Lambda，S3，DynamoDB を利用する際に押さえておかなければならない知識を一通り説明しきる都合上，具体的なイメージがわきにくいかもしれない． が，続く <a href="#sec_intro_serverless">Hands-on #5: サーバーレス入門</a> でそれぞれについてハンズオン形式で演習を行うので，そこでさらに理解を深めれば大丈夫である．</p>
<p><img src="./assets/serverless_logos.png" alt="Lambda, S3, DynamoDB のアイコン"></p>
<h3 id="lambda" tabindex="-1">Lambda <a class="header-anchor" href="#lambda" aria-label="Permalink to &quot;Lambda&quot;">&ZeroWidthSpace;</a></h3>
<p>AWS でサーバーレスコンピューティングの中心を担うのが， <a href="https://aws.amazon.com/lambda/" target="_blank" rel="noreferrer">Lambda</a> である． Lambda の使い方を <a href="#lambda_workflow">figure_title</a> に図示している． Lambda の仕組みはシンプルで，まずユーザーは実行したいプログラムのコードを事前に登録しておく． プログラムは， Python, Node.js, Ruby などの主要な言語がサポートされている． Lambda に登録されたひとつひとつのプログラムを関数 (Function) とよぶ． そして，関数を実行したいときに，invoke コマンドを Lambda に送信する． Lambda では， invoke のリクエストを受け取るとただちに (数ミリセカンドから数百ミリセカンド程度の時間で) プログラムの実行を開始する． そして，実行結果をクライアントやその他の計算機に返す．</p>
<p><img src="./assets/lambda_workflow.png" alt="AWS Lambda"></p>
<p>このように，Lambda では占有された仮想インスタンスは存在せず，実行を待っているプログラムだけがある状態である． invoke のリクエストに応じて，プログラムが AWS の巨大な計算機プールのどこかに配置され，実行される． 同時に複数のリクエストが来た場合でも， AWS はそれらを実行するための計算リソースを割り当て，並列的に処理を行ってくれる． 原理上は，<strong>数千から数万のリクエストが同時に来たとしても， Lambda はそれらを同時に実行することができる</strong>． このような，占有された仮想サーバーの存在なしに，動的に関数を実行するサービスのことを総称して <strong>FaaS (Function as a Service)</strong> とよぶ．</p>
<p>Lambda ではそれぞれの関数につき， 128MB から 10240MB のメモリーを使用することができる (執筆時点の仕様)． また，実効的な CPU のパワーはメモリーの量に比例する形で割り当てられる． すなわち，タスクに割り当てたメモリーの量が多ければ多いほど，より多くの CPU リソースが割り当てられることになる (しかし， RAM と CPU パワーの具体的な換算表は AWS からは公開されていない)． 実行時間は 100 ミリ秒の単位で記録され，実行時間に比例して料金が決定される． <a href="#lambda_pricing">table_title</a> は Lambda の利用料金表である (執筆時点で <code>ap-north-east1</code> リージョンを選択した場合)．</p>
<table><caption>Lambda の料金表</caption><colgroup><col style="width: 50%" /><col style="width: 50%" /></colgroup><thead><tr class="header"><th>Memory (MB)</th><th>Price per 100ms</th></tr></thead><tbody><tr class="odd"><td><p>128</p></td><td><p>$0.0000002083</p></td></tr><tr class="even"><td><p>512</p></td><td><p>$0.0000008333</p></td></tr><tr class="odd"><td><p>1024</p></td><td><p>$0.0000016667</p></td></tr><tr class="even"><td><p>3008</p></td><td><p>$0.0000048958</p></td></tr></tbody></table>
<p>実行時間に比例する料金に追加して，リクエストを送信するごとに発生する料金が設定されている． これは，百万回のリクエストにつき $0.2 である． たとえば， 128MB のメモリーを使用する関数を，それぞれ 200 ミリ秒，合計で 100 万回実行した場合， 0.0000002083 * 2 * 10^6 + 0.2 = $0.6 の料金となる． ウェブサーバーのデータベースの更新など簡単な計算であれば，200 ミリ秒程度で実行できる関数も多いことから，100 万回データベースの更新を行ったとしても，たった $0.6 しかコストが発生しないことになる． また，コードが実行されず待機状態になっている場合は，発生する料金は 0 である． このように，実際に意味のある処理が行われた時間にのみ，料金が発生する仕組みになっている．</p>
<p>Lambda は比較的短時間で完了する，反復性の高いタスクの実行に向いている． データベースの読み書きはその典型的な例であるが，そのほかにも，画像のサイズをトリミングしたり，サーバーサイドで定期的に実行されるメンテナンス処理などの利用が考えられる． また，複数の Lambda をリレー式に繋げることも可能で，シンプルな処理を組み合わせることで複雑なロジックを表現することができる．</p>
<p>上述の Lambda の料金計算は，説明のためコストに寄与する要素をいくつか省いている点は承知いただきたい． 例えば， DynamoDB の読み書きに関する料金や，ネットワークの通信にかかわるコストが考慮されていない．</p>
<h3 id="サーバーレスストレージ-s3" tabindex="-1">サーバーレスストレージ: S3 <a class="header-anchor" href="#サーバーレスストレージ-s3" aria-label="Permalink to &quot;サーバーレスストレージ: S3&quot;">&ZeroWidthSpace;</a></h3>
<p>サーバーレスの概念は，ストレージにも拡張されている．</p>
<p>従来的なストレージ (ファイルシステム) では，必ずホストとなるマシンと OS が存在しなければならない． したがって，それほどパワーは必要ないまでも，ある程度の CPU リソースを割かなければならない． また，従来的なファイルシステムでは，データ領域のサイズは最初にディスクを初期化するときに決めなければならず，後から容量を増加させることはしばしば困難である (ZFS などのファイルシステムを使えばある程度は自由にファイルシステムのサイズを変更することは可能である)． よって，従来的なクラウドでは，ストレージを借りる際にはあらかじめディスクのサイズを指定せねばならず，ディスクの中身が空であろうと満杯であろうと，同じ利用料金が発生することになる (<a href="#fig:s3_vs_filesystem">figure_title</a>)．</p>
<p><a href="https://aws.amazon.com/s3/" target="_blank" rel="noreferrer">Simple Storage Service (S3)</a> は，サーバーレスなストレージシステムを提供する (<a href="#fig:s3_vs_filesystem">figure_title</a>)． S3 は従来的なストレージシステムと異なり， OS に&quot;マウントする”という概念はない． 基本的に API を通じてデータの読み書きの操作が行われる． また，データの冗長化や暗号化，バックアップの作成など，通常ならば OS と CPU が介在しなければならない操作も， API を通じて行うことができる． S3 では事前に決められたディスク領域のサイズはなく，データを入れれば入れた分だけ，保存領域は拡大していく (仕様上はペタバイトスケールのデータを保存することが可能である)． ストレージにかかる料金は，保存してあるデータの総容量で決定される．</p>
<p><img src="./assets/s3_vs_filesystem.png" alt="S3 と従来的なファイルシステムの比較"></p>
<p>S3 を利用する際に，料金に関わってくる主要な事項をまとめたのが <a href="#tab:s3_pricing">table_title</a> である (<code>us-east-1</code> リージョンのもの． 説明のため主要な事項のみ取り出している． 詳細は <a href="https://aws.amazon.com/s3/pricing/?nc=sn&amp;loc=4" target="_blank" rel="noreferrer">公式ドキュメンテーション &quot;Amazon S3 pricing&quot;</a> を参照)．</p>
<table><caption>S3 の利用料金</caption><colgroup><col style="width: 50%" /><col style="width: 50%" /></colgroup><thead><tr class="header"><th>項目</th><th>料金</th></tr></thead><tbody><tr class="odd"><td><p>Data storage (First 50TB)</p></td><td><p>$0.023 per GB per month</p></td></tr><tr class="even"><td><p>PUT, COPY, POST, LIST requests (per 1,000 requests)</p></td><td><p>$0.005</p></td></tr><tr class="odd"><td><p>GET, SELECT, and all other requests (per 1,000 requests)</p></td><td><p>$0.0004</p></td></tr><tr class="even"><td><p>Data Transfer IN To Amazon S3 From Internet</p></td><td><p>$0</p></td></tr><tr class="odd"><td><p>Data Transfer OUT From Amazon S3 To Internet</p></td><td><p>$0.09 per GB</p></td></tr></tbody></table>
<p>第一に，データの保存には $0.025 per GB のコストが月ごとに発生する． したがって，1000GB のデータを S3 に一ヵ月保存した場合， $25 の料金が発生することになる． また，<code>PUT</code>, <code>COPY</code>, <code>POST</code> などのリクエスト (=データを書き込む操作) に対しては，データ容量に関係なく，1000 回ごとに $0.005 のコストが発生する． <code>GET</code>, <code>SELECT</code> などのリクエスト (=データを読み込む操作) に対しては，1000 回ごとに $0.0004 のコストが発生する． また， S3 はデータを外に取り出す際の通信にもコストが生じる． 執筆時点では，S3 からインターネットを通じて外部にデータを転送 (data-out) すると $0.09 per GB のコストが発生する． データをインターネットを通じて S3 に入れる (data-in) 通信は無料で行える． また， AWS の 同じ Region 内のサービス (Lambda や EC2 など) にデータを転送するのは無料である． AWS のリージョンをまたいだデータの転送にはコストが発生する． いずれにせよ，サーバーレスの概念に則り，すべての料金が従量課金制で決定される設定になっている．</p>
<h3 id="サーバーレスデータベース-dynamodb" tabindex="-1">サーバーレスデータベース: DynamoDB <a class="header-anchor" href="#サーバーレスデータベース-dynamodb" aria-label="Permalink to &quot;サーバーレスデータベース: DynamoDB&quot;">&ZeroWidthSpace;</a></h3>
<p>サーバーレスの概念は，データベースにも適用することができる．</p>
<p>ここでいうデータベースとは， Web サービスなどにおけるユーザーや商品の情報を記録しておくための保存領域のことを指している． 従来的に有名なデータベースとしては <a href="https://www.mysql.com/" target="_blank" rel="noreferrer">MySQL</a>, <a href="https://www.postgresql.org/" target="_blank" rel="noreferrer">PostgreSQL</a>, <a href="https://www.mongodb.com/" target="_blank" rel="noreferrer">MongoDB</a> などが挙げられる． データベースと普通のストレージの違いは，データの検索機能にある． 普通のストレージではデータは単純にディスクに書き込まれるだけだが， データベースでは検索がより効率的になるようなデータの配置がされたり， 頻繁にアクセスされるデータはメモリーにキャッシュされるなどの機能が備わっている． これにより，巨大なデータの中から，興味のある要素を高速に取得することができる．</p>
<p>このような検索機能を実現するには，当然 CPU の存在が必須である． したがって，従来的なデータベースを構築する際は，ストレージ領域に加えて，たくさんの CPU コアを搭載したマシンが用いられることが多い． また，データベースが巨大な場合は複数マシンにまたがった分散型のシステムが設計される． 分散型システムの場合は， <a href="#chap_serverful_cloud">Serverful クラウド (従来型)</a> で議論したようにデータベースへのアクセス負荷に応じて適切なスケーリングがなされる必要がある．</p>
<p><a href="https://aws.amazon.com/dynamodb/" target="_blank" rel="noreferrer">DynamoDB</a> は， AWS が提供しているサーバーレスな分散型データベースである． サーバーレスであるので，占有されたデータベース用仮想インスタンスは存在せず， API を通じてデータの書き込み・読み出し・検索などの操作を行う． S3 と同様に，データ保存領域の上限は定められておらず，データを入れれば入れた分だけ，保存領域は拡大していく． また，データベースへの負荷が増減したときのスケーリングは， DynamoDB が自動で行うので，ユーザーは心配する必要はない．</p>
<p>DynamoDB での利用料金の計算はやや複雑なのだが， &quot;On-demand Capacity&quot; というモードで使用した場合の料金に関わってくる主要な事項をまとめたのが <a href="#tab:dynamodb_pricing">table_title</a> である (<code>us-east-1</code> リージョンのもの． 詳細は <a href="https://aws.amazon.com/dynamodb/pricing/on-demand/" target="_blank" rel="noreferrer">公式ドキュメンテーション &quot;Pricing for On-Demand Capacity&quot;</a> を参照)．</p>
<table><caption>DynamoDB の利用料金</caption><colgroup><col style="width: 50%" /><col style="width: 50%" /></colgroup><thead><tr class="header"><th>項目</th><th>料金</th></tr></thead><tbody><tr class="odd"><td><p>Write request units</p></td><td><p>$1.25 per million write request units</p></td></tr><tr class="even"><td><p>Read request units</p></td><td><p>$0.25 per million read request units</p></td></tr><tr class="odd"><td><p>Data storage</p></td><td><p>$0.25 per GB-month</p></td></tr></tbody></table>
<p>DynamoDB ではデータの書き込み操作の単位を write request unit とよび，データの読み込み操作の単位を read request unit とよぶ． 基本的に， 1kB 以下のデータを一度書き込むと 1 write request unit を消費し，4kB 以下のデータを一度読み込むと 1 read request unit を消費する (詳しくは <a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.ReadWriteCapacityMode.html" target="_blank" rel="noreferrer">公式ドキュメンテーション &quot;Read/Write Capacity Mode&quot;</a> を参照のこと)． write request units は 100 万回ごとに $1.25, read request units は 100 万回ごとに $0.25 のコストが設定されている． また，保存されたデータ容量に対して $0.25 per GB のコストが月ごとに発生する． DynamoDB は高速な検索機能などを備えたデータベースであるので， GB あたりのストレージコストは S3 に比べ 10 倍程度高い． DynamoDB のデータの転送に関わるコストは，同じリージョン内ならば data-in，data-out ともに $0 である． リージョンをまたいだ通信には別途コストが発生する．</p>
<h3 id="その他のサーバーレスクラウドの構成要素" tabindex="-1">その他のサーバーレスクラウドの構成要素 <a class="header-anchor" href="#その他のサーバーレスクラウドの構成要素" aria-label="Permalink to &quot;その他のサーバーレスクラウドの構成要素&quot;">&ZeroWidthSpace;</a></h3>
<p>以上で紹介した Lambda, S3, DynamoDB がサーバーレスクラウドの中で最も使用する頻度が高いサービスになる． その他のサーバーレスクラウドの構成要素を以下に列挙する． いくつかについては，今後のハンズオンを行う中で改めて解説を行う．</p>
<ul>
<li>
<p><a href="https://aws.amazon.com/api-gateway/" target="_blank" rel="noreferrer">API Gateway</a>: API を構築する際のルーティングを担う． <a href="#sec_bashoutter">Hands-on #6: Bashoutter</a> で取り上げる．</p>
</li>
<li>
<p><a href="https://aws.amazon.com/fargate/" target="_blank" rel="noreferrer">Fargate</a>: <a href="#sec_fargate_qabot">Hands-on #3: AWS で自動質問回答ボットを走らせる</a> で触れた Fargate も，サーバーレスクラウドの要素の一部である． Lambda との違いは，Lambda よりも大容量のメモリーや CPU を要するような計算などを行うことができる点が挙げられる．</p>
</li>
<li>
<p><a href="https://aws.amazon.com/sns/" target="_blank" rel="noreferrer">Simple Notification Service (SNS)</a>: サーバーレスのサービス間でイベントをやり取りするためのサービス．</p>
</li>
<li>
<p><a href="https://aws.amazon.com/step-functions/" target="_blank" rel="noreferrer">Step Functions</a>: サーバーレスのサービス間のオーケストレーションを担う．</p>
</li>
</ul>
<p><strong>サーバーレスアーキテクチャは万能か？</strong></p>
<p>この問いへの答えは，筆者は NO であると考える．</p>
<p>ここまで，サーバーレスの利点を強調して説明をしてきたが，まだまだ新しい技術なだけに，欠点，あるいはサーバーフルなシステムに劣る点は数多くある．</p>
<p>大きな欠点を一つあげるとすれば，サーバーレスのシステムは各クラウドプラットフォームに固有なものなので，特定のプラットフォームでしか運用できないシステムになってしまう点であろう． AWS で作成したサーバーレスのシステムを， Google のクラウドに移植するには，かなり大掛かりなプログラムの書き換えが必要になる． 一方， serverful なシステムであれば，プラットフォーム間のマイグレーションは比較的簡単に行うことができる． クラウドプロバイダーとしては，自社のシステムへの依存度を強めることで，顧客を離さないようにするという狙いがあるのだろう…</p>
<p>その他，サーバーレスコンピューティングの欠点や今後の課題などは，次の論文で詳しく議論されている． 興味のある読者はぜひ読んでいただきたい．</p>
<ul>
<li><a href="https://arxiv.org/abs/1812.03651" target="_blank" rel="noreferrer">Hellerstein et al., &quot;Serverless Computing: One Step Forward, Two Steps Back&quot; arXiv (2018)</a></li>
</ul>
<h1 id="hands-on-5-サーバーレス入門" tabindex="-1">Hands-on #5: サーバーレス入門 <a class="header-anchor" href="#hands-on-5-サーバーレス入門" aria-label="Permalink to &quot;Hands-on \#5: サーバーレス入門&quot;">&ZeroWidthSpace;</a></h1>
<p>前章ではサーバーレスアーキテクチャの概要の説明を行った． 本章では，ハンズオン形式でサーバーレスクラウドを実際に動かしながら，具体的な使用方法を学んでいこう． 今回のハンズオンでは Lambda, S3, DynamoDB の三つのサーバーレスクラウドの構成要素に触れていく． それぞれについて，短いチュートリアルを用意してある．</p>
<h2 id="lambda-ハンズオン" tabindex="-1">Lambda ハンズオン <a class="header-anchor" href="#lambda-ハンズオン" aria-label="Permalink to &quot;Lambda ハンズオン&quot;">&ZeroWidthSpace;</a></h2>
<p>まずは， Lambda を実際に動かしてみよう． ハンズオンのソースコードは GitHub の <a href="https://github.com/andatoshiki/toshiki-notebooktree/main/handson/serverless/lambda" target="_blank" rel="noreferrer">handson/serverless/lambda</a> に置いてある．</p>
<p>このハンズオンで使用するアプリケーションのスケッチを <a href="#fig:lambda_deploy">figure_title</a> に示す． STEP 1 では，AWS CDK を使用して Python で書かれたコードを Lambda に登録する． 続いて STEP 2 では， Invoke API を使用して，同時にいくつもの Lambda を起動し，並列な計算を行う． Lambda のワークフローを体験する目的で最小限の設定である．</p>
<p><img src="./assets/handson-serverless/lambda_deploy.png" alt="Lambda チュートリアルの概要"></p>
<p>このハンズオンは，基本的に <a href="https://aws.amazon.com/free/?all-free-tier.sort-by=item.additionalFields.SortRank&amp;all-free-tier.sort-order=asc" target="_blank" rel="noreferrer">AWS Lambda の無料枠</a> の範囲内で実行することができる．</p>
<p><a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/serverless/lambda/app.py" target="_blank" rel="noreferrer">app.py</a> にデプロイするプログラムが書かれている． 中身を見てみよう．</p>
<div class="language-py vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">py</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #6CB6FF">FUNC</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;&quot;&quot;</span></span>
<span class="line"><span style="color: #96D0FF">import time</span></span>
<span class="line"><span style="color: #96D0FF">from random import choice, randint</span></span>
<span class="line"><span style="color: #96D0FF">def handler(event, context):</span></span>
<span class="line"><span style="color: #96D0FF">    time.sleep(randint(2,5))</span></span>
<span class="line"><span style="color: #96D0FF">    sushi = [&quot;salmon&quot;, &quot;tuna&quot;, &quot;squid&quot;]</span></span>
<span class="line"><span style="color: #96D0FF">    message = &quot;Welcome to Cloud Sushi. Your order is &quot; + choice(sushi)</span></span>
<span class="line"><span style="color: #96D0FF">    print(message)</span></span>
<span class="line"><span style="color: #96D0FF">    return message</span></span>
<span class="line"><span style="color: #96D0FF">&quot;&quot;&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F47067">class</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50">SimpleLambda</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">core</span><span style="color: #ADBAC7">.</span><span style="color: #6CB6FF">Stack</span><span style="color: #ADBAC7">):</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">def</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">__init__</span><span style="color: #ADBAC7">(self, scope: core.App, name: </span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">, </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">kwargs) -&gt; </span><span style="color: #6CB6FF">None</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #6CB6FF">super</span><span style="color: #ADBAC7">().</span><span style="color: #6CB6FF">__init__</span><span style="color: #ADBAC7">(scope, name, </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">kwargs)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        handler </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> _lambda.Function(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&#39;LambdaHandler&#39;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">runtime</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">_lambda.Runtime.</span><span style="color: #6CB6FF">PYTHON_3_7</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">code</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">_lambda.Code.from_inline(</span><span style="color: #6CB6FF">FUNC</span><span style="color: #ADBAC7">),</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">handler</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;index.handler&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">memory_size</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">128</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">timeout</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">core.Duration.seconds(</span><span style="color: #6CB6FF">10</span><span style="color: #ADBAC7">),</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">dead_letter_queue_enabled</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">True</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #005CC5">FUNC</span><span style="color: #24292E"> </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;&quot;&quot;</span></span>
<span class="line"><span style="color: #032F62">import time</span></span>
<span class="line"><span style="color: #032F62">from random import choice, randint</span></span>
<span class="line"><span style="color: #032F62">def handler(event, context):</span></span>
<span class="line"><span style="color: #032F62">    time.sleep(randint(2,5))</span></span>
<span class="line"><span style="color: #032F62">    sushi = [&quot;salmon&quot;, &quot;tuna&quot;, &quot;squid&quot;]</span></span>
<span class="line"><span style="color: #032F62">    message = &quot;Welcome to Cloud Sushi. Your order is &quot; + choice(sushi)</span></span>
<span class="line"><span style="color: #032F62">    print(message)</span></span>
<span class="line"><span style="color: #032F62">    return message</span></span>
<span class="line"><span style="color: #032F62">&quot;&quot;&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D73A49">class</span><span style="color: #24292E"> </span><span style="color: #6F42C1">SimpleLambda</span><span style="color: #24292E">(</span><span style="color: #6F42C1">core</span><span style="color: #24292E">.</span><span style="color: #6F42C1">Stack</span><span style="color: #24292E">):</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">def</span><span style="color: #24292E"> </span><span style="color: #005CC5">__init__</span><span style="color: #24292E">(self, scope: core.App, name: </span><span style="color: #005CC5">str</span><span style="color: #24292E">, </span><span style="color: #D73A49">**</span><span style="color: #24292E">kwargs) -&gt; </span><span style="color: #005CC5">None</span><span style="color: #24292E">:</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #005CC5">super</span><span style="color: #24292E">().</span><span style="color: #005CC5">__init__</span><span style="color: #24292E">(scope, name, </span><span style="color: #D73A49">**</span><span style="color: #24292E">kwargs)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        handler </span><span style="color: #D73A49">=</span><span style="color: #24292E"> _lambda.Function(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&#39;LambdaHandler&#39;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">runtime</span><span style="color: #D73A49">=</span><span style="color: #24292E">_lambda.Runtime.</span><span style="color: #005CC5">PYTHON_3_7</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">code</span><span style="color: #D73A49">=</span><span style="color: #24292E">_lambda.Code.from_inline(</span><span style="color: #005CC5">FUNC</span><span style="color: #24292E">),</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">handler</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;index.handler&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">memory_size</span><span style="color: #D73A49">=</span><span style="color: #005CC5">128</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">timeout</span><span style="color: #D73A49">=</span><span style="color: #24292E">core.Duration.seconds(</span><span style="color: #005CC5">10</span><span style="color: #24292E">),</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">dead_letter_queue_enabled</span><span style="color: #D73A49">=</span><span style="color: #005CC5">True</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        )</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br></div></div><ul>
<li>
<p>ここで， Lambda で実行されるべき関数を定義している． これは非常に単純な関数で，2-5 秒のランダムな時間スリープした後，[&quot;salmon&quot;, &quot;tuna&quot;, &quot;squid&quot;] のいずれかの文字列をランダムに選択し， &quot;Welcome to Cloud Sushi. Your order is XXXX&quot; (XXXX は選ばれた寿司のネタ) というメッセージをリターンする．</p>
</li>
<li>
<p>次に， Lambda に &lt;1&gt; で書いた関数を配置している． パラメータの意味は，文字どおりの意味なので難しくはないが，以下に解説する．</p>
<ul>
<li>
<p><code>runtime=_lambda.Runtime.PYTHON_3_7</code>: ここでは， Python3.7 を使って上記で定義された関数を実行せよ，と指定している． Python3.7 のほかに， Node.js, Java, Ruby, Go などの言語を指定することが可能である．</p>
</li>
<li>
<p><code>code=_lambda.Code.from_inline(FUNC)</code>: 実行されるべき関数が書かれたコードを指定する． ここでは， <code>FUNC=...</code> で定義した文字列を渡しているが，文字列以外にもファイルのパスを渡すことも可能である．</p>
</li>
<li>
<p><code>handler=&quot;index.handler&quot;</code>: これは，コードの中にいくつかのサブ関数が含まれているときに，メインとサブを区別するためのパラメータである． <code>handler</code> という名前の関数をメイン関数として実行せよ，という意味である．</p>
</li>
<li>
<p><code>memory_size=128</code>: メモリーは 128MB を最大で使用することを指定している．</p>
</li>
<li>
<p><code>timeout=core.Duration.seconds(10)</code> タイムアウト時間を 10 秒に設定している． 10 秒以内に関数の実行が終了しなかった場合，エラーが返される．</p>
</li>
<li>
<p><code>dead_letter_queue_enabled=True</code>: アドバンストな設定なので説明は省略する．</p>
</li>
</ul>
</li>
</ul>
<p>上記のプログラムを実行することで， Lambda 関数がクラウド上に作成される． 早速デプロイしてみよう．</p>
<h3 id="デプロイ" tabindex="-1">デプロイ <a class="header-anchor" href="#デプロイ" aria-label="Permalink to &quot;デプロイ&quot;">&ZeroWidthSpace;</a></h3>
<p>デプロイの手順は，これまでのハンズオンとほとんど共通である． ここでは，コマンドのみ列挙する (<code>#</code> で始まる行はコメントである)． それぞれの意味を忘れてしまった場合は，ハンズオン 1, 2 に戻って復習していただきたい． シークレットキーの設定も忘れずに (<a href="#aws_cli_install">AWS CLI のインストール</a>)．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390"># プロジェクトのディレクトリに移動</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cd</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">handson/serverless/lambda</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># venv を作成し，依存ライブラリのインストールを行う</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python3</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-m</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">venv</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.env</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">source</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.env/bin/activate</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">pip</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">install</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-r</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">requirements.txt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># デプロイを実行</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cdk</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">deploy</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D"># プロジェクトのディレクトリに移動</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cd</span><span style="color: #24292E"> </span><span style="color: #032F62">handson/serverless/lambda</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># venv を作成し，依存ライブラリのインストールを行う</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python3</span><span style="color: #24292E"> </span><span style="color: #005CC5">-m</span><span style="color: #24292E"> </span><span style="color: #032F62">venv</span><span style="color: #24292E"> </span><span style="color: #032F62">.env</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">source</span><span style="color: #24292E"> </span><span style="color: #032F62">.env/bin/activate</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">pip</span><span style="color: #24292E"> </span><span style="color: #032F62">install</span><span style="color: #24292E"> </span><span style="color: #005CC5">-r</span><span style="color: #24292E"> </span><span style="color: #032F62">requirements.txt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># デプロイを実行</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cdk</span><span style="color: #24292E"> </span><span style="color: #032F62">deploy</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br></div></div><p>デプロイのコマンドが無事に実行されれば， <a href="#handson_04_lambda_cdk_output">figure_title</a> のような出力が得られるはずである． ここで表示されている <code>SimpleLambda.FunctionName = XXXX</code> の XXXX の文字列は後で使うのでメモしておこう．</p>
<p><img src="./assets/handson-serverless/handson_04_lambda_cdk_output.png" alt="CDKデプロイ実行後の出力"></p>
<p>AWS コンソールにログインして，デプロイされたスタックを確認してみよう． コンソールから，Lambda のページに行くと <a href="#handson_04_lambda_console_func_list">figure_title</a> のような画面から Lambda の関数の一覧が確認できる．</p>
<p><img src="./assets/handson-serverless/lambda_console_func_list.png" alt="Lambda コンソール - 関数の一覧"></p>
<p>今回のアプリケーションで作成したのが <code>SimpleLambda</code> で始まるランダムな名前のついた関数だ． 関数の名前をクリックして，詳細を見てみる． すると <a href="#handson_04_lambda_console_func_detail">figure_title</a> のような画面が表示されるはずだ． 先ほどプログラムの中で定義した Python の関数がエディターから確認できる． さらに下の方にスクロールすると，関数の各種設定も確認できる．</p>
<p><img src="./assets/handson-serverless/lambda_console_func_detail.png" alt="Lambda コンソール - 関数の詳細"></p>
<p>Lambda で実行されるコードは， Lambda のコンソール画面 (<a href="#handson_04_lambda_console_func_detail">figure_title</a>) のエディターで編集することもできる． デバッグをするときなどは，こちらを直接いじる方が早い場合もある． その場合は， CDK のコードに行った編集を反映させなおすことを忘れずに．</p>
<h3 id="lambda-関数の実行" tabindex="-1">Lambda 関数の実行 <a class="header-anchor" href="#lambda-関数の実行" aria-label="Permalink to &quot;Lambda 関数の実行&quot;">&ZeroWidthSpace;</a></h3>
<p>それでは，作成した Lambda 関数を実行 (invoke) してみよう． AWS の API を使うことで，関数の実行をスタートすることができる． 今回は， <a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/serverless/lambda/invoke_one.py" target="_blank" rel="noreferrer">handson/serverless/lambda/invoke_one.py</a> に関数を実行するための簡単なプログラムを提供している． 興味のある読者はコードを読んでもらいたい．</p>
<p>以下のコマンドで，Lambda の関数を実行する． コマンドの <code>XXXX</code> の部分は，先ほどデプロイしたときに <code>SimpleLambda.FunctionName = XXXX</code> で得られた XXXX の文字列で置換する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">invoke_one.py</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">XXXX</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python</span><span style="color: #24292E"> </span><span style="color: #032F62">invoke_one.py</span><span style="color: #24292E"> </span><span style="color: #032F62">XXXX</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>すると， <code>&quot;Welcome to Cloud Sushi. Your order is salmon&quot;</code> という出力が得られるはずだ． とてもシンプルではあるが，クラウド上で先ほどの関数が走り，乱数が生成されたうえで，ランダムな寿司ネタが選択されて出力が返されている． このコマンドを何度か打ってみて，実行ごとに異なる寿司ネタが返されることを確認しよう．</p>
<p>さて，このコマンドは，一度につき一回の関数を実行したわけであるが， Lambda の本領は一度に大量のタスクを同時に実行できる点である． そこで，今度は一度に 100 個のタスクを同時に送信してみよう． <a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/serverless/lambda/invoke_many.py" target="_blank" rel="noreferrer">handson/serverless/lambda/invoke_many.py</a> のスクリプトを使用する．</p>
<p>次のコマンドを実行しよう． XXXX の部分は前述と同様に置き換える． 第二引数の <code>100</code> は 100 個のタスクを投入せよ，という意味である．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">invoke_many.py</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">XXXX</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">100</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python</span><span style="color: #24292E"> </span><span style="color: #032F62">invoke_many.py</span><span style="color: #24292E"> </span><span style="color: #032F62">XXXX</span><span style="color: #24292E"> </span><span style="color: #005CC5">100</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>すると次のような出力が得られるはずだ．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #6CB6FF">....................................................................................................</span></span>
<span class="line"><span style="color: #F69D50">Submitted</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">100</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">tasks</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">to</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">Lambda!</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #005CC5">....................................................................................................</span></span>
<span class="line"><span style="color: #6F42C1">Submitted</span><span style="color: #24292E"> </span><span style="color: #005CC5">100</span><span style="color: #24292E"> </span><span style="color: #032F62">tasks</span><span style="color: #24292E"> </span><span style="color: #032F62">to</span><span style="color: #24292E"> </span><span style="color: #032F62">Lambda!</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>実際に，100 個のタスクが同時に実行されていることを確認しよう． <a href="#handson_04_lambda_console_func_detail">figure_title</a> の画面に戻り， &quot;Monitoring&quot; というタブがあるので，それをクリックする． すると， <a href="#handson_04_lambda_console_monitoring">figure_title</a> のようなグラフが表示されるだろう．</p>
<p><img src="./assets/handson-serverless/lambda_console_monitoring.png" alt="Lambda コンソール - 関数の実行のモニタリング"></p>
<p><a href="#handson_04_lambda_console_monitoring">figure_title</a> のグラフの更新には数分かかることがあるので，なにも表示されない場合は少し待つ．</p>
<p><a href="#handson_04_lambda_console_monitoring">figure_title</a> で &quot;Invocations&quot; が関数が何度実行されたかを意味している． たしかに 100 回実行されていることがわかる． さらに， &quot;Concurrent executions&quot; は何個のタスクが同時に行われたかを示している． ここでは 96 となっていることから，96 個のタスクが並列的に実行されたことを意味している (これが 100 とならないのは，タスクの開始のコマンドが送られたのが完全には同タイミングではないことに起因する)．</p>
<p>このように，非常にシンプルではあるが， Lambda を使うことで，同時並列的に処理を実行することのできるクラウドシステムを簡単に作ることができた．</p>
<p>もしこのようなことを従来的な serverful なクラウドで行おうとした場合，クラスターのスケーリングなど多くのコードを書くことに加えて，いろいろなパラメータを調節する必要がある．</p>
<p>興味がある人は，一気に 1000 個などのジョブを投入してみるとよい． Lambda はそのような大量のリクエストにも対応できることが確認できるだろう． が，あまりやりすぎると Lambda の無料利用枠を超えて料金が発生してしまうので注意．</p>
<h3 id="スタックの削除-3" tabindex="-1">スタックの削除 <a class="header-anchor" href="#スタックの削除-3" aria-label="Permalink to &quot;スタックの削除&quot;">&ZeroWidthSpace;</a></h3>
<p>最後にスタックを削除しよう． スタックを削除するには，次のコマンドを実行すればよい．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cdk</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">destroy</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cdk</span><span style="color: #24292E"> </span><span style="color: #032F62">destroy</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><h2 id="dynamodb-ハンズオン" tabindex="-1">DynamoDB ハンズオン <a class="header-anchor" href="#dynamodb-ハンズオン" aria-label="Permalink to &quot;DynamoDB ハンズオン&quot;">&ZeroWidthSpace;</a></h2>
<p>続いて， DynamoDB の簡単なチュートリアルをやってみよう． ハンズオンのソースコードは GitHub の <a href="https://github.com/andatoshiki/toshiki-notebooktree/main/handson/serverless/dynamodb" target="_blank" rel="noreferrer">/handson/serverless/dynamodb</a> に置いてある．</p>
<p>このハンズオンで使用するアプリケーションのスケッチを <a href="#fig:dynamodb_deploy">figure_title</a> に示す． STEP 1 では，AWS CDK を使用して DynamoDB のテーブルを初期化し，デプロイする． 続いて STEP 2 では， API を使用してデータベースのデータの書き込み・読み出し・削除などの操作を練習する．</p>
<p><img src="./assets/handson-serverless/dynamodb_deploy.png" alt="DynamoDB チュートリアルの概要"></p>
<p>このハンズオンは，基本的に <a href="https://aws.amazon.com/free/?all-free-tier.sort-by=item.additionalFields.SortRank&amp;all-free-tier.sort-order=asc" target="_blank" rel="noreferrer">AWS DynamoDB の無料枠</a> の範囲内で実行できる．</p>
<p><a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/serverless/dynamodb/app.py" target="_blank" rel="noreferrer">handson/serverless/dynamodb/app.py</a> にデプロイするプログラムが書かれている． 中身を見てみよう．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">class</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50">SimpleDynamoDb</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">core</span><span style="color: #ADBAC7">.</span><span style="color: #6CB6FF">Stack</span><span style="color: #ADBAC7">):</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">def</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">__init__</span><span style="color: #ADBAC7">(self, scope: core.App, name: </span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">, </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">kwargs) -&gt; </span><span style="color: #6CB6FF">None</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #6CB6FF">super</span><span style="color: #ADBAC7">().</span><span style="color: #6CB6FF">__init__</span><span style="color: #ADBAC7">(scope, name, </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">kwargs)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        table </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ddb.Table(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;SimpleTable&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">partition_key</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ddb.Attribute(</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">name</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;item_id&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">type</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ddb.AttributeType.</span><span style="color: #6CB6FF">STRING</span></span>
<span class="line"><span style="color: #ADBAC7">            ),</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">billing_mode</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ddb.BillingMode.</span><span style="color: #6CB6FF">PAY_PER_REQUEST</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">removal_policy</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">core.RemovalPolicy.</span><span style="color: #6CB6FF">DESTROY</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">class</span><span style="color: #24292E"> </span><span style="color: #6F42C1">SimpleDynamoDb</span><span style="color: #24292E">(</span><span style="color: #6F42C1">core</span><span style="color: #24292E">.</span><span style="color: #6F42C1">Stack</span><span style="color: #24292E">):</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">def</span><span style="color: #24292E"> </span><span style="color: #005CC5">__init__</span><span style="color: #24292E">(self, scope: core.App, name: </span><span style="color: #005CC5">str</span><span style="color: #24292E">, </span><span style="color: #D73A49">**</span><span style="color: #24292E">kwargs) -&gt; </span><span style="color: #005CC5">None</span><span style="color: #24292E">:</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #005CC5">super</span><span style="color: #24292E">().</span><span style="color: #005CC5">__init__</span><span style="color: #24292E">(scope, name, </span><span style="color: #D73A49">**</span><span style="color: #24292E">kwargs)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        table </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ddb.Table(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;SimpleTable&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">partition_key</span><span style="color: #D73A49">=</span><span style="color: #24292E">ddb.Attribute(</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">name</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;item_id&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">type</span><span style="color: #D73A49">=</span><span style="color: #24292E">ddb.AttributeType.</span><span style="color: #005CC5">STRING</span></span>
<span class="line"><span style="color: #24292E">            ),</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">billing_mode</span><span style="color: #D73A49">=</span><span style="color: #24292E">ddb.BillingMode.</span><span style="color: #005CC5">PAY_PER_REQUEST</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">removal_policy</span><span style="color: #D73A49">=</span><span style="color: #24292E">core.RemovalPolicy.</span><span style="color: #005CC5">DESTROY</span></span>
<span class="line"><span style="color: #24292E">        )</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br></div></div><p>このコードで，最低限の設定がなされた空の DynamoDB テーブルが作成される． それぞれのパラメータの意味を簡単に解説しよう．</p>
<ul>
<li>
<p><code>partition_key</code>: すべての DynamoDB テーブルには Partition key が定義されていなければならない． Partition key とは，テーブル内の要素 (レコード) ごとに存在する固有の ID のことである． 同一の Partition key をもった要素がテーブルの中に二つ以上存在することはできない (注: Sort Key を使用している場合は除く．詳しくは <a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.CoreComponents.html" target="_blank" rel="noreferrer">公式ドキュメンテーション &quot;Core Components of Amazon DynamoDB&quot;</a> 参照)． また， Partition key が定義されていない要素はテーブルの中に存在することはできない． ここでは， Partition key に <code>item_id</code> という名前をつけている．</p>
</li>
<li>
<p><code>billing_mode</code>: <code>ddb.BillingMode.PAY_PER_REQUEST</code> を指定することで， <a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.ReadWriteCapacityMode.html#HowItWorks.OnDemand" target="_blank" rel="noreferrer">On-demand Capacity Mode</a> の DynamoDB が作成される． ほかに <code>PROVISIONED</code> というモードがあるが，これはかなり高度なケースを除いて使用しないだろう．</p>
</li>
<li>
<p><code>removal_policy</code>: CloudFormation のスタックが消去されたときに， DynamoDB も一緒に消去されるかどうかを指定する． このコードでは <code>DESTROY</code> を選んでいるので，すべて消去される． ほかのオプションを選択すると，スタックを消去しても DynamoDB のバックアップを残す，などの動作を定義することができる．</p>
</li>
</ul>
<h3 id="デプロイ-1" tabindex="-1">デプロイ <a class="header-anchor" href="#デプロイ-1" aria-label="Permalink to &quot;デプロイ&quot;">&ZeroWidthSpace;</a></h3>
<p>デプロイの手順は，これまでのハンズオンとほとんど共通である． ここでは，コマンドのみ列挙する (<code>#</code> で始まる行はコメントである)． シークレットキーの設定も忘れずに (<a href="#aws_cli_install">AWS CLI のインストール</a>)．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390"># プロジェクトのディレクトリに移動</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cd</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">handson/serverless/dynamodb</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># venv を作成し，依存ライブラリのインストールを行う</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python3</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-m</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">venv</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.env</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">source</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.env/bin/activate</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">pip</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">install</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-r</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">requirements.txt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># デプロイを実行</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cdk</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">deploy</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D"># プロジェクトのディレクトリに移動</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cd</span><span style="color: #24292E"> </span><span style="color: #032F62">handson/serverless/dynamodb</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># venv を作成し，依存ライブラリのインストールを行う</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python3</span><span style="color: #24292E"> </span><span style="color: #005CC5">-m</span><span style="color: #24292E"> </span><span style="color: #032F62">venv</span><span style="color: #24292E"> </span><span style="color: #032F62">.env</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">source</span><span style="color: #24292E"> </span><span style="color: #032F62">.env/bin/activate</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">pip</span><span style="color: #24292E"> </span><span style="color: #032F62">install</span><span style="color: #24292E"> </span><span style="color: #005CC5">-r</span><span style="color: #24292E"> </span><span style="color: #032F62">requirements.txt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># デプロイを実行</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cdk</span><span style="color: #24292E"> </span><span style="color: #032F62">deploy</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br></div></div><p>デプロイのコマンドが無事に実行されれば， <a href="#handson_04_dynamodb_cdk_output">figure_title</a> のような出力が得られるはずである． ここで表示されている <code>SimpleDynamoDb.TableName = XXXX</code> の XXXX の文字列は後で使うのでメモしておこう．</p>
<p><img src="./assets/handson-serverless/handson_04_dynamodb_cdk_output.png" alt="CDKデプロイ実行後の出力"></p>
<p>AWS コンソールにログインして，デプロイされたスタックを確認してみよう． コンソールから， DynamoDB のページに行き，左のメニューバーから &quot;Tables&quot; を選択する． すると， <a href="#handson_04_dynamodb_table_list">figure_title</a> のような画面からテーブルの一覧が確認できる．</p>
<p><img src="./assets/handson-serverless/dynamodb_table_list.png" alt="DynamoDB のコンソール (テーブルの一覧)"></p>
<p>今回のアプリケーションで作成したのが <code>SimpleDynamoDb</code> で始まるランダムな名前のついたテーブルだ． テーブルの名前をクリックして，詳細を見てみる． すると <a href="#handson_04_dynamodb_table_detail">figure_title</a> のような画面が表示されるはずだ． &quot;Items&quot; のタブをクリックすると，テーブルの中のレコードを確認できる． 現時点ではなにもデータを書き込んでいないので，空である．</p>
<p><img src="./assets/handson-serverless/dynamodb_table_detail.png" alt="DynamoDB のコンソール (テーブルの詳細画面)"></p>
<h3 id="データの読み書き" tabindex="-1">データの読み書き <a class="header-anchor" href="#データの読み書き" aria-label="Permalink to &quot;データの読み書き&quot;">&ZeroWidthSpace;</a></h3>
<p>それでは， <a href="#sec:serverless_dynamodb_deploy">デプロイ</a> で作ったテーブルを使ってデータの読み書きを実践してみよう． ここでは Python と <a href="https://boto3.amazonaws.com/v1/documentation/api/latest/index.html" target="_blank" rel="noreferrer">boto3</a> ライブラリを用いた方法を紹介する．</p>
<p>まずは，テーブルに新しい要素を追加してみよう． ハンズオンのディレクトリにある <a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/serverless/dynamodb/simple_write.py" target="_blank" rel="noreferrer">simple_write.py</a> を開いてみよう． 中には次のような関数が書かれている．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> boto3</span></span>
<span class="line"><span style="color: #F47067">from</span><span style="color: #ADBAC7"> uuid </span><span style="color: #F47067">import</span><span style="color: #ADBAC7"> uuid4</span></span>
<span class="line"><span style="color: #ADBAC7">ddb </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> boto3.resource(</span><span style="color: #96D0FF">&#39;dynamodb&#39;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F47067">def</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">write_item</span><span style="color: #ADBAC7">(table_name):</span></span>
<span class="line"><span style="color: #ADBAC7">    table </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ddb.Table(table_name)</span></span>
<span class="line"><span style="color: #ADBAC7">    table.put_item(</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">Item</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">{</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #96D0FF">&#39;item_id&#39;</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">(uuid4()),</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #96D0FF">&#39;first_name&#39;</span><span style="color: #ADBAC7">: </span><span style="color: #96D0FF">&#39;John&#39;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #96D0FF">&#39;last_name&#39;</span><span style="color: #ADBAC7">: </span><span style="color: #96D0FF">&#39;Doe&#39;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #96D0FF">&#39;age&#39;</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">25</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        }</span></span>
<span class="line"><span style="color: #ADBAC7">    )</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> boto3</span></span>
<span class="line"><span style="color: #D73A49">from</span><span style="color: #24292E"> uuid </span><span style="color: #D73A49">import</span><span style="color: #24292E"> uuid4</span></span>
<span class="line"><span style="color: #24292E">ddb </span><span style="color: #D73A49">=</span><span style="color: #24292E"> boto3.resource(</span><span style="color: #032F62">&#39;dynamodb&#39;</span><span style="color: #24292E">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D73A49">def</span><span style="color: #24292E"> </span><span style="color: #6F42C1">write_item</span><span style="color: #24292E">(table_name):</span></span>
<span class="line"><span style="color: #24292E">    table </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ddb.Table(table_name)</span></span>
<span class="line"><span style="color: #24292E">    table.put_item(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">Item</span><span style="color: #D73A49">=</span><span style="color: #24292E">{</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #032F62">&#39;item_id&#39;</span><span style="color: #24292E">: </span><span style="color: #005CC5">str</span><span style="color: #24292E">(uuid4()),</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #032F62">&#39;first_name&#39;</span><span style="color: #24292E">: </span><span style="color: #032F62">&#39;John&#39;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #032F62">&#39;last_name&#39;</span><span style="color: #24292E">: </span><span style="color: #032F62">&#39;Doe&#39;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #032F62">&#39;age&#39;</span><span style="color: #24292E">: </span><span style="color: #005CC5">25</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        }</span></span>
<span class="line"><span style="color: #24292E">    )</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br></div></div><p>コードを上から読んでいくと，まず最初に boto3 ライブラリをインポートし， <code>dynamodb</code> のリソースを呼び出している． <code>write_item()</code> 関数は， DynamoDB のテーブルの名前 (上で見た SimpleDynamoDb-XXXX) を引数として受け取る． そして， <code>put_item()</code> メソッドを呼ぶことで，新しいアイテムを DB に書き込んでいる． アイテムには <code>item_id</code>, <code>first_name</code>, <code>last_name</code>, <code>age</code> の 4 つの属性が定義されている． ここで， <code>item_id</code> は先ほど説明した Partition key に相当しており， <a href="https://en.wikipedia.org/wiki/Universally_unique_identifier" target="_blank" rel="noreferrer">UUID4</a> を用いたランダムな文字列を割り当てている．</p>
<p>では， <code>simple_write.py</code> を実行してみよう． &quot;XXXX&quot; の部分を自分がデプロイしたテーブルの名前 (<code>SimpleDynamoDb</code> で始まる文字列) に置き換えたうえで，次のコマンドを実行する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">simple_write.py</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">XXXX</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python</span><span style="color: #24292E"> </span><span style="color: #032F62">simple_write.py</span><span style="color: #24292E"> </span><span style="color: #032F62">XXXX</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>新しい要素が正しく書き込めたか， AWS コンソールから確認してみよう． <a href="#handson_04_dynamodb_table_detail">figure_title</a> と同じ手順で，テーブルの中身の要素の一覧を表示する． すると <a href="#fig:dynamodb_table_new_item">figure_title</a> のように，期待通り新しい要素が見つかるだろう．</p>
<p><img src="./assets/handson-serverless/dynamodb_table_new_item.png" alt="DynamoDB に新しい要素が追加されたことを確認"></p>
<p>boto3 を使ってテーブルから要素を読みだすことも可能である． ハンズオンのディレクトリにある <a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/serverless/dynamodb/simple_read.py" target="_blank" rel="noreferrer">simple_read.py</a> を見てみよう．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">import</span><span style="color: #ADBAC7"> boto3</span></span>
<span class="line"><span style="color: #ADBAC7">ddb </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> boto3.resource(</span><span style="color: #96D0FF">&#39;dynamodb&#39;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F47067">def</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">scan_table</span><span style="color: #ADBAC7">(table_name):</span></span>
<span class="line"><span style="color: #ADBAC7">    table </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ddb.Table(table_name)</span></span>
<span class="line"><span style="color: #ADBAC7">    items </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> table.scan().get(</span><span style="color: #96D0FF">&quot;Items&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">print</span><span style="color: #ADBAC7">(items)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">import</span><span style="color: #24292E"> boto3</span></span>
<span class="line"><span style="color: #24292E">ddb </span><span style="color: #D73A49">=</span><span style="color: #24292E"> boto3.resource(</span><span style="color: #032F62">&#39;dynamodb&#39;</span><span style="color: #24292E">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D73A49">def</span><span style="color: #24292E"> </span><span style="color: #6F42C1">scan_table</span><span style="color: #24292E">(table_name):</span></span>
<span class="line"><span style="color: #24292E">    table </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ddb.Table(table_name)</span></span>
<span class="line"><span style="color: #24292E">    items </span><span style="color: #D73A49">=</span><span style="color: #24292E"> table.scan().get(</span><span style="color: #032F62">&quot;Items&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">print</span><span style="color: #24292E">(items)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br></div></div><p><code>table.scan().get(&quot;Items&quot;)</code> によって，テーブルの中にあるすべての要素を読みだしている．</p>
<p>次のコマンドで，このスクリプトを実行してみよう (&quot;XXXX&quot; の部分を正しく置き換えることを忘れずに）．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">simple_read.py</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">XXXX</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python</span><span style="color: #24292E"> </span><span style="color: #032F62">simple_read.py</span><span style="color: #24292E"> </span><span style="color: #032F62">XXXX</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>先ほど書き込んだ要素が出力されることを確認しよう．</p>
<h3 id="大量のデータの読み書き" tabindex="-1">大量のデータの読み書き <a class="header-anchor" href="#大量のデータの読み書き" aria-label="Permalink to &quot;大量のデータの読み書き&quot;">&ZeroWidthSpace;</a></h3>
<p>DynamoDB の利点は，最初に述べたとおり，負荷に応じて自在にその処理能力を拡大できる点である．</p>
<p>そこで，ここでは一度に大量のデータを書き込む場合をシミュレートしてみよう． <a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/serverless/dynamodb/batch_rw.py" target="_blank" rel="noreferrer">batch_rw.py</a> に，一度に大量の書き込みを実行するためのプログラムが書いてある．</p>
<p>次のコマンドを実行してみよう (XXXX は自分のテーブルの名前に置き換える)．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">batch_rw.py</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">XXXX</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">write</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">1000</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python</span><span style="color: #24292E"> </span><span style="color: #032F62">batch_rw.py</span><span style="color: #24292E"> </span><span style="color: #032F62">XXXX</span><span style="color: #24292E"> </span><span style="color: #032F62">write</span><span style="color: #24292E"> </span><span style="color: #005CC5">1000</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>このコマンドを実行することで，ランダムなデータが 1000 個データベースに書き込まれる．</p>
<p>さらに，データベースの検索をかけてみよう． 今回書き込んだデータには <code>age</code> という属性に 1 から 50 のランダムな整数が割り当てられている． <code>age</code> が 2 以下であるような要素だけを検索し拾ってくるには，次のコマンドを実行すればよい．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">batch_rw.py</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">XXXX</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">search_under_age</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">2</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python</span><span style="color: #24292E"> </span><span style="color: #032F62">batch_rw.py</span><span style="color: #24292E"> </span><span style="color: #032F62">XXXX</span><span style="color: #24292E"> </span><span style="color: #032F62">search_under_age</span><span style="color: #24292E"> </span><span style="color: #005CC5">2</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>上の 2 つのコマンドを何回か繰り返し実行してみて，データベースに負荷をかけてみよう． とくに大きな遅延なく結果が返ってくることが確認できるだろう．</p>
<h3 id="スタックの削除-4" tabindex="-1">スタックの削除 <a class="header-anchor" href="#スタックの削除-4" aria-label="Permalink to &quot;スタックの削除&quot;">&ZeroWidthSpace;</a></h3>
<p>DynamoDB で十分に遊ぶことができたら，忘れずにスタックを削除しよう．</p>
<p>これまでのハンズオンと同様，スタックを削除するには，次のコマンドを実行すればよい．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cdk</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">destroy</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cdk</span><span style="color: #24292E"> </span><span style="color: #032F62">destroy</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><h2 id="s3-ハンズオン" tabindex="-1">S3 ハンズオン <a class="header-anchor" href="#s3-ハンズオン" aria-label="Permalink to &quot;S3 ハンズオン&quot;">&ZeroWidthSpace;</a></h2>
<p>最後に， S3 の簡単なチュートリアルを紹介する． ハンズオンのソースコードは GitHub の <a href="https://github.com/andatoshiki/toshiki-notebooktree/main/handson/serverless/s3" target="_blank" rel="noreferrer">handson/serverless/s3</a> に置いてある．</p>
<p><a href="#fig:s3_deploy">figure_title</a> が今回提供する S3 チュートリアルの概要である． STEP 1 として， AWS CDK を用いて S3 に新しい空のバケット (Bucket) を作成する． 続いて STEP 2 では，データのアップロード・ダウンロードの方法を解説する．</p>
<p><img src="./assets/handson-serverless/s3_deploy.png" alt="S3 チュートリアルの概要"></p>
<p>このハンズオンは，基本的に <a href="https://aws.amazon.com/free/?all-free-tier.sort-by=item.additionalFields.SortRank&amp;all-free-tier.sort-order=asc" target="_blank" rel="noreferrer">S3 の無料枠</a> の範囲内で実行することができる．</p>
<p><a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/serverless/s3/app.py" target="_blank" rel="noreferrer">app.py</a> にデプロイするプログラムが書かれている． 中身を見てみよう．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">class</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50">SimpleS3</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">core</span><span style="color: #ADBAC7">.</span><span style="color: #6CB6FF">Stack</span><span style="color: #ADBAC7">):</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">def</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">__init__</span><span style="color: #ADBAC7">(self, scope: core.App, name: </span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">, </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">kwargs) -&gt; </span><span style="color: #6CB6FF">None</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #6CB6FF">super</span><span style="color: #ADBAC7">().</span><span style="color: #6CB6FF">__init__</span><span style="color: #ADBAC7">(scope, name, </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">kwargs)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390"># S3 bucket to store data</span></span>
<span class="line"><span style="color: #ADBAC7">        bucket </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> s3.Bucket(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;bucket&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">removal_policy</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">core.RemovalPolicy.</span><span style="color: #6CB6FF">DESTROY</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">auto_delete_objects</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">True</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">class</span><span style="color: #24292E"> </span><span style="color: #6F42C1">SimpleS3</span><span style="color: #24292E">(</span><span style="color: #6F42C1">core</span><span style="color: #24292E">.</span><span style="color: #6F42C1">Stack</span><span style="color: #24292E">):</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">def</span><span style="color: #24292E"> </span><span style="color: #005CC5">__init__</span><span style="color: #24292E">(self, scope: core.App, name: </span><span style="color: #005CC5">str</span><span style="color: #24292E">, </span><span style="color: #D73A49">**</span><span style="color: #24292E">kwargs) -&gt; </span><span style="color: #005CC5">None</span><span style="color: #24292E">:</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #005CC5">super</span><span style="color: #24292E">().</span><span style="color: #005CC5">__init__</span><span style="color: #24292E">(scope, name, </span><span style="color: #D73A49">**</span><span style="color: #24292E">kwargs)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D"># S3 bucket to store data</span></span>
<span class="line"><span style="color: #24292E">        bucket </span><span style="color: #D73A49">=</span><span style="color: #24292E"> s3.Bucket(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;bucket&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">removal_policy</span><span style="color: #D73A49">=</span><span style="color: #24292E">core.RemovalPolicy.</span><span style="color: #005CC5">DESTROY</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">auto_delete_objects</span><span style="color: #D73A49">=</span><span style="color: #005CC5">True</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        )</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br></div></div><p><code>s3.Bucket()</code> を呼ぶことによって空のバケットが新規に作成される． 上記のコードだと，バケットの名前は自動生成される． もし，自分の指定した名前を与えたい場合は， <code>bucket_name</code> というパラメータを指定すればよい． その際， バケットの名前はユニークでなければならない (i.e. AWS のデプロイが行われるリージョン内で名前の重複がない) 点に注意しよう． もし，同じ名前のバケットが既に存在する場合はエラーが返ってくる．</p>
<p>デフォルトでは， CloudFormation スタックが削除されたとき， S3 バケットとその中に保存されたファイルは削除されない． これは，大切なデータを誤って消してしまうことを防止するための安全策である． <code>cdk destroy</code> を実行したときにバケットも含めてすべて削除されるようにするには， <code>removal_policy=core.RemovalPolicy.DESTROY, auto_delete_objects=True</code> とパラメータを設定する． 結果もよく理解したうえで，自分の用途にあった適切なパラメータを設定しよう．</p>
<h3 id="デプロイ-2" tabindex="-1">デプロイ <a class="header-anchor" href="#デプロイ-2" aria-label="Permalink to &quot;デプロイ&quot;">&ZeroWidthSpace;</a></h3>
<p>デプロイの手順は，これまでのハンズオンとほとんど共通である． ここでは，コマンドのみ列挙する (<code>#</code> で始まる行はコメントである)． シークレットキーの設定も忘れずに (<a href="#aws_cli_install">AWS CLI のインストール</a>)．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390"># プロジェクトのディレクトリに移動</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cd</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">handson/serverless/s3</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># venv を作成し，依存ライブラリのインストールを行う</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python3</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-m</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">venv</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.env</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">source</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.env/bin/activate</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">pip</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">install</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-r</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">requirements.txt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># デプロイを実行</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cdk</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">deploy</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D"># プロジェクトのディレクトリに移動</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cd</span><span style="color: #24292E"> </span><span style="color: #032F62">handson/serverless/s3</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># venv を作成し，依存ライブラリのインストールを行う</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python3</span><span style="color: #24292E"> </span><span style="color: #005CC5">-m</span><span style="color: #24292E"> </span><span style="color: #032F62">venv</span><span style="color: #24292E"> </span><span style="color: #032F62">.env</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">source</span><span style="color: #24292E"> </span><span style="color: #032F62">.env/bin/activate</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">pip</span><span style="color: #24292E"> </span><span style="color: #032F62">install</span><span style="color: #24292E"> </span><span style="color: #005CC5">-r</span><span style="color: #24292E"> </span><span style="color: #032F62">requirements.txt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># デプロイを実行</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cdk</span><span style="color: #24292E"> </span><span style="color: #032F62">deploy</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br></div></div><p>デプロイを実行すると， <a href="#fig:s3_deploy_output">figure_title</a> のような出力が得られるはずである． ここで表示されている <code>SimpleS3.BucketName = XXXX</code> が，新しく作られたバケットの名前である (今回提供しているコードを使うとランダムな名前がバケットに割り当てられる）． これはあとで使うのでメモしておこう．</p>
<p><img src="./assets/handson-serverless/s3_deploy_output.png" alt="デプロイ実行後の出力"></p>
<h3 id="データの読み書き-1" tabindex="-1">データの読み書き <a class="header-anchor" href="#データの読み書き-1" aria-label="Permalink to &quot;データの読み書き&quot;">&ZeroWidthSpace;</a></h3>
<p>スタックのデプロイが完了したら，早速バケットにデータをアップロードしてみよう．</p>
<p>まずは，以下のコマンドを実行して， <code>tmp.txt</code> という仮のファイルを生成する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">echo</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;Hello world!&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">&gt;&gt;</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">tmp.txt</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">echo</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;Hello world!&quot;</span><span style="color: #24292E"> </span><span style="color: #D73A49">&gt;&gt;</span><span style="color: #24292E"> </span><span style="color: #032F62">tmp.txt</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>ハンズオンのディレクトリにある <a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/serverless/s3/simple_s3.py" target="_blank" rel="noreferrer">simple_s3.py</a> に <a href="https://boto3.amazonaws.com/v1/documentation/api/latest/index.html" target="_blank" rel="noreferrer">boto3</a> ライブラリを使用した S3 のファイルのアップロード・ダウンロードのスクリプトが書いてある． <code>simple_s3.py</code> を使って，上で作成した <code>tmp.txt</code> を以下のコマンドによりバケットにアップロードする． <code>XXXX</code> のところは，自分自身のバケットの名前で置き換えること．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">simple_s3.py</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">XXXX</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">upload</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">tmp.txt</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python</span><span style="color: #24292E"> </span><span style="color: #032F62">simple_s3.py</span><span style="color: #24292E"> </span><span style="color: #032F62">XXXX</span><span style="color: #24292E"> </span><span style="color: #032F62">upload</span><span style="color: #24292E"> </span><span style="color: #032F62">tmp.txt</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p><code>simple_s3.py</code> のアップロードを担当している部分を以下に抜粋する．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">def</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">upload_file</span><span style="color: #ADBAC7">(bucket_name, filename, key</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">None</span><span style="color: #ADBAC7">):</span></span>
<span class="line"><span style="color: #ADBAC7">    bucket </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> s3.Bucket(bucket_name)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> key </span><span style="color: #F47067">is</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">None</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">        key </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> os.path.basename(filename)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    bucket.upload_file(filename, key)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">def</span><span style="color: #24292E"> </span><span style="color: #6F42C1">upload_file</span><span style="color: #24292E">(bucket_name, filename, key</span><span style="color: #D73A49">=</span><span style="color: #005CC5">None</span><span style="color: #24292E">):</span></span>
<span class="line"><span style="color: #24292E">    bucket </span><span style="color: #D73A49">=</span><span style="color: #24292E"> s3.Bucket(bucket_name)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">if</span><span style="color: #24292E"> key </span><span style="color: #D73A49">is</span><span style="color: #24292E"> </span><span style="color: #005CC5">None</span><span style="color: #24292E">:</span></span>
<span class="line"><span style="color: #24292E">        key </span><span style="color: #D73A49">=</span><span style="color: #24292E"> os.path.basename(filename)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">    bucket.upload_file(filename, key)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br></div></div><p><code>bucket = s3.Bucket(bucket_name)</code> の行で <code>Bucket()</code> オブジェクトを呼び出している． そして， <code>upload_file()</code> メソッドを呼ぶことでファイルのアップロードを実行している．</p>
<p>S3 においてファイルの識別子として使われるのが <strong>Key</strong> である． これは，従来的なファイルシステムにおけるパス (Path) と相同な概念で，それぞれのファイルに固有な Key が割り当てられる必要がある． Key という呼び方は， S3 が <a href="https://en.wikipedia.org/wiki/Object_storage" target="_blank" rel="noreferrer">Object storage</a> と呼ばれるシステムに立脚していることに由来する． <code>--key</code> のオプションを追加して <code>simple_s3.py</code> を実行することで， Key を指定してアップロードを実行することができる．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">simple_s3.py</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">XXXX</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">upload</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">tmp.txt</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--key</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">a/b/tmp.txt</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python</span><span style="color: #24292E"> </span><span style="color: #032F62">simple_s3.py</span><span style="color: #24292E"> </span><span style="color: #032F62">XXXX</span><span style="color: #24292E"> </span><span style="color: #032F62">upload</span><span style="color: #24292E"> </span><span style="color: #032F62">tmp.txt</span><span style="color: #24292E"> </span><span style="color: #005CC5">--key</span><span style="color: #24292E"> </span><span style="color: #032F62">a/b/tmp.txt</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>ここではアップロードされたファイルに <code>a/b/tmp.txt</code> という Key を割り当てている．</p>
<p>ここまでコマンドを実行し終えたところで，一度 AWS コンソールに行き S3 の中身を確認してみよう． S3 のコンソールに行くと，バケットの一覧が見つかるはずである． その中から， <code>simples3-bucket</code> から始まるランダムな名前のついたバケットを探し，クリックする． するとバケットの中に含まれるファイルの一覧が表示される (<a href="#fig:s3_bucket_filelist">figure_title</a>)．</p>
<p><img src="./assets/handson-serverless/s3_bucket_filelist.png" alt="S3 バケットの中のファイル一覧"></p>
<p>ここで実行した 2 つのコマンドによって， <code>tmp.txt</code> というファイルと， <code>a/b/tmp.txt</code> というファイルが見つかることに注目しよう． 従来的なファイルシステムと似た体験を提供するため， S3 では Key が <strong>&quot;/&quot; (スラッシュ)</strong> によって区切られていた場合，<strong>ツリー状の階層構造</strong>によってファイルを管理することができる．</p>
<p>オブジェクトストレージには本来ディレクトリという概念はない． 上で紹介した &quot;/&quot; による階層づけはあくまでユーザー体験向上の目的のお化粧的な機能である．</p>
<p>次に，バケットからファイルのダウンロードを実行してみよう． <code>simple_s3.py</code> を使って，以下のコマンドを実行すればよい． <code>XXXX</code> のところは，自分自身のバケットの名前で置き換えること．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">simple_s3.py</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">XXXX</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">download</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">tmp.txt</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python</span><span style="color: #24292E"> </span><span style="color: #032F62">simple_s3.py</span><span style="color: #24292E"> </span><span style="color: #032F62">XXXX</span><span style="color: #24292E"> </span><span style="color: #032F62">download</span><span style="color: #24292E"> </span><span style="color: #032F62">tmp.txt</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p><code>simple_s3.py</code> のダウンロードを担当している部分を以下に抜粋する．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">def</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">download_file</span><span style="color: #ADBAC7">(bucket_name, key, filename</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">None</span><span style="color: #ADBAC7">):</span></span>
<span class="line"><span style="color: #ADBAC7">    bucket </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> s3.Bucket(bucket_name)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">if</span><span style="color: #ADBAC7"> filename </span><span style="color: #F47067">is</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">None</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">        filename </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> os.path.basename(key)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    bucket.download_file(key, filename)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">def</span><span style="color: #24292E"> </span><span style="color: #6F42C1">download_file</span><span style="color: #24292E">(bucket_name, key, filename</span><span style="color: #D73A49">=</span><span style="color: #005CC5">None</span><span style="color: #24292E">):</span></span>
<span class="line"><span style="color: #24292E">    bucket </span><span style="color: #D73A49">=</span><span style="color: #24292E"> s3.Bucket(bucket_name)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">if</span><span style="color: #24292E"> filename </span><span style="color: #D73A49">is</span><span style="color: #24292E"> </span><span style="color: #005CC5">None</span><span style="color: #24292E">:</span></span>
<span class="line"><span style="color: #24292E">        filename </span><span style="color: #D73A49">=</span><span style="color: #24292E"> os.path.basename(key)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">    bucket.download_file(key, filename)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br></div></div><p>S3 からのダウンロードはシンプルで， <code>download_file()</code> メソッドを使って，ダウンロードしたい対象の Key を指定すればよい． ローカルのコンピュータでの保存先のパスを 2 個目の引数として渡している．</p>
<h3 id="スタックの削除-5" tabindex="-1">スタックの削除 <a class="header-anchor" href="#スタックの削除-5" aria-label="Permalink to &quot;スタックの削除&quot;">&ZeroWidthSpace;</a></h3>
<p>以上のハンズオンで， S3 の一番基本的な使い方を紹介した． ここまでのハンズオンが理解できたら，忘れずにスタックを削除しよう． これまでのハンズオンと同様，スタックを削除するには，次のコマンドを実行すればよい．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cdk</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">destroy</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cdk</span><span style="color: #24292E"> </span><span style="color: #032F62">destroy</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><h1 id="hands-on-6-bashoutter" tabindex="-1">Hands-on #6: Bashoutter <a class="header-anchor" href="#hands-on-6-bashoutter" aria-label="Permalink to &quot;Hands-on \#6: Bashoutter&quot;">&ZeroWidthSpace;</a></h1>
<p>さて，最後のハンズオンとなる第六回では，これまで学んできたサーバーレスクラウドの技術を使って，簡単なウェブサービスを作ってみよう． 具体的には，人々が自分の作った俳句を投稿する SNS サービス (<strong>Bashoutter</strong> と名付ける) を作成してみよう． Lambda, DynamoDB, S3 などの技術をすべて盛り込み，シンプルながらもサーバーレスの利点を生かしたスケーラブルな SNS アプリが誕生する． 最終的には， <a href="#handson_05_bashoutter">figure_title</a> のような，ミニマルではあるがとても現代風な SNS サイトが完成する！</p>
<p><img src="./assets/handson-bashoutter/bashoutter.png" alt="ハンズオン#6で作製する SNS アプリケーション &quot;Bashoutter&quot;"></p>
<h2 id="準備-4" tabindex="-1">準備 <a class="header-anchor" href="#準備-4" aria-label="Permalink to &quot;準備&quot;">&ZeroWidthSpace;</a></h2>
<p>ハンズオンのソースコードは GitHub の <a href="https://github.com/andatoshiki/toshiki-notebooktree/main/handson/bashoutter" target="_blank" rel="noreferrer">handson/bashoutter</a> に置いてある．</p>
<p>本ハンズオンの実行には，第一回ハンズオンで説明した準備 (<a href="#handson_01_prep">準備</a>) が整っていることを前提とする． それ以外に必要な準備はない．</p>
<p>このハンズオンは，基本的に <a href="https://aws.amazon.com/free/?all-free-tier.sort-by=item.additionalFields.SortRank&amp;all-free-tier.sort-order=asc" target="_blank" rel="noreferrer">AWS の無料枠</a> の範囲内で実行できる．</p>
<h2 id="アプリケーションの説明-4" tabindex="-1">アプリケーションの説明 <a class="header-anchor" href="#アプリケーションの説明-4" aria-label="Permalink to &quot;アプリケーションの説明&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="api" tabindex="-1">API <a class="header-anchor" href="#api" aria-label="Permalink to &quot;API&quot;">&ZeroWidthSpace;</a></h3>
<p>今回のアプリケーションでは，人々からの俳句の投稿を受け付けたり，投稿された俳句の一覧を取得する，といった機能を実装したい． この機能を実現するための最小限の設計として， <a href="#tab_handson_05_api">table_title</a> に示すような四つの REST API を今回は実装する． 俳句を投稿する，閲覧する，削除するという基本的なデータ操作を行うための API が完備されている． また， <code>PATCH /haiku/{item_id}</code> は， <code>{item_id}</code> で指定された俳句に”いいね”をするために使用する．</p>
<table><caption>Bashoutter API</caption><colgroup><col style="width: 50%" /><col style="width: 50%" /></colgroup><tbody><tr class="odd"><td><p><code>GET /haiku</code></p></td><td><p>俳句の一覧を取得する</p></td></tr><tr class="even"><td><p><code>POST /haiku</code></p></td><td><p>新しい俳句を投稿する</p></td></tr><tr class="odd"><td><p><code>PATCH /haiku/{item_id}</code></p></td><td><p><code>{item_id}</code> で指定された俳句にお気に入り票を一つ入れる</p></td></tr><tr class="even"><td><p><code>DELETE /haiku/{item_id}</code></p></td><td><p><code>{item_id}</code> で指定された俳句を削除する</p></td></tr></tbody></table>
<p>それぞれの API のパラメータおよび返り値の詳細は，ハンズオンのソースコードの中の <a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/bashoutter/specs/swagger.yml" target="_blank" rel="noreferrer">swagger.yml</a> に定義してある．</p>
<p><strong>Open API Specification</strong> (OAS; 少し前は Swagger Specification とよばれていた) は， REST API のための記述フォーマットである． OAS に従って API の仕様が記述されていると，簡単にドキュメンテーションを生成したり，クライアントアプリケーションを自動生成することができる． <a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/bashoutter/specs/swagger.yml" target="_blank" rel="noreferrer">今回用意した API 仕様</a> も， OAS に従って書いてある． 詳しくは <a href="https://swagger.io/docs/specification/about/" target="_blank" rel="noreferrer">Swagger の公式ドキュメンテーション</a> などを参照．</p>
<h3 id="アプリケーションアーキテクチャ" tabindex="-1">アプリケーションアーキテクチャ <a class="header-anchor" href="#アプリケーションアーキテクチャ" aria-label="Permalink to &quot;アプリケーションアーキテクチャ&quot;">&ZeroWidthSpace;</a></h3>
<p>このハンズオンで作成するアプリケーションの概要を <a href="#handson_05_architecture">figure_title</a> に示す．</p>
<p><img src="./assets/handson-bashoutter/handson-05-architecture.png" alt="ハンズオン#5で作製するアプリケーションのアーキテクチャ"></p>
<p>簡単にまとめると，次のような設計である．</p>
<ul>
<li>
<p>クライアントからの API リクエストは， <strong>API Gateway</strong> (後述)にまず送信され， API の URI で指定された Lambda 関数へ転送される．</p>
</li>
<li>
<p>それぞれの API のパス (リソース) ごとに独立した Lambda を用意する．</p>
</li>
<li>
<p>俳句の情報 (作者，本文，投稿日時など) を記録するためのデータベース (DynamoDB) を用意する．</p>
</li>
<li>
<p>各 Lambda 関数には， DynamoDB へのアクセス権を付与する．</p>
</li>
<li>
<p>最後に，ウェブブラウザからコンテンツを表示できるよう， ウェブページの静的コンテンツを配信するための S3 バケットを用意する．クライアントはこの S3 バケットにアクセスすることで HTML/CSS/JS などのコンテンツを取得する．</p>
</li>
</ul>
<p>それでは，プログラムのソースコードを見てみよう (<a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/bashoutter/app.py" target="_blank" rel="noreferrer">handson/bashoutter/app.py</a>)．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">class</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50">Bashoutter</span><span style="color: #ADBAC7">(</span><span style="color: #6CB6FF">core</span><span style="color: #ADBAC7">.</span><span style="color: #6CB6FF">Stack</span><span style="color: #ADBAC7">):</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">def</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">__init__</span><span style="color: #ADBAC7">(self, scope: core.App, name: </span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">, </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">kwargs) -&gt; </span><span style="color: #6CB6FF">None</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #6CB6FF">super</span><span style="color: #ADBAC7">().</span><span style="color: #6CB6FF">__init__</span><span style="color: #ADBAC7">(scope, name, </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">kwargs)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390"># dynamoDB table to store haiku</span></span>
<span class="line"><span style="color: #ADBAC7">        table </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ddb.Table(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;Bashoutter-Table&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">partition_key</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ddb.Attribute(</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">name</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;item_id&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">type</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ddb.AttributeType.</span><span style="color: #6CB6FF">STRING</span></span>
<span class="line"><span style="color: #ADBAC7">            ),</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">billing_mode</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">ddb.BillingMode.</span><span style="color: #6CB6FF">PAY_PER_REQUEST</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">removal_policy</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">core.RemovalPolicy.</span><span style="color: #6CB6FF">DESTROY</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        bucket </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> s3.Bucket(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;Bashoutter-Bucket&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">website_index_document</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;index.html&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">public_read_access</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">True</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">removal_policy</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">core.RemovalPolicy.</span><span style="color: #6CB6FF">DESTROY</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        common_params </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> {</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #96D0FF">&quot;runtime&quot;</span><span style="color: #ADBAC7">: _lambda.Runtime.</span><span style="color: #6CB6FF">PYTHON_3_7</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #96D0FF">&quot;environment&quot;</span><span style="color: #ADBAC7">: {</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #96D0FF">&quot;TABLE_NAME&quot;</span><span style="color: #ADBAC7">: table.table_name</span></span>
<span class="line"><span style="color: #ADBAC7">            }</span></span>
<span class="line"><span style="color: #ADBAC7">        }</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390"># define Lambda functions</span></span>
<span class="line"><span style="color: #ADBAC7">        get_haiku_lambda </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> _lambda.Function(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;GetHaiku&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">code</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">_lambda.Code.from_asset(</span><span style="color: #96D0FF">&quot;api&quot;</span><span style="color: #ADBAC7">),</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">handler</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;api.get_haiku&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">memory_size</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">512</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">common_params,</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"><span style="color: #ADBAC7">        post_haiku_lambda </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> _lambda.Function(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;PostHaiku&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">code</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">_lambda.Code.from_asset(</span><span style="color: #96D0FF">&quot;api&quot;</span><span style="color: #ADBAC7">),</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">handler</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;api.post_haiku&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">common_params,</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"><span style="color: #ADBAC7">        patch_haiku_lambda </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> _lambda.Function(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;PatchHaiku&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">code</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">_lambda.Code.from_asset(</span><span style="color: #96D0FF">&quot;api&quot;</span><span style="color: #ADBAC7">),</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">handler</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;api.patch_haiku&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">common_params,</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"><span style="color: #ADBAC7">        delete_haiku_lambda </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> _lambda.Function(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;DeleteHaiku&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">code</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">_lambda.Code.from_asset(</span><span style="color: #96D0FF">&quot;api&quot;</span><span style="color: #ADBAC7">),</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">handler</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;api.delete_haiku&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">common_params,</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390"># grant permissions</span></span>
<span class="line"><span style="color: #ADBAC7">        table.grant_read_data(get_haiku_lambda)</span></span>
<span class="line"><span style="color: #ADBAC7">        table.grant_read_write_data(post_haiku_lambda)</span></span>
<span class="line"><span style="color: #ADBAC7">        table.grant_read_write_data(patch_haiku_lambda)</span></span>
<span class="line"><span style="color: #ADBAC7">        table.grant_read_write_data(delete_haiku_lambda)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #768390"># define API Gateway</span></span>
<span class="line"><span style="color: #ADBAC7">        api </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> apigw.RestApi(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;BashoutterApi&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #F69D50">default_cors_preflight_options</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">apigw.CorsOptions(</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">allow_origins</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">apigw.Cors.</span><span style="color: #6CB6FF">ALL_ORIGINS</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">                </span><span style="color: #F69D50">allow_methods</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">apigw.Cors.</span><span style="color: #6CB6FF">ALL_METHODS</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            )</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        haiku </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> api.root.add_resource(</span><span style="color: #96D0FF">&quot;haiku&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">        haiku.add_method(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #96D0FF">&quot;GET&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            apigw.LambdaIntegration(get_haiku_lambda)</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"><span style="color: #ADBAC7">        haiku.add_method(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #96D0FF">&quot;POST&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            apigw.LambdaIntegration(post_haiku_lambda)</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        haiku_item_id </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> haiku.add_resource(</span><span style="color: #96D0FF">&quot;</span><span style="color: #F47067">{item_id}</span><span style="color: #96D0FF">&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">        haiku_item_id.add_method(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #96D0FF">&quot;PATCH&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            apigw.LambdaIntegration(patch_haiku_lambda)</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span>
<span class="line"><span style="color: #ADBAC7">        haiku_item_id.add_method(</span></span>
<span class="line"><span style="color: #ADBAC7">            </span><span style="color: #96D0FF">&quot;DELETE&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">            apigw.LambdaIntegration(delete_haiku_lambda)</span></span>
<span class="line"><span style="color: #ADBAC7">        )</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">class</span><span style="color: #24292E"> </span><span style="color: #6F42C1">Bashoutter</span><span style="color: #24292E">(</span><span style="color: #6F42C1">core</span><span style="color: #24292E">.</span><span style="color: #6F42C1">Stack</span><span style="color: #24292E">):</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">def</span><span style="color: #24292E"> </span><span style="color: #005CC5">__init__</span><span style="color: #24292E">(self, scope: core.App, name: </span><span style="color: #005CC5">str</span><span style="color: #24292E">, </span><span style="color: #D73A49">**</span><span style="color: #24292E">kwargs) -&gt; </span><span style="color: #005CC5">None</span><span style="color: #24292E">:</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #005CC5">super</span><span style="color: #24292E">().</span><span style="color: #005CC5">__init__</span><span style="color: #24292E">(scope, name, </span><span style="color: #D73A49">**</span><span style="color: #24292E">kwargs)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D"># dynamoDB table to store haiku</span></span>
<span class="line"><span style="color: #24292E">        table </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ddb.Table(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;Bashoutter-Table&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">partition_key</span><span style="color: #D73A49">=</span><span style="color: #24292E">ddb.Attribute(</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">name</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;item_id&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">type</span><span style="color: #D73A49">=</span><span style="color: #24292E">ddb.AttributeType.</span><span style="color: #005CC5">STRING</span></span>
<span class="line"><span style="color: #24292E">            ),</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">billing_mode</span><span style="color: #D73A49">=</span><span style="color: #24292E">ddb.BillingMode.</span><span style="color: #005CC5">PAY_PER_REQUEST</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">removal_policy</span><span style="color: #D73A49">=</span><span style="color: #24292E">core.RemovalPolicy.</span><span style="color: #005CC5">DESTROY</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        bucket </span><span style="color: #D73A49">=</span><span style="color: #24292E"> s3.Bucket(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;Bashoutter-Bucket&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">website_index_document</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;index.html&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">public_read_access</span><span style="color: #D73A49">=</span><span style="color: #005CC5">True</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">removal_policy</span><span style="color: #D73A49">=</span><span style="color: #24292E">core.RemovalPolicy.</span><span style="color: #005CC5">DESTROY</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        common_params </span><span style="color: #D73A49">=</span><span style="color: #24292E"> {</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #032F62">&quot;runtime&quot;</span><span style="color: #24292E">: _lambda.Runtime.</span><span style="color: #005CC5">PYTHON_3_7</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #032F62">&quot;environment&quot;</span><span style="color: #24292E">: {</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #032F62">&quot;TABLE_NAME&quot;</span><span style="color: #24292E">: table.table_name</span></span>
<span class="line"><span style="color: #24292E">            }</span></span>
<span class="line"><span style="color: #24292E">        }</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D"># define Lambda functions</span></span>
<span class="line"><span style="color: #24292E">        get_haiku_lambda </span><span style="color: #D73A49">=</span><span style="color: #24292E"> _lambda.Function(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;GetHaiku&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">code</span><span style="color: #D73A49">=</span><span style="color: #24292E">_lambda.Code.from_asset(</span><span style="color: #032F62">&quot;api&quot;</span><span style="color: #24292E">),</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">handler</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;api.get_haiku&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">memory_size</span><span style="color: #D73A49">=</span><span style="color: #005CC5">512</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #D73A49">**</span><span style="color: #24292E">common_params,</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"><span style="color: #24292E">        post_haiku_lambda </span><span style="color: #D73A49">=</span><span style="color: #24292E"> _lambda.Function(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;PostHaiku&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">code</span><span style="color: #D73A49">=</span><span style="color: #24292E">_lambda.Code.from_asset(</span><span style="color: #032F62">&quot;api&quot;</span><span style="color: #24292E">),</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">handler</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;api.post_haiku&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #D73A49">**</span><span style="color: #24292E">common_params,</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"><span style="color: #24292E">        patch_haiku_lambda </span><span style="color: #D73A49">=</span><span style="color: #24292E"> _lambda.Function(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;PatchHaiku&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">code</span><span style="color: #D73A49">=</span><span style="color: #24292E">_lambda.Code.from_asset(</span><span style="color: #032F62">&quot;api&quot;</span><span style="color: #24292E">),</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">handler</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;api.patch_haiku&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #D73A49">**</span><span style="color: #24292E">common_params,</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"><span style="color: #24292E">        delete_haiku_lambda </span><span style="color: #D73A49">=</span><span style="color: #24292E"> _lambda.Function(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;DeleteHaiku&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">code</span><span style="color: #D73A49">=</span><span style="color: #24292E">_lambda.Code.from_asset(</span><span style="color: #032F62">&quot;api&quot;</span><span style="color: #24292E">),</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">handler</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;api.delete_haiku&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #D73A49">**</span><span style="color: #24292E">common_params,</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D"># grant permissions</span></span>
<span class="line"><span style="color: #24292E">        table.grant_read_data(get_haiku_lambda)</span></span>
<span class="line"><span style="color: #24292E">        table.grant_read_write_data(post_haiku_lambda)</span></span>
<span class="line"><span style="color: #24292E">        table.grant_read_write_data(patch_haiku_lambda)</span></span>
<span class="line"><span style="color: #24292E">        table.grant_read_write_data(delete_haiku_lambda)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #6A737D"># define API Gateway</span></span>
<span class="line"><span style="color: #24292E">        api </span><span style="color: #D73A49">=</span><span style="color: #24292E"> apigw.RestApi(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;BashoutterApi&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #E36209">default_cors_preflight_options</span><span style="color: #D73A49">=</span><span style="color: #24292E">apigw.CorsOptions(</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">allow_origins</span><span style="color: #D73A49">=</span><span style="color: #24292E">apigw.Cors.</span><span style="color: #005CC5">ALL_ORIGINS</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">                </span><span style="color: #E36209">allow_methods</span><span style="color: #D73A49">=</span><span style="color: #24292E">apigw.Cors.</span><span style="color: #005CC5">ALL_METHODS</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            )</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        haiku </span><span style="color: #D73A49">=</span><span style="color: #24292E"> api.root.add_resource(</span><span style="color: #032F62">&quot;haiku&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">        haiku.add_method(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #032F62">&quot;GET&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            apigw.LambdaIntegration(get_haiku_lambda)</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"><span style="color: #24292E">        haiku.add_method(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #032F62">&quot;POST&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            apigw.LambdaIntegration(post_haiku_lambda)</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        haiku_item_id </span><span style="color: #D73A49">=</span><span style="color: #24292E"> haiku.add_resource(</span><span style="color: #032F62">&quot;</span><span style="color: #005CC5">{item_id}</span><span style="color: #032F62">&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">        haiku_item_id.add_method(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #032F62">&quot;PATCH&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            apigw.LambdaIntegration(patch_haiku_lambda)</span></span>
<span class="line"><span style="color: #24292E">        )</span></span>
<span class="line"><span style="color: #24292E">        haiku_item_id.add_method(</span></span>
<span class="line"><span style="color: #24292E">            </span><span style="color: #032F62">&quot;DELETE&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">            apigw.LambdaIntegration(delete_haiku_lambda)</span></span>
<span class="line"><span style="color: #24292E">        )</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br><span class="line-number">36</span><br><span class="line-number">37</span><br><span class="line-number">38</span><br><span class="line-number">39</span><br><span class="line-number">40</span><br><span class="line-number">41</span><br><span class="line-number">42</span><br><span class="line-number">43</span><br><span class="line-number">44</span><br><span class="line-number">45</span><br><span class="line-number">46</span><br><span class="line-number">47</span><br><span class="line-number">48</span><br><span class="line-number">49</span><br><span class="line-number">50</span><br><span class="line-number">51</span><br><span class="line-number">52</span><br><span class="line-number">53</span><br><span class="line-number">54</span><br><span class="line-number">55</span><br><span class="line-number">56</span><br><span class="line-number">57</span><br><span class="line-number">58</span><br><span class="line-number">59</span><br><span class="line-number">60</span><br><span class="line-number">61</span><br><span class="line-number">62</span><br><span class="line-number">63</span><br><span class="line-number">64</span><br><span class="line-number">65</span><br><span class="line-number">66</span><br><span class="line-number">67</span><br><span class="line-number">68</span><br><span class="line-number">69</span><br><span class="line-number">70</span><br><span class="line-number">71</span><br><span class="line-number">72</span><br><span class="line-number">73</span><br><span class="line-number">74</span><br><span class="line-number">75</span><br><span class="line-number">76</span><br><span class="line-number">77</span><br><span class="line-number">78</span><br><span class="line-number">79</span><br><span class="line-number">80</span><br><span class="line-number">81</span><br><span class="line-number">82</span><br><span class="line-number">83</span><br><span class="line-number">84</span><br><span class="line-number">85</span><br><span class="line-number">86</span><br><span class="line-number">87</span><br><span class="line-number">88</span><br><span class="line-number">89</span><br><span class="line-number">90</span><br><span class="line-number">91</span><br><span class="line-number">92</span><br><span class="line-number">93</span><br><span class="line-number">94</span><br><span class="line-number">95</span><br><span class="line-number">96</span><br></div></div><ul>
<li>
<p>ここで，俳句の情報を記録しておくための DynamoDB テーブルを定義している．</p>
</li>
<li>
<p>静的コンテンツを配信するための S3 バケットを用意している．</p>
</li>
<li>
<p>それぞれの API で実行される Lambda 関数を定義している． 関数は Python3.7 で書かれており，コードは <a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/bashoutter/api/api.py" target="_blank" rel="noreferrer">handson/bashoutter/api/api.py</a> にある．</p>
</li>
<li>
<p>&lt;3&gt; で定義された Lambda 関数に対し，データベースへの読み書きのアクセス権限を付与している．</p>
</li>
<li>
<p>ここで，API Gateway により，各 API パスとそこで実行されるべき Lambda 関数を紐付けている．</p>
</li>
</ul>
<p>それぞれの項目について，もう少し詳しく説明しよう．</p>
<h3 id="public-access-mode-の-s3-バケット" tabindex="-1">Public access mode の S3 バケット <a class="header-anchor" href="#public-access-mode-の-s3-バケット" aria-label="Permalink to &quot;Public access mode の S3 バケット&quot;">&ZeroWidthSpace;</a></h3>
<p>S3 のバケットを作成しているコードを見てみよう．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">bucket </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> s3.Bucket(</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;Bashoutter-Bucket&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">website_index_document</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;index.html&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">public_read_access</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">True</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">removal_policy</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">core.RemovalPolicy.</span><span style="color: #6CB6FF">DESTROY</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">bucket </span><span style="color: #D73A49">=</span><span style="color: #24292E"> s3.Bucket(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;Bashoutter-Bucket&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">website_index_document</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;index.html&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">public_read_access</span><span style="color: #D73A49">=</span><span style="color: #005CC5">True</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">removal_policy</span><span style="color: #D73A49">=</span><span style="color: #24292E">core.RemovalPolicy.</span><span style="color: #005CC5">DESTROY</span></span>
<span class="line"><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br></div></div><p>ここで注目してほしいのは <code>public_read_access=True</code> の部分だ． 前章で， S3 について説明を行ったときには触れなかったが， S3 には <strong>Public access mode</strong> という機能がある． Public access mode をオンにしておくと，バケットの中のファイルは認証なしで (i.e. インターネット上の誰でも) 閲覧できるようになる． この設定は，一般公開されているウェブサイトの静的なコンテンツを置いておくのに最適であり，多くのサーバーレスによるウェブサービスでこのような設計が行われる． public access mode を設定しておくと， <code>http://XXXX.s3-website-ap-northeast-1.amazonaws.com/</code> のような固有の URL がバケットに対して付与される． そして，クライアントがこの URL にアクセスをすると，バケットの中にある <code>index.html</code> がクライアントに返され，ページがロードされる (どのファイルが返されるかは， <code>website_index_document=&quot;index.html&quot;</code> の部分で設定している．)</p>
<p>なお，この時点ではバケットは空である． HTML/CSS/JS など静的コンテンツの配置は，デプロイを行った後ほどのステップで行う．</p>
<p>より本格的なウェブページを運用する際には， public access mode の S3 バケットに， <a href="https://aws.amazon.com/cloudfront/" target="_blank" rel="noreferrer">CloudFront</a> という機能を追加することが一般的である． CloudFront により，　<strong>Content Delivery Nework (CDN)</strong> や暗号化された HTTPS 通信を設定することができる． CloudFront についての詳細は <a href="https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Introduction.html" target="_blank" rel="noreferrer">公式ドキュメンテーション &quot;What is Amazon CloudFront?&quot;</a> などを参照いただきたい．</p>
<p>今回のハンズオンでは説明の簡略化のため CloudFront の設定を行わなかったが，興味のある読者は次のリンクのプログラムが参考になるだろう．</p>
<ul>
<li><a href="https://github.com/aws-samples/aws-cdk-examples/tree/master/typescript/static-site" target="_blank" rel="noreferrer">https://github.com/aws-samples/aws-cdk-examples/tree/master/typescript/static-site</a></li>
</ul>
<p>今回の S3 バケットには， AWS によって付与されたランダムな URL がついている． これを． <code>example.com</code> のような自分のドメインでホストしたければ， AWS によって付与された URL を自分のドメインの DNS レコードに追加すればよい．</p>
<h3 id="api-のハンドラ関数" tabindex="-1">API のハンドラ関数 <a class="header-anchor" href="#api-のハンドラ関数" aria-label="Permalink to &quot;API のハンドラ関数&quot;">&ZeroWidthSpace;</a></h3>
<p>API リクエストが来たときに，リクエストされた処理を行う関数のことをハンドラ (handler) 関数とよぶ． <code>GET /haiku</code> の API に対してのハンドラ関数を Lambda で定義している部分を見てみよう．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">get_haiku_lambda </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> _lambda.Function(</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;GetHaiku&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">code</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">_lambda.Code.from_asset(</span><span style="color: #96D0FF">&quot;api&quot;</span><span style="color: #ADBAC7">),</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">handler</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;api.get_haiku&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">memory_size</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">512</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">**</span><span style="color: #ADBAC7">common_params</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">get_haiku_lambda </span><span style="color: #D73A49">=</span><span style="color: #24292E"> _lambda.Function(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;GetHaiku&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">code</span><span style="color: #D73A49">=</span><span style="color: #24292E">_lambda.Code.from_asset(</span><span style="color: #032F62">&quot;api&quot;</span><span style="color: #24292E">),</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">handler</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;api.get_haiku&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">memory_size</span><span style="color: #D73A49">=</span><span style="color: #005CC5">512</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">**</span><span style="color: #24292E">common_params</span></span>
<span class="line"><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br></div></div><p>簡単なところから見ていくと， <code>memory_size=512</code> の箇所でメモリーの使用量を 512MB に指定している． また， <code>code=_lambda.Code.from_asset(&quot;api&quot;)</code> によって外部のディレクトリ (<code>api/</code>) を参照せよと指定しており， <code>handler=&quot;api.get_haiku&quot;</code> のところで <code>api.py</code> というファイルの <code>get_haiku()</code> という関数をハンドラ関数として実行せよ，と定義している．</p>
<p>次に，ハンドラ関数として使用されている <code>get_haiku()</code> のコードを見てみよう (<a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/bashoutter/api/api.py" target="_blank" rel="noreferrer">handson/bashoutter/api/api.py</a>)．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">ddb </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> boto3.resource(</span><span style="color: #96D0FF">&quot;dynamodb&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">table </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> ddb.Table(os.environ[</span><span style="color: #96D0FF">&quot;TABLE_NAME&quot;</span><span style="color: #ADBAC7">])</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F47067">def</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">get_haiku</span><span style="color: #ADBAC7">(event, context):</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #96D0FF">&quot;&quot;&quot;</span></span>
<span class="line"><span style="color: #96D0FF">    handler for GET /haiku</span></span>
<span class="line"><span style="color: #96D0FF">    &quot;&quot;&quot;</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">try</span><span style="color: #ADBAC7">:</span></span>
<span class="line"><span style="color: #ADBAC7">        response </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> table.scan()</span></span>
<span class="line"></span>
<span class="line"><span style="color: #ADBAC7">        status_code </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">200</span></span>
<span class="line"><span style="color: #ADBAC7">        resp </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> response.get(</span><span style="color: #96D0FF">&quot;Items&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">except</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">Exception</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">as</span><span style="color: #ADBAC7"> e:</span></span>
<span class="line"><span style="color: #ADBAC7">        status_code </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">500</span></span>
<span class="line"><span style="color: #ADBAC7">        resp </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> {</span><span style="color: #96D0FF">&quot;description&quot;</span><span style="color: #ADBAC7">: </span><span style="color: #F47067">f</span><span style="color: #96D0FF">&quot;Internal server error. </span><span style="color: #F47067">{</span><span style="color: #6CB6FF">str</span><span style="color: #ADBAC7">(e)</span><span style="color: #F47067">}</span><span style="color: #96D0FF">&quot;</span><span style="color: #ADBAC7">}</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">return</span><span style="color: #ADBAC7"> {</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #96D0FF">&quot;statusCode&quot;</span><span style="color: #ADBAC7">: status_code,</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #96D0FF">&quot;headers&quot;</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">HEADERS</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #96D0FF">&quot;body&quot;</span><span style="color: #ADBAC7">: json.dumps(resp, </span><span style="color: #F69D50">cls</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">DecimalEncoder)</span></span>
<span class="line"><span style="color: #ADBAC7">    }</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">ddb </span><span style="color: #D73A49">=</span><span style="color: #24292E"> boto3.resource(</span><span style="color: #032F62">&quot;dynamodb&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">table </span><span style="color: #D73A49">=</span><span style="color: #24292E"> ddb.Table(os.environ[</span><span style="color: #032F62">&quot;TABLE_NAME&quot;</span><span style="color: #24292E">])</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D73A49">def</span><span style="color: #24292E"> </span><span style="color: #6F42C1">get_haiku</span><span style="color: #24292E">(event, context):</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #032F62">&quot;&quot;&quot;</span></span>
<span class="line"><span style="color: #032F62">    handler for GET /haiku</span></span>
<span class="line"><span style="color: #032F62">    &quot;&quot;&quot;</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">try</span><span style="color: #24292E">:</span></span>
<span class="line"><span style="color: #24292E">        response </span><span style="color: #D73A49">=</span><span style="color: #24292E"> table.scan()</span></span>
<span class="line"></span>
<span class="line"><span style="color: #24292E">        status_code </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #005CC5">200</span></span>
<span class="line"><span style="color: #24292E">        resp </span><span style="color: #D73A49">=</span><span style="color: #24292E"> response.get(</span><span style="color: #032F62">&quot;Items&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">except</span><span style="color: #24292E"> </span><span style="color: #005CC5">Exception</span><span style="color: #24292E"> </span><span style="color: #D73A49">as</span><span style="color: #24292E"> e:</span></span>
<span class="line"><span style="color: #24292E">        status_code </span><span style="color: #D73A49">=</span><span style="color: #24292E"> </span><span style="color: #005CC5">500</span></span>
<span class="line"><span style="color: #24292E">        resp </span><span style="color: #D73A49">=</span><span style="color: #24292E"> {</span><span style="color: #032F62">&quot;description&quot;</span><span style="color: #24292E">: </span><span style="color: #D73A49">f</span><span style="color: #032F62">&quot;Internal server error. </span><span style="color: #005CC5">{str</span><span style="color: #24292E">(e)</span><span style="color: #005CC5">}</span><span style="color: #032F62">&quot;</span><span style="color: #24292E">}</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">return</span><span style="color: #24292E"> {</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #032F62">&quot;statusCode&quot;</span><span style="color: #24292E">: status_code,</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #032F62">&quot;headers&quot;</span><span style="color: #24292E">: </span><span style="color: #005CC5">HEADERS</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #032F62">&quot;body&quot;</span><span style="color: #24292E">: json.dumps(resp, </span><span style="color: #E36209">cls</span><span style="color: #D73A49">=</span><span style="color: #24292E">DecimalEncoder)</span></span>
<span class="line"><span style="color: #24292E">    }</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br></div></div><p><code>response = table.scan()</code> で，俳句の格納された DynamoDB テーブルから，すべての要素を取り出している． もしなにもエラーが起きなければステータスコード 200 が返され，もしなにかエラーが起こればステータスコード 500 が返されるようになっている．</p>
<p>上記のような操作を，ほかの API についても繰り返すことで，すべての API のハンドラ関数が定義されている．</p>
<p><code>GET /haiku</code> のハンドラ関数で， <code>response = table.scan()</code> という部分があるが，実はこれは最善の書き方ではない． DynamoDB の <code>scan()</code> メソッドは，最大で 1MB までのデータしか返さない． データベースのサイズが大きく， 1MB 以上のデータがある場合には，再帰的に <code>scan()</code> メソッドをよぶ必要がある． 詳しくは <a href="https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/dynamodb.html#DynamoDB.Table.scan" target="_blank" rel="noreferrer">boto3 ドキュメンテーション</a> を参照．</p>
<h3 id="aws-における権限の管理-iam" tabindex="-1">AWS における権限の管理 (IAM) <a class="header-anchor" href="#aws-における権限の管理-iam" aria-label="Permalink to &quot;AWS における権限の管理 (IAM)&quot;">&ZeroWidthSpace;</a></h3>
<p>以下の部分のコードに注目してほしい．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">table.grant_read_data(get_haiku_lambda)</span></span>
<span class="line"><span style="color: #ADBAC7">table.grant_read_write_data(post_haiku_lambda)</span></span>
<span class="line"><span style="color: #ADBAC7">table.grant_read_write_data(patch_haiku_lambda)</span></span>
<span class="line"><span style="color: #ADBAC7">table.grant_read_write_data(delete_haiku_lambda)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">table.grant_read_data(get_haiku_lambda)</span></span>
<span class="line"><span style="color: #24292E">table.grant_read_write_data(post_haiku_lambda)</span></span>
<span class="line"><span style="color: #24292E">table.grant_read_write_data(patch_haiku_lambda)</span></span>
<span class="line"><span style="color: #24292E">table.grant_read_write_data(delete_haiku_lambda)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br></div></div><p>これまでは説明の簡略化のためにあえて触れてこなかったが， AWS には <a href="https://aws.amazon.com/iam/" target="_blank" rel="noreferrer">IAM (Identity and Access Management)</a> という重要な概念がある． IAM は基本的に，あるリソースがほかのリソースに対してどのような権限をもっているか，を規定するものである． Lambda は，デフォルトの状態ではほかのリソースにアクセスする権限をなにも有していない． したがって， Lambda 関数が DynamoDB のデータを読み書きするためには，それを許可するような IAM が Lambda 関数に付与されていなければならない．</p>
<p>CDK による <code>dynamodb.Table</code> オブジェクトには <code>grant_read_write_data()</code> という便利なメソッドが備わっており，アクセスを許可したい Lambda 関数を引数としてこのメソッドを呼ぶことで，データベースへの読み書きを許可する IAM を付与することができる． 同様に，CDK の <code>s3.Bucket</code> オブジェクトにも <code>grant_read_write()</code> というメソッドが備わっており，これによってバケットへの読み書きを許可することができる． このメソッドは，実は <a href="#sec_aws_batch">Hands-on #4: AWS Batch を使って機械学習のハイパーパラメータサーチを並列化する</a> で AWS Batch によるクラスターを構成した際に使用した． 興味のある読者は振り返ってコードを確認してみよう．</p>
<p>各リソースに付与する IAM は，<strong>必要最低限の権限を与えるにとどめる</strong>というのが基本方針である． これにより，セキュリティを向上させるだけでなく，意図していないプログラムからのデータベースへの読み書きを防止するという点で，バグを未然に防ぐことができる．</p>
<p>そのような理由により，このコードでは <code>GET</code> のハンドラー関数に対しては <code>grant_read_data()</code> によって， read 権限のみを付与している．</p>
<h3 id="api-gateway" tabindex="-1">API Gateway <a class="header-anchor" href="#api-gateway" aria-label="Permalink to &quot;API Gateway&quot;">&ZeroWidthSpace;</a></h3>
<p><a href="https://aws.amazon.com/api-gateway/" target="_blank" rel="noreferrer">API Gateway</a> とは， API の&quot;入り口&quot;として，API のリクエストパスに従って Lambda や EC2 などに接続を行うという機能を担う (<a href="#fig:bashoutter_api_gateway">figure_title</a>)． Lambda や EC2 によって行われた処理の結果は，再び API Gateway を経由してクライアントに返される． このように，クライアントとバックエンドサーバーの間に立ち， API のリソースパスに応じて接続先を振り分けるようなサーバーを<strong>ルーター</strong>，あるいは<strong>リバースプロキシ</strong>とよんだりする． 従来的には，ルーターにはそれ専用の仮想サーバーが置かれることが一般的であった． しかし， API Gateway はサーバーレスなルーターとして，固定されたサーバーを配置することなく， API のリクエストが来たときのみ起動し，API のルーティングを実行する． サーバーレスであることの当然の帰結として，アクセスの件数が増大したときにはそれにルーティングの処理能力を自動で増やす機能も備わっている．</p>
<p><img src="./assets/handson-bashoutter/api_gateway.png" alt="API Gateway"></p>
<p>API Gateway を配置することで，大量 (1 秒間に数千から数万件) の API リクエストに対応することのできるシステムを容易に構築することができる． API Gateway の料金は <a href="#tab_handson_05_apigateway_price">table_title</a> のように設定されている． また，無料利用枠により，月ごとに 100 万件までのリクエストは 0 円で利用できる．</p>
<table><caption>API Gateway の利用料金設定 (<a href="https://aws.amazon.com/api-gateway/pricing/">参照</a>)</caption><colgroup><col style="width: 50%" /><col style="width: 50%" /></colgroup><thead><tr class="header"><th>Number of Requests (per month)</th><th>Price (per million)</th></tr></thead><tbody><tr class="odd"><td><p>First 333 million</p></td><td><p>$4.25</p></td></tr><tr class="even"><td><p>Next 667 million</p></td><td><p>$3.53</p></td></tr><tr class="odd"><td><p>Next 19 billion</p></td><td><p>$3.00</p></td></tr><tr class="even"><td><p>Over 20 billion</p></td><td><p>$1.91</p></td></tr></tbody></table>
<p>ソースコードの該当箇所を見てみよう．</p>
<div class="language-python vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">api </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> apigw.RestApi(</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">self</span><span style="color: #ADBAC7">, </span><span style="color: #96D0FF">&quot;BashoutterApi&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">default_cors_preflight_options</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">apigw.CorsOptions(</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #F69D50">allow_origins</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">apigw.Cors.</span><span style="color: #6CB6FF">ALL_ORIGINS</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #F69D50">allow_methods</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">apigw.Cors.</span><span style="color: #6CB6FF">ALL_METHODS</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    )</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">haiku </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> api.root.add_resource(</span><span style="color: #96D0FF">&quot;haiku&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">haiku.add_method(</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #96D0FF">&quot;GET&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    apigw.LambdaIntegration(get_haiku_lambda)</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">haiku.add_method(</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #96D0FF">&quot;POST&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    apigw.LambdaIntegration(post_haiku_lambda)</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">haiku_item_id </span><span style="color: #F47067">=</span><span style="color: #ADBAC7"> haiku.add_resource(</span><span style="color: #96D0FF">&quot;</span><span style="color: #F47067">{item_id}</span><span style="color: #96D0FF">&quot;</span><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #768390">#</span></span>
<span class="line"><span style="color: #ADBAC7">haiku_item_id.add_method(</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #96D0FF">&quot;PATCH&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    apigw.LambdaIntegration(patch_haiku_lambda)</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span>
<span class="line"><span style="color: #ADBAC7">haiku_item_id.add_method(</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #96D0FF">&quot;DELETE&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">    apigw.LambdaIntegration(delete_haiku_lambda)</span></span>
<span class="line"><span style="color: #ADBAC7">)</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">api </span><span style="color: #D73A49">=</span><span style="color: #24292E"> apigw.RestApi(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">self</span><span style="color: #24292E">, </span><span style="color: #032F62">&quot;BashoutterApi&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #E36209">default_cors_preflight_options</span><span style="color: #D73A49">=</span><span style="color: #24292E">apigw.CorsOptions(</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #E36209">allow_origins</span><span style="color: #D73A49">=</span><span style="color: #24292E">apigw.Cors.</span><span style="color: #005CC5">ALL_ORIGINS</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #E36209">allow_methods</span><span style="color: #D73A49">=</span><span style="color: #24292E">apigw.Cors.</span><span style="color: #005CC5">ALL_METHODS</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    )</span></span>
<span class="line"><span style="color: #24292E">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">haiku </span><span style="color: #D73A49">=</span><span style="color: #24292E"> api.root.add_resource(</span><span style="color: #032F62">&quot;haiku&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">haiku.add_method(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #032F62">&quot;GET&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    apigw.LambdaIntegration(get_haiku_lambda)</span></span>
<span class="line"><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">haiku.add_method(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #032F62">&quot;POST&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    apigw.LambdaIntegration(post_haiku_lambda)</span></span>
<span class="line"><span style="color: #24292E">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">haiku_item_id </span><span style="color: #D73A49">=</span><span style="color: #24292E"> haiku.add_resource(</span><span style="color: #032F62">&quot;</span><span style="color: #005CC5">{item_id}</span><span style="color: #032F62">&quot;</span><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #6A737D">#</span></span>
<span class="line"><span style="color: #24292E">haiku_item_id.add_method(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #032F62">&quot;PATCH&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    apigw.LambdaIntegration(patch_haiku_lambda)</span></span>
<span class="line"><span style="color: #24292E">)</span></span>
<span class="line"><span style="color: #24292E">haiku_item_id.add_method(</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #032F62">&quot;DELETE&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">    apigw.LambdaIntegration(delete_haiku_lambda)</span></span>
<span class="line"><span style="color: #24292E">)</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br></div></div><ul>
<li>
<p>最初に， <code>api = apigw.RestApi()</code> により，空の API Gateway を作成している．</p>
</li>
<li>
<p>次に， <code>api.root.add_resource()</code> のメソッドを呼ぶことで， <code>/haiku</code> という API パスを追加している．</p>
</li>
<li>
<p>続いて， <code>add_method()</code> を呼ぶことで， <code>GET</code>, <code>POST</code> のメソッドを <code>/haiku</code> のパスに定義している．</p>
</li>
<li>
<p>さらに， <code>haiku.add_resource(&quot;{item_id}&quot;)</code> により， <code>/haiku/{item_id}</code> という API パスを追加している．</p>
</li>
<li>
<p>最後に， <code>add_method()</code> を呼ぶことにより， <code>PATCH</code>, <code>DELETE</code> のメソッドを <code>/haiku/{item_id}</code> のパスに定義している．</p>
</li>
</ul>
<p>このように， API Gateway の使い方は非常にシンプルで，逐次的に API パスとそこで実行されるメソッド・Lambda を記述していくだけでよい．</p>
<p>このプログラムで 新規 API を作成すると， ランダムな URL がその API のエンドポイントとして割り当てられる． これを． <code>api.example.com</code> のような自分のドメインでホストしたければ， AWS によって付与された URL を自分のドメインの DNS レコードに追加すればよい．</p>
<p>API Gateway で新規 API を作成したとき， <code>default_cors_preflight_options=</code> というパラメータで <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS" target="_blank" rel="noreferrer">Cross Origin Resource Sharing (CORS)</a> の設定を行っている． これは，ブラウザで走る Web アプリケーションと API を接続するときに必要な設定である．</p>
<h2 id="アプリケーションのデプロイ" tabindex="-1">アプリケーションのデプロイ <a class="header-anchor" href="#アプリケーションのデプロイ" aria-label="Permalink to &quot;アプリケーションのデプロイ&quot;">&ZeroWidthSpace;</a></h2>
<p>アプリケーションの中身が理解できたところで，早速デプロイを行ってみよう． デプロイの手順は，これまでのハンズオンとほとんど共通である． ここでは，コマンドのみ列挙する (<code>#</code> で始まる行はコメントである)． シークレットキーの設定も忘れずに (<a href="#aws_cli_install">AWS CLI のインストール</a>)．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390"># プロジェクトのディレクトリに移動</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cd</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">intro-aws/handson/bashoutter</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># venv を作成し，依存ライブラリのインストールを行う</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python3</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-m</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">venv</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.env</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">source</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.env/bin/activate</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">pip</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">install</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-r</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">requirements.txt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># デプロイを実行</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cdk</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">deploy</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D"># プロジェクトのディレクトリに移動</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cd</span><span style="color: #24292E"> </span><span style="color: #032F62">intro-aws/handson/bashoutter</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># venv を作成し，依存ライブラリのインストールを行う</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python3</span><span style="color: #24292E"> </span><span style="color: #005CC5">-m</span><span style="color: #24292E"> </span><span style="color: #032F62">venv</span><span style="color: #24292E"> </span><span style="color: #032F62">.env</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">source</span><span style="color: #24292E"> </span><span style="color: #032F62">.env/bin/activate</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">pip</span><span style="color: #24292E"> </span><span style="color: #032F62">install</span><span style="color: #24292E"> </span><span style="color: #005CC5">-r</span><span style="color: #24292E"> </span><span style="color: #032F62">requirements.txt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># デプロイを実行</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cdk</span><span style="color: #24292E"> </span><span style="color: #032F62">deploy</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br></div></div><p>デプロイのコマンドが無事に実行されれば， <a href="#handson_05_cdk_output">figure_title</a> のような出力が得られるはずである． ここで表示されている <code>Bashoutter.BashoutterApiEndpoint = XXXX</code>, <code>Bashoutter.BucketUrl = YYYY</code> の二つ文字列はあとで使うのでメモしておこう．</p>
<p><img src="./assets/handson-bashoutter/cdk_output.png" alt="CDKデプロイ実行後の出力"></p>
<p>AWS コンソールにログインして，デプロイされたスタックを確認してみよう． まずは，コンソールから API Gateway のページに行く． すると， <a href="#handson_05_apigw_console_list">figure_title</a> のような画面が表示され，デプロイ済みの API エンドポイントの一覧が確認できる．</p>
<p><img src="./assets/handson-bashoutter/apigw_console_list.png" alt="API Gateway コンソール画面 (1)"></p>
<p>今回デプロイした &quot;BashoutterApi&quot; という名前の API をクリックすることで <a href="#handson_05_apigw_console_detail">figure_title</a> のような画面に遷移し，詳細情報を閲覧できる． <code>GET /haiku</code>, <code>POST /haiku</code> などが定義されていることが確認できる．</p>
<p>それぞれのメソッドをクリックすると，そのメソッドの詳細情報を確認できる． API Gateway は，前述したルーティングの機能だけでなく，認証機能などを追加することも可能である． このハンズオンではとくにこれらの機能は使用しないが， &quot;Method Request&quot; と書いてある項目などがそれに相当する． 次に， <a href="#handson_05_apigw_console_detail">figure_title</a> で画面右端の赤色で囲った部分に，この API で呼ばれる Lambda 関数が指定されていることに注目しよう． 関数名をクリックと，該当する Lambda のコンソールに遷移し，関数の中身を閲覧することが可能である．</p>
<p><img src="./assets/handson-bashoutter/apigw_console_detail.png" alt="API Gateway コンソール画面 (2)"></p>
<p>次に， S3 のコンソール画面に移ってみよう． <code>bashouter-</code> で始まるランダムな名前のバケットが見つかるはずである (<a href="#handson_05_s3_console">figure_title</a>)．</p>
<p><img src="./assets/handson-bashoutter/s3_console.png" alt="S3 コンソール画面"></p>
<p>バケットの名前をクリックすることで，バケットの中身を確認してみよう． <code>index.html</code> のほか， <code>css/</code>, <code>js/</code> などのディレクトリがあるのが確認できるだろう (<a href="#handson_05_s3_contents">figure_title</a>)． これらが，ウェブページの&quot;枠&quot;を定義している静的コンテンツである．</p>
<p><img src="./assets/handson-bashoutter/s3_contents.png" alt="S3 バケットの中身"></p>
<h2 id="api-リクエストを送信する" tabindex="-1">API リクエストを送信する <a class="header-anchor" href="#api-リクエストを送信する" aria-label="Permalink to &quot;API リクエストを送信する&quot;">&ZeroWidthSpace;</a></h2>
<p>それでは，デプロイしたアプリケーションに対し，実際に API リクエストを送信してみよう． まずはコマンドラインから API を送信する演習を行おう． S3 に配置した GUI は一旦おいておく．</p>
<p>ここではコマンドラインから HTTP API リクエストを送信するためのシンプルな HTTP クライアントである <a href="https://httpie.org/" target="_blank" rel="noreferrer">HTTPie</a> を使ってみよう． HTTPie は，スタックをデプロイするときに Python 仮想環境 (venv) を作成したとき，一緒にインストールされている． 念のためインストールがうまくいっているか確認するには，仮想環境を立ち上げたあとコマンドラインに <code>http</code> と打ってみる． ヘルプのメッセージが出力されたら準備 OK である．</p>
<p>まず，先ほどデプロイを実行したときに得られた API のエンドポイントの URL (<code>Bashoutter.BashoutterApiEndpoint = XXXX</code> で得られた <code>XXXX</code> の文字列) をコマンドラインの変数に設定しておく．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">export</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ENDPOINT_URL=XXXX</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">export</span><span style="color: #24292E"> </span><span style="color: #032F62">ENDPOINT_URL=XXXX</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>次に，俳句の一覧を取得するため， <code>GET /haiku</code> の API を送信してみよう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">http</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">GET</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;${</span><span style="color: #ADBAC7">ENDPOINT_URL</span><span style="color: #96D0FF">}/haiku&quot;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">http</span><span style="color: #24292E"> </span><span style="color: #032F62">GET</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;${</span><span style="color: #24292E">ENDPOINT_URL</span><span style="color: #032F62">}/haiku&quot;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>現時点では，まだだれも俳句を投稿していないので，空の配列 (<code>[]</code>) が返ってくる．</p>
<p>それでは次に， <code>POST /haiku</code> を使って俳句を投稿してみよう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">http</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">POST</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;${</span><span style="color: #ADBAC7">ENDPOINT_URL</span><span style="color: #96D0FF">}/haiku&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">\</span></span>
<span class="line"><span style="color: #ADBAC7">username=</span><span style="color: #96D0FF">&quot;松尾芭蕉&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">\</span></span>
<span class="line"><span style="color: #ADBAC7">first=</span><span style="color: #96D0FF">&quot;閑さや&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">\</span></span>
<span class="line"><span style="color: #ADBAC7">second=</span><span style="color: #96D0FF">&quot;岩にしみ入る&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">\</span></span>
<span class="line"><span style="color: #ADBAC7">third=</span><span style="color: #96D0FF">&quot;蝉の声&quot;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">http</span><span style="color: #24292E"> </span><span style="color: #032F62">POST</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;${</span><span style="color: #24292E">ENDPOINT_URL</span><span style="color: #032F62">}/haiku&quot;</span><span style="color: #24292E"> </span><span style="color: #005CC5">\</span></span>
<span class="line"><span style="color: #24292E">username=</span><span style="color: #032F62">&quot;松尾芭蕉&quot;</span><span style="color: #24292E"> </span><span style="color: #005CC5">\</span></span>
<span class="line"><span style="color: #24292E">first=</span><span style="color: #032F62">&quot;閑さや&quot;</span><span style="color: #24292E"> </span><span style="color: #005CC5">\</span></span>
<span class="line"><span style="color: #24292E">second=</span><span style="color: #032F62">&quot;岩にしみ入る&quot;</span><span style="color: #24292E"> </span><span style="color: #005CC5">\</span></span>
<span class="line"><span style="color: #24292E">third=</span><span style="color: #032F62">&quot;蝉の声&quot;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br></div></div><p>次のような出力が得られるだろう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">HTTP/1.1</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">201</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">Created</span></span>
<span class="line"><span style="color: #F69D50">Connection:</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">keep-alive</span></span>
<span class="line"><span style="color: #F69D50">Content-Length:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">49</span></span>
<span class="line"><span style="color: #F69D50">Content-Type:</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">application/json</span></span>
<span class="line"><span style="color: #6CB6FF">....</span></span>
<span class="line"><span style="color: #ADBAC7">{</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F69D50">&quot;description&quot;</span><span style="color: #6CB6FF">:</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;Successfully added a new haiku&quot;</span></span>
<span class="line"><span style="color: #ADBAC7">}</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">HTTP/1.1</span><span style="color: #24292E"> </span><span style="color: #005CC5">201</span><span style="color: #24292E"> </span><span style="color: #032F62">Created</span></span>
<span class="line"><span style="color: #6F42C1">Connection:</span><span style="color: #24292E"> </span><span style="color: #032F62">keep-alive</span></span>
<span class="line"><span style="color: #6F42C1">Content-Length:</span><span style="color: #24292E"> </span><span style="color: #005CC5">49</span></span>
<span class="line"><span style="color: #6F42C1">Content-Type:</span><span style="color: #24292E"> </span><span style="color: #032F62">application/json</span></span>
<span class="line"><span style="color: #005CC5">....</span></span>
<span class="line"><span style="color: #24292E">{</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #6F42C1">&quot;description&quot;</span><span style="color: #005CC5">:</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;Successfully added a new haiku&quot;</span></span>
<span class="line"><span style="color: #24292E">}</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br></div></div><p>新しい俳句を投稿することに成功したようである． 本当に俳句が追加されたか，再び GET リクエストを呼ぶことで確認してみよう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">http</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">GET</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;${</span><span style="color: #ADBAC7">ENDPOINT_URL</span><span style="color: #96D0FF">}/haiku&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F69D50">HTTP/1.1</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">200</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">OK</span></span>
<span class="line"><span style="color: #F69D50">Connection:</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">keep-alive</span></span>
<span class="line"><span style="color: #F69D50">Content-Length:</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">258</span></span>
<span class="line"><span style="color: #F69D50">Content-Type:</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">application/json</span></span>
<span class="line"><span style="color: #6CB6FF">...</span></span>
<span class="line"><span style="color: #ADBAC7">[</span></span>
<span class="line"><span style="color: #ADBAC7">    {</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #96D0FF">&quot;created_at&quot;</span><span style="color: #ADBAC7">: </span><span style="color: #96D0FF">&quot;2020-07-06T02:46:04+00:00&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #96D0FF">&quot;first&quot;</span><span style="color: #ADBAC7">: </span><span style="color: #96D0FF">&quot;閑さや&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #96D0FF">&quot;item_id&quot;</span><span style="color: #ADBAC7">: </span><span style="color: #96D0FF">&quot;7e91c5e4d7ad47909e0ac14c8bbab05b&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #96D0FF">&quot;likes&quot;</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">0.0</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #96D0FF">&quot;second&quot;</span><span style="color: #ADBAC7">: </span><span style="color: #96D0FF">&quot;岩にしみ入る&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #96D0FF">&quot;third&quot;</span><span style="color: #ADBAC7">: </span><span style="color: #96D0FF">&quot;蝉の声&quot;</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #96D0FF">&quot;username&quot;</span><span style="color: #ADBAC7">: </span><span style="color: #96D0FF">&quot;松尾芭蕉&quot;</span></span>
<span class="line"><span style="color: #ADBAC7">    }</span></span>
<span class="line"><span style="color: #ADBAC7">]</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">http</span><span style="color: #24292E"> </span><span style="color: #032F62">GET</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;${</span><span style="color: #24292E">ENDPOINT_URL</span><span style="color: #032F62">}/haiku&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6F42C1">HTTP/1.1</span><span style="color: #24292E"> </span><span style="color: #005CC5">200</span><span style="color: #24292E"> </span><span style="color: #032F62">OK</span></span>
<span class="line"><span style="color: #6F42C1">Connection:</span><span style="color: #24292E"> </span><span style="color: #032F62">keep-alive</span></span>
<span class="line"><span style="color: #6F42C1">Content-Length:</span><span style="color: #24292E"> </span><span style="color: #005CC5">258</span></span>
<span class="line"><span style="color: #6F42C1">Content-Type:</span><span style="color: #24292E"> </span><span style="color: #032F62">application/json</span></span>
<span class="line"><span style="color: #005CC5">...</span></span>
<span class="line"><span style="color: #24292E">[</span></span>
<span class="line"><span style="color: #24292E">    {</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #032F62">&quot;created_at&quot;</span><span style="color: #24292E">: </span><span style="color: #032F62">&quot;2020-07-06T02:46:04+00:00&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #032F62">&quot;first&quot;</span><span style="color: #24292E">: </span><span style="color: #032F62">&quot;閑さや&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #032F62">&quot;item_id&quot;</span><span style="color: #24292E">: </span><span style="color: #032F62">&quot;7e91c5e4d7ad47909e0ac14c8bbab05b&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #032F62">&quot;likes&quot;</span><span style="color: #24292E">: </span><span style="color: #005CC5">0.0</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #032F62">&quot;second&quot;</span><span style="color: #24292E">: </span><span style="color: #032F62">&quot;岩にしみ入る&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #032F62">&quot;third&quot;</span><span style="color: #24292E">: </span><span style="color: #032F62">&quot;蝉の声&quot;</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #032F62">&quot;username&quot;</span><span style="color: #24292E">: </span><span style="color: #032F62">&quot;松尾芭蕉&quot;</span></span>
<span class="line"><span style="color: #24292E">    }</span></span>
<span class="line"><span style="color: #24292E">]</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br></div></div><p>素晴らしい！</p>
<p>次に， <code>PATCH /haiku/{item_id}</code> を呼ぶことでこの俳句にいいねを追加してみよう． 一つ前のコマンドで取得した俳句の <code>item_id</code> を，次のコマンドの <code>XXXX</code> に代入した上で実行しよう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">http</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">PATCH</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;${</span><span style="color: #ADBAC7">ENDPOINT_URL</span><span style="color: #96D0FF">}/haiku/XXXX&quot;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">http</span><span style="color: #24292E"> </span><span style="color: #032F62">PATCH</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;${</span><span style="color: #24292E">ENDPOINT_URL</span><span style="color: #032F62">}/haiku/XXXX&quot;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p><code>{&quot;description&quot;: &quot;OK&quot;}</code> という出力が得られるはずである． 再び GET リクエストを送ることで，いいね (<code>likes</code>) が 1 増えたことを確認しよう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">http</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">GET</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;${</span><span style="color: #ADBAC7">ENDPOINT_URL</span><span style="color: #96D0FF">}/haiku&quot;</span></span>
<span class="line"><span style="color: #6CB6FF">...</span></span>
<span class="line"><span style="color: #ADBAC7">[</span></span>
<span class="line"><span style="color: #ADBAC7">    {</span></span>
<span class="line"><span style="color: #ADBAC7">        ...</span></span>
<span class="line"><span style="color: #ADBAC7">        </span><span style="color: #96D0FF">&quot;likes&quot;</span><span style="color: #ADBAC7">: </span><span style="color: #6CB6FF">1.0</span><span style="color: #ADBAC7">,</span></span>
<span class="line"><span style="color: #ADBAC7">        ...</span></span>
<span class="line"><span style="color: #ADBAC7">    }</span></span>
<span class="line"><span style="color: #ADBAC7">]</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">http</span><span style="color: #24292E"> </span><span style="color: #032F62">GET</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;${</span><span style="color: #24292E">ENDPOINT_URL</span><span style="color: #032F62">}/haiku&quot;</span></span>
<span class="line"><span style="color: #005CC5">...</span></span>
<span class="line"><span style="color: #24292E">[</span></span>
<span class="line"><span style="color: #24292E">    {</span></span>
<span class="line"><span style="color: #24292E">        ...</span></span>
<span class="line"><span style="color: #24292E">        </span><span style="color: #032F62">&quot;likes&quot;</span><span style="color: #24292E">: </span><span style="color: #005CC5">1.0</span><span style="color: #24292E">,</span></span>
<span class="line"><span style="color: #24292E">        ...</span></span>
<span class="line"><span style="color: #24292E">    }</span></span>
<span class="line"><span style="color: #24292E">]</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br></div></div><p>最後に， DELETE リクエストを送ることで俳句をデータベースから削除しよう． <code>XXXX</code> は <code>item_id</code> の値で置き換えたうえで次のコマンドを実行する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">http</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">DELETE</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;${</span><span style="color: #ADBAC7">ENDPOINT_URL</span><span style="color: #96D0FF">}/haiku/XXXX&quot;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">http</span><span style="color: #24292E"> </span><span style="color: #032F62">DELETE</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;${</span><span style="color: #24292E">ENDPOINT_URL</span><span style="color: #032F62">}/haiku/XXXX&quot;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>再び GET リクエストを送ることで，返り値が空 (<code>[]</code>) になっていることを確認しよう．</p>
<p>これで，俳句の投稿・取得・削除そしていいねの追加，といった基本的な API がきちんと動作していることが確認できた．</p>
<h2 id="大量の-api-リクエストをシミュレートする" tabindex="-1">大量の API リクエストをシミュレートする <a class="header-anchor" href="#大量の-api-リクエストをシミュレートする" aria-label="Permalink to &quot;大量の API リクエストをシミュレートする&quot;">&ZeroWidthSpace;</a></h2>
<p>さて，前節ではマニュアルで一つずつ俳句を投稿した． 多数のユーザーがいるような SNS では，1 秒間に数千件以上の投稿がされている． 今回はサーバーレスアーキテクチャを採用したことで，そのような瞬間的な大量アクセスにも容易に対応できるようなシステムが自動的に構築されている． このポイントを実証するため，ここでは大量の API が送信された状況をシミュレートしてみよう．</p>
<p><a href="https://github.com/andatoshiki/toshiki-notebookblob/main/handson/bashoutter/client.py" target="_blank" rel="noreferrer">handson/bashoutter/client.py</a> に，大量の API リクエストをシミュレートするためのプログラムが書かれている． このプログラムを使用すると， <code>POST /haiku</code> の API リクエストを指定された回数だけ実行することができる．</p>
<p>テストとして， API を 300 回実行してみよう． 次のコマンドを実行する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">client.py</span><span style="color: #ADBAC7"> $ENDPOINT_URL </span><span style="color: #96D0FF">post_many</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">300</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python</span><span style="color: #24292E"> </span><span style="color: #032F62">client.py</span><span style="color: #24292E"> $ENDPOINT_URL </span><span style="color: #032F62">post_many</span><span style="color: #24292E"> </span><span style="color: #005CC5">300</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>数秒のうちに実行が完了するだろう． これがもし，単一のサーバーからなる API だったとしたら，このような大量のリクエストの処理にはもっと時間がかかっただろう． 最悪の場合には，サーバーダウンにもつながっていたかもしれない． したがって，今回作成したサーバーレスアプリケーションは，とてもシンプルながらも 1 秒間に数百件の処理を行えるような，スケーラブルなクラウドシステムであることがわかる． サーバーレスでクラウドを設計することの利点を垣間見ることができただろうか？</p>
<p>先述のコマンドにより大量の俳句を投稿するとデータベースに無駄なデータがどんどん溜まってしまう． データベースを完全に空にするには，次のコマンドを使用する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">client.py</span><span style="color: #ADBAC7"> $ENDPOINT_URL </span><span style="color: #96D0FF">clear_database</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python</span><span style="color: #24292E"> </span><span style="color: #032F62">client.py</span><span style="color: #24292E"> $ENDPOINT_URL </span><span style="color: #032F62">clear_database</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><h2 id="bashoutter-gui-を動かしてみる" tabindex="-1">Bashoutter GUI を動かしてみる <a class="header-anchor" href="#bashoutter-gui-を動かしてみる" aria-label="Permalink to &quot;Bashoutter GUI を動かしてみる&quot;">&ZeroWidthSpace;</a></h2>
<p>前節ではコマンドラインから API を送信する演習を行った． ウェブアプリケーションでは，これと同じことがウェブブラウザの背後で行われ，ページのコンテンツが表示されている (<a href="#fig:web_server">figure_title</a> 参照)． 最後に， API が GUI と統合されるとどうなるのか，見てみよう．</p>
<p>CDK のコードで， Public access mode の S3 バケットを作成したことを思い出してほしい． 最初のステップとして，ここにウェブサイトのコンテンツをアップロードしよう． ハンズオンのソースコードの中に <code>gui/dist</code> というフォルダが見つかるはずである． ここにはビルド済みのウェブサイトの静的コンテンツ (HTML/CSS/JavaScript) が入っている． AWS CLI のコマンドを使うことでこれらのファイルを S3 にアップロードしよう．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">s3</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cp</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--recursive</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">./gui/dist</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">s3://</span><span style="color: #F47067">&lt;</span><span style="color: #96D0FF">BUCKET_NAM</span><span style="color: #ADBAC7">E</span><span style="color: #F47067">&gt;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">aws</span><span style="color: #24292E"> </span><span style="color: #032F62">s3</span><span style="color: #24292E"> </span><span style="color: #032F62">cp</span><span style="color: #24292E"> </span><span style="color: #005CC5">--recursive</span><span style="color: #24292E"> </span><span style="color: #032F62">./gui/dist</span><span style="color: #24292E"> </span><span style="color: #032F62">s3://</span><span style="color: #D73A49">&lt;</span><span style="color: #032F62">BUCKET_NAM</span><span style="color: #24292E">E</span><span style="color: #D73A49">&gt;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>コマンドを実行する際は， Bashoutter ハンズオンのディレクトリから行うこと (<code>./gui/dist</code> に注目)，そして <code>&lt;BUCKET_NAME&gt;</code> にはデプロイした自身のバケットの名前が入る点に注意． 念のため，AWS コンソールにログインし，バケットにファイルがアップロードされている点を確認しておこう．</p>
<p>なお，今回は GUI の説明はとくに行わないが， Bashoutter のウェブサイトは <a href="https://vuejs.org/" target="_blank" rel="noreferrer">Vue.js</a> と <a href="https://vuetifyjs.com/" target="_blank" rel="noreferrer">Vuetify</a> という UI フレームワークを使って作成した． Vue を使うことで， Single page application (SPA) の技術でウェブサイトの画面がレンダリングされる． ソースコードは <a href="https://github.com/andatoshiki/toshiki-notebooktree/main/handson/bashoutter/gui" target="_blank" rel="noreferrer">handson/bashoutter/gui</a> のディレクトリの中にあるので，興味のある読者は確認してみるとよい．</p>
<p>アップトードが完了したところで，続いてデプロイを実行したときにコマンドラインの出力を見直してみよう． <code>Bashoutter.BucketUrl=</code> で与えられた URL が見つかるはずである (<a href="#handson_05_cdk_output">figure_title</a>)． これは，先述したとおり， Public access mode の S3 バケットの URL である．</p>
<p>ウェブブラウザを開き，アドレスバーに S3 の URL を入力しへアクセスしてみよう． すると， <a href="#handson_05_bashoutter_2">figure_title</a> のようなページが表示されるはずである．</p>
<p><img src="./assets/handson-bashoutter/bashoutter_2.png" alt="&quot;Bashoutter&quot; の GUI 画面"></p>
<p>ページが表示されたら，一番上の &quot;API Endpoint URL&quot; と書いてあるテキストボックスに，今回デプロイした <strong>API Gateway の URL を入力</strong>する (今回のアプリケーションでは，API Gateway の URL はランダムに割り当てられるのでこのような GUI の仕様になっている)． そうしたら，画面の &quot;REFRESH&quot; と書いてあるボタンを押してみよう． データベースに俳句が登録済みであれば，俳句の一覧が表示されるはずである． 各俳句の左下にあるハートのアイコンをクリックすることで， &quot;like&quot; の票を入れることができる．</p>
<p>新しい俳句を投稿するには，五七五と投稿者の名前を入力して， &quot;POST&quot; を押す． &quot;POST&quot; を押した後は，再び &quot;REFRESH&quot; ボタンを押すことで最新の俳句のリストをデータベースから取得する．</p>
<h2 id="アプリケーションの削除" tabindex="-1">アプリケーションの削除 <a class="header-anchor" href="#アプリケーションの削除" aria-label="Permalink to &quot;アプリケーションの削除&quot;">&ZeroWidthSpace;</a></h2>
<p>これで， Bashoutter プロジェクトが完成した！ この SNS は，インターネットを通じて世界のどこからでもアクセスできる状態にある． また， <a href="#simulating_many_apis">大量の API リクエストをシミュレートする</a> で見たように，大量のユーザーの同時アクセスによる負荷がかかっても，柔軟にスケールが行われ遅延なく処理を行うことができる． 極めて簡素ながらも，立派なウェブサービスとしてのスペックは満たしているのである！</p>
<p>Bashoutter アプリを存分に楽しむことができたら，最後に忘れずにスタックを削除しよう．</p>
<p>コマンドラインからスタックの削除を実行するには，次のコマンドを使う．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cdk</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">destroy</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cdk</span><span style="color: #24292E"> </span><span style="color: #032F62">destroy</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>CDK のバージョンによっては S3 のバケットが空でないと， <code>cdk destroy</code> がエラーを出力する場合がある． この場合はスタックを削除する前に， S3 バケットの中身をすべて削除しなければならない．</p>
<p>コンソールから実行するには， S3 コンソールに行き，バケットの中身を開いたうえで，すべてのファイルを選択し， &quot;Actions&quot; → &quot;Delete&quot; を実行すればよいい．</p>
<p>コマンドラインから実行するには， 次のコマンドを使う． &lt;BUCKET NAME&gt; のところは，自分の バケットの名前 (&quot;<code>BashoutterBucketXXXX</code>&quot; というパターンの名前がついているはずである) に置き換えることを忘れずに．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">s3</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">rm</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">&lt;</span><span style="color: #96D0FF">BUCKET</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">NAM</span><span style="color: #ADBAC7">E</span><span style="color: #F47067">&gt;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--recursive</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">aws</span><span style="color: #24292E"> </span><span style="color: #032F62">s3</span><span style="color: #24292E"> </span><span style="color: #032F62">rm</span><span style="color: #24292E"> </span><span style="color: #D73A49">&lt;</span><span style="color: #032F62">BUCKET</span><span style="color: #24292E"> </span><span style="color: #032F62">NAM</span><span style="color: #24292E">E</span><span style="color: #D73A49">&gt;</span><span style="color: #24292E"> </span><span style="color: #005CC5">--recursive</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><h2 id="小括-2" tabindex="-1">小括 <a class="header-anchor" href="#小括-2" aria-label="Permalink to &quot;小括&quot;">&ZeroWidthSpace;</a></h2>
<p>ここまでが，本書第三部の内容であった．</p>
<p>第三部では，クラウドの応用として，一般の人に使ってもらうようなウェブアプリケーション・データベースをどのようにして作るのか，という点に焦点を当てて，説明を行った． その中で，従来的なクラウドシステムの設計と，ここ数年の最新の設計方法であるサーバーレスアーキテクチャについて解説した． <a href="#sec_intro_serverless">Hands-on #5: サーバーレス入門</a> では， AWS でのサーバーレスの実践として， Lambda, S3, DynamoDB のハンズオンを行った． 最後に， <a href="#sec_bashoutter">Hands-on #6: Bashoutter</a> では，これらの技術を統合することで，完全サーバーレスなウェブアプリケーション &quot;Bashoutter&quot; を作成した．</p>
<p>これらの演習を通じて，世の中のウェブサービスがどのようにしてでき上がっているのか，少し理解が深まっただろうか？ また，そのようなウェブアプリケーションを自分が作りたいと思ったとき，今回のハンズオンがその出発点となることができたならば幸いである．</p>
<h1 id="まとめ" tabindex="-1">まとめ <a class="header-anchor" href="#まとめ" aria-label="Permalink to &quot;まとめ&quot;">&ZeroWidthSpace;</a></h1>
<h1 id="appendix-環境構築" tabindex="-1">Appendix: 環境構築 <a class="header-anchor" href="#appendix-環境構築" aria-label="Permalink to &quot;Appendix: 環境構築&quot;">&ZeroWidthSpace;</a></h1>
<p>本書を読み進めるにあたって，ハンズオンのプログラムを実行するための環境を自分のローカルマシンにセットアップしなければならない． ここでは， AWS やコマンドラインの初心者を想定して，本章で必要なソフトウェアやライブラリのインストールなどを簡単に解説する． 以下に簡単な目次を示そう． 既に環境構築が済んでいる場合は適宜読み飛ばしていただき，関係のある箇所のみ目を通せば良い．</p>
<ul>
<li>
<p>AWS アカウントの取得 (<a href="#sec:create_aws_account">AWS アカウントの取得</a>)</p>
</li>
<li>
<p>AWS シークレットキーの作成 (<a href="#aws_secrets">AWS のシークレットキーの作成</a>)</p>
</li>
<li>
<p>AWS CLI のインストール (<a href="#aws_cli_install">AWS CLI のインストール</a>)</p>
</li>
<li>
<p>AWS CDK のインストール (<a href="#aws_cdk_install">AWS CDK のインストール</a>)</p>
</li>
<li>
<p>WSL のインストール (<a href="#sec:install_wsl">WSL のインストール</a>)</p>
</li>
<li>
<p>Docker のインストール (<a href="#sec:install_docker">Docker のインストール</a>)</p>
</li>
<li>
<p>Python venv クイックガイド (<a href="#venv_quick_guide">Python クイックガイド</a>)</p>
</li>
<li>
<p>ハンズオン実行用の Docker image の使い方 (<a href="#sec_handson_docker">ハンズオン実行用の Docker image の使い方</a>)</p>
</li>
</ul>
<p>使用する OS は Linux/Mac/Windows のどれを用いても構わない． Windows のユーザーは， Windows Subsytem for Linux (WSL) を使用することを想定している (<a href="#sec:install_wsl">WSL のインストール</a>)．</p>
<p>また，本書のハンズオンを実行するための <a href="https://hub.docker.com/repository/docker/tomomano/labc" target="_blank" rel="noreferrer">Docker イメージ</a> を提供している． これを用いると， AWS CLI/CDK や Python の設定などをスキップできるので， Docker の使用方法を知っている読者には便利だろう．</p>
<h2 id="aws-アカウントの取得" tabindex="-1">AWS アカウントの取得 <a class="header-anchor" href="#aws-アカウントの取得" aria-label="Permalink to &quot;AWS アカウントの取得&quot;">&ZeroWidthSpace;</a></h2>
<p>本書で提供するハンズオンを実際に自分で試すには，読者自身で AWS のアカウントの作成をする必要がある． 詳しいアカウントの作成の手順は <a href="https://aws.amazon.com/jp/register-flow/" target="_blank" rel="noreferrer">公式のドキュメンテーション</a> に書かれているので，そちらも参照していただきたい． 以下の手順に従ってアカウントの作成を行う．</p>
<p>まず，ウェブブラウザから <a href="https://aws.amazon.com/console/" target="_blank" rel="noreferrer">AWS コンソール</a> にアクセスし，右上の <code>Create an AWS Account</code> をクリックする (<a href="#fig:aws-signup-1">figure_title</a> で実線で囲った部分)．</p>
<p><img src="./assets/signup-1.png" alt="サインアップ (1): AWS コンソールにアクセス"></p>
<p>次に，遷移した先のページでメールアドレスとパスワードなどの登録を行う (<a href="#fig:aws-signup-3">figure_title</a>)．</p>
<p><img src="./assets/signup-3.png" alt="サインアップ (2): メールアドレス・パスワードなどの登録．"></p>
<p>続いて，住所や電話番号などを訊かれるので，すべて入力しよう (<a href="#fig:aws-signup-4">figure_title</a>)．</p>
<p><img src="./assets/signup-4.png" alt="サインアップ (3): 住所・電話番号の入力"></p>
<p>次に，クレジットカードの情報の登録を求められる (<a href="#fig:aws-signup-5">figure_title</a>)． 個人で AWS を利用する場合は，利用料金の請求はクレジットカードを経由して行われる． クレジットカードの登録なしには AWS を使い始めることはできないことに注意．</p>
<p><img src="./assets/signup-5.png" alt="サインアップ (4): クレジットカードの登録"></p>
<p>次の画面では，携帯電話の SMS またはボイスメッセージを利用した本人確認が求められる (<a href="#fig:aws-signup-6">figure_title</a>)． 希望の認証方法を選択し，自分の携帯電話番号を入力しよう．</p>
<p><img src="./assets/signup-6.png" alt="サインアップ (5): 携帯電話による本人確認"></p>
<p>無事に本人確認が完了すると，最後にサポートプランの選択を求められる (<a href="#fig:aws-signup-8">figure_title</a>)． 無料の Basic support を選択しておけば問題ない．</p>
<p><img src="./assets/signup-8.png" alt="サインアップ (6): サポートプランの選択"></p>
<p>以上のステップにより，アカウントの作成が完了する (<a href="#fig:aws-signup-9">figure_title</a>)． 早速ログインをして， AWS コンソールにアクセスできるか確認しておこう．</p>
<p><img src="./assets/signup-9.png" alt="サインアップ (7): アカウントの作成が完了した"></p>
<h2 id="aws-のシークレットキーの作成" tabindex="-1">AWS のシークレットキーの作成 <a class="header-anchor" href="#aws-のシークレットキーの作成" aria-label="Permalink to &quot;AWS のシークレットキーの作成&quot;">&ZeroWidthSpace;</a></h2>
<p>AWS シークレットキーとは， AWS CLI や AWS CDK から AWS の API を操作するときに，ユーザー認証を行うための鍵のことである． AWS CLI/CDK を使うには，最初にシークレットキーを発行する必要がある． AWS シークレットキーの詳細は <a href="https://docs.aws.amazon.com/general/latest/gr/aws-sec-cred-types.html" target="_blank" rel="noreferrer">公式ドキュメンテーション &quot;Understanding and getting your AWS credentials&quot;</a> を参照．</p>
<ol>
<li>
<p>AWS コンソールにログインする．</p>
</li>
<li>
<p>画面右上のアカウント名をクリックし，表示されるプルダウンメニューから &quot;My Security Credentials&quot; を選択 (<a href="#fig:aws_secret_key_1">figure_title</a>)</p>
</li>
<li>
<p>&quot;Access keys for CLI, SDK, &amp; API access&quot; の下にある &quot;Create accesss key&quot; のボタンをクリックする (<a href="#fig:aws_secret_key_2">figure_title</a>)</p>
</li>
<li>
<p>表示された Access key ID, Secret access key を記録しておく (画面を閉じると二度と表示されない)．</p>
</li>
<li>
<p>鍵を忘れてしまった場合などは，同じ手順で再発行が可能である．</p>
</li>
<li>
<p>発行したシークレットキーは， <code>~/.aws/credentials</code> のファイルに書き込むか，環境変数に設定するなどして使う (詳しくは <a href="#aws_cli_install">AWS CLI のインストール</a>)．</p>
</li>
</ol>
<p><img src="./assets/aws_secret_key_1.png" alt="AWS シークレットキーの発行1"></p>
<p><img src="./assets/aws_secret_key_2.png" alt="AWS シークレットキーの発行2"></p>
<p><strong>AWS Educate Starter Account</strong> を用いている場合は，次の手順でシークレットキーを確認する．</p>
<ul>
<li>
<p>AWS Educate のコンソール画面から， <code>vocareum</code> のコンソールに移動する (<a href="#fig:vocareum_console">figure_title</a>)．</p>
</li>
<li>
<p><code>Account Details</code> をクリックし，続いて <code>AWS CLI: Show</code> をクリックする．</p>
</li>
<li>
<p><code>aws_access_key_id</code>, <code>aws_secret_access_key</code>, <code>aws_session_token</code> が表示される (<a href="#fig:vocareum_secret">figure_title</a>)． ここで表示された内容を <code>~/.aws/credentials</code> にコピーする (<a href="#aws_cli_install">AWS CLI のインストール</a> 参照)． <code>aws_session_token</code> の箇所も漏らさずコピーすること．</p>
</li>
<li>
<p>続いて， <code>~/.aws/config</code> というファイルを用意し，次の内容を書き込む． 現時点では AWS Starter Account は <code>us-east-1</code> リージョンでしか利用できないためである．</p>
<p>[default]
region = us-east-1
output = json</p>
</li>
<li>
<p>上記の説明ではプロファイル名が <code>default</code> となっていたが，これは自分の好きな名前に変更してもよい． <code>default</code> 以外の名前を使用する場合は，コマンドを実行するときにプロファイル名を指定する必要がある (詳しくは <a href="#aws_cli_install">AWS CLI のインストール</a>)．</p>
</li>
</ul>
<p><img src="./assets/vocareum_console.png" alt="vocareum コンソール"></p>
<p><img src="./assets/vocareum_secret.png" alt="vocareum から AWS シークレットキーの発行"></p>
<h2 id="aws-cli-のインストール" tabindex="-1">AWS CLI のインストール <a class="header-anchor" href="#aws-cli-のインストール" aria-label="Permalink to &quot;AWS CLI のインストール&quot;">&ZeroWidthSpace;</a></h2>
<p>読者のために，執筆時点におけるインストールの手順 (Linux 向け) を簡単に記述する． 将来のバージョンでは変更される可能性があるので，常に <a href="https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html" target="_blank" rel="noreferrer">公式のドキュメンテーション</a> で最新の情報をチェックすることを忘れずに．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">curl</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-o</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;awscliv2.zip&quot;</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">unzip</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">awscliv2.zip</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">sudo</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">./aws/install</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">curl</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip&quot;</span><span style="color: #24292E"> </span><span style="color: #005CC5">-o</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;awscliv2.zip&quot;</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">unzip</span><span style="color: #24292E"> </span><span style="color: #032F62">awscliv2.zip</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">sudo</span><span style="color: #24292E"> </span><span style="color: #032F62">./aws/install</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><p>インストールできたか確認するため，次のコマンドを打ってバージョン情報が出力されることを確認する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--version</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">aws</span><span style="color: #24292E"> </span><span style="color: #005CC5">--version</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>インストールができたら，次のコマンドにより初期設定を行う (<a href="https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html" target="_blank" rel="noreferrer">参照</a>)．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">configure</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">aws</span><span style="color: #24292E"> </span><span style="color: #032F62">configure</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>コマンドを実行すると， <code>AWS Access Key ID</code>, <code>AWS Secret Access Key</code> を入力するよう指示される． シークレットキーの発行については <a href="#aws_secrets">AWS のシークレットキーの作成</a> を参照． コマンドは加えて，<code>Default region name</code> を訊いてくる． ここには自分の好きな地域 (例えば <code>ap-northeast-1</code> =東京リージョン) を指定すればよい． 最後の <code>Default output format</code> は <code>json</code> としておくとよい．</p>
<p>このコマンドを完了すると， <code>~/.aws/credentials</code> と <code>~/.aws/config</code>　という名前のファイルが生成されているはずである． 念のため， <code>cat</code> コマンドを使って中身を確認してみるとよい．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cat</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">~/.aws/credentials</span></span>
<span class="line"><span style="color: #ADBAC7">[default]</span></span>
<span class="line"><span style="color: #F69D50">aws_access_key_id</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">XXXXXXXXXXXXXXXXXX</span></span>
<span class="line"><span style="color: #F69D50">aws_secret_access_key</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">YYYYYYYYYYYYYYYYYYY</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cat</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">~/.aws/config</span></span>
<span class="line"><span style="color: #ADBAC7">[profile default]</span></span>
<span class="line"><span style="color: #F69D50">region</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ap-northeast-1</span></span>
<span class="line"><span style="color: #F69D50">output</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">json</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cat</span><span style="color: #24292E"> </span><span style="color: #032F62">~/.aws/credentials</span></span>
<span class="line"><span style="color: #24292E">[default]</span></span>
<span class="line"><span style="color: #6F42C1">aws_access_key_id</span><span style="color: #24292E"> </span><span style="color: #032F62">=</span><span style="color: #24292E"> </span><span style="color: #032F62">XXXXXXXXXXXXXXXXXX</span></span>
<span class="line"><span style="color: #6F42C1">aws_secret_access_key</span><span style="color: #24292E"> </span><span style="color: #032F62">=</span><span style="color: #24292E"> </span><span style="color: #032F62">YYYYYYYYYYYYYYYYYYY</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cat</span><span style="color: #24292E"> </span><span style="color: #032F62">~/.aws/config</span></span>
<span class="line"><span style="color: #24292E">[profile default]</span></span>
<span class="line"><span style="color: #6F42C1">region</span><span style="color: #24292E"> </span><span style="color: #032F62">=</span><span style="color: #24292E"> </span><span style="color: #032F62">ap-northeast-1</span></span>
<span class="line"><span style="color: #6F42C1">output</span><span style="color: #24292E"> </span><span style="color: #032F62">=</span><span style="color: #24292E"> </span><span style="color: #032F62">json</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br></div></div><p><code>~/.aws/credentials</code> には認証鍵の情報が， <code>~/.aws/config</code> には AWS CLI の設定が記録されている．</p>
<p>デフォルトでは， <code>[default]</code> という名前でプロファイルが保存される． いくつかのプロファイルを使い分けたければ， default の例に従って，たとえば <code>[myprofile]</code> などという名前でプロファイルを追加すればよい．</p>
<p>AWS CLI でコマンドを打つときに，プロファイルを使い分けるには，</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">s3</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ls</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--profile</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">myprofile</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">aws</span><span style="color: #24292E"> </span><span style="color: #032F62">s3</span><span style="color: #24292E"> </span><span style="color: #032F62">ls</span><span style="color: #24292E"> </span><span style="color: #005CC5">--profile</span><span style="color: #24292E"> </span><span style="color: #032F62">myprofile</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>のように， <code>--profile</code> というオプションをつけてコマンドを実行する．</p>
<p>いちいち <code>--profile</code> オプションをつけるのが面倒だと感じる場合は， <code>AWS_PROFILE</code> という環境変数を設定するとよい．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">export</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">AWS_PROFILE=myprofile</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">export</span><span style="color: #24292E"> </span><span style="color: #032F62">AWS_PROFILE=myprofile</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>あるいは，認証情報などを環境変数に設定するテクニックもある．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">export</span><span style="color: #ADBAC7"> AWS_ACCESS_KEY_ID</span><span style="color: #F47067">=</span><span style="color: #96D0FF">XXXXXX</span></span>
<span class="line"><span style="color: #F47067">export</span><span style="color: #ADBAC7"> AWS_SECRET_ACCESS_KEY</span><span style="color: #F47067">=</span><span style="color: #96D0FF">YYYYYY</span></span>
<span class="line"><span style="color: #F47067">export</span><span style="color: #ADBAC7"> AWS_DEFAULT_REGION</span><span style="color: #F47067">=</span><span style="color: #96D0FF">ap-northeast-1</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">export</span><span style="color: #24292E"> AWS_ACCESS_KEY_ID</span><span style="color: #D73A49">=</span><span style="color: #032F62">XXXXXX</span></span>
<span class="line"><span style="color: #D73A49">export</span><span style="color: #24292E"> AWS_SECRET_ACCESS_KEY</span><span style="color: #D73A49">=</span><span style="color: #032F62">YYYYYY</span></span>
<span class="line"><span style="color: #D73A49">export</span><span style="color: #24292E"> AWS_DEFAULT_REGION</span><span style="color: #D73A49">=</span><span style="color: #032F62">ap-northeast-1</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><p>これらの環境変数は， <code>~/.aws/credentials</code> よりも高い優先度をもつので，環境変数が設定されていればそちらの情報が使用される (<a href="https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html" target="_blank" rel="noreferrer">参照</a>)．</p>
<p><strong>AWS Educate Starter Account</strong> は <code>us-east-1</code> のリージョンのみ利用可能である (執筆時点での情報)． よって， AWS Educate Starter Account を使用している場合は， default region を <code>us-east-1</code> に設定する必要がある．</p>
<h2 id="aws-cdk-のインストール" tabindex="-1">AWS CDK のインストール <a class="header-anchor" href="#aws-cdk-のインストール" aria-label="Permalink to &quot;AWS CDK のインストール&quot;">&ZeroWidthSpace;</a></h2>
<p>読者のために，執筆時点におけるインストールの手順 (Linux 向け) を簡単に記述する． 将来のバージョンでは変更される可能性があるので，常に <a href="https://docs.aws.amazon.com/cdk/latest/guide/getting_started.html" target="_blank" rel="noreferrer">公式のドキュメンテーション</a> で最新の情報をチェックすることを忘れずに．</p>
<p>Node.js がインストールされていれば，基本的に次のコマンドを実行すればよい．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">sudo</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">npm</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">install</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-g</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws-cdk</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">sudo</span><span style="color: #24292E"> </span><span style="color: #032F62">npm</span><span style="color: #24292E"> </span><span style="color: #032F62">install</span><span style="color: #24292E"> </span><span style="color: #005CC5">-g</span><span style="color: #24292E"> </span><span style="color: #032F62">aws-cdk</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>本書のハンズオンは AWS CDK version 1.100.0 で開発した． CDK は開発途上のライブラリなので，将来的に API が変更される可能性がある． API の変更によりエラーが生じた場合は， version 1.100.0 を使用することを推奨する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">npm</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">install</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-g</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">aws-cdk@1.100</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">npm</span><span style="color: #24292E"> </span><span style="color: #032F62">install</span><span style="color: #24292E"> </span><span style="color: #005CC5">-g</span><span style="color: #24292E"> </span><span style="color: #032F62">aws-cdk@1.100</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>インストールできたか確認するため，次のコマンドを打って正しくバージョンが表示されることを確認する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cdk</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--version</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cdk</span><span style="color: #24292E"> </span><span style="color: #005CC5">--version</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>インストールができたら，次のコマンドにより AWS 側の初期設定を行う． これは一度実行すれば OK．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cdk</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">bootstrap</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cdk</span><span style="color: #24292E"> </span><span style="color: #032F62">bootstrap</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p><code>cdk bootstrap</code> を実行するときは，AWS の認証情報とリージョンが正しく設定されていることを確認する． デフォルトでは <code>~/.aws/config</code> にあるデフォルトのプロファイルが使用される． デフォルト以外のプロファイルを用いるときは <a href="#aws_cli_install">AWS CLI のインストール</a> で紹介したテクニックを使って切り替える．</p>
<p>AWS CDK の認証情報の設定は AWS CLI と基本的に同じである．詳しくは <a href="#aws_cli_install">AWS CLI のインストール</a> を参照．</p>
<h2 id="wsl-のインストール" tabindex="-1">WSL のインストール <a class="header-anchor" href="#wsl-のインストール" aria-label="Permalink to &quot;WSL のインストール&quot;">&ZeroWidthSpace;</a></h2>
<p>本書のハンズオンではコマンドラインから AWS CLI のコマンドを実行したり， Python で書かれたプログラムを実行する． コマンドは基本的に UNIX のターミナルを想定して書かれている． Linux や Mac のユーザーは OS に標準搭載されているターミナルを用いれば良い． Windows を利用している読者は， <a href="https://docs.microsoft.com/en-us/windows/wsl/" target="_blank" rel="noreferrer">Windows Subsystem for Linux (WSL)</a> を利用することで，仮想の Linux 環境を構築することを推奨する． <a href="https://www.cygwin.com/" target="_blank" rel="noreferrer">Cygwin</a> などの Linux 環境をエミュレートするほかのツールでも構わないが，本書のプログラムは WSL でのみ動作確認を行っている．</p>
<p>WSL とは， Windows の OS 上で Linux の仮想環境を起動するための， Microsoft 社が公式で提供しているソフトウェアである． Ubuntu など希望の Linux distribution が選択でき，基本的にすべての Linux 向けに作られたプログラム・ソフトウェアを使用することができる．</p>
<p>執筆時点では <a href="https://docs.microsoft.com/en-us/windows/wsl/compare-versions#whats-new-in-wsl-2" target="_blank" rel="noreferrer">WSL 2</a> が最新版として提供されているので，以下では WSL 2 のインストール手順を簡単に説明する． 細かな詳細などは， <a href="https://docs.microsoft.com/en-us/windows/wsl/install-win10" target="_blank" rel="noreferrer">公式ドキュメンテーション</a> を参照のこと．</p>
<p>前提として，使用される OS は Windows 10 (Pro または Home エディション) でなければならない． さらに，使用している Windows 10 のバージョンが WSL に対応するバージョンであるかを確認する． X64 のシステムでは Version 1903, Build 18362 以上でなければならない． バージョンが対応していない場合は、 Windows のアップデートを行う．</p>
<p>まず最初に， Administrator 権限で PowerShell を起動する (<a href="#fig:powershell">figure_title</a>)． 左下の Windows メニューの検索バーに <code>powershell</code> と入力すると， PowerShell のプログラムが見つかるはずである， これを右クリックし、 <code>Run as administrator</code> を選択し起動する．</p>
<p><img src="./assets/wsl/powershell.png" alt="管理者権限での PowerShell の起動"></p>
<p>PowerShell が起動したら、次のコマンドを実行する．</p>
<div class="language-powershell vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">powershell</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #6CB6FF">dism.exe</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">/</span><span style="color: #ADBAC7">online </span><span style="color: #F47067">/</span><span style="color: #6CB6FF">enable-feature</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">/</span><span style="color: #ADBAC7">featurename:Microsoft</span><span style="color: #F47067">-</span><span style="color: #ADBAC7">Windows</span><span style="color: #F47067">-</span><span style="color: #ADBAC7">Subsystem</span><span style="color: #F47067">-</span><span style="color: #ADBAC7">Linux </span><span style="color: #F47067">/</span><span style="color: #ADBAC7">all </span><span style="color: #F47067">/</span><span style="color: #ADBAC7">norestart</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #005CC5">dism.exe</span><span style="color: #24292E"> </span><span style="color: #D73A49">/</span><span style="color: #24292E">online </span><span style="color: #D73A49">/</span><span style="color: #005CC5">enable-feature</span><span style="color: #24292E"> </span><span style="color: #D73A49">/</span><span style="color: #24292E">featurename:Microsoft</span><span style="color: #D73A49">-</span><span style="color: #24292E">Windows</span><span style="color: #D73A49">-</span><span style="color: #24292E">Subsystem</span><span style="color: #D73A49">-</span><span style="color: #24292E">Linux </span><span style="color: #D73A49">/</span><span style="color: #24292E">all </span><span style="color: #D73A49">/</span><span style="color: #24292E">norestart</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>実行して、“The operation completed successfully.” と出力されるのを確認する． これで WSL が enable される．</p>
<p>次に，先ほどと同じ Administrator 権限で開いた PowerShell で次のコマンドを実行する。</p>
<div class="language-powersh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">powersh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #adbac7">dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292e">dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>実行して， “The operation completed successfully.” と出力されるのを確認する． これが確認出来たら、一度コンピュータを再起動する．</p>
<p>続いて， Linux kernel update package を次のリンクからダウンロードする． <a href="https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi" target="_blank" rel="noreferrer">https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi</a></p>
<p>ダウンロードしたファイルをダブルクリックして実行する． ダイアログに従ってインストールを完了させる．</p>
<p>そうしたら，再び PowerShell を開き次のコマンドを実行する。</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">wsl</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">--set-default-version</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">2</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">wsl</span><span style="color: #24292E"> </span><span style="color: #005CC5">--set-default-version</span><span style="color: #24292E"> </span><span style="color: #005CC5">2</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>最後に、自分の好みの Linux distribution をインストールする． ここでは Ubuntu 20.04 をインストールしよう．</p>
<p>Microsoft store のアプリを起動し，検索バーに <code>Ubuntu</code> と入力する． Ubuntu 20.04 LTS という項目が見つかるはずなので，それを開き， “Get” ボタンをクリックする (<a href="#fig:microsoft_store">figure_title</a>)． しばらく待つと， Ubuntu 20.04 のインストールが完了する．</p>
<p><img src="./assets/wsl/microsoft_store.png" alt="Microsoft store から Ubuntu 20.04 をインストール"></p>
<p>Ubuntu 20.04 を初回に起動すると，初期設定が自動で開始され，数分待つことになる． 初期設定が終わると，ユーザー名・パスワードを設定するようプロンプトが出るので，プロンプトに従い入力する．</p>
<p>これで WSL2 のインストールが完了した． 早速 WSL2 を起動してみよう． 左下の Windows メニューの検索バーに <code>Ubuntu</code> と入力すると， Ubuntu 20.04 のプログラムが見つかるはずである (<a href="#fig:ubuntu">figure_title</a>)． クリックして起動しよう．</p>
<p><img src="./assets/wsl/ubuntu2004.png" alt="Ubuntu 20.04 の起動"></p>
<p>すると，ターミナルの黒い画面が立ち上がるだろう (<a href="#fig:wsl_window">figure_title</a>)． <code>ls</code>, <code>top</code> などのコマンドを打ってみて， WSL がきちんと動作していることを確認しよう．</p>
<p><img src="./assets/wsl/wsl_window.png" alt="WSL の起動画面"></p>
<p>オプションとして， <a href="https://docs.microsoft.com/en-us/windows/terminal/get-started" target="_blank" rel="noreferrer">Windows Terminal</a> というマイクロソフトから提供されているツールを使うと，より快適に WSL を使用することができる． 興味のある読者はこちらのインストールも推奨する．</p>
<h2 id="docker-のインストール" tabindex="-1">Docker のインストール <a class="header-anchor" href="#docker-のインストール" aria-label="Permalink to &quot;Docker のインストール&quot;">&ZeroWidthSpace;</a></h2>
<p>Docker のインストールの方法は OS によって異なる．</p>
<p>Mac ユーザーは， Docker Desktop をインストールする． インストールの方法は， <a href="https://docs.docker.com/docker-for-mac/install/" target="_blank" rel="noreferrer">Docker のウェブサイト</a> から， Mac 版の Docker Desktop をダウンロードし，ダウンロードされたファイルをダブルクリックし， <code>Applications</code> のフォルダにドラッグするだけで良い． 詳細は <a href="https://docs.docker.com/docker-for-mac/install/" target="_blank" rel="noreferrer">公式ドキュメンテーション</a> を参照のこと．</p>
<p>Windows のユーザーは，Docker Desktop をインストールする． その際， WSL 2 が事前にインストールされていなければならない． 詳細は <a href="https://docs.docker.com/desktop/windows/install/" target="_blank" rel="noreferrer">公式ドキュメンテーション</a> を参照のこと． Docker Desktop をインストールすると， WSL からも <code>docker</code> コマンドが使用できるようになる．</p>
<p>Linux ユーザー (特に Ubuntu ユーザー) については，インストールの方法はいくつかのアプローチがある． <a href="https://docs.docker.com/engine/install/ubuntu/" target="_blank" rel="noreferrer">公式ドキュメンテーション</a> にいくつかのインストールの方法が示されているので，詳しい情報はそちらを参照いただきたい．</p>
<p>最も簡単な方法は， Docker が公式で提供しているインストールスクリプトを用いる方法である． この場合，次のコマンドを実行することで Docker がインストールされる．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">curl</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-fsSL</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">https://get.docker.com</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-o</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">get-docker.sh</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">sudo</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">sh</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">get-docker.sh</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">curl</span><span style="color: #24292E"> </span><span style="color: #005CC5">-fsSL</span><span style="color: #24292E"> </span><span style="color: #032F62">https://get.docker.com</span><span style="color: #24292E"> </span><span style="color: #005CC5">-o</span><span style="color: #24292E"> </span><span style="color: #032F62">get-docker.sh</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">sudo</span><span style="color: #24292E"> </span><span style="color: #032F62">sh</span><span style="color: #24292E"> </span><span style="color: #032F62">get-docker.sh</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>デフォルトのインストールでは， root ユーザーのみが <code>docker</code> コマンドを使用できる設定になっている． 従って，コマンドには毎回 <code>sudo</code> を付け加える必要がある． これが面倒だと感じる場合は，次のステップにより，使用するユーザーを <code>docker</code> というグループに追加する (詳細は <a href="https://docs.docker.com/engine/install/linux-postinstall/#manage-docker-as-a-non-root-user" target="_blank" rel="noreferrer">公式ドキュメンテーション &quot;Post-installation steps for Linux&quot;</a> を参照)．</p>
<p>まず最初に， <code>docker</code> という名前にグループを追加する． インストールによっては，既に <code>docker</code> グループが作られている場合もある．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">sudo</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">groupadd</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">docker</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">sudo</span><span style="color: #24292E"> </span><span style="color: #032F62">groupadd</span><span style="color: #24292E"> </span><span style="color: #032F62">docker</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>次に，現在使用しているユーザーを <code>docker</code> グループに加える．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">sudo</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">usermod</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-aG</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">docker</span><span style="color: #ADBAC7"> $USER</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">sudo</span><span style="color: #24292E"> </span><span style="color: #032F62">usermod</span><span style="color: #24292E"> </span><span style="color: #005CC5">-aG</span><span style="color: #24292E"> </span><span style="color: #032F62">docker</span><span style="color: #24292E"> $USER</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>ここまでできたら，一度ログアウトし，再度ログインする． これによって，グループの変更がターミナルのセッションに反映される．</p>
<p>設定が正しくできているかを確認するため，次のコマンドを実行してみる．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">docker</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">run</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">hello-world</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">docker</span><span style="color: #24292E"> </span><span style="color: #032F62">run</span><span style="color: #24292E"> </span><span style="color: #032F62">hello-world</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p><code>sudo</code> なしでコンテナが実行できたならば，設定は完了である．</p>
<h2 id="python-venv-クイックガイド" tabindex="-1">Python <code>venv</code> クイックガイド <a class="header-anchor" href="#python-venv-クイックガイド" aria-label="Permalink to &quot;Python `venv` クイックガイド&quot;">&ZeroWidthSpace;</a></h2>
<p>他人からもらったプログラムで， numpy や scipy のバージョンが違う！などの理由で，プログラムが動かない，という経験をしたことがある人は多いのではないだろうか． もし，自分の計算機の中に一つしか Python 環境がないとすると，プロジェクトを切り替えるごとに正しいバージョンをインストールし直さなければならず，これは大変な手間である．</p>
<p>コードのシェアをよりスムーズにするためには，ライブラリのバージョンはプロジェクトごとに管理されるべきである． それを可能にするのが Python 仮想環境とよばれるツールであり， <a href="https://docs.python.org/3/tutorial/venv.html" target="_blank" rel="noreferrer">venv</a>, <a href="https://github.com/pyenv/pyenv" target="_blank" rel="noreferrer">pyenv</a>, <a href="https://docs.conda.io/en/latest/" target="_blank" rel="noreferrer">conda</a> などがよく使われる．</p>
<p>そのなかでも， <code>venv</code> は Python に標準搭載されているのでとても便利である． <code>pyenv</code> や <code>conda</code> は，別途インストールの必要があるが，それぞれの長所もある．</p>
<p><code>venv</code> を使って仮想環境を作成するには，</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">python</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-m</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">venv</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.env</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">python</span><span style="color: #24292E"> </span><span style="color: #005CC5">-m</span><span style="color: #24292E"> </span><span style="color: #032F62">venv</span><span style="color: #24292E"> </span><span style="color: #032F62">.env</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>と実行する． これにより <code>.env/</code> というディレクトリが作られ，このディレクトリに依存するライブラリが保存されることになる．</p>
<p>この新たな仮想環境を起動するには</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">source</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">.env/bin/activate</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">source</span><span style="color: #24292E"> </span><span style="color: #032F62">.env/bin/activate</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>と実行する．</p>
<p>シェルのプロンプトに <code>(.env)</code> という文字が追加されていることを確認しよう (<a href="#fig_venv_prompt">figure_title</a>)． これが， &quot;いまあなたは venv の中にいますよ&quot; というしるしになる．</p>
<p><img src="./assets/venv_shell.png" alt="venv を起動したときのプロンプト"></p>
<p>仮想環境を起動すると，それ以降実行する <code>pip</code> コマンドは， <code>.env/</code> 以下にインストールされる．このようにして，プロジェクトごとに使うライブラリのバージョンを切り分けることができる．</p>
<p>Python では <code>requirements.txt</code> というファイルに依存ライブラリを記述するのが一般的な慣例である．他人からもらったプログラムに， <code>requirements.txt</code> が定義されていれば，</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">pip</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">install</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-r</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">requirements.txt</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">pip</span><span style="color: #24292E"> </span><span style="color: #032F62">install</span><span style="color: #24292E"> </span><span style="color: #005CC5">-r</span><span style="color: #24292E"> </span><span style="color: #032F62">requirements.txt</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>と実行することで，必要なライブラリをインストールし，瞬時に Python 環境を再現することができる．</p>
<p>venv による仮想環境を保存するディレクトリの名前は任意に選べることができるが， <code>.env</code> という名前を用いるのが一般的である．</p>
<h2 id="ハンズオン実行用の-docker-image-の使い方" tabindex="-1">ハンズオン実行用の Docker image の使い方 <a class="header-anchor" href="#ハンズオン実行用の-docker-image-の使い方" aria-label="Permalink to &quot;ハンズオン実行用の Docker image の使い方&quot;">&ZeroWidthSpace;</a></h2>
<p>ハンズオンを実行するために必要な， Node.js, Python, AWS CDK などがインストールされた Docker image を用意した． これを使用することで，自分のローカルマシンに諸々をインストールする必要なく，すぐにハンズオンのコードが実行できる．</p>
<p>ハンズオンのいくつかのコマンドは Docker の外 = ローカルマシンのリアル環境で実行されなければならない． それらについてはハンズオンの該当箇所に注意書きとして記してある．</p>
<p>Docker イメージは <a href="https://hub.docker.com/repository/docker/tomomano/labc" target="_blank" rel="noreferrer">Docker Hub</a> においてある． Docker イメージのビルドファイルは GitHub の <a href="https://github.com/tomomano/learn-aws-by-coding-source-code/blob/main/docker/Dockerfile" target="_blank" rel="noreferrer">docker/Dockerfile</a> にある．</p>
<p>次のコマンドでコンテナを起動する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">docker</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">run</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-it</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">tomomano/labc:latest</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">docker</span><span style="color: #24292E"> </span><span style="color: #032F62">run</span><span style="color: #24292E"> </span><span style="color: #005CC5">-it</span><span style="color: #24292E"> </span><span style="color: #032F62">tomomano/labc:latest</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>初回にコマンドを実行したときのみ，イメージが Docker Hub からダウンロード (pull) される． 二回目以降はローカルにダウンロードされたイメージが使用される．</p>
<p>コンテナが起動すると，次のようなインタラクティブシェルが表示されるはずである (起動時に <code>-it</code> のオプションをつけたのがポイントである)．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">root@aws-handson:~/programlisting</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">root@aws-handson:~/programlisting</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>この状態で <code>ls</code> コマンドを打つと， <code>handson/</code> というディレクトリがあるはずである． ここに <code>cd</code> する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">cd</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">handson</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">cd</span><span style="color: #24292E"> </span><span style="color: #032F62">handson</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>すると，各ハンズオンごとのディレクトリが見つかるはずである．</p>
<p>あとは，ハンズオンごとにディレクトリを移動し，ハンズオンごとの virtualenv を作成し，スタックのデプロイを行えばよい (<a href="#sec_handson_ec2_run">プログラムを実行する</a> など参照)． ハンズオンごとに使用する依存ライブラリが異なるので，それぞれのハンズオンごとに virtualenv を作成するという設計になっている．</p>
<p>AWS の認証情報を設定することも忘れずに． <a href="#aws_cli_install">AWS CLI のインストール</a> で記述したように， <code>AWS_ACCESS_KEY_ID</code> などの環境変数を設定するのが簡単な方法である． あるいは，<strong>ローカルマシンの</strong> <code>~/.aws/credentials</code> に認証情報が書き込まれているなら，このディレクトリをコンテナに<strong>マウント</strong>することで，同じ認証ファイルをコンテナ内部から参照することが可能である． この選択肢を取る場合は，次のコマンドでコンテナを起動する．</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">docker</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">run</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-it</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-v</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">~/.aws:/root/.aws:ro</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">tomomano/labc:latest</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">docker</span><span style="color: #24292E"> </span><span style="color: #032F62">run</span><span style="color: #24292E"> </span><span style="color: #005CC5">-it</span><span style="color: #24292E"> </span><span style="color: #005CC5">-v</span><span style="color: #24292E"> </span><span style="color: #032F62">~/.aws:/root/.aws:ro</span><span style="color: #24292E"> </span><span style="color: #032F62">tomomano/labc:latest</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>これにより，ローカルマシンの <code>~/.aws</code> をコンテナの <code>/root/.aws</code> にマウントすることができる． 最後の <code>:ro</code> は read-only を意味する． 大切な認証ファイルが誤って書き換えられてしまわないように， read-only のフラグをつけることをおすすめする．</p>
<p><code>/root/</code> がコンテナ環境におけるホームディレクトリである． ここで紹介した認証ファイルをマウントするテクニックは， SSH 鍵をコンテナに渡すときなどにも使える．</p>
<h1 id="ライセンス" tabindex="-1">ライセンス <a class="header-anchor" href="#ライセンス" aria-label="Permalink to &quot;ライセンス&quot;">&ZeroWidthSpace;</a></h1>
<p>本教科書およびハンズオンのソースコードは <a href="https://creativecommons.org/licenses/by-nc-nd/4.0/" target="_blank" rel="noreferrer">CC BY-NC-ND 4.0</a> に従うライセンスで公開しています．</p>
<p>教育など非商用の目的での本教科書の使用や再配布は自由に行うことが可能です． 商用目的で本書の全体またはその一部を無断で転載する行為は，これを固く禁じます．</p>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[クラウドで行う科学計算・機械学習 ]]></title>
            <link>https://note.toshiki.devdevelopment/aws/scientific-computing</link>
            <guid>https://note.toshiki.devdevelopment/aws/scientific-computing</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="クラウドで行う科学計算・機械学習" tabindex="-1">クラウドで行う科学計算・機械学習 <a class="header-anchor" href="#クラウドで行う科学計算・機械学習" aria-label="Permalink to &quot;クラウドで行う科学計算・機械学習&quot;">&ZeroWidthSpace;</a></h1>
<p>計算機が発達した現代では，計算機によるシミュレーションやビッグデータの解析は，科学・エンジニアリングの研究の主要な柱である． これらの大規模な計算を実行するには，クラウドは最適である． 本章から始まる第二部では，どのようにしてクラウド上で科学計算を実行するのかを，ハンズオンとともに体験してもらう． 科学計算の具体的な題材として，今回は機械学習(深層学習)を取り上げる．</p>
<p>なお，本書では <a href="https://pytorch.org/" target="_blank" rel="noreferrer">PyTorch</a> ライブラリを使って深層学習のアルゴリズムを実装するが，深層学習および PyTorch の知識は不要である． 講義ではなぜ・どうやって深層学習をクラウドで実行するかに主眼を置いているので，実行するプログラムの詳細には立ち入らない． 将来，自分で深層学習を使う機会が来たときに，詳しく学んでもらいたい．</p>
<h2 id="なぜ機械学習をクラウドで行うのか" tabindex="-1">なぜ機械学習をクラウドで行うのか？ <a class="header-anchor" href="#なぜ機械学習をクラウドで行うのか" aria-label="Permalink to &quot;なぜ機械学習をクラウドで行うのか？&quot;">&ZeroWidthSpace;</a></h2>
<p>2010 年頃に始まった第三次 AI ブームのおかげで，学術研究だけでなく社会・ビジネスの文脈でも機械学習に高い関心が寄せられている． とくに，<strong>深層学習 (ディープラーニング)</strong> とよばれる多層のレイヤーからなるニューラルネットワークを用いたアルゴリズムは，画像認識や自然言語処理などの分野で圧倒的に高い性能を実現し，革命をもたらしている．</p>
<p>深層学習の特徴は，なんといってもそのパラメータの多さである． 層が深くなるほど，層間のニューロンを結ぶ重みパラメータの数が増大していく． たとえば，最新の言語モデルである <a href="https://arxiv.org/abs/2005.14165" target="_blank" rel="noreferrer">GPT-3</a> には<strong>1750 億個</strong>ものパラメータが含まれている． このような膨大なパラメータを有することで，深層学習は高い表現力と汎化性能を実現しているのである．</p>
<p>GPT-3 に限らず，最近の SOTA (State-of-the-art) の性能を達成するニューラルネットワークでは，百万から億のオーダーのパラメータを内包することは頻繁になってきている． そのような巨大なニューラルネットを訓練 (最適化) させるのは，当然のことながら膨大な計算コストがかかる． 結果として，ひとつの計算機では丸一日以上の時間がかかる場合も珍しくない． 深層学習の発展の速度は目覚ましく，研究・ビジネス両方の観点からも，いかにスループットよくニューラルネットワークの最適化を行えるかが鍵となってくる． そのような問題を解決するのにとても有効な手段が，クラウドである！ (#sec_first_ec2) でその片鱗を見たように，クラウドを使用することでゼロから数千に至るまでの数のインスタンスを動的に起動し，並列に計算を実行することができる． さらに，深層学習を加速させる目的で，深層学習の演算に専用設計された計算チップ (GPU など) がある． クラウドを利用すると，そのような専用計算チップも無尽蔵に利用することができる． 事実，先述した GPT-3 の学習も，詳細は明かされていないが，Microsoft 社のクラウドを使って行われたと報告されている．</p>
<h2 id="gpu-による深層学習の高速化" tabindex="-1">GPU による深層学習の高速化 <a class="header-anchor" href="#gpu-による深層学習の高速化" aria-label="Permalink to &quot;GPU による深層学習の高速化&quot;">&ZeroWidthSpace;</a></h2>
<p>深層学習の計算で欠かすことのできない技術として， <strong>GPU (Graphics Processing Unit)</strong> について少し説明する．</p>
<p>GPU は，その名のとおり，元々はコンピュータグラフィックスを出力するための専用計算チップである． CPU (Central Processing Unit) に対し，グラフィックスの演算に特化した設計がなされている． 身近なところでは， XBox や PS5 などのゲームコンソールなどに搭載されているし，ハイエンドなノート型・デスクトップ型計算機にも搭載されていることがある． コンピュータグラフィックスでは，スクリーンにアレイ状に並んだ数百万個の画素をビデオレート (30 fps) 以上で処理する必要がある． そのため，GPU はコアあたりの演算能力は比較的小さいかわりに，チップあたり数百から数千のコアを搭載しており (<a href="#gpu_architecture">figure_title</a>)，スクリーンの画素を並列的に処理することで，リアルタイムでの描画を実現している．</p>
<p><img src="./assets/gpu_architecture.jpg" alt="GPUのアーキテクチャ．GPUには数百から数千の独立した計算コアが搭載されている． (画像出典: https://devblogs.nvidia.com/nvidia-turing-architecture-in-depth/)"></p>
<p>このように，コンピュータグラフィクスの目的で生まれた GPU だが，2010 年前後から，その高い並列計算能力をグラフィックス以外の計算 (科学計算など) に用いるという流れ (<strong>General-purpose computing on GPU; GPGPU</strong>) が生まれた． GPU のコアは，その設計から，行列の計算など，単純かつ規則的な演算が得意であり，そのような演算に対しては数個程度のコアしかもたない CPU に比べて圧倒的に高い計算速度を実現することができる． 現在では GPGPU は分子動力学や気象シミュレーション，そして機械学習など多くの分野で使われている．</p>
<p>ディープラーニングで最も頻繁に起こる演算が，ニューロンの出力を次の層のニューロンに伝える<strong>畳み込み (Convolution)</strong> 演算である (<a href="#fig:convolution">figure_title</a>)． 畳み込み演算は，まさに GPU が得意とする演算であり， CPU ではなく GPU を用いることで学習を飛躍的に (最大で数百倍程度) 加速させることができる．</p>
<p><img src="./assets/cnn.png" alt="ニューラルネットワークにおける畳み込み演算．"></p>
<p>このように GPU は機械学習の計算で欠かせないものであるが，なかなか高価である． たとえば，科学計算・機械学習に専用設計された NVIDIA 社の Tesla V100 というチップは，一台で約百万円の価格が設定されている． 機械学習を始めるのに，いきなり百万円の投資はなかなか大きい． だが，クラウドを使えば，初期コスト０で GPU を使用することができる．</p>
<p>機械学習を行うのに， V100 が必ずしも必要というわけではない． むしろ，研究者などでしばしば行われるのは，コンピュータゲームに使われるグラフィックス用の GPU を買ってきて (NVIDIA GeForce シリーズなど)，開発のときはをそれを用いる，というアプローチである． グラフィックス用のいわゆる&quot;コンシューマ GPU&quot;は，市場の需要が大きいおかげで，10 万円前後の価格で購入することができる． V100 と比べると，コンシューマ GPU はコアの数が少なかったり，メモリーが小さかったりなどで劣る点があるが， それらを除いては計算能力にとくに制限があるわけではなく，開発の段階では十分な性能である場合がほとんどである． プログラムができあがって，ビッグデータの解析や，モデルをさらに大きくしたいときなどに，クラウドは有効だろう．</p>
<p>クラウドで GPU を使うには， GPU が搭載された EC2 インスタンスタイプ (<code>P3</code>, <code>P2</code>, <code>G3</code>, <code>G4</code> など) を選択しなければならない． <a href="#table_gpu_instances">table_title</a> に，代表的な GPU 搭載のインスタンスタイプを挙げる (執筆時点での情報)．</p>
<table style="width:100%;"><caption>GPUを搭載したEC2インスタンスタイプ</caption><colgroup><col style="width: 14%" /><col style="width: 14%" /><col style="width: 14%" /><col style="width: 14%" /><col style="width: 14%" /><col style="width: 14%" /><col style="width: 14%" /></colgroup><thead><tr class="header"><th>Instance</th><th>GPUs</th><th>GPU model</th><th>GPU Mem (GiB)</th><th>vCPU</th><th>Mem (GiB)</th><th>Price per hour ($)</th></tr></thead><tbody><tr class="odd"><td><p>p3.2xlarge</p></td><td><p>1</p></td><td><p>NVIDIA V100</p></td><td><p>16</p></td><td><p>8</p></td><td><p>61</p></td><td><p>3.06</p></td></tr><tr class="even"><td><p>p3n.16xlarge</p></td><td><p>8</p></td><td><p>NVIDIA V100</p></td><td><p>128</p></td><td><p>64</p></td><td><p>488</p></td><td><p>24.48</p></td></tr><tr class="odd"><td><p>p2.xlarge</p></td><td><p>1</p></td><td><p>NVIDIA K80</p></td><td><p>12</p></td><td><p>4</p></td><td><p>61</p></td><td><p>0.9</p></td></tr><tr class="even"><td><p>g4dn.xlarge</p></td><td><p>1</p></td><td><p>NVIDIA T4</p></td><td><p>16</p></td><td><p>4</p></td><td><p>16</p></td><td><p>0.526</p></td></tr></tbody></table>
<p><a href="#table_gpu_instances">table_title</a> からわかるとおり， CPU のみのインスタンスと比べると少し高い価格設定になっている． また，古い世代の GPU (V100 に対しての K80) はより安価な価格で提供されている． 1 インスタンスあたりの GPU の搭載数は 1 台から最大で 8 台まで選択することが可能である．</p>
<p>GPU を搭載した一番安いインスタンスタイプは， <code>g4dn.xlarge</code> であり，これには廉価かつ省エネルギー設計の NVIDIA T4 が搭載されている． 後のハンズオンでは，このインスタンスを使用して，ディープラーニングの計算を行ってみる．</p>
<p><a href="#table_gpu_instances">table_title</a> の価格は <code>us-east-1</code> のものである． リージョンによって多少価格設定が異なる．</p>
<p>V100 を一台搭載した <code>p3.2xlarge</code> の利用料金は一時間あたり $3.06 である． V100 が約百万円で売られていることを考えると，約 3000 時間 (= 124 日間)，通算で計算を行った場合に，クラウドを使うよりも V100 を自分で買ったほうがお得になる，という計算になる (実際には，自前で V100 を用意する場合は， V100 だけでなく， CPU やネットワーク機器，電気使用料も必要なので，百万円よりもさらにコストがかかる)．</p>
<p>GPT-3 で使われた計算リソースの詳細は論文でも明かされていないのだが， <a href="https://lambdalabs.com/blog/demystifying-gpt-3/" target="_blank" rel="noreferrer">Lambda 社のブログ</a>で興味深い考察が行われている (Lambda 社は機械学習に特化したクラウドサービスを提供している)．</p>
<p>記事によると，1750 億のパラメータを訓練するには，一台の GPU (NVIDIA V100) を用いた場合，342 年の月日と 460 万ドルのクラウド利用料が必要となる，とのことである． GPT-3 のチームは，複数の GPU に処理を分散することで現実的な時間のうちに訓練を完了させたのであろうが，このレベルのモデルになってくるとクラウド技術の限界を攻めないと達成できないことは確かである．</p>
<p>深層学習を詳しく勉強したい人には以下の参考書を推薦したい． 深層学習の基礎的な概念や理論は普遍的であるが，この分野は日進月歩なので，常に最新の情報を取り入れることを忘れずに．</p>
<ul>
<li>
<p><a href="https://www.deeplearningbook.org/" target="_blank" rel="noreferrer">Deep Learning (Ian Goodfellow, Yoshua Bengio and Aaron Courville)</a> 出版されてから数年が経つが，深層学習の理論的な側面を学びたいならばおすすめの入門書． ウェブで無料で読むことができる． 日本語版も出版されている． 実装についてはほとんど触れられていないので，理論家向けの本．</p>
</li>
<li>
<p><a href="https://www.oreilly.co.jp/books/9784873117584/" target="_blank" rel="noreferrer">ゼロから作る Deep Learning (斎藤 康毅)</a> 合計三冊からなるシリーズ． 理論と実装がバランスよく説明されていて，深層学習の入門書の決定版．</p>
</li>
<li>
<p><a href="https://d2l.ai/" target="_blank" rel="noreferrer">Dive into Deep Learning (Aston Zhang, Zachary C. Lipton, Mu Li, and Alexander J. Smola)</a> 深層学習の基礎から最新のアルゴリズムまでを，実装を通して学んでいくスタイルの本． ウェブで無料で読むことができる，1000 ページ越えの超大作． これを読破することができれば，深層学習の実装で困ることはないだろう．</p>
</li>
</ul>
]]></description>
            <content:encoded><![CDATA[<h1 id="クラウドで行う科学計算・機械学習" tabindex="-1">クラウドで行う科学計算・機械学習 <a class="header-anchor" href="#クラウドで行う科学計算・機械学習" aria-label="Permalink to &quot;クラウドで行う科学計算・機械学習&quot;">&ZeroWidthSpace;</a></h1>
<p>計算機が発達した現代では，計算機によるシミュレーションやビッグデータの解析は，科学・エンジニアリングの研究の主要な柱である． これらの大規模な計算を実行するには，クラウドは最適である． 本章から始まる第二部では，どのようにしてクラウド上で科学計算を実行するのかを，ハンズオンとともに体験してもらう． 科学計算の具体的な題材として，今回は機械学習(深層学習)を取り上げる．</p>
<p>なお，本書では <a href="https://pytorch.org/" target="_blank" rel="noreferrer">PyTorch</a> ライブラリを使って深層学習のアルゴリズムを実装するが，深層学習および PyTorch の知識は不要である． 講義ではなぜ・どうやって深層学習をクラウドで実行するかに主眼を置いているので，実行するプログラムの詳細には立ち入らない． 将来，自分で深層学習を使う機会が来たときに，詳しく学んでもらいたい．</p>
<h2 id="なぜ機械学習をクラウドで行うのか" tabindex="-1">なぜ機械学習をクラウドで行うのか？ <a class="header-anchor" href="#なぜ機械学習をクラウドで行うのか" aria-label="Permalink to &quot;なぜ機械学習をクラウドで行うのか？&quot;">&ZeroWidthSpace;</a></h2>
<p>2010 年頃に始まった第三次 AI ブームのおかげで，学術研究だけでなく社会・ビジネスの文脈でも機械学習に高い関心が寄せられている． とくに，<strong>深層学習 (ディープラーニング)</strong> とよばれる多層のレイヤーからなるニューラルネットワークを用いたアルゴリズムは，画像認識や自然言語処理などの分野で圧倒的に高い性能を実現し，革命をもたらしている．</p>
<p>深層学習の特徴は，なんといってもそのパラメータの多さである． 層が深くなるほど，層間のニューロンを結ぶ重みパラメータの数が増大していく． たとえば，最新の言語モデルである <a href="https://arxiv.org/abs/2005.14165" target="_blank" rel="noreferrer">GPT-3</a> には<strong>1750 億個</strong>ものパラメータが含まれている． このような膨大なパラメータを有することで，深層学習は高い表現力と汎化性能を実現しているのである．</p>
<p>GPT-3 に限らず，最近の SOTA (State-of-the-art) の性能を達成するニューラルネットワークでは，百万から億のオーダーのパラメータを内包することは頻繁になってきている． そのような巨大なニューラルネットを訓練 (最適化) させるのは，当然のことながら膨大な計算コストがかかる． 結果として，ひとつの計算機では丸一日以上の時間がかかる場合も珍しくない． 深層学習の発展の速度は目覚ましく，研究・ビジネス両方の観点からも，いかにスループットよくニューラルネットワークの最適化を行えるかが鍵となってくる． そのような問題を解決するのにとても有効な手段が，クラウドである！ (#sec_first_ec2) でその片鱗を見たように，クラウドを使用することでゼロから数千に至るまでの数のインスタンスを動的に起動し，並列に計算を実行することができる． さらに，深層学習を加速させる目的で，深層学習の演算に専用設計された計算チップ (GPU など) がある． クラウドを利用すると，そのような専用計算チップも無尽蔵に利用することができる． 事実，先述した GPT-3 の学習も，詳細は明かされていないが，Microsoft 社のクラウドを使って行われたと報告されている．</p>
<h2 id="gpu-による深層学習の高速化" tabindex="-1">GPU による深層学習の高速化 <a class="header-anchor" href="#gpu-による深層学習の高速化" aria-label="Permalink to &quot;GPU による深層学習の高速化&quot;">&ZeroWidthSpace;</a></h2>
<p>深層学習の計算で欠かすことのできない技術として， <strong>GPU (Graphics Processing Unit)</strong> について少し説明する．</p>
<p>GPU は，その名のとおり，元々はコンピュータグラフィックスを出力するための専用計算チップである． CPU (Central Processing Unit) に対し，グラフィックスの演算に特化した設計がなされている． 身近なところでは， XBox や PS5 などのゲームコンソールなどに搭載されているし，ハイエンドなノート型・デスクトップ型計算機にも搭載されていることがある． コンピュータグラフィックスでは，スクリーンにアレイ状に並んだ数百万個の画素をビデオレート (30 fps) 以上で処理する必要がある． そのため，GPU はコアあたりの演算能力は比較的小さいかわりに，チップあたり数百から数千のコアを搭載しており (<a href="#gpu_architecture">figure_title</a>)，スクリーンの画素を並列的に処理することで，リアルタイムでの描画を実現している．</p>
<p><img src="./assets/gpu_architecture.jpg" alt="GPUのアーキテクチャ．GPUには数百から数千の独立した計算コアが搭載されている． (画像出典: https://devblogs.nvidia.com/nvidia-turing-architecture-in-depth/)"></p>
<p>このように，コンピュータグラフィクスの目的で生まれた GPU だが，2010 年前後から，その高い並列計算能力をグラフィックス以外の計算 (科学計算など) に用いるという流れ (<strong>General-purpose computing on GPU; GPGPU</strong>) が生まれた． GPU のコアは，その設計から，行列の計算など，単純かつ規則的な演算が得意であり，そのような演算に対しては数個程度のコアしかもたない CPU に比べて圧倒的に高い計算速度を実現することができる． 現在では GPGPU は分子動力学や気象シミュレーション，そして機械学習など多くの分野で使われている．</p>
<p>ディープラーニングで最も頻繁に起こる演算が，ニューロンの出力を次の層のニューロンに伝える<strong>畳み込み (Convolution)</strong> 演算である (<a href="#fig:convolution">figure_title</a>)． 畳み込み演算は，まさに GPU が得意とする演算であり， CPU ではなく GPU を用いることで学習を飛躍的に (最大で数百倍程度) 加速させることができる．</p>
<p><img src="./assets/cnn.png" alt="ニューラルネットワークにおける畳み込み演算．"></p>
<p>このように GPU は機械学習の計算で欠かせないものであるが，なかなか高価である． たとえば，科学計算・機械学習に専用設計された NVIDIA 社の Tesla V100 というチップは，一台で約百万円の価格が設定されている． 機械学習を始めるのに，いきなり百万円の投資はなかなか大きい． だが，クラウドを使えば，初期コスト０で GPU を使用することができる．</p>
<p>機械学習を行うのに， V100 が必ずしも必要というわけではない． むしろ，研究者などでしばしば行われるのは，コンピュータゲームに使われるグラフィックス用の GPU を買ってきて (NVIDIA GeForce シリーズなど)，開発のときはをそれを用いる，というアプローチである． グラフィックス用のいわゆる&quot;コンシューマ GPU&quot;は，市場の需要が大きいおかげで，10 万円前後の価格で購入することができる． V100 と比べると，コンシューマ GPU はコアの数が少なかったり，メモリーが小さかったりなどで劣る点があるが， それらを除いては計算能力にとくに制限があるわけではなく，開発の段階では十分な性能である場合がほとんどである． プログラムができあがって，ビッグデータの解析や，モデルをさらに大きくしたいときなどに，クラウドは有効だろう．</p>
<p>クラウドで GPU を使うには， GPU が搭載された EC2 インスタンスタイプ (<code>P3</code>, <code>P2</code>, <code>G3</code>, <code>G4</code> など) を選択しなければならない． <a href="#table_gpu_instances">table_title</a> に，代表的な GPU 搭載のインスタンスタイプを挙げる (執筆時点での情報)．</p>
<table style="width:100%;"><caption>GPUを搭載したEC2インスタンスタイプ</caption><colgroup><col style="width: 14%" /><col style="width: 14%" /><col style="width: 14%" /><col style="width: 14%" /><col style="width: 14%" /><col style="width: 14%" /><col style="width: 14%" /></colgroup><thead><tr class="header"><th>Instance</th><th>GPUs</th><th>GPU model</th><th>GPU Mem (GiB)</th><th>vCPU</th><th>Mem (GiB)</th><th>Price per hour ($)</th></tr></thead><tbody><tr class="odd"><td><p>p3.2xlarge</p></td><td><p>1</p></td><td><p>NVIDIA V100</p></td><td><p>16</p></td><td><p>8</p></td><td><p>61</p></td><td><p>3.06</p></td></tr><tr class="even"><td><p>p3n.16xlarge</p></td><td><p>8</p></td><td><p>NVIDIA V100</p></td><td><p>128</p></td><td><p>64</p></td><td><p>488</p></td><td><p>24.48</p></td></tr><tr class="odd"><td><p>p2.xlarge</p></td><td><p>1</p></td><td><p>NVIDIA K80</p></td><td><p>12</p></td><td><p>4</p></td><td><p>61</p></td><td><p>0.9</p></td></tr><tr class="even"><td><p>g4dn.xlarge</p></td><td><p>1</p></td><td><p>NVIDIA T4</p></td><td><p>16</p></td><td><p>4</p></td><td><p>16</p></td><td><p>0.526</p></td></tr></tbody></table>
<p><a href="#table_gpu_instances">table_title</a> からわかるとおり， CPU のみのインスタンスと比べると少し高い価格設定になっている． また，古い世代の GPU (V100 に対しての K80) はより安価な価格で提供されている． 1 インスタンスあたりの GPU の搭載数は 1 台から最大で 8 台まで選択することが可能である．</p>
<p>GPU を搭載した一番安いインスタンスタイプは， <code>g4dn.xlarge</code> であり，これには廉価かつ省エネルギー設計の NVIDIA T4 が搭載されている． 後のハンズオンでは，このインスタンスを使用して，ディープラーニングの計算を行ってみる．</p>
<p><a href="#table_gpu_instances">table_title</a> の価格は <code>us-east-1</code> のものである． リージョンによって多少価格設定が異なる．</p>
<p>V100 を一台搭載した <code>p3.2xlarge</code> の利用料金は一時間あたり $3.06 である． V100 が約百万円で売られていることを考えると，約 3000 時間 (= 124 日間)，通算で計算を行った場合に，クラウドを使うよりも V100 を自分で買ったほうがお得になる，という計算になる (実際には，自前で V100 を用意する場合は， V100 だけでなく， CPU やネットワーク機器，電気使用料も必要なので，百万円よりもさらにコストがかかる)．</p>
<p>GPT-3 で使われた計算リソースの詳細は論文でも明かされていないのだが， <a href="https://lambdalabs.com/blog/demystifying-gpt-3/" target="_blank" rel="noreferrer">Lambda 社のブログ</a>で興味深い考察が行われている (Lambda 社は機械学習に特化したクラウドサービスを提供している)．</p>
<p>記事によると，1750 億のパラメータを訓練するには，一台の GPU (NVIDIA V100) を用いた場合，342 年の月日と 460 万ドルのクラウド利用料が必要となる，とのことである． GPT-3 のチームは，複数の GPU に処理を分散することで現実的な時間のうちに訓練を完了させたのであろうが，このレベルのモデルになってくるとクラウド技術の限界を攻めないと達成できないことは確かである．</p>
<p>深層学習を詳しく勉強したい人には以下の参考書を推薦したい． 深層学習の基礎的な概念や理論は普遍的であるが，この分野は日進月歩なので，常に最新の情報を取り入れることを忘れずに．</p>
<ul>
<li>
<p><a href="https://www.deeplearningbook.org/" target="_blank" rel="noreferrer">Deep Learning (Ian Goodfellow, Yoshua Bengio and Aaron Courville)</a> 出版されてから数年が経つが，深層学習の理論的な側面を学びたいならばおすすめの入門書． ウェブで無料で読むことができる． 日本語版も出版されている． 実装についてはほとんど触れられていないので，理論家向けの本．</p>
</li>
<li>
<p><a href="https://www.oreilly.co.jp/books/9784873117584/" target="_blank" rel="noreferrer">ゼロから作る Deep Learning (斎藤 康毅)</a> 合計三冊からなるシリーズ． 理論と実装がバランスよく説明されていて，深層学習の入門書の決定版．</p>
</li>
<li>
<p><a href="https://d2l.ai/" target="_blank" rel="noreferrer">Dive into Deep Learning (Aston Zhang, Zachary C. Lipton, Mu Li, and Alexander J. Smola)</a> 深層学習の基礎から最新のアルゴリズムまでを，実装を通して学んでいくスタイルの本． ウェブで無料で読むことができる，1000 ページ越えの超大作． これを読破することができれば，深層学習の実装で困ることはないだろう．</p>
</li>
</ul>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Serverless architecture ]]></title>
            <link>https://note.toshiki.devdevelopment/aws/serverless</link>
            <guid>https://note.toshiki.devdevelopment/aws/serverless</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="serverless-architecture" tabindex="-1">Serverless architecture <a class="header-anchor" href="#serverless-architecture" aria-label="Permalink to &quot;Serverless architecture&quot;">&ZeroWidthSpace;</a></h1>
<p>サーバーレスアーキテクチャ (Serverless architecture) あるいは サーバーレスコンピューティング (Serverless computing) とは，従来とは全く異なるアプローチに基づくクラウドシステムの設計方法である． 歴史的には， AWS が 2014 年に発表した <a href="https://aws.amazon.com/lambda/" target="_blank" rel="noreferrer">Lamba</a> がサーバーレスアーキテクチャの先駆けとされている． その後， Google や Microsoft などのクラウドプラットフォームも同様の機能の提供を開始している． サーバーレスアーキテクチャの利点は，スケーラブルなクラウドシステムを安価かつ簡易に作成できる点であり，近年いたるところで導入が進んでいる．</p>
<p>Serverless とは，文字どおりの意味としてはサーバーなしで計算をするということになるが，それは一体どういう意味だろうか？ サーバーレスについて説明するためには，まずは従来的な， &quot;serverful&quot; とよばれるようなシステムについて解説しなければならない．</p>
<h2 id="serverful-クラウド-従来型" tabindex="-1">Serverful クラウド (従来型) <a class="header-anchor" href="#serverful-クラウド-従来型" aria-label="Permalink to &quot;Serverful クラウド (従来型)&quot;">&ZeroWidthSpace;</a></h2>
<p>従来的なクラウドシステムのスケッチを <a href="#serverful">figure_title</a> に示す． クライアントから送信されたリクエストは，最初に API サーバーに送られる． API サーバーでは，リクエストの内容に応じてタスクが実行される． タスクには，API サーバーだけで完結できるものもあるが，多くの場合，データベースの読み書きが必要である． データベースには，データベース専用の独立したサーバーマシンが用いられることが一般的である． また，画像や動画などの容量の大きいデータは，また別のストレージサーバーに保存されることが多い． これらの API サーバー，データベースサーバー，ストレージサーバーはそれぞれ独立したサーバーマシンであり， AWS の言葉では EC2 による仮想インスタンスを想定してもらったらよい．</p>
<p>多くのウェブサービスでは，多数のクライアントからのリクエストを処理するため，複数のサーバーマシンがクラウド内で起動し，負荷を分散するような設計がなされている． クライアントから来たリクエストを計算容量に余裕のあるサーバーに振り分けるような操作を <strong>Load balancing</strong> とよび，そのような操作を担当するマシンのことを <strong>Load balancer</strong> という．</p>
<p>計算負荷を分散する目的で多数のインスタンスを起動するのはよいのだが，計算負荷が小さすぎてアイドリング状態にあるようではコストと電力の無駄遣いである． したがって，すべてのサーバーが常に目標とする計算負荷を維持するよう，計算の負荷に応じてクラスター内の仮想サーバーの数を動的に増減させるような仕組みが必要である． そのような仕組みを<strong>クラスターのスケーリング</strong>とよび，負荷の増大に応答して新しい仮想インスタンスをクラスターに追加する操作を <strong>scale-out</strong>，負荷の減少に応答してインスタンスをシャットダウンする操作を <strong>scale-in</strong> とよぶ． クラスターのスケーリングは， API サーバーではもちろんのこと，データベースサーバー・ストレージサーバーでも必要になる． ストレージサーバーでは，例えば頻繁にアクセスされるデータはキャッシュ領域に保存したり，データのコピーを複数作るなどのスケーリングが行われる． データベースサーバーも同様に，頻繁にアクセスされるデータのアクセスがパンクしてしまわないよう，分散的な処理が必要となる． このように，<strong>クラウドシステム内すべての箇所で，負荷が均一になるような調整が必要であり，開発者は多くの時間をそのチューニングに費やさなければならない．</strong> また，サービスの利用者の数などに応じてスケーリングの設定は常に見直される必要があり，継続的な開発が要求される．</p>
<p>さらに問題を複雑にするのは，API サーバーで処理されるべきタスクが，非一様な点である． 非一様であるとは，たとえばタスク A は 3000 ミリ秒の実行時間と 512MB のメモリーを消費し，別のタスク B は 1000 ミリ秒の実行時間と 128MB のメモリーを消費する，というような状況を指している． 一つのサーバーマシンが計算負荷が異なる複数のタスクを処理する場合，クラスターのスケーリングはより複雑になる． この状況をシンプルにするために，１サーバーで実行するタスクは１種類に限る，という設計も可能であるが，そうするとで生まれる弊害も多い (ほとんど使われないタスクに対してもサーバー一台をまるまる割り当てなければならない = ほとんどアイドリング状態になってしまう，など)．</p>
<p><img src="./assets/serverful.png" alt="Serverful なクラウドシステム"></p>
<h2 id="serverless-クラウドへ" tabindex="-1">Serverless クラウドへ <a class="header-anchor" href="#serverless-クラウドへ" aria-label="Permalink to &quot;Serverless クラウドへ&quot;">&ZeroWidthSpace;</a></h2>
<p><a href="#chap_serverful_cloud">Serverful クラウド (従来型)</a> で議論したように，クラスターのスケーリングはクラウドシステムの経済的効率とシステムの安定性を最大化するために必須の作業である． それを反映して，多くの開発者の時間が投資されてきた．</p>
<p>クラスターのスケーリングはすべての開発者が何度も繰り返し行ってきた作業であり，いくつかの側面をテンプレート化し，共通化することができたならば開発のコストを大幅に削減できるだろう． それを実現するには，根本的なレベルからクラウドシステムの設計を考え直す必要がある． <strong>スケーリングを前提</strong>として考えることで，もっと<strong>シンプルで見通しがよいクラウドシステムの設計の仕組みはないだろうか</strong>？ そのような動機が，サーバーレスアーキテクチャが誕生する背後にあった．</p>
<p>従来の serverful なシステムでの最大の問題点は，<strong>サーバーをまるまる占有してしまう</strong>という点にある． すなわち， EC2 インスタンスを起動したとき，そのインスタンスは起動したユーザーだけが使えるものであり，<strong>計算のリソース (CPU や RAM) が独占的に割り当てられた状態</strong>になる． 固定した計算資源の割り当てがされてしまっているので，<strong>インスタンスの計算負荷が 0%であろうが 100%であろうが，均一の使用料金が起動時間に比例</strong>して発生する．</p>
<p>サーバーレスアーキテクチャは，このような <strong>独占的に割り当てられた計算リソースというものを完全に廃止する</strong>ことを出発点とする． サーバーレスアーキテクチャでは，計算のリソースは，クラウドプロバイダーがすべて管理する． クライアントは，仮想インスタンスを一台まるごと借りるのではなく，計算のタスクの需要が生まれる毎に，<strong>実行したいプログラム・コマンドをクラウドに提出する</strong>． クラウドプロバイダーは，自身のもつ巨大な計算リソースから空きを探し，提出されたプログラムを実行し，実行結果をクライアントに返す． 言い換えると，計算リソースのスケーリングやアロケーションなどはクラウドプロバイダーが一手に引き受け，ユーザーはジョブをサブミットすることに注力する，という枠組みである． これを図示すると， <a href="#serverless">figure_title</a> のようになる．</p>
<p><img src="./assets/serverless.png" alt="従来のクラウドと Serverless クラウドの比較"></p>
<p>サーバーレスクラウドでは，スケーリングはすべてクラウドプロバイダーが引き受けるので，スケーラビリティーが保証されている． クライアントが同時に大量のタスクを送信した場合でも，クラウドプロバイダー側の独自の仕組みによってすべてのタスクが遅延なく実行される． また，サーバーレスクラウドを利用することで，<strong>クラウドのコストは実際に使用した計算の総量 (稼働時間) で決定される</strong>ことになる． これは，計算の実行総量に関わらずインスタンスの起動時間で料金が決定されていた従来のシステムと比べて大きな違いである．</p>
<p>サーバーレスクラウドは，従来のクラウドとは根本から異なったアプローチなので，コードの書き方やシステムの設計が大きく異なる． サーバーレスクラウドを開発・運用するには，サーバーレス固有の概念や用語に精通している必要がある． 以降では，実際にクラウドを動かしながら，サーバーレスをより具体的に体験していこう．</p>
<p>従来型の(仮想インスタンスをたくさん起動するような)クラウドシステムは，<strong>賃貸</strong>と似ているかもしれない． 部屋を借りるというのは，その部屋でどれだけの時間を過ごそうが，月々の家賃は一定である． 同様に，仮想サーバーも，それがどれほどの計算を行っているかに関わらず，一定の料金が時間ごとに発生する．</p>
<p>一方で，サーバーレスクラウドは，<strong>電気・水道・ガス料金</strong> と似ている． こちらは，実際に使用した量に比例して料金が決定されている． サーバーレスクラウドも，実際に計算を行った総時間で料金が決まる仕組みになっている．</p>
<h2 id="サーバーレスクラウドを構成するコンポーネント" tabindex="-1">サーバーレスクラウドを構成するコンポーネント <a class="header-anchor" href="#サーバーレスクラウドを構成するコンポーネント" aria-label="Permalink to &quot;サーバーレスクラウドを構成するコンポーネント&quot;">&ZeroWidthSpace;</a></h2>
<p>サーバーレスアーキテクチャの概要がわかってきたところで，ここでは AWS においてサーバーレスクラウドを構成する様々なコンポーネントを紹介していこう． 特に， <strong>Lambda</strong>, <strong>S3</strong>, <strong>DynamoDB</strong> を取り上げ，解説する (<a href="#fig:serverless_logos">figure_title</a>)． サーバーレスクラウドは，これらのコンポーネントを統合することで一つのシステムが出来上がる． ここでは， Lambda，S3，DynamoDB を利用する際に押さえておかなければならない知識を一通り説明しきる都合上，具体的なイメージがわきにくいかもしれない． が，続く (#sec_intro_serverless) でそれぞれについてハンズオン形式で演習を行うので，そこでさらに理解を深めれば大丈夫である．</p>
<p><img src="./assets/serverless_logos.png" alt="Lambda, S3, DynamoDB のアイコン"></p>
<h3 id="lambda" tabindex="-1">Lambda <a class="header-anchor" href="#lambda" aria-label="Permalink to &quot;Lambda&quot;">&ZeroWidthSpace;</a></h3>
<p>AWS でサーバーレスコンピューティングの中心を担うのが， <a href="https://aws.amazon.com/lambda/" target="_blank" rel="noreferrer">Lambda</a> である． Lambda の使い方を <a href="#lambda_workflow">figure_title</a> に図示している． Lambda の仕組みはシンプルで，まずユーザーは実行したいプログラムのコードを事前に登録しておく． プログラムは， Python, Node.js, Ruby などの主要な言語がサポートされている． Lambda に登録されたひとつひとつのプログラムを関数 (Function) とよぶ． そして，関数を実行したいときに，invoke コマンドを Lambda に送信する． Lambda では， invoke のリクエストを受け取るとただちに (数ミリセカンドから数百ミリセカンド程度の時間で) プログラムの実行を開始する． そして，実行結果をクライアントやその他の計算機に返す．</p>
<p><img src="./assets/lambda_workflow.png" alt="AWS Lambda"></p>
<p>このように，Lambda では占有された仮想インスタンスは存在せず，実行を待っているプログラムだけがある状態である． invoke のリクエストに応じて，プログラムが AWS の巨大な計算機プールのどこかに配置され，実行される． 同時に複数のリクエストが来た場合でも， AWS はそれらを実行するための計算リソースを割り当て，並列的に処理を行ってくれる． 原理上は，<strong>数千から数万のリクエストが同時に来たとしても， Lambda はそれらを同時に実行することができる</strong>． このような，占有された仮想サーバーの存在なしに，動的に関数を実行するサービスのことを総称して <strong>FaaS (Function as a Service)</strong> とよぶ．</p>
<p>Lambda ではそれぞれの関数につき， 128MB から 10240MB のメモリーを使用することができる (執筆時点の仕様)． また，実効的な CPU のパワーはメモリーの量に比例する形で割り当てられる． すなわち，タスクに割り当てたメモリーの量が多ければ多いほど，より多くの CPU リソースが割り当てられることになる (しかし， RAM と CPU パワーの具体的な換算表は AWS からは公開されていない)． 実行時間は 100 ミリ秒の単位で記録され，実行時間に比例して料金が決定される． <a href="#lambda_pricing">table_title</a> は Lambda の利用料金表である (執筆時点で <code>ap-north-east1</code> リージョンを選択した場合)．</p>
<table><caption>Lambda の料金表</caption><colgroup><col style="width: 50%" /><col style="width: 50%" /></colgroup><thead><tr class="header"><th>Memory (MB)</th><th>Price per 100ms</th></tr></thead><tbody><tr class="odd"><td><p>128</p></td><td><p>$0.0000002083</p></td></tr><tr class="even"><td><p>512</p></td><td><p>$0.0000008333</p></td></tr><tr class="odd"><td><p>1024</p></td><td><p>$0.0000016667</p></td></tr><tr class="even"><td><p>3008</p></td><td><p>$0.0000048958</p></td></tr></tbody></table>
<p>実行時間に比例する料金に追加して，リクエストを送信するごとに発生する料金が設定されている． これは，百万回のリクエストにつき $0.2 である． たとえば， 128MB のメモリーを使用する関数を，それぞれ 200 ミリ秒，合計で 100 万回実行した場合， 0.0000002083 * 2 * 10^6 + 0.2 = $0.6 の料金となる． ウェブサーバーのデータベースの更新など簡単な計算であれば，200 ミリ秒程度で実行できる関数も多いことから，100 万回データベースの更新を行ったとしても，たった $0.6 しかコストが発生しないことになる． また，コードが実行されず待機状態になっている場合は，発生する料金は 0 である． このように，実際に意味のある処理が行われた時間にのみ，料金が発生する仕組みになっている．</p>
<p>Lambda は比較的短時間で完了する，反復性の高いタスクの実行に向いている． データベースの読み書きはその典型的な例であるが，そのほかにも，画像のサイズをトリミングしたり，サーバーサイドで定期的に実行されるメンテナンス処理などの利用が考えられる． また，複数の Lambda をリレー式に繋げることも可能で，シンプルな処理を組み合わせることで複雑なロジックを表現することができる．</p>
<p>上述の Lambda の料金計算は，説明のためコストに寄与する要素をいくつか省いている点は承知いただきたい． 例えば， DynamoDB の読み書きに関する料金や，ネットワークの通信にかかわるコストが考慮されていない．</p>
<h3 id="サーバーレスストレージ-s3" tabindex="-1">サーバーレスストレージ: S3 <a class="header-anchor" href="#サーバーレスストレージ-s3" aria-label="Permalink to &quot;サーバーレスストレージ: S3&quot;">&ZeroWidthSpace;</a></h3>
<p>サーバーレスの概念は，ストレージにも拡張されている．</p>
<p>従来的なストレージ (ファイルシステム) では，必ずホストとなるマシンと OS が存在しなければならない． したがって，それほどパワーは必要ないまでも，ある程度の CPU リソースを割かなければならない． また，従来的なファイルシステムでは，データ領域のサイズは最初にディスクを初期化するときに決めなければならず，後から容量を増加させることはしばしば困難である (ZFS などのファイルシステムを使えばある程度は自由にファイルシステムのサイズを変更することは可能である)． よって，従来的なクラウドでは，ストレージを借りる際にはあらかじめディスクのサイズを指定せねばならず，ディスクの中身が空であろうと満杯であろうと，同じ利用料金が発生することになる (<a href="#fig:s3_vs_filesystem">figure_title</a>)．</p>
<p><a href="https://aws.amazon.com/s3/" target="_blank" rel="noreferrer">Simple Storage Service (S3)</a> は，サーバーレスなストレージシステムを提供する (<a href="#fig:s3_vs_filesystem">figure_title</a>)． S3 は従来的なストレージシステムと異なり， OS に&quot;マウントする”という概念はない． 基本的に API を通じてデータの読み書きの操作が行われる． また，データの冗長化や暗号化，バックアップの作成など，通常ならば OS と CPU が介在しなければならない操作も， API を通じて行うことができる． S3 では事前に決められたディスク領域のサイズはなく，データを入れれば入れた分だけ，保存領域は拡大していく (仕様上はペタバイトスケールのデータを保存することが可能である)． ストレージにかかる料金は，保存してあるデータの総容量で決定される．</p>
<p><img src="./assets/s3_vs_filesystem.png" alt="S3 と従来的なファイルシステムの比較"></p>
<p>S3 を利用する際に，料金に関わってくる主要な事項をまとめたのが <a href="#tab:s3_pricing">table_title</a> である (<code>us-east-1</code> リージョンのもの． 説明のため主要な事項のみ取り出している． 詳細は <a href="https://aws.amazon.com/s3/pricing/?nc=sn&amp;loc=4" target="_blank" rel="noreferrer">公式ドキュメンテーション &quot;Amazon S3 pricing&quot;</a> を参照)．</p>
<table><caption>S3 の利用料金</caption><colgroup><col style="width: 50%" /><col style="width: 50%" /></colgroup><thead><tr class="header"><th>項目</th><th>料金</th></tr></thead><tbody><tr class="odd"><td><p>Data storage (First 50TB)</p></td><td><p>$0.023 per GB per month</p></td></tr><tr class="even"><td><p>PUT, COPY, POST, LIST requests (per 1,000 requests)</p></td><td><p>$0.005</p></td></tr><tr class="odd"><td><p>GET, SELECT, and all other requests (per 1,000 requests)</p></td><td><p>$0.0004</p></td></tr><tr class="even"><td><p>Data Transfer IN To Amazon S3 From Internet</p></td><td><p>$0</p></td></tr><tr class="odd"><td><p>Data Transfer OUT From Amazon S3 To Internet</p></td><td><p>$0.09 per GB</p></td></tr></tbody></table>
<p>第一に，データの保存には $0.025 per GB のコストが月ごとに発生する． したがって，1000GB のデータを S3 に一ヵ月保存した場合， $25 の料金が発生することになる． また，<code>PUT</code>, <code>COPY</code>, <code>POST</code> などのリクエスト (=データを書き込む操作) に対しては，データ容量に関係なく，1000 回ごとに $0.005 のコストが発生する． <code>GET</code>, <code>SELECT</code> などのリクエスト (=データを読み込む操作) に対しては，1000 回ごとに $0.0004 のコストが発生する． また， S3 はデータを外に取り出す際の通信にもコストが生じる． 執筆時点では，S3 からインターネットを通じて外部にデータを転送 (data-out) すると $0.09 per GB のコストが発生する． データをインターネットを通じて S3 に入れる (data-in) 通信は無料で行える． また， AWS の 同じ Region 内のサービス (Lambda や EC2 など) にデータを転送するのは無料である． AWS のリージョンをまたいだデータの転送にはコストが発生する． いずれにせよ，サーバーレスの概念に則り，すべての料金が従量課金制で決定される設定になっている．</p>
<h3 id="サーバーレスデータベース-dynamodb" tabindex="-1">サーバーレスデータベース: DynamoDB <a class="header-anchor" href="#サーバーレスデータベース-dynamodb" aria-label="Permalink to &quot;サーバーレスデータベース: DynamoDB&quot;">&ZeroWidthSpace;</a></h3>
<p>サーバーレスの概念は，データベースにも適用することができる．</p>
<p>ここでいうデータベースとは， Web サービスなどにおけるユーザーや商品の情報を記録しておくための保存領域のことを指している． 従来的に有名なデータベースとしては <a href="https://www.mysql.com/" target="_blank" rel="noreferrer">MySQL</a>, <a href="https://www.postgresql.org/" target="_blank" rel="noreferrer">PostgreSQL</a>, <a href="https://www.mongodb.com/" target="_blank" rel="noreferrer">MongoDB</a> などが挙げられる． データベースと普通のストレージの違いは，データの検索機能にある． 普通のストレージではデータは単純にディスクに書き込まれるだけだが， データベースでは検索がより効率的になるようなデータの配置がされたり， 頻繁にアクセスされるデータはメモリーにキャッシュされるなどの機能が備わっている． これにより，巨大なデータの中から，興味のある要素を高速に取得することができる．</p>
<p>このような検索機能を実現するには，当然 CPU の存在が必須である． したがって，従来的なデータベースを構築する際は，ストレージ領域に加えて，たくさんの CPU コアを搭載したマシンが用いられることが多い． また，データベースが巨大な場合は複数マシンにまたがった分散型のシステムが設計される． 分散型システムの場合は， <a href="#chap_serverful_cloud">Serverful クラウド (従来型)</a> で議論したようにデータベースへのアクセス負荷に応じて適切なスケーリングがなされる必要がある．</p>
<p><a href="https://aws.amazon.com/dynamodb/" target="_blank" rel="noreferrer">DynamoDB</a> は， AWS が提供しているサーバーレスな分散型データベースである． サーバーレスであるので，占有されたデータベース用仮想インスタンスは存在せず， API を通じてデータの書き込み・読み出し・検索などの操作を行う． S3 と同様に，データ保存領域の上限は定められておらず，データを入れれば入れた分だけ，保存領域は拡大していく． また，データベースへの負荷が増減したときのスケーリングは， DynamoDB が自動で行うので，ユーザーは心配する必要はない．</p>
<p>DynamoDB での利用料金の計算はやや複雑なのだが， &quot;On-demand Capacity&quot; というモードで使用した場合の料金に関わってくる主要な事項をまとめたのが <a href="#tab:dynamodb_pricing">table_title</a> である (<code>us-east-1</code> リージョンのもの． 詳細は <a href="https://aws.amazon.com/dynamodb/pricing/on-demand/" target="_blank" rel="noreferrer">公式ドキュメンテーション &quot;Pricing for On-Demand Capacity&quot;</a> を参照)．</p>
<table><caption>DynamoDB の利用料金</caption><colgroup><col style="width: 50%" /><col style="width: 50%" /></colgroup><thead><tr class="header"><th>項目</th><th>料金</th></tr></thead><tbody><tr class="odd"><td><p>Write request units</p></td><td><p>$1.25 per million write request units</p></td></tr><tr class="even"><td><p>Read request units</p></td><td><p>$0.25 per million read request units</p></td></tr><tr class="odd"><td><p>Data storage</p></td><td><p>$0.25 per GB-month</p></td></tr></tbody></table>
<p>DynamoDB ではデータの書き込み操作の単位を write request unit とよび，データの読み込み操作の単位を read request unit とよぶ． 基本的に， 1kB 以下のデータを一度書き込むと 1 write request unit を消費し，4kB 以下のデータを一度読み込むと 1 read request unit を消費する (詳しくは <a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.ReadWriteCapacityMode.html" target="_blank" rel="noreferrer">公式ドキュメンテーション &quot;Read/Write Capacity Mode&quot;</a> を参照のこと)． write request units は 100 万回ごとに $1.25, read request units は 100 万回ごとに $0.25 のコストが設定されている． また，保存されたデータ容量に対して $0.25 per GB のコストが月ごとに発生する． DynamoDB は高速な検索機能などを備えたデータベースであるので， GB あたりのストレージコストは S3 に比べ 10 倍程度高い． DynamoDB のデータの転送に関わるコストは，同じリージョン内ならば data-in，data-out ともに $0 である． リージョンをまたいだ通信には別途コストが発生する．</p>
<h3 id="その他のサーバーレスクラウドの構成要素" tabindex="-1">その他のサーバーレスクラウドの構成要素 <a class="header-anchor" href="#その他のサーバーレスクラウドの構成要素" aria-label="Permalink to &quot;その他のサーバーレスクラウドの構成要素&quot;">&ZeroWidthSpace;</a></h3>
<p>以上で紹介した Lambda, S3, DynamoDB がサーバーレスクラウドの中で最も使用する頻度が高いサービスになる． その他のサーバーレスクラウドの構成要素を以下に列挙する． いくつかについては，今後のハンズオンを行う中で改めて解説を行う．</p>
<ul>
<li>
<p><a href="https://aws.amazon.com/api-gateway/" target="_blank" rel="noreferrer">API Gateway</a>: API を構築する際のルーティングを担う． (#sec_bashoutter) で取り上げる．</p>
</li>
<li>
<p><a href="https://aws.amazon.com/fargate/" target="_blank" rel="noreferrer">Fargate</a>: (#sec_fargate_qabot) で触れた Fargate も，サーバーレスクラウドの要素の一部である． Lambda との違いは，Lambda よりも大容量のメモリーや CPU を要するような計算などを行うことができる点が挙げられる．</p>
</li>
<li>
<p><a href="https://aws.amazon.com/sns/" target="_blank" rel="noreferrer">Simple Notification Service (SNS)</a>: サーバーレスのサービス間でイベントをやり取りするためのサービス．</p>
</li>
<li>
<p><a href="https://aws.amazon.com/step-functions/" target="_blank" rel="noreferrer">Step Functions</a>: サーバーレスのサービス間のオーケストレーションを担う．</p>
</li>
</ul>
<p><strong>サーバーレスアーキテクチャは万能か？</strong></p>
<p>この問いへの答えは，筆者は NO であると考える．</p>
<p>ここまで，サーバーレスの利点を強調して説明をしてきたが，まだまだ新しい技術なだけに，欠点，あるいはサーバーフルなシステムに劣る点は数多くある．</p>
<p>大きな欠点を一つあげるとすれば，サーバーレスのシステムは各クラウドプラットフォームに固有なものなので，特定のプラットフォームでしか運用できないシステムになってしまう点であろう． AWS で作成したサーバーレスのシステムを， Google のクラウドに移植するには，かなり大掛かりなプログラムの書き換えが必要になる． 一方， serverful なシステムであれば，プラットフォーム間のマイグレーションは比較的簡単に行うことができる． クラウドプロバイダーとしては，自社のシステムへの依存度を強めることで，顧客を離さないようにするという狙いがあるのだろう…</p>
<p>その他，サーバーレスコンピューティングの欠点や今後の課題などは，次の論文で詳しく議論されている． 興味のある読者はぜひ読んでいただきたい．</p>
<ul>
<li><a href="https://arxiv.org/abs/1812.03651" target="_blank" rel="noreferrer">Hellerstein et al., &quot;Serverless Computing: One Step Forward, Two Steps Back&quot; arXiv (2018)</a></li>
</ul>
]]></description>
            <content:encoded><![CDATA[<h1 id="serverless-architecture" tabindex="-1">Serverless architecture <a class="header-anchor" href="#serverless-architecture" aria-label="Permalink to &quot;Serverless architecture&quot;">&ZeroWidthSpace;</a></h1>
<p>サーバーレスアーキテクチャ (Serverless architecture) あるいは サーバーレスコンピューティング (Serverless computing) とは，従来とは全く異なるアプローチに基づくクラウドシステムの設計方法である． 歴史的には， AWS が 2014 年に発表した <a href="https://aws.amazon.com/lambda/" target="_blank" rel="noreferrer">Lamba</a> がサーバーレスアーキテクチャの先駆けとされている． その後， Google や Microsoft などのクラウドプラットフォームも同様の機能の提供を開始している． サーバーレスアーキテクチャの利点は，スケーラブルなクラウドシステムを安価かつ簡易に作成できる点であり，近年いたるところで導入が進んでいる．</p>
<p>Serverless とは，文字どおりの意味としてはサーバーなしで計算をするということになるが，それは一体どういう意味だろうか？ サーバーレスについて説明するためには，まずは従来的な， &quot;serverful&quot; とよばれるようなシステムについて解説しなければならない．</p>
<h2 id="serverful-クラウド-従来型" tabindex="-1">Serverful クラウド (従来型) <a class="header-anchor" href="#serverful-クラウド-従来型" aria-label="Permalink to &quot;Serverful クラウド (従来型)&quot;">&ZeroWidthSpace;</a></h2>
<p>従来的なクラウドシステムのスケッチを <a href="#serverful">figure_title</a> に示す． クライアントから送信されたリクエストは，最初に API サーバーに送られる． API サーバーでは，リクエストの内容に応じてタスクが実行される． タスクには，API サーバーだけで完結できるものもあるが，多くの場合，データベースの読み書きが必要である． データベースには，データベース専用の独立したサーバーマシンが用いられることが一般的である． また，画像や動画などの容量の大きいデータは，また別のストレージサーバーに保存されることが多い． これらの API サーバー，データベースサーバー，ストレージサーバーはそれぞれ独立したサーバーマシンであり， AWS の言葉では EC2 による仮想インスタンスを想定してもらったらよい．</p>
<p>多くのウェブサービスでは，多数のクライアントからのリクエストを処理するため，複数のサーバーマシンがクラウド内で起動し，負荷を分散するような設計がなされている． クライアントから来たリクエストを計算容量に余裕のあるサーバーに振り分けるような操作を <strong>Load balancing</strong> とよび，そのような操作を担当するマシンのことを <strong>Load balancer</strong> という．</p>
<p>計算負荷を分散する目的で多数のインスタンスを起動するのはよいのだが，計算負荷が小さすぎてアイドリング状態にあるようではコストと電力の無駄遣いである． したがって，すべてのサーバーが常に目標とする計算負荷を維持するよう，計算の負荷に応じてクラスター内の仮想サーバーの数を動的に増減させるような仕組みが必要である． そのような仕組みを<strong>クラスターのスケーリング</strong>とよび，負荷の増大に応答して新しい仮想インスタンスをクラスターに追加する操作を <strong>scale-out</strong>，負荷の減少に応答してインスタンスをシャットダウンする操作を <strong>scale-in</strong> とよぶ． クラスターのスケーリングは， API サーバーではもちろんのこと，データベースサーバー・ストレージサーバーでも必要になる． ストレージサーバーでは，例えば頻繁にアクセスされるデータはキャッシュ領域に保存したり，データのコピーを複数作るなどのスケーリングが行われる． データベースサーバーも同様に，頻繁にアクセスされるデータのアクセスがパンクしてしまわないよう，分散的な処理が必要となる． このように，<strong>クラウドシステム内すべての箇所で，負荷が均一になるような調整が必要であり，開発者は多くの時間をそのチューニングに費やさなければならない．</strong> また，サービスの利用者の数などに応じてスケーリングの設定は常に見直される必要があり，継続的な開発が要求される．</p>
<p>さらに問題を複雑にするのは，API サーバーで処理されるべきタスクが，非一様な点である． 非一様であるとは，たとえばタスク A は 3000 ミリ秒の実行時間と 512MB のメモリーを消費し，別のタスク B は 1000 ミリ秒の実行時間と 128MB のメモリーを消費する，というような状況を指している． 一つのサーバーマシンが計算負荷が異なる複数のタスクを処理する場合，クラスターのスケーリングはより複雑になる． この状況をシンプルにするために，１サーバーで実行するタスクは１種類に限る，という設計も可能であるが，そうするとで生まれる弊害も多い (ほとんど使われないタスクに対してもサーバー一台をまるまる割り当てなければならない = ほとんどアイドリング状態になってしまう，など)．</p>
<p><img src="./assets/serverful.png" alt="Serverful なクラウドシステム"></p>
<h2 id="serverless-クラウドへ" tabindex="-1">Serverless クラウドへ <a class="header-anchor" href="#serverless-クラウドへ" aria-label="Permalink to &quot;Serverless クラウドへ&quot;">&ZeroWidthSpace;</a></h2>
<p><a href="#chap_serverful_cloud">Serverful クラウド (従来型)</a> で議論したように，クラスターのスケーリングはクラウドシステムの経済的効率とシステムの安定性を最大化するために必須の作業である． それを反映して，多くの開発者の時間が投資されてきた．</p>
<p>クラスターのスケーリングはすべての開発者が何度も繰り返し行ってきた作業であり，いくつかの側面をテンプレート化し，共通化することができたならば開発のコストを大幅に削減できるだろう． それを実現するには，根本的なレベルからクラウドシステムの設計を考え直す必要がある． <strong>スケーリングを前提</strong>として考えることで，もっと<strong>シンプルで見通しがよいクラウドシステムの設計の仕組みはないだろうか</strong>？ そのような動機が，サーバーレスアーキテクチャが誕生する背後にあった．</p>
<p>従来の serverful なシステムでの最大の問題点は，<strong>サーバーをまるまる占有してしまう</strong>という点にある． すなわち， EC2 インスタンスを起動したとき，そのインスタンスは起動したユーザーだけが使えるものであり，<strong>計算のリソース (CPU や RAM) が独占的に割り当てられた状態</strong>になる． 固定した計算資源の割り当てがされてしまっているので，<strong>インスタンスの計算負荷が 0%であろうが 100%であろうが，均一の使用料金が起動時間に比例</strong>して発生する．</p>
<p>サーバーレスアーキテクチャは，このような <strong>独占的に割り当てられた計算リソースというものを完全に廃止する</strong>ことを出発点とする． サーバーレスアーキテクチャでは，計算のリソースは，クラウドプロバイダーがすべて管理する． クライアントは，仮想インスタンスを一台まるごと借りるのではなく，計算のタスクの需要が生まれる毎に，<strong>実行したいプログラム・コマンドをクラウドに提出する</strong>． クラウドプロバイダーは，自身のもつ巨大な計算リソースから空きを探し，提出されたプログラムを実行し，実行結果をクライアントに返す． 言い換えると，計算リソースのスケーリングやアロケーションなどはクラウドプロバイダーが一手に引き受け，ユーザーはジョブをサブミットすることに注力する，という枠組みである． これを図示すると， <a href="#serverless">figure_title</a> のようになる．</p>
<p><img src="./assets/serverless.png" alt="従来のクラウドと Serverless クラウドの比較"></p>
<p>サーバーレスクラウドでは，スケーリングはすべてクラウドプロバイダーが引き受けるので，スケーラビリティーが保証されている． クライアントが同時に大量のタスクを送信した場合でも，クラウドプロバイダー側の独自の仕組みによってすべてのタスクが遅延なく実行される． また，サーバーレスクラウドを利用することで，<strong>クラウドのコストは実際に使用した計算の総量 (稼働時間) で決定される</strong>ことになる． これは，計算の実行総量に関わらずインスタンスの起動時間で料金が決定されていた従来のシステムと比べて大きな違いである．</p>
<p>サーバーレスクラウドは，従来のクラウドとは根本から異なったアプローチなので，コードの書き方やシステムの設計が大きく異なる． サーバーレスクラウドを開発・運用するには，サーバーレス固有の概念や用語に精通している必要がある． 以降では，実際にクラウドを動かしながら，サーバーレスをより具体的に体験していこう．</p>
<p>従来型の(仮想インスタンスをたくさん起動するような)クラウドシステムは，<strong>賃貸</strong>と似ているかもしれない． 部屋を借りるというのは，その部屋でどれだけの時間を過ごそうが，月々の家賃は一定である． 同様に，仮想サーバーも，それがどれほどの計算を行っているかに関わらず，一定の料金が時間ごとに発生する．</p>
<p>一方で，サーバーレスクラウドは，<strong>電気・水道・ガス料金</strong> と似ている． こちらは，実際に使用した量に比例して料金が決定されている． サーバーレスクラウドも，実際に計算を行った総時間で料金が決まる仕組みになっている．</p>
<h2 id="サーバーレスクラウドを構成するコンポーネント" tabindex="-1">サーバーレスクラウドを構成するコンポーネント <a class="header-anchor" href="#サーバーレスクラウドを構成するコンポーネント" aria-label="Permalink to &quot;サーバーレスクラウドを構成するコンポーネント&quot;">&ZeroWidthSpace;</a></h2>
<p>サーバーレスアーキテクチャの概要がわかってきたところで，ここでは AWS においてサーバーレスクラウドを構成する様々なコンポーネントを紹介していこう． 特に， <strong>Lambda</strong>, <strong>S3</strong>, <strong>DynamoDB</strong> を取り上げ，解説する (<a href="#fig:serverless_logos">figure_title</a>)． サーバーレスクラウドは，これらのコンポーネントを統合することで一つのシステムが出来上がる． ここでは， Lambda，S3，DynamoDB を利用する際に押さえておかなければならない知識を一通り説明しきる都合上，具体的なイメージがわきにくいかもしれない． が，続く (#sec_intro_serverless) でそれぞれについてハンズオン形式で演習を行うので，そこでさらに理解を深めれば大丈夫である．</p>
<p><img src="./assets/serverless_logos.png" alt="Lambda, S3, DynamoDB のアイコン"></p>
<h3 id="lambda" tabindex="-1">Lambda <a class="header-anchor" href="#lambda" aria-label="Permalink to &quot;Lambda&quot;">&ZeroWidthSpace;</a></h3>
<p>AWS でサーバーレスコンピューティングの中心を担うのが， <a href="https://aws.amazon.com/lambda/" target="_blank" rel="noreferrer">Lambda</a> である． Lambda の使い方を <a href="#lambda_workflow">figure_title</a> に図示している． Lambda の仕組みはシンプルで，まずユーザーは実行したいプログラムのコードを事前に登録しておく． プログラムは， Python, Node.js, Ruby などの主要な言語がサポートされている． Lambda に登録されたひとつひとつのプログラムを関数 (Function) とよぶ． そして，関数を実行したいときに，invoke コマンドを Lambda に送信する． Lambda では， invoke のリクエストを受け取るとただちに (数ミリセカンドから数百ミリセカンド程度の時間で) プログラムの実行を開始する． そして，実行結果をクライアントやその他の計算機に返す．</p>
<p><img src="./assets/lambda_workflow.png" alt="AWS Lambda"></p>
<p>このように，Lambda では占有された仮想インスタンスは存在せず，実行を待っているプログラムだけがある状態である． invoke のリクエストに応じて，プログラムが AWS の巨大な計算機プールのどこかに配置され，実行される． 同時に複数のリクエストが来た場合でも， AWS はそれらを実行するための計算リソースを割り当て，並列的に処理を行ってくれる． 原理上は，<strong>数千から数万のリクエストが同時に来たとしても， Lambda はそれらを同時に実行することができる</strong>． このような，占有された仮想サーバーの存在なしに，動的に関数を実行するサービスのことを総称して <strong>FaaS (Function as a Service)</strong> とよぶ．</p>
<p>Lambda ではそれぞれの関数につき， 128MB から 10240MB のメモリーを使用することができる (執筆時点の仕様)． また，実効的な CPU のパワーはメモリーの量に比例する形で割り当てられる． すなわち，タスクに割り当てたメモリーの量が多ければ多いほど，より多くの CPU リソースが割り当てられることになる (しかし， RAM と CPU パワーの具体的な換算表は AWS からは公開されていない)． 実行時間は 100 ミリ秒の単位で記録され，実行時間に比例して料金が決定される． <a href="#lambda_pricing">table_title</a> は Lambda の利用料金表である (執筆時点で <code>ap-north-east1</code> リージョンを選択した場合)．</p>
<table><caption>Lambda の料金表</caption><colgroup><col style="width: 50%" /><col style="width: 50%" /></colgroup><thead><tr class="header"><th>Memory (MB)</th><th>Price per 100ms</th></tr></thead><tbody><tr class="odd"><td><p>128</p></td><td><p>$0.0000002083</p></td></tr><tr class="even"><td><p>512</p></td><td><p>$0.0000008333</p></td></tr><tr class="odd"><td><p>1024</p></td><td><p>$0.0000016667</p></td></tr><tr class="even"><td><p>3008</p></td><td><p>$0.0000048958</p></td></tr></tbody></table>
<p>実行時間に比例する料金に追加して，リクエストを送信するごとに発生する料金が設定されている． これは，百万回のリクエストにつき $0.2 である． たとえば， 128MB のメモリーを使用する関数を，それぞれ 200 ミリ秒，合計で 100 万回実行した場合， 0.0000002083 * 2 * 10^6 + 0.2 = $0.6 の料金となる． ウェブサーバーのデータベースの更新など簡単な計算であれば，200 ミリ秒程度で実行できる関数も多いことから，100 万回データベースの更新を行ったとしても，たった $0.6 しかコストが発生しないことになる． また，コードが実行されず待機状態になっている場合は，発生する料金は 0 である． このように，実際に意味のある処理が行われた時間にのみ，料金が発生する仕組みになっている．</p>
<p>Lambda は比較的短時間で完了する，反復性の高いタスクの実行に向いている． データベースの読み書きはその典型的な例であるが，そのほかにも，画像のサイズをトリミングしたり，サーバーサイドで定期的に実行されるメンテナンス処理などの利用が考えられる． また，複数の Lambda をリレー式に繋げることも可能で，シンプルな処理を組み合わせることで複雑なロジックを表現することができる．</p>
<p>上述の Lambda の料金計算は，説明のためコストに寄与する要素をいくつか省いている点は承知いただきたい． 例えば， DynamoDB の読み書きに関する料金や，ネットワークの通信にかかわるコストが考慮されていない．</p>
<h3 id="サーバーレスストレージ-s3" tabindex="-1">サーバーレスストレージ: S3 <a class="header-anchor" href="#サーバーレスストレージ-s3" aria-label="Permalink to &quot;サーバーレスストレージ: S3&quot;">&ZeroWidthSpace;</a></h3>
<p>サーバーレスの概念は，ストレージにも拡張されている．</p>
<p>従来的なストレージ (ファイルシステム) では，必ずホストとなるマシンと OS が存在しなければならない． したがって，それほどパワーは必要ないまでも，ある程度の CPU リソースを割かなければならない． また，従来的なファイルシステムでは，データ領域のサイズは最初にディスクを初期化するときに決めなければならず，後から容量を増加させることはしばしば困難である (ZFS などのファイルシステムを使えばある程度は自由にファイルシステムのサイズを変更することは可能である)． よって，従来的なクラウドでは，ストレージを借りる際にはあらかじめディスクのサイズを指定せねばならず，ディスクの中身が空であろうと満杯であろうと，同じ利用料金が発生することになる (<a href="#fig:s3_vs_filesystem">figure_title</a>)．</p>
<p><a href="https://aws.amazon.com/s3/" target="_blank" rel="noreferrer">Simple Storage Service (S3)</a> は，サーバーレスなストレージシステムを提供する (<a href="#fig:s3_vs_filesystem">figure_title</a>)． S3 は従来的なストレージシステムと異なり， OS に&quot;マウントする”という概念はない． 基本的に API を通じてデータの読み書きの操作が行われる． また，データの冗長化や暗号化，バックアップの作成など，通常ならば OS と CPU が介在しなければならない操作も， API を通じて行うことができる． S3 では事前に決められたディスク領域のサイズはなく，データを入れれば入れた分だけ，保存領域は拡大していく (仕様上はペタバイトスケールのデータを保存することが可能である)． ストレージにかかる料金は，保存してあるデータの総容量で決定される．</p>
<p><img src="./assets/s3_vs_filesystem.png" alt="S3 と従来的なファイルシステムの比較"></p>
<p>S3 を利用する際に，料金に関わってくる主要な事項をまとめたのが <a href="#tab:s3_pricing">table_title</a> である (<code>us-east-1</code> リージョンのもの． 説明のため主要な事項のみ取り出している． 詳細は <a href="https://aws.amazon.com/s3/pricing/?nc=sn&amp;loc=4" target="_blank" rel="noreferrer">公式ドキュメンテーション &quot;Amazon S3 pricing&quot;</a> を参照)．</p>
<table><caption>S3 の利用料金</caption><colgroup><col style="width: 50%" /><col style="width: 50%" /></colgroup><thead><tr class="header"><th>項目</th><th>料金</th></tr></thead><tbody><tr class="odd"><td><p>Data storage (First 50TB)</p></td><td><p>$0.023 per GB per month</p></td></tr><tr class="even"><td><p>PUT, COPY, POST, LIST requests (per 1,000 requests)</p></td><td><p>$0.005</p></td></tr><tr class="odd"><td><p>GET, SELECT, and all other requests (per 1,000 requests)</p></td><td><p>$0.0004</p></td></tr><tr class="even"><td><p>Data Transfer IN To Amazon S3 From Internet</p></td><td><p>$0</p></td></tr><tr class="odd"><td><p>Data Transfer OUT From Amazon S3 To Internet</p></td><td><p>$0.09 per GB</p></td></tr></tbody></table>
<p>第一に，データの保存には $0.025 per GB のコストが月ごとに発生する． したがって，1000GB のデータを S3 に一ヵ月保存した場合， $25 の料金が発生することになる． また，<code>PUT</code>, <code>COPY</code>, <code>POST</code> などのリクエスト (=データを書き込む操作) に対しては，データ容量に関係なく，1000 回ごとに $0.005 のコストが発生する． <code>GET</code>, <code>SELECT</code> などのリクエスト (=データを読み込む操作) に対しては，1000 回ごとに $0.0004 のコストが発生する． また， S3 はデータを外に取り出す際の通信にもコストが生じる． 執筆時点では，S3 からインターネットを通じて外部にデータを転送 (data-out) すると $0.09 per GB のコストが発生する． データをインターネットを通じて S3 に入れる (data-in) 通信は無料で行える． また， AWS の 同じ Region 内のサービス (Lambda や EC2 など) にデータを転送するのは無料である． AWS のリージョンをまたいだデータの転送にはコストが発生する． いずれにせよ，サーバーレスの概念に則り，すべての料金が従量課金制で決定される設定になっている．</p>
<h3 id="サーバーレスデータベース-dynamodb" tabindex="-1">サーバーレスデータベース: DynamoDB <a class="header-anchor" href="#サーバーレスデータベース-dynamodb" aria-label="Permalink to &quot;サーバーレスデータベース: DynamoDB&quot;">&ZeroWidthSpace;</a></h3>
<p>サーバーレスの概念は，データベースにも適用することができる．</p>
<p>ここでいうデータベースとは， Web サービスなどにおけるユーザーや商品の情報を記録しておくための保存領域のことを指している． 従来的に有名なデータベースとしては <a href="https://www.mysql.com/" target="_blank" rel="noreferrer">MySQL</a>, <a href="https://www.postgresql.org/" target="_blank" rel="noreferrer">PostgreSQL</a>, <a href="https://www.mongodb.com/" target="_blank" rel="noreferrer">MongoDB</a> などが挙げられる． データベースと普通のストレージの違いは，データの検索機能にある． 普通のストレージではデータは単純にディスクに書き込まれるだけだが， データベースでは検索がより効率的になるようなデータの配置がされたり， 頻繁にアクセスされるデータはメモリーにキャッシュされるなどの機能が備わっている． これにより，巨大なデータの中から，興味のある要素を高速に取得することができる．</p>
<p>このような検索機能を実現するには，当然 CPU の存在が必須である． したがって，従来的なデータベースを構築する際は，ストレージ領域に加えて，たくさんの CPU コアを搭載したマシンが用いられることが多い． また，データベースが巨大な場合は複数マシンにまたがった分散型のシステムが設計される． 分散型システムの場合は， <a href="#chap_serverful_cloud">Serverful クラウド (従来型)</a> で議論したようにデータベースへのアクセス負荷に応じて適切なスケーリングがなされる必要がある．</p>
<p><a href="https://aws.amazon.com/dynamodb/" target="_blank" rel="noreferrer">DynamoDB</a> は， AWS が提供しているサーバーレスな分散型データベースである． サーバーレスであるので，占有されたデータベース用仮想インスタンスは存在せず， API を通じてデータの書き込み・読み出し・検索などの操作を行う． S3 と同様に，データ保存領域の上限は定められておらず，データを入れれば入れた分だけ，保存領域は拡大していく． また，データベースへの負荷が増減したときのスケーリングは， DynamoDB が自動で行うので，ユーザーは心配する必要はない．</p>
<p>DynamoDB での利用料金の計算はやや複雑なのだが， &quot;On-demand Capacity&quot; というモードで使用した場合の料金に関わってくる主要な事項をまとめたのが <a href="#tab:dynamodb_pricing">table_title</a> である (<code>us-east-1</code> リージョンのもの． 詳細は <a href="https://aws.amazon.com/dynamodb/pricing/on-demand/" target="_blank" rel="noreferrer">公式ドキュメンテーション &quot;Pricing for On-Demand Capacity&quot;</a> を参照)．</p>
<table><caption>DynamoDB の利用料金</caption><colgroup><col style="width: 50%" /><col style="width: 50%" /></colgroup><thead><tr class="header"><th>項目</th><th>料金</th></tr></thead><tbody><tr class="odd"><td><p>Write request units</p></td><td><p>$1.25 per million write request units</p></td></tr><tr class="even"><td><p>Read request units</p></td><td><p>$0.25 per million read request units</p></td></tr><tr class="odd"><td><p>Data storage</p></td><td><p>$0.25 per GB-month</p></td></tr></tbody></table>
<p>DynamoDB ではデータの書き込み操作の単位を write request unit とよび，データの読み込み操作の単位を read request unit とよぶ． 基本的に， 1kB 以下のデータを一度書き込むと 1 write request unit を消費し，4kB 以下のデータを一度読み込むと 1 read request unit を消費する (詳しくは <a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.ReadWriteCapacityMode.html" target="_blank" rel="noreferrer">公式ドキュメンテーション &quot;Read/Write Capacity Mode&quot;</a> を参照のこと)． write request units は 100 万回ごとに $1.25, read request units は 100 万回ごとに $0.25 のコストが設定されている． また，保存されたデータ容量に対して $0.25 per GB のコストが月ごとに発生する． DynamoDB は高速な検索機能などを備えたデータベースであるので， GB あたりのストレージコストは S3 に比べ 10 倍程度高い． DynamoDB のデータの転送に関わるコストは，同じリージョン内ならば data-in，data-out ともに $0 である． リージョンをまたいだ通信には別途コストが発生する．</p>
<h3 id="その他のサーバーレスクラウドの構成要素" tabindex="-1">その他のサーバーレスクラウドの構成要素 <a class="header-anchor" href="#その他のサーバーレスクラウドの構成要素" aria-label="Permalink to &quot;その他のサーバーレスクラウドの構成要素&quot;">&ZeroWidthSpace;</a></h3>
<p>以上で紹介した Lambda, S3, DynamoDB がサーバーレスクラウドの中で最も使用する頻度が高いサービスになる． その他のサーバーレスクラウドの構成要素を以下に列挙する． いくつかについては，今後のハンズオンを行う中で改めて解説を行う．</p>
<ul>
<li>
<p><a href="https://aws.amazon.com/api-gateway/" target="_blank" rel="noreferrer">API Gateway</a>: API を構築する際のルーティングを担う． (#sec_bashoutter) で取り上げる．</p>
</li>
<li>
<p><a href="https://aws.amazon.com/fargate/" target="_blank" rel="noreferrer">Fargate</a>: (#sec_fargate_qabot) で触れた Fargate も，サーバーレスクラウドの要素の一部である． Lambda との違いは，Lambda よりも大容量のメモリーや CPU を要するような計算などを行うことができる点が挙げられる．</p>
</li>
<li>
<p><a href="https://aws.amazon.com/sns/" target="_blank" rel="noreferrer">Simple Notification Service (SNS)</a>: サーバーレスのサービス間でイベントをやり取りするためのサービス．</p>
</li>
<li>
<p><a href="https://aws.amazon.com/step-functions/" target="_blank" rel="noreferrer">Step Functions</a>: サーバーレスのサービス間のオーケストレーションを担う．</p>
</li>
</ul>
<p><strong>サーバーレスアーキテクチャは万能か？</strong></p>
<p>この問いへの答えは，筆者は NO であると考える．</p>
<p>ここまで，サーバーレスの利点を強調して説明をしてきたが，まだまだ新しい技術なだけに，欠点，あるいはサーバーフルなシステムに劣る点は数多くある．</p>
<p>大きな欠点を一つあげるとすれば，サーバーレスのシステムは各クラウドプラットフォームに固有なものなので，特定のプラットフォームでしか運用できないシステムになってしまう点であろう． AWS で作成したサーバーレスのシステムを， Google のクラウドに移植するには，かなり大掛かりなプログラムの書き換えが必要になる． 一方， serverful なシステムであれば，プラットフォーム間のマイグレーションは比較的簡単に行うことができる． クラウドプロバイダーとしては，自社のシステムへの依存度を強めることで，顧客を離さないようにするという狙いがあるのだろう…</p>
<p>その他，サーバーレスコンピューティングの欠点や今後の課題などは，次の論文で詳しく議論されている． 興味のある読者はぜひ読んでいただきたい．</p>
<ul>
<li><a href="https://arxiv.org/abs/1812.03651" target="_blank" rel="noreferrer">Hellerstein et al., &quot;Serverless Computing: One Step Forward, Two Steps Back&quot; arXiv (2018)</a></li>
</ul>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Web サービスの作り方 ]]></title>
            <link>https://note.toshiki.devdevelopment/aws/webserver</link>
            <guid>https://note.toshiki.devdevelopment/aws/webserver</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="web-サービスの作り方" tabindex="-1">Web サービスの作り方 <a class="header-anchor" href="#web-サービスの作り方" aria-label="Permalink to &quot;Web サービスの作り方&quot;">&ZeroWidthSpace;</a></h1>
<p>ここからが，本書第三部の内容になる． これまでのセクションでは，仮想サーバーをクラウド上に起動し，そこで計算を走らせる方法について解説をしてきた． EC2, ECS, Fargate, Batch などを利用して，動的にスケールするクラスターを構成し，並列にタスクを実行するクラウドシステムを実装してきた． 振り返ると，これまで紹介してきた内容は，<strong>自分自身が行いたい計算をクラウドを駆使することで実現する</strong>，という用途にフォーカスしていたことに気がつくだろう． 一方で，<strong>広く一般の人々に使ってもらえるような計算サービス・データベース</strong>を提供する，というのもクラウドの重要な役割として挙げられる．</p>
<p>本章から始まる第三部では，前回までとは少し方向性を変え，どのようにしてクラウド上にアプリケーションを展開し，広く一般の人に使ってもらうか，という点を講義したいと思う． これを通じて，どのようにして世の中のウェブサービスができ上がっているのかを知り，さらにどうやって自分でそのようなアプリケーションをゼロから構築するのか，という点を学んでもらう． その過程で，サーバーレスアーキテクチャという最新のクラウド設計手法を解説する．</p>
<p>その前準備として，本章ではどのようにしてウェブサービスが出来上がっているのか，その背後にある技術の概要を解説する． 用語の解説が中心となるが，後のハンズオンを実装するために必須の知識であるので，理解して前に進むよう心がけよう．</p>
<h2 id="ウェブサービスの仕組み-—-twitter-を例に" tabindex="-1">ウェブサービスの仕組み  — Twitter を例に <a class="header-anchor" href="#ウェブサービスの仕組み-—-twitter-を例に" aria-label="Permalink to &quot;ウェブサービスの仕組み  — Twitter を例に&quot;">&ZeroWidthSpace;</a></h2>
<p>あなたがパソコンやスマートフォンから Twitter, Facebook, YouTube などのウェブサービスにアクセスしたとき，実際にどのようなことが行われ，コンテンツが提示されているのだろうか？</p>
<p>HTTP を通じたサーバーとクライアントのデータのやり取りは，すでに知っている読者も多いだろうし，逆にすべて解説しようとすると紙面が足りないので，ここではエッセンスの説明のみにとどめる． 以降では <a href="https://twitter.com" target="_blank" rel="noreferrer">Twitter</a> を具体例として，背後にあるサーバーとクライアントの間の通信を概説しよう． 概念図としては <a href="#fig:web_server">figure_title</a> のような通信がクライアントとサーバーの間で行われていることになる．</p>
<p><img src="./assets/web_server.png" alt="クライアントと Web サーバーの通信の概念図"></p>
<p>前提として，クライアントとサーバーの通信は <strong>HTTP (Hypertext Transfer Protocol)</strong> を使って行われる． また，最近では，暗号化された HTTP である <strong>HTTPS (HTTPS (Hypertext Transfer Protocol Secure))</strong> を用いることがスタンダードになってきている． 第一のステップとして，クライアントは HTTP(S) 通信によってサーバーから静的なコンテンツを取得する． 静的なコンテンツとは， <strong>HTML (Hyptertext Markup Language)</strong> で記述されたウェブページの文書本体， <strong>CSS (Cascading Style Sheets)</strong> で記述されたページのデザインやレイアウトファイル，そして <strong>JavaScript (JS)</strong> で記述されたページの動的な挙動を定義したプログラム，が含まれる． Twitter を含む現代的なウェブアプリケーションの設計では，この静的なファイル群はページの”枠”を定義するだけで，中身となるコンテンツ (例: ツイートの一覧) は別途 <strong>API (Application Programming Interface)</strong> によって取得されなければならない． そこで，クライアントは先のステップで取得された JavaScript で定義されたプログラムに従って，サーバーに API を送信し，ツイートや画像データを取得する． この際，テキストデータのやり取りには <strong>JSON (JavaScript Object Notation)</strong> というフォーマットが用いられることが多い． 画像や動画などのコンテンツも同様に API により取得される． このようにして取得されたテキストや画像が，HTML の文書に埋め込まれることで，最終的にユーザーに提示されるページが完成するのである． また，新しいツイートを投稿するときにも，クライアントから API を通じてサーバーのデータベースにデータが書き込まれる．</p>
<h2 id="rest-api" tabindex="-1">REST API <a class="header-anchor" href="#rest-api" aria-label="Permalink to &quot;REST API&quot;">&ZeroWidthSpace;</a></h2>
<p>API (Application Programming Interface) とはこれまで何度も出てきた言葉であるが，ここではよりフォーマルな定義付けを行う． API とはあるソフトウェア・アプリケーションが，外部のソフトウェアに対してコマンドやデータをやり取りするための媒介の一般的総称である． とくに，ウェブサービスの文脈では，サーバーが外界に対して提示しているコマンドの一覧のことを意味する． クライアントは，提示されている API から適切なコマンドを使うことによって，所望のデータを取得したり，あるいはサーバーにデータを送信したりする．</p>
<p>とくに，ウェブの文脈では <strong>REST (Representational State Transfer)</strong> とよばれる設計思想に基づいた API が現在では最も一般的に使われている． REST の設計指針に従った API のことを <strong>REST API</strong> あるいは <strong>RESTful API</strong> とよんだりする．</p>
<p>REST API は， <a href="#rest_api">figure_title</a> に示したような <strong>Method</strong> と <strong>URI (Universal Resource Identifier)</strong> の組からなる．</p>
<p><img src="./assets/rest_api.png" alt="REST API"></p>
<p>Method (メソッド) とは，どのような操作を行いたいかを抽象的に表す，<strong>&quot;動詞&quot;</strong> として捉えることができる． メソッドには HTTP 規格で定義された 9 個の動詞 (verb) を使用することができる． この中でも， <code>GET</code>, <code>POST</code>, <code>PUT</code>, <code>PATCH</code>, <code>DELETE</code> の 5 個が最も頻繁に使用される (<a href="#tab:rest_api_methods">table_title</a>)． この 5 つのメソッドによる操作を総称して <strong>CRUD</strong> (create, read, update, and delete) とよぶ．</p>
<table><caption>REST API Methods</caption><colgroup><col style="width: 25%" /><col style="width: 75%" /></colgroup><thead><tr class="header"><th>メソッド</th><th>意図される動作</th></tr></thead><tbody><tr class="odd"><td><p>GET</p></td><td><p>要素を取得する</p></td></tr><tr class="even"><td><p>POST</p></td><td><p>新しい要素を作成する</p></td></tr><tr class="odd"><td><p>PUT</p></td><td><p>既存の要素を新しい要素と置き換える</p></td></tr><tr class="even"><td><p>PATCH</p></td><td><p>既存の要素の一部を更新する</p></td></tr><tr class="odd"><td><p>DELETE</p></td><td><p>要素を削除する</p></td></tr></tbody></table>
<p>一方， URI は操作が行われる対象，すなわち <strong>&quot;目的語&quot;</strong> を表す． ウェブの文脈では操作が行われる対象のことをしばしば <strong>リソース</strong> とよぶ． URI は多くの場合 http または https から始まるウェブサーバーのアドレスから始まり， / (スラッシュ) 以降に所望のリソースのパスが指定される． <a href="#rest_api">figure_title</a> の例で言えば， <code>https://api.twitter.com</code> というアドレスの <code>/1.1/status/home_timeline</code> というリソースを取得 (GET) せよ，という意味になる (なお，ここで <code>1.1</code> という数字は API のバージョンを示している)． この API リクエストによって，ユーザーのホームのタイムラインのツイートの一覧が取得される．</p>
<p>REST API のメソッドには， <a href="#tab:rest_api_methods">table_title</a> で挙げたもの以外に， HTTP プロトコルで定義されているほかのメソッド (OPTIONS, TRACE など) を用いることもできるが，あまり一般的ではない．</p>
<p>また，これらのメソッドだけでは動詞として表現しきれないこともあるが， URI の名前でより意味を明確にすることもある． メソッドの使い方も，要素を削除する際は必ず <code>DELETE</code> を使わなければならない，という決まりもなく，たとえば， Twitter API でツイートを消す API は <code>POST statuses/destroy/:id</code> で定義されている． 最終的には，各ウェブサービスが公開している API ドキュメンテーションを読んで，それぞれの API がどんな操作をするのかを調べる必要がある．</p>
<p>REST の概念は 2000 年代初頭に確立され，今日の API 設計のスタンダードとなった． 一方で，ウェブのテクノロジーが進歩するにつれて，新たな API の設計アプローチの需要も高まっている． 近年とくに人気を集めているのが， <a href="https://graphql.org/" target="_blank" rel="noreferrer">GraphQL</a> と呼ばれる API の設計方法である． GraphQL は Facebook 社によって最初に作られ，現在は GraghQL Foundation によって維持と更新がされている． GraphQL を使用すると，クライアントは REST と比較してより柔軟性の高いデータのクエリを行うことができるなど，いくつかの利点がある． キーワードだけでも知っておくと，今後役に立つだろう．</p>
<h2 id="twitter-api" tabindex="-1">Twitter API <a class="header-anchor" href="#twitter-api" aria-label="Permalink to &quot;Twitter API&quot;">&ZeroWidthSpace;</a></h2>
<p>もう少し具体的にウェブサービスの API を体験する目的で，ここでは Twitter の API を見てみよう． Twitter が提供している API の一覧は <a href="https://developer.twitter.com/en/docs/api-reference-index" target="_blank" rel="noreferrer">Twitter の Developer Documentation</a> で見ることができる． いくつかの代表的な API を <a href="#tab_twitter_api">table_title</a> にまとめた．</p>
<table><caption>Twitter API</caption><colgroup><col style="width: 50%" /><col style="width: 50%" /></colgroup><thead><tr class="header"><th>エンドポイント</th><th>動作</th></tr></thead><tbody><tr class="odd"><td><p><code>GET statuses/home_timeline</code></p></td><td><p>ホームのタイムラインのツイートの一覧を取得する．</p></td></tr><tr class="even"><td><p><code>GET statuses/show/:id</code></p></td><td><p><code>:id</code> で指定されたツイートの詳細情報を取得する．</p></td></tr><tr class="odd"><td><p><code>GET search</code></p></td><td><p>ツイートの検索を実行する．</p></td></tr><tr class="even"><td><p><code>POST statuses/update</code></p></td><td><p>新しいツイートを投稿する．</p></td></tr><tr class="odd"><td><p><code>POST media/upload</code></p></td><td><p>画像をアップロードする</p></td></tr><tr class="even"><td><p><code>POST statuses/destroy/:id</code></p></td><td><p><code>:id</code> で指定されたツイートを削除する．</p></td></tr><tr class="odd"><td><p><code>POST statuses/retweet/:id</code></p></td><td><p><code>:id</code> で指定されたツイートをリツイートする．</p></td></tr><tr class="even"><td><p><code>POST statuses/unretweet/:id</code></p></td><td><p><code>:id</code> で指定されたツイートのリツイートを取り消す．</p></td></tr><tr class="odd"><td><p><code>POST favorites/create</code></p></td><td><p>選択したツイートを"いいね"する．</p></td></tr><tr class="even"><td><p><code>POST favorites/destroy</code></p></td><td><p>選択したツイートを"いいね"を取り消す．</p></td></tr></tbody></table>
<p>この API リストをもとに， Twitter のアプリまたはウェブサイトを開いたときに起こるクライアントとサーバーの通信をシミュレートしてみよう．</p>
<p>ユーザーが Twitter を開くと，まず最初に <code>GET statuses/home_timeline</code> の API リクエストによって，ユーザーのホームのタイムラインのツイートのリストが取得される． 個々のツイートは JSON 形式のデータになっており， <code>id</code>, <code>text</code>, <code>user</code>, <code>coordinates</code>, <code>entities</code> などの属性を含む． <code>id</code> はツイートに固有な ID を表し， <code>text</code> はツイートの本文を含んでいる． <code>user</code> はツイートを投稿したユーザーの名前やプロフィール画像の URL などを含んだ JSON データになっている． <code>coordinates</code> にはツイートが発信された地理的な座標が記録されている． また， <code>entities</code> にはツイートに関連するメディアファイル (画像など) のリンクなどの情報が埋め込まれている． <code>GET statuses/home_timeline</code> からは直近のツイートのリスト (リストが長すぎる場合は途中で切られたもの) が取得される． もしツイートの ID を知っている場合は <code>GET statuses/show/:id</code> を呼ぶことによって， <code>:id</code> パラメータで指定された特定のツイートを取得することができる．</p>
<p>ツイートの検索を行うためには <code>GET search</code> API を使用する． この API には，ツイートに含まれる単語や，ハッシュタグ，ツイートの発信された日時や場所など，様々なクエリの条件を渡すことができる． API からは， <code>GET statuses/home_timeline</code> などと同様， JSON 形式のツイートのデータが返される．</p>
<p>ユーザーが新しいツイートを投稿するには <code>POST statuses/update</code> のエンドポイントを利用する． <code>POST statuses/update</code> には，ツイートの文章や，リプライの場合はリプライ先のツイートの ID などのデータを送信する． また，ツイートに画像データを添付したい場合は， <code>POST media/upload</code> を併せて使用する． ツイートの削除を行うには， <code>POST statuses/destroy/:id</code> を用いる．</p>
<p>そのほか，頻繁に行われる操作としては， <code>POST statuses/retweet/:id</code> と <code>POST statuses/unretweet/:id</code> がある． これらは， <code>:id</code> で指定されるツイートに対して，それぞれリツイートを実行あるいは取り消すための API である． また， <code>POST favorites/create</code>，<code>POST favorites/destroy</code> を使用することによって，選択されたツイートに&quot;いいね&quot;を追加したり，取り消したりする操作を行う．</p>
<p>このような一連の操作が， Twitter のアプリの背後では行われている． また，自分自身でボットを作成したい場合は，これらの API を適切に組み合わせ，カスタムのプログラムを書くことで実現される．</p>
<p>このように， API はあらゆるウェブサービスを作るうえで一番基礎となる要素である． 次からの章では本章で紹介した用語が何度も出てくるので，頭の片隅に置いたうえで読み進めていただきたい．</p>
]]></description>
            <content:encoded><![CDATA[<h1 id="web-サービスの作り方" tabindex="-1">Web サービスの作り方 <a class="header-anchor" href="#web-サービスの作り方" aria-label="Permalink to &quot;Web サービスの作り方&quot;">&ZeroWidthSpace;</a></h1>
<p>ここからが，本書第三部の内容になる． これまでのセクションでは，仮想サーバーをクラウド上に起動し，そこで計算を走らせる方法について解説をしてきた． EC2, ECS, Fargate, Batch などを利用して，動的にスケールするクラスターを構成し，並列にタスクを実行するクラウドシステムを実装してきた． 振り返ると，これまで紹介してきた内容は，<strong>自分自身が行いたい計算をクラウドを駆使することで実現する</strong>，という用途にフォーカスしていたことに気がつくだろう． 一方で，<strong>広く一般の人々に使ってもらえるような計算サービス・データベース</strong>を提供する，というのもクラウドの重要な役割として挙げられる．</p>
<p>本章から始まる第三部では，前回までとは少し方向性を変え，どのようにしてクラウド上にアプリケーションを展開し，広く一般の人に使ってもらうか，という点を講義したいと思う． これを通じて，どのようにして世の中のウェブサービスができ上がっているのかを知り，さらにどうやって自分でそのようなアプリケーションをゼロから構築するのか，という点を学んでもらう． その過程で，サーバーレスアーキテクチャという最新のクラウド設計手法を解説する．</p>
<p>その前準備として，本章ではどのようにしてウェブサービスが出来上がっているのか，その背後にある技術の概要を解説する． 用語の解説が中心となるが，後のハンズオンを実装するために必須の知識であるので，理解して前に進むよう心がけよう．</p>
<h2 id="ウェブサービスの仕組み-—-twitter-を例に" tabindex="-1">ウェブサービスの仕組み  — Twitter を例に <a class="header-anchor" href="#ウェブサービスの仕組み-—-twitter-を例に" aria-label="Permalink to &quot;ウェブサービスの仕組み  — Twitter を例に&quot;">&ZeroWidthSpace;</a></h2>
<p>あなたがパソコンやスマートフォンから Twitter, Facebook, YouTube などのウェブサービスにアクセスしたとき，実際にどのようなことが行われ，コンテンツが提示されているのだろうか？</p>
<p>HTTP を通じたサーバーとクライアントのデータのやり取りは，すでに知っている読者も多いだろうし，逆にすべて解説しようとすると紙面が足りないので，ここではエッセンスの説明のみにとどめる． 以降では <a href="https://twitter.com" target="_blank" rel="noreferrer">Twitter</a> を具体例として，背後にあるサーバーとクライアントの間の通信を概説しよう． 概念図としては <a href="#fig:web_server">figure_title</a> のような通信がクライアントとサーバーの間で行われていることになる．</p>
<p><img src="./assets/web_server.png" alt="クライアントと Web サーバーの通信の概念図"></p>
<p>前提として，クライアントとサーバーの通信は <strong>HTTP (Hypertext Transfer Protocol)</strong> を使って行われる． また，最近では，暗号化された HTTP である <strong>HTTPS (HTTPS (Hypertext Transfer Protocol Secure))</strong> を用いることがスタンダードになってきている． 第一のステップとして，クライアントは HTTP(S) 通信によってサーバーから静的なコンテンツを取得する． 静的なコンテンツとは， <strong>HTML (Hyptertext Markup Language)</strong> で記述されたウェブページの文書本体， <strong>CSS (Cascading Style Sheets)</strong> で記述されたページのデザインやレイアウトファイル，そして <strong>JavaScript (JS)</strong> で記述されたページの動的な挙動を定義したプログラム，が含まれる． Twitter を含む現代的なウェブアプリケーションの設計では，この静的なファイル群はページの”枠”を定義するだけで，中身となるコンテンツ (例: ツイートの一覧) は別途 <strong>API (Application Programming Interface)</strong> によって取得されなければならない． そこで，クライアントは先のステップで取得された JavaScript で定義されたプログラムに従って，サーバーに API を送信し，ツイートや画像データを取得する． この際，テキストデータのやり取りには <strong>JSON (JavaScript Object Notation)</strong> というフォーマットが用いられることが多い． 画像や動画などのコンテンツも同様に API により取得される． このようにして取得されたテキストや画像が，HTML の文書に埋め込まれることで，最終的にユーザーに提示されるページが完成するのである． また，新しいツイートを投稿するときにも，クライアントから API を通じてサーバーのデータベースにデータが書き込まれる．</p>
<h2 id="rest-api" tabindex="-1">REST API <a class="header-anchor" href="#rest-api" aria-label="Permalink to &quot;REST API&quot;">&ZeroWidthSpace;</a></h2>
<p>API (Application Programming Interface) とはこれまで何度も出てきた言葉であるが，ここではよりフォーマルな定義付けを行う． API とはあるソフトウェア・アプリケーションが，外部のソフトウェアに対してコマンドやデータをやり取りするための媒介の一般的総称である． とくに，ウェブサービスの文脈では，サーバーが外界に対して提示しているコマンドの一覧のことを意味する． クライアントは，提示されている API から適切なコマンドを使うことによって，所望のデータを取得したり，あるいはサーバーにデータを送信したりする．</p>
<p>とくに，ウェブの文脈では <strong>REST (Representational State Transfer)</strong> とよばれる設計思想に基づいた API が現在では最も一般的に使われている． REST の設計指針に従った API のことを <strong>REST API</strong> あるいは <strong>RESTful API</strong> とよんだりする．</p>
<p>REST API は， <a href="#rest_api">figure_title</a> に示したような <strong>Method</strong> と <strong>URI (Universal Resource Identifier)</strong> の組からなる．</p>
<p><img src="./assets/rest_api.png" alt="REST API"></p>
<p>Method (メソッド) とは，どのような操作を行いたいかを抽象的に表す，<strong>&quot;動詞&quot;</strong> として捉えることができる． メソッドには HTTP 規格で定義された 9 個の動詞 (verb) を使用することができる． この中でも， <code>GET</code>, <code>POST</code>, <code>PUT</code>, <code>PATCH</code>, <code>DELETE</code> の 5 個が最も頻繁に使用される (<a href="#tab:rest_api_methods">table_title</a>)． この 5 つのメソッドによる操作を総称して <strong>CRUD</strong> (create, read, update, and delete) とよぶ．</p>
<table><caption>REST API Methods</caption><colgroup><col style="width: 25%" /><col style="width: 75%" /></colgroup><thead><tr class="header"><th>メソッド</th><th>意図される動作</th></tr></thead><tbody><tr class="odd"><td><p>GET</p></td><td><p>要素を取得する</p></td></tr><tr class="even"><td><p>POST</p></td><td><p>新しい要素を作成する</p></td></tr><tr class="odd"><td><p>PUT</p></td><td><p>既存の要素を新しい要素と置き換える</p></td></tr><tr class="even"><td><p>PATCH</p></td><td><p>既存の要素の一部を更新する</p></td></tr><tr class="odd"><td><p>DELETE</p></td><td><p>要素を削除する</p></td></tr></tbody></table>
<p>一方， URI は操作が行われる対象，すなわち <strong>&quot;目的語&quot;</strong> を表す． ウェブの文脈では操作が行われる対象のことをしばしば <strong>リソース</strong> とよぶ． URI は多くの場合 http または https から始まるウェブサーバーのアドレスから始まり， / (スラッシュ) 以降に所望のリソースのパスが指定される． <a href="#rest_api">figure_title</a> の例で言えば， <code>https://api.twitter.com</code> というアドレスの <code>/1.1/status/home_timeline</code> というリソースを取得 (GET) せよ，という意味になる (なお，ここで <code>1.1</code> という数字は API のバージョンを示している)． この API リクエストによって，ユーザーのホームのタイムラインのツイートの一覧が取得される．</p>
<p>REST API のメソッドには， <a href="#tab:rest_api_methods">table_title</a> で挙げたもの以外に， HTTP プロトコルで定義されているほかのメソッド (OPTIONS, TRACE など) を用いることもできるが，あまり一般的ではない．</p>
<p>また，これらのメソッドだけでは動詞として表現しきれないこともあるが， URI の名前でより意味を明確にすることもある． メソッドの使い方も，要素を削除する際は必ず <code>DELETE</code> を使わなければならない，という決まりもなく，たとえば， Twitter API でツイートを消す API は <code>POST statuses/destroy/:id</code> で定義されている． 最終的には，各ウェブサービスが公開している API ドキュメンテーションを読んで，それぞれの API がどんな操作をするのかを調べる必要がある．</p>
<p>REST の概念は 2000 年代初頭に確立され，今日の API 設計のスタンダードとなった． 一方で，ウェブのテクノロジーが進歩するにつれて，新たな API の設計アプローチの需要も高まっている． 近年とくに人気を集めているのが， <a href="https://graphql.org/" target="_blank" rel="noreferrer">GraphQL</a> と呼ばれる API の設計方法である． GraphQL は Facebook 社によって最初に作られ，現在は GraghQL Foundation によって維持と更新がされている． GraphQL を使用すると，クライアントは REST と比較してより柔軟性の高いデータのクエリを行うことができるなど，いくつかの利点がある． キーワードだけでも知っておくと，今後役に立つだろう．</p>
<h2 id="twitter-api" tabindex="-1">Twitter API <a class="header-anchor" href="#twitter-api" aria-label="Permalink to &quot;Twitter API&quot;">&ZeroWidthSpace;</a></h2>
<p>もう少し具体的にウェブサービスの API を体験する目的で，ここでは Twitter の API を見てみよう． Twitter が提供している API の一覧は <a href="https://developer.twitter.com/en/docs/api-reference-index" target="_blank" rel="noreferrer">Twitter の Developer Documentation</a> で見ることができる． いくつかの代表的な API を <a href="#tab_twitter_api">table_title</a> にまとめた．</p>
<table><caption>Twitter API</caption><colgroup><col style="width: 50%" /><col style="width: 50%" /></colgroup><thead><tr class="header"><th>エンドポイント</th><th>動作</th></tr></thead><tbody><tr class="odd"><td><p><code>GET statuses/home_timeline</code></p></td><td><p>ホームのタイムラインのツイートの一覧を取得する．</p></td></tr><tr class="even"><td><p><code>GET statuses/show/:id</code></p></td><td><p><code>:id</code> で指定されたツイートの詳細情報を取得する．</p></td></tr><tr class="odd"><td><p><code>GET search</code></p></td><td><p>ツイートの検索を実行する．</p></td></tr><tr class="even"><td><p><code>POST statuses/update</code></p></td><td><p>新しいツイートを投稿する．</p></td></tr><tr class="odd"><td><p><code>POST media/upload</code></p></td><td><p>画像をアップロードする</p></td></tr><tr class="even"><td><p><code>POST statuses/destroy/:id</code></p></td><td><p><code>:id</code> で指定されたツイートを削除する．</p></td></tr><tr class="odd"><td><p><code>POST statuses/retweet/:id</code></p></td><td><p><code>:id</code> で指定されたツイートをリツイートする．</p></td></tr><tr class="even"><td><p><code>POST statuses/unretweet/:id</code></p></td><td><p><code>:id</code> で指定されたツイートのリツイートを取り消す．</p></td></tr><tr class="odd"><td><p><code>POST favorites/create</code></p></td><td><p>選択したツイートを"いいね"する．</p></td></tr><tr class="even"><td><p><code>POST favorites/destroy</code></p></td><td><p>選択したツイートを"いいね"を取り消す．</p></td></tr></tbody></table>
<p>この API リストをもとに， Twitter のアプリまたはウェブサイトを開いたときに起こるクライアントとサーバーの通信をシミュレートしてみよう．</p>
<p>ユーザーが Twitter を開くと，まず最初に <code>GET statuses/home_timeline</code> の API リクエストによって，ユーザーのホームのタイムラインのツイートのリストが取得される． 個々のツイートは JSON 形式のデータになっており， <code>id</code>, <code>text</code>, <code>user</code>, <code>coordinates</code>, <code>entities</code> などの属性を含む． <code>id</code> はツイートに固有な ID を表し， <code>text</code> はツイートの本文を含んでいる． <code>user</code> はツイートを投稿したユーザーの名前やプロフィール画像の URL などを含んだ JSON データになっている． <code>coordinates</code> にはツイートが発信された地理的な座標が記録されている． また， <code>entities</code> にはツイートに関連するメディアファイル (画像など) のリンクなどの情報が埋め込まれている． <code>GET statuses/home_timeline</code> からは直近のツイートのリスト (リストが長すぎる場合は途中で切られたもの) が取得される． もしツイートの ID を知っている場合は <code>GET statuses/show/:id</code> を呼ぶことによって， <code>:id</code> パラメータで指定された特定のツイートを取得することができる．</p>
<p>ツイートの検索を行うためには <code>GET search</code> API を使用する． この API には，ツイートに含まれる単語や，ハッシュタグ，ツイートの発信された日時や場所など，様々なクエリの条件を渡すことができる． API からは， <code>GET statuses/home_timeline</code> などと同様， JSON 形式のツイートのデータが返される．</p>
<p>ユーザーが新しいツイートを投稿するには <code>POST statuses/update</code> のエンドポイントを利用する． <code>POST statuses/update</code> には，ツイートの文章や，リプライの場合はリプライ先のツイートの ID などのデータを送信する． また，ツイートに画像データを添付したい場合は， <code>POST media/upload</code> を併せて使用する． ツイートの削除を行うには， <code>POST statuses/destroy/:id</code> を用いる．</p>
<p>そのほか，頻繁に行われる操作としては， <code>POST statuses/retweet/:id</code> と <code>POST statuses/unretweet/:id</code> がある． これらは， <code>:id</code> で指定されるツイートに対して，それぞれリツイートを実行あるいは取り消すための API である． また， <code>POST favorites/create</code>，<code>POST favorites/destroy</code> を使用することによって，選択されたツイートに&quot;いいね&quot;を追加したり，取り消したりする操作を行う．</p>
<p>このような一連の操作が， Twitter のアプリの背後では行われている． また，自分自身でボットを作成したい場合は，これらの API を適切に組み合わせ，カスタムのプログラムを書くことで実現される．</p>
<p>このように， API はあらゆるウェブサービスを作るうえで一番基礎となる要素である． 次からの章では本章で紹介した用語が何度も出てくるので，頭の片隅に置いたうえで読み進めていただきたい．</p>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[File Name Conventions ]]></title>
            <link>https://note.toshiki.devdevelopment/file-naming-convention</link>
            <guid>https://note.toshiki.devdevelopment/file-naming-convention</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="file-name-conventions" tabindex="-1">File Name Conventions <a class="header-anchor" href="#file-name-conventions" aria-label="Permalink to &quot;File Name Conventions&quot;">&ZeroWidthSpace;</a></h1>
<blockquote>
<p>A collection of guidelines for writing file names used in web projects.</p>
</blockquote>
<h2 id="possible-characters" tabindex="-1">Possible characters <a class="header-anchor" href="#possible-characters" aria-label="Permalink to &quot;Possible characters&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="use-dashes-as-delimiters" tabindex="-1">Use dashes as delimiters <a class="header-anchor" href="#use-dashes-as-delimiters" aria-label="Permalink to &quot;Use dashes as delimiters&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>You should use dashes (-) as delimiters.</li>
<li>Periods are allowed in some cases, such as for languages and conditions.</li>
<li>Never use spaces or underscores. Spaces are converted to %20 in URLs or can break an URL when shared. Underscores are difficult to see when the file name is displayed as an underlined link. Although the use of underscores does not impact your ranking that much, <a href="https://www.youtube.com/watch?v=AQcSFsQyct8" target="_blank" rel="noreferrer">Google advices not to use underscores</a>.</li>
<li>Exceptions apply for functional requirements, such as for <a href="http://sass-lang.com/guide#topic-4" target="_blank" rel="noreferrer">Sass partials</a>. A leading underscore informs the Sass compiler a file is only a partial file and should never be generated into a stand alone CSS file.</li>
</ul>
<p><strong>Right:</strong></p>
<div class="language- vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #adbac7">file-name-with-dashes.en.min.html</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292e">file-name-with-dashes.en.min.html</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><h3 id="do-not-use-special-characters" tabindex="-1">Do not use special characters <a class="header-anchor" href="#do-not-use-special-characters" aria-label="Permalink to &quot;Do not use special characters&quot;">&ZeroWidthSpace;</a></h3>
<p>Avoid using non-alphanumeric characters in file names, such as: '<code>*</code>' '<code>:</code>' '<code>\</code>' '<code>/</code>' '<code>&lt;</code>' '<code>&gt;</code>' '<code>|</code>' '<code>&quot;</code>' '<code>!</code>' '<code>?</code>' '<code>[</code>' '<code>]</code>' '<code>;</code>' '<code>=</code>' '<code>+</code>' '<code>&amp;</code>' '<code>£</code>' '<code>$</code>' '<code>€</code>' '<code>%</code>' or '<code>,</code>'. These characters can have special meaning in programming languages or can cause problems with different operating systems.</p>
<h3 id="use-lowercase-never-uppercase" tabindex="-1">Use lowercase, never uppercase <a class="header-anchor" href="#use-lowercase-never-uppercase" aria-label="Permalink to &quot;Use lowercase, never uppercase&quot;">&ZeroWidthSpace;</a></h3>
<p>We should always consider URLs as case-sensitive according to <a href="http://www.w3.org/TR/WD-html40-970708/htmlweb.html" target="_blank" rel="noreferrer">W3.org</a>. Therefore, use lowercase to reduces errors when typing URLs.</p>
<h2 id="write-sections-of-a-file-name-in-a-consistent-order" tabindex="-1">Write sections of a file name in a consistent order <a class="header-anchor" href="#write-sections-of-a-file-name-in-a-consistent-order" aria-label="Permalink to &quot;Write sections of a file name in a consistent order&quot;">&ZeroWidthSpace;</a></h2>
<p>Sections should be written in this order:</p>
<ol>
<li>Description</li>
<li>Number</li>
<li>Date</li>
<li>Target device, image size, pixel density</li>
<li>Version number</li>
<li>Status</li>
<li>Language code</li>
<li>File conditions</li>
</ol>
<p><strong>Possible combinations</strong></p>
<div class="language- vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #adbac7">description-01-20150102-palm-1.0b-draft.en.min.js /* extreme combination */</span></span>
<span class="line"><span style="color: #adbac7">description.min.js</span></span>
<span class="line"><span style="color: #adbac7">description.en.html</span></span>
<span class="line"><span style="color: #adbac7">description-01.jpg</span></span>
<span class="line"><span style="color: #adbac7">description-02.jpg</span></span>
<span class="line"><span style="color: #adbac7">description-1024x768_2x.jpg</span></span>
<span class="line"><span style="color: #adbac7">description-desk_2x.jpg</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292e">description-01-20150102-palm-1.0b-draft.en.min.js /* extreme combination */</span></span>
<span class="line"><span style="color: #24292e">description.min.js</span></span>
<span class="line"><span style="color: #24292e">description.en.html</span></span>
<span class="line"><span style="color: #24292e">description-01.jpg</span></span>
<span class="line"><span style="color: #24292e">description-02.jpg</span></span>
<span class="line"><span style="color: #24292e">description-1024x768_2x.jpg</span></span>
<span class="line"><span style="color: #24292e">description-desk_2x.jpg</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br></div></div><h3 id="write-description-for-developers-and-users" tabindex="-1">Write description for developers and users <a class="header-anchor" href="#write-description-for-developers-and-users" aria-label="Permalink to &quot;Write description for developers and users&quot;">&ZeroWidthSpace;</a></h3>
<p>Don't be afraid to write long informative file names. Few people type a file name manually and most operating systems support <a href="http://en.wikipedia.org/wiki/Comparison_of_file_systems" target="_blank" rel="noreferrer">255 characters</a>. But only add information that makes it easy for users and developers to recognize files from one another at a glance. For the description use information such as:</p>
<ul>
<li>type of data</li>
<li>project name or acronym</li>
<li>subjects</li>
<li>people's names</li>
<li>characteristics</li>
<li>location</li>
</ul>
<blockquote>
<p><strong>Give your images detailed, informative filenames</strong> The filename can give Google clues about the subject matter of the image. Try to make your filename a good description of the subject matter of the image. For example, my-new-black-kitten.jpg is a lot more informative than IMG00023.JPG. Descriptive filenames can also be useful to users: If we're unable to find suitable text in the page on which we found the image, we'll use the filename as the image's snippet in our search results. - <a href="https://support.google.com/webmasters/answer/114016?hl=en" target="_blank" rel="noreferrer">Google, 2015, Image publishing guidelines</a></p>
</blockquote>
<h4 id="keep-people-s-names-compact" tabindex="-1">Keep people's names compact <a class="header-anchor" href="#keep-people-s-names-compact" aria-label="Permalink to &quot;Keep people's names compact&quot;">&ZeroWidthSpace;</a></h4>
<p>Sometimes you want to include the name of a person in the file name, e.g. the author or the person in the photo.</p>
<ul>
<li>Write names without word delimiters.</li>
<li>Only write initials for the first name and write the last name in full. There are two exceptions: (1) when the last name or final file name is very long you may use initials for the last name; (2) when there is already a person with the same combination, you may write the first name in full.</li>
<li>If people have exactly the same name written in full, you can add a number: firstnamelastname2.</li>
</ul>
<p><strong>Right:</strong></p>
<div class="language- vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #adbac7">bvandebiezen.jpg</span></span>
<span class="line"><span style="color: #adbac7">shoogenhout.jpg</span></span>
<span class="line"><span style="color: #adbac7">a-very-long-description-with-name-bvdb.jpg</span></span>
<span class="line"><span style="color: #adbac7">asmith.jpg</span></span>
<span class="line"><span style="color: #adbac7">adamsmith.jpg</span></span>
<span class="line"><span style="color: #adbac7">adamsmith2.jpg</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292e">bvandebiezen.jpg</span></span>
<span class="line"><span style="color: #24292e">shoogenhout.jpg</span></span>
<span class="line"><span style="color: #24292e">a-very-long-description-with-name-bvdb.jpg</span></span>
<span class="line"><span style="color: #24292e">asmith.jpg</span></span>
<span class="line"><span style="color: #24292e">adamsmith.jpg</span></span>
<span class="line"><span style="color: #24292e">adamsmith2.jpg</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br></div></div><h3 id="use-two-or-more-digits-to-distinguish-sequential-files-with-the-same-description" tabindex="-1">Use two or more digits to distinguish sequential files with the same description <a class="header-anchor" href="#use-two-or-more-digits-to-distinguish-sequential-files-with-the-same-description" aria-label="Permalink to &quot;Use two or more digits to distinguish sequential files with the same description&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>Start number with a dash as a delimiter.</li>
<li>Add a zero to single digit numbers, e.g. '01' instead of '1'.</li>
<li>Numbers may also be placed before the description if needed. A dash will still be used as delimiter with the description.</li>
</ul>
<p><strong>Right:</strong></p>
<div class="language- vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #adbac7">description-01.jpg</span></span>
<span class="line"><span style="color: #adbac7">description-02.jpg</span></span>
<span class="line"><span style="color: #adbac7">description-03.jpg</span></span>
<span class="line"><span style="color: #adbac7">description-04.jpg</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">01-description.jpg</span></span>
<span class="line"><span style="color: #adbac7">02-description.jpg</span></span>
<span class="line"><span style="color: #adbac7">03-description.jpg</span></span>
<span class="line"><span style="color: #adbac7">04-description.jpg</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292e">description-01.jpg</span></span>
<span class="line"><span style="color: #24292e">description-02.jpg</span></span>
<span class="line"><span style="color: #24292e">description-03.jpg</span></span>
<span class="line"><span style="color: #24292e">description-04.jpg</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">01-description.jpg</span></span>
<span class="line"><span style="color: #24292e">02-description.jpg</span></span>
<span class="line"><span style="color: #24292e">03-description.jpg</span></span>
<span class="line"><span style="color: #24292e">04-description.jpg</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br></div></div><h3 id="keep-dates-or-date-ranges-compact-and-start-with-year" tabindex="-1">Keep dates or date ranges compact and start with year <a class="header-anchor" href="#keep-dates-or-date-ranges-compact-and-start-with-year" aria-label="Permalink to &quot;Keep dates or date ranges compact and start with year&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>Write dates without delimiters.</li>
<li>Always use four digits for years, two digits for months and two digits for days.</li>
<li>Start with year, then month, and end with day if available: yyyymmdd, yyyymm, or yyyy. This makes sure similar file names are sorted by date when sorted alphabetically.</li>
<li>Use a double dash to separate two dates describing an interval: yyyy--yyyy. Start with the earliest date.</li>
</ul>
<p><strong>Right:</strong></p>
<div class="language- vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #adbac7">description-20150401.php</span></span>
<span class="line"><span style="color: #adbac7">description-201504.php</span></span>
<span class="line"><span style="color: #adbac7">description-2015.php</span></span>
<span class="line"><span style="color: #adbac7">description-2000--2010.php</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292e">description-20150401.php</span></span>
<span class="line"><span style="color: #24292e">description-201504.php</span></span>
<span class="line"><span style="color: #24292e">description-2015.php</span></span>
<span class="line"><span style="color: #24292e">description-2000--2010.php</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br></div></div><p>See <a href="https://en.wikipedia.org/wiki/ISO_8601" target="_blank" rel="noreferrer">'ISO 8601'</a> for further reading.</p>
<h3 id="use-special-modifiers-for-target-devices-image-sizes-or-media-queries-and-pixel-densities" tabindex="-1">Use special modifiers for target devices, image sizes or media queries, and pixel densities. <a class="header-anchor" href="#use-special-modifiers-for-target-devices-image-sizes-or-media-queries-and-pixel-densities" aria-label="Permalink to &quot;Use special modifiers for target devices, image sizes or media queries, and pixel densities.&quot;">&ZeroWidthSpace;</a></h3>
<p>Modifiers are inspired by <a href="https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/LoadingResources/ImageSoundResources/ImageSoundResources.html#//apple_ref/doc/uid/10000051i-CH7-SW1" target="_blank" rel="noreferrer">Apple iOS naming conventions</a>. There are some differences. Apple uses '<code>@</code>'as a delimiter for the section indicating higher resolution images, for example '<code>@2x</code>' for retina images. Because '<code>@</code>' is a reserved character and can create problems, we use <a href="http://bourbon.io/docs/#retina-image" target="_blank" rel="noreferrer">Bourbon's convention</a>: an underscore. Also, Apple uses a tilde (<code>~</code>) as a delimiter for a section indicating specific devices. Because also a tilde can create problems, we suggest to simply use a dash.</p>
<ul>
<li>Order should be: (<code>1</code>) target device or media query, (<code>2</code>) size, (<code>3</code>) pixel density.</li>
<li>Start target device or media queries with a dash (<code>-</code>) as delimiter.</li>
<li>Start image sizes with a dash (<code>-</code>) as delimiter.</li>
<li>Start pixel density with an underscore (<code>_</code>) as delimiter, for example '<code>_2x</code>' or '<code>_3x</code>'.</li>
<li>When only a width or height is available or applicable, add a '<code>w</code>' for width or '<code>h</code>' for height directly after the the amount of pixels.</li>
<li>When both measurements are available, do not add a '<code>w</code>' or 'h' and separate the width and height with an '<code>x</code>'.</li>
<li>When both the width and height should not exceed a dimension but the images should keep the original aspect ratio, add a '<code>max</code>' (maximum) after the amount of pixels.</li>
</ul>
<p><strong>Right:</strong></p>
<div class="language- vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #adbac7">description_2x.jpg</span></span>
<span class="line"><span style="color: #adbac7">description-lap.jpg</span></span>
<span class="line"><span style="color: #adbac7">description-desk.jpg</span></span>
<span class="line"><span style="color: #adbac7">description-lap_2x.jpg</span></span>
<span class="line"><span style="color: #adbac7">description-palm-1024w_2x.jpg</span></span>
<span class="line"><span style="color: #adbac7">description-iphone5-568h_2x.jpg</span></span>
<span class="line"><span style="color: #adbac7">description-palm-1024x768_2x.jpg</span></span>
<span class="line"><span style="color: #adbac7">description-40max.jpg</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292e">description_2x.jpg</span></span>
<span class="line"><span style="color: #24292e">description-lap.jpg</span></span>
<span class="line"><span style="color: #24292e">description-desk.jpg</span></span>
<span class="line"><span style="color: #24292e">description-lap_2x.jpg</span></span>
<span class="line"><span style="color: #24292e">description-palm-1024w_2x.jpg</span></span>
<span class="line"><span style="color: #24292e">description-iphone5-568h_2x.jpg</span></span>
<span class="line"><span style="color: #24292e">description-palm-1024x768_2x.jpg</span></span>
<span class="line"><span style="color: #24292e">description-40max.jpg</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br></div></div><h3 id="use-version-numbers-if-available" tabindex="-1">Use version numbers if available <a class="header-anchor" href="#use-version-numbers-if-available" aria-label="Permalink to &quot;Use version numbers if available&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>Start version with a dash (<code>-</code>) as delimiter.</li>
<li>Use periods (<code>.</code>) to separate point releases.</li>
<li>Always add trailing zeros to major releases, e.g. '<code>2.0</code>' instead of '<code>2</code>'.</li>
<li>Types, such as '<code>a</code>' (alpha), '<code>b</code>' (beta), 'rc1' (release candidate 1) can be added without delimiters.</li>
</ul>
<p><strong>Right:</strong></p>
<div class="language- vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #adbac7">description-0.5.js</span></span>
<span class="line"><span style="color: #adbac7">description-1.0b.js</span></span>
<span class="line"><span style="color: #adbac7">description-1.0rc1.js</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292e">description-0.5.js</span></span>
<span class="line"><span style="color: #24292e">description-1.0b.js</span></span>
<span class="line"><span style="color: #24292e">description-1.0rc1.js</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><h3 id="add-status-when-needed" tabindex="-1">Add status when needed <a class="header-anchor" href="#add-status-when-needed" aria-label="Permalink to &quot;Add status when needed&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>You can optionally add a file status such as '<code>draft</code>' and '<code>published</code>'.</li>
<li>Start status with a dash.</li>
</ul>
<p><strong>Right:</strong></p>
<div class="language- vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #adbac7">description-draft.md</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292e">description-draft.md</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><h3 id="add-language-code-only-when-different-languages-are-available" tabindex="-1">Add language code only when different languages are available <a class="header-anchor" href="#add-language-code-only-when-different-languages-are-available" aria-label="Permalink to &quot;Add language code only when different languages are available&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>Use a period to separate the language code from the rest of the file name.</li>
<li>Use <a href="https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes" target="_blank" rel="noreferrer">ISO 639-1</a>, two-letter codes, for languages.</li>
<li>Only add languages when different languages are available.</li>
</ul>
<p><strong>Right:</strong></p>
<div class="language- vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #adbac7">description.nl.txt</span></span>
<span class="line"><span style="color: #adbac7">description.en.txt</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292e">description.nl.txt</span></span>
<span class="line"><span style="color: #24292e">description.en.txt</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><h3 id="add-file-conditions-just-before-the-file-extension" tabindex="-1">Add file conditions just before the file extension <a class="header-anchor" href="#add-file-conditions-just-before-the-file-extension" aria-label="Permalink to &quot;Add file conditions just before the file extension&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>The file condition should be the last part, just before the file extension.</li>
<li>Use a period (<code>.</code>) to separate the condition from the rest of the file name.</li>
<li>Use periods (<code>.</code>) as a delimiter for different conditions.</li>
</ul>
<p><strong>Right:</strong></p>
<div class="language- vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #adbac7">description.min.js</span></span>
<span class="line"><span style="color: #adbac7">description.custom1234.min.js</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292e">description.min.js</span></span>
<span class="line"><span style="color: #24292e">description.custom1234.min.js</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><h2 id="rewrite-original-file-names-not-following-conventions" tabindex="-1">Rewrite original file names not following conventions <a class="header-anchor" href="#rewrite-original-file-names-not-following-conventions" aria-label="Permalink to &quot;Rewrite original file names not following conventions&quot;">&ZeroWidthSpace;</a></h2>
<p>It is not preferred to keep file names in it's original format if it doesn't match your file name conventions. But in some cases it is easier to keep the file name untouched. Sometimes you want to easily replace a file with a newer one from the original source in the future.</p>
]]></description>
            <content:encoded><![CDATA[<h1 id="file-name-conventions" tabindex="-1">File Name Conventions <a class="header-anchor" href="#file-name-conventions" aria-label="Permalink to &quot;File Name Conventions&quot;">&ZeroWidthSpace;</a></h1>
<blockquote>
<p>A collection of guidelines for writing file names used in web projects.</p>
</blockquote>
<h2 id="possible-characters" tabindex="-1">Possible characters <a class="header-anchor" href="#possible-characters" aria-label="Permalink to &quot;Possible characters&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="use-dashes-as-delimiters" tabindex="-1">Use dashes as delimiters <a class="header-anchor" href="#use-dashes-as-delimiters" aria-label="Permalink to &quot;Use dashes as delimiters&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>You should use dashes (-) as delimiters.</li>
<li>Periods are allowed in some cases, such as for languages and conditions.</li>
<li>Never use spaces or underscores. Spaces are converted to %20 in URLs or can break an URL when shared. Underscores are difficult to see when the file name is displayed as an underlined link. Although the use of underscores does not impact your ranking that much, <a href="https://www.youtube.com/watch?v=AQcSFsQyct8" target="_blank" rel="noreferrer">Google advices not to use underscores</a>.</li>
<li>Exceptions apply for functional requirements, such as for <a href="http://sass-lang.com/guide#topic-4" target="_blank" rel="noreferrer">Sass partials</a>. A leading underscore informs the Sass compiler a file is only a partial file and should never be generated into a stand alone CSS file.</li>
</ul>
<p><strong>Right:</strong></p>
<div class="language- vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #adbac7">file-name-with-dashes.en.min.html</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292e">file-name-with-dashes.en.min.html</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><h3 id="do-not-use-special-characters" tabindex="-1">Do not use special characters <a class="header-anchor" href="#do-not-use-special-characters" aria-label="Permalink to &quot;Do not use special characters&quot;">&ZeroWidthSpace;</a></h3>
<p>Avoid using non-alphanumeric characters in file names, such as: '<code>*</code>' '<code>:</code>' '<code>\</code>' '<code>/</code>' '<code>&lt;</code>' '<code>&gt;</code>' '<code>|</code>' '<code>&quot;</code>' '<code>!</code>' '<code>?</code>' '<code>[</code>' '<code>]</code>' '<code>;</code>' '<code>=</code>' '<code>+</code>' '<code>&amp;</code>' '<code>£</code>' '<code>$</code>' '<code>€</code>' '<code>%</code>' or '<code>,</code>'. These characters can have special meaning in programming languages or can cause problems with different operating systems.</p>
<h3 id="use-lowercase-never-uppercase" tabindex="-1">Use lowercase, never uppercase <a class="header-anchor" href="#use-lowercase-never-uppercase" aria-label="Permalink to &quot;Use lowercase, never uppercase&quot;">&ZeroWidthSpace;</a></h3>
<p>We should always consider URLs as case-sensitive according to <a href="http://www.w3.org/TR/WD-html40-970708/htmlweb.html" target="_blank" rel="noreferrer">W3.org</a>. Therefore, use lowercase to reduces errors when typing URLs.</p>
<h2 id="write-sections-of-a-file-name-in-a-consistent-order" tabindex="-1">Write sections of a file name in a consistent order <a class="header-anchor" href="#write-sections-of-a-file-name-in-a-consistent-order" aria-label="Permalink to &quot;Write sections of a file name in a consistent order&quot;">&ZeroWidthSpace;</a></h2>
<p>Sections should be written in this order:</p>
<ol>
<li>Description</li>
<li>Number</li>
<li>Date</li>
<li>Target device, image size, pixel density</li>
<li>Version number</li>
<li>Status</li>
<li>Language code</li>
<li>File conditions</li>
</ol>
<p><strong>Possible combinations</strong></p>
<div class="language- vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #adbac7">description-01-20150102-palm-1.0b-draft.en.min.js /* extreme combination */</span></span>
<span class="line"><span style="color: #adbac7">description.min.js</span></span>
<span class="line"><span style="color: #adbac7">description.en.html</span></span>
<span class="line"><span style="color: #adbac7">description-01.jpg</span></span>
<span class="line"><span style="color: #adbac7">description-02.jpg</span></span>
<span class="line"><span style="color: #adbac7">description-1024x768_2x.jpg</span></span>
<span class="line"><span style="color: #adbac7">description-desk_2x.jpg</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292e">description-01-20150102-palm-1.0b-draft.en.min.js /* extreme combination */</span></span>
<span class="line"><span style="color: #24292e">description.min.js</span></span>
<span class="line"><span style="color: #24292e">description.en.html</span></span>
<span class="line"><span style="color: #24292e">description-01.jpg</span></span>
<span class="line"><span style="color: #24292e">description-02.jpg</span></span>
<span class="line"><span style="color: #24292e">description-1024x768_2x.jpg</span></span>
<span class="line"><span style="color: #24292e">description-desk_2x.jpg</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br></div></div><h3 id="write-description-for-developers-and-users" tabindex="-1">Write description for developers and users <a class="header-anchor" href="#write-description-for-developers-and-users" aria-label="Permalink to &quot;Write description for developers and users&quot;">&ZeroWidthSpace;</a></h3>
<p>Don't be afraid to write long informative file names. Few people type a file name manually and most operating systems support <a href="http://en.wikipedia.org/wiki/Comparison_of_file_systems" target="_blank" rel="noreferrer">255 characters</a>. But only add information that makes it easy for users and developers to recognize files from one another at a glance. For the description use information such as:</p>
<ul>
<li>type of data</li>
<li>project name or acronym</li>
<li>subjects</li>
<li>people's names</li>
<li>characteristics</li>
<li>location</li>
</ul>
<blockquote>
<p><strong>Give your images detailed, informative filenames</strong> The filename can give Google clues about the subject matter of the image. Try to make your filename a good description of the subject matter of the image. For example, my-new-black-kitten.jpg is a lot more informative than IMG00023.JPG. Descriptive filenames can also be useful to users: If we're unable to find suitable text in the page on which we found the image, we'll use the filename as the image's snippet in our search results. - <a href="https://support.google.com/webmasters/answer/114016?hl=en" target="_blank" rel="noreferrer">Google, 2015, Image publishing guidelines</a></p>
</blockquote>
<h4 id="keep-people-s-names-compact" tabindex="-1">Keep people's names compact <a class="header-anchor" href="#keep-people-s-names-compact" aria-label="Permalink to &quot;Keep people's names compact&quot;">&ZeroWidthSpace;</a></h4>
<p>Sometimes you want to include the name of a person in the file name, e.g. the author or the person in the photo.</p>
<ul>
<li>Write names without word delimiters.</li>
<li>Only write initials for the first name and write the last name in full. There are two exceptions: (1) when the last name or final file name is very long you may use initials for the last name; (2) when there is already a person with the same combination, you may write the first name in full.</li>
<li>If people have exactly the same name written in full, you can add a number: firstnamelastname2.</li>
</ul>
<p><strong>Right:</strong></p>
<div class="language- vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #adbac7">bvandebiezen.jpg</span></span>
<span class="line"><span style="color: #adbac7">shoogenhout.jpg</span></span>
<span class="line"><span style="color: #adbac7">a-very-long-description-with-name-bvdb.jpg</span></span>
<span class="line"><span style="color: #adbac7">asmith.jpg</span></span>
<span class="line"><span style="color: #adbac7">adamsmith.jpg</span></span>
<span class="line"><span style="color: #adbac7">adamsmith2.jpg</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292e">bvandebiezen.jpg</span></span>
<span class="line"><span style="color: #24292e">shoogenhout.jpg</span></span>
<span class="line"><span style="color: #24292e">a-very-long-description-with-name-bvdb.jpg</span></span>
<span class="line"><span style="color: #24292e">asmith.jpg</span></span>
<span class="line"><span style="color: #24292e">adamsmith.jpg</span></span>
<span class="line"><span style="color: #24292e">adamsmith2.jpg</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br></div></div><h3 id="use-two-or-more-digits-to-distinguish-sequential-files-with-the-same-description" tabindex="-1">Use two or more digits to distinguish sequential files with the same description <a class="header-anchor" href="#use-two-or-more-digits-to-distinguish-sequential-files-with-the-same-description" aria-label="Permalink to &quot;Use two or more digits to distinguish sequential files with the same description&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>Start number with a dash as a delimiter.</li>
<li>Add a zero to single digit numbers, e.g. '01' instead of '1'.</li>
<li>Numbers may also be placed before the description if needed. A dash will still be used as delimiter with the description.</li>
</ul>
<p><strong>Right:</strong></p>
<div class="language- vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #adbac7">description-01.jpg</span></span>
<span class="line"><span style="color: #adbac7">description-02.jpg</span></span>
<span class="line"><span style="color: #adbac7">description-03.jpg</span></span>
<span class="line"><span style="color: #adbac7">description-04.jpg</span></span>
<span class="line"><span style="color: #adbac7"></span></span>
<span class="line"><span style="color: #adbac7">01-description.jpg</span></span>
<span class="line"><span style="color: #adbac7">02-description.jpg</span></span>
<span class="line"><span style="color: #adbac7">03-description.jpg</span></span>
<span class="line"><span style="color: #adbac7">04-description.jpg</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292e">description-01.jpg</span></span>
<span class="line"><span style="color: #24292e">description-02.jpg</span></span>
<span class="line"><span style="color: #24292e">description-03.jpg</span></span>
<span class="line"><span style="color: #24292e">description-04.jpg</span></span>
<span class="line"><span style="color: #24292e"></span></span>
<span class="line"><span style="color: #24292e">01-description.jpg</span></span>
<span class="line"><span style="color: #24292e">02-description.jpg</span></span>
<span class="line"><span style="color: #24292e">03-description.jpg</span></span>
<span class="line"><span style="color: #24292e">04-description.jpg</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br></div></div><h3 id="keep-dates-or-date-ranges-compact-and-start-with-year" tabindex="-1">Keep dates or date ranges compact and start with year <a class="header-anchor" href="#keep-dates-or-date-ranges-compact-and-start-with-year" aria-label="Permalink to &quot;Keep dates or date ranges compact and start with year&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>Write dates without delimiters.</li>
<li>Always use four digits for years, two digits for months and two digits for days.</li>
<li>Start with year, then month, and end with day if available: yyyymmdd, yyyymm, or yyyy. This makes sure similar file names are sorted by date when sorted alphabetically.</li>
<li>Use a double dash to separate two dates describing an interval: yyyy--yyyy. Start with the earliest date.</li>
</ul>
<p><strong>Right:</strong></p>
<div class="language- vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #adbac7">description-20150401.php</span></span>
<span class="line"><span style="color: #adbac7">description-201504.php</span></span>
<span class="line"><span style="color: #adbac7">description-2015.php</span></span>
<span class="line"><span style="color: #adbac7">description-2000--2010.php</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292e">description-20150401.php</span></span>
<span class="line"><span style="color: #24292e">description-201504.php</span></span>
<span class="line"><span style="color: #24292e">description-2015.php</span></span>
<span class="line"><span style="color: #24292e">description-2000--2010.php</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br></div></div><p>See <a href="https://en.wikipedia.org/wiki/ISO_8601" target="_blank" rel="noreferrer">'ISO 8601'</a> for further reading.</p>
<h3 id="use-special-modifiers-for-target-devices-image-sizes-or-media-queries-and-pixel-densities" tabindex="-1">Use special modifiers for target devices, image sizes or media queries, and pixel densities. <a class="header-anchor" href="#use-special-modifiers-for-target-devices-image-sizes-or-media-queries-and-pixel-densities" aria-label="Permalink to &quot;Use special modifiers for target devices, image sizes or media queries, and pixel densities.&quot;">&ZeroWidthSpace;</a></h3>
<p>Modifiers are inspired by <a href="https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/LoadingResources/ImageSoundResources/ImageSoundResources.html#//apple_ref/doc/uid/10000051i-CH7-SW1" target="_blank" rel="noreferrer">Apple iOS naming conventions</a>. There are some differences. Apple uses '<code>@</code>'as a delimiter for the section indicating higher resolution images, for example '<code>@2x</code>' for retina images. Because '<code>@</code>' is a reserved character and can create problems, we use <a href="http://bourbon.io/docs/#retina-image" target="_blank" rel="noreferrer">Bourbon's convention</a>: an underscore. Also, Apple uses a tilde (<code>~</code>) as a delimiter for a section indicating specific devices. Because also a tilde can create problems, we suggest to simply use a dash.</p>
<ul>
<li>Order should be: (<code>1</code>) target device or media query, (<code>2</code>) size, (<code>3</code>) pixel density.</li>
<li>Start target device or media queries with a dash (<code>-</code>) as delimiter.</li>
<li>Start image sizes with a dash (<code>-</code>) as delimiter.</li>
<li>Start pixel density with an underscore (<code>_</code>) as delimiter, for example '<code>_2x</code>' or '<code>_3x</code>'.</li>
<li>When only a width or height is available or applicable, add a '<code>w</code>' for width or '<code>h</code>' for height directly after the the amount of pixels.</li>
<li>When both measurements are available, do not add a '<code>w</code>' or 'h' and separate the width and height with an '<code>x</code>'.</li>
<li>When both the width and height should not exceed a dimension but the images should keep the original aspect ratio, add a '<code>max</code>' (maximum) after the amount of pixels.</li>
</ul>
<p><strong>Right:</strong></p>
<div class="language- vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #adbac7">description_2x.jpg</span></span>
<span class="line"><span style="color: #adbac7">description-lap.jpg</span></span>
<span class="line"><span style="color: #adbac7">description-desk.jpg</span></span>
<span class="line"><span style="color: #adbac7">description-lap_2x.jpg</span></span>
<span class="line"><span style="color: #adbac7">description-palm-1024w_2x.jpg</span></span>
<span class="line"><span style="color: #adbac7">description-iphone5-568h_2x.jpg</span></span>
<span class="line"><span style="color: #adbac7">description-palm-1024x768_2x.jpg</span></span>
<span class="line"><span style="color: #adbac7">description-40max.jpg</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292e">description_2x.jpg</span></span>
<span class="line"><span style="color: #24292e">description-lap.jpg</span></span>
<span class="line"><span style="color: #24292e">description-desk.jpg</span></span>
<span class="line"><span style="color: #24292e">description-lap_2x.jpg</span></span>
<span class="line"><span style="color: #24292e">description-palm-1024w_2x.jpg</span></span>
<span class="line"><span style="color: #24292e">description-iphone5-568h_2x.jpg</span></span>
<span class="line"><span style="color: #24292e">description-palm-1024x768_2x.jpg</span></span>
<span class="line"><span style="color: #24292e">description-40max.jpg</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br></div></div><h3 id="use-version-numbers-if-available" tabindex="-1">Use version numbers if available <a class="header-anchor" href="#use-version-numbers-if-available" aria-label="Permalink to &quot;Use version numbers if available&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>Start version with a dash (<code>-</code>) as delimiter.</li>
<li>Use periods (<code>.</code>) to separate point releases.</li>
<li>Always add trailing zeros to major releases, e.g. '<code>2.0</code>' instead of '<code>2</code>'.</li>
<li>Types, such as '<code>a</code>' (alpha), '<code>b</code>' (beta), 'rc1' (release candidate 1) can be added without delimiters.</li>
</ul>
<p><strong>Right:</strong></p>
<div class="language- vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #adbac7">description-0.5.js</span></span>
<span class="line"><span style="color: #adbac7">description-1.0b.js</span></span>
<span class="line"><span style="color: #adbac7">description-1.0rc1.js</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292e">description-0.5.js</span></span>
<span class="line"><span style="color: #24292e">description-1.0b.js</span></span>
<span class="line"><span style="color: #24292e">description-1.0rc1.js</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><h3 id="add-status-when-needed" tabindex="-1">Add status when needed <a class="header-anchor" href="#add-status-when-needed" aria-label="Permalink to &quot;Add status when needed&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>You can optionally add a file status such as '<code>draft</code>' and '<code>published</code>'.</li>
<li>Start status with a dash.</li>
</ul>
<p><strong>Right:</strong></p>
<div class="language- vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #adbac7">description-draft.md</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292e">description-draft.md</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><h3 id="add-language-code-only-when-different-languages-are-available" tabindex="-1">Add language code only when different languages are available <a class="header-anchor" href="#add-language-code-only-when-different-languages-are-available" aria-label="Permalink to &quot;Add language code only when different languages are available&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>Use a period to separate the language code from the rest of the file name.</li>
<li>Use <a href="https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes" target="_blank" rel="noreferrer">ISO 639-1</a>, two-letter codes, for languages.</li>
<li>Only add languages when different languages are available.</li>
</ul>
<p><strong>Right:</strong></p>
<div class="language- vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #adbac7">description.nl.txt</span></span>
<span class="line"><span style="color: #adbac7">description.en.txt</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292e">description.nl.txt</span></span>
<span class="line"><span style="color: #24292e">description.en.txt</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><h3 id="add-file-conditions-just-before-the-file-extension" tabindex="-1">Add file conditions just before the file extension <a class="header-anchor" href="#add-file-conditions-just-before-the-file-extension" aria-label="Permalink to &quot;Add file conditions just before the file extension&quot;">&ZeroWidthSpace;</a></h3>
<ul>
<li>The file condition should be the last part, just before the file extension.</li>
<li>Use a period (<code>.</code>) to separate the condition from the rest of the file name.</li>
<li>Use periods (<code>.</code>) as a delimiter for different conditions.</li>
</ul>
<p><strong>Right:</strong></p>
<div class="language- vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #adbac7">description.min.js</span></span>
<span class="line"><span style="color: #adbac7">description.custom1234.min.js</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292e">description.min.js</span></span>
<span class="line"><span style="color: #24292e">description.custom1234.min.js</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><h2 id="rewrite-original-file-names-not-following-conventions" tabindex="-1">Rewrite original file names not following conventions <a class="header-anchor" href="#rewrite-original-file-names-not-following-conventions" aria-label="Permalink to &quot;Rewrite original file names not following conventions&quot;">&ZeroWidthSpace;</a></h2>
<p>It is not preferred to keep file names in it's original format if it doesn't match your file name conventions. But in some cases it is easier to keep the file name untouched. Sometimes you want to easily replace a file with a newer one from the original source in the future.</p>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Proxies Configuration for Shells & Terminal]]></title>
            <link>https://note.toshiki.devdevelopment/proxy4shell-terminal</link>
            <guid>https://note.toshiki.devdevelopment/proxy4shell-terminal</guid>
            <pubDate>Thu, 02 Nov 2023 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="proxies-configuration-for-shells-terminal" tabindex="-1">Proxies Configuration for Shells &amp; Terminal <a class="header-anchor" href="#proxies-configuration-for-shells-terminal" aria-label="Permalink to &quot;Proxies Configuration for Shells &amp; Terminal&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="tl-dr" tabindex="-1">TL;DR <a class="header-anchor" href="#tl-dr" aria-label="Permalink to &quot;TL;DR&quot;">&ZeroWidthSpace;</a></h2>
<p>This article discusses the configuration of proxies for shells and terminals. It explains the advantages of using proxy servers to bypass network restrictions and surveillance. The article provides examples of the challenges faced when accessing foreign services and shows how to set up a proxy tunnel using the curl command. It also provides scripts and instructions for setting up proxy switches in different shell environments, such as zsh, bash, and Windows CMD and PowerShell. The article concludes with additional information on proxy configurations for applications like ssh and tips for working with authentication procedures.</p>
<h2 id="_1-background" tabindex="-1">1. Background <a class="header-anchor" href="#_1-background" aria-label="Permalink to &quot;1. Background&quot;">&ZeroWidthSpace;</a></h2>
<p>Proxies or namely proxy servers are by far one of the most affordable or cost-effective option to establish a masked layer connection to bypass the network restrictions with the annoying surveillance tracked by a local network ISP as compared to a click-to-use VPN service, which generically requires more individual invest to protect themselves under the insecure internet environment nowadays. When a user resides within the environment where the local gateways of full, user-dominant open access towards the internet is censored or restricted with domestic network blockages by the country.</p>
<p align="center">
<img src="./assets/2023-11-04-03-15-12.png" width="100" height="100" align="center">
</p>
 while I adopt absolute subjective yet objective perspectives on the individual viewpoints towards the MIIT department of each country those of which applies the internet regulatory services within the national range for avoiding pitfalls on misleading information brought by cross-border influences; meanwhile regardlessly such measures are still facing controversial debates amongst publics that vastly limits the independent freedom rights, though advantages must not be underestimated, still.
<h2 id="_2-the-major-issue" tabindex="-1">2. The Major Issue <a class="header-anchor" href="#_2-the-major-issue" aria-label="Permalink to &quot;2. The Major Issue&quot;">&ZeroWidthSpace;</a></h2>
<p>The majority of the issue still heavily preserves across the developmental fields which the layer of the blockage imposes limits on communicating with third-party, remote platforms such as <a href="https://github.com" target="_blank" rel="noreferrer">Github</a> or registries like <a href="https://npmjs.com" target="_blank" rel="noreferrer">NPM</a> for frontend developments that stores key packages or components, as a requirement during a pre-built phase of a project. Most of the time foreign services becomes completely inaccessible or fortunately users could reach the services during a possible ISP maintenance downtime but normally the potentiality is mere, or hardly none yet the load speed before TTL connection expires are objectively slow, shortly before the origin site DNS being spoofed again. The unpleasant experiences with the networking somewhat affects interest on development reduces by high percentages or it even strand some awesome projects ran ashore ultimately.</p>
<p>The following screenshots are a more direct representation to visualize the differences between the connection towards one of the most beloved search engine, <a href="https://google.com" target="_blank" rel="noreferrer">Google</a> with the following command via <code>curl</code>.</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">curl</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-I</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">google.com</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">curl</span><span style="color: #24292E"> </span><span style="color: #005CC5">-I</span><span style="color: #24292E"> </span><span style="color: #032F62">google.com</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><blockquote>
<p>The command is used to fetch the headers of a URL or web page. When you run &quot;curl -I&quot; followed by a URL, the command sends an HTTP HEAD request to the specified URL and retrieves the HTTP headers of the response. This allows you to view the information contained in the response headers without requesting and downloading the entire content of the page. The headers typically include details like the server information, content type, content length, status codes, and more.</p>
</blockquote>
<p>The following screenshot from terminal indicates the the final output of the package availability received without losses on a bare unmasked network environment, which returns <code>FAIL</code> in the final connection after a dry run fails 11s after when the TTL expires the connection fails.</p>
<p><img src="./assets/2023-11-02-04-44-14.png" alt=""></p>
<p>The next screenshot from terminal indicates a temporary proxy tunnel is established both in <code>http</code> and <code>https</code> protocol tunneled through a local proxy gateway at the local systemic IP address at <code>127.0.0.1</code> and exposes the proxy server at a mix of socks/https/http protocol port at <code>7890</code>, just simply with the traditional <code>export</code> method by setting up in the nonce, the command is given as followed.</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">export</span><span style="color: #ADBAC7"> http_proxy</span><span style="color: #F47067">=</span><span style="color: #96D0FF">http://127.0.0.1:7890</span></span>
<span class="line"><span style="color: #F47067">export</span><span style="color: #ADBAC7"> https_proxy</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">$http_proxy</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">export</span><span style="color: #24292E"> http_proxy</span><span style="color: #D73A49">=</span><span style="color: #032F62">http://127.0.0.1:7890</span></span>
<span class="line"><span style="color: #D73A49">export</span><span style="color: #24292E"> https_proxy</span><span style="color: #D73A49">=</span><span style="color: #24292E">$http_proxy</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>And then we re-enter the same command with <code>curl</code> from above; surprisingly, the header responses returned <code>TTP/1.1 200 OK</code>, thus the conclusion drawn here is the proxy server we launched was successfully up and running with tunneled access towards foreign sites without restrictions! Hooray!</p>
<p><figure><img src="./assets/2023-11-04-00-42-58.png" alt="" title="Curl in action with successful response header from Google" /><figcaption align="center"><small>◎ Curl in action with successful response header from Google</small></figcaption></figure></p>
<p>Since each proxy configuration might varies atop of the user preferred client, not including ShadowRocket, Clash, V2ray or other proprietary softwares that are licensed either behind a paywall to run with; or simply expensive to purchase a subscription; the proxy ports forwarded varies alongside the changes amongst clients. But the overall approach taken into the account still remains the same with the following traditional formats, the local IP of the machine (normally <code>127.0.0.1</code>) followed after with the specified ports. In the scenario of the article is referenced as example, I chose Clash (in spite the entire Clash project repository as well as its affiliated forked projects are being taken down by anonymous reasons by either archiving the overall projects or simply shutting down due to possible legal actions or political reasons regarding the country of residency of various developers).</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390"># http protocal</span></span>
<span class="line"><span style="color: #F69D50">http://127.0.0.1:7890</span></span>
<span class="line"><span style="color: #768390"># https protocal</span></span>
<span class="line"><span style="color: #F69D50">https://127.0.0.1:7890</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D"># http protocal</span></span>
<span class="line"><span style="color: #6F42C1">http://127.0.0.1:7890</span></span>
<span class="line"><span style="color: #6A737D"># https protocal</span></span>
<span class="line"><span style="color: #6F42C1">https://127.0.0.1:7890</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br></div></div><h3 id="_2-1-kill-the-complexities-unleash-the-simplicity" tabindex="-1">2.1: Kill the Complexities; Unleash the Simplicity! <a class="header-anchor" href="#_2-1-kill-the-complexities-unleash-the-simplicity" aria-label="Permalink to &quot;2.1: Kill the Complexities; Unleash the Simplicity!&quot;">&ZeroWidthSpace;</a></h3>
<p>But, the logic routes to the central question on: <strong>How can we simplify the course of action on setting up proxies without manually run <code>export</code> command every single time we wish to use?</strong> Below is a simple approach by aliasing a shortcut code to a proxy switch script amended towards your shell configuration profile that initializes on every session startups, in this case I uses zsh since it's integrated as the default shell on macOS since the release of macOS Catalina, yet it's one of my most familiar and favored shell when was using other OS as well.</p>
<p>Though some people might use autosuggestion extensions as third-party shell features to automatically predict the command completion after a code piece is inputted such as <code>zsh-autosuggestion</code> plugin or fan of fish shell users has the native privilege of auto completions but I personally not fond of such featured integration since it might decelerate the load speed of an active session; I prefer stick tightly with original shell.</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390"># open your shell profile with an preferred editor</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">vim</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">~/.zshrc</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># session proxy switch shortcut</span></span>
<span class="line"><span style="color: #F47067">function</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">proxy_on</span><span style="color: #ADBAC7">() {</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">export</span><span style="color: #ADBAC7"> http_proxy</span><span style="color: #F47067">=</span><span style="color: #96D0FF">http://127.0.0.1:7890</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">export</span><span style="color: #ADBAC7"> https_proxy</span><span style="color: #F47067">=\$</span><span style="color: #96D0FF">http_proxy</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">echo</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-e</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;global proxy for the current terminal session has turned on&quot;</span></span>
<span class="line"><span style="color: #ADBAC7">}</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F47067">function</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">proxy_off</span><span style="color: #ADBAC7">(){</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">unset</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">http_proxy</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">https_proxy</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">echo</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-e</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;global proxy for the current terminal session has turned off&quot;</span></span>
<span class="line"><span style="color: #ADBAC7">}</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># restart your terminal with a new session or reload the config</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">source</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">~/.zshrc</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D"># open your shell profile with an preferred editor</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">vim</span><span style="color: #24292E"> </span><span style="color: #032F62">~/.zshrc</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># session proxy switch shortcut</span></span>
<span class="line"><span style="color: #D73A49">function</span><span style="color: #24292E"> </span><span style="color: #6F42C1">proxy_on</span><span style="color: #24292E">() {</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">export</span><span style="color: #24292E"> http_proxy</span><span style="color: #D73A49">=</span><span style="color: #032F62">http://127.0.0.1:7890</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">export</span><span style="color: #24292E"> https_proxy</span><span style="color: #D73A49">=</span><span style="color: #005CC5">\$</span><span style="color: #032F62">http_proxy</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">echo</span><span style="color: #24292E"> </span><span style="color: #005CC5">-e</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;global proxy for the current terminal session has turned on&quot;</span></span>
<span class="line"><span style="color: #24292E">}</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D73A49">function</span><span style="color: #24292E"> </span><span style="color: #6F42C1">proxy_off</span><span style="color: #24292E">(){</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">unset</span><span style="color: #24292E"> </span><span style="color: #032F62">http_proxy</span><span style="color: #24292E"> </span><span style="color: #032F62">https_proxy</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">echo</span><span style="color: #24292E"> </span><span style="color: #005CC5">-e</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;global proxy for the current terminal session has turned off&quot;</span></span>
<span class="line"><span style="color: #24292E">}</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># restart your terminal with a new session or reload the config</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">source</span><span style="color: #24292E"> </span><span style="color: #032F62">~/.zshrc</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br></div></div><p>The proxy essentially provides two shortcut command function defined with <code>proxy_on</code> and <code>proxy_off</code>. he <code>proxy_on</code> function sets the environment variables <code>http_proxy</code> and <code>https_proxy</code> to <code>http://127.0.0.1:7890</code>, which is the default proxy port of the traditional clash protocol, <strong>here is where you could replace the IP with other remote proxy servers or ports of other local proxies</strong> .Enabling a global proxy for the current terminal session. Meanwhile the <code>proxy_off</code> function unsets (removes) the <code>http_proxy</code> and <code>https_proxy</code> environment variables, effectively turning off the global proxy for the current terminal session. When any of the both executed, the indicator message will be echoed on the terminal, see the following screenshot in action.</p>
<p><figure><img src="./assets/2023-11-04-01-32-28.png" alt="" title="Enabling the shell session proxy with script" /><figcaption align="center"><small>◎ Enabling the shell session proxy with script</small></figcaption></figure></p>
<p>After you reload your shell profile you can test out the scripted command yourself. To test whether the proxy has a successful setup after the proxy has been switched on, run <code>echo $http_proxy</code> or <code>https_proxy</code> with a dollar sign in front of the alias as an indicator for environmental variable, the third command as shown in the screenshot above, the command will simply print the configured variable value addressed to the specified alias. Contrarily, if your terminal returns the following resultant,</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">proxy_on</span></span>
<span class="line"><span style="color: #F69D50">zsh:</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">command</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">not</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">found:</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">proxy_on</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">proxy_on</span></span>
<span class="line"><span style="color: #6F42C1">zsh:</span><span style="color: #24292E"> </span><span style="color: #032F62">command</span><span style="color: #24292E"> </span><span style="color: #032F62">not</span><span style="color: #24292E"> </span><span style="color: #032F62">found:</span><span style="color: #24292E"> </span><span style="color: #032F62">proxy_on</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>Then you will have to distinguish the exact shell you are currently on, the hereinafter content are mainly targeted towards novice learners whom are unable to track the shell types or configuration on particular operating systems. The configuration file for each shell varies their file names as well the location of storage; <strong>while Mac users could directly apply changes based on the instruction provided above if your system if Catalina or above</strong>. To know what exactly the active shell running, run,</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">echo</span><span style="color: #ADBAC7"> $SHELL</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">echo</span><span style="color: #24292E"> $SHELL</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>The returned string text will be the name of the current active shell, the following is a list of the possible shell profile config name affiliated with each shell; most of the config profile files should be lied under the <code>~</code> or the root/home folder of each operating system with a <code>dot</code> in front of the file names are inferred as hidden file or directory in most of the Unix-like systems, such as macOS, Ubuntu, Debian and etc, but some of the config file such as fish shell could locate in an isolated config directory. The usual format of a config file is as followed,</p>
<div class="language-shell vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">shell</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">~</span><span style="color: #ADBAC7">/.zshrc</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">~</span><span style="color: #24292E">/.zshrc</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>The following is a list of the most common shells with their possible profile file names that corresponded,</p>
<ul>
<li><code>/bin/bash</code> : <code>.bash_profile</code> or <code>.bashrc</code></li>
<li><code>/bin/zsh</code> : <code>.zprofile</code> or <code>.zshrc</code></li>
<li><code>/bin/fish</code>: <code> ~/.config/fish/config</code></li>
</ul>
<p>Still, the location might still varies, users might have to perform individual research to precisely locate their configuration file location, which is out of my jurisdiction of concerns (it's just evident action of procrastination and laziness, my apologies if none of the ones above fits your demand) <code>;)</code>.</p>
<p align="center">
<img src="./assets/2023-11-04-03-49-38.png" width="100" height="100" align="center">
</p>
<p>For Unix-like users, after you have specified your shell as well as your config file name and locations, copy the following code chunk as command and paste it back into your terminal and run to apply permanent changes to the configuration.</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">cat</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">&gt;&gt;</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">~/.zshrc</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">&lt;&lt;</span><span style="color: #ADBAC7"> </span><span style="color: #ADBAC7">EOF</span></span>
<span class="line"><span style="color: #96D0FF"># session proxy switch shortcut</span></span>
<span class="line"><span style="color: #96D0FF">function proxy_on() {</span></span>
<span class="line"><span style="color: #96D0FF">    export http_proxy=http://127.0.0.1:7890</span></span>
<span class="line"><span style="color: #96D0FF">    export https_proxy=</span><span style="color: #ADBAC7">$http_proxy</span></span>
<span class="line"><span style="color: #96D0FF">    echo -e &quot;global proxy for the current terminal session has turned on&quot;</span></span>
<span class="line"><span style="color: #96D0FF">}</span></span>
<span class="line"></span>
<span class="line"><span style="color: #96D0FF">function proxy_off(){</span></span>
<span class="line"><span style="color: #96D0FF">    unset http_proxy https_proxy</span></span>
<span class="line"><span style="color: #96D0FF">    echo -e &quot;global proxy for the current terminal session has turned off&quot;</span></span>
<span class="line"><span style="color: #96D0FF">}</span></span>
<span class="line"><span style="color: #ADBAC7">EOF</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">cat</span><span style="color: #24292E"> </span><span style="color: #D73A49">&gt;&gt;</span><span style="color: #24292E"> </span><span style="color: #032F62">~/.zshrc</span><span style="color: #24292E"> </span><span style="color: #D73A49">&lt;&lt;</span><span style="color: #24292E"> </span><span style="color: #032F62">EOF</span></span>
<span class="line"><span style="color: #032F62"># session proxy switch shortcut</span></span>
<span class="line"><span style="color: #032F62">function proxy_on() {</span></span>
<span class="line"><span style="color: #032F62">    export http_proxy=http://127.0.0.1:7890</span></span>
<span class="line"><span style="color: #032F62">    export https_proxy=</span><span style="color: #24292E">$http_proxy</span></span>
<span class="line"><span style="color: #032F62">    echo -e &quot;global proxy for the current terminal session has turned on&quot;</span></span>
<span class="line"><span style="color: #032F62">}</span></span>
<span class="line"></span>
<span class="line"><span style="color: #032F62">function proxy_off(){</span></span>
<span class="line"><span style="color: #032F62">    unset http_proxy https_proxy</span></span>
<span class="line"><span style="color: #032F62">    echo -e &quot;global proxy for the current terminal session has turned off&quot;</span></span>
<span class="line"><span style="color: #032F62">}</span></span>
<span class="line"><span style="color: #032F62">EOF</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br></div></div><p>The script above will write-in and install the proxy switch script and save the the content to the very end of the file. <strong>As a kindly reminder, if your shell is not <code>zsh</code> make sure to replace the string after <code>cat &gt;&gt;</code> to the actual path of your profile as well as your proxy server IP and port to the actual functioning details to your own demand</strong>; then ultimately, don't for get to reinitialize the shell by close and reopen the terminal or simply sourcing the config,</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #6CB6FF">source</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">~/.zshrc</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #005CC5">source</span><span style="color: #24292E"> </span><span style="color: #032F62">~/.zshrc</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>To check whether the proxy script has taken its effect to the current session, don't forget to rerun the same echo command indicated as above. And up until here, the script has been properly installed and operatable as a charm, if your's still does not take any effect, go through the process again and <strong>read</strong> carefully through the documentation.</p>
<h2 id="_3-to-all-windows-users" tabindex="-1">3: To All Windows Users <a class="header-anchor" href="#_3-to-all-windows-users" aria-label="Permalink to &quot;3: To All Windows Users&quot;">&ZeroWidthSpace;</a></h2>
<p>The documentation above are mainly targeted towards macOS &amp; Linux users, to setup local proxy with Windows machines there is a complete different approach if you are more comfortably working with Powershells and CMD, since I disused windows less and less frequently by the time I decided to upgrade my device to macOS; even if I did use Windows my primary choice of developmental environment is still Linux by the native support of <a href="https://learn.microsoft.com/en-us/windows/wsl/install" target="_blank" rel="noreferrer">WSL</a> with enhanced Ubuntu version in a virtual environment; the following commands are only done from my prior researches, I do not fully guarantee the usability of the commands, please use them at your own risks if any unexpected errors not only including system crashes or other affiliated damages, I do not relate responsibility to any of those presented.</p>
<p><img src="./assets/2023-11-04-04-27-59.png" alt=""></p>
<p>Simple concluding, abandon proprietary software, fall in the hug of open source; Linux even if most of the users might feel overwhelming when getting started with the system first <code>:)</code>. Alright, enough with off-topic talkings, let's jump right in the process.</p>
<h3 id="_3-1-cmd" tabindex="-1">3.1: CMD <a class="header-anchor" href="#_3-1-cmd" aria-label="Permalink to &quot;3.1: CMD&quot;">&ZeroWidthSpace;</a></h3>
<div class="language-cmd vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">cmd</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">set </span><span style="color: #ADBAC7">http_proxy</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">http://</span><span style="color: #6CB6FF">127.0.0.1</span><span style="color: #ADBAC7">:</span><span style="color: #6CB6FF">7890</span></span>
<span class="line"><span style="color: #F47067">set </span><span style="color: #ADBAC7">https_proxy</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">http://</span><span style="color: #6CB6FF">127.0.0.1</span><span style="color: #ADBAC7">:</span><span style="color: #6CB6FF">7890</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">set </span><span style="color: #24292E">http_proxy</span><span style="color: #D73A49">=</span><span style="color: #24292E">http://</span><span style="color: #005CC5">127.0.0.1</span><span style="color: #24292E">:</span><span style="color: #005CC5">7890</span></span>
<span class="line"><span style="color: #D73A49">set </span><span style="color: #24292E">https_proxy</span><span style="color: #D73A49">=</span><span style="color: #24292E">http://</span><span style="color: #005CC5">127.0.0.1</span><span style="color: #24292E">:</span><span style="color: #005CC5">7890</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>The commands are basically the same to Unix but the major difference is the amend commands in Windows are <code>set</code> instead of <code>export</code>. Once again I haven't personally tested the command, thus only use them as a reference. And whenever you wish to unset the global proxy for the session just simply run the <code>set</code> proxy command again but without any proxy server details.</p>
<div class="language-cmd vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">cmd</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">set </span><span style="color: #ADBAC7">http_proxy</span><span style="color: #F47067">=</span></span>
<span class="line"><span style="color: #F47067">set </span><span style="color: #ADBAC7">https_proxy</span><span style="color: #F47067">=</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">set </span><span style="color: #24292E">http_proxy</span><span style="color: #D73A49">=</span></span>
<span class="line"><span style="color: #D73A49">set </span><span style="color: #24292E">https_proxy</span><span style="color: #D73A49">=</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><h3 id="_3-2-powershell" tabindex="-1">3.2: PowerShell <a class="header-anchor" href="#_3-2-powershell" aria-label="Permalink to &quot;3.2: PowerShell&quot;">&ZeroWidthSpace;</a></h3>
<p>Alike CMD, the string after are exactly the same but the setup prefix command differentiates,</p>
<div class="language-powershell vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">powershell</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">$</span><span style="color: #6CB6FF">env:</span><span style="color: #ADBAC7">http_proxy</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;http://127.0.0.1:1080&quot;</span></span>
<span class="line"><span style="color: #ADBAC7">$</span><span style="color: #6CB6FF">env:</span><span style="color: #ADBAC7">https_proxy</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;http://127.0.0.1:1080&quot;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">$</span><span style="color: #005CC5">env:</span><span style="color: #24292E">http_proxy</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;http://127.0.0.1:1080&quot;</span></span>
<span class="line"><span style="color: #24292E">$</span><span style="color: #005CC5">env:</span><span style="color: #24292E">https_proxy</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;http://127.0.0.1:1080&quot;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>And to revert to the default proxy setting, execute the following command to unset both the http and https proxy.</p>
<div class="language-powershell vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">powershell</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">$</span><span style="color: #6CB6FF">env:</span><span style="color: #ADBAC7">http_proxy</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;&quot;</span></span>
<span class="line"><span style="color: #ADBAC7">$</span><span style="color: #6CB6FF">env:</span><span style="color: #ADBAC7">https_proxy</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;&quot;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">$</span><span style="color: #005CC5">env:</span><span style="color: #24292E">http_proxy</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;&quot;</span></span>
<span class="line"><span style="color: #24292E">$</span><span style="color: #005CC5">env:</span><span style="color: #24292E">https_proxy</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;&quot;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><h2 id="_4-extended-trivia-on-proxy" tabindex="-1">4: Extended Trivia on Proxy <a class="header-anchor" href="#_4-extended-trivia-on-proxy" aria-label="Permalink to &quot;4: Extended Trivia on Proxy&quot;">&ZeroWidthSpace;</a></h2>
<p>Sometimes a proxy server may require an authentication procedure involving passcode for accessing before establishing a secure connection to interact with the server itself. From the partial article above we only discussed on a simple local proxy server setup including a host IP with its forwarded port gateways; but when facing the scenario described for a net connection, we will need a bit more complex method when working in the CLI environment.</p>
<p>Before we start, quoting from one of the answer from <a href="https://askubuntu.com/questions/583797/how-to-set-a-proxy-for-terminal" target="_blank" rel="noreferrer">AskUbuntu</a>, resolving the misconception on the difference between terminal application and the net utilities falls underly,</p>
<blockquote>
<p>Terminal is not net application. Maybe is better to say, in your case, terminal is container for net application like <code>ssh</code>, <code>telnet</code>, <code>lftp</code>, <code>wget</code>, <code>lynx</code> ...</p>
</blockquote>
<p>A terminal provides a command-line interface that allows users to send commands and receive responses from network applications, facilitating communication and control over a network connection. It acts as a mediator between the user and the network applications, enabling the user to send instructions and receive information, but not a proxy client.</p>
<p align="center">
<img src="./assets/2023-11-04-05-01-04.png" width="200" height="145" align="center">
</p>
<p>Done with the technical talkings, now let's dive into the actual configuration process of the shell. Other than simply inputting a host IP and a port followed, the following formats are the default configuration for a proxy server with HTTP connection protocol, follow the exact same process as described based on your shell type, modify the fields with the following,</p>
<div class="language-shell vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">shell</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">export</span><span style="color: #ADBAC7"> http_proxy</span><span style="color: #F47067">=</span><span style="color: #96D0FF">http://username:password@proxyhost:port/</span></span>
<span class="line"><span style="color: #F47067">export</span><span style="color: #ADBAC7"> ftp_proxy</span><span style="color: #F47067">=</span><span style="color: #96D0FF">http://username:password@proxyhost:port/</span></span>
<span class="line"><span style="color: #F47067">export</span><span style="color: #ADBAC7"> telnet_proxy</span><span style="color: #F47067">=</span><span style="color: #96D0FF">http://username:password@proxyhost:port/</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">export</span><span style="color: #24292E"> http_proxy</span><span style="color: #D73A49">=</span><span style="color: #032F62">http://username:password@proxyhost:port/</span></span>
<span class="line"><span style="color: #D73A49">export</span><span style="color: #24292E"> ftp_proxy</span><span style="color: #D73A49">=</span><span style="color: #032F62">http://username:password@proxyhost:port/</span></span>
<span class="line"><span style="color: #D73A49">export</span><span style="color: #24292E"> telnet_proxy</span><span style="color: #D73A49">=</span><span style="color: #032F62">http://username:password@proxyhost:port/</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><p>Another approach suggested by the same user whom provided the answer on AskUbuntu for all Ubuntu users, edit the proxy configuration at the root of your machine as follows,</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">sudo</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-H</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">vim</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">/etc/profile.d/proxy.sh</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">sudo</span><span style="color: #24292E"> </span><span style="color: #005CC5">-H</span><span style="color: #24292E"> </span><span style="color: #032F62">vim</span><span style="color: #24292E"> </span><span style="color: #032F62">/etc/profile.d/proxy.sh</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>And add the exported proxy members aligning the format as above, then save and reinitialize the environment, viola. The patches edited are mainly targeted for incorporating with <code>wget</code>, <code>ftp</code>, <code>lftp</code>, <code>telnet</code> in terminal.</p>
<p>When working with <code>ssh</code> instance over a proxy, a different approach has to be taken since SSH library does not natively support <code>SOCKS5</code> client, user will have to pass a <code>ProxyCommand</code> option as a workaround to apply proxied connection, below is an instance of <code>socat</code>,</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">ssh</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-o</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ProxyCommand=&#39;socat - SOCKS4A:myproxy:%h:%p,socksuser=nobody&#39;</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">user@host</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">ssh</span><span style="color: #24292E"> </span><span style="color: #005CC5">-o</span><span style="color: #24292E"> </span><span style="color: #032F62">ProxyCommand=&#39;socat - SOCKS4A:myproxy:%h:%p,socksuser=nobody&#39;</span><span style="color: #24292E"> </span><span style="color: #032F62">user@host</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>The <code>proxyCommand</code> option allows user to integrate <code>socat</code> as an intermediary mediator to establish connection above a proxy. Other alternatives like <code>tsocks</code> are as well viable to transparently use <code>SOCKS</code> for <code>TCP</code> traffic, Exemplifying running <code>SOCKS5</code> over <code>socat2</code>,</p>
<div class="language-bash vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">ssh</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-o</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ProxyCommand=&#39;socat - &quot;SOCKS5:%h:%p|tcp:myproxy:1080&quot;&#39;</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">user@host</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">ssh</span><span style="color: #24292E"> </span><span style="color: #005CC5">-o</span><span style="color: #24292E"> </span><span style="color: #032F62">ProxyCommand=&#39;socat - &quot;SOCKS5:%h:%p|tcp:myproxy:1080&quot;&#39;</span><span style="color: #24292E"> </span><span style="color: #032F62">user@host</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>Further, <code>socat2</code> for HTTP Proxy CONNECT method,</p>
<div class="language-bash vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">ssh</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-o</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ProxyCommand=&#39;socat - &quot;PROXY:%h:%p|tcp:myproxy:80&quot;&#39;</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">user@host</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">ssh</span><span style="color: #24292E"> </span><span style="color: #005CC5">-o</span><span style="color: #24292E"> </span><span style="color: #032F62">ProxyCommand=&#39;socat - &quot;PROXY:%h:%p|tcp:myproxy:80&quot;&#39;</span><span style="color: #24292E"> </span><span style="color: #032F62">user@host</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="tip custom-block"><p class="custom-block-title">Reference</p>
<ul>
<li><a href="https://askubuntu.com/questions/583797/how-to-set-a-proxy-for-terminal" target="_blank" rel="noreferrer">https://askubuntu.com/questions/583797/how-to-set-a-proxy-for-terminal</a></li>
<li><a href="https://zhuanlan.zhihu.com/p/357875811" target="_blank" rel="noreferrer">https://zhuanlan.zhihu.com/p/357875811</a></li>
<li><a href="https://askubuntu.com/questions/158557/setting-proxy-for-apt-from-terminal" target="_blank" rel="noreferrer">https://askubuntu.com/questions/158557/setting-proxy-for-apt-from-terminal</a>
:::</li>
</ul>
</div>
]]></description>
            <content:encoded><![CDATA[<h1 id="proxies-configuration-for-shells-terminal" tabindex="-1">Proxies Configuration for Shells &amp; Terminal <a class="header-anchor" href="#proxies-configuration-for-shells-terminal" aria-label="Permalink to &quot;Proxies Configuration for Shells &amp; Terminal&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="tl-dr" tabindex="-1">TL;DR <a class="header-anchor" href="#tl-dr" aria-label="Permalink to &quot;TL;DR&quot;">&ZeroWidthSpace;</a></h2>
<p>This article discusses the configuration of proxies for shells and terminals. It explains the advantages of using proxy servers to bypass network restrictions and surveillance. The article provides examples of the challenges faced when accessing foreign services and shows how to set up a proxy tunnel using the curl command. It also provides scripts and instructions for setting up proxy switches in different shell environments, such as zsh, bash, and Windows CMD and PowerShell. The article concludes with additional information on proxy configurations for applications like ssh and tips for working with authentication procedures.</p>
<h2 id="_1-background" tabindex="-1">1. Background <a class="header-anchor" href="#_1-background" aria-label="Permalink to &quot;1. Background&quot;">&ZeroWidthSpace;</a></h2>
<p>Proxies or namely proxy servers are by far one of the most affordable or cost-effective option to establish a masked layer connection to bypass the network restrictions with the annoying surveillance tracked by a local network ISP as compared to a click-to-use VPN service, which generically requires more individual invest to protect themselves under the insecure internet environment nowadays. When a user resides within the environment where the local gateways of full, user-dominant open access towards the internet is censored or restricted with domestic network blockages by the country.</p>
<p align="center">
<img src="./assets/2023-11-04-03-15-12.png" width="100" height="100" align="center">
</p>
 while I adopt absolute subjective yet objective perspectives on the individual viewpoints towards the MIIT department of each country those of which applies the internet regulatory services within the national range for avoiding pitfalls on misleading information brought by cross-border influences; meanwhile regardlessly such measures are still facing controversial debates amongst publics that vastly limits the independent freedom rights, though advantages must not be underestimated, still.
<h2 id="_2-the-major-issue" tabindex="-1">2. The Major Issue <a class="header-anchor" href="#_2-the-major-issue" aria-label="Permalink to &quot;2. The Major Issue&quot;">&ZeroWidthSpace;</a></h2>
<p>The majority of the issue still heavily preserves across the developmental fields which the layer of the blockage imposes limits on communicating with third-party, remote platforms such as <a href="https://github.com" target="_blank" rel="noreferrer">Github</a> or registries like <a href="https://npmjs.com" target="_blank" rel="noreferrer">NPM</a> for frontend developments that stores key packages or components, as a requirement during a pre-built phase of a project. Most of the time foreign services becomes completely inaccessible or fortunately users could reach the services during a possible ISP maintenance downtime but normally the potentiality is mere, or hardly none yet the load speed before TTL connection expires are objectively slow, shortly before the origin site DNS being spoofed again. The unpleasant experiences with the networking somewhat affects interest on development reduces by high percentages or it even strand some awesome projects ran ashore ultimately.</p>
<p>The following screenshots are a more direct representation to visualize the differences between the connection towards one of the most beloved search engine, <a href="https://google.com" target="_blank" rel="noreferrer">Google</a> with the following command via <code>curl</code>.</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">curl</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-I</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">google.com</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">curl</span><span style="color: #24292E"> </span><span style="color: #005CC5">-I</span><span style="color: #24292E"> </span><span style="color: #032F62">google.com</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><blockquote>
<p>The command is used to fetch the headers of a URL or web page. When you run &quot;curl -I&quot; followed by a URL, the command sends an HTTP HEAD request to the specified URL and retrieves the HTTP headers of the response. This allows you to view the information contained in the response headers without requesting and downloading the entire content of the page. The headers typically include details like the server information, content type, content length, status codes, and more.</p>
</blockquote>
<p>The following screenshot from terminal indicates the the final output of the package availability received without losses on a bare unmasked network environment, which returns <code>FAIL</code> in the final connection after a dry run fails 11s after when the TTL expires the connection fails.</p>
<p><img src="./assets/2023-11-02-04-44-14.png" alt=""></p>
<p>The next screenshot from terminal indicates a temporary proxy tunnel is established both in <code>http</code> and <code>https</code> protocol tunneled through a local proxy gateway at the local systemic IP address at <code>127.0.0.1</code> and exposes the proxy server at a mix of socks/https/http protocol port at <code>7890</code>, just simply with the traditional <code>export</code> method by setting up in the nonce, the command is given as followed.</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">export</span><span style="color: #ADBAC7"> http_proxy</span><span style="color: #F47067">=</span><span style="color: #96D0FF">http://127.0.0.1:7890</span></span>
<span class="line"><span style="color: #F47067">export</span><span style="color: #ADBAC7"> https_proxy</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">$http_proxy</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">export</span><span style="color: #24292E"> http_proxy</span><span style="color: #D73A49">=</span><span style="color: #032F62">http://127.0.0.1:7890</span></span>
<span class="line"><span style="color: #D73A49">export</span><span style="color: #24292E"> https_proxy</span><span style="color: #D73A49">=</span><span style="color: #24292E">$http_proxy</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>And then we re-enter the same command with <code>curl</code> from above; surprisingly, the header responses returned <code>TTP/1.1 200 OK</code>, thus the conclusion drawn here is the proxy server we launched was successfully up and running with tunneled access towards foreign sites without restrictions! Hooray!</p>
<p><figure><img src="./assets/2023-11-04-00-42-58.png" alt="" title="Curl in action with successful response header from Google" /><figcaption align="center"><small>◎ Curl in action with successful response header from Google</small></figcaption></figure></p>
<p>Since each proxy configuration might varies atop of the user preferred client, not including ShadowRocket, Clash, V2ray or other proprietary softwares that are licensed either behind a paywall to run with; or simply expensive to purchase a subscription; the proxy ports forwarded varies alongside the changes amongst clients. But the overall approach taken into the account still remains the same with the following traditional formats, the local IP of the machine (normally <code>127.0.0.1</code>) followed after with the specified ports. In the scenario of the article is referenced as example, I chose Clash (in spite the entire Clash project repository as well as its affiliated forked projects are being taken down by anonymous reasons by either archiving the overall projects or simply shutting down due to possible legal actions or political reasons regarding the country of residency of various developers).</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390"># http protocal</span></span>
<span class="line"><span style="color: #F69D50">http://127.0.0.1:7890</span></span>
<span class="line"><span style="color: #768390"># https protocal</span></span>
<span class="line"><span style="color: #F69D50">https://127.0.0.1:7890</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D"># http protocal</span></span>
<span class="line"><span style="color: #6F42C1">http://127.0.0.1:7890</span></span>
<span class="line"><span style="color: #6A737D"># https protocal</span></span>
<span class="line"><span style="color: #6F42C1">https://127.0.0.1:7890</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br></div></div><h3 id="_2-1-kill-the-complexities-unleash-the-simplicity" tabindex="-1">2.1: Kill the Complexities; Unleash the Simplicity! <a class="header-anchor" href="#_2-1-kill-the-complexities-unleash-the-simplicity" aria-label="Permalink to &quot;2.1: Kill the Complexities; Unleash the Simplicity!&quot;">&ZeroWidthSpace;</a></h3>
<p>But, the logic routes to the central question on: <strong>How can we simplify the course of action on setting up proxies without manually run <code>export</code> command every single time we wish to use?</strong> Below is a simple approach by aliasing a shortcut code to a proxy switch script amended towards your shell configuration profile that initializes on every session startups, in this case I uses zsh since it's integrated as the default shell on macOS since the release of macOS Catalina, yet it's one of my most familiar and favored shell when was using other OS as well.</p>
<p>Though some people might use autosuggestion extensions as third-party shell features to automatically predict the command completion after a code piece is inputted such as <code>zsh-autosuggestion</code> plugin or fan of fish shell users has the native privilege of auto completions but I personally not fond of such featured integration since it might decelerate the load speed of an active session; I prefer stick tightly with original shell.</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390"># open your shell profile with an preferred editor</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">vim</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">~/.zshrc</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># session proxy switch shortcut</span></span>
<span class="line"><span style="color: #F47067">function</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">proxy_on</span><span style="color: #ADBAC7">() {</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">export</span><span style="color: #ADBAC7"> http_proxy</span><span style="color: #F47067">=</span><span style="color: #96D0FF">http://127.0.0.1:7890</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #F47067">export</span><span style="color: #ADBAC7"> https_proxy</span><span style="color: #F47067">=\$</span><span style="color: #96D0FF">http_proxy</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">echo</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-e</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;global proxy for the current terminal session has turned on&quot;</span></span>
<span class="line"><span style="color: #ADBAC7">}</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F47067">function</span><span style="color: #ADBAC7"> </span><span style="color: #DCBDFB">proxy_off</span><span style="color: #ADBAC7">(){</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">unset</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">http_proxy</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">https_proxy</span></span>
<span class="line"><span style="color: #ADBAC7">    </span><span style="color: #6CB6FF">echo</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-e</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;global proxy for the current terminal session has turned off&quot;</span></span>
<span class="line"><span style="color: #ADBAC7">}</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># restart your terminal with a new session or reload the config</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">source</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">~/.zshrc</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D"># open your shell profile with an preferred editor</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">vim</span><span style="color: #24292E"> </span><span style="color: #032F62">~/.zshrc</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># session proxy switch shortcut</span></span>
<span class="line"><span style="color: #D73A49">function</span><span style="color: #24292E"> </span><span style="color: #6F42C1">proxy_on</span><span style="color: #24292E">() {</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">export</span><span style="color: #24292E"> http_proxy</span><span style="color: #D73A49">=</span><span style="color: #032F62">http://127.0.0.1:7890</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #D73A49">export</span><span style="color: #24292E"> https_proxy</span><span style="color: #D73A49">=</span><span style="color: #005CC5">\$</span><span style="color: #032F62">http_proxy</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">echo</span><span style="color: #24292E"> </span><span style="color: #005CC5">-e</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;global proxy for the current terminal session has turned on&quot;</span></span>
<span class="line"><span style="color: #24292E">}</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D73A49">function</span><span style="color: #24292E"> </span><span style="color: #6F42C1">proxy_off</span><span style="color: #24292E">(){</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">unset</span><span style="color: #24292E"> </span><span style="color: #032F62">http_proxy</span><span style="color: #24292E"> </span><span style="color: #032F62">https_proxy</span></span>
<span class="line"><span style="color: #24292E">    </span><span style="color: #005CC5">echo</span><span style="color: #24292E"> </span><span style="color: #005CC5">-e</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;global proxy for the current terminal session has turned off&quot;</span></span>
<span class="line"><span style="color: #24292E">}</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># restart your terminal with a new session or reload the config</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">source</span><span style="color: #24292E"> </span><span style="color: #032F62">~/.zshrc</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br></div></div><p>The proxy essentially provides two shortcut command function defined with <code>proxy_on</code> and <code>proxy_off</code>. he <code>proxy_on</code> function sets the environment variables <code>http_proxy</code> and <code>https_proxy</code> to <code>http://127.0.0.1:7890</code>, which is the default proxy port of the traditional clash protocol, <strong>here is where you could replace the IP with other remote proxy servers or ports of other local proxies</strong> .Enabling a global proxy for the current terminal session. Meanwhile the <code>proxy_off</code> function unsets (removes) the <code>http_proxy</code> and <code>https_proxy</code> environment variables, effectively turning off the global proxy for the current terminal session. When any of the both executed, the indicator message will be echoed on the terminal, see the following screenshot in action.</p>
<p><figure><img src="./assets/2023-11-04-01-32-28.png" alt="" title="Enabling the shell session proxy with script" /><figcaption align="center"><small>◎ Enabling the shell session proxy with script</small></figcaption></figure></p>
<p>After you reload your shell profile you can test out the scripted command yourself. To test whether the proxy has a successful setup after the proxy has been switched on, run <code>echo $http_proxy</code> or <code>https_proxy</code> with a dollar sign in front of the alias as an indicator for environmental variable, the third command as shown in the screenshot above, the command will simply print the configured variable value addressed to the specified alias. Contrarily, if your terminal returns the following resultant,</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">proxy_on</span></span>
<span class="line"><span style="color: #F69D50">zsh:</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">command</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">not</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">found:</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">proxy_on</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">proxy_on</span></span>
<span class="line"><span style="color: #6F42C1">zsh:</span><span style="color: #24292E"> </span><span style="color: #032F62">command</span><span style="color: #24292E"> </span><span style="color: #032F62">not</span><span style="color: #24292E"> </span><span style="color: #032F62">found:</span><span style="color: #24292E"> </span><span style="color: #032F62">proxy_on</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>Then you will have to distinguish the exact shell you are currently on, the hereinafter content are mainly targeted towards novice learners whom are unable to track the shell types or configuration on particular operating systems. The configuration file for each shell varies their file names as well the location of storage; <strong>while Mac users could directly apply changes based on the instruction provided above if your system if Catalina or above</strong>. To know what exactly the active shell running, run,</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">echo</span><span style="color: #ADBAC7"> $SHELL</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">echo</span><span style="color: #24292E"> $SHELL</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>The returned string text will be the name of the current active shell, the following is a list of the possible shell profile config name affiliated with each shell; most of the config profile files should be lied under the <code>~</code> or the root/home folder of each operating system with a <code>dot</code> in front of the file names are inferred as hidden file or directory in most of the Unix-like systems, such as macOS, Ubuntu, Debian and etc, but some of the config file such as fish shell could locate in an isolated config directory. The usual format of a config file is as followed,</p>
<div class="language-shell vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">shell</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">~</span><span style="color: #ADBAC7">/.zshrc</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">~</span><span style="color: #24292E">/.zshrc</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>The following is a list of the most common shells with their possible profile file names that corresponded,</p>
<ul>
<li><code>/bin/bash</code> : <code>.bash_profile</code> or <code>.bashrc</code></li>
<li><code>/bin/zsh</code> : <code>.zprofile</code> or <code>.zshrc</code></li>
<li><code>/bin/fish</code>: <code> ~/.config/fish/config</code></li>
</ul>
<p>Still, the location might still varies, users might have to perform individual research to precisely locate their configuration file location, which is out of my jurisdiction of concerns (it's just evident action of procrastination and laziness, my apologies if none of the ones above fits your demand) <code>;)</code>.</p>
<p align="center">
<img src="./assets/2023-11-04-03-49-38.png" width="100" height="100" align="center">
</p>
<p>For Unix-like users, after you have specified your shell as well as your config file name and locations, copy the following code chunk as command and paste it back into your terminal and run to apply permanent changes to the configuration.</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">cat</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">&gt;&gt;</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">~/.zshrc</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">&lt;&lt;</span><span style="color: #ADBAC7"> </span><span style="color: #ADBAC7">EOF</span></span>
<span class="line"><span style="color: #96D0FF"># session proxy switch shortcut</span></span>
<span class="line"><span style="color: #96D0FF">function proxy_on() {</span></span>
<span class="line"><span style="color: #96D0FF">    export http_proxy=http://127.0.0.1:7890</span></span>
<span class="line"><span style="color: #96D0FF">    export https_proxy=</span><span style="color: #ADBAC7">$http_proxy</span></span>
<span class="line"><span style="color: #96D0FF">    echo -e &quot;global proxy for the current terminal session has turned on&quot;</span></span>
<span class="line"><span style="color: #96D0FF">}</span></span>
<span class="line"></span>
<span class="line"><span style="color: #96D0FF">function proxy_off(){</span></span>
<span class="line"><span style="color: #96D0FF">    unset http_proxy https_proxy</span></span>
<span class="line"><span style="color: #96D0FF">    echo -e &quot;global proxy for the current terminal session has turned off&quot;</span></span>
<span class="line"><span style="color: #96D0FF">}</span></span>
<span class="line"><span style="color: #ADBAC7">EOF</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">cat</span><span style="color: #24292E"> </span><span style="color: #D73A49">&gt;&gt;</span><span style="color: #24292E"> </span><span style="color: #032F62">~/.zshrc</span><span style="color: #24292E"> </span><span style="color: #D73A49">&lt;&lt;</span><span style="color: #24292E"> </span><span style="color: #032F62">EOF</span></span>
<span class="line"><span style="color: #032F62"># session proxy switch shortcut</span></span>
<span class="line"><span style="color: #032F62">function proxy_on() {</span></span>
<span class="line"><span style="color: #032F62">    export http_proxy=http://127.0.0.1:7890</span></span>
<span class="line"><span style="color: #032F62">    export https_proxy=</span><span style="color: #24292E">$http_proxy</span></span>
<span class="line"><span style="color: #032F62">    echo -e &quot;global proxy for the current terminal session has turned on&quot;</span></span>
<span class="line"><span style="color: #032F62">}</span></span>
<span class="line"></span>
<span class="line"><span style="color: #032F62">function proxy_off(){</span></span>
<span class="line"><span style="color: #032F62">    unset http_proxy https_proxy</span></span>
<span class="line"><span style="color: #032F62">    echo -e &quot;global proxy for the current terminal session has turned off&quot;</span></span>
<span class="line"><span style="color: #032F62">}</span></span>
<span class="line"><span style="color: #032F62">EOF</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br></div></div><p>The script above will write-in and install the proxy switch script and save the the content to the very end of the file. <strong>As a kindly reminder, if your shell is not <code>zsh</code> make sure to replace the string after <code>cat &gt;&gt;</code> to the actual path of your profile as well as your proxy server IP and port to the actual functioning details to your own demand</strong>; then ultimately, don't for get to reinitialize the shell by close and reopen the terminal or simply sourcing the config,</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #6CB6FF">source</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">~/.zshrc</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #005CC5">source</span><span style="color: #24292E"> </span><span style="color: #032F62">~/.zshrc</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>To check whether the proxy script has taken its effect to the current session, don't forget to rerun the same echo command indicated as above. And up until here, the script has been properly installed and operatable as a charm, if your's still does not take any effect, go through the process again and <strong>read</strong> carefully through the documentation.</p>
<h2 id="_3-to-all-windows-users" tabindex="-1">3: To All Windows Users <a class="header-anchor" href="#_3-to-all-windows-users" aria-label="Permalink to &quot;3: To All Windows Users&quot;">&ZeroWidthSpace;</a></h2>
<p>The documentation above are mainly targeted towards macOS &amp; Linux users, to setup local proxy with Windows machines there is a complete different approach if you are more comfortably working with Powershells and CMD, since I disused windows less and less frequently by the time I decided to upgrade my device to macOS; even if I did use Windows my primary choice of developmental environment is still Linux by the native support of <a href="https://learn.microsoft.com/en-us/windows/wsl/install" target="_blank" rel="noreferrer">WSL</a> with enhanced Ubuntu version in a virtual environment; the following commands are only done from my prior researches, I do not fully guarantee the usability of the commands, please use them at your own risks if any unexpected errors not only including system crashes or other affiliated damages, I do not relate responsibility to any of those presented.</p>
<p><img src="./assets/2023-11-04-04-27-59.png" alt=""></p>
<p>Simple concluding, abandon proprietary software, fall in the hug of open source; Linux even if most of the users might feel overwhelming when getting started with the system first <code>:)</code>. Alright, enough with off-topic talkings, let's jump right in the process.</p>
<h3 id="_3-1-cmd" tabindex="-1">3.1: CMD <a class="header-anchor" href="#_3-1-cmd" aria-label="Permalink to &quot;3.1: CMD&quot;">&ZeroWidthSpace;</a></h3>
<div class="language-cmd vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">cmd</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">set </span><span style="color: #ADBAC7">http_proxy</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">http://</span><span style="color: #6CB6FF">127.0.0.1</span><span style="color: #ADBAC7">:</span><span style="color: #6CB6FF">7890</span></span>
<span class="line"><span style="color: #F47067">set </span><span style="color: #ADBAC7">https_proxy</span><span style="color: #F47067">=</span><span style="color: #ADBAC7">http://</span><span style="color: #6CB6FF">127.0.0.1</span><span style="color: #ADBAC7">:</span><span style="color: #6CB6FF">7890</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">set </span><span style="color: #24292E">http_proxy</span><span style="color: #D73A49">=</span><span style="color: #24292E">http://</span><span style="color: #005CC5">127.0.0.1</span><span style="color: #24292E">:</span><span style="color: #005CC5">7890</span></span>
<span class="line"><span style="color: #D73A49">set </span><span style="color: #24292E">https_proxy</span><span style="color: #D73A49">=</span><span style="color: #24292E">http://</span><span style="color: #005CC5">127.0.0.1</span><span style="color: #24292E">:</span><span style="color: #005CC5">7890</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>The commands are basically the same to Unix but the major difference is the amend commands in Windows are <code>set</code> instead of <code>export</code>. Once again I haven't personally tested the command, thus only use them as a reference. And whenever you wish to unset the global proxy for the session just simply run the <code>set</code> proxy command again but without any proxy server details.</p>
<div class="language-cmd vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">cmd</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">set </span><span style="color: #ADBAC7">http_proxy</span><span style="color: #F47067">=</span></span>
<span class="line"><span style="color: #F47067">set </span><span style="color: #ADBAC7">https_proxy</span><span style="color: #F47067">=</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">set </span><span style="color: #24292E">http_proxy</span><span style="color: #D73A49">=</span></span>
<span class="line"><span style="color: #D73A49">set </span><span style="color: #24292E">https_proxy</span><span style="color: #D73A49">=</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><h3 id="_3-2-powershell" tabindex="-1">3.2: PowerShell <a class="header-anchor" href="#_3-2-powershell" aria-label="Permalink to &quot;3.2: PowerShell&quot;">&ZeroWidthSpace;</a></h3>
<p>Alike CMD, the string after are exactly the same but the setup prefix command differentiates,</p>
<div class="language-powershell vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">powershell</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">$</span><span style="color: #6CB6FF">env:</span><span style="color: #ADBAC7">http_proxy</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;http://127.0.0.1:1080&quot;</span></span>
<span class="line"><span style="color: #ADBAC7">$</span><span style="color: #6CB6FF">env:</span><span style="color: #ADBAC7">https_proxy</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;http://127.0.0.1:1080&quot;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">$</span><span style="color: #005CC5">env:</span><span style="color: #24292E">http_proxy</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;http://127.0.0.1:1080&quot;</span></span>
<span class="line"><span style="color: #24292E">$</span><span style="color: #005CC5">env:</span><span style="color: #24292E">https_proxy</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;http://127.0.0.1:1080&quot;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>And to revert to the default proxy setting, execute the following command to unset both the http and https proxy.</p>
<div class="language-powershell vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">powershell</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">$</span><span style="color: #6CB6FF">env:</span><span style="color: #ADBAC7">http_proxy</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;&quot;</span></span>
<span class="line"><span style="color: #ADBAC7">$</span><span style="color: #6CB6FF">env:</span><span style="color: #ADBAC7">https_proxy</span><span style="color: #F47067">=</span><span style="color: #96D0FF">&quot;&quot;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">$</span><span style="color: #005CC5">env:</span><span style="color: #24292E">http_proxy</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;&quot;</span></span>
<span class="line"><span style="color: #24292E">$</span><span style="color: #005CC5">env:</span><span style="color: #24292E">https_proxy</span><span style="color: #D73A49">=</span><span style="color: #032F62">&quot;&quot;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><h2 id="_4-extended-trivia-on-proxy" tabindex="-1">4: Extended Trivia on Proxy <a class="header-anchor" href="#_4-extended-trivia-on-proxy" aria-label="Permalink to &quot;4: Extended Trivia on Proxy&quot;">&ZeroWidthSpace;</a></h2>
<p>Sometimes a proxy server may require an authentication procedure involving passcode for accessing before establishing a secure connection to interact with the server itself. From the partial article above we only discussed on a simple local proxy server setup including a host IP with its forwarded port gateways; but when facing the scenario described for a net connection, we will need a bit more complex method when working in the CLI environment.</p>
<p>Before we start, quoting from one of the answer from <a href="https://askubuntu.com/questions/583797/how-to-set-a-proxy-for-terminal" target="_blank" rel="noreferrer">AskUbuntu</a>, resolving the misconception on the difference between terminal application and the net utilities falls underly,</p>
<blockquote>
<p>Terminal is not net application. Maybe is better to say, in your case, terminal is container for net application like <code>ssh</code>, <code>telnet</code>, <code>lftp</code>, <code>wget</code>, <code>lynx</code> ...</p>
</blockquote>
<p>A terminal provides a command-line interface that allows users to send commands and receive responses from network applications, facilitating communication and control over a network connection. It acts as a mediator between the user and the network applications, enabling the user to send instructions and receive information, but not a proxy client.</p>
<p align="center">
<img src="./assets/2023-11-04-05-01-04.png" width="200" height="145" align="center">
</p>
<p>Done with the technical talkings, now let's dive into the actual configuration process of the shell. Other than simply inputting a host IP and a port followed, the following formats are the default configuration for a proxy server with HTTP connection protocol, follow the exact same process as described based on your shell type, modify the fields with the following,</p>
<div class="language-shell vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">shell</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F47067">export</span><span style="color: #ADBAC7"> http_proxy</span><span style="color: #F47067">=</span><span style="color: #96D0FF">http://username:password@proxyhost:port/</span></span>
<span class="line"><span style="color: #F47067">export</span><span style="color: #ADBAC7"> ftp_proxy</span><span style="color: #F47067">=</span><span style="color: #96D0FF">http://username:password@proxyhost:port/</span></span>
<span class="line"><span style="color: #F47067">export</span><span style="color: #ADBAC7"> telnet_proxy</span><span style="color: #F47067">=</span><span style="color: #96D0FF">http://username:password@proxyhost:port/</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #D73A49">export</span><span style="color: #24292E"> http_proxy</span><span style="color: #D73A49">=</span><span style="color: #032F62">http://username:password@proxyhost:port/</span></span>
<span class="line"><span style="color: #D73A49">export</span><span style="color: #24292E"> ftp_proxy</span><span style="color: #D73A49">=</span><span style="color: #032F62">http://username:password@proxyhost:port/</span></span>
<span class="line"><span style="color: #D73A49">export</span><span style="color: #24292E"> telnet_proxy</span><span style="color: #D73A49">=</span><span style="color: #032F62">http://username:password@proxyhost:port/</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><p>Another approach suggested by the same user whom provided the answer on AskUbuntu for all Ubuntu users, edit the proxy configuration at the root of your machine as follows,</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">sudo</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-H</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">vim</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">/etc/profile.d/proxy.sh</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">sudo</span><span style="color: #24292E"> </span><span style="color: #005CC5">-H</span><span style="color: #24292E"> </span><span style="color: #032F62">vim</span><span style="color: #24292E"> </span><span style="color: #032F62">/etc/profile.d/proxy.sh</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>And add the exported proxy members aligning the format as above, then save and reinitialize the environment, viola. The patches edited are mainly targeted for incorporating with <code>wget</code>, <code>ftp</code>, <code>lftp</code>, <code>telnet</code> in terminal.</p>
<p>When working with <code>ssh</code> instance over a proxy, a different approach has to be taken since SSH library does not natively support <code>SOCKS5</code> client, user will have to pass a <code>ProxyCommand</code> option as a workaround to apply proxied connection, below is an instance of <code>socat</code>,</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">ssh</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-o</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ProxyCommand=&#39;socat - SOCKS4A:myproxy:%h:%p,socksuser=nobody&#39;</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">user@host</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">ssh</span><span style="color: #24292E"> </span><span style="color: #005CC5">-o</span><span style="color: #24292E"> </span><span style="color: #032F62">ProxyCommand=&#39;socat - SOCKS4A:myproxy:%h:%p,socksuser=nobody&#39;</span><span style="color: #24292E"> </span><span style="color: #032F62">user@host</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>The <code>proxyCommand</code> option allows user to integrate <code>socat</code> as an intermediary mediator to establish connection above a proxy. Other alternatives like <code>tsocks</code> are as well viable to transparently use <code>SOCKS</code> for <code>TCP</code> traffic, Exemplifying running <code>SOCKS5</code> over <code>socat2</code>,</p>
<div class="language-bash vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">ssh</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-o</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ProxyCommand=&#39;socat - &quot;SOCKS5:%h:%p|tcp:myproxy:1080&quot;&#39;</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">user@host</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">ssh</span><span style="color: #24292E"> </span><span style="color: #005CC5">-o</span><span style="color: #24292E"> </span><span style="color: #032F62">ProxyCommand=&#39;socat - &quot;SOCKS5:%h:%p|tcp:myproxy:1080&quot;&#39;</span><span style="color: #24292E"> </span><span style="color: #032F62">user@host</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>Further, <code>socat2</code> for HTTP Proxy CONNECT method,</p>
<div class="language-bash vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">ssh</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-o</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">ProxyCommand=&#39;socat - &quot;PROXY:%h:%p|tcp:myproxy:80&quot;&#39;</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">user@host</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">ssh</span><span style="color: #24292E"> </span><span style="color: #005CC5">-o</span><span style="color: #24292E"> </span><span style="color: #032F62">ProxyCommand=&#39;socat - &quot;PROXY:%h:%p|tcp:myproxy:80&quot;&#39;</span><span style="color: #24292E"> </span><span style="color: #032F62">user@host</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><div class="tip custom-block"><p class="custom-block-title">Reference</p>
<ul>
<li><a href="https://askubuntu.com/questions/583797/how-to-set-a-proxy-for-terminal" target="_blank" rel="noreferrer">https://askubuntu.com/questions/583797/how-to-set-a-proxy-for-terminal</a></li>
<li><a href="https://zhuanlan.zhihu.com/p/357875811" target="_blank" rel="noreferrer">https://zhuanlan.zhihu.com/p/357875811</a></li>
<li><a href="https://askubuntu.com/questions/158557/setting-proxy-for-apt-from-terminal" target="_blank" rel="noreferrer">https://askubuntu.com/questions/158557/setting-proxy-for-apt-from-terminal</a>
:::</li>
</ul>
</div>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Configure rclone for R2 ]]></title>
            <link>https://note.toshiki.devdevelopment/rclone-for-r2</link>
            <guid>https://note.toshiki.devdevelopment/rclone-for-r2</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="configure-rclone-for-r2" tabindex="-1">Configure rclone for R2 <a class="header-anchor" href="#configure-rclone-for-r2" aria-label="Permalink to &quot;Configure rclone for R2&quot;">&ZeroWidthSpace;</a></h1>
<p>Example of how to configure <code>rclone</code> to use R2.</p>
<p>You must <a href="https://developers.cloudflare.com/r2/data-access/s3-api/tokens/" target="_blank" rel="noreferrer">generate an Access Key</a> before getting started. All examples will utilize <code>access_key_id</code> and <code>access_key_secret</code> variables which represent the <strong>Access Key ID</strong> and <strong>Secret Access Key</strong> values you generated.</p>
<p>With <a href="https://rclone.org/install/" target="_blank" rel="noreferrer"><code>rclone</code></a> installed, you may run <a href="https://rclone.org/s3/" target="_blank" rel="noreferrer"><code>rclone config</code></a> to configure a new S3 storage provider. You will be prompted with a series of questions for the new prvider details.</p>
<p>If you have already configured <code>rclone</code> in the past, you may run <code>rclone config file</code> to print the location of your <code>rclone</code> configuration file:</p>
<div class="language-bash vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">rclone</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">config</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">file</span></span>
<span class="line"><span style="color: #768390"># Configuration file is stored at:</span></span>
<span class="line"><span style="color: #768390"># ~/.config/rclone/rclone.conf</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">rclone</span><span style="color: #24292E"> </span><span style="color: #032F62">config</span><span style="color: #24292E"> </span><span style="color: #032F62">file</span></span>
<span class="line"><span style="color: #6A737D"># Configuration file is stored at:</span></span>
<span class="line"><span style="color: #6A737D"># ~/.config/rclone/rclone.conf</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><p>Then use an editor (<code>nano</code> or <code>vim</code>, for example) to add or edit the new provider. This example assumes you are adding a new <code>r2demo</code> provider:</p>
<div class="language-bash vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">[r2]</span></span>
<span class="line"><span style="color: #6CB6FF">type</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">s3</span></span>
<span class="line"><span style="color: #F69D50">provider</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">Cloudflare</span></span>
<span class="line"><span style="color: #F69D50">access_key_id</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">abc123</span><span style="color: #ADBAC7"> </span><span style="color: #768390"># Your access_key_id</span></span>
<span class="line"><span style="color: #F69D50">secret_access_key</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">xyz456</span><span style="color: #ADBAC7"> </span><span style="color: #768390"># Your access_key_secret</span></span>
<span class="line"><span style="color: #F69D50">endpoint</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">https://</span><span style="color: #F47067">&lt;</span><span style="color: #96D0FF">accounti</span><span style="color: #ADBAC7">d</span><span style="color: #F47067">&gt;</span><span style="color: #96D0FF">.r2.cloudflarestorage.com</span></span>
<span class="line"><span style="color: #F69D50">acl</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">private</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">[r2]</span></span>
<span class="line"><span style="color: #005CC5">type</span><span style="color: #24292E"> </span><span style="color: #032F62">=</span><span style="color: #24292E"> </span><span style="color: #032F62">s3</span></span>
<span class="line"><span style="color: #6F42C1">provider</span><span style="color: #24292E"> </span><span style="color: #032F62">=</span><span style="color: #24292E"> </span><span style="color: #032F62">Cloudflare</span></span>
<span class="line"><span style="color: #6F42C1">access_key_id</span><span style="color: #24292E"> </span><span style="color: #032F62">=</span><span style="color: #24292E"> </span><span style="color: #032F62">abc123</span><span style="color: #24292E"> </span><span style="color: #6A737D"># Your access_key_id</span></span>
<span class="line"><span style="color: #6F42C1">secret_access_key</span><span style="color: #24292E"> </span><span style="color: #032F62">=</span><span style="color: #24292E"> </span><span style="color: #032F62">xyz456</span><span style="color: #24292E"> </span><span style="color: #6A737D"># Your access_key_secret</span></span>
<span class="line"><span style="color: #6F42C1">endpoint</span><span style="color: #24292E"> </span><span style="color: #032F62">=</span><span style="color: #24292E"> </span><span style="color: #032F62">https://</span><span style="color: #D73A49">&lt;</span><span style="color: #032F62">accounti</span><span style="color: #24292E">d</span><span style="color: #D73A49">&gt;</span><span style="color: #032F62">.r2.cloudflarestorage.com</span></span>
<span class="line"><span style="color: #6F42C1">acl</span><span style="color: #24292E"> </span><span style="color: #032F62">=</span><span style="color: #24292E"> </span><span style="color: #032F62">private</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br></div></div><p>You may then use the new <code>rclone</code> provider for any of your normal workflows.</p>
<h2 id="list-buckets-objects" tabindex="-1">List buckets &amp; objects <a class="header-anchor" href="#list-buckets-objects" aria-label="Permalink to &quot;List buckets &amp; objects&quot;">&ZeroWidthSpace;</a></h2>
<p>The <a href="https://rclone.org/commands/rclone_tree/" target="_blank" rel="noreferrer">rclone tree</a> command can be used to list the contents of the remote, in this case Cloudflare R2.</p>
<div class="language-bash vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">rclone</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">tree</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">r2demo:</span></span>
<span class="line"><span style="color: #768390"># /</span></span>
<span class="line"><span style="color: #768390"># ├── user-uploads</span></span>
<span class="line"><span style="color: #768390"># │   └── foobar.png</span></span>
<span class="line"><span style="color: #768390"># └── my-bucket-name</span></span>
<span class="line"><span style="color: #768390">#     ├── cat.png</span></span>
<span class="line"><span style="color: #768390">#     └── todos.txt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">rclone</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">tree</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">r2demo:my-bucket-name</span></span>
<span class="line"><span style="color: #768390"># /</span></span>
<span class="line"><span style="color: #768390"># ├── cat.png</span></span>
<span class="line"><span style="color: #768390"># └── todos.txt</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">rclone</span><span style="color: #24292E"> </span><span style="color: #032F62">tree</span><span style="color: #24292E"> </span><span style="color: #032F62">r2demo:</span></span>
<span class="line"><span style="color: #6A737D"># /</span></span>
<span class="line"><span style="color: #6A737D"># ├── user-uploads</span></span>
<span class="line"><span style="color: #6A737D"># │   └── foobar.png</span></span>
<span class="line"><span style="color: #6A737D"># └── my-bucket-name</span></span>
<span class="line"><span style="color: #6A737D">#     ├── cat.png</span></span>
<span class="line"><span style="color: #6A737D">#     └── todos.txt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">rclone</span><span style="color: #24292E"> </span><span style="color: #032F62">tree</span><span style="color: #24292E"> </span><span style="color: #032F62">r2demo:my-bucket-name</span></span>
<span class="line"><span style="color: #6A737D"># /</span></span>
<span class="line"><span style="color: #6A737D"># ├── cat.png</span></span>
<span class="line"><span style="color: #6A737D"># └── todos.txt</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br></div></div><h2 id="upload-and-retrieve-objects" tabindex="-1">Upload and retrieve objects <a class="header-anchor" href="#upload-and-retrieve-objects" aria-label="Permalink to &quot;Upload and retrieve objects&quot;">&ZeroWidthSpace;</a></h2>
<p>The <a href="https://rclone.org/commands/rclone_copy/" target="_blank" rel="noreferrer">rclone copy</a> command can be used to upload objects to an R2 bucket and vice versa - this allows you to upload files up to the 5 TB maximum object size that R2 supports.</p>
<div class="language-bash vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390"># Upload dog.txt to the user-uploads bucket</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">rclone</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">copy</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">dog.txt</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">r2demo:user-uploads/dog.txt</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">rclone</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">tree</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">r2demo:user-uploads</span></span>
<span class="line"><span style="color: #768390"># /</span></span>
<span class="line"><span style="color: #768390"># ├── foobar.png</span></span>
<span class="line"><span style="color: #768390"># └── dog.txt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># Download dog.txt from the user-uploads bucket</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">rclone</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">copy</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">r2demo:user-uploads/dog.txt</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">dog.txt</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D"># Upload dog.txt to the user-uploads bucket</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">rclone</span><span style="color: #24292E"> </span><span style="color: #032F62">copy</span><span style="color: #24292E"> </span><span style="color: #032F62">dog.txt</span><span style="color: #24292E"> </span><span style="color: #032F62">r2demo:user-uploads/dog.txt</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">rclone</span><span style="color: #24292E"> </span><span style="color: #032F62">tree</span><span style="color: #24292E"> </span><span style="color: #032F62">r2demo:user-uploads</span></span>
<span class="line"><span style="color: #6A737D"># /</span></span>
<span class="line"><span style="color: #6A737D"># ├── foobar.png</span></span>
<span class="line"><span style="color: #6A737D"># └── dog.txt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># Download dog.txt from the user-uploads bucket</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">rclone</span><span style="color: #24292E"> </span><span style="color: #032F62">copy</span><span style="color: #24292E"> </span><span style="color: #032F62">r2demo:user-uploads/dog.txt</span><span style="color: #24292E"> </span><span style="color: #032F62">dog.txt</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br></div></div><h2 id="generate-presigned-urls" tabindex="-1">Generate presigned URLs <a class="header-anchor" href="#generate-presigned-urls" aria-label="Permalink to &quot;Generate presigned URLs&quot;">&ZeroWidthSpace;</a></h2>
<p>You can also generate presigned links which allow you to share public access to a file temporarily using the <a href="https://rclone.org/commands/rclone_link/" target="_blank" rel="noreferrer">rclone link</a> command.</p>
]]></description>
            <content:encoded><![CDATA[<h1 id="configure-rclone-for-r2" tabindex="-1">Configure rclone for R2 <a class="header-anchor" href="#configure-rclone-for-r2" aria-label="Permalink to &quot;Configure rclone for R2&quot;">&ZeroWidthSpace;</a></h1>
<p>Example of how to configure <code>rclone</code> to use R2.</p>
<p>You must <a href="https://developers.cloudflare.com/r2/data-access/s3-api/tokens/" target="_blank" rel="noreferrer">generate an Access Key</a> before getting started. All examples will utilize <code>access_key_id</code> and <code>access_key_secret</code> variables which represent the <strong>Access Key ID</strong> and <strong>Secret Access Key</strong> values you generated.</p>
<p>With <a href="https://rclone.org/install/" target="_blank" rel="noreferrer"><code>rclone</code></a> installed, you may run <a href="https://rclone.org/s3/" target="_blank" rel="noreferrer"><code>rclone config</code></a> to configure a new S3 storage provider. You will be prompted with a series of questions for the new prvider details.</p>
<p>If you have already configured <code>rclone</code> in the past, you may run <code>rclone config file</code> to print the location of your <code>rclone</code> configuration file:</p>
<div class="language-bash vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">rclone</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">config</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">file</span></span>
<span class="line"><span style="color: #768390"># Configuration file is stored at:</span></span>
<span class="line"><span style="color: #768390"># ~/.config/rclone/rclone.conf</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">rclone</span><span style="color: #24292E"> </span><span style="color: #032F62">config</span><span style="color: #24292E"> </span><span style="color: #032F62">file</span></span>
<span class="line"><span style="color: #6A737D"># Configuration file is stored at:</span></span>
<span class="line"><span style="color: #6A737D"># ~/.config/rclone/rclone.conf</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><p>Then use an editor (<code>nano</code> or <code>vim</code>, for example) to add or edit the new provider. This example assumes you are adding a new <code>r2demo</code> provider:</p>
<div class="language-bash vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">[r2]</span></span>
<span class="line"><span style="color: #6CB6FF">type</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">s3</span></span>
<span class="line"><span style="color: #F69D50">provider</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">Cloudflare</span></span>
<span class="line"><span style="color: #F69D50">access_key_id</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">abc123</span><span style="color: #ADBAC7"> </span><span style="color: #768390"># Your access_key_id</span></span>
<span class="line"><span style="color: #F69D50">secret_access_key</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">xyz456</span><span style="color: #ADBAC7"> </span><span style="color: #768390"># Your access_key_secret</span></span>
<span class="line"><span style="color: #F69D50">endpoint</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">https://</span><span style="color: #F47067">&lt;</span><span style="color: #96D0FF">accounti</span><span style="color: #ADBAC7">d</span><span style="color: #F47067">&gt;</span><span style="color: #96D0FF">.r2.cloudflarestorage.com</span></span>
<span class="line"><span style="color: #F69D50">acl</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">=</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">private</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">[r2]</span></span>
<span class="line"><span style="color: #005CC5">type</span><span style="color: #24292E"> </span><span style="color: #032F62">=</span><span style="color: #24292E"> </span><span style="color: #032F62">s3</span></span>
<span class="line"><span style="color: #6F42C1">provider</span><span style="color: #24292E"> </span><span style="color: #032F62">=</span><span style="color: #24292E"> </span><span style="color: #032F62">Cloudflare</span></span>
<span class="line"><span style="color: #6F42C1">access_key_id</span><span style="color: #24292E"> </span><span style="color: #032F62">=</span><span style="color: #24292E"> </span><span style="color: #032F62">abc123</span><span style="color: #24292E"> </span><span style="color: #6A737D"># Your access_key_id</span></span>
<span class="line"><span style="color: #6F42C1">secret_access_key</span><span style="color: #24292E"> </span><span style="color: #032F62">=</span><span style="color: #24292E"> </span><span style="color: #032F62">xyz456</span><span style="color: #24292E"> </span><span style="color: #6A737D"># Your access_key_secret</span></span>
<span class="line"><span style="color: #6F42C1">endpoint</span><span style="color: #24292E"> </span><span style="color: #032F62">=</span><span style="color: #24292E"> </span><span style="color: #032F62">https://</span><span style="color: #D73A49">&lt;</span><span style="color: #032F62">accounti</span><span style="color: #24292E">d</span><span style="color: #D73A49">&gt;</span><span style="color: #032F62">.r2.cloudflarestorage.com</span></span>
<span class="line"><span style="color: #6F42C1">acl</span><span style="color: #24292E"> </span><span style="color: #032F62">=</span><span style="color: #24292E"> </span><span style="color: #032F62">private</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br></div></div><p>You may then use the new <code>rclone</code> provider for any of your normal workflows.</p>
<h2 id="list-buckets-objects" tabindex="-1">List buckets &amp; objects <a class="header-anchor" href="#list-buckets-objects" aria-label="Permalink to &quot;List buckets &amp; objects&quot;">&ZeroWidthSpace;</a></h2>
<p>The <a href="https://rclone.org/commands/rclone_tree/" target="_blank" rel="noreferrer">rclone tree</a> command can be used to list the contents of the remote, in this case Cloudflare R2.</p>
<div class="language-bash vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">rclone</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">tree</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">r2demo:</span></span>
<span class="line"><span style="color: #768390"># /</span></span>
<span class="line"><span style="color: #768390"># ├── user-uploads</span></span>
<span class="line"><span style="color: #768390"># │   └── foobar.png</span></span>
<span class="line"><span style="color: #768390"># └── my-bucket-name</span></span>
<span class="line"><span style="color: #768390">#     ├── cat.png</span></span>
<span class="line"><span style="color: #768390">#     └── todos.txt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">rclone</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">tree</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">r2demo:my-bucket-name</span></span>
<span class="line"><span style="color: #768390"># /</span></span>
<span class="line"><span style="color: #768390"># ├── cat.png</span></span>
<span class="line"><span style="color: #768390"># └── todos.txt</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">rclone</span><span style="color: #24292E"> </span><span style="color: #032F62">tree</span><span style="color: #24292E"> </span><span style="color: #032F62">r2demo:</span></span>
<span class="line"><span style="color: #6A737D"># /</span></span>
<span class="line"><span style="color: #6A737D"># ├── user-uploads</span></span>
<span class="line"><span style="color: #6A737D"># │   └── foobar.png</span></span>
<span class="line"><span style="color: #6A737D"># └── my-bucket-name</span></span>
<span class="line"><span style="color: #6A737D">#     ├── cat.png</span></span>
<span class="line"><span style="color: #6A737D">#     └── todos.txt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">rclone</span><span style="color: #24292E"> </span><span style="color: #032F62">tree</span><span style="color: #24292E"> </span><span style="color: #032F62">r2demo:my-bucket-name</span></span>
<span class="line"><span style="color: #6A737D"># /</span></span>
<span class="line"><span style="color: #6A737D"># ├── cat.png</span></span>
<span class="line"><span style="color: #6A737D"># └── todos.txt</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br></div></div><h2 id="upload-and-retrieve-objects" tabindex="-1">Upload and retrieve objects <a class="header-anchor" href="#upload-and-retrieve-objects" aria-label="Permalink to &quot;Upload and retrieve objects&quot;">&ZeroWidthSpace;</a></h2>
<p>The <a href="https://rclone.org/commands/rclone_copy/" target="_blank" rel="noreferrer">rclone copy</a> command can be used to upload objects to an R2 bucket and vice versa - this allows you to upload files up to the 5 TB maximum object size that R2 supports.</p>
<div class="language-bash vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #768390"># Upload dog.txt to the user-uploads bucket</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">rclone</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">copy</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">dog.txt</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">r2demo:user-uploads/dog.txt</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">rclone</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">tree</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">r2demo:user-uploads</span></span>
<span class="line"><span style="color: #768390"># /</span></span>
<span class="line"><span style="color: #768390"># ├── foobar.png</span></span>
<span class="line"><span style="color: #768390"># └── dog.txt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #768390"># Download dog.txt from the user-uploads bucket</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">rclone</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">copy</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">r2demo:user-uploads/dog.txt</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">dog.txt</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6A737D"># Upload dog.txt to the user-uploads bucket</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">rclone</span><span style="color: #24292E"> </span><span style="color: #032F62">copy</span><span style="color: #24292E"> </span><span style="color: #032F62">dog.txt</span><span style="color: #24292E"> </span><span style="color: #032F62">r2demo:user-uploads/dog.txt</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">rclone</span><span style="color: #24292E"> </span><span style="color: #032F62">tree</span><span style="color: #24292E"> </span><span style="color: #032F62">r2demo:user-uploads</span></span>
<span class="line"><span style="color: #6A737D"># /</span></span>
<span class="line"><span style="color: #6A737D"># ├── foobar.png</span></span>
<span class="line"><span style="color: #6A737D"># └── dog.txt</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A737D"># Download dog.txt from the user-uploads bucket</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">rclone</span><span style="color: #24292E"> </span><span style="color: #032F62">copy</span><span style="color: #24292E"> </span><span style="color: #032F62">r2demo:user-uploads/dog.txt</span><span style="color: #24292E"> </span><span style="color: #032F62">dog.txt</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br></div></div><h2 id="generate-presigned-urls" tabindex="-1">Generate presigned URLs <a class="header-anchor" href="#generate-presigned-urls" aria-label="Permalink to &quot;Generate presigned URLs&quot;">&ZeroWidthSpace;</a></h2>
<p>You can also generate presigned links which allow you to share public access to a file temporarily using the <a href="https://rclone.org/commands/rclone_link/" target="_blank" rel="noreferrer">rclone link</a> command.</p>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Git push results in "Authentication Failed”]]></title>
            <link>https://note.toshiki.devgetting-started</link>
            <guid>https://note.toshiki.devgetting-started</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="git-push-results-in-authentication-failed" tabindex="-1">Git push results in &quot;Authentication Failed” <a class="header-anchor" href="#git-push-results-in-authentication-failed" aria-label="Permalink to &quot;Git push results in &quot;Authentication Failed”&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="issue" tabindex="-1">Issue <a class="header-anchor" href="#issue" aria-label="Permalink to &quot;Issue&quot;">&ZeroWidthSpace;</a></h2>
<div class="language-bash vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">git</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">push</span></span>
<span class="line"><span style="color: #F69D50">Username</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">for</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;https://github.com&#39;:</span><span style="color: #ADBAC7"> ${{ GITHUB_USERNAME }</span><span style="color: #96D0FF">}</span></span>
<span class="line"><span style="color: #F69D50">Password</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">for</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;https://andatoshiki@github.com&#39;:</span><span style="color: #ADBAC7"> ${{ GITHUB_PASSWORD }</span><span style="color: #96D0FF">}</span><span style="color: #ADBAC7"> </span><span style="color: #768390"># or GitHub personal access token</span></span>
<span class="line"><span style="color: #F69D50">remote:</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">Invalid</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">username</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">or</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">password.</span></span>
<span class="line"><span style="color: #F69D50">fatal:</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">Authentication</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">failed</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">for</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;https://github.com/andatoshiki/andatoshiki.git/&#39;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">git</span><span style="color: #24292E"> </span><span style="color: #032F62">push</span></span>
<span class="line"><span style="color: #6F42C1">Username</span><span style="color: #24292E"> </span><span style="color: #032F62">for</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;https://github.com&#39;:</span><span style="color: #24292E"> ${{ GITHUB_USERNAME }</span><span style="color: #032F62">}</span></span>
<span class="line"><span style="color: #6F42C1">Password</span><span style="color: #24292E"> </span><span style="color: #032F62">for</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;https://andatoshiki@github.com&#39;:</span><span style="color: #24292E"> ${{ GITHUB_PASSWORD }</span><span style="color: #032F62">}</span><span style="color: #24292E"> </span><span style="color: #6A737D"># or GitHub personal access token</span></span>
<span class="line"><span style="color: #6F42C1">remote:</span><span style="color: #24292E"> </span><span style="color: #032F62">Invalid</span><span style="color: #24292E"> </span><span style="color: #032F62">username</span><span style="color: #24292E"> </span><span style="color: #032F62">or</span><span style="color: #24292E"> </span><span style="color: #032F62">password.</span></span>
<span class="line"><span style="color: #6F42C1">fatal:</span><span style="color: #24292E"> </span><span style="color: #032F62">Authentication</span><span style="color: #24292E"> </span><span style="color: #032F62">failed</span><span style="color: #24292E"> </span><span style="color: #032F62">for</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;https://github.com/andatoshiki/andatoshiki.git/&#39;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br></div></div><p><code>git push</code> to GitHub remote branch failed via https protocol</p>
<h2 id="solution" tabindex="-1">Solution <a class="header-anchor" href="#solution" aria-label="Permalink to &quot;Solution&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="solution-1" tabindex="-1">Solution 1 <a class="header-anchor" href="#solution-1" aria-label="Permalink to &quot;Solution 1&quot;">&ZeroWidthSpace;</a></h3>
<blockquote>
<p>If you enabled two-factor authentication in your GitHub account you won't be able to push via HTTPS using your accounts password. Instead you need to generate a personal access token. This can be done in the application settings of your GitHub account. Using this token as your password should allow you to push to your remote repository via HTTPS. Use your username as usual.</p>
</blockquote>
<p>You may also need to update the origin for your repository if it is set to HTTPS. Do this to switch to SSH:</p>
<div class="language-bash vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">git</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">remote</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-v</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">git</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">remote</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">set-url</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">origin</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">git@github.com:</span><span style="color: #ADBAC7">$USERNAME</span><span style="color: #96D0FF">/</span><span style="color: #ADBAC7">$REPONAME</span><span style="color: #96D0FF">.git</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">git</span><span style="color: #24292E"> </span><span style="color: #032F62">remote</span><span style="color: #24292E"> </span><span style="color: #005CC5">-v</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">git</span><span style="color: #24292E"> </span><span style="color: #032F62">remote</span><span style="color: #24292E"> </span><span style="color: #032F62">set-url</span><span style="color: #24292E"> </span><span style="color: #032F62">origin</span><span style="color: #24292E"> </span><span style="color: #032F62">git@github.com:</span><span style="color: #24292E">$USERNAME</span><span style="color: #032F62">/</span><span style="color: #24292E">$REPONAME</span><span style="color: #032F62">.git</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><h3 id="solution-2" tabindex="-1">Solution 2 <a class="header-anchor" href="#solution-2" aria-label="Permalink to &quot;Solution 2&quot;">&ZeroWidthSpace;</a></h3>
<p>GitHub username &amp; password/access token mismatched due to prior temporary Git config setup → Reset Git global username &amp; email config or in current repository</p>
<p><strong>To set your global username/email configuration:</strong></p>
<ol>
<li>Open the command line.</li>
<li>Set your username: <code>git config --global user.name &quot;FIRST_NAME LAST_NAME&quot;</code></li>
<li>Set your email address: <code>git config --global user.email &quot;MY_NAME@example.com&quot;</code></li>
</ol>
<p><strong>To set repository-specific username/email configuration:</strong></p>
<ol>
<li>From the command line, change into the repository directory.</li>
<li>Set your username: <code>git config user.name &quot;FIRST_NAME LAST_NAME&quot;</code></li>
<li>Set your email address: <code>git config user.email &quot;MY_NAME@example.com&quot;</code></li>
<li>Verify your configuration by displaying your configuration file: <code>cat .git/config</code></li>
</ol>
]]></description>
            <content:encoded><![CDATA[<h1 id="git-push-results-in-authentication-failed" tabindex="-1">Git push results in &quot;Authentication Failed” <a class="header-anchor" href="#git-push-results-in-authentication-failed" aria-label="Permalink to &quot;Git push results in &quot;Authentication Failed”&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="issue" tabindex="-1">Issue <a class="header-anchor" href="#issue" aria-label="Permalink to &quot;Issue&quot;">&ZeroWidthSpace;</a></h2>
<div class="language-bash vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">git</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">push</span></span>
<span class="line"><span style="color: #F69D50">Username</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">for</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;https://github.com&#39;:</span><span style="color: #ADBAC7"> ${{ GITHUB_USERNAME }</span><span style="color: #96D0FF">}</span></span>
<span class="line"><span style="color: #F69D50">Password</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">for</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;https://andatoshiki@github.com&#39;:</span><span style="color: #ADBAC7"> ${{ GITHUB_PASSWORD }</span><span style="color: #96D0FF">}</span><span style="color: #ADBAC7"> </span><span style="color: #768390"># or GitHub personal access token</span></span>
<span class="line"><span style="color: #F69D50">remote:</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">Invalid</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">username</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">or</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">password.</span></span>
<span class="line"><span style="color: #F69D50">fatal:</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">Authentication</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">failed</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">for</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;https://github.com/andatoshiki/andatoshiki.git/&#39;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">git</span><span style="color: #24292E"> </span><span style="color: #032F62">push</span></span>
<span class="line"><span style="color: #6F42C1">Username</span><span style="color: #24292E"> </span><span style="color: #032F62">for</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;https://github.com&#39;:</span><span style="color: #24292E"> ${{ GITHUB_USERNAME }</span><span style="color: #032F62">}</span></span>
<span class="line"><span style="color: #6F42C1">Password</span><span style="color: #24292E"> </span><span style="color: #032F62">for</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;https://andatoshiki@github.com&#39;:</span><span style="color: #24292E"> ${{ GITHUB_PASSWORD }</span><span style="color: #032F62">}</span><span style="color: #24292E"> </span><span style="color: #6A737D"># or GitHub personal access token</span></span>
<span class="line"><span style="color: #6F42C1">remote:</span><span style="color: #24292E"> </span><span style="color: #032F62">Invalid</span><span style="color: #24292E"> </span><span style="color: #032F62">username</span><span style="color: #24292E"> </span><span style="color: #032F62">or</span><span style="color: #24292E"> </span><span style="color: #032F62">password.</span></span>
<span class="line"><span style="color: #6F42C1">fatal:</span><span style="color: #24292E"> </span><span style="color: #032F62">Authentication</span><span style="color: #24292E"> </span><span style="color: #032F62">failed</span><span style="color: #24292E"> </span><span style="color: #032F62">for</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;https://github.com/andatoshiki/andatoshiki.git/&#39;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br></div></div><p><code>git push</code> to GitHub remote branch failed via https protocol</p>
<h2 id="solution" tabindex="-1">Solution <a class="header-anchor" href="#solution" aria-label="Permalink to &quot;Solution&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="solution-1" tabindex="-1">Solution 1 <a class="header-anchor" href="#solution-1" aria-label="Permalink to &quot;Solution 1&quot;">&ZeroWidthSpace;</a></h3>
<blockquote>
<p>If you enabled two-factor authentication in your GitHub account you won't be able to push via HTTPS using your accounts password. Instead you need to generate a personal access token. This can be done in the application settings of your GitHub account. Using this token as your password should allow you to push to your remote repository via HTTPS. Use your username as usual.</p>
</blockquote>
<p>You may also need to update the origin for your repository if it is set to HTTPS. Do this to switch to SSH:</p>
<div class="language-bash vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">git</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">remote</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">-v</span></span>
<span class="line"><span style="color: #F69D50">$</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">git</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">remote</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">set-url</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">origin</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">git@github.com:</span><span style="color: #ADBAC7">$USERNAME</span><span style="color: #96D0FF">/</span><span style="color: #ADBAC7">$REPONAME</span><span style="color: #96D0FF">.git</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">git</span><span style="color: #24292E"> </span><span style="color: #032F62">remote</span><span style="color: #24292E"> </span><span style="color: #005CC5">-v</span></span>
<span class="line"><span style="color: #6F42C1">$</span><span style="color: #24292E"> </span><span style="color: #032F62">git</span><span style="color: #24292E"> </span><span style="color: #032F62">remote</span><span style="color: #24292E"> </span><span style="color: #032F62">set-url</span><span style="color: #24292E"> </span><span style="color: #032F62">origin</span><span style="color: #24292E"> </span><span style="color: #032F62">git@github.com:</span><span style="color: #24292E">$USERNAME</span><span style="color: #032F62">/</span><span style="color: #24292E">$REPONAME</span><span style="color: #032F62">.git</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><h3 id="solution-2" tabindex="-1">Solution 2 <a class="header-anchor" href="#solution-2" aria-label="Permalink to &quot;Solution 2&quot;">&ZeroWidthSpace;</a></h3>
<p>GitHub username &amp; password/access token mismatched due to prior temporary Git config setup → Reset Git global username &amp; email config or in current repository</p>
<p><strong>To set your global username/email configuration:</strong></p>
<ol>
<li>Open the command line.</li>
<li>Set your username: <code>git config --global user.name &quot;FIRST_NAME LAST_NAME&quot;</code></li>
<li>Set your email address: <code>git config --global user.email &quot;MY_NAME@example.com&quot;</code></li>
</ol>
<p><strong>To set repository-specific username/email configuration:</strong></p>
<ol>
<li>From the command line, change into the repository directory.</li>
<li>Set your username: <code>git config user.name &quot;FIRST_NAME LAST_NAME&quot;</code></li>
<li>Set your email address: <code>git config user.email &quot;MY_NAME@example.com&quot;</code></li>
<li>Verify your configuration by displaying your configuration file: <code>cat .git/config</code></li>
</ol>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Toshiki's Notebook]]></title>
            <link>https://note.toshiki.dev</link>
            <guid>https://note.toshiki.dev</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<!-- <script setup>
import { VPTeamMembers } from 'vitepress/theme'

const khanacademySVG = {
  svg: '<svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Khan Academy</title><path d="M21.724 4.973L13.418.328a3.214 3.214 0 0 0-2.828 0L2.276 4.973A3.05 3.05 0 0 0 .862 7.371v9.256a3.05 3.05 0 0 0 1.414 2.4l8.306 4.645a3.214 3.214 0 0 0 2.828 0l8.314-4.645a3.05 3.05 0 0 0 1.414-2.4V7.373a3.05 3.05 0 0 0-1.414-2.4zM12 4.921a2.571 2.571 0 1 1 .001 5.143A2.571 2.571 0 0 1 12 4.92zm3.094 13.627a9.119 9.119 0 0 1-3.103.549 8.972 8.972 0 0 1-3.076-.55 8.493 8.493 0 0 1-5.486-7.987v-.857c4.646.017 8.074 3.823 8.074 8.51v.198h.926v-.197c0-4.688 3.445-8.51 8.056-8.51.026.29.043.582.086.856a8.502 8.502 0 0 1-5.477 7.988z"/></svg>'
}

const members = [
  {
    avatar: "/logos/khancademy.svg",
    name: "Khan Academy",
    title: "Khan Academy is a non-profit educational organization that provides free online learning resources.",
    links: [
      { icon: "github", link: "https://github.com/Khan" },
      { icon: khanacademySVG, link: "https://khanacademy.org" }
    ],
  },
    {
    avatar: "/logos/khancademy.svg",
    name: "Khan Academy",
    title: "Khan Academy is a non-profit educational organization that provides free online learning resources.",
    links: [
      { icon: "github", link: "https://github.com/Khan" },
      { icon: khanacademySVG, link: "https://khanacademy.org" }
    ],
  },
    {
    avatar: "/logos/khancademy.svg",
    name: "Khan Academy",
    title: "Khan Academy is a non-profit educational organization that provides free online learning resources.",
    links: [
      { icon: "github", link: "https://github.com/Khan" },
      { icon: khanacademySVG, link: "https://khanacademy.org" }
    ],
  },
    {
    avatar: "/logos/khancademy.svg",
    name: "Khan Academy",
    title: "Khan Academy is a non-profit educational organization that provides free online learning resources.",
    links: [
      { icon: "github", link: "https://github.com/Khan" },
      { icon: khanacademySVG, link: "https://khanacademy.org" }
    ],
  },
  {
    avatar: "https://avatars.githubusercontent.com/u/5837277?v=4",
    name: "Knut Sveidqvist",
    title: "Creator",
    links: [{ icon: "github", link: "https://github.com/knsv" }],
  },
];
</script>

<div class="vp-doc" >
  <h2 id="meet-the-team"> 👀 My Learning Platforms </h2>
  <VPTeamMembers size="small" :members="members" />
</div>

<style>
  .image-container .image-src {
    margin: 1rem auto;
    /* max-width: 100%;
    width: 100%; */
}

  .dark .image-src{
    filter: invert(1) hue-rotate(217deg)  contrast(0.72);
  }

  .vp-doc {
    align-items: center;
    flex-direction: column;
    display: flex;
    margin: 1.5rem;
  }

  .vp-doc h2 {
    margin: 48px 0 16px;
    border-top: 1px solid var(--vp-c-divider-light);
    padding-top: 24px;
    letter-spacing: -.02em;
    line-height: 32px;
    font-size: 24px;
}
</style> -->
]]></description>
            <content:encoded><![CDATA[<!-- <script setup>
import { VPTeamMembers } from 'vitepress/theme'

const khanacademySVG = {
  svg: '<svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Khan Academy</title><path d="M21.724 4.973L13.418.328a3.214 3.214 0 0 0-2.828 0L2.276 4.973A3.05 3.05 0 0 0 .862 7.371v9.256a3.05 3.05 0 0 0 1.414 2.4l8.306 4.645a3.214 3.214 0 0 0 2.828 0l8.314-4.645a3.05 3.05 0 0 0 1.414-2.4V7.373a3.05 3.05 0 0 0-1.414-2.4zM12 4.921a2.571 2.571 0 1 1 .001 5.143A2.571 2.571 0 0 1 12 4.92zm3.094 13.627a9.119 9.119 0 0 1-3.103.549 8.972 8.972 0 0 1-3.076-.55 8.493 8.493 0 0 1-5.486-7.987v-.857c4.646.017 8.074 3.823 8.074 8.51v.198h.926v-.197c0-4.688 3.445-8.51 8.056-8.51.026.29.043.582.086.856a8.502 8.502 0 0 1-5.477 7.988z"/></svg>'
}

const members = [
  {
    avatar: "/logos/khancademy.svg",
    name: "Khan Academy",
    title: "Khan Academy is a non-profit educational organization that provides free online learning resources.",
    links: [
      { icon: "github", link: "https://github.com/Khan" },
      { icon: khanacademySVG, link: "https://khanacademy.org" }
    ],
  },
    {
    avatar: "/logos/khancademy.svg",
    name: "Khan Academy",
    title: "Khan Academy is a non-profit educational organization that provides free online learning resources.",
    links: [
      { icon: "github", link: "https://github.com/Khan" },
      { icon: khanacademySVG, link: "https://khanacademy.org" }
    ],
  },
    {
    avatar: "/logos/khancademy.svg",
    name: "Khan Academy",
    title: "Khan Academy is a non-profit educational organization that provides free online learning resources.",
    links: [
      { icon: "github", link: "https://github.com/Khan" },
      { icon: khanacademySVG, link: "https://khanacademy.org" }
    ],
  },
    {
    avatar: "/logos/khancademy.svg",
    name: "Khan Academy",
    title: "Khan Academy is a non-profit educational organization that provides free online learning resources.",
    links: [
      { icon: "github", link: "https://github.com/Khan" },
      { icon: khanacademySVG, link: "https://khanacademy.org" }
    ],
  },
  {
    avatar: "https://avatars.githubusercontent.com/u/5837277?v=4",
    name: "Knut Sveidqvist",
    title: "Creator",
    links: [{ icon: "github", link: "https://github.com/knsv" }],
  },
];
</script>

<div class="vp-doc" >
  <h2 id="meet-the-team"> 👀 My Learning Platforms </h2>
  <VPTeamMembers size="small" :members="members" />
</div>

<style>
  .image-container .image-src {
    margin: 1rem auto;
    /* max-width: 100%;
    width: 100%; */
}

  .dark .image-src{
    filter: invert(1) hue-rotate(217deg)  contrast(0.72);
  }

  .vp-doc {
    align-items: center;
    flex-direction: column;
    display: flex;
    margin: 1.5rem;
  }

  .vp-doc h2 {
    margin: 48px 0 16px;
    border-top: 1px solid var(--vp-c-divider-light);
    padding-top: 24px;
    letter-spacing: -.02em;
    line-height: 32px;
    font-size: 24px;
}
</style> -->
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[1-1: Values]]></title>
            <link>https://note.toshiki.devjavascript/notes/1/1-1</link>
            <guid>https://note.toshiki.devjavascript/notes/1/1-1</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="_1-1-values" tabindex="-1">1-1: Values <a class="header-anchor" href="#_1-1-values" aria-label="Permalink to &quot;1-1: Values&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="_1-1-1-numbers" tabindex="-1">1-1-1: Numbers <Badge type="danger" text="must know" /> <a class="header-anchor" href="#_1-1-1-numbers" aria-label="Permalink to &quot;1-1-1: Numbers &lt;Badge type=&quot;danger&quot; text=&quot;must know&quot; /&gt;&quot;">&ZeroWidthSpace;</a></h2>
<p>Values of the <em>number</em> type are numeric values, normally written as follows,</p>
<div class="language-js vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">js</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #6CB6FF">144</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #005CC5">144</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><ul>
<li>
<p>Put this into a program, it will cause the number 144 to come into existence inside the computer, with the following bash script, 144 might looks like this in bits,</p>
<div class="language-js vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">js</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #6CB6FF">0100000001100010000000000000000000000000000000000000000000000000</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #005CC5">0100000001100010000000000000000000000000000000000000000000000000</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div></li>
<li>
<p>With the following bash script, 144 will be converted into binary values in integer form,</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">ip1</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">144</span><span style="color: #ADBAC7"> </span><span style="color: #768390"># defines a variable named ip1, with the value of 10</span></span>
<span class="line"><span style="color: #6CB6FF">echo</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;obase=2;</span><span style="color: #ADBAC7">$ip1</span><span style="color: #96D0FF">&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">|</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50">bc</span><span style="color: #ADBAC7"> </span><span style="color: #768390"># convert the value to binary via bc</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">ip1</span><span style="color: #D73A49">=</span><span style="color: #005CC5">144</span><span style="color: #24292E"> </span><span style="color: #6A737D"># defines a variable named ip1, with the value of 10</span></span>
<span class="line"><span style="color: #005CC5">echo</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;obase=2;</span><span style="color: #24292E">$ip1</span><span style="color: #032F62">&quot;</span><span style="color: #24292E"> </span><span style="color: #D73A49">|</span><span style="color: #24292E"> </span><span style="color: #6F42C1">bc</span><span style="color: #24292E"> </span><span style="color: #6A737D"># convert the value to binary via bc</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><ul>
<li>The variable <code>ip1</code> is assigned the value 144.</li>
<li>The <code>echo</code> command prints out the string &quot;obase=2;144&quot;, where &quot;obase=2;&quot; is an argument for <code>bc</code> that tells it to output the result in base 2 (binary), and &quot;10&quot; is the decimal number we want to convert.</li>
<li>The output of the <code>echo</code> command is piped (using the <code>|</code> character) to <code>bc</code>, which takes the input &quot;<code>obase=2;144</code>&quot; and interprets it as a command to convert the number 10 to binary.</li>
<li>Finally, the binary equivalent of 144, which is &quot;10010000&quot;, is printed to the terminal.</li>
</ul>
</li>
</ul>
<div class="tip custom-block"><p class="custom-block-title">TIP</p>
<p>But the standard describes JavaScript numbers as 64-bit floating-point values, which indicates fractions and exponents are available.</p>
</div>
<p>Not all whole numbers <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>1</mn><msup><mn>0</mn><mn>19</mn></msup></mrow><annotation encoding="application/x-tex">10^{19}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8141em;"></span><span class="mord">1</span><span class="mord"><span class="mord">0</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">19</span></span></span></span></span></span></span></span></span></span></span></span> fit in a JavaScript number. There are also negative numbers, so one of the bits has to be used to store the sign of the number.</p>
<ul>
<li>11 bits are used to store the position of the decimal dot within the number.</li>
<li>52 bits, any whole number less than <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msup><mn>2</mn><mn>52</mn></msup></mrow><annotation encoding="application/x-tex">2^{52}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8141em;"></span><span class="mord"><span class="mord">2</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">52</span></span></span></span></span></span></span></span></span></span></span></span>, which is more than <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>1</mn><msup><mn>0</mn><mn>15</mn></msup></mrow><annotation encoding="application/x-tex">10^{15}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8141em;"></span><span class="mord">1</span><span class="mord"><span class="mord">0</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">15</span></span></span></span></span></span></span></span></span></span></span></span> will safely fit in a JavaScript number, numbers we are using stay well below that.</li>
</ul>
<p>Fractional numbers are written by using a dot,</p>
<div class="language-js vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">js</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #6CB6FF">9.81</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #005CC5">9.81</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>For extreme huge or tiny numbers, we can also use &quot;scientific&quot; notion by adding an <code>e</code>, followed by the exponent of the number,</p>
<div class="language-js vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">js</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #6CB6FF">2.998e8</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #005CC5">2.998e8</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>This indicates <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>2.998</mn><mo>×</mo><mn>1</mn><msup><mn>0</mn><mn>8</mn></msup><mo>=</mo><mn>29980000</mn></mrow><annotation encoding="application/x-tex">2.998 \times 10^8 = 29980000</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7278em;vertical-align:-0.0833em;"></span><span class="mord">2.998</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">×</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.8141em;"></span><span class="mord">1</span><span class="mord"><span class="mord">0</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">8</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">29980000</span></span></span></span>.</p>
<p>Calculations with whole numbers (referred as <em>integers</em>) that fits into 52 bits are guaranteed to be always precise, but calculation with fraction numbers are generally not.</p>
<ul>
<li>Such as <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>π</mi></mrow><annotation encoding="application/x-tex">\pi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">π</span></span></span></span> cannot be precisely expressed by a finite amount of decimal digits, <strong>thus many numbers lose some precision when only 64 bits are available to store them.</strong></li>
</ul>
<details class="details custom-block"><summary>1-1-1: Numbers review</summary>
<ul>
<li>64 bits: A 64-bit number is a binary sequence of 64 bits, which can represent <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msup><mn>2</mn><mn>64</mn></msup></mrow><annotation encoding="application/x-tex">2^{64}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8141em;"></span><span class="mord"><span class="mord">2</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">64</span></span></span></span></span></span></span></span></span></span></span></span> (18,446,744,073,709,551,616) different values. This is commonly used for representing memory addresses and integers with large values in computer systems.</li>
<li>11 bits: An 11-bit number is a binary sequence of 11 bits, which can represent <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msup><mn>2</mn><mn>11</mn></msup></mrow><annotation encoding="application/x-tex">2^{11}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8141em;"></span><span class="mord"><span class="mord">2</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">11</span></span></span></span></span></span></span></span></span></span></span></span> (2,048) different values. This is often used in computer systems for encoding small integers, such as color values in images.</li>
<li>52 bits: A 52-bit number is a binary sequence of 52 bits, which can represent <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msup><mn>2</mn><mn>52</mn></msup></mrow><annotation encoding="application/x-tex">2^{52}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8141em;"></span><span class="mord"><span class="mord">2</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">52</span></span></span></span></span></span></span></span></span></span></span></span> (4,503,599,627,370,496) different values. This is often used for representing the significand or mantissa portion of a floating-point number in computer systems.</li>
</ul>
</details>
<h2 id="_1-1-2-arithmetic" tabindex="-1">1-1-2: Arithmetic <a class="header-anchor" href="#_1-1-2-arithmetic" aria-label="Permalink to &quot;1-1-2: Arithmetic&quot;">&ZeroWidthSpace;</a></h2>
<p>The main thing to do with numbers is arithmetic. Arithmetic operations such as addition or multiplication take two number values and produce a new number from them, the following is an example of calculation in JavaScript.</p>
<div class="language-js vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">js</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #6CB6FF">100</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">4</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">*</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">11</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #005CC5">100</span><span style="color: #24292E"> </span><span style="color: #D73A49">+</span><span style="color: #24292E"> </span><span style="color: #005CC5">4</span><span style="color: #24292E"> </span><span style="color: #D73A49">*</span><span style="color: #24292E"> </span><span style="color: #005CC5">11</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><ul>
<li>
<p>The <code>+</code> and <code>*</code> symbols are called <em>operators</em>.</p>
<ul>
<li><code>+</code> apparently stands for addition while <code>*</code> stands for multiplication.</li>
</ul>
</li>
<li>
<p>This expression indicates the multiplication takes place first then the adding of 100 comes next as a regard to <a href="https://www.khanacademy.org/math/cc-sixth-grade-math/x0267d782:cc-6th-exponents-and-order-of-operations/cc-6th-order-of-operations/v/more-complicated-order-of-operations-example#:~:text=The%20order%20of%20operations%20is,(from%20left%20to%20right)." target="_blank" rel="noreferrer">PEMDAS</a> rules (Order of Operations).</p>
</li>
</ul>
<p>But we can still overwrite the steps of operation using a parenthesis around the addition,</p>
<div class="language-js vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">js</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">;(</span><span style="color: #6CB6FF">100</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">4</span><span style="color: #ADBAC7">) </span><span style="color: #F47067">*</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">11</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">;(</span><span style="color: #005CC5">100</span><span style="color: #24292E"> </span><span style="color: #D73A49">+</span><span style="color: #24292E"> </span><span style="color: #005CC5">4</span><span style="color: #24292E">) </span><span style="color: #D73A49">*</span><span style="color: #24292E"> </span><span style="color: #005CC5">11</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>For subtraction, there is the <code>-</code> operator, and division can be done with <code>/</code>. When operators appear together without parentheses, they are applied is determined by the <em>precedence</em> of the operators.</p>
<ul>
<li>When multiple operators with the same precedence appear next to each other (as <code>1-2+1</code>), they are applied left to right (refers to PEMDAS).</li>
<li>Precedence: Priorities.</li>
</ul>
<div class="warning custom-block"><p class="custom-block-title">WARNING</p>
<p>When is doubt, don't care about precedence, just add parentheses for order of operation.</p>
</div>
<p>There is one more arithmetic operator, which is the <code>%</code> percent sign used to represent the <em>modulo</em> operation. <strong>The term &quot;X modulo Y&quot; is defined as the remainder of dividing X by Y.</strong></p>
<ul>
<li>For example, <code>314 % 100</code> is <code>14</code>, <code>10 % 3</code> is <code>1</code>, and <code>144 % 12</code> is 0 because there are no remainders.</li>
<li>Modulo's precedence is the same as that of multiplication and division.</li>
</ul>
<details class="details custom-block"><summary>1-2: Arithmetic review</summary>
<ul>
<li>All of the operators in JavaScript follows precedence rules, or referred as PEMDAS in conventional math.
<ul>
<li><code>+</code> and <code>-</code> has the same lowest precedence.</li>
<li><code>*</code> , <code>/</code> and <code>%</code> has the same medium precedence.</li>
<li><code>()</code> has the highest precedence, followed on with brackets.</li>
</ul>
</li>
<li>The symbol <code>%</code> refers to &quot;modulo&quot;, in mathematical reading, we say &quot;X modulo Y&quot; is the remainder of X over Y.</li>
</ul>
</details>
<h2 id="_1-1-3-strings" tabindex="-1">1-1-3: Strings <a class="header-anchor" href="#_1-1-3-strings" aria-label="Permalink to &quot;1-1-3: Strings&quot;">&ZeroWidthSpace;</a></h2>
<p>The next data type is the <em>string</em>. Its use is not as evident from its name as with numbers, it also fulfills a very basic role.</p>
<ul>
<li>Strings are used to represent text.</li>
<li>Strings are usually written by enclosing the contents with quotes.</li>
</ul>
<div class="language-js vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">js</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #96D0FF">&#39;Lorem ipsum dolor sit amet, consectetur adipiscing elit.&#39;</span></span>
<span class="line"><span style="color: #96D0FF">&#39;Lorem ipsum dolor sit amet, consectetur adipiscing elit.&#39;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #032F62">&#39;Lorem ipsum dolor sit amet, consectetur adipiscing elit.&#39;</span></span>
<span class="line"><span style="color: #032F62">&#39;Lorem ipsum dolor sit amet, consectetur adipiscing elit.&#39;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><div class="tip custom-block"><p class="custom-block-title">TIP</p>
<p><strong>Both single and double quotes</strong> can be used to mark strings</p>
<ul>
<li>As long as the quotes at the start and the end of the string match.</li>
</ul>
</div>
<p>Almost anything can be put between quotes, and JavaScript will make a string value out of it. But the followings are tricky to be put between quotes.</p>
<ul>
<li><strong>Newlines</strong>: The things we get when we press <kbd>enter</kbd> on keyboard. We uses <code>\n</code> to represent.</li>
<li><strong>New tab</strong>: Similarly like newlines, <code>\t</code> indicates a new tab being indented.</li>
</ul>
<p>Take the following string as an example,</p>
<div class="language-js vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">js</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #96D0FF">&#39;Lorem ipsum dolor sit amet,</span><span style="color: #F47067">\n</span><span style="color: #96D0FF"> consectetur adipiscing elit.&#39;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #032F62">&#39;Lorem ipsum dolor sit amet,</span><span style="color: #005CC5">\n</span><span style="color: #032F62"> consectetur adipiscing elit.&#39;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>The following will be the rendered output,</p>
<div class="language-js vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">js</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">Lorem ipsum dolor sit amet,</span></span>
<span class="line"><span style="color: #ADBAC7">consectetur adipiscing elit.</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">Lorem ipsum dolor sit amet,</span></span>
<span class="line"><span style="color: #24292E">consectetur adipiscing elit.</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><div class="warning custom-block"><p class="custom-block-title">WARNING</p>
<p>But the situations where we want a backslash in a string to just be a backslash instead of a special code. By using <code>\\</code> would render the &quot;just slash&quot; to <code>\</code> on output, instead of a special character, as follows,</p>
<div class="language-js vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">js</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #96D0FF">&quot;A newline character is written like </span><span style="color: #F47067">\&quot;\\</span><span style="color: #96D0FF">n</span><span style="color: #F47067">\&quot;</span><span style="color: #96D0FF">.&quot;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #032F62">&quot;A newline character is written like </span><span style="color: #005CC5">\&quot;\\</span><span style="color: #032F62">n</span><span style="color: #005CC5">\&quot;</span><span style="color: #032F62">.&quot;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div></div>
<p>Strings cannot be divided, multiplied, or subtracted, unlike integers. But the <code>+</code> operator can be used on the. It concatenates (glues) the two strings together, the following example will produce the string &quot;<code>concatenate</code>&quot;.</p>
<div class="language-js vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">js</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #96D0FF">&#39;con&#39;</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;cat&#39;</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;e&#39;</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;nate&#39;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #032F62">&#39;con&#39;</span><span style="color: #24292E"> </span><span style="color: #D73A49">+</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;cat&#39;</span><span style="color: #24292E"> </span><span style="color: #D73A49">+</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;e&#39;</span><span style="color: #24292E"> </span><span style="color: #D73A49">+</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;nate&#39;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><details class="details custom-block"><summary>1-1-3: Strings review</summary>
<ul>
<li>Nearly everything could be put into strings in JavaScript</li>
<li>String could be wrapped with <code>&quot;&quot;</code> double quotation marks or <code>''</code> single quotation marks.</li>
<li>There is a tricky situation in JavaScript's string, where <code>\</code> backslash followed with a character are being introduced specially by the interpreter, such as <code>\n</code> referred as newline, <code>\t</code> referred as new tab.
<ul>
<li><code>\\</code> double backslash will be rendered as a single <code>\</code>.</li>
<li><code>\&amp;</code> symbols followed after slash will not contain its original function such as connecting, but will be rendered as <code>&amp;</code> on output.</li>
</ul>
</li>
</ul>
</details>
<h3 id="_1-1-3-fr-further-reading" tabindex="-1">1-1-3-FR: Further Reading <a class="header-anchor" href="#_1-1-3-fr-further-reading" aria-label="Permalink to &quot;1-1-3-FR: Further Reading&quot;">&ZeroWidthSpace;</a></h3>
<p>From the example given in the prior section with a lot of backslashes, it might be hard to understand the concept on at what time the slash will be rendered and when it will be considered as a special character starter.</p>
<p>The example is given as,</p>
<div class="language-js vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">js</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #96D0FF">&quot;A newline character is written like </span><span style="color: #F47067">\&quot;\\</span><span style="color: #96D0FF">n</span><span style="color: #F47067">\&quot;</span><span style="color: #96D0FF">.&quot;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #032F62">&quot;A newline character is written like </span><span style="color: #005CC5">\&quot;\\</span><span style="color: #032F62">n</span><span style="color: #005CC5">\&quot;</span><span style="color: #032F62">.&quot;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>The rendered output will be on print,</p>
<div class="language-js vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">js</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #6CB6FF">A</span><span style="color: #ADBAC7"> newline character is written like </span><span style="color: #96D0FF">&quot;</span><span style="color: #F47067">\n</span><span style="color: #96D0FF">&quot;</span><span style="color: #ADBAC7">.</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #005CC5">A</span><span style="color: #24292E"> newline character is written like </span><span style="color: #032F62">&quot;</span><span style="color: #005CC5">\n</span><span style="color: #032F62">&quot;</span><span style="color: #24292E">.</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>the backslash character (<code>\</code>) is used as an escape character to indicate that the following character(s) should be treated specially. In this case, the <code>&quot;\n&quot;</code> sequence is an escape sequence that represents a newline character. The backslash before the <code>n</code> character tells the JavaScript interpreter that it should treat the <code>n</code> as a special character and not just as the letter &quot;n&quot;.</p>
<p>However, if we want to include an <strong>actual backslash character</strong> (<code>\</code>), we will have to <strong>escape it</strong> by using to two backslashes <code>\\</code>, or else with one single slash the JavaScript interpreter will still determines it as an special operator, Thus <code>\\</code> will print <code>\</code> on output.</p>
<ul>
<li>
<p><strong>But what about the quotation marks used within the quotation marks that wraps the string? Wouldn't JavaScript interpreter throw error?</strong></p>
<ul>
<li>
<p>In the given JavaScript string, the inner set of double quotation marks (<code>&quot;\\n&quot;</code>) is escaped using a backslash (<code>\</code>) character. This tells the JavaScript interpreter to treat the inner double quotation marks as a regular character instead of a string delimiter.</p>
<p>So when the string is rendered on output, the backslash character will be removed and the inner set of quotation marks will be displayed as a regular character. The rendered string will look like this,</p>
<div class="language-js vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">js</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #96D0FF">&#39;</span><span style="color: #F47067">\n</span><span style="color: #96D0FF">&#39;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #032F62">&#39;</span><span style="color: #005CC5">\n</span><span style="color: #032F62">&#39;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>The outer set of double quotation marks in the original string delimit the entire string and will be displayed as regular quotation marks.</p>
</li>
</ul>
</li>
</ul>
<blockquote>
<p><strong>Source</strong>: ChatGPT CA (Code Analysis)</p>
</blockquote>
]]></description>
            <content:encoded><![CDATA[<h1 id="_1-1-values" tabindex="-1">1-1: Values <a class="header-anchor" href="#_1-1-values" aria-label="Permalink to &quot;1-1: Values&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="_1-1-1-numbers" tabindex="-1">1-1-1: Numbers <Badge type="danger" text="must know" /> <a class="header-anchor" href="#_1-1-1-numbers" aria-label="Permalink to &quot;1-1-1: Numbers &lt;Badge type=&quot;danger&quot; text=&quot;must know&quot; /&gt;&quot;">&ZeroWidthSpace;</a></h2>
<p>Values of the <em>number</em> type are numeric values, normally written as follows,</p>
<div class="language-js vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">js</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #6CB6FF">144</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #005CC5">144</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><ul>
<li>
<p>Put this into a program, it will cause the number 144 to come into existence inside the computer, with the following bash script, 144 might looks like this in bits,</p>
<div class="language-js vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">js</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #6CB6FF">0100000001100010000000000000000000000000000000000000000000000000</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #005CC5">0100000001100010000000000000000000000000000000000000000000000000</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div></li>
<li>
<p>With the following bash script, 144 will be converted into binary values in integer form,</p>
<div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">ip1</span><span style="color: #F47067">=</span><span style="color: #6CB6FF">144</span><span style="color: #ADBAC7"> </span><span style="color: #768390"># defines a variable named ip1, with the value of 10</span></span>
<span class="line"><span style="color: #6CB6FF">echo</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&quot;obase=2;</span><span style="color: #ADBAC7">$ip1</span><span style="color: #96D0FF">&quot;</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">|</span><span style="color: #ADBAC7"> </span><span style="color: #F69D50">bc</span><span style="color: #ADBAC7"> </span><span style="color: #768390"># convert the value to binary via bc</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">ip1</span><span style="color: #D73A49">=</span><span style="color: #005CC5">144</span><span style="color: #24292E"> </span><span style="color: #6A737D"># defines a variable named ip1, with the value of 10</span></span>
<span class="line"><span style="color: #005CC5">echo</span><span style="color: #24292E"> </span><span style="color: #032F62">&quot;obase=2;</span><span style="color: #24292E">$ip1</span><span style="color: #032F62">&quot;</span><span style="color: #24292E"> </span><span style="color: #D73A49">|</span><span style="color: #24292E"> </span><span style="color: #6F42C1">bc</span><span style="color: #24292E"> </span><span style="color: #6A737D"># convert the value to binary via bc</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><ul>
<li>The variable <code>ip1</code> is assigned the value 144.</li>
<li>The <code>echo</code> command prints out the string &quot;obase=2;144&quot;, where &quot;obase=2;&quot; is an argument for <code>bc</code> that tells it to output the result in base 2 (binary), and &quot;10&quot; is the decimal number we want to convert.</li>
<li>The output of the <code>echo</code> command is piped (using the <code>|</code> character) to <code>bc</code>, which takes the input &quot;<code>obase=2;144</code>&quot; and interprets it as a command to convert the number 10 to binary.</li>
<li>Finally, the binary equivalent of 144, which is &quot;10010000&quot;, is printed to the terminal.</li>
</ul>
</li>
</ul>
<div class="tip custom-block"><p class="custom-block-title">TIP</p>
<p>But the standard describes JavaScript numbers as 64-bit floating-point values, which indicates fractions and exponents are available.</p>
</div>
<p>Not all whole numbers <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>1</mn><msup><mn>0</mn><mn>19</mn></msup></mrow><annotation encoding="application/x-tex">10^{19}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8141em;"></span><span class="mord">1</span><span class="mord"><span class="mord">0</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">19</span></span></span></span></span></span></span></span></span></span></span></span> fit in a JavaScript number. There are also negative numbers, so one of the bits has to be used to store the sign of the number.</p>
<ul>
<li>11 bits are used to store the position of the decimal dot within the number.</li>
<li>52 bits, any whole number less than <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msup><mn>2</mn><mn>52</mn></msup></mrow><annotation encoding="application/x-tex">2^{52}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8141em;"></span><span class="mord"><span class="mord">2</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">52</span></span></span></span></span></span></span></span></span></span></span></span>, which is more than <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>1</mn><msup><mn>0</mn><mn>15</mn></msup></mrow><annotation encoding="application/x-tex">10^{15}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8141em;"></span><span class="mord">1</span><span class="mord"><span class="mord">0</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">15</span></span></span></span></span></span></span></span></span></span></span></span> will safely fit in a JavaScript number, numbers we are using stay well below that.</li>
</ul>
<p>Fractional numbers are written by using a dot,</p>
<div class="language-js vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">js</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #6CB6FF">9.81</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #005CC5">9.81</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>For extreme huge or tiny numbers, we can also use &quot;scientific&quot; notion by adding an <code>e</code>, followed by the exponent of the number,</p>
<div class="language-js vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">js</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #6CB6FF">2.998e8</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #005CC5">2.998e8</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>This indicates <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>2.998</mn><mo>×</mo><mn>1</mn><msup><mn>0</mn><mn>8</mn></msup><mo>=</mo><mn>29980000</mn></mrow><annotation encoding="application/x-tex">2.998 \times 10^8 = 29980000</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7278em;vertical-align:-0.0833em;"></span><span class="mord">2.998</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">×</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.8141em;"></span><span class="mord">1</span><span class="mord"><span class="mord">0</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">8</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">29980000</span></span></span></span>.</p>
<p>Calculations with whole numbers (referred as <em>integers</em>) that fits into 52 bits are guaranteed to be always precise, but calculation with fraction numbers are generally not.</p>
<ul>
<li>Such as <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>π</mi></mrow><annotation encoding="application/x-tex">\pi</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">π</span></span></span></span> cannot be precisely expressed by a finite amount of decimal digits, <strong>thus many numbers lose some precision when only 64 bits are available to store them.</strong></li>
</ul>
<details class="details custom-block"><summary>1-1-1: Numbers review</summary>
<ul>
<li>64 bits: A 64-bit number is a binary sequence of 64 bits, which can represent <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msup><mn>2</mn><mn>64</mn></msup></mrow><annotation encoding="application/x-tex">2^{64}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8141em;"></span><span class="mord"><span class="mord">2</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">64</span></span></span></span></span></span></span></span></span></span></span></span> (18,446,744,073,709,551,616) different values. This is commonly used for representing memory addresses and integers with large values in computer systems.</li>
<li>11 bits: An 11-bit number is a binary sequence of 11 bits, which can represent <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msup><mn>2</mn><mn>11</mn></msup></mrow><annotation encoding="application/x-tex">2^{11}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8141em;"></span><span class="mord"><span class="mord">2</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">11</span></span></span></span></span></span></span></span></span></span></span></span> (2,048) different values. This is often used in computer systems for encoding small integers, such as color values in images.</li>
<li>52 bits: A 52-bit number is a binary sequence of 52 bits, which can represent <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msup><mn>2</mn><mn>52</mn></msup></mrow><annotation encoding="application/x-tex">2^{52}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8141em;"></span><span class="mord"><span class="mord">2</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8141em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">52</span></span></span></span></span></span></span></span></span></span></span></span> (4,503,599,627,370,496) different values. This is often used for representing the significand or mantissa portion of a floating-point number in computer systems.</li>
</ul>
</details>
<h2 id="_1-1-2-arithmetic" tabindex="-1">1-1-2: Arithmetic <a class="header-anchor" href="#_1-1-2-arithmetic" aria-label="Permalink to &quot;1-1-2: Arithmetic&quot;">&ZeroWidthSpace;</a></h2>
<p>The main thing to do with numbers is arithmetic. Arithmetic operations such as addition or multiplication take two number values and produce a new number from them, the following is an example of calculation in JavaScript.</p>
<div class="language-js vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">js</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #6CB6FF">100</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">4</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">*</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">11</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #005CC5">100</span><span style="color: #24292E"> </span><span style="color: #D73A49">+</span><span style="color: #24292E"> </span><span style="color: #005CC5">4</span><span style="color: #24292E"> </span><span style="color: #D73A49">*</span><span style="color: #24292E"> </span><span style="color: #005CC5">11</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><ul>
<li>
<p>The <code>+</code> and <code>*</code> symbols are called <em>operators</em>.</p>
<ul>
<li><code>+</code> apparently stands for addition while <code>*</code> stands for multiplication.</li>
</ul>
</li>
<li>
<p>This expression indicates the multiplication takes place first then the adding of 100 comes next as a regard to <a href="https://www.khanacademy.org/math/cc-sixth-grade-math/x0267d782:cc-6th-exponents-and-order-of-operations/cc-6th-order-of-operations/v/more-complicated-order-of-operations-example#:~:text=The%20order%20of%20operations%20is,(from%20left%20to%20right)." target="_blank" rel="noreferrer">PEMDAS</a> rules (Order of Operations).</p>
</li>
</ul>
<p>But we can still overwrite the steps of operation using a parenthesis around the addition,</p>
<div class="language-js vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">js</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">;(</span><span style="color: #6CB6FF">100</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">4</span><span style="color: #ADBAC7">) </span><span style="color: #F47067">*</span><span style="color: #ADBAC7"> </span><span style="color: #6CB6FF">11</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">;(</span><span style="color: #005CC5">100</span><span style="color: #24292E"> </span><span style="color: #D73A49">+</span><span style="color: #24292E"> </span><span style="color: #005CC5">4</span><span style="color: #24292E">) </span><span style="color: #D73A49">*</span><span style="color: #24292E"> </span><span style="color: #005CC5">11</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>For subtraction, there is the <code>-</code> operator, and division can be done with <code>/</code>. When operators appear together without parentheses, they are applied is determined by the <em>precedence</em> of the operators.</p>
<ul>
<li>When multiple operators with the same precedence appear next to each other (as <code>1-2+1</code>), they are applied left to right (refers to PEMDAS).</li>
<li>Precedence: Priorities.</li>
</ul>
<div class="warning custom-block"><p class="custom-block-title">WARNING</p>
<p>When is doubt, don't care about precedence, just add parentheses for order of operation.</p>
</div>
<p>There is one more arithmetic operator, which is the <code>%</code> percent sign used to represent the <em>modulo</em> operation. <strong>The term &quot;X modulo Y&quot; is defined as the remainder of dividing X by Y.</strong></p>
<ul>
<li>For example, <code>314 % 100</code> is <code>14</code>, <code>10 % 3</code> is <code>1</code>, and <code>144 % 12</code> is 0 because there are no remainders.</li>
<li>Modulo's precedence is the same as that of multiplication and division.</li>
</ul>
<details class="details custom-block"><summary>1-2: Arithmetic review</summary>
<ul>
<li>All of the operators in JavaScript follows precedence rules, or referred as PEMDAS in conventional math.
<ul>
<li><code>+</code> and <code>-</code> has the same lowest precedence.</li>
<li><code>*</code> , <code>/</code> and <code>%</code> has the same medium precedence.</li>
<li><code>()</code> has the highest precedence, followed on with brackets.</li>
</ul>
</li>
<li>The symbol <code>%</code> refers to &quot;modulo&quot;, in mathematical reading, we say &quot;X modulo Y&quot; is the remainder of X over Y.</li>
</ul>
</details>
<h2 id="_1-1-3-strings" tabindex="-1">1-1-3: Strings <a class="header-anchor" href="#_1-1-3-strings" aria-label="Permalink to &quot;1-1-3: Strings&quot;">&ZeroWidthSpace;</a></h2>
<p>The next data type is the <em>string</em>. Its use is not as evident from its name as with numbers, it also fulfills a very basic role.</p>
<ul>
<li>Strings are used to represent text.</li>
<li>Strings are usually written by enclosing the contents with quotes.</li>
</ul>
<div class="language-js vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">js</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #96D0FF">&#39;Lorem ipsum dolor sit amet, consectetur adipiscing elit.&#39;</span></span>
<span class="line"><span style="color: #96D0FF">&#39;Lorem ipsum dolor sit amet, consectetur adipiscing elit.&#39;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #032F62">&#39;Lorem ipsum dolor sit amet, consectetur adipiscing elit.&#39;</span></span>
<span class="line"><span style="color: #032F62">&#39;Lorem ipsum dolor sit amet, consectetur adipiscing elit.&#39;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><div class="tip custom-block"><p class="custom-block-title">TIP</p>
<p><strong>Both single and double quotes</strong> can be used to mark strings</p>
<ul>
<li>As long as the quotes at the start and the end of the string match.</li>
</ul>
</div>
<p>Almost anything can be put between quotes, and JavaScript will make a string value out of it. But the followings are tricky to be put between quotes.</p>
<ul>
<li><strong>Newlines</strong>: The things we get when we press <kbd>enter</kbd> on keyboard. We uses <code>\n</code> to represent.</li>
<li><strong>New tab</strong>: Similarly like newlines, <code>\t</code> indicates a new tab being indented.</li>
</ul>
<p>Take the following string as an example,</p>
<div class="language-js vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">js</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #96D0FF">&#39;Lorem ipsum dolor sit amet,</span><span style="color: #F47067">\n</span><span style="color: #96D0FF"> consectetur adipiscing elit.&#39;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #032F62">&#39;Lorem ipsum dolor sit amet,</span><span style="color: #005CC5">\n</span><span style="color: #032F62"> consectetur adipiscing elit.&#39;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>The following will be the rendered output,</p>
<div class="language-js vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">js</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #ADBAC7">Lorem ipsum dolor sit amet,</span></span>
<span class="line"><span style="color: #ADBAC7">consectetur adipiscing elit.</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #24292E">Lorem ipsum dolor sit amet,</span></span>
<span class="line"><span style="color: #24292E">consectetur adipiscing elit.</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><div class="warning custom-block"><p class="custom-block-title">WARNING</p>
<p>But the situations where we want a backslash in a string to just be a backslash instead of a special code. By using <code>\\</code> would render the &quot;just slash&quot; to <code>\</code> on output, instead of a special character, as follows,</p>
<div class="language-js vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">js</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #96D0FF">&quot;A newline character is written like </span><span style="color: #F47067">\&quot;\\</span><span style="color: #96D0FF">n</span><span style="color: #F47067">\&quot;</span><span style="color: #96D0FF">.&quot;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #032F62">&quot;A newline character is written like </span><span style="color: #005CC5">\&quot;\\</span><span style="color: #032F62">n</span><span style="color: #005CC5">\&quot;</span><span style="color: #032F62">.&quot;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div></div>
<p>Strings cannot be divided, multiplied, or subtracted, unlike integers. But the <code>+</code> operator can be used on the. It concatenates (glues) the two strings together, the following example will produce the string &quot;<code>concatenate</code>&quot;.</p>
<div class="language-js vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">js</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #96D0FF">&#39;con&#39;</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;cat&#39;</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;e&#39;</span><span style="color: #ADBAC7"> </span><span style="color: #F47067">+</span><span style="color: #ADBAC7"> </span><span style="color: #96D0FF">&#39;nate&#39;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #032F62">&#39;con&#39;</span><span style="color: #24292E"> </span><span style="color: #D73A49">+</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;cat&#39;</span><span style="color: #24292E"> </span><span style="color: #D73A49">+</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;e&#39;</span><span style="color: #24292E"> </span><span style="color: #D73A49">+</span><span style="color: #24292E"> </span><span style="color: #032F62">&#39;nate&#39;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><details class="details custom-block"><summary>1-1-3: Strings review</summary>
<ul>
<li>Nearly everything could be put into strings in JavaScript</li>
<li>String could be wrapped with <code>&quot;&quot;</code> double quotation marks or <code>''</code> single quotation marks.</li>
<li>There is a tricky situation in JavaScript's string, where <code>\</code> backslash followed with a character are being introduced specially by the interpreter, such as <code>\n</code> referred as newline, <code>\t</code> referred as new tab.
<ul>
<li><code>\\</code> double backslash will be rendered as a single <code>\</code>.</li>
<li><code>\&amp;</code> symbols followed after slash will not contain its original function such as connecting, but will be rendered as <code>&amp;</code> on output.</li>
</ul>
</li>
</ul>
</details>
<h3 id="_1-1-3-fr-further-reading" tabindex="-1">1-1-3-FR: Further Reading <a class="header-anchor" href="#_1-1-3-fr-further-reading" aria-label="Permalink to &quot;1-1-3-FR: Further Reading&quot;">&ZeroWidthSpace;</a></h3>
<p>From the example given in the prior section with a lot of backslashes, it might be hard to understand the concept on at what time the slash will be rendered and when it will be considered as a special character starter.</p>
<p>The example is given as,</p>
<div class="language-js vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">js</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #96D0FF">&quot;A newline character is written like </span><span style="color: #F47067">\&quot;\\</span><span style="color: #96D0FF">n</span><span style="color: #F47067">\&quot;</span><span style="color: #96D0FF">.&quot;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #032F62">&quot;A newline character is written like </span><span style="color: #005CC5">\&quot;\\</span><span style="color: #032F62">n</span><span style="color: #005CC5">\&quot;</span><span style="color: #032F62">.&quot;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>The rendered output will be on print,</p>
<div class="language-js vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">js</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #6CB6FF">A</span><span style="color: #ADBAC7"> newline character is written like </span><span style="color: #96D0FF">&quot;</span><span style="color: #F47067">\n</span><span style="color: #96D0FF">&quot;</span><span style="color: #ADBAC7">.</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #005CC5">A</span><span style="color: #24292E"> newline character is written like </span><span style="color: #032F62">&quot;</span><span style="color: #005CC5">\n</span><span style="color: #032F62">&quot;</span><span style="color: #24292E">.</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>the backslash character (<code>\</code>) is used as an escape character to indicate that the following character(s) should be treated specially. In this case, the <code>&quot;\n&quot;</code> sequence is an escape sequence that represents a newline character. The backslash before the <code>n</code> character tells the JavaScript interpreter that it should treat the <code>n</code> as a special character and not just as the letter &quot;n&quot;.</p>
<p>However, if we want to include an <strong>actual backslash character</strong> (<code>\</code>), we will have to <strong>escape it</strong> by using to two backslashes <code>\\</code>, or else with one single slash the JavaScript interpreter will still determines it as an special operator, Thus <code>\\</code> will print <code>\</code> on output.</p>
<ul>
<li>
<p><strong>But what about the quotation marks used within the quotation marks that wraps the string? Wouldn't JavaScript interpreter throw error?</strong></p>
<ul>
<li>
<p>In the given JavaScript string, the inner set of double quotation marks (<code>&quot;\\n&quot;</code>) is escaped using a backslash (<code>\</code>) character. This tells the JavaScript interpreter to treat the inner double quotation marks as a regular character instead of a string delimiter.</p>
<p>So when the string is rendered on output, the backslash character will be removed and the inner set of quotation marks will be displayed as a regular character. The rendered string will look like this,</p>
<div class="language-js vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">js</span><pre v-pre class="shiki github-dark-dimmed vp-code-dark" ><code><span class="line"><span style="color: #96D0FF">&#39;</span><span style="color: #F47067">\n</span><span style="color: #96D0FF">&#39;</span></span></code></pre><pre v-pre class="shiki github-light vp-code-light" ><code><span class="line"><span style="color: #032F62">&#39;</span><span style="color: #005CC5">\n</span><span style="color: #032F62">&#39;</span></span></code></pre>
<div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>The outer set of double quotation marks in the original string delimit the entire string and will be displayed as regular quotation marks.</p>
</li>
</ul>
</li>
</ul>
<blockquote>
<p><strong>Source</strong>: ChatGPT CA (Code Analysis)</p>
</blockquote>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[1-2]]></title>
            <link>https://note.toshiki.devjavascript/notes/1/1-2</link>
            <guid>https://note.toshiki.devjavascript/notes/1/1-2</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
        </item>
        <item>
            <title><![CDATA[俊樹のノート]]></title>
            <link>https://note.toshiki.devjp/</link>
            <guid>https://note.toshiki.devjp/</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<!-- <script setup>
import { VPTeamMembers } from 'vitepress/theme'

const khanacademySVG = {
  svg: '<svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Khan Academy</title><path d="M21.724 4.973L13.418.328a3.214 3.214 0 0 0-2.828 0L2.276 4.973A3.05 3.05 0 0 0 .862 7.371v9.256a3.05 3.05 0 0 0 1.414 2.4l8.306 4.645a3.214 3.214 0 0 0 2.828 0l8.314-4.645a3.05 3.05 0 0 0 1.414-2.4V7.373a3.05 3.05 0 0 0-1.414-2.4zM12 4.921a2.571 2.571 0 1 1 .001 5.143A2.571 2.571 0 0 1 12 4.92zm3.094 13.627a9.119 9.119 0 0 1-3.103.549 8.972 8.972 0 0 1-3.076-.55 8.493 8.493 0 0 1-5.486-7.987v-.857c4.646.017 8.074 3.823 8.074 8.51v.198h.926v-.197c0-4.688 3.445-8.51 8.056-8.51.026.29.043.582.086.856a8.502 8.502 0 0 1-5.477 7.988z"/></svg>'
}

const members = [
  {
    avatar: "/logos/khancademy.svg",
    name: "Khan Academy",
    title: "Khan Academy is a non-profit educational organization that provides free online learning resources.",
    links: [
      { icon: "github", link: "https://github.com/Khan" },
      { icon: khanacademySVG, link: "https://khanacademy.org" }
    ],
  },
    {
    avatar: "/logos/khancademy.svg",
    name: "Khan Academy",
    title: "Khan Academy is a non-profit educational organization that provides free online learning resources.",
    links: [
      { icon: "github", link: "https://github.com/Khan" },
      { icon: khanacademySVG, link: "https://khanacademy.org" }
    ],
  },
    {
    avatar: "/logos/khancademy.svg",
    name: "Khan Academy",
    title: "Khan Academy is a non-profit educational organization that provides free online learning resources.",
    links: [
      { icon: "github", link: "https://github.com/Khan" },
      { icon: khanacademySVG, link: "https://khanacademy.org" }
    ],
  },
    {
    avatar: "/logos/khancademy.svg",
    name: "Khan Academy",
    title: "Khan Academy is a non-profit educational organization that provides free online learning resources.",
    links: [
      { icon: "github", link: "https://github.com/Khan" },
      { icon: khanacademySVG, link: "https://khanacademy.org" }
    ],
  },
  {
    avatar: "https://avatars.githubusercontent.com/u/5837277?v=4",
    name: "Knut Sveidqvist",
    title: "Creator",
    links: [{ icon: "github", link: "https://github.com/knsv" }],
  },
];
</script>

<div class="vp-doc" >
  <h2 id="meet-the-team"> 👀 My Learning Platforms </h2>
  <VPTeamMembers size="small" :members="members" />
</div>

<style>
  .image-container .image-src {
    margin: 1rem auto;
    /* max-width: 100%;
    width: 100%; */
}

  .dark .image-src{
    filter: invert(1) hue-rotate(217deg)  contrast(0.72);
  }

  .vp-doc {
    align-items: center;
    flex-direction: column;
    display: flex;
    margin: 1.5rem;
  }

  .vp-doc h2 {
    margin: 48px 0 16px;
    border-top: 1px solid var(--vp-c-divider-light);
    padding-top: 24px;
    letter-spacing: -.02em;
    line-height: 32px;
    font-size: 24px;
}
</style> -->
]]></description>
            <content:encoded><![CDATA[<!-- <script setup>
import { VPTeamMembers } from 'vitepress/theme'

const khanacademySVG = {
  svg: '<svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Khan Academy</title><path d="M21.724 4.973L13.418.328a3.214 3.214 0 0 0-2.828 0L2.276 4.973A3.05 3.05 0 0 0 .862 7.371v9.256a3.05 3.05 0 0 0 1.414 2.4l8.306 4.645a3.214 3.214 0 0 0 2.828 0l8.314-4.645a3.05 3.05 0 0 0 1.414-2.4V7.373a3.05 3.05 0 0 0-1.414-2.4zM12 4.921a2.571 2.571 0 1 1 .001 5.143A2.571 2.571 0 0 1 12 4.92zm3.094 13.627a9.119 9.119 0 0 1-3.103.549 8.972 8.972 0 0 1-3.076-.55 8.493 8.493 0 0 1-5.486-7.987v-.857c4.646.017 8.074 3.823 8.074 8.51v.198h.926v-.197c0-4.688 3.445-8.51 8.056-8.51.026.29.043.582.086.856a8.502 8.502 0 0 1-5.477 7.988z"/></svg>'
}

const members = [
  {
    avatar: "/logos/khancademy.svg",
    name: "Khan Academy",
    title: "Khan Academy is a non-profit educational organization that provides free online learning resources.",
    links: [
      { icon: "github", link: "https://github.com/Khan" },
      { icon: khanacademySVG, link: "https://khanacademy.org" }
    ],
  },
    {
    avatar: "/logos/khancademy.svg",
    name: "Khan Academy",
    title: "Khan Academy is a non-profit educational organization that provides free online learning resources.",
    links: [
      { icon: "github", link: "https://github.com/Khan" },
      { icon: khanacademySVG, link: "https://khanacademy.org" }
    ],
  },
    {
    avatar: "/logos/khancademy.svg",
    name: "Khan Academy",
    title: "Khan Academy is a non-profit educational organization that provides free online learning resources.",
    links: [
      { icon: "github", link: "https://github.com/Khan" },
      { icon: khanacademySVG, link: "https://khanacademy.org" }
    ],
  },
    {
    avatar: "/logos/khancademy.svg",
    name: "Khan Academy",
    title: "Khan Academy is a non-profit educational organization that provides free online learning resources.",
    links: [
      { icon: "github", link: "https://github.com/Khan" },
      { icon: khanacademySVG, link: "https://khanacademy.org" }
    ],
  },
  {
    avatar: "https://avatars.githubusercontent.com/u/5837277?v=4",
    name: "Knut Sveidqvist",
    title: "Creator",
    links: [{ icon: "github", link: "https://github.com/knsv" }],
  },
];
</script>

<div class="vp-doc" >
  <h2 id="meet-the-team"> 👀 My Learning Platforms </h2>
  <VPTeamMembers size="small" :members="members" />
</div>

<style>
  .image-container .image-src {
    margin: 1rem auto;
    /* max-width: 100%;
    width: 100%; */
}

  .dark .image-src{
    filter: invert(1) hue-rotate(217deg)  contrast(0.72);
  }

  .vp-doc {
    align-items: center;
    flex-direction: column;
    display: flex;
    margin: 1.5rem;
  }

  .vp-doc h2 {
    margin: 48px 0 16px;
    border-top: 1px solid var(--vp-c-divider-light);
    padding-top: 24px;
    letter-spacing: -.02em;
    line-height: 32px;
    font-size: 24px;
}
</style> -->
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Theme ]]></title>
            <link>https://note.toshiki.devroadmap</link>
            <guid>https://note.toshiki.devroadmap</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="theme" tabindex="-1">Theme <a class="header-anchor" href="#theme" aria-label="Permalink to &quot;Theme&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="homepage" tabindex="-1">Homepage <a class="header-anchor" href="#homepage" aria-label="Permalink to &quot;Homepage&quot;">&ZeroWidthSpace;</a></h2>
<ul class="contains-task-list">
<li class="task-list-item">
<p><input class="task-list-item-checkbox" checked="" disabled="" type="checkbox"> Finish three hero action blocks with keywords and its corresponded descriptions.</p>
</li>
<li class="task-list-item">
<p><input class="task-list-item-checkbox" disabled="" type="checkbox"> Finish my learning platform section using SVGs of different online academies from simple icons.</p>
<ul>
<li>
<p>Descriptions</p>
</li>
<li>
<p>Icon in SVG format</p>
</li>
<li>
<p>Platform name</p>
</li>
<li>
<p>Linkable SVG icon/button</p>
<ul class="contains-task-list">
<li class="task-list-item"><input class="task-list-item-checkbox" checked="" disabled="" type="checkbox"> Khan academy</li>
<li class="task-list-item"><input class="task-list-item-checkbox" disabled="" type="checkbox"> GitHub</li>
<li class="task-list-item"><input class="task-list-item-checkbox" disabled="" type="checkbox"> Libretext</li>
<li class="task-list-item"><input class="task-list-item-checkbox" disabled="" type="checkbox"> OpenStax</li>
<li class="task-list-item"><input class="task-list-item-checkbox" disabled="" type="checkbox"> BCcampus</li>
<li class="task-list-item"><input class="task-list-item-checkbox" disabled="" type="checkbox"> Wikibooks</li>
<li class="task-list-item"><input class="task-list-item-checkbox" disabled="" type="checkbox"> Wikipedia</li>
<li class="task-list-item"><input class="task-list-item-checkbox" disabled="" type="checkbox"> Bookboon</li>
<li>[ ]</li>
</ul>
</li>
</ul>
</li>
</ul>
<h2 id="footer" tabindex="-1">Footer <a class="header-anchor" href="#footer" aria-label="Permalink to &quot;Footer&quot;">&ZeroWidthSpace;</a></h2>
<ul class="contains-task-list">
<li class="task-list-item"><input class="task-list-item-checkbox" disabled="" type="checkbox"> Footer copyright section new-lining and other additional information designs
<ul>
<li>Refer to footer of <a href="https://status.toshiki.dev" target="_blank" rel="noreferrer">https://status.toshiki.dev</a></li>
</ul>
</li>
</ul>
<h2 id="configs" tabindex="-1">Configs <a class="header-anchor" href="#configs" aria-label="Permalink to &quot;Configs&quot;">&ZeroWidthSpace;</a></h2>
<ul class="contains-task-list">
<li class="task-list-item"><input class="task-list-item-checkbox" disabled="" type="checkbox"> Header configs including different properties and meta configs.</li>
<li class="task-list-item"><input class="task-list-item-checkbox" disabled="" type="checkbox"> Complete navigation configuration.
<ul class="contains-task-list">
<li class="task-list-item"><input class="task-list-item-checkbox" disabled="" type="checkbox"> Navigation divider and text title, line breakings.
<ul>
<li>Refer to: <a href="https://github.com/maomao1996/mm-notes/blob/master/docs/.vitepress/configs/nav.ts" target="_blank" rel="noreferrer">mm-notes: <code>nav.ts</code></a>.</li>
</ul>
</li>
</ul>
</li>
<li class="task-list-item"><input class="task-list-item-checkbox" disabled="" type="checkbox"> Complete sidebar configs for different directories.</li>
<li class="task-list-item"><input class="task-list-item-checkbox" disabled="" type="checkbox"> Vitepress sidebar generation plugin for huge bundled clips article directory.</li>
</ul>
<h1 id="articles" tabindex="-1">Articles <a class="header-anchor" href="#articles" aria-label="Permalink to &quot;Articles&quot;">&ZeroWidthSpace;</a></h1>
<ul class="contains-task-list">
<li class="task-list-item"><input class="task-list-item-checkbox" disabled="" type="checkbox"> <code>&lt;head&gt;</code> tag documentation or guide by <a href="https://github.com/joshbuchea" target="_blank" rel="noreferrer">joshbuchea</a>/<a href="https://github.com/joshbuchea/HEAD" target="_blank" rel="noreferrer">HEAD</a>.</li>
<li class="task-list-item"><input class="task-list-item-checkbox" disabled="" type="checkbox"> Write index page for every directory, <strong>no Chat GPT allowed</strong>.</li>
<li class="task-list-item"><input class="task-list-item-checkbox" disabled="" type="checkbox"> Chemistry review notes.</li>
<li class="task-list-item"><input class="task-list-item-checkbox" disabled="" type="checkbox"> JavaScript 0-100 notes per chapter.
<ul>
<li>Marijn Haverbeke - Eloquent JavaScript_ A Modern Introduction to Programming (2011, No Starch Press)</li>
</ul>
</li>
<li class="task-list-item"><input class="task-list-item-checkbox" disabled="" type="checkbox"> Outliers novel clips</li>
<li class="task-list-item"><input class="task-list-item-checkbox" disabled="" type="checkbox"> Migrate clipped articles and archives from Notion to Vitepress.</li>
<li class="task-list-item"><input class="task-list-item-checkbox" disabled="" type="checkbox"> Fresh copy of &quot;How To Ask Questions The Smart Way&quot; by Eric Steven Raymond
<ul class="contains-task-list">
<li class="task-list-item"><input class="task-list-item-checkbox" disabled="" type="checkbox"> Reading notes</li>
<li><a href="http://www.catb.org/~esr/faqs/smart-questions.html" target="_blank" rel="noreferrer">http://www.catb.org/~esr/faqs/smart-questions.html</a></li>
</ul>
</li>
</ul>
]]></description>
            <content:encoded><![CDATA[<h1 id="theme" tabindex="-1">Theme <a class="header-anchor" href="#theme" aria-label="Permalink to &quot;Theme&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="homepage" tabindex="-1">Homepage <a class="header-anchor" href="#homepage" aria-label="Permalink to &quot;Homepage&quot;">&ZeroWidthSpace;</a></h2>
<ul class="contains-task-list">
<li class="task-list-item">
<p><input class="task-list-item-checkbox" checked="" disabled="" type="checkbox"> Finish three hero action blocks with keywords and its corresponded descriptions.</p>
</li>
<li class="task-list-item">
<p><input class="task-list-item-checkbox" disabled="" type="checkbox"> Finish my learning platform section using SVGs of different online academies from simple icons.</p>
<ul>
<li>
<p>Descriptions</p>
</li>
<li>
<p>Icon in SVG format</p>
</li>
<li>
<p>Platform name</p>
</li>
<li>
<p>Linkable SVG icon/button</p>
<ul class="contains-task-list">
<li class="task-list-item"><input class="task-list-item-checkbox" checked="" disabled="" type="checkbox"> Khan academy</li>
<li class="task-list-item"><input class="task-list-item-checkbox" disabled="" type="checkbox"> GitHub</li>
<li class="task-list-item"><input class="task-list-item-checkbox" disabled="" type="checkbox"> Libretext</li>
<li class="task-list-item"><input class="task-list-item-checkbox" disabled="" type="checkbox"> OpenStax</li>
<li class="task-list-item"><input class="task-list-item-checkbox" disabled="" type="checkbox"> BCcampus</li>
<li class="task-list-item"><input class="task-list-item-checkbox" disabled="" type="checkbox"> Wikibooks</li>
<li class="task-list-item"><input class="task-list-item-checkbox" disabled="" type="checkbox"> Wikipedia</li>
<li class="task-list-item"><input class="task-list-item-checkbox" disabled="" type="checkbox"> Bookboon</li>
<li>[ ]</li>
</ul>
</li>
</ul>
</li>
</ul>
<h2 id="footer" tabindex="-1">Footer <a class="header-anchor" href="#footer" aria-label="Permalink to &quot;Footer&quot;">&ZeroWidthSpace;</a></h2>
<ul class="contains-task-list">
<li class="task-list-item"><input class="task-list-item-checkbox" disabled="" type="checkbox"> Footer copyright section new-lining and other additional information designs
<ul>
<li>Refer to footer of <a href="https://status.toshiki.dev" target="_blank" rel="noreferrer">https://status.toshiki.dev</a></li>
</ul>
</li>
</ul>
<h2 id="configs" tabindex="-1">Configs <a class="header-anchor" href="#configs" aria-label="Permalink to &quot;Configs&quot;">&ZeroWidthSpace;</a></h2>
<ul class="contains-task-list">
<li class="task-list-item"><input class="task-list-item-checkbox" disabled="" type="checkbox"> Header configs including different properties and meta configs.</li>
<li class="task-list-item"><input class="task-list-item-checkbox" disabled="" type="checkbox"> Complete navigation configuration.
<ul class="contains-task-list">
<li class="task-list-item"><input class="task-list-item-checkbox" disabled="" type="checkbox"> Navigation divider and text title, line breakings.
<ul>
<li>Refer to: <a href="https://github.com/maomao1996/mm-notes/blob/master/docs/.vitepress/configs/nav.ts" target="_blank" rel="noreferrer">mm-notes: <code>nav.ts</code></a>.</li>
</ul>
</li>
</ul>
</li>
<li class="task-list-item"><input class="task-list-item-checkbox" disabled="" type="checkbox"> Complete sidebar configs for different directories.</li>
<li class="task-list-item"><input class="task-list-item-checkbox" disabled="" type="checkbox"> Vitepress sidebar generation plugin for huge bundled clips article directory.</li>
</ul>
<h1 id="articles" tabindex="-1">Articles <a class="header-anchor" href="#articles" aria-label="Permalink to &quot;Articles&quot;">&ZeroWidthSpace;</a></h1>
<ul class="contains-task-list">
<li class="task-list-item"><input class="task-list-item-checkbox" disabled="" type="checkbox"> <code>&lt;head&gt;</code> tag documentation or guide by <a href="https://github.com/joshbuchea" target="_blank" rel="noreferrer">joshbuchea</a>/<a href="https://github.com/joshbuchea/HEAD" target="_blank" rel="noreferrer">HEAD</a>.</li>
<li class="task-list-item"><input class="task-list-item-checkbox" disabled="" type="checkbox"> Write index page for every directory, <strong>no Chat GPT allowed</strong>.</li>
<li class="task-list-item"><input class="task-list-item-checkbox" disabled="" type="checkbox"> Chemistry review notes.</li>
<li class="task-list-item"><input class="task-list-item-checkbox" disabled="" type="checkbox"> JavaScript 0-100 notes per chapter.
<ul>
<li>Marijn Haverbeke - Eloquent JavaScript_ A Modern Introduction to Programming (2011, No Starch Press)</li>
</ul>
</li>
<li class="task-list-item"><input class="task-list-item-checkbox" disabled="" type="checkbox"> Outliers novel clips</li>
<li class="task-list-item"><input class="task-list-item-checkbox" disabled="" type="checkbox"> Migrate clipped articles and archives from Notion to Vitepress.</li>
<li class="task-list-item"><input class="task-list-item-checkbox" disabled="" type="checkbox"> Fresh copy of &quot;How To Ask Questions The Smart Way&quot; by Eric Steven Raymond
<ul class="contains-task-list">
<li class="task-list-item"><input class="task-list-item-checkbox" disabled="" type="checkbox"> Reading notes</li>
<li><a href="http://www.catb.org/~esr/faqs/smart-questions.html" target="_blank" rel="noreferrer">http://www.catb.org/~esr/faqs/smart-questions.html</a></li>
</ul>
</li>
</ul>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Welcome to Reading Notes ]]></title>
            <link>https://note.toshiki.devsave/reading/</link>
            <guid>https://note.toshiki.devsave/reading/</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="welcome-to-reading-notes" tabindex="-1">Welcome to Reading Notes <a class="header-anchor" href="#welcome-to-reading-notes" aria-label="Permalink to &quot;Welcome to Reading Notes&quot;">&ZeroWidthSpace;</a></h1>
]]></description>
            <content:encoded><![CDATA[<h1 id="welcome-to-reading-notes" tabindex="-1">Welcome to Reading Notes <a class="header-anchor" href="#welcome-to-reading-notes" aria-label="Permalink to &quot;Welcome to Reading Notes&quot;">&ZeroWidthSpace;</a></h1>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction & Chapter 1: The Roseto Mystery]]></title>
            <link>https://note.toshiki.devsave/reading/outliers/1</link>
            <guid>https://note.toshiki.devsave/reading/outliers/1</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="introduction-chapter-1-the-roseto-mystery" tabindex="-1">Introduction &amp; Chapter 1: The Roseto Mystery <a class="header-anchor" href="#introduction-chapter-1-the-roseto-mystery" aria-label="Permalink to &quot;Introduction &amp; Chapter 1: The Roseto Mystery&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="summary-introduction-the-roseto-mystery" tabindex="-1">Summary: Introduction: The Roseto Mystery <a class="header-anchor" href="#summary-introduction-the-roseto-mystery" aria-label="Permalink to &quot;Summary: Introduction: The Roseto Mystery&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="section-1" tabindex="-1">Section 1. <a class="header-anchor" href="#section-1" aria-label="Permalink to &quot;Section 1.&quot;">&ZeroWidthSpace;</a></h3>
<p>In the late 1800s, immigrants from Roseto Valfortore, Italy, came to Pennsylvania to work in the slate quarry near the town of Bangor. The settlers established a new community, named after their old one: Roseto. They built schools, a park, small shops, and more than a dozen factories. They kept to themselves and did not interact much with the predominantly German and English populations of the towns around them.</p>
<p>In the 1950s, a local doctor told Stewart Wolf, a medical researcher, that hardly anyone in Roseto under age sixty-five had heart disease. Wolf was curious. He did blood draws and EKG scans, and he analyzed physicians’ records and death certificates. Wolf was amazed that almost no one under fifty-five showed any signs of heart disease, which at the time was America’s leading cause of death in men under sixty-five. Wolf enlisted the help of John Bruhn, a sociologist. They found that there was no suicide, alcoholism, or drug addiction in Roseto: everyone seemed to be dying of old age. According to Gladwell, Roseto was an <em>outlier</em>.</p>
<h3 id="section-2" tabindex="-1">Section 2. <a class="header-anchor" href="#section-2" aria-label="Permalink to &quot;Section 2.&quot;">&ZeroWidthSpace;</a></h3>
<p>Wolf was forced to rule out diet and lifestyle as explanations, because the Rosetans had poor eating habits, smoked heavily, and were obese. He ruled out genetics after determining that Rosetans’ relatives in other parts of the country were not in comparably good health. Wolf eventually decided that what made Roseto’s inhabitants so healthy was the town itself—its culture and social structure. Many homes contained three generations living together, and with a population of just two thousand people, there were twenty-two separate civic organizations.</p>
<p>Wolf and Bruhn were met with a great deal of skepticism. They had to work hard to convince the medical establishment that the values of where we live and the people around us have a significant impact on who we are. Gladwell wants <em>Outliers</em> to do for our understanding of success what Wolf did for our understanding of health.</p>
<h2 id="summary-chapter-one-the-matthew-effect" tabindex="-1">Summary: Chapter One: The Matthew Effect <a class="header-anchor" href="#summary-chapter-one-the-matthew-effect" aria-label="Permalink to &quot;Summary: Chapter One: The Matthew Effect&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="section-1-1" tabindex="-1">Section 1. <a class="header-anchor" href="#section-1-1" aria-label="Permalink to &quot;Section 1.&quot;">&ZeroWidthSpace;</a></h3>
<p>Gladwell describes a game between two teams in the Canadian Hockey League, the most competitive junior hockey league in the world. Starting at a very young age, players are regularly assessed for talent, so that the best can be separated out and prepared for the next level. The system is designed to be a meritocracy.</p>
<h3 id="section-2-1" tabindex="-1">Section 2. <a class="header-anchor" href="#section-2-1" aria-label="Permalink to &quot;Section 2.&quot;">&ZeroWidthSpace;</a></h3>
<p>Gladwell wants to show that circumstances matter just as much for success as work ethic or intelligence. People often ask about the lifestyle, intelligence, or special talents of successful individuals, but not enough people ask when and where a person grew up. Gladwell likens people to trees: we all know that the tallest trees received the most sunlight, had nutrient-rich soil, and were lucky enough to avoid lumberjacks. He suggests that we study the environmental and social influences that make people successful.</p>
<h3 id="section-3" tabindex="-1">Section 3. <a class="header-anchor" href="#section-3" aria-label="Permalink to &quot;Section 3.&quot;">&ZeroWidthSpace;</a></h3>
<p>In the 1980s, Canadian psychologist Roger Barnsley observed that on elite Canadian hockey teams, whether youth league or NHL, a disproportionate number of players have birthdays in the first three months of the year.</p>
<h3 id="section-4" tabindex="-1">Section 4. <a class="header-anchor" href="#section-4" aria-label="Permalink to &quot;Section 4.&quot;">&ZeroWidthSpace;</a></h3>
<p>The explanation for the distribution of birthdays is simple: the cutoff date for an individual’s league assignment is January 1. A player born on January 2 will be 12 months older than one born at the end of December. At the age of nine or ten, this often translates into a huge difference in size, coordination, and maturity. By age ten, coaches regularly pick the oldest and largest potential players for the more competitive “rep squads,” where the players will receive better coaching, have more practice time, and play many more games. By thirteen or fourteen, all of the extra experience and coaching will have actually made the players better, and they will be selected for the more competitive league(s). The same thing happens in American youth baseball and European soccer, but with different cutoff dates.</p>
<p>The phenomenon is also observable in education. Economists Kelly Bedard and Elizabeth Dhuey found that on math and science tests, the older children in fourth grade regularly score better than the youngest children. This can affect whether a child qualifies for a gifted program. When Bedard and Dhuey extended their analysis to four-year colleges, they found that the students who belonged to the relatively youngest group were underrepresented by more than 10 percent.</p>
<h3 id="section-5" tabindex="-1">Section 5. <a class="header-anchor" href="#section-5" aria-label="Permalink to &quot;Section 5.&quot;">&ZeroWidthSpace;</a></h3>
<p>The top-level hockey players were given opportunities they neither deserved nor earned. Sociologist Robert Merton called this the “Matthew Effect,” after the verse in the Gospel of Matthew:</p>
<p>“For unto everyone that hath shall be given, and he shall have abundance. But from that hath not shall be taken away even that which he hath.”</p>
<p>The successful receive more resources: the best students receive the best teaching, the richest citizens get the biggest tax breaks, the largest kids get the best coaching. Sociologists call this “accumulative advantage.” Gladwell points out that cutoff dates exclude nearly half of the potential athletes from a population. Junior hockey teams in the Czech Republic show the same unbalanced distribution of birthdays as in Canada. If Canada or the Czech Republic separated each of their youth leagues into two separate leagues, one for kids born in the first half of the year, and one for kids born in the second half of the year, they would have twice as many athletes available for their national teams. Similarly, schools could separate kindergarten classes into students born in the first, middle, and last four months of the year. The benefits would justify the added administrative work, but, writes Gladwell, the scheme would run afoul of society’s need to believe that individual merit matters more than the rules society has created.</p>
<h3 id="section-6" tabindex="-1">Section 6. <a class="header-anchor" href="#section-6" aria-label="Permalink to &quot;Section 6.&quot;">&ZeroWidthSpace;</a></h3>
<p>Gord Wasden, the father of one of the Canadian Hockey League boys from the first section, describes his son. Scott Wasden worked hard to get where he is, but he has also generally had the advantage of being big compared to others on his team. He was born on January 4.</p>
<h3 id="analysis-introduction-the-roseto-mystery-chapter-1-the-matthew-effect" tabindex="-1">Analysis: Introduction: The Roseto Mystery &amp; Chapter 1: The Matthew Effect <a class="header-anchor" href="#analysis-introduction-the-roseto-mystery-chapter-1-the-matthew-effect" aria-label="Permalink to &quot;Analysis: Introduction: The Roseto Mystery &amp; Chapter 1: The Matthew Effect&quot;">&ZeroWidthSpace;</a></h3>
<p>Gladwell's thesis argues that that the idea of rugged, individual success is not accurate. Rather, the most successful person doesn’t thrive without some environmental and social influence plus a dose of good fortune.  After laying out the concepts of a meritocracy and suggesting that this is the way that hockey players advance in Canada, he immediately undercuts this idea. Gladwell uses the illustration of birthday distribution as an example of an invisible contributor to the success of hockey players. With a registration cutoff date of January 1, players born from January 2 through March 31 are older than teammates born later in the year. These older players are likely bigger, faster, more coordinated, and more mature. Since the older players are seen as more skilled, they get selected for more advanced leagues with more practice, more games, and higher-quality coaching. By the time these older players reach their early teens, the extra advantages gained from being judged better because of their birthday translate into being better players. Similarly, the age cutoff for school registrations often mistakes maturity for ability. As a result, the older children appear smarter, get put into advanced groups, and qualify for gifted programs. The birthdate bias carries through to college.</p>
<p>Advantages result in more advantages. Gladwell reinforces this idea with the “Matthew Effect,” which states that &quot;success leads to more success.&quot; More simply: by being a little bit better, a hockey player will get opportunities that may result in the player becoming an outlier. Gladwell implies that the systems that determine success are not efficient. He asks readers to question the way we, as a society, think about success. He suggests that changing the systems in athletics and education would chip away at the myth of individual merit as the chief marker of success and help level the playing field. Gladwell's model for this phenomenon is hockey player Scott Wasden. By demonstrating that Scott had the passion, talent, and work ethic for the game, as well as the good luck to be born on January 4, Gladwell reasons that Wasden, like many others he will be profiling, benefit by being both good and lucky.</p>
<div class="info custom-block"><p class="custom-block-title">Reference</p>
<ul>
<li>“Outliers Introduction &amp; Chapter 1 Summary &amp; Analysis.” SparkNotes, www.sparknotes.com/lit/outliers/section1/.</li>
</ul>
</div>
]]></description>
            <content:encoded><![CDATA[<h1 id="introduction-chapter-1-the-roseto-mystery" tabindex="-1">Introduction &amp; Chapter 1: The Roseto Mystery <a class="header-anchor" href="#introduction-chapter-1-the-roseto-mystery" aria-label="Permalink to &quot;Introduction &amp; Chapter 1: The Roseto Mystery&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="summary-introduction-the-roseto-mystery" tabindex="-1">Summary: Introduction: The Roseto Mystery <a class="header-anchor" href="#summary-introduction-the-roseto-mystery" aria-label="Permalink to &quot;Summary: Introduction: The Roseto Mystery&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="section-1" tabindex="-1">Section 1. <a class="header-anchor" href="#section-1" aria-label="Permalink to &quot;Section 1.&quot;">&ZeroWidthSpace;</a></h3>
<p>In the late 1800s, immigrants from Roseto Valfortore, Italy, came to Pennsylvania to work in the slate quarry near the town of Bangor. The settlers established a new community, named after their old one: Roseto. They built schools, a park, small shops, and more than a dozen factories. They kept to themselves and did not interact much with the predominantly German and English populations of the towns around them.</p>
<p>In the 1950s, a local doctor told Stewart Wolf, a medical researcher, that hardly anyone in Roseto under age sixty-five had heart disease. Wolf was curious. He did blood draws and EKG scans, and he analyzed physicians’ records and death certificates. Wolf was amazed that almost no one under fifty-five showed any signs of heart disease, which at the time was America’s leading cause of death in men under sixty-five. Wolf enlisted the help of John Bruhn, a sociologist. They found that there was no suicide, alcoholism, or drug addiction in Roseto: everyone seemed to be dying of old age. According to Gladwell, Roseto was an <em>outlier</em>.</p>
<h3 id="section-2" tabindex="-1">Section 2. <a class="header-anchor" href="#section-2" aria-label="Permalink to &quot;Section 2.&quot;">&ZeroWidthSpace;</a></h3>
<p>Wolf was forced to rule out diet and lifestyle as explanations, because the Rosetans had poor eating habits, smoked heavily, and were obese. He ruled out genetics after determining that Rosetans’ relatives in other parts of the country were not in comparably good health. Wolf eventually decided that what made Roseto’s inhabitants so healthy was the town itself—its culture and social structure. Many homes contained three generations living together, and with a population of just two thousand people, there were twenty-two separate civic organizations.</p>
<p>Wolf and Bruhn were met with a great deal of skepticism. They had to work hard to convince the medical establishment that the values of where we live and the people around us have a significant impact on who we are. Gladwell wants <em>Outliers</em> to do for our understanding of success what Wolf did for our understanding of health.</p>
<h2 id="summary-chapter-one-the-matthew-effect" tabindex="-1">Summary: Chapter One: The Matthew Effect <a class="header-anchor" href="#summary-chapter-one-the-matthew-effect" aria-label="Permalink to &quot;Summary: Chapter One: The Matthew Effect&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="section-1-1" tabindex="-1">Section 1. <a class="header-anchor" href="#section-1-1" aria-label="Permalink to &quot;Section 1.&quot;">&ZeroWidthSpace;</a></h3>
<p>Gladwell describes a game between two teams in the Canadian Hockey League, the most competitive junior hockey league in the world. Starting at a very young age, players are regularly assessed for talent, so that the best can be separated out and prepared for the next level. The system is designed to be a meritocracy.</p>
<h3 id="section-2-1" tabindex="-1">Section 2. <a class="header-anchor" href="#section-2-1" aria-label="Permalink to &quot;Section 2.&quot;">&ZeroWidthSpace;</a></h3>
<p>Gladwell wants to show that circumstances matter just as much for success as work ethic or intelligence. People often ask about the lifestyle, intelligence, or special talents of successful individuals, but not enough people ask when and where a person grew up. Gladwell likens people to trees: we all know that the tallest trees received the most sunlight, had nutrient-rich soil, and were lucky enough to avoid lumberjacks. He suggests that we study the environmental and social influences that make people successful.</p>
<h3 id="section-3" tabindex="-1">Section 3. <a class="header-anchor" href="#section-3" aria-label="Permalink to &quot;Section 3.&quot;">&ZeroWidthSpace;</a></h3>
<p>In the 1980s, Canadian psychologist Roger Barnsley observed that on elite Canadian hockey teams, whether youth league or NHL, a disproportionate number of players have birthdays in the first three months of the year.</p>
<h3 id="section-4" tabindex="-1">Section 4. <a class="header-anchor" href="#section-4" aria-label="Permalink to &quot;Section 4.&quot;">&ZeroWidthSpace;</a></h3>
<p>The explanation for the distribution of birthdays is simple: the cutoff date for an individual’s league assignment is January 1. A player born on January 2 will be 12 months older than one born at the end of December. At the age of nine or ten, this often translates into a huge difference in size, coordination, and maturity. By age ten, coaches regularly pick the oldest and largest potential players for the more competitive “rep squads,” where the players will receive better coaching, have more practice time, and play many more games. By thirteen or fourteen, all of the extra experience and coaching will have actually made the players better, and they will be selected for the more competitive league(s). The same thing happens in American youth baseball and European soccer, but with different cutoff dates.</p>
<p>The phenomenon is also observable in education. Economists Kelly Bedard and Elizabeth Dhuey found that on math and science tests, the older children in fourth grade regularly score better than the youngest children. This can affect whether a child qualifies for a gifted program. When Bedard and Dhuey extended their analysis to four-year colleges, they found that the students who belonged to the relatively youngest group were underrepresented by more than 10 percent.</p>
<h3 id="section-5" tabindex="-1">Section 5. <a class="header-anchor" href="#section-5" aria-label="Permalink to &quot;Section 5.&quot;">&ZeroWidthSpace;</a></h3>
<p>The top-level hockey players were given opportunities they neither deserved nor earned. Sociologist Robert Merton called this the “Matthew Effect,” after the verse in the Gospel of Matthew:</p>
<p>“For unto everyone that hath shall be given, and he shall have abundance. But from that hath not shall be taken away even that which he hath.”</p>
<p>The successful receive more resources: the best students receive the best teaching, the richest citizens get the biggest tax breaks, the largest kids get the best coaching. Sociologists call this “accumulative advantage.” Gladwell points out that cutoff dates exclude nearly half of the potential athletes from a population. Junior hockey teams in the Czech Republic show the same unbalanced distribution of birthdays as in Canada. If Canada or the Czech Republic separated each of their youth leagues into two separate leagues, one for kids born in the first half of the year, and one for kids born in the second half of the year, they would have twice as many athletes available for their national teams. Similarly, schools could separate kindergarten classes into students born in the first, middle, and last four months of the year. The benefits would justify the added administrative work, but, writes Gladwell, the scheme would run afoul of society’s need to believe that individual merit matters more than the rules society has created.</p>
<h3 id="section-6" tabindex="-1">Section 6. <a class="header-anchor" href="#section-6" aria-label="Permalink to &quot;Section 6.&quot;">&ZeroWidthSpace;</a></h3>
<p>Gord Wasden, the father of one of the Canadian Hockey League boys from the first section, describes his son. Scott Wasden worked hard to get where he is, but he has also generally had the advantage of being big compared to others on his team. He was born on January 4.</p>
<h3 id="analysis-introduction-the-roseto-mystery-chapter-1-the-matthew-effect" tabindex="-1">Analysis: Introduction: The Roseto Mystery &amp; Chapter 1: The Matthew Effect <a class="header-anchor" href="#analysis-introduction-the-roseto-mystery-chapter-1-the-matthew-effect" aria-label="Permalink to &quot;Analysis: Introduction: The Roseto Mystery &amp; Chapter 1: The Matthew Effect&quot;">&ZeroWidthSpace;</a></h3>
<p>Gladwell's thesis argues that that the idea of rugged, individual success is not accurate. Rather, the most successful person doesn’t thrive without some environmental and social influence plus a dose of good fortune.  After laying out the concepts of a meritocracy and suggesting that this is the way that hockey players advance in Canada, he immediately undercuts this idea. Gladwell uses the illustration of birthday distribution as an example of an invisible contributor to the success of hockey players. With a registration cutoff date of January 1, players born from January 2 through March 31 are older than teammates born later in the year. These older players are likely bigger, faster, more coordinated, and more mature. Since the older players are seen as more skilled, they get selected for more advanced leagues with more practice, more games, and higher-quality coaching. By the time these older players reach their early teens, the extra advantages gained from being judged better because of their birthday translate into being better players. Similarly, the age cutoff for school registrations often mistakes maturity for ability. As a result, the older children appear smarter, get put into advanced groups, and qualify for gifted programs. The birthdate bias carries through to college.</p>
<p>Advantages result in more advantages. Gladwell reinforces this idea with the “Matthew Effect,” which states that &quot;success leads to more success.&quot; More simply: by being a little bit better, a hockey player will get opportunities that may result in the player becoming an outlier. Gladwell implies that the systems that determine success are not efficient. He asks readers to question the way we, as a society, think about success. He suggests that changing the systems in athletics and education would chip away at the myth of individual merit as the chief marker of success and help level the playing field. Gladwell's model for this phenomenon is hockey player Scott Wasden. By demonstrating that Scott had the passion, talent, and work ethic for the game, as well as the good luck to be born on January 4, Gladwell reasons that Wasden, like many others he will be profiling, benefit by being both good and lucky.</p>
<div class="info custom-block"><p class="custom-block-title">Reference</p>
<ul>
<li>“Outliers Introduction &amp; Chapter 1 Summary &amp; Analysis.” SparkNotes, www.sparknotes.com/lit/outliers/section1/.</li>
</ul>
</div>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Chapter Two: The 10,000-Hour Rule]]></title>
            <link>https://note.toshiki.devsave/reading/outliers/2</link>
            <guid>https://note.toshiki.devsave/reading/outliers/2</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="chapter-two-the-10-000-hour-rule" tabindex="-1">Chapter Two: The 10,000-Hour Rule <a class="header-anchor" href="#chapter-two-the-10-000-hour-rule" aria-label="Permalink to &quot;Chapter Two: The 10,000-Hour Rule&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="summary-chapter-two-the-10-000-hour-rule" tabindex="-1">Summary: Chapter Two: The 10,000-Hour Rule <a class="header-anchor" href="#summary-chapter-two-the-10-000-hour-rule" aria-label="Permalink to &quot;Summary: Chapter Two: The 10,000-Hour Rule&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="section-1" tabindex="-1">Section 1. <a class="header-anchor" href="#section-1" aria-label="Permalink to &quot;Section 1.&quot;">&ZeroWidthSpace;</a></h3>
<p>Bill Joy, a co-founder of Sun Microsystems, is one of the most influential computer programmers of all time. Joy attended the University of Michigan, thinking to become a biologist or mathematician, but he became obsessed with the Computer Center that opened during his freshman year. In 1975, he enrolled in graduate school at UC Berkeley. At both schools, Bill Joy spent much of his free time programming. After graduating from Berkeley, he founded Sun Microsystems, eventually rewriting the Java programming language. He would appear to be a good example of success based on individual merit.</p>
<h3 id="section-2" tabindex="-1">Section 2. <a class="header-anchor" href="#section-2" aria-label="Permalink to &quot;Section 2.&quot;">&ZeroWidthSpace;</a></h3>
<p>If achievement is the combination of talent and preparation, how much does innate talent affect one’s success? In the 1990s, a study at Berlin’s elite Academy of Music determined that, regardless of instrument, all of the world-class students had practiced more than 10,000 hours. They did not find anyone at the top level who spent less time, nor did they find anyone who spent that amount of time who was not successful. Neurologist Daniel Levitin states that, across many fields, world-class expertise is never accomplished in less than 10,000 hours. The law holds even for a prodigy like Mozart, who started composing at age six: he did not compose his first masterwork until he was twenty-one. The youth athletes from the previous chapter who made it to the professional level put in 10,000 hours of practice. And note: individuals cannot normally put in that much practice without help. Most people will need supportive parents, financial stability, and probably a special program—like an all-star youth hockey team.</p>
<h3 id="section-3" tabindex="-1">Section 3. <a class="header-anchor" href="#section-3" aria-label="Permalink to &quot;Section 3.&quot;">&ZeroWidthSpace;</a></h3>
<p>Bill Joy was certainly intelligent, having achieved a perfect score on the math portion of his Scholastic Aptitude Test. His opportunities, however, were extraordinary. Bill Joy happened to choose a college that had a time-sharing computer available, something that was exceedingly rare during the early 1970s. While most students had to pay for computer time, Bill Joy exploited a bug in the college’s system to gain unlimited access to the Computer Center, which was walking distance from where he lived. He was able to spend almost all of his free time programming, and when he went to Berkeley, he had a terminal at home, where he could program until he fell asleep at his keyboard. Bill Joy was able to accumulate 10,000 hours while in college.</p>
<h3 id="section-4" tabindex="-1">Section 4. <a class="header-anchor" href="#section-4" aria-label="Permalink to &quot;Section 4.&quot;">&ZeroWidthSpace;</a></h3>
<p>The Beatles are another example of the 10,000-hours principle. In 1960, when they were still a high school rock band, they were given the chance to travel to Hamburg, Germany and play in various strip clubs. The Beatles were contracted to play for hours every night, seven nights a week, and thereby were forced to develop as musicians. After a year and a half, they had performed 270 nights. By 1964, when they first found commercial success, they had performed an estimated twelve hundred times—more than most band bands do in an entire career.</p>
<h3 id="section-5" tabindex="-1">Section 5. <a class="header-anchor" href="#section-5" aria-label="Permalink to &quot;Section 5.&quot;">&ZeroWidthSpace;</a></h3>
<p>Born in Seattle to affluent parents, Bill Gates was sent to a private school for seventh grade. The school’s Mother’s Club funded the purchase of a time-sharing terminal connected to a mainframe computer in Seattle. As an eighth-grader, Gates was able to start programming. When the Mother’s Club could no longer pay for computing time, Gates was able to continue programming at Information Sciences, Inc. (ISI) through a connection he made with one of the school parents. After that, one of ISI’s founders recommended Gates for a programming project at the Bonneville Power station. Gates was able to leave high school during his senior year to program for the Bonneville Power station as an independent study project. By the time Bill Gates dropped out of Harvard, he was well past 10,000 hours of experience.</p>
<h3 id="section-6" tabindex="-1">Section 6. <a class="header-anchor" href="#section-6" aria-label="Permalink to &quot;Section 6.&quot;">&ZeroWidthSpace;</a></h3>
<p>In a list of the seventy-five richest people in human history, going as far back as ancient Egypt and converting all wealth estimates into modern U.S. dollars, fourteen names are Americans born within nine years of one another (including John D. Rockefeller and J.P. Morgan). What accounts for the fact that a list that covers thousands of years should have 20 percent of its members so close together? The fourteen Americans happened to live during the 1860s and 1870s, when the American economy was undergoing a huge transformation: the expansion of the railroads and the creation of Wall Street. Gladwell argues that the fourteen names are so close in birth date because they were all the perfect age to seize the opportunities available.</p>
<p>Bill Joy and Bill Gates were also born at just the right time. In 1975, <em>Popular Electronics</em> ran a cover story about the Altair 8800, a $397 microcomputer kit. Someone born before 1954 would likely already have a job with IBM, working on mainframes. Someone born after 1956 would likely still be in high school. Most of the biggest pioneers in the modern computer industry, including Bill Gates, Bill Joy, Steve Jobs, and Eric Schmidt, were born in 1954 or 1955, as were Joy’s three fellow founders at Sun.</p>
<h2 id="analysis-chapter-two-the-10-000-hour-rule" tabindex="-1">Analysis: Chapter Two: The 10,000-Hour Rule <a class="header-anchor" href="#analysis-chapter-two-the-10-000-hour-rule" aria-label="Permalink to &quot;Analysis: Chapter Two: The 10,000-Hour Rule&quot;">&ZeroWidthSpace;</a></h2>
<p>Gladwell introduces his controversial and widely disputed 10,000 hours rule. Simply put, the rule suggests that to master a skill, an individual needs to practice it for 10,000 hours. Gladwell argues that, like hockey, success in computing requires both skill and luck, rather than pure, simple, natural ability. Gladwell's example is situated at the University of Michigan, specifically the new computer center, in 1971. The story of Bill Joy undermines the idea of success as an inexplicable, miraculous accomplishment. Though Gladwell agrees Joy is bright and talented, Joy also lucks into several happy accidents that allow for increased access. These strokes of luck give Joy the opportunity to become a computer expert. Gladwell's use of a psychological study conducted at the Academy of Music in Berlin, Germany, in the early 1990s forms the crux of his argument in this chapter. However, critics have suggested that this study was flawed and that there is no incontrovertible evidence to suggest that doing anything for 10,000 hours guarantees mastery. Rather, practice is, as Gladwell points out elsewhere throughout the text, just one of the factors in success. However, he also correlates the familial and economic advantages necessary to reach 10,000 of practice time, reinforcing the larger thesis of the book.</p>
<p>Gladwell argues that the Beatles and Bill Gates are examples of his notion of time spent directly relating to mastery. While detailing how the Beatles reached the 10,000-hour threshold for mastery, Gladwell also highlights the lucky breaks they had in achieving success, like the connection that landed the band in Hamburg’s music scene. Additionally, while Gates has become something of an American folk hero, Gladwell argues that Gates did not reach his great achievements completely on his own. His wealthy family, his lucky interaction with a computer in 1968, and his college experience allowed him far greater access to opportunity. Without this combination of factors, along with his intelligence and drive, Gates would likely not have become a household name. Again, Gladwell reinforces the idea that success comes not only from being good, but from having no small amount of luck, whether that be time, money, or, in an echo of the hockey player example, birthdate.</p>
<p>Gladwell claims that one important factor of success is the year in which one is born. In terms of wealth, there are 14 Americans, born in a nine-year period of the 1800s, who are among the richest people in history. This suggests that there was some connection to when they were born and the opportunities available to them in terms of innovation and invention, as well as the position they were in to take advantage of the opportunities. Similarly, men born in the same era of Bill Gates were coming of age at the bleeding edge of technology. Proximity to social and technological change, as well as the wealth and connections to take advantage of it, put these men in an advantageous position. Being in the right place at the right time, Gladwell argues, has at least as much to do with success as one's inborn abilities.</p>
<div class="info custom-block"><p class="custom-block-title">Reference</p>
<ul>
<li>“Outliers Chapter 2 Summary &amp; Analysis.” SparkNotes, www.sparknotes.com/lit/outliers/section2/. Accessed 27 Feb. 2023.</li>
</ul>
</div>
]]></description>
            <content:encoded><![CDATA[<h1 id="chapter-two-the-10-000-hour-rule" tabindex="-1">Chapter Two: The 10,000-Hour Rule <a class="header-anchor" href="#chapter-two-the-10-000-hour-rule" aria-label="Permalink to &quot;Chapter Two: The 10,000-Hour Rule&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="summary-chapter-two-the-10-000-hour-rule" tabindex="-1">Summary: Chapter Two: The 10,000-Hour Rule <a class="header-anchor" href="#summary-chapter-two-the-10-000-hour-rule" aria-label="Permalink to &quot;Summary: Chapter Two: The 10,000-Hour Rule&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="section-1" tabindex="-1">Section 1. <a class="header-anchor" href="#section-1" aria-label="Permalink to &quot;Section 1.&quot;">&ZeroWidthSpace;</a></h3>
<p>Bill Joy, a co-founder of Sun Microsystems, is one of the most influential computer programmers of all time. Joy attended the University of Michigan, thinking to become a biologist or mathematician, but he became obsessed with the Computer Center that opened during his freshman year. In 1975, he enrolled in graduate school at UC Berkeley. At both schools, Bill Joy spent much of his free time programming. After graduating from Berkeley, he founded Sun Microsystems, eventually rewriting the Java programming language. He would appear to be a good example of success based on individual merit.</p>
<h3 id="section-2" tabindex="-1">Section 2. <a class="header-anchor" href="#section-2" aria-label="Permalink to &quot;Section 2.&quot;">&ZeroWidthSpace;</a></h3>
<p>If achievement is the combination of talent and preparation, how much does innate talent affect one’s success? In the 1990s, a study at Berlin’s elite Academy of Music determined that, regardless of instrument, all of the world-class students had practiced more than 10,000 hours. They did not find anyone at the top level who spent less time, nor did they find anyone who spent that amount of time who was not successful. Neurologist Daniel Levitin states that, across many fields, world-class expertise is never accomplished in less than 10,000 hours. The law holds even for a prodigy like Mozart, who started composing at age six: he did not compose his first masterwork until he was twenty-one. The youth athletes from the previous chapter who made it to the professional level put in 10,000 hours of practice. And note: individuals cannot normally put in that much practice without help. Most people will need supportive parents, financial stability, and probably a special program—like an all-star youth hockey team.</p>
<h3 id="section-3" tabindex="-1">Section 3. <a class="header-anchor" href="#section-3" aria-label="Permalink to &quot;Section 3.&quot;">&ZeroWidthSpace;</a></h3>
<p>Bill Joy was certainly intelligent, having achieved a perfect score on the math portion of his Scholastic Aptitude Test. His opportunities, however, were extraordinary. Bill Joy happened to choose a college that had a time-sharing computer available, something that was exceedingly rare during the early 1970s. While most students had to pay for computer time, Bill Joy exploited a bug in the college’s system to gain unlimited access to the Computer Center, which was walking distance from where he lived. He was able to spend almost all of his free time programming, and when he went to Berkeley, he had a terminal at home, where he could program until he fell asleep at his keyboard. Bill Joy was able to accumulate 10,000 hours while in college.</p>
<h3 id="section-4" tabindex="-1">Section 4. <a class="header-anchor" href="#section-4" aria-label="Permalink to &quot;Section 4.&quot;">&ZeroWidthSpace;</a></h3>
<p>The Beatles are another example of the 10,000-hours principle. In 1960, when they were still a high school rock band, they were given the chance to travel to Hamburg, Germany and play in various strip clubs. The Beatles were contracted to play for hours every night, seven nights a week, and thereby were forced to develop as musicians. After a year and a half, they had performed 270 nights. By 1964, when they first found commercial success, they had performed an estimated twelve hundred times—more than most band bands do in an entire career.</p>
<h3 id="section-5" tabindex="-1">Section 5. <a class="header-anchor" href="#section-5" aria-label="Permalink to &quot;Section 5.&quot;">&ZeroWidthSpace;</a></h3>
<p>Born in Seattle to affluent parents, Bill Gates was sent to a private school for seventh grade. The school’s Mother’s Club funded the purchase of a time-sharing terminal connected to a mainframe computer in Seattle. As an eighth-grader, Gates was able to start programming. When the Mother’s Club could no longer pay for computing time, Gates was able to continue programming at Information Sciences, Inc. (ISI) through a connection he made with one of the school parents. After that, one of ISI’s founders recommended Gates for a programming project at the Bonneville Power station. Gates was able to leave high school during his senior year to program for the Bonneville Power station as an independent study project. By the time Bill Gates dropped out of Harvard, he was well past 10,000 hours of experience.</p>
<h3 id="section-6" tabindex="-1">Section 6. <a class="header-anchor" href="#section-6" aria-label="Permalink to &quot;Section 6.&quot;">&ZeroWidthSpace;</a></h3>
<p>In a list of the seventy-five richest people in human history, going as far back as ancient Egypt and converting all wealth estimates into modern U.S. dollars, fourteen names are Americans born within nine years of one another (including John D. Rockefeller and J.P. Morgan). What accounts for the fact that a list that covers thousands of years should have 20 percent of its members so close together? The fourteen Americans happened to live during the 1860s and 1870s, when the American economy was undergoing a huge transformation: the expansion of the railroads and the creation of Wall Street. Gladwell argues that the fourteen names are so close in birth date because they were all the perfect age to seize the opportunities available.</p>
<p>Bill Joy and Bill Gates were also born at just the right time. In 1975, <em>Popular Electronics</em> ran a cover story about the Altair 8800, a $397 microcomputer kit. Someone born before 1954 would likely already have a job with IBM, working on mainframes. Someone born after 1956 would likely still be in high school. Most of the biggest pioneers in the modern computer industry, including Bill Gates, Bill Joy, Steve Jobs, and Eric Schmidt, were born in 1954 or 1955, as were Joy’s three fellow founders at Sun.</p>
<h2 id="analysis-chapter-two-the-10-000-hour-rule" tabindex="-1">Analysis: Chapter Two: The 10,000-Hour Rule <a class="header-anchor" href="#analysis-chapter-two-the-10-000-hour-rule" aria-label="Permalink to &quot;Analysis: Chapter Two: The 10,000-Hour Rule&quot;">&ZeroWidthSpace;</a></h2>
<p>Gladwell introduces his controversial and widely disputed 10,000 hours rule. Simply put, the rule suggests that to master a skill, an individual needs to practice it for 10,000 hours. Gladwell argues that, like hockey, success in computing requires both skill and luck, rather than pure, simple, natural ability. Gladwell's example is situated at the University of Michigan, specifically the new computer center, in 1971. The story of Bill Joy undermines the idea of success as an inexplicable, miraculous accomplishment. Though Gladwell agrees Joy is bright and talented, Joy also lucks into several happy accidents that allow for increased access. These strokes of luck give Joy the opportunity to become a computer expert. Gladwell's use of a psychological study conducted at the Academy of Music in Berlin, Germany, in the early 1990s forms the crux of his argument in this chapter. However, critics have suggested that this study was flawed and that there is no incontrovertible evidence to suggest that doing anything for 10,000 hours guarantees mastery. Rather, practice is, as Gladwell points out elsewhere throughout the text, just one of the factors in success. However, he also correlates the familial and economic advantages necessary to reach 10,000 of practice time, reinforcing the larger thesis of the book.</p>
<p>Gladwell argues that the Beatles and Bill Gates are examples of his notion of time spent directly relating to mastery. While detailing how the Beatles reached the 10,000-hour threshold for mastery, Gladwell also highlights the lucky breaks they had in achieving success, like the connection that landed the band in Hamburg’s music scene. Additionally, while Gates has become something of an American folk hero, Gladwell argues that Gates did not reach his great achievements completely on his own. His wealthy family, his lucky interaction with a computer in 1968, and his college experience allowed him far greater access to opportunity. Without this combination of factors, along with his intelligence and drive, Gates would likely not have become a household name. Again, Gladwell reinforces the idea that success comes not only from being good, but from having no small amount of luck, whether that be time, money, or, in an echo of the hockey player example, birthdate.</p>
<p>Gladwell claims that one important factor of success is the year in which one is born. In terms of wealth, there are 14 Americans, born in a nine-year period of the 1800s, who are among the richest people in history. This suggests that there was some connection to when they were born and the opportunities available to them in terms of innovation and invention, as well as the position they were in to take advantage of the opportunities. Similarly, men born in the same era of Bill Gates were coming of age at the bleeding edge of technology. Proximity to social and technological change, as well as the wealth and connections to take advantage of it, put these men in an advantageous position. Being in the right place at the right time, Gladwell argues, has at least as much to do with success as one's inborn abilities.</p>
<div class="info custom-block"><p class="custom-block-title">Reference</p>
<ul>
<li>“Outliers Chapter 2 Summary &amp; Analysis.” SparkNotes, www.sparknotes.com/lit/outliers/section2/. Accessed 27 Feb. 2023.</li>
</ul>
</div>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Chapter 3: The Trouble with Geniuses, Part 1]]></title>
            <link>https://note.toshiki.devsave/reading/outliers/3</link>
            <guid>https://note.toshiki.devsave/reading/outliers/3</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="chapter-3-the-trouble-with-geniuses-part-1" tabindex="-1">Chapter 3: The Trouble with Geniuses, Part 1 <a class="header-anchor" href="#chapter-3-the-trouble-with-geniuses-part-1" aria-label="Permalink to &quot;Chapter 3: The Trouble with Geniuses, Part 1&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="summary-chapter-three-the-trouble-with-geniuses-part-1" tabindex="-1">Summary: Chapter Three: The Trouble with Geniuses, Part 1 <a class="header-anchor" href="#summary-chapter-three-the-trouble-with-geniuses-part-1" aria-label="Permalink to &quot;Summary: Chapter Three: The Trouble with Geniuses, Part 1&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="section-1" tabindex="-1">Section 1. <a class="header-anchor" href="#section-1" aria-label="Permalink to &quot;Section 1.&quot;">&ZeroWidthSpace;</a></h3>
<p>Chris Langan appeared on the television trivia show <em>1 vs. 100</em> after being the subject of interviews and at least one documentary, due to his extremely high IQ. He had little difficulty in high school, got a perfect score on his SAT, and read through <em>Principia Mathematica</em> as a teenager. On <em>1 vs. 100</em>, Langan cashed out with winnings of $250,000.</p>
<h3 id="section-2" tabindex="-1">Section 2. <a class="header-anchor" href="#section-2" aria-label="Permalink to &quot;Section 2.&quot;">&ZeroWidthSpace;</a></h3>
<p>Shortly after World War I, Lewis Terman, creator of the widely used Stanford-Binet IQ test, became fascinated with child prodigies. In 1921, he identified exceptionally gifted 1,470 students who came to be known as the “Termites.” Terman kept track of them over the years, carefully cataloging their educational achievement, marriages, psychological health, and employment. Terman was sure that the Termites would be the future elite of the United States. The same confidence underlies the use of IQ-like tests, such as the SAT, to assess applicants at Ivy League schools and corporations such as Microsoft and Google. Gladwell states that Terman was wrong about the Termites, and if he had met Chris Langan as a teenager, he would have been wrong about him, too.</p>
<h3 id="section-3" tabindex="-1">Section 3. <a class="header-anchor" href="#section-3" aria-label="Permalink to &quot;Section 3.&quot;">&ZeroWidthSpace;</a></h3>
<p>Gladwell gives two examples—one easy and one much harder—of questions that use visual puzzles to test IQ, without requiring any language abilities or specific factual knowledge. The average human will score 100. Those scoring below 70 are considered mentally disabled, and those who are successful in graduate programs likely have an IQ of 115 or higher. According to Gladwell, however, above 120 IQ makes little or no difference to success. A similar point applies to basketball: height is certainly an advantage, but there is, at best, modest value in being six foot seven instead of six foot six. A basketball player just needs to be tall <em>enough</em>.</p>
<p>A list of the last twenty-five Americans to win a Nobel Prize in Medicine includes graduates of prestigious schools, such as Columbia, Harvard, and MIT, but also graduates of DePauw, Holy Cross, and Gettysburg College. Similarly, there have been American Nobel laureates in Chemistry from Harvard and MIT, but also from Notre Dame and the University of Illinois. Harvard might have more intelligent students, but many other colleges have students smart <em>enough</em> to win a Nobel.</p>
<p>At the University of Michigan law school, around 10 percent of students are racial minorities. Without affirmative action, there would be less than 3 percent. Looking at career performance after graduation, Michigan found no difference between white and minority graduates. Minority students come into law school with weaker academic credentials than their white counterparts, but they are above the threshold required to be just as successful.</p>
<h3 id="section-4" tabindex="-1">Section 4. <a class="header-anchor" href="#section-4" aria-label="Permalink to &quot;Section 4.&quot;">&ZeroWidthSpace;</a></h3>
<p>Not all questions that test for intelligence have a single correct answer. A different sort of question might ask for a list of different uses for a brick, or a blanket. A question like this measures imagination and creativity. At a top British high school, one student lists more than ten uses, many of which are comical. Another student, a prodigy with one of the school’s highest IQs, lists just a few uses, all of which are practical. Compared to an IQ test, asking about different uses for a brick might be a better way to identify future Nobel Prize winners.</p>
<h3 id="section-5" tabindex="-1">Section 5. <a class="header-anchor" href="#section-5" aria-label="Permalink to &quot;Section 5.&quot;">&ZeroWidthSpace;</a></h3>
<p>Terman’s error was using intelligence alone to choose his Termites. While some of the Termites had successful careers, an unexpectedly high went on to careers that even Terman didn’t consider to be successful. The two students tested by Terman’s team who actually did go on to win Nobels were not selected as Termites: their IQs were too low. Terman eventually concluded that “intellect and achievement are far from perfectly correlated.”</p>
<p>Gladwell states that to understand Chris Langan’s prospects of becoming a “true outlier,” one must learn more about him.</p>
<h2 id="analysis-chapter-three-the-trouble-with-geniuses-part-1" tabindex="-1">Analysis: Chapter Three: The Trouble with Geniuses, Part 1 <a class="header-anchor" href="#analysis-chapter-three-the-trouble-with-geniuses-part-1" aria-label="Permalink to &quot;Analysis: Chapter Three: The Trouble with Geniuses, Part 1&quot;">&ZeroWidthSpace;</a></h2>
<p>Intelligence, Gladwell argues, does not equal success. He dedicates this chapter to the examination of geniuses. Comparing the young subjects of Lewis Terman to Chris Langan, Gladwell argues against Terman’s idea that genius is a key to societal advancement. Gladwell lists Langan’s early accomplishments as a shining example of Terman's idea, then swiftly undercuts expectations. Gladwell argues again that individuals do not succeed or fail solely on their own, but rather due to a constellation of factors, many of which are uncontrollable. Langan's early achievements would suggest great things and a continued path toward accomplishment, but Gladwell includes the anecdote of his game show appearance to undermine the notion that genius equals success. Using two questions from an IQ test, Gladwell introduces the idea of an IQ threshold to examine the the larger notion of intelligence and its limitations. Arguing that the measure of someone’s intelligence is only helpful up to a point, Gladwell uses examples of schools that Nobel laureates attended for undergraduate studies. Some, he points out, are elite institutions; others are not. Additionally, he points to success among graduates of the law school at the University of Michigan. There was no quantifiable difference in success post-graduation between white and POC students, some of whom were admitted under affirmative action with slightly lower undergraduate grades and standardized test scores. Reasonably, then, the level of intelligence beyond a certain point is moot. All of the students were intelligent enough to graduate, and beyond that, he argues, their intelligence predicted nothing.</p>
<p>Elements other than intelligence must contribute to success. Gladwell expands on his notion of an intelligence threshold and examines these other factors through an example of a question on a divergence test. Using examples of two students at an elite British school, Gladwell shows that the divergence test has no right answers, but instead looks for answers that demonstrate uniqueness and creativity. Intelligence matters, but so does imagination, creativity, and outside-the-box thinking. Gladwell circles back to Terman, reinforcing that the error when choosing his Termites was a focus on intelligence alone. He once again turns his attention to Chris Langan, foreshadowing that Langan’s story did not follow a direct line to achievement. Intelligence alone does not offer a certain path to success.</p>
<div class="info custom-block"><p class="custom-block-title">Reference</p>
<ul>
<li>“Outliers Chapter 3 Summary &amp; Analysis.” SparkNotes, www.sparknotes.com/lit/outliers/section3/. Accessed 27 Feb. 2023.</li>
</ul>
</div>
]]></description>
            <content:encoded><![CDATA[<h1 id="chapter-3-the-trouble-with-geniuses-part-1" tabindex="-1">Chapter 3: The Trouble with Geniuses, Part 1 <a class="header-anchor" href="#chapter-3-the-trouble-with-geniuses-part-1" aria-label="Permalink to &quot;Chapter 3: The Trouble with Geniuses, Part 1&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="summary-chapter-three-the-trouble-with-geniuses-part-1" tabindex="-1">Summary: Chapter Three: The Trouble with Geniuses, Part 1 <a class="header-anchor" href="#summary-chapter-three-the-trouble-with-geniuses-part-1" aria-label="Permalink to &quot;Summary: Chapter Three: The Trouble with Geniuses, Part 1&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="section-1" tabindex="-1">Section 1. <a class="header-anchor" href="#section-1" aria-label="Permalink to &quot;Section 1.&quot;">&ZeroWidthSpace;</a></h3>
<p>Chris Langan appeared on the television trivia show <em>1 vs. 100</em> after being the subject of interviews and at least one documentary, due to his extremely high IQ. He had little difficulty in high school, got a perfect score on his SAT, and read through <em>Principia Mathematica</em> as a teenager. On <em>1 vs. 100</em>, Langan cashed out with winnings of $250,000.</p>
<h3 id="section-2" tabindex="-1">Section 2. <a class="header-anchor" href="#section-2" aria-label="Permalink to &quot;Section 2.&quot;">&ZeroWidthSpace;</a></h3>
<p>Shortly after World War I, Lewis Terman, creator of the widely used Stanford-Binet IQ test, became fascinated with child prodigies. In 1921, he identified exceptionally gifted 1,470 students who came to be known as the “Termites.” Terman kept track of them over the years, carefully cataloging their educational achievement, marriages, psychological health, and employment. Terman was sure that the Termites would be the future elite of the United States. The same confidence underlies the use of IQ-like tests, such as the SAT, to assess applicants at Ivy League schools and corporations such as Microsoft and Google. Gladwell states that Terman was wrong about the Termites, and if he had met Chris Langan as a teenager, he would have been wrong about him, too.</p>
<h3 id="section-3" tabindex="-1">Section 3. <a class="header-anchor" href="#section-3" aria-label="Permalink to &quot;Section 3.&quot;">&ZeroWidthSpace;</a></h3>
<p>Gladwell gives two examples—one easy and one much harder—of questions that use visual puzzles to test IQ, without requiring any language abilities or specific factual knowledge. The average human will score 100. Those scoring below 70 are considered mentally disabled, and those who are successful in graduate programs likely have an IQ of 115 or higher. According to Gladwell, however, above 120 IQ makes little or no difference to success. A similar point applies to basketball: height is certainly an advantage, but there is, at best, modest value in being six foot seven instead of six foot six. A basketball player just needs to be tall <em>enough</em>.</p>
<p>A list of the last twenty-five Americans to win a Nobel Prize in Medicine includes graduates of prestigious schools, such as Columbia, Harvard, and MIT, but also graduates of DePauw, Holy Cross, and Gettysburg College. Similarly, there have been American Nobel laureates in Chemistry from Harvard and MIT, but also from Notre Dame and the University of Illinois. Harvard might have more intelligent students, but many other colleges have students smart <em>enough</em> to win a Nobel.</p>
<p>At the University of Michigan law school, around 10 percent of students are racial minorities. Without affirmative action, there would be less than 3 percent. Looking at career performance after graduation, Michigan found no difference between white and minority graduates. Minority students come into law school with weaker academic credentials than their white counterparts, but they are above the threshold required to be just as successful.</p>
<h3 id="section-4" tabindex="-1">Section 4. <a class="header-anchor" href="#section-4" aria-label="Permalink to &quot;Section 4.&quot;">&ZeroWidthSpace;</a></h3>
<p>Not all questions that test for intelligence have a single correct answer. A different sort of question might ask for a list of different uses for a brick, or a blanket. A question like this measures imagination and creativity. At a top British high school, one student lists more than ten uses, many of which are comical. Another student, a prodigy with one of the school’s highest IQs, lists just a few uses, all of which are practical. Compared to an IQ test, asking about different uses for a brick might be a better way to identify future Nobel Prize winners.</p>
<h3 id="section-5" tabindex="-1">Section 5. <a class="header-anchor" href="#section-5" aria-label="Permalink to &quot;Section 5.&quot;">&ZeroWidthSpace;</a></h3>
<p>Terman’s error was using intelligence alone to choose his Termites. While some of the Termites had successful careers, an unexpectedly high went on to careers that even Terman didn’t consider to be successful. The two students tested by Terman’s team who actually did go on to win Nobels were not selected as Termites: their IQs were too low. Terman eventually concluded that “intellect and achievement are far from perfectly correlated.”</p>
<p>Gladwell states that to understand Chris Langan’s prospects of becoming a “true outlier,” one must learn more about him.</p>
<h2 id="analysis-chapter-three-the-trouble-with-geniuses-part-1" tabindex="-1">Analysis: Chapter Three: The Trouble with Geniuses, Part 1 <a class="header-anchor" href="#analysis-chapter-three-the-trouble-with-geniuses-part-1" aria-label="Permalink to &quot;Analysis: Chapter Three: The Trouble with Geniuses, Part 1&quot;">&ZeroWidthSpace;</a></h2>
<p>Intelligence, Gladwell argues, does not equal success. He dedicates this chapter to the examination of geniuses. Comparing the young subjects of Lewis Terman to Chris Langan, Gladwell argues against Terman’s idea that genius is a key to societal advancement. Gladwell lists Langan’s early accomplishments as a shining example of Terman's idea, then swiftly undercuts expectations. Gladwell argues again that individuals do not succeed or fail solely on their own, but rather due to a constellation of factors, many of which are uncontrollable. Langan's early achievements would suggest great things and a continued path toward accomplishment, but Gladwell includes the anecdote of his game show appearance to undermine the notion that genius equals success. Using two questions from an IQ test, Gladwell introduces the idea of an IQ threshold to examine the the larger notion of intelligence and its limitations. Arguing that the measure of someone’s intelligence is only helpful up to a point, Gladwell uses examples of schools that Nobel laureates attended for undergraduate studies. Some, he points out, are elite institutions; others are not. Additionally, he points to success among graduates of the law school at the University of Michigan. There was no quantifiable difference in success post-graduation between white and POC students, some of whom were admitted under affirmative action with slightly lower undergraduate grades and standardized test scores. Reasonably, then, the level of intelligence beyond a certain point is moot. All of the students were intelligent enough to graduate, and beyond that, he argues, their intelligence predicted nothing.</p>
<p>Elements other than intelligence must contribute to success. Gladwell expands on his notion of an intelligence threshold and examines these other factors through an example of a question on a divergence test. Using examples of two students at an elite British school, Gladwell shows that the divergence test has no right answers, but instead looks for answers that demonstrate uniqueness and creativity. Intelligence matters, but so does imagination, creativity, and outside-the-box thinking. Gladwell circles back to Terman, reinforcing that the error when choosing his Termites was a focus on intelligence alone. He once again turns his attention to Chris Langan, foreshadowing that Langan’s story did not follow a direct line to achievement. Intelligence alone does not offer a certain path to success.</p>
<div class="info custom-block"><p class="custom-block-title">Reference</p>
<ul>
<li>“Outliers Chapter 3 Summary &amp; Analysis.” SparkNotes, www.sparknotes.com/lit/outliers/section3/. Accessed 27 Feb. 2023.</li>
</ul>
</div>
]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Chapter 4: The Trouble with Geniuses, Part 2]]></title>
            <link>https://note.toshiki.devsave/reading/outliers/4</link>
            <guid>https://note.toshiki.devsave/reading/outliers/4</guid>
            <pubDate>Thu, 01 Jul 2021 00:00:00 GMT</pubDate>
            <description><![CDATA[<h1 id="chapter-4-the-trouble-with-geniuses-part-2" tabindex="-1">Chapter 4: The Trouble with Geniuses, Part 2 <a class="header-anchor" href="#chapter-4-the-trouble-with-geniuses-part-2" aria-label="Permalink to &quot;Chapter 4: The Trouble with Geniuses, Part 2&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="summary-chapter-four-the-trouble-with-geniuses-part-2" tabindex="-1">Summary: Chapter Four: The Trouble with Geniuses, Part 2 <a class="header-anchor" href="#summary-chapter-four-the-trouble-with-geniuses-part-2" aria-label="Permalink to &quot;Summary: Chapter Four: The Trouble with Geniuses, Part 2&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="section-1" tabindex="-1">Section 1. <a class="header-anchor" href="#section-1" aria-label="Permalink to &quot;Section 1.&quot;">&ZeroWidthSpace;</a></h3>
<p>Chris Langan’s mother had four children, all from different fathers. Her first husband died in Mexico, the second was murdered, the third committed suicide, and the fourth was an abusive alcoholic. Langan says he has never met someone who grew up as impoverished as he and his brothers did. Attending Reed College, in Oregon, on a scholarship, he felt as though he did not belong with the rest of the students. When his mother neglected to fill out the financial aid forms, he lost his scholarship and dropped out. According to Langan, the school just did not care about their students. Later, Langan attended Montana State University in Bozeman but he dropped out when a dean refused Langan’s request to adjust his class schedule because of car trouble. He still has intellectual interests and has been working on a treatise called the “Cognitive Theoretic Model of the Universe.” When asked if, hypothetically, he would take a position at Harvard, he acknowledges the benefit of an environment with so much intellectual energy, but he worries about a lack of intellectual freedom.</p>
<h3 id="section-2" tabindex="-1">Section 2. <a class="header-anchor" href="#section-2" aria-label="Permalink to &quot;Section 2.&quot;">&ZeroWidthSpace;</a></h3>
<p>Gladwell points out the oddity of Langan’s experiences. Most colleges, especially small ones, try to accommodate student needs. Smart people take positions at places like Harvard instead of in the private sector precisely for the added intellectual freedom. Gladwell contrasts Langan’s story with Robert Oppenheimer’s. While at Cambridge, Oppenheimer became frustrated with his tutor and tried to poison him. After negotiations with the school administration, Oppenheimer was put on probation and assigned to a psychiatrist. Whereas Langan dropped out after his mother failed to fill out paperwork, Oppenheimer managed to stay in college after trying to kill someone. Later, Oppenheimer convinced General Leslie Groves to make Oppenheimer the scientific director of the Manhattan Project. Oppenheimer had the ability to persuade people, where Langan did not.</p>
<h3 id="section-3" tabindex="-1">Section 3. <a class="header-anchor" href="#section-3" aria-label="Permalink to &quot;Section 3.&quot;">&ZeroWidthSpace;</a></h3>
<p>Psychologist Robert Sternberg calls the ability to persuade someone “practical intelligence.” It involves knowing what to say, how to say it, and when. It requires an ability to read situations. Individuals can have either practical or analytical intelligence, or in the case of Oppenheimer, both. To understand where one obtains practical intelligence, Gladwell refers to a study conducted by Annette Lareau.</p>
<p>Lareau observed parenting strategies in both Black and white families from different socioeconomic strata. She found two distinct strategies: “concerted cultivation” and “accomplishment of natural growth.” Concerted cultivation, most common in middle-class and wealthier families, is defined by parents’ active promotion of their children’s talents and interests. Accomplishment of natural growth, most common in working-class or impoverished families, is defined by parents’ lack of interest or interaction in their children’s free time. Concerted cultivation, writes Gladwell, encourages children to seek opportunities for growth and to advocate for themselves. Accomplishment of natural growth leaves children unprepared to shape their environment for their own benefit. Concerted cultivation fosters an attitude better suited for success in the modern world.</p>
<h3 id="section-4" tabindex="-1">Section 4. <a class="header-anchor" href="#section-4" aria-label="Permalink to &quot;Section 4.&quot;">&ZeroWidthSpace;</a></h3>
<p>Oppenheimer was raised by affluent parents who sent him to a progressive private school and took an active interest in his hobbies.</p>
<ul>
<li><strong>Affluent</strong>: Having an abundant supply of money or possessions of value.</li>
</ul>
<p>By contrast, Chris Langan’s brother Mark states that as children, they learned to resent authority. Mark, too, was unable to obtain financial aid, because he had no knowledge of how the system worked. If Chris Langan had been raised in a family that valued education, he probably would have had more success.</p>
<h3 id="section-5" tabindex="-1">Section 5. <a class="header-anchor" href="#section-5" aria-label="Permalink to &quot;Section 5.&quot;">&ZeroWidthSpace;</a></h3>
<p>Once the Termites reached working adulthood, Terman grouped 730 of the males into three categories, based on their levels of success. The top 20 percent were upper-class professionals, while the bottom 20 percent had low-paying jobs or were unemployed. After analyzing the differences between the groups, Terman found that the bottom 20 percent came almost entirely from the lowest social and economic classes. What they lacked was “a community around them that prepared them properly for the world.”</p>
<h3 id="section-6" tabindex="-1">Section 6. <a class="header-anchor" href="#section-6" aria-label="Permalink to &quot;Section 6.&quot;">&ZeroWidthSpace;</a></h3>
<p>Chris Langan lives on a horse farm in Missouri, where he still writes. He is happily married and continues to read physics and philosophy. While he has spent decades on his writing, almost none of it has ever been published. Langan admits he has not tried to contact publishers or found an agent—and does not plan to. Chris Langan did not have the support necessary to meet success. Gladwell points that no one ever makes it alone, regardless of if they are successful musicians, athletes, tech billionaires, or geniuses.</p>
<h2 id="analysis-chapter-four-the-trouble-with-geniuses-part-2" tabindex="-1">Analysis: Chapter Four: The Trouble with Geniuses, Part 2 <a class="header-anchor" href="#analysis-chapter-four-the-trouble-with-geniuses-part-2" aria-label="Permalink to &quot;Analysis: Chapter Four: The Trouble with Geniuses, Part 2&quot;">&ZeroWidthSpace;</a></h2>
<p><strong>Family background plays a crucial role in an individual’s success.</strong> While a genius like Chris Langan should thrive on a college campus, he drops out. <strong>Langan doesn’t struggle with academics, but with paperwork, procedures, and environment</strong>. Gladwell’s characterization of Langan almost makes him seem like two separate characters: a confident, genius game show contestant versus a child from a poor and troubled family. Langan may be a true outlier in the sense that he doesn’t seem to fit in academia or the working-class world.  Langan’s story is ironic. His brilliant mind should propel him to success. However, <strong>his story also perfectly proves Gladwell’s point that brainpower alone does not lead to success.</strong> The author delves deeper into the <strong>irony</strong> of Langan’s situation by comparing him to Robert Oppenheimer, who worked on the nuclear bomb during World War II. Like Langan, Oppenheimer possesses great intelligence. <strong>Unlike Langan, Oppenheimer has an understanding that allows him to navigate the world effectively. Oppenheimer knows how to combat challenges, where Langan gets bested by a financial aid problem and class schedule.</strong> <strong>Oppenheimer’s family background gave him the confidence to deal with authority while Langan’s upbringing created a distrust of authority.</strong> Without a family background that encourages success, intelligence is not enough.</p>
<div class="danger custom-block"><p class="custom-block-title">Contrast &amp; Comparison</p>
<p>Oppenheimer’s family background gave him the confidence to deal with authority while Langan’s upbringing created a distrust of authority.</p>
</div>
<p>The power of persuasion is an important factor that drives success. Gladwell notes that the power of persuasion is practical intelligence. He contrasts practical intelligence with analytical ability, noting that just because a person is smart does not mean they have practical intelligence. These two types of knowledge are not necessarily coeval. He reinforces this point with a return to the comparison of Langan and Oppenheimer. Both men are exceedingly intelligent, but Langan lacks the social savvy of practical intelligence. Gladwell suggests that individuals gain practical intelligence skills from their families, discussing a study by sociologist Annette Lareau to prove his point. Children from wealthier families learn how to interact with society in a way that drives achievement. Successful people have the power of persuasion and can convince others to see things from their point of view.</p>
<p>Success, then, depends on more than individual effort. Gladwell builds this argument by detailing the differences between Oppenheimer’s upbringing and Langan’s. Oppenheimer lived in an upper-class neighborhood with myriad advantages. He learned how to negotiate and stand up for himself. Langan’s family moved from place to place, struggling for jobs, money, food, and clothes, and Langan learned that he couldn’t rely on others. Gladwell's consideration of the Termites' success or struggles as adults supports his assertion that success is more than an individual effort; Gladwell states, “In the end, only one thing mattered: family background.” Terman’s findings and Gladwell’s conclusion do not mean that talented individuals from lower social and economic classes cannot have successful futures. To succeed, everyone needs help along the way, if not from family, then from a supportive community. Individuals do not achieve success solely on their own.</p>
<div class="info custom-block"><p class="custom-block-title">Reference</p>
<ul>
<li>“Outliers Chapter 4 Summary &amp; Analysis.” SparkNotes, www.sparknotes.com/lit/outliers/section4/.</li>
</ul>
</div>
]]></description>
            <content:encoded><![CDATA[<h1 id="chapter-4-the-trouble-with-geniuses-part-2" tabindex="-1">Chapter 4: The Trouble with Geniuses, Part 2 <a class="header-anchor" href="#chapter-4-the-trouble-with-geniuses-part-2" aria-label="Permalink to &quot;Chapter 4: The Trouble with Geniuses, Part 2&quot;">&ZeroWidthSpace;</a></h1>
<h2 id="summary-chapter-four-the-trouble-with-geniuses-part-2" tabindex="-1">Summary: Chapter Four: The Trouble with Geniuses, Part 2 <a class="header-anchor" href="#summary-chapter-four-the-trouble-with-geniuses-part-2" aria-label="Permalink to &quot;Summary: Chapter Four: The Trouble with Geniuses, Part 2&quot;">&ZeroWidthSpace;</a></h2>
<h3 id="section-1" tabindex="-1">Section 1. <a class="header-anchor" href="#section-1" aria-label="Permalink to &quot;Section 1.&quot;">&ZeroWidthSpace;</a></h3>
<p>Chris Langan’s mother had four children, all from different fathers. Her first husband died in Mexico, the second was murdered, the third committed suicide, and the fourth was an abusive alcoholic. Langan says he has never met someone who grew up as impoverished as he and his brothers did. Attending Reed College, in Oregon, on a scholarship, he felt as though he did not belong with the rest of the students. When his mother neglected to fill out the financial aid forms, he lost his scholarship and dropped out. According to Langan, the school just did not care about their students. Later, Langan attended Montana State University in Bozeman but he dropped out when a dean refused Langan’s request to adjust his class schedule because of car trouble. He still has intellectual interests and has been working on a treatise called the “Cognitive Theoretic Model of the Universe.” When asked if, hypothetically, he would take a position at Harvard, he acknowledges the benefit of an environment with so much intellectual energy, but he worries about a lack of intellectual freedom.</p>
<h3 id="section-2" tabindex="-1">Section 2. <a class="header-anchor" href="#section-2" aria-label="Permalink to &quot;Section 2.&quot;">&ZeroWidthSpace;</a></h3>
<p>Gladwell points out the oddity of Langan’s experiences. Most colleges, especially small ones, try to accommodate student needs. Smart people take positions at places like Harvard instead of in the private sector precisely for the added intellectual freedom. Gladwell contrasts Langan’s story with Robert Oppenheimer’s. While at Cambridge, Oppenheimer became frustrated with his tutor and tried to poison him. After negotiations with the school administration, Oppenheimer was put on probation and assigned to a psychiatrist. Whereas Langan dropped out after his mother failed to fill out paperwork, Oppenheimer managed to stay in college after trying to kill someone. Later, Oppenheimer convinced General Leslie Groves to make Oppenheimer the scientific director of the Manhattan Project. Oppenheimer had the ability to persuade people, where Langan did not.</p>
<h3 id="section-3" tabindex="-1">Section 3. <a class="header-anchor" href="#section-3" aria-label="Permalink to &quot;Section 3.&quot;">&ZeroWidthSpace;</a></h3>
<p>Psychologist Robert Sternberg calls the ability to persuade someone “practical intelligence.” It involves knowing what to say, how to say it, and when. It requires an ability to read situations. Individuals can have either practical or analytical intelligence, or in the case of Oppenheimer, both. To understand where one obtains practical intelligence, Gladwell refers to a study conducted by Annette Lareau.</p>
<p>Lareau observed parenting strategies in both Black and white families from different socioeconomic strata. She found two distinct strategies: “concerted cultivation” and “accomplishment of natural growth.” Concerted cultivation, most common in middle-class and wealthier families, is defined by parents’ active promotion of their children’s talents and interests. Accomplishment of natural growth, most common in working-class or impoverished families, is defined by parents’ lack of interest or interaction in their children’s free time. Concerted cultivation, writes Gladwell, encourages children to seek opportunities for growth and to advocate for themselves. Accomplishment of natural growth leaves children unprepared to shape their environment for their own benefit. Concerted cultivation fosters an attitude better suited for success in the modern world.</p>
<h3 id="section-4" tabindex="-1">Section 4. <a class="header-anchor" href="#section-4" aria-label="Permalink to &quot;Section 4.&quot;">&ZeroWidthSpace;</a></h3>
<p>Oppenheimer was raised by affluent parents who sent him to a progressive private school and took an active interest in his hobbies.</p>
<ul>
<li><strong>Affluent</strong>: Having an abundant supply of money or possessions of value.</li>
</ul>
<p>By contrast, Chris Langan’s brother Mark states that as children, they learned to resent authority. Mark, too, was unable to obtain financial aid, because he had no knowledge of how the system worked. If Chris Langan had been raised in a family that valued education, he probably would have had more success.</p>
<h3 id="section-5" tabindex="-1">Section 5. <a class="header-anchor" href="#section-5" aria-label="Permalink to &quot;Section 5.&quot;">&ZeroWidthSpace;</a></h3>
<p>Once the Termites reached working adulthood, Terman grouped 730 of the males into three categories, based on their levels of success. The top 20 percent were upper-class professionals, while the bottom 20 percent had low-paying jobs or were unemployed. After analyzing the differences between the groups, Terman found that the bottom 20 percent came almost entirely from the lowest social and economic classes. What they lacked was “a community around them that prepared them properly for the world.”</p>
<h3 id="section-6" tabindex="-1">Section 6. <a class="header-anchor" href="#section-6" aria-label="Permalink to &quot;Section 6.&quot;">&ZeroWidthSpace;</a></h3>
<p>Chris Langan lives on a horse farm in Missouri, where he still writes. He is happily married and continues to read physics and philosophy. While he has spent decades on his writing, almost none of it has ever been published. Langan admits he has not tried to contact publishers or found an agent—and does not plan to. Chris Langan did not have the support necessary to meet success. Gladwell points that no one ever makes it alone, regardless of if they are successful musicians, athletes, tech billionaires, or geniuses.</p>
<h2 id="analysis-chapter-four-the-trouble-with-geniuses-part-2" tabindex="-1">Analysis: Chapter Four: The Trouble with Geniuses, Part 2 <a class="header-anchor" href="#analysis-chapter-four-the-trouble-with-geniuses-part-2" aria-label="Permalink to &quot;Analysis: Chapter Four: The Trouble with Geniuses, Part 2&quot;">&ZeroWidthSpace;</a></h2>
<p><strong>Family background plays a crucial role in an individual’s success.</strong> While a genius like Chris Langan should thrive on a college campus, he drops out. <strong>Langan doesn’t struggle with academics, but with paperwork, procedures, and environment</strong>. Gladwell’s characterization of Langan almost makes him seem like two separate characters: a confident, genius game show contestant versus a child from a poor and troubled family. Langan may be a true outlier in the sense that he doesn’t seem to fit in academia or the working-class world.  Langan’s story is ironic. His brilliant mind should propel him to success. However, <strong>his story also perfectly proves Gladwell’s point that brainpower alone does not lead to success.</strong> The author delves deeper into the <strong>irony</strong> of Langan’s situation by comparing him to Robert Oppenheimer, who worked on the nuclear bomb during World War II. Like Langan, Oppenheimer possesses great intelligence. <strong>Unlike Langan, Oppenheimer has an understanding that allows him to navigate the world effectively. Oppenheimer knows how to combat challenges, where Langan gets bested by a financial aid problem and class schedule.</strong> <strong>Oppenheimer’s family background gave him the confidence to deal with authority while Langan’s upbringing created a distrust of authority.</strong> Without a family background that encourages success, intelligence is not enough.</p>
<div class="danger custom-block"><p class="custom-block-title">Contrast &amp; Comparison</p>
<p>Oppenheimer’s family background gave him the confidence to deal with authority while Langan’s upbringing created a distrust of authority.</p>
</div>
<p>The power of persuasion is an important factor that drives success. Gladwell notes that the power of persuasion is practical intelligence. He contrasts practical intelligence with analytical ability, noting that just because a person is smart does not mean they have practical intelligence. These two types of knowledge are not necessarily coeval. He reinforces this point with a return to the comparison of Langan and Oppenheimer. Both men are exceedingly intelligent, but Langan lacks the social savvy of practical intelligence. Gladwell suggests that individuals gain practical intelligence skills from their families, discussing a study by sociologist Annette Lareau to prove his point. Children from wealthier families learn how to interact with society in a way that drives achievement. Successful people have the power of persuasion and can convince others to see things from their point of view.</p>
<p>Success, then, depends on more than individual effort. Gladwell builds this argument by detailing the differences between Oppenheimer’s upbringing and Langan’s. Oppenheimer lived in an upper-class neighborhood with myriad advantages. He learned how to negotiate and stand up for himself. Langan’s family moved from place to place, struggling for jobs, money, food, and clothes, and Langan learned that he couldn’t rely on others. Gladwell's consideration of the Termites' success or struggles as adults supports his assertion that success is more than an individual effort; Gladwell states, “In the end, only one thing mattered: family background.” Terman’s findings and Gladwell’s conclusion do not mean that talented individuals from lower social and economic classes cannot have successful futures. To succeed, everyone needs help along the way, if not from family, then from a supportive community. Individuals do not achieve success solely on their own.</p>
<div class="info custom-block"><p class="custom-block-title">Reference</p>
<ul>
<li>“Outliers Chapter 4 Summary &amp; Analysis.” SparkNotes, www.sparknotes.com/lit/outliers/section4/.</li>
</ul>
</div>
]]></content:encoded>
        </item>
    </channel>
</rss>